Changeset 1519


Ignore:
Timestamp:
Jan 23, 2012, 1:39:05 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #348: Consent form registration wizard should allow 'Yes' in all cases

The consent registration wizard now check blood registrations and register consent with the blood if found.

The personal registration wizard can now handle the case were things are registered in the following order: blood, consent, case.

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

Legend:

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

    r1514 r1519  
    3737
    3838var caseInfo = null;
     39var bloodInfo = null;
    3940
    4041function init()
     
    115116  // Get case information from the AJAX response
    116117  caseInfo = response.caseInfo;
    117 
     118  bloodInfo = response.bloodInfo;
     119 
    118120  if (caseInfo.consentDate)
    119121  {
    120122    frm.consentDate.value = caseInfo.consentDate;
    121123  }
     124  else if (bloodInfo.consentDate)
     125  {
     126    frm.consentDate.value = bloodInfo.consentDate;
     127  }
    122128  frm.consentDate.focus();
    123 
    124  
    125   // caseInfo.consent = 'No';
    126   // caseInfo.id = 999;
    127   // caseInfo.specimen = [ 1 ];
    128129   
    129   if (caseInfo.consent)
     130  if (caseInfo.consent || bloodInfo.consent)
    130131  {
    131132    // A consent has already been registered for this case
     
    136137    frm.consentDate.disabled = true;
    137138  }
    138   else if (caseInfo.id)
     139  else if (caseInfo.id || bloodInfo.id)
    139140  {
    140141    // There is an existing case already registered
     
    214215  var submitInfo = new Object();
    215216  submitInfo.caseInfo = caseInfo;
     217  submitInfo.bloodInfo = bloodInfo;
    216218
    217219  if (debug) Main.debug(JSON.stringify(submitInfo));
  • extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp

    r1514 r1519  
    4141var patientInfo = null;
    4242var caseInfo = null;
     43var bloodInfo = null;
    4344
    4445function init()
     
    404405  // Get biosource information from the AJAX response
    405406  caseInfo = response.caseInfo;
     407  bloodInfo = response.bloodInfo;
    406408 
    407409  if (caseInfo && caseInfo.patient)
     
    410412    gotoStep2();
    411413  }
    412  
     414  else if (bloodInfo && bloodInfo.patient)
     415  {
     416    frm.personalNumber.value = bloodInfo.patient.personalNumber;
     417    gotoStep2();
     418  }
    413419}
    414420
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/ConsentFormServlet.java

    r1504 r1519  
    2525import net.sf.basedb.reggie.converter.DateToStringConverter;
    2626import net.sf.basedb.reggie.converter.StringToDateConverter;
     27import net.sf.basedb.reggie.dao.Blood;
    2728import net.sf.basedb.reggie.dao.Case;
    2829import net.sf.basedb.reggie.dao.Patient;
     
    7071        dc = sc.newDbControl();
    7172       
    72         // Find a case by name
     73        // Find a case + blood by name
    7374        String caseName = req.getParameter("caseName");
    7475        Case theCase = Case.findByName(dc, caseName);
     76        Blood blood = Blood.findByCaseName(dc, caseName);
     77       
    7578        List<SpecimenTube> specimenTubes = null;
    7679        JSONObject jsonCase = null;
     80        JSONObject jsonBlood = null;
    7781       
    7882        if (theCase != null)
     
    105109          jsonCase.put("specimen", jsonTubes);
    106110        }
    107        
    108         // This is what we send back to the browser
    109111        json.put("caseInfo", jsonCase);
     112       
     113        // Load blood information for the same case
     114        if (blood != null)
     115        {
     116          blood.loadAnnotations(dc, "consent", Reggie.ANNOTATION_CONSENT, null);
     117          DateToStringConverter dateConverter = new DateToStringConverter(new SimpleDateFormat("yyyyMMdd"));
     118          blood.loadAnnotations(dc, "consentDate", Reggie.ANNOTATION_CONSENT_DATE, dateConverter);
     119         
     120          // Wrap it up into JSON objects
     121          jsonBlood = blood.asJSONObject();
     122        }
     123       
     124        json.put("bloodInfo", jsonBlood);
    110125
    111126      }
     
    149164        JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader());
    150165        JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo");
     166        JSONObject jsonBlood = (JSONObject)jsonReq.get("bloodInfo");
    151167       
    152168        dc = sc.newDbControl();
    153169       
    154170        Number caseId = (Number)jsonCase.get("id");
     171        Number bloodId = (Number)jsonBlood.get("id");
    155172        String consent = Values.getStringOrNull((String)jsonCase.get("consent"));
    156173        StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyyMMdd"));
     
    194211        if (consentDate != null) Reggie.setAnnotationValue(theCase, consentDateType, consentDate);
    195212       
     213        // Blood if available
     214        if (bloodId != null)
     215        {
     216          Sample blood = Sample.getById(dc, bloodId.intValue());
     217          jsonMessages.add("Consent for blood '" + blood.getName() + "' set to: " + consent);
     218          Reggie.setAnnotationValue(blood, consentType, consent);
     219          if (consentDate != null) Reggie.setAnnotationValue(blood, consentDateType, consentDate);
     220        }
     221       
    196222        dc.commit();
    197223        json.put("messages", jsonMessages);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1518 r1519  
    7777        String caseName = req.getParameter("caseName");
    7878        Case theCase = Case.findByName(dc, caseName);
    79         Patient patient = null;
     79        Blood blood = Blood.findByCaseName(dc, caseName);
     80       
    8081        List<SpecimenTube> specimenTubes = null;
    8182        JSONObject jsonCase = null;
     83        JSONObject jsonBlood = null;
    8284       
    8385        if (theCase != null)
     
    104106
    105107          // Load the patient associated with the case
    106           patient = Patient.findByCase(dc, theCase);
     108          Patient patient = Patient.findByCase(dc, theCase);
     109          // The patient can be null if (for example) we have only registered consent=yes so far
     110          if (patient != null)
     111          {
     112            patient.loadDefaultAnnotations(dc);
     113            jsonCase.put("patient", patient.asJSONObject());
     114          }
    107115        }
    108116        else
     
    112120          jsonCase = new JSONObject();
    113121          jsonCase.put("name", caseName);
    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());
     122        }
     123       
     124        if (blood != null)
     125        {
     126          // Check that the registration is not prohibited
     127          blood.verifyConsent(dc, null);
     128
     129          // Wrap what we have so far up into JSON objects
     130          jsonBlood = blood.asJSONObject();
     131
     132          // Load patient information
     133          Patient patient = Patient.findByBlood(dc, blood);
     134          if (patient != null)
     135          {
     136            patient.loadDefaultAnnotations(dc);
     137            jsonBlood.put("patient", patient.asJSONObject());
     138          }
    125139        }
    126140       
     
    147161        // This is what we send back to the browser
    148162        json.put("caseInfo", jsonCase);
     163        json.put("bloodInfo", jsonBlood);
    149164
    150165      }
Note: See TracChangeset for help on using the changeset viewer.