Changeset 1523


Ignore:
Timestamp:
Jan 24, 2012, 3:34:18 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #349: Copy consent information to multiple cases

The personal information registration now checks if there is a case or blood sample with consent information and allows copying of that information to a new case.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp

    r1519 r1523  
    3030<script language="JavaScript">
    3131
    32 var debug = false;
     32var debug = true;
    3333var currentStep = 1;
    3434var pnrIsValid = false;
     
    4343var bloodInfo = null;
    4444
     45var copyConsentEnabled = false;
     46
    4547function init()
    4648{
     
    248250  setInputStatus('laterality', updateMode && numCases > 1 ? 'NOTE! Some alternatives may be missing if there is another case for the patient.' : '', 'valid');
    249251  lateralityIsValid = true;
    250  
     252   
    251253  var laterality = selectedLaterality.value;
    252254  if (laterality.match(/\d+/))
     
    267269    laterality = null;
    268270  }
     271 
     272  // If the selected laterality/case is not the same as the other case with consent enable the copy consent option
     273  Main.showHide('copyConsentSection', copyConsentEnabled && selectedLaterality.value != frm.copyConsent.value);
    269274   
    270275  // No specimen tubes?
     
    672677        cases += ' onclick="lateralityOnChange()"><label for="lateralityUnknown"><i>unknown laterality</i> [<i>new case</i>]</label><br>';
    673678      }
     679     
     680      if (!updateMode && patientInfo.cases[0].consent)
     681      {
     682        var c = patientInfo.cases[0];
     683        var html = "From case '" + c.name;
     684        html += "' (" + c.consent;
     685        if (c.consentDate) html += '; ' + c.consentDate;
     686        html += ')';
     687        setInnerHTML('copyConsent.text', html);
     688        frm.copyConsent.value = patientInfo.cases[0].id;
     689        copyConsentEnabled = true;
     690      }
     691     
    674692    }
    675693   
     
    697715    setInnerHTML('laterality.input', cases);
    698716  }
     717 
     718  // Check the blood registration for consent information
     719  if (!copyConsentEnabled && bloodInfo && bloodInfo.consent)
     720  {
     721    var html = "From blood '" + bloodInfo.name;
     722    html += "' (" + bloodInfo.consent;
     723    if (bloodInfo.consentDate) html += '; ' + bloodInfo.consentDate;
     724    html += ')';
     725    setInnerHTML('copyConsent.text', html);
     726    frm.copyConsent.value = bloodInfo.id;
     727    copyConsentEnabled = true;
     728  }
     729
     730 
    699731  lateralityOnChange();
    700732
     
    726758  caseInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value);
    727759  caseInfo.rnaLaterDate = Main.trimString(frm.rnaLaterDate.value + ' ' + frm.rnaLaterTime.value);
     760  if (frm.copyConsent.checked && frm.copyConsent.value)
     761  {
     762    caseInfo.copyConsent = parseInt(frm.copyConsent.value);
     763  }
    728764
    729765  for (var i = 0; i < frm.laterality.length; i++)
     
    737773  frm.rnaLaterDate.disabled = true;
    738774  frm.rnaLaterTime.disabled = true;
     775  frm.copyConsent.disabled = true;
    739776
    740777  var updateMode = caseInfo.id && caseInfo.patient;
     
    744781
    745782  if (debug) Main.debug(JSON.stringify(submitInfo));
    746  
     783
    747784  var request = Ajax.getXmlHttpRequest();
    748785  var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=';
     
    943980        <td class="help"><span id="laterality.message" class="message" style="display: none;"></span></td>
    944981      </tr>
     982      <tr id="copyConsentSection" style="display: none;">
     983        <td class="prompt">Copy consent?</td>
     984        <td class="input">
     985          <input type="checkbox" name="copyConsent" id="copyConsent" value="" checked>
     986          <label for="copyConsent"><span id="copyConsent.text"></span></label>
     987        </td>
     988        <td class="status" id="copyConsent.status"></td>
     989        <td class="help"></td>
     990      </tr>
    945991      <tr id="padSection" valign="top">
    946992        <td class="prompt">PAD</td>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1519 r1523  
    4141
    4242  private static final long serialVersionUID = 8770173686061080429L;
    43 
     43  private final DateToStringConverter dateTimeConverter;
     44  private final DateToStringConverter dateConverter;
     45 
    4446  public PersonalRegistrationServlet()
    45   {}
     47  {
     48    dateTimeConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
     49    dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd"));
     50  }
    4651
    4752  @SuppressWarnings("unchecked")
     
    126131          // Check that the registration is not prohibited
    127132          blood.verifyConsent(dc, null);
    128 
     133          blood.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null);
     134          blood.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter);
     135         
    129136          // Wrap what we have so far up into JSON objects
    130137          jsonBlood = blood.asJSONObject();
     
    147154          AnnotationType samplingDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_SAMPLING_DATETIME, true);
    148155          AnnotationType rnaLaterDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_RNALATER_DATETIME, true);
    149           DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd HHmm"));
    150156          for (SpecimenTube tube : specimenTubes)
    151157          {
    152158            tube.loadAnnotations("pad", padType, null);
    153159            tube.loadAnnotations("laterality", lateralityType, null);
    154             tube.loadAnnotations("samplingDate", samplingDateType, dateConverter);
    155             tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, dateConverter);
     160            tube.loadAnnotations("samplingDate", samplingDateType, dateTimeConverter);
     161            tube.loadAnnotations("rnaLaterDate", rnaLaterDateType, dateTimeConverter);
    156162            jsonTubes.add(tube.asJSONObject());
    157163          }
     
    199205            {
    200206              c.loadAnnotations("laterality", lateralityType, null);
     207              c.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null);
     208              c.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter);
    201209              jsonCases.add(c.asJSONObject());
    202210            }
     
    293301          {
    294302            // Remove the pre-registered case but copy consent information first
    295             AnnotationType consentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT, true);
    296             AnnotationType consentDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT_DATE, true);
    297            
    298303            Sample preCase = Sample.getById(dc, preCaseId.intValue());
    299             Reggie.copyAnnotationValues(preCase, theCase, consentType, false);
    300             Reggie.copyAnnotationValues(preCase, theCase, consentDateType, false);
     304            copyConsentAnnotations(dc, preCase, theCase);
    301305            dc.deleteItem(preCase);
    302306          }
     
    324328          }
    325329          theCase.getCreationEvent().setSource(patient);
     330         
     331          Number copyConsentId = (Number)jsonCase.get("copyConsent");
     332          if (copyConsentId != null)
     333          {
     334            Sample consentCase = Sample.getById(dc, copyConsentId.intValue());
     335            copyConsentAnnotations(dc, consentCase, theCase);
     336          }
     337         
    326338          jsonMessages.add("Case '" + originalCaseName + "' created successfully.");
    327339        }
     
    518530  }
    519531 
    520  
     532  private void copyConsentAnnotations(DbControl dc, Sample from, Sample to)
     533  {
     534    AnnotationType consentType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT, true);
     535    AnnotationType consentDateType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_CONSENT_DATE, true);
     536   
     537    Reggie.copyAnnotationValues(from, to, consentType, false);
     538    Reggie.copyAnnotationValues(from, to, consentDateType, false);
     539  }
    521540}
Note: See TracChangeset for help on using the changeset viewer.