Changeset 1518


Ignore:
Timestamp:
Jan 23, 2012, 11:39:49 AM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #350: Blood referral form registration wizard

There is now support for creating and updating 'Blood' samples. If there is already patient information for the case it is loaded automatically.

The personal information registration wizard has been updated to also check for blood registration.

Thus, it should now work to use both wizards in any order. Consent information is still not considered.

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

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/META-INF/servlets.xml

    r1472 r1518  
    1212    <servlet-name>ReferralForm</servlet-name>
    1313    <servlet-class>net.sf.basedb.reggie.servlet.ReferralFormServlet</servlet-class>
     14  </servlet>
     15  <servlet>
     16    <servlet-name>BloodRegistration</servlet-name>
     17    <servlet-class>net.sf.basedb.reggie.servlet.BloodRegistrationServlet</servlet-class>
    1418  </servlet>
    1519  <servlet>
  • extensions/net.sf.basedb.reggie/trunk/resources/bloodform.jsp

    r1517 r1518  
    3030<script language="JavaScript">
    3131
    32 var debug = false;
     32var debug = true;
    3333var currentStep = 1;
    3434var pnrIsValid = false;
     
    3939
    4040var patientInfo = null;
    41 var caseInfo = null;
     41var bloodInfo = null;
    4242
    4343function init()
     
    156156  caseIsValid = true;
    157157 
    158   getCaseInfo();
     158  getBloodInfo();
    159159}
    160160
     
    303303}
    304304
    305 function getCaseInfo()
     305function getBloodInfo()
    306306{
    307307  // Check entered case and pnr with AJAX
     
    309309  var caseName = frm.caseName.value;
    310310  var request = Ajax.getXmlHttpRequest();
    311   var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=GetCaseInfo';
     311  var url = 'BloodRegistration.servlet?ID=<%=ID%>&cmd=GetBloodInfo';
    312312  url += '&caseName=' + caseName;
    313313  request.open("GET", url, false);
     
    324324 
    325325  // Get biosource information from the AJAX response
    326   caseInfo = response.caseInfo;
    327  
    328   if (caseInfo && caseInfo.patient)
    329   {
    330     frm.personalNumber.value = caseInfo.patient.personalNumber;
     326  bloodInfo = response.bloodInfo;
     327 
     328  if (bloodInfo && bloodInfo.patient)
     329  {
     330    frm.personalNumber.value = bloodInfo.patient.personalNumber;
    331331    gotoStep2();
    332332  }
     
    403403  currentStep = 3;
    404404 
    405   var updateMode = caseInfo.id && caseInfo.patient;
     405  var updateMode = bloodInfo.id && bloodInfo.patient;
    406406   
    407   Main.show('caseSection');
     407  Main.show('bloodSection');
     408 
     409  if (updateMode)
     410  {
     411   
     412    if (bloodInfo.samplingDate != null)
     413    {
     414      frm.samplingDate.value = bloodInfo.samplingDate.substring(0, 8);
     415      frm.samplingTime.value = bloodInfo.samplingDate.substring(9, 13);
     416      samplingDateTimeOnChange();
     417    }
     418    if (bloodInfo.freezerDate != null)
     419    {
     420      frm.freezerDate.value = bloodInfo.freezerDate.substring(0, 8);
     421      frm.freezerTime.value = bloodInfo.freezerDate.substring(9, 13);
     422      freezerDateTimeOnChange();
     423    }
     424    frm.serum.checked = bloodInfo.serum == 'Yes';
     425  }
    408426 
    409427  Main.hide('gonext');
     
    429447  var frm = document.forms['reggie'];
    430448
    431   caseInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value);
    432   caseInfo.freezerDate = Main.trimString(frm.freezerDate.value + ' ' + frm.freezerTime.value);
    433   caseInfo.serum = frm.serum.checked ? true : false;
     449  bloodInfo.samplingDate = Main.trimString(frm.samplingDate.value + ' ' + frm.samplingTime.value);
     450  bloodInfo.freezerDate = Main.trimString(frm.freezerDate.value + ' ' + frm.freezerTime.value);
     451  bloodInfo.serum = frm.serum.checked ? "Yes" : "No";
    434452
    435453  frm.samplingDate.disabled = true;
     
    438456  frm.freezerTime.disabled = true;
    439457
    440   var updateMode = caseInfo.id && caseInfo.patient;
     458  var updateMode = bloodInfo.id && bloodInfo.patient;
    441459  var submitInfo = new Object();
    442460  submitInfo.patientInfo = patientInfo;
    443   submitInfo.caseInfo = caseInfo;
     461  submitInfo.bloodInfo = bloodInfo;
    444462
    445463  if (debug) Main.debug(JSON.stringify(submitInfo));
     
    447465  var request = Ajax.getXmlHttpRequest();
    448466  var url = 'BloodRegistration.servlet?ID=<%=ID%>&cmd=';
    449   url += updateMode ? 'UpdateCase' : 'CreateCase';
     467  url += updateMode ? 'UpdateBlood' : 'CreateBlood';
    450468  request.open("POST", url, false);
    451469  request.setRequestHeader("Content-Type", "application/json");
     
    622640
    623641
    624   <!-- 3. Case registration -->
    625   <div id="caseSection" style="display: none;">
     642  <!-- 3. Blood registration -->
     643  <div id="bloodSection" style="display: none;">
    626644  <p>
    627645  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
    628646  <tr>
    629647    <td rowspan="2" class="stepno">3</td>
    630     <td class="steptitle" id="step3.title">Create new case</td>
     648    <td class="steptitle" id="step3.title">Create new blood</td>
    631649  </tr>
    632650  <tr>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Patient.java

    r1509 r1518  
    7878  }
    7979 
     80  /**
     81    Find the patient the blood case is linked with. Null is returned if
     82    not found.
     83    @since 2.2
     84  */
     85  public static Patient findByBlood(DbControl dc, Blood blood)
     86  {
     87    Patient patient = null;
     88    Sample s = blood.getSample();
     89    BioSource b = s.getParentType() == Item.BIOSOURCE ? (BioSource)s.getParent() : null;
     90    if (b != null)
     91    {
     92      patient = new Patient(b);
     93    }
     94    return patient;
     95  }
     96
    8097 
    8198  /**
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/ReggieItem.java

    r1333 r1518  
    5353    Initialize a JSON object with information. Subclasses
    5454    should override this method if the need to put in more
    55     than the 'id', 'name' or loaded annotations (see {@link #loadAnnotations(String, AnnotationType)})
     55    than the 'id', 'name' or loaded annotations (see {@link #loadAnnotations(String, AnnotationType, ValueConverter)})
    5656  */
    5757  protected void initJSON(JSONObject json)
     
    9898    Utility method that first finds the annotation type using
    9999    {@link Reggie#findAnnotationType(DbControl, net.sf.basedb.core.Item, String, boolean)}
    100     and then calls {@link #loadAnnotations(String, AnnotationType)}.
     100    and then calls {@link #loadAnnotations(String, AnnotationType, ValueConverter)}.
    101101  */
    102102  public void loadAnnotations(DbControl dc, String jsonKey, String annotationTypeName, ValueConverter converter)
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r1515 r1518  
    9393    Load the subtype as a BASE item.
    9494    @param dc The DbControl to use for database access
    95     @return
     95    @return An ItemSubtype object
    9696  */
    9797  public ItemSubtype load(DbControl dc)
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1513 r1518  
    2626import net.sf.basedb.reggie.converter.DateToStringConverter;
    2727import net.sf.basedb.reggie.converter.StringToDateConverter;
     28import net.sf.basedb.reggie.dao.Blood;
    2829import net.sf.basedb.reggie.dao.Case;
    2930import net.sf.basedb.reggie.dao.Patient;
     
    7677        String caseName = req.getParameter("caseName");
    7778        Case theCase = Case.findByName(dc, caseName);
     79        Patient patient = null;
    7880        List<SpecimenTube> specimenTubes = null;
    7981        JSONObject jsonCase = null;
     
    102104
    103105          // Load the patient associated with the case
    104           Patient patient = Patient.findByCase(dc, theCase);
    105           // The patient can be null if (for example) we have only registered consent=yes so far
    106           if (patient != null)
    107           {
    108             patient.loadDefaultAnnotations(dc);
    109             jsonCase.put("patient", patient.asJSONObject());
    110           }
     106          patient = Patient.findByCase(dc, theCase);
    111107        }
    112108        else
     
    116112          jsonCase = new JSONObject();
    117113          jsonCase.put("name", caseName);
    118         }
    119 
     114         
     115          // Also check for a blood sample so that we can get patient information
     116          Blood blood = Blood.findByCaseName(dc, caseName);
     117          if (blood != null) patient = Patient.findByBlood(dc, blood);
     118        }
     119
     120        // The patient can be null if (for example) we have only registered consent=yes so far
     121        if (patient != null)
     122        {
     123          patient.loadDefaultAnnotations(dc);
     124          jsonCase.put("patient", patient.asJSONObject());
     125        }
     126       
    120127        // Load specimen tube annotations
    121128        JSONArray jsonTubes = new JSONArray();
Note: See TracChangeset for help on using the changeset viewer.