HL7Extractors { public static PersonNameType translateENListtoPersonNameType(List<ENExplicit> names) { LOG.debug("HL7Extractor.translateENListtoPersonNameType() -- Begin"); PersonNameType personName = new PersonNameType(); if (CollectionUtils.isNotEmpty(names) && CollectionUtils.isNotEmpty(names.get(0).getUse())) { CeType nameType = new CeType(); nameType.setCode(names.get(0).getUse().get(0)); personName.setNameType(nameType); } if (CollectionUtils.isNotEmpty(names) && names.get(0).getContent() != null) { List<Serializable> choice = names.get(0).getContent(); Iterator<Serializable> iterSerialObjects = choice.iterator(); String nameString = ""; EnExplicitFamily familyName = new EnExplicitFamily(); EnExplicitGiven givenName = new EnExplicitGiven(); while (iterSerialObjects.hasNext()) { Serializable contentItem = iterSerialObjects.next(); if (contentItem instanceof String) { String strValue = (String) contentItem; if (!nameString.isEmpty()) { nameString += strValue; } else { nameString = strValue; } LOG.debug("Here is the contents of the string: {}", strValue); } else if (contentItem instanceof JAXBElement) { JAXBElement oJAXBElement = (JAXBElement) contentItem; if (oJAXBElement.getValue() instanceof EnExplicitFamily) { familyName = (EnExplicitFamily) oJAXBElement.getValue(); } else if (oJAXBElement.getValue() instanceof EnExplicitGiven) { givenName = (EnExplicitGiven) oJAXBElement.getValue(); } } } if (!nameString.isEmpty()) { LOG.debug("set org name text "); personName.setFamilyName(nameString); } else { if (givenName.getContent() != null && givenName.getContent().length() > 0) { LOG.debug("set org name given "); personName.setGivenName(givenName.getContent()); } if (familyName.getContent() != null && familyName.getContent().length() > 0) { LOG.debug("set org name family "); personName.setFamilyName(familyName.getContent()); } } } LOG.debug("HL7Extractor.translateENListtoPersonNameType() -- End"); return personName; }  static PRPAIN201301UV02MFMIMT700701UV01Subject1 ExtractSubjectFromMessage(
        org.hl7.v3.PRPAIN201301UV02 message); static PRPAIN201302UV02MFMIMT700701UV01Subject1 ExtractSubjectFromMessage(
        org.hl7.v3.PRPAIN201302UV02 message); static PRPAIN201310UV02MFMIMT700711UV01Subject1 ExtractSubjectFromMessage(
        org.hl7.v3.PRPAIN201310UV02 message); static PRPAMT201301UV02Patient ExtractHL7PatientFromMessage(org.hl7.v3.PRPAIN201301UV02 message); static PRPAMT201302UV02Patient ExtractHL7PatientFromMessage(org.hl7.v3.PRPAIN201302UV02 message); static PRPAMT201304UV02Patient ExtractHL7PatientFromMessage(org.hl7.v3.PRPAIN201310UV02 message); static PersonNameType translatePNListtoPersonNameType(List<PNExplicit> names); static PersonNameType translateENListtoPersonNameType(List<ENExplicit> names); static PRPAMT201301UV02Person ExtractHL7PatientPersonFromHL7Patient(PRPAMT201301UV02Patient patient); static PRPAMT201302UV02Person ExtractHL7PatientPersonFromHL7Patient(PRPAMT201302UV02Patient patient); static PRPAMT201301UV02Person ExtractHL7PatientPersonFrom201301Message(org.hl7.v3.PRPAIN201301UV02 message); static PRPAMT201302UV02Person ExtractHL7PatientPersonFrom201302Message(org.hl7.v3.PRPAIN201302UV02 message); static String ExtractHL7ReceiverOID(org.hl7.v3.PRPAIN201305UV02 oPRPAIN201305UV); static String ExtractHL7SenderOID(org.hl7.v3.PRPAIN201305UV02 oPRPAIN201305UV);  }
@Test public void translateENListtoPersonNameType() { HL7Extractors extractor = new HL7Extractors(); PersonNameType person = extractor.translateENListtoPersonNameType(createENExplicitList()); assertEquals(person.getFamilyName(), "Younger"); assertEquals(person.getGivenName(), "Gallow"); }
@Test public void translateENListtoPersonNameTypeWhenUserTypeAndUserNameListNull() { HL7Extractors extractor = new HL7Extractors(); PersonNameType person = extractor .translateENListtoPersonNameType(createENExplicitNamesListWhenNameTypeandNameListNull()); assertNull(person.getFamilyName()); }