Changeset 1767


Ignore:
Timestamp:
Dec 4, 2012, 9:27:53 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #442: Allow pathology and blood registration wizards to save patients without names

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

Legend:

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

    r1726 r1767  
    7171    if (frm.allFirstNames.value == '')
    7272    {
    73       setInputStatus('allFirstNames', 'Missing', 'invalid');
    74       frm.allFirstNames.focus();
     73      setInputStatus('allFirstNames', 'Missing', 'warning');
    7574      formOk = false;
    7675    }
     
    8281    if (frm.familyName.value == '')
    8382    {
    84       setInputStatus('familyName', 'Missing', 'invalid');
    85       frm.familyName.focus();
     83      setInputStatus('familyName', 'Missing', 'warning');
    8684      formOk = false;
    8785    }
     
    104102  return formOk;
    105103}
     104
     105function step2IsAcceptable()
     106{
     107  var formOk = true;
     108  var frm = document.forms['reggie'];
     109  // New patient only
     110  if (!patientInfo.id)
     111  {
     112    formOk = frm.patientCode.value != '';
     113  }
     114  return formOk;
     115}
     116
    106117
    107118function step3IsValid()
     
    141152  else if (currentStep == 2)
    142153  {
    143     if (step2IsValid()) gotoStep3();
     154    if (step2IsValid())
     155    {
     156      gotoStep3();
     157    }
     158    else if (step2IsAcceptable())
     159    {
     160      if (manual)
     161      {
     162        gotoStep3();
     163      }
     164      else
     165      {
     166        setInnerHTML('gonext.message', 'Missing name(s). Click \'Next\' to continue registration.');
     167      }
     168    }
    144169  }
    145170}
     
    220245  setInputStatus('pnr', '', 'valid');
    221246  pnrIsValid = true;
     247}
     248
     249function nameOnChange(event)
     250{
     251  var field = event.target;
     252  if (field.value == '')
     253  {
     254    setInputStatus(field.name, 'Missing', 'warning');
     255  }
     256  else
     257  {
     258    setInputStatus(field.name, '', 'valid');
     259  }
    222260}
    223261
     
    601639        <td class="prompt">Family name</td>
    602640        <td class="input"><input type="text" name="familyName"
    603           value="" size="35" maxlength="255"
     641          value="" size="35" maxlength="255" onblur="nameOnChange(event)"
    604642          onkeypress="focusOnEnter(event, 'allFirstNames')"></td>
    605643        <td class="status" id="familyName.status"></td>
     
    608646      <tr valign="top">
    609647        <td class="prompt">All first names</td>
    610         <td class="input"><input type="text" name="allFirstNames"
     648        <td class="input"><input type="text" name="allFirstNames" onblur="nameOnChange(event)"
    611649          size="35" maxlength="255" onkeypress="doOnTabOrEnter(event, goNextAuto)"></td>
    612650        <td class="status" id="allFirstNames.status"></td>
  • extensions/net.sf.basedb.reggie/trunk/resources/persinfo.jsp

    r1726 r1767  
    7474    if (frm.allFirstNames.value == '')
    7575    {
    76       setInputStatus('allFirstNames', 'Missing', 'invalid');
    77       frm.allFirstNames.focus();
     76      setInputStatus('allFirstNames', 'Missing', 'warning');
    7877      formOk = false;
    7978    }
     
    8584    if (frm.familyName.value == '')
    8685    {
    87       setInputStatus('familyName', 'Missing', 'invalid');
    88       frm.familyName.focus();
     86      setInputStatus('familyName', 'Missing', 'warning');
    8987      formOk = false;
    9088    }
     
    109107    if (frm.existingAllFirstNames.value == '')
    110108    {
    111       setInputStatus('existingAllFirstNames', 'Missing', 'invalid');
    112       frm.existingAllFirstNames.focus();
     109      setInputStatus('existingAllFirstNames', 'Missing', 'warning');
    113110      formOk = false;
    114111    }
     
    120117    if (frm.existingFamilyName.value == '')
    121118    {
    122       setInputStatus('existingFamilyName', 'Missing', 'invalid');
    123       frm.existingFamilyName.focus();
     119      setInputStatus('existingFamilyName', 'Missing', 'warning');
    124120      formOk = false;
    125121    }
     
    132128  return formOk;
    133129}
     130
     131function step2IsAcceptable()
     132{
     133  var formOk = true;
     134  var frm = document.forms['reggie'];
     135  // New patient only
     136  if (!patientInfo.id)
     137  {
     138    formOk = frm.patientCode.value != '';
     139  }
     140  return formOk;
     141}
     142
     143
    134144
    135145function step3IsValid()
     
    173183  else if (currentStep == 2)
    174184  {
    175     if (step2IsValid()) gotoStep3();
     185    if (step2IsValid())
     186    {
     187      gotoStep3();
     188    }
     189    else if (step2IsAcceptable())
     190    {
     191      if (manual)
     192      {
     193        gotoStep3();
     194      }
     195      else
     196      {
     197        setInnerHTML('gonext.message', 'Missing name(s). Click \'Next\' to continue registration.');
     198      }
     199    }
    176200  }
    177201}
     
    253277}
    254278
     279function nameOnChange(event)
     280{
     281  var field = event.target;
     282  if (field.value == '')
     283  {
     284    setInputStatus(field.name, 'Missing', 'warning');
     285  }
     286  else
     287  {
     288    setInputStatus(field.name, '', 'valid');
     289  }
     290}
     291
    255292function lateralityOnChange()
    256293{
     
    351388    }
    352389   
    353     if (!Dates.isDate(samplingDate, 'yyyyMMdd'))
     390    if (samplingDate != '' && !Dates.isDate(samplingDate, 'yyyyMMdd'))
    354391    {
    355392      setInputStatus('samplingDate', 'Not a valid date', 'invalid');
     
    366403      }
    367404    }
    368     setInputStatus('samplingDate', '', 'valid');
     405    if (samplingDate == '')
     406    {
     407      setInputStatus('samplingDate', 'Missing', 'warning');
     408    }
     409    else
     410    {
     411      setInputStatus('samplingDate', '', 'valid');
     412    }
    369413  }
    370414  samplingDateIsValid = true;
     
    929973        <td class="prompt">Family name</td>
    930974        <td class="input"><input type="text" name="familyName"
    931           value="" size="35" maxlength="255"
     975          value="" size="35" maxlength="255" onblur="nameOnChange(event)"
    932976          onkeypress="focusOnEnter(event, 'allFirstNames')"></td>
    933977        <td class="status" id="familyName.status"></td>
     
    936980      <tr valign="top">
    937981        <td class="prompt">All first names</td>
    938         <td class="input"><input type="text" name="allFirstNames"
     982        <td class="input"><input type="text" name="allFirstNames" onblur="nameOnChange(event)"
    939983          size="35" maxlength="255" onkeypress="doOnTabOrEnter(event, goNextAuto)"></td>
    940984        <td class="status" id="allFirstNames.status"></td>
     
    9771021        <td class="prompt">Family name</td>
    9781022        <td class="input"><input type="text" name="existingFamilyName"
    979           value="" size="35" maxlength="255"
     1023          value="" size="35" maxlength="255" onblur="nameOnChange(event)"
    9801024          onkeypress="focusOnEnter(event, 'existingAllFirstNames')"></td>
    9811025        <td class="status" id="existingFamilyName.status"></td>
     
    9841028      <tr valign="top">
    9851029        <td class="prompt">All first names</td>
    986         <td class="input"><input type="text" name="existingAllFirstNames"
     1030        <td class="input"><input type="text" name="existingAllFirstNames" onblur="nameOnChange(event)"
    9871031          size="35" maxlength="255" onkeypress="doOnTabOrEnter(event, goNextAuto)"></td>
    9881032        <td class="status" id="existingAllFirstNames.status"></td>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/BloodRegistrationServlet.java

    r1736 r1767  
    1414import org.json.simple.parser.JSONParser;
    1515
    16 import net.sf.basedb.core.AnnotationSet;
    17 import net.sf.basedb.core.AnnotationType;
    1816import net.sf.basedb.core.Application;
    1917import net.sf.basedb.core.BioMaterialEvent;
     
    2422import net.sf.basedb.reggie.Reggie;
    2523import net.sf.basedb.reggie.Site;
     24import net.sf.basedb.reggie.converter.StringToDateConverter;
    2625import net.sf.basedb.reggie.dao.Annotationtype;
    2726import net.sf.basedb.reggie.dao.Blood;
     
    288287      patient.setName((String)jsonPat.get("name"));
    289288      String pnr = (String)jsonPat.get("personalNumber");
    290       String dateOfBirth = (String)jsonPat.get("dateOfBirth");
    291       String gender = (String)jsonPat.get("gender");
    292      
    293       AnnotationType personalNumberType = Annotationtype.PERSONAL_NUMBER.load(dc);
    294       AnnotationType familyNameType = Annotationtype.FAMILY_NAME.load(dc);
    295       AnnotationType allFirstNamesType = Annotationtype.ALL_FIRST_NAMES.load(dc);
    296       AnnotationType genderType = Annotationtype.GENDER.load(dc);
    297       AnnotationType dateOfBirthType = Annotationtype.DATE_OF_BIRTH.load(dc);
    298      
    299       AnnotationSet as = patient.getAnnotationSet();
    300       as.getAnnotation(personalNumberType).setValue(pnr);
    301       as.getAnnotation(familyNameType).setValue((String)jsonPat.get("familyName"));
    302       as.getAnnotation(allFirstNamesType).setValue((String)jsonPat.get("allFirstNames"));
    303       if (gender != null) as.getAnnotation(genderType).setValue(gender);
    304       if (dateOfBirth != null)
    305       {
    306         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    307         df.setLenient(false);
    308         as.getAnnotation(dateOfBirthType).setValue(df.parse(dateOfBirth));
    309       }
     289      StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyy-MM-dd"));
     290      Date dateOfBirth = dateConverter.convert((String)jsonPat.get("dateOfBirth"));
     291      String gender = Values.getStringOrNull((String)jsonPat.get("gender"));
     292      String familyName = Values.getStringOrNull((String)jsonPat.get("familyName"));
     293      String allFirstNames = Values.getStringOrNull((String)jsonPat.get("allFirstNames"));
     294
     295      Annotationtype.PERSONAL_NUMBER.setAnnotationValue(dc, patient, pnr);
     296      Annotationtype.FAMILY_NAME.setAnnotationValue(dc, patient, familyName);
     297      Annotationtype.ALL_FIRST_NAMES.setAnnotationValue(dc, patient, allFirstNames);
     298      Annotationtype.GENDER.setAnnotationValue(dc, patient, gender);
     299      Annotationtype.DATE_OF_BIRTH.setAnnotationValue(dc, patient, dateOfBirth);
     300   
    310301      if (gender == null || dateOfBirth == null)
    311302      {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1677 r1767  
    2626import net.sf.basedb.reggie.Reggie;
    2727import net.sf.basedb.reggie.Site;
     28import net.sf.basedb.reggie.converter.StringToDateConverter;
    2829import net.sf.basedb.reggie.dao.Annotationtype;
    2930import net.sf.basedb.reggie.dao.Blood;
     
    543544    Number patientId = (Number)jsonPat.get("id");
    544545    BioSource patient = null;
    545     AnnotationType familyNameType = Annotationtype.FAMILY_NAME.load(dc);
    546     AnnotationType allFirstNamesType = Annotationtype.ALL_FIRST_NAMES.load(dc);
    547    
     546    String familyName = Values.getStringOrNull((String)jsonPat.get("familyName"));
     547    String allFirstNames = Values.getStringOrNull((String)jsonPat.get("allFirstNames"));
    548548    if (patientId != null)
    549549    {
    550550      patient = BioSource.getById(dc, patientId.intValue());
    551551      // Update names
    552       AnnotationSet as = patient.getAnnotationSet();
    553       as.getAnnotation(familyNameType).setValue((String)jsonPat.get("familyName"));
    554       as.getAnnotation(allFirstNamesType).setValue((String)jsonPat.get("allFirstNames"));
     552      Annotationtype.FAMILY_NAME.setAnnotationValue(dc, patient, familyName);
     553      Annotationtype.ALL_FIRST_NAMES.setAnnotationValue(dc, patient, allFirstNames);
    555554    }
    556555    else
     
    561560      patient.setName((String)jsonPat.get("name"));
    562561      String pnr = (String)jsonPat.get("personalNumber");
    563       String dateOfBirth = (String)jsonPat.get("dateOfBirth");
    564       String gender = (String)jsonPat.get("gender");
    565      
    566       AnnotationType personalNumberType = Annotationtype.PERSONAL_NUMBER.load(dc);
    567       AnnotationType genderType = Annotationtype.GENDER.load(dc);
    568       AnnotationType dateOfBirthType = Annotationtype.DATE_OF_BIRTH.load(dc);
    569      
    570       AnnotationSet as = patient.getAnnotationSet();
    571       as.getAnnotation(personalNumberType).setValue(pnr);
    572       as.getAnnotation(familyNameType).setValue((String)jsonPat.get("familyName"));
    573       as.getAnnotation(allFirstNamesType).setValue((String)jsonPat.get("allFirstNames"));
    574       if (gender != null) as.getAnnotation(genderType).setValue(gender);
    575       if (dateOfBirth != null)
    576       {
    577         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    578         df.setLenient(false);
    579         as.getAnnotation(dateOfBirthType).setValue(df.parse(dateOfBirth));
    580       }
     562      StringToDateConverter dateConverter = new StringToDateConverter(new SimpleDateFormat("yyyy-MM-dd"));
     563      Date dateOfBirth = dateConverter.convert((String)jsonPat.get("dateOfBirth"));
     564      String gender = Values.getStringOrNull((String)jsonPat.get("gender"));
     565     
     566      Annotationtype.PERSONAL_NUMBER.setAnnotationValue(dc, patient, pnr);
     567      Annotationtype.FAMILY_NAME.setAnnotationValue(dc, patient, familyName);
     568      Annotationtype.ALL_FIRST_NAMES.setAnnotationValue(dc, patient, allFirstNames);
     569      Annotationtype.GENDER.setAnnotationValue(dc, patient, gender);
     570      Annotationtype.DATE_OF_BIRTH.setAnnotationValue(dc, patient, dateOfBirth);
     571     
    581572      if (gender == null || dateOfBirth == null)
    582573      {
Note: See TracChangeset for help on using the changeset viewer.