HL7DataTransformHelper { public static ENExplicit convertPNToEN(PNExplicit pnName) { org.hl7.v3.ObjectFactory factory = new org.hl7.v3.ObjectFactory(); ENExplicit enName = factory.createENExplicit(); List enNamelist = enName.getContent(); EnExplicitFamily familyName; EnExplicitGiven givenName; List<Serializable> choice = pnName.getContent(); Iterator<Serializable> iterSerialObjects = choice.iterator(); while (iterSerialObjects.hasNext()) { Serializable contentItem = iterSerialObjects.next(); if (contentItem instanceof JAXBElement) { JAXBElement oJAXBElement = (JAXBElement) contentItem; if (oJAXBElement.getValue() instanceof EnExplicitFamily) { familyName = (EnExplicitFamily) oJAXBElement.getValue(); enNamelist.add(factory.createENExplicitFamily(familyName)); } else if (oJAXBElement.getValue() instanceof EnExplicitGiven) { givenName = (EnExplicitGiven) oJAXBElement.getValue(); enNamelist.add(factory.createENExplicitGiven(givenName)); } else if (oJAXBElement.getValue() instanceof EnExplicitPrefix) { EnExplicitPrefix explicitPrefix = (EnExplicitPrefix) oJAXBElement.getValue(); enNamelist.add(factory.createENExplicitPrefix(explicitPrefix)); } else if (oJAXBElement.getValue() instanceof EnExplicitSuffix) { EnExplicitSuffix explicitSuffix = (EnExplicitSuffix) oJAXBElement.getValue(); enNamelist.add(factory.createENExplicitSuffix(explicitSuffix)); } } } return enName; }  static II IIFactory(String root); static II IIFactory(String root, String extension); static II IIFactory(String root, String extension, String assigningAuthorityName); static II IIFactoryCreateNull(); static CS CSFactory(String code); static CE CEFactory(String code); static CD CDFactory(String code); static CD CDFactory(String code, String codeSystem); static CD CDFactory(String code, String codeSystem, String displayName); static TSExplicit TSExplicitFactory(String value); static TSExplicit creationTimeFactory(); static ENExplicit convertPNToEN(PNExplicit pnName); static PNExplicit convertENtoPN(ENExplicit value); static ENExplicit createEnExplicit(String firstName, String middleName, String lastName, String title,
            String suffix); static PNExplicit createPNExplicit(String firstName, String lastName); static PNExplicit createPNExplicit(String firstName, String middleName, String lastName); static PNExplicit createPNExplicit(String firstName, String middleName, String lastName, String title,
            String suffix); static ADExplicit createADExplicit(boolean notOrdered, String street, String city, String state,
            String zip); static ADExplicit createADExplicit(String street, String city, String state, String zip); static ADExplicit createADExplicit(boolean notOrdered, String street, String street1, String city,
            String state, String zip); static ADExplicit createADExplicit(String street, String street1, String city, String state, String zip); static TELExplicit createTELExplicit(String value);  }
@Test public void convertPNToEN() { HL7DataTransformHelper helper = new HL7DataTransformHelper(); String firstName = "Gallow"; String lastName = "Younger"; String middleName = "Matt"; String prefix = "Mr"; String suffix = "s"; EnExplicitFamily familyName = null; EnExplicitGiven givenName = null; EnExplicitPrefix prefixEx = null; EnExplicitSuffix sufEx = null; PNExplicit pnName = helper.createPNExplicit(firstName, middleName, lastName, prefix, suffix); ENExplicit enName = helper.convertPNToEN(pnName); List<Serializable> enList = enName.getContent(); Iterator<Serializable> iter = enList.iterator(); while (iter.hasNext()) { Serializable contentItem = iter.next(); if (contentItem instanceof JAXBElement) { JAXBElement oJAXBElement = (JAXBElement) contentItem; if (oJAXBElement.getValue() instanceof EnExplicitFamily) { familyName = (EnExplicitFamily) oJAXBElement.getValue(); } if (oJAXBElement.getValue() instanceof EnExplicitGiven) { givenName = (EnExplicitGiven) oJAXBElement.getValue(); } if (oJAXBElement.getValue() instanceof EnExplicitGiven) { givenName = (EnExplicitGiven) oJAXBElement.getValue(); } if (oJAXBElement.getValue() instanceof EnExplicitPrefix) { prefixEx = (EnExplicitPrefix) oJAXBElement.getValue(); } if (oJAXBElement.getValue() instanceof EnExplicitSuffix) { sufEx = (EnExplicitSuffix) oJAXBElement.getValue(); } } } assertEquals(familyName.getContent(), lastName); assertEquals(prefixEx.getContent(), prefix); assertEquals(sufEx.getContent(), suffix); }