Changeset 1317


Ignore:
Timestamp:
Mar 18, 2011, 11:01:19 AM (11 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #299: Add field for PAD when no specimen tubes exists for a case

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

Legend:

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

    r1311 r1317  
    309309  var hasUnknownSpecimen = false;
    310310  var thisCaseLaterality = null;
     311  var hasPAD = false;
    311312  if (caseInfo.specimen && caseInfo.specimen.length > 0)
    312313  {
     
    317318      var specimen = caseInfo.specimen[i];
    318319      specimenTubes += specimen.name;
     320      if (specimen.pad) hasPAD = true;
    319321      if (specimen.laterality)
    320322      {
     
    346348  }
    347349
     350  Main.showHide('padSection', !hasPAD);
     351 
    348352  Main.show('caseSection');
    349353 
     
    431435  caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value;
    432436  caseInfo.reasonIfNoSpecimen = frm.reasonIfNoSpecimen.value;
     437  caseInfo.pad = frm.pad.value;
    433438
    434439  for (var i = 0; i < frm.laterality.length; i++)
     
    437442  }
    438443  frm.reasonIfNoSpecimen.disabled = true;
     444  frm.pad.disabled = true;
    439445
    440446  var submitInfo = new Object();
     
    442448  submitInfo.caseInfo = caseInfo;
    443449
     450  //setInnerHTML('debug', JSON.stringify(submitInfo));
     451 
    444452  var request = Ajax.getXmlHttpRequest();
    445453  var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=Create';
     
    782790        <td class="help"><span id="specimenTubes.message" class="message" style="display: none;"></span>The specimen tube(s) associated with this case.</td>
    783791      </tr>
     792      <tr id="padSection" valign="top">
     793        <td class="prompt">PAD</td>
     794        <td class="input"><input type="text" name="pad"
     795          value="" size="35" maxlength="255"
     796          onkeypress="focusOnEnter(event, 'reasonIfNoSpecimen')"></td>
     797        <td class="status"></td>
     798        <td class="help"></td>
     799      </tr>
    784800      <tr id="reasonIfNoSpecimenSection" valign="top">
    785801        <td class="prompt">Reason if no specimen</td>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1307 r1317  
    7272        AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true);
    7373        AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true);
     74        AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true);
    7475       
    7576        String pnr = req.getParameter("personalNumber");
     
    168169          jsonSpecimen.put("name", specimen.getName());
    169170          jsonSpecimen.put("laterality", Reggie.getAnnotationValue(specimen, lateralityType));
     171          jsonSpecimen.put("pad", Reggie.getAnnotationValue(specimen, padType));
    170172          jsonSpecimens.add(jsonSpecimen);
    171173        }
     
    285287        AnnotationSet caseAnnotations = theCase.getAnnotationSet();
    286288        JSONArray jsonSpecimen = (JSONArray)jsonCase.get("specimen");
     289        AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true);
     290        AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true);
     291        // Get existing PADcase annotations
     292        List padCase = new ArrayList();
     293        if (caseAnnotations.hasAnnotation(padCaseType))
     294        {
     295          padCase.addAll(caseAnnotations.getAnnotation(padCaseType).getValues());
     296        }
     297        int numOriginalPADCaseValues = padCase.size();
     298        String pad = Values.getStringOrNull((String)jsonCase.get("pad"));
     299        if (pad != null && !padCase.contains(pad)) padCase.add(pad);
    287300        if (jsonSpecimen != null && jsonSpecimen.size() > 0)
    288301        {
    289           AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true);
    290           AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true);
    291           List padCase = new ArrayList();
    292           if (caseAnnotations.hasAnnotation(padCaseType))
    293           {
    294             padCase.addAll(caseAnnotations.getAnnotation(padCaseType).getValues());
    295           }
    296302          for (int i = 0; i < jsonSpecimen.size(); ++i)
    297303          {
     
    302308            specimen.getCreationEvent().addSource(theCase, null);
    303309            // Copy PAD annotation on specimen to PADcase annotation on case
    304             String pad = (String)Reggie.getAnnotationValue(specimen, padType);
     310            pad = (String)Reggie.getAnnotationValue(specimen, padType);
    305311            if (pad != null && !padCase.contains(pad)) padCase.add(pad);
    306312            // Set laterality on the specimen tube if it is missing
     
    316322           
    317323          }
    318           if (padCase.size() > 0) caseAnnotations.getAnnotation(padCaseType).setValues(padCase);
    319324          jsonMessages.add(jsonSpecimen.size() + " specimen tube(s) linked with case '" + theCase.getName() + "' successfully.");
    320325        }
     
    327332          reasonIfNoSpecimen.setValues(values);
    328333        }
     334        if (padCase.size() > numOriginalPADCaseValues)
     335        {
     336          caseAnnotations.getAnnotation(padCaseType).setValues(padCase);
     337        }
    329338       
    330339        dc.commit();
Note: See TracChangeset for help on using the changeset viewer.