Changeset 1572


Ignore:
Timestamp:
Mar 16, 2012, 2:47:15 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #369: Update names for an existing patient

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

Legend:

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

    r1538 r1572  
    113113    }
    114114  }
     115  else // existing patient
     116  {
     117    if (frm.existingAllFirstNames.value == '')
     118    {
     119      setInputStatus('existingAllFirstNames', 'Missing', 'invalid');
     120      frm.existingAllFirstNames.focus();
     121      formOk = false;
     122    }
     123    else
     124    {
     125      setInputStatus('existingAllFirstNames', '', 'valid');
     126    }
     127   
     128    if (frm.existingFamilyName.value == '')
     129    {
     130      setInputStatus('existingFamilyName', 'Missing', 'invalid');
     131      frm.existingFamilyName.focus();
     132      formOk = false;
     133    }
     134    else
     135    {
     136      setInputStatus('existingFamilyName', '', 'valid');
     137    }
     138   
     139  }
    115140  return formOk;
    116141}
     
    480505    Main.show('existingPatientSection');
    481506    setInnerHTML('existing.patientCode', patientInfo.name);
    482     setInnerHTML('existing.familyName', patientInfo.familyName);
    483     setInnerHTML('existing.allFirstNames', patientInfo.allFirstNames);
     507    frm.existingFamilyName.value = patientInfo.familyName;
     508    frm.existingAllFirstNames.value = patientInfo.allFirstNames;
    484509    if (patientInfo.dateOfBirth) setInnerHTML('existing.dateOfBirth', patientInfo.dateOfBirth);
    485510    if (patientInfo.gender) setInnerHTML('existing.gender', patientInfo.gender);
    486     gotoStep3();
     511    frm.existingFamilyName.focus();
    487512  }
    488513}
     
    493518  var frm = document.forms['reggie'];
    494519 
    495   if (!patientInfo.id)
     520  if (!patientInfo.id) // new patient
    496521  {
    497522    frm.patientCode.disabled = true;
     
    500525    patientInfo.familyName = frm.familyName.value;
    501526    patientInfo.allFirstNames = frm.allFirstNames.value;
     527  }
     528  else // existing patient
     529  {
     530    frm.existingFamilyName.disabled = true;
     531    frm.existingAllFirstNames.disabled = true;
     532    patientInfo.familyName = frm.existingFamilyName.value;
     533    patientInfo.allFirstNames = frm.existingAllFirstNames.value;
    502534  }
    503535  currentStep = 3;
     
    791823
    792824  if (debug) Main.debug(JSON.stringify(submitInfo));
    793 
     825 
    794826  var request = Ajax.getXmlHttpRequest();
    795827  var url = 'PersonalRegistration.servlet?ID=<%=ID%>&cmd=';
     
    939971        <td class="help"></td>
    940972      </tr>
    941       <tr>
     973      <tr valign="top">
    942974        <td class="prompt">Family name</td>
    943         <td class="input" id="existing.familyName"></td>
    944         <td class="status"></td>
    945         <td class="help"></td>
    946       </tr>
    947       <tr>
     975        <td class="input"><input type="text" name="existingFamilyName"
     976          value="" size="35" maxlength="255"
     977          onkeypress="focusOnEnter(event, 'existingAllFirstNames')"></td>
     978        <td class="status" id="existingFamilyName.status"></td>
     979        <td class="help"><span id="existingFamilyName.message" class="message" style="display: none;"></span>Keep hyphens, keep åäö, replace all special accented letters [e.g. éèü etc] with standard alphabet character.</td>
     980      </tr>
     981      <tr valign="top">
    948982        <td class="prompt">All first names</td>
    949         <td class="input" id="existing.allFirstNames"></td>
    950         <td class="status"></td>
    951         <td class="help"></td>
     983        <td class="input"><input type="text" name="existingAllFirstNames"
     984          size="35" maxlength="255" onkeypress="doOnTabOrEnter(event, goNextAuto)"></td>
     985        <td class="status" id="existingAllFirstNames.status"></td>
     986        <td class="help"><span id="existingAllFirstNames.message" class="message" style="display: none;"></span>Type all names, see FamilyName comment on valid characters.</td>
    952987      </tr>
    953988      <tr>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1565 r1572  
    378378        JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader());
    379379        JSONObject jsonCase = (JSONObject)jsonReq.get("caseInfo");
     380        JSONObject jsonPat = (JSONObject)jsonReq.get("patientInfo");
    380381        dc = sc.newDbControl();
    381382       
     383        BioSource patient = getOrCreatePatient(dc, jsonPat, jsonMessages);
     384     
    382385        Number caseId = (Number)jsonCase.get("id");
    383386        Sample theCase = Sample.getById(dc, caseId.intValue());
     
    475478    Number patientId = (Number)jsonPat.get("id");
    476479    BioSource patient = null;
     480    AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_FAMILY_NAME, true);
     481    AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_ALL_FIRST_NAMES, true);
    477482   
    478483    if (patientId != null)
    479484    {
    480485      patient = BioSource.getById(dc, patientId.intValue());
     486      // Update names
     487      AnnotationSet as = patient.getAnnotationSet();
     488      as.getAnnotation(familyNameType).setValue((String)jsonPat.get("familyName"));
     489      as.getAnnotation(allFirstNamesType).setValue((String)jsonPat.get("allFirstNames"));
    481490    }
    482491    else
     
    491500     
    492501      AnnotationType personalNumberType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true);
    493       AnnotationType familyNameType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_FAMILY_NAME, true);
    494       AnnotationType allFirstNamesType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_ALL_FIRST_NAMES, true);
    495502      AnnotationType genderType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_GENDER, true);
    496503      AnnotationType dateOfBirthType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_DATE_OF_BIRTH, true);
Note: See TracChangeset for help on using the changeset viewer.