PatientInfoTransformer { public PatientInfo fromHL7(List<String> hl7PID) { if (hl7PID == null || hl7PID.isEmpty()) { return null; } PatientInfo patientInfo = new PatientInfo(); for (String hl7PIDLine : hl7PID) { String[] fields = PipeParser.split(hl7PIDLine.trim(), "|"); if (fields.length == 2) { Integer pidNo = getPidNumber(fields[0]); PIDTransformer transformer = pidTransformers.get(pidNo); if (transformer != null) { transformer.fromHL7(fields[1], patientInfo); } } } return patientInfo; }  PatientInfo fromHL7(List<String> hl7PID); List<String> toHL7(PatientInfo patientInfo);  }
@Test public void testFromHL7() { List<String> hl7PID = Arrays.asList( "PID-3|abcdef", "PID-3|fedcba", "PID-5|Joman", "PID-7|1234", "PID-8|A", "PID-9|Not used", "PID-11|Jo Str. 3"); PatientInfo patientInfo = transformer.fromHL7(hl7PID); assertNotNull(patientInfo); assertEquals(2, patientInfo.getIds().size()); assertEquals("abcdef", patientInfo.getIds().get(0).getId()); assertEquals("fedcba", patientInfo.getIds().get(1).getId()); assertEquals("Joman", patientInfo.getName().getFamilyName()); assertEquals("1234", patientInfo.getDateOfBirth()); assertEquals("A", patientInfo.getGender()); assertEquals("Jo Str. 3", patientInfo.getAddress().getStreetAddress()); }
@Test public void testFromHL7EmptyList() { assertNull(transformer.fromHL7(Collections.<String>emptyList())); }
@Test public void testFromHL7Null() { assertNull(transformer.fromHL7(null)); }