PatientAddressPIDTransformer implements PIDTransformer { @Override public List<String> toHL7(PatientInfo patientInfo) { notNull(patientInfo, "patientInfo cannot be null"); String address = Hl7v2Based.render(patientInfo.getAddress()); return (address == null) ? null : Collections.singletonList(address); }  @Override void fromHL7(String hl7Data, PatientInfo patientInfo); @Override List<String> toHL7(PatientInfo patientInfo);  }
@Test public void testToHL7() { PatientInfo patientInfo = new PatientInfo(); Address address = new Address(); address.setStreetAddress("I live here 42"); address.setCountry("ECU"); patientInfo.setAddress(address); assertEquals("I live here 42^^^^^ECU", transformer.toHL7(patientInfo).get(0)); }
@Test public void testToHL7EmptyAddress() { PatientInfo patientInfo = new PatientInfo(); Address address = new Address(); patientInfo.setAddress(address); assertEquals(null, transformer.toHL7(patientInfo)); }
@Test public void testToHL7NoAddress() { assertEquals(null, transformer.toHL7(new PatientInfo())); }