SourcePatientIdentifierPIDTransformer implements PIDTransformer { @Override public void fromHL7(String hl7Data, PatientInfo patientInfo) { notNull(patientInfo, "patientInfo cannot be null"); String[] repetitions = PipeParser.split(hl7Data, "~"); for (String hl7id : repetitions) { Identifiable id = Hl7v2Based.parse(hl7id, Identifiable.class); if (id != null) { patientInfo.getIds().add(id); } } }  @Override void fromHL7(String hl7Data, PatientInfo patientInfo); @Override List<String> toHL7(PatientInfo patientInfo);  }
@Test public void testFromHL7() { PatientInfo patientInfo = new PatientInfo(); transformer.fromHL7("id1^^^&1.1.1.1&ISO~id2^^^&2.2.2.2&ISO", patientInfo); List<Identifiable> ids = patientInfo.getIds(); assertEquals(2, ids.size()); assertEquals("id1", ids.get(0).getId()); assertEquals("1.1.1.1", ids.get(0).getAssigningAuthority().getUniversalId()); assertEquals("ISO", ids.get(0).getAssigningAuthority().getUniversalIdType()); assertEquals("id2", ids.get(1).getId()); assertEquals("2.2.2.2", ids.get(1).getAssigningAuthority().getUniversalId()); assertEquals("ISO", ids.get(1).getAssigningAuthority().getUniversalIdType()); }
@Test public void testFromHL7OneEmptyId() { PatientInfo patientInfo = new PatientInfo(); transformer.fromHL7("^^^~id2^^^&2.2.2.2&ISO", patientInfo); List<Identifiable> ids = patientInfo.getIds(); assertEquals(1, ids.size()); assertEquals("id2", ids.get(0).getId()); assertEquals("2.2.2.2", ids.get(0).getAssigningAuthority().getUniversalId()); assertEquals("ISO", ids.get(0).getAssigningAuthority().getUniversalIdType()); }
@Test public void testFromHL7Empty() { PatientInfo patientInfo = new PatientInfo(); transformer.fromHL7("", patientInfo); assertEquals(0, patientInfo.getIds().size()); }
@Test public void testFromHL7Null() { PatientInfo patientInfo = new PatientInfo(); transformer.fromHL7(null, patientInfo); assertEquals(0, patientInfo.getIds().size()); }