Ignore:
Timestamp:
Feb 8, 2011, 2:51:55 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #291: Personal information registration

If one is careful it is now possible to register new patients and cases. Error handling is not fully working and may result in corrupted data. Several use cases are still not supported.

File:
1 edited

Legend:

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

    r1283 r1286  
    3030var caseIsValid = false;
    3131
     32var patientInfo = null;
     33var caseInfo = null;
     34
    3235function goNext()
    3336{
     
    3538  {
    3639    if (pnrIsValid && caseIsValid) gotoStep2();
     40  }
     41  else if (currentStep == 2)
     42  {
     43    gotoStep3();
    3744  }
    3845}
     
    103110 
    104111  var pnr = frm.personalNumber.value;
     112  var caseName = frm.caseName.value;
    105113  var request = Ajax.getXmlHttpRequest();
    106   var url = 'Ajax.servlet?ID=<%=ID%>&cmd=FindPatientByPersonalNumber&personalNumber=' + pnr;
     114  var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=CheckPersonalNumberAndCaseName';
     115  url += '&personalNumber=' + pnr;
     116  url += '&caseName=' + caseName;
    107117  request.open("GET", url, false);
    108118  request.send(null);
     
    118128 
    119129  // Get biosource information from the AJAX response
    120   var patientInfo = response.patient;
    121  
    122   if (!patientInfo)
     130  patientInfo = response.patientInfo;
     131  caseInfo = response.caseInfo;
     132 
     133  if (!patientInfo.id)
    123134  {
    124135    Main.show('newPatientSection');
    125     frm.patientCode.value=response.nextPatientCode;
    126     setInnerHTML('new.dateOfBirth', pnr.substr(0,4) + '-' + pnr.substr(4,2)+'-'+pnr.substr(6,2));
    127     setInnerHTML('new.gender', parseInt(pnr.substr(10,1)) % 2 == 0 ? 'F' : 'M');
     136    frm.patientCode.value=patientInfo.name;
     137    setInnerHTML('new.dateOfBirth', patientInfo.dateOfBirth);
     138    setInnerHTML('new.gender', patientInfo.gender);
    128139    frm.familyName.focus();
    129140  }
     
    139150  }
    140151}
     152
     153function gotoStep3()
     154{
     155  // Check entered case and pnr with AJAX
     156  var frm = document.forms['reggie'];
     157  if (frm.familyName)
     158  {
     159    // Check form
     160  }
     161 
     162  currentStep = 3;
     163  if (!patientInfo.id)
     164  {
     165    frm.patientCode.disabled = true;
     166    frm.familyName.disabled = true;
     167    frm.allFirstNames.disabled = true;
     168    patientInfo.familyName = frm.familyName.value;
     169    patientInfo.allFirstNames = frm.allFirstNames.value;
     170  }
     171 
     172  if (!patientInfo.cases || patientInfo.cases.length == 0)
     173  {
     174    Main.show('newCaseSection'); 
     175  }
     176 
     177  if (!caseInfo.specimen || caseInfo.specimen.length == 0)
     178  {
     179    Main.show('reasonIfNoSpecimenSection');
     180  }
     181 
     182  Main.hide('gonext');
     183  Main.show('gocreate');
     184}
     185
     186function goCreate()
     187{
     188  var frm = document.forms['reggie'];
     189
     190  caseInfo.laterality = Forms.getCheckedRadio(frm.laterality).value;
     191  caseInfo.reasonIfNoSpecimen = frm.reasonIfNoSpecimen.value;
     192 
     193  var submitInfo = new Object();
     194  submitInfo.patientInfo = patientInfo;
     195  submitInfo.caseInfo = caseInfo;
     196  alert(JSON.stringify(submitInfo));
     197
     198  var request = Ajax.getXmlHttpRequest();
     199  var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=Create';
     200  request.open("POST", url, false);
     201  request.setRequestHeader("Content-Type", "application/json");
     202  request.send(JSON.stringify(submitInfo));
     203
     204  setInnerHTML('debug', request.responseText);
     205}
     206
    141207
    142208function setInnerHTML(id, html)
     
    302368      <table border="0" cellspacing="0" cellpadding="0" width="100%">
    303369      <tr>
    304         <td class="prompt">Patient cumber</td>
     370        <td class="prompt">Patient code</td>
    305371        <td class="input"><input type="text" name="patientCode" value="" size="12" maxlength="12"></td>
    306372        <td class="status"></td>
     
    386452  </div>
    387453
     454
     455  <!-- 3. New case registration -->
     456  <div id="newCaseSection" style="display: none;">
     457  <p>
     458  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
     459  <tr>
     460    <td rowspan="2" class="stepno">3</td>
     461    <td class="steptitle">New case: Enter information</td>
     462  </tr>
     463  <tr>
     464    <td class="stepfields">
     465      <table border="0" cellspacing="0" cellpadding="0" width="100%">
     466      <tr>
     467        <td class="prompt">Laterality</td>
     468        <td class="input">
     469          <input type="radio" name="laterality" value="LEFT">LEFT
     470          <input type="radio" name="laterality" value="RIGHT">RIGHT
     471        </td>
     472        <td class="status"></td>
     473        <td class="help"></td>
     474      </tr>
     475      <tr id="reasonIfNoSpecimenSection" style="display: none;">
     476        <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>
     480      </tr>
     481      </table>
     482    </td>
     483  </tr>
     484  </table>
     485  </div>
     486
    388487  <div class="error" id="errorMessage" style="display: none; width: 800px;">
    389488  </div>
     
    391490  <table>
    392491    <tr><td><base:button id="gonext" title="Next" image="gonext.gif" onclick="goNext()"/></td></tr>
    393   </table> 
    394 
     492    <tr><td><base:button id="gocreate" title="Create" image="gonext.gif" onclick="goCreate()" style="display: none;"/></td></tr>
     493  </table>
    395494  </form>
    396495
Note: See TracChangeset for help on using the changeset viewer.