Changeset 1289


Ignore:
Timestamp:
Feb 14, 2011, 3:20:00 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #291: Personal information registration

Copy PAD annotations to PADcase. Display more specimen information in the third step of the registration. Automatic selection of laterality if it is present on the specimen. More error handling in case no specimen is found.

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

Legend:

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

    r1286 r1289  
    101101}
    102102
     103function allFirstNamesOnKeyPress(event)
     104{
     105  if (event.keyCode == 9) setTimeout('goNext()', 200);
     106  return true;
     107}
     108
    103109function gotoStep2()
    104110{
     
    155161  // Check entered case and pnr with AJAX
    156162  var frm = document.forms['reggie'];
    157   if (frm.familyName)
    158   {
    159     // Check form
     163  if (frm.patientCode)
     164  {
     165    var formOk = true;
     166    // Validate 'New patient' form
     167    if (frm.allFirstNames.value == '')
     168    {
     169      setInputStatus('allFirstNames', 'Missing', false);
     170      frm.allFirstNames.focus();
     171      formOk = false;
     172    }
     173    else
     174    {
     175      setInputStatus('allFirstNames', '', true);
     176    }
     177   
     178    if (frm.familyName.value == '')
     179    {
     180      setInputStatus('familyName', 'Missing', false);
     181      frm.familyName.focus();
     182      formOk = false;
     183    }
     184    else
     185    {
     186      setInputStatus('familyName', '', true);
     187    }
     188
     189   
     190    if (frm.patientCode.value == '')
     191    {
     192      setInputStatus('patientCode', 'Missing', false);
     193      frm.patientCode.focus();
     194      formOk = false;
     195    }
     196    else
     197    {
     198      setInputStatus('patientCode', '', true);
     199    }
     200    if (!formOk) return;
    160201  }
    161202 
     
    175216  }
    176217 
    177   if (!caseInfo.specimen || caseInfo.specimen.length == 0)
    178   {
    179     Main.show('reasonIfNoSpecimenSection');
     218  if (caseInfo.specimen && caseInfo.specimen.length > 0)
     219  {
     220    var specimenTubes = '';
     221    Main.hide('reasonIfNoSpecimenSection');
     222    for (var i = 0; i < caseInfo.specimen.length; i++)
     223    {
     224      var specimen = caseInfo.specimen[i];
     225      specimenTubes += specimen.name ;
     226      if (specimen.laterality)
     227      {
     228        specimenTubes += ' ('+specimen.laterality + ')';
     229        Forms.checkRadio(frm.laterality, specimen.laterality);
     230      }
     231      specimenTubes += '<br>';
     232    }
     233    setInnerHTML('specimenTubes', specimenTubes);
    180234  }
    181235 
     
    194248  submitInfo.patientInfo = patientInfo;
    195249  submitInfo.caseInfo = caseInfo;
    196   alert(JSON.stringify(submitInfo));
     250  //alert(JSON.stringify(submitInfo));
    197251
    198252  var request = Ajax.getXmlHttpRequest();
     
    220274 
    221275  setInnerHTML(prefix + '.message', message);
     276  if (message)
     277  {
     278    Main.showInline(prefix + '.message');
     279  }
     280  else
     281  {
     282    Main.hide(prefix + '.message');
     283  }
    222284}
    223285
     
    227289  Main.show('errorMessage');
    228290  Main.hide('gonext');
     291  Main.show('gorestart');
     292}
     293
     294function goRestart()
     295{
     296  location.href = location.href;
    229297}
    230298</script>
     
    233301.stepform
    234302{
     303  margin-left: 20px;
    235304  border: 1px solid #999999;
    236305  width: 800px;
     
    283352.input
    284353{
    285   width: 150px;
     354  width: 250px;
    286355  padding: 1px 2px 1px 2px;
    287356}
     
    296365{
    297366  background: #e0e0e0;
    298   width: 400px;
     367  width: 350px;
    299368  font-style: italic;
    300369  padding: 1px 2px 1px 2px;
     
    321390<base:body>
    322391
    323   <p:path>
     392  <p:path style="margin-top: 20px; margin-bottom: 10px;">
    324393    <p:pathelement title="Reggie" href="<%="index.jsp?ID="+ID%>" />
    325394    <p:pathelement title="Personal information registration" />
     
    340409        <td class="prompt">Case Name</td>
    341410        <td class="input"><input type="text" name="caseName"
    342           size="15" maxlength="12" onblur="caseNameOnChange()"></td>
     411          size="18" maxlength="12" onblur="caseNameOnChange()"></td>
    343412        <td class="status" id="case.status"></td>
    344         <td class="help"><span id="case.message" class="message"></span>The case (barcode) associated with this patient.</td>
     413        <td class="help"><span id="case.message" class="message" style="display: none;"></span>The case (barcode) associated with this patient.</td>
    345414      </tr>
    346415      <tr>
    347416        <td class="prompt">Personal Number</td>
    348417        <td class="input"><input type="text" name="personalNumber"
    349           size="15" maxlength="12" onkeyup="personalNumberOnChange()"></td>
     418          size="18" maxlength="12" onkeyup="personalNumberOnChange()"></td>
    350419        <td class="status" id="pnr.status"></td>
    351         <td class="help"><span id="pnr.message" class="message"></span>(YYYYMMDDZZZZ)</td>
     420        <td class="help"><span id="pnr.message" class="message" style="display: none;"></span>(YYYYMMDDZZZZ)</td>
    352421      </tr>
    353422      </table>
     
    369438      <tr>
    370439        <td class="prompt">Patient code</td>
    371         <td class="input"><input type="text" name="patientCode" value="" size="12" maxlength="12"></td>
    372         <td class="status"></td>
    373         <td class="help"></td>
    374       </tr>
    375       <tr>
     440        <td class="input"><input type="text" name="patientCode" value="" size="18" maxlength="12"></td>
     441        <td class="status" id="patientCode.status"></td>
     442        <td class="help"><span id="patientCode.message" class="message" style="display: none;"></span></td>
     443      </tr>
     444      <tr valign="top">
    376445        <td class="prompt">Family name</td>
    377446        <td class="input"><input type="text" name="familyName"
    378           size="30" maxlength="255"></td>
    379         <td class="status"></td>
    380         <td class="help">Keep hyphens, keep åäö, replace all special accented letters [e.g. éèü etc] with standard alphabet character.</td>
    381       </tr>
    382       <tr>
     447          size="35" maxlength="255"></td>
     448        <td class="status" id="familyName.status"></td>
     449        <td class="help"><span id="familyName.message" class="message" style="display: none;"></span>Keep hyphens, keep åäö, replace all special accented letters [e.g. éèü etc] with standard alphabet character.</td>
     450      </tr>
     451      <tr valign="top">
    383452        <td class="prompt">All first names</td>
    384453        <td class="input"><input type="text" name="allFirstNames"
    385           size="30" maxlength="255"></td>
    386         <td class="status"></td>
    387         <td class="help">Type all names, see FamilyName comment on valid characters.</td>
     454          size="35" maxlength="255" onkeypress="allFirstNamesOnKeyPress(event)"></td>
     455        <td class="status" id="allFirstNames.status"></td>
     456        <td class="help"><span id="allFirstNames.message" class="message" style="display: none;"></span>Type all names, see FamilyName comment on valid characters.</td>
    388457      </tr>
    389458      <tr>
     
    473542        <td class="help"></td>
    474543      </tr>
    475       <tr id="reasonIfNoSpecimenSection" style="display: none;">
     544      <tr valign="top">
     545        <td class="prompt">Specimen tubes</td>
     546        <td class="input" id="specimenTubes">not found</td>
     547        <td class="status"></td>
     548        <td class="help">The specimen tube(s) associated with this case.</td>
     549      </tr>
     550       
     551      <tr id="reasonIfNoSpecimenSection" valign="top">
    476552        <td class="prompt">Reason if no specimen</td>
    477         <td class="input"><input type="text" name="reasonIfNoSpecimen" value="" size="30" maxlength="200"></td>
    478         <td class="status"></td>
    479         <td class="help"></td>
     553        <td class="input"><textarea rows="3" cols="30" name="reasonIfNoSpecimen" value=""></textarea></td>
     554        <td class="status"></td>
     555        <td class="help">Comment why there was no specimen tubes in the delivery.</td>
    480556      </tr>
    481557      </table>
     
    485561  </div>
    486562
    487   <div class="error" id="errorMessage" style="display: none; width: 800px;">
    488   </div>
    489 
    490   <table>
     563  <div class="error" id="errorMessage" style="display: none; width: 800px; margin-left: 20px; margin-bottom: 0px;"></div>
     564
     565  <table style="margin-left: 20px; margin-top: 10px;">
    491566    <tr><td><base:button id="gonext" title="Next" image="gonext.gif" onclick="goNext()"/></td></tr>
    492567    <tr><td><base:button id="gocreate" title="Create" image="gonext.gif" onclick="goCreate()" style="display: none;"/></td></tr>
     568    <tr><td><base:button id="gorestart" title="Restart" image="goback.gif" onclick="goRestart()" style="display: none;"/></td></tr>
    493569  </table>
    494570  </form>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1286 r1289  
    1515import org.json.simple.parser.JSONParser;
    1616
    17 import net.sf.basedb.clients.web.Base;
    1817import net.sf.basedb.core.Annotation;
    1918import net.sf.basedb.core.AnnotationSet;
     
    3635import net.sf.basedb.reggie.Reggie;
    3736import net.sf.basedb.util.MD5;
    38 import net.sf.basedb.util.Values;
    3937import net.sf.basedb.util.error.ThrowableUtil;
    4038import net.sf.basedb.util.formatter.DateFormatter;
    41 import net.sf.basedb.util.formatter.NumberFormatter;
    4239
    4340
     
    4542  extends HttpServlet
    4643{
     44
     45  private static final long serialVersionUID = 8770173686061080429L;
    4746
    4847  public PersonalRegistrationServlet()
     
    7170        dc = sc.newDbControl();
    7271        AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true);
     72        AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true);
    7373       
    7474        String pnr = req.getParameter("personalNumber");
     
    9696          AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_GENDER, true);
    9797          AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_DATE_OF_BIRTH, true);
    98           AnnotationType lateralityType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_LATERALITY, true);
    9998          DateFormatter df = new DateFormatter("yyyy-MM-dd");
    10099          BioSource bs = patients.get(0);
     
    106105          jsonPat.put("dateOfBirth", df.format((Date)Reggie.getAnnotationValue(bs, dateOfBirthType)));
    107106         
    108           // Find cases
     107          // Find existing cases for the patient
    109108          ItemQuery<Sample> caseQuery = bs.getSamples();
    110109          caseQuery.include(Include.ALL);
     
    167166          jsonSpecimen.put("id", specimen.getId());
    168167          jsonSpecimen.put("name", specimen.getName());
     168          jsonSpecimen.put("laterality", Reggie.getAnnotationValue(specimen, lateralityType));
    169169          jsonSpecimens.add(jsonSpecimen);
    170170        }
     
    257257       
    258258        // Link the case with specimen
    259         JSONArray specimen = (JSONArray)jsonCase.get("specimen");
    260         if (specimen != null && specimen.size() > 0)
    261         {
    262           for (int i = 0; i < specimen.size(); ++i)
     259        JSONArray jsonSpecimen = (JSONArray)jsonCase.get("specimen");
     260        if (jsonSpecimen != null && jsonSpecimen.size() > 0)
     261        {
     262          AnnotationType padType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD, true);
     263          AnnotationType padCaseType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_PAD_CASE, true);
     264          List padCase = new ArrayList(as.getAnnotation(padCaseType).getValues());
     265          for (int i = 0; i < jsonSpecimen.size(); ++i)
    263266          {
    264             JSONObject jsonSpec = (JSONObject)specimen.get(i);
    265             Sample s = Sample.getById(dc, ((Long)jsonSpec.get("id")).intValue());
    266             s.setPooled(true);
    267             s.getCreationEvent().addSource(cse, null);
     267            JSONObject jsonSpec = (JSONObject)jsonSpecimen.get(i);
     268            Sample specimen = Sample.getById(dc, ((Long)jsonSpec.get("id")).intValue());
     269            specimen.setPooled(true);
     270            specimen.getCreationEvent().addSource(cse, null);
     271            String pad = (String)Reggie.getAnnotationValue(specimen, padType);
     272            if (pad != null && !padCase.contains(pad)) padCase.add(pad);
    268273          }
     274          as.getAnnotation(padCaseType).setValues(padCase);
    269275        }
    270276        else
Note: See TracChangeset for help on using the changeset viewer.