Changeset 1622


Ignore:
Timestamp:
Apr 25, 2012, 2:36:02 PM (11 years ago)
Author:
Nicklas Nordborg
Message:

References #381: Handle core biopsies

Added support to the consent registration wizard and fixed blood registration wizard to also find consent-related and patient information in other blood samples for the same case (with or without 'C' suffix).

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

Legend:

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

    r1614 r1622  
    4141<script language="JavaScript">
    4242
    43 var debug = false;
     43var debug = true;
    4444var currentStep = 1;
    4545var pnrIsValid = false;
     
    5151var patientInfo = null;
    5252var bloodInfo = null;
    53 var caseInfo = null;
     53var consentInfo = null;
    5454
    5555function init()
     
    165165    return;
    166166  }
    167   if (!isValidCaseName(caseName))
     167  if (!isValidCaseName(caseName, true)) // Allow 'C' suffix to be used
    168168  {
    169169    setInputStatus('case', 'Only 7-digits name is allowed.', 'invalid');
     
    333333  bloodInfo = response.bloodInfo;
    334334  patientInfo = response.patientInfo;
    335   caseInfo = response.caseInfo;
     335  consentInfo = response.consentInfo;
    336336 
    337337  if (patientInfo)
     
    452452      Forms.selectListOption(frm.bloodSample, 'PreNeo');
    453453    }
    454     if (caseInfo && caseInfo.consent)
    455     {
    456       frm.copyConsent.value = caseInfo.id;
    457       var html = "From case '" + caseInfo.name + "' (" + caseInfo.consent;
    458       if (caseInfo.consentDate) html += '; ' + caseInfo.consentDate;
     454    if (consentInfo && consentInfo.consent)
     455    {
     456      frm.copyConsent.value = consentInfo.id;
     457      var html = "From '" + consentInfo.name + "' (" + consentInfo.consent;
     458      if (consentInfo.consentDate) html += '; ' + consentInfo.consentDate;
    459459      html += ')';
    460460      setInnerHTML('copyConsent.text', html);
  • extensions/net.sf.basedb.reggie/trunk/resources/consentform.jsp

    r1601 r1622  
    6363    frm.caseName.focus();
    6464  }
    65   else if (!isValidCaseName(caseName))
     65  else if (!isValidCaseName(caseName, false)) // 'C' suffix is not used
    6666  {
    6767    setInputStatus('case', 'Only 7-digits name is allowed .', 'invalid');
  • extensions/net.sf.basedb.reggie/trunk/resources/reggie.js

    r1614 r1622  
    262262  Verify that the 'case' name is a 7-digit value + optional 'C' suffix
    263263 */
    264 function isValidCaseName(caseName)
    265 {
    266   return caseName.match(/^\d{7}C?$/);
     264function isValidCaseName(caseName, allowSuffix)
     265{
     266  var regex = allowSuffix ? /^\d{7}C?$/ : /^\d{7}$/;
     267  return caseName.match(regex);
    267268}
    268269
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Case.java

    r1610 r1622  
    4343    boolean merged = false;
    4444   
     45    // Get rid of suffixes in the name (eg. 'C' which is used for pre-neoadjuvant forms)
     46    if (name.length() > 7) name = name.substring(0, 7);   
     47   
    4548    // Look for a case with the given name (primary case)
    4649    ItemQuery<Sample> caseQuery = Sample.getQuery();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/BloodRegistrationServlet.java

    r1614 r1622  
    1919import net.sf.basedb.core.BioSource;
    2020import net.sf.basedb.core.DbControl;
    21 import net.sf.basedb.core.InvalidDataException;
    2221import net.sf.basedb.core.Sample;
    2322import net.sf.basedb.core.SessionControl;
     
    7473        Site site = Site.findByCaseName(caseName);
    7574        Blood blood = Blood.findByCaseName(dc, caseName, site != null && site.useCaseSuffixForPreNeoForms());
    76         Case theCase = Case.findByName(dc, caseName);
    7775        Patient patient = null;
    7876        JSONObject jsonBlood = null;
     
    10199          String bloodName = Blood.generateNextName(dc, caseName + ".b", Subtype.BLOOD);
    102100         
     101          // Try to find other items related to this case so that we
     102          // may find a patient and consent-related information
     103
     104          // First, check if a case can be found
     105          Case theCase = Case.findByName(dc, caseName);
     106          if (theCase != null)
     107          {
     108            // Check that the registration is not prohibited
     109            theCase.verifyConsent(dc, null);
     110            patient = Patient.findByCase(dc, theCase);
     111            Consent.loadConsentAnnotations(dc, theCase);
     112            json.put("consentInfo", theCase.asJSONObject());
     113          }
     114         
     115          // Second, check if another blood sample can be found
    103116          if (!bloodName.endsWith("b"))
    104117          {
    105             // If the blood has a numeric suffix we should be able to find a patient
    106             // by looking for the '.b' blood sample
    107             blood = Blood.getByName(dc, caseName + ".b");
    108             if (blood != null) patient = Patient.findByBlood(dc, blood);
     118            // If the auto-generated blood name has a numeric suffix
     119            // we should be able to find a patient by looking for the '.b' blood sample
     120            Blood otherBlood = Blood.getByName(dc, caseName + ".b");
     121            if (otherBlood != null)
     122            {
     123              if (patient == null) patient = Patient.findByBlood(dc, otherBlood);
     124              if (!json.containsKey("consentInfo"))
     125              {
     126                Consent.loadConsentAnnotations(dc, otherBlood);
     127                json.put("consentInfo", otherBlood.asJSONObject());
     128              }
     129            }
    109130          }
    110131         
     
    114135        }
    115136        json.put("bloodInfo", jsonBlood);
    116        
    117         if (theCase != null)
    118         {
    119           // Check that the registration is not prohibited
    120           theCase.verifyConsent(dc, null);
    121           Consent.loadConsentAnnotations(dc, theCase);
    122           JSONObject jsonCase = theCase.asJSONObject();
    123 
    124           Patient casePatient = Patient.findByCase(dc, theCase);
    125           if (casePatient != null)
    126           {
    127             // Verify that both samples have the same patient
    128             if (patient != null && !casePatient.equals(patient))
    129             {
    130               throw new InvalidDataException("Found case '" + theCase.getName() + "' and blood '" + blood.getName() +
    131                 "' but they have not the same patient. This wizard can't continue until that is corrected.");
    132             }
    133             patient = casePatient;
    134           }
    135           json.put("caseInfo", jsonCase);
    136         }
    137137       
    138138        // Connect the patient information if we have any
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/ConsentFormServlet.java

    r1614 r1622  
    8989        // Then, check for a blood sample + patient
    9090        Blood blood = Blood.findByCaseName(dc, caseName, site != null && site.useCaseSuffixForPreNeoForms());
     91        if (blood == null && site != null && site.useCaseSuffixForPreNeoForms())
     92        {
     93          // Second try without checking 'C' suffix
     94          blood = Blood.findByCaseName(dc, caseName, false);
     95        }
    9196        if (blood != null)
    9297        {
Note: See TracChangeset for help on using the changeset viewer.