private String createSearchResultXML(String sampleId, StringBuilder xml) { String success = VALID; Sample sample = sampleDao.getSampleByID(sampleId); List<SampleRequester> requesters = sampleRequesterDAO.getRequestersForSampleId(sampleId); xml.append("<sampleDetails>"); XMLUtil.appendKeyValue("sampleSource", sample.getSampleSource().getId(), xml); XMLUtil.appendKeyValue("sampleReceivedDateForDisplay", sample.getReceivedDateForDisplay(), xml); if (requesters.size() > 0) { XMLUtil.appendKeyValue( "sampleRequester", String.valueOf(requesters.get(0).getRequesterId()), xml); } xml.append("</sampleDetails>"); return success; }
/* * This is protected until we integrate JMock into unit testing */ protected void createPatientElement(PatientSearchResults result, StringBuilder xml) { List<PatientIdentity> identityList = getIdentityListForPatient(result.getPatientID()); PatientIdentityTypeMap identityMap = PatientIdentityTypeMap.getInstance(); XMLUtil.appendKeyValue("first", result.getFirstName(), xml); XMLUtil.appendKeyValue("last", result.getLastName(), xml); XMLUtil.appendKeyValue("gender", result.getGender(), xml); XMLUtil.appendKeyValue( "dob", PatientUtil.getDisplayDOBForPatient(result.getPatientID(), result.getDOB()), xml); XMLUtil.appendKeyValue("nationalID", result.getNationalId(), xml); XMLUtil.appendKeyValue("ST", result.getSTNumber(), xml); XMLUtil.appendKeyValue("subjectNumber", result.getSubjectNumber(), xml); String mothersName = GenericValidator.isBlankOrNull(result.getMothersName()) ? identityMap.getIdentityValue(identityList, "MOTHER") : result.getMothersName(); XMLUtil.appendKeyValue("mother", mothersName, xml); XMLUtil.appendKeyValue("dataSourceName", result.getDataSourceName(), xml); XMLUtil.appendKeyValue("id", result.getPatientID(), xml); }