SourcePatientNamePIDTransformer implements PIDTransformer { @Override public List<String> toHL7(PatientInfo patientInfo) { notNull(patientInfo, "patientInfo cannot be null"); String name = Hl7v2Based.render(patientInfo.getName()); return (name == null) ? null : Collections.singletonList(name); }  @Override void fromHL7(String hl7Data, PatientInfo patientInfo); @Override List<String> toHL7(PatientInfo patientInfo);  }
@Test public void testToHL7() { PatientInfo patientInfo = new PatientInfo(); Name name = new XpnName(); name.setFamilyName("Jo|man"); name.setGivenName("Jo|chen"); name.setSecondAndFurtherGivenNames("Jo|achim"); name.setSuffix("von Jo|del"); name.setPrefix("Jo|dler"); patientInfo.setName(name); assertEquals("Jo\\F\\man^Jo\\F\\chen^Jo\\F\\achim^von Jo\\F\\del^Jo\\F\\dler", transformer.toHL7(patientInfo).get(0)); }
@Test public void testToHL7EmptyName() { PatientInfo patientInfo = new PatientInfo(); patientInfo.setName(new XcnName()); assertNull(transformer.toHL7(patientInfo)); }
@Test public void testToHL7NoName() { PatientInfo patientInfo = new PatientInfo(); assertNull(transformer.toHL7(patientInfo)); }