HL7Parser201306 { public static PRPAIN201306UV02 buildMessageFromMpiPatient(Patients patients, PRPAIN201305UV02 query) { LOG.trace("Entering HL7Parser201306.BuildMessageFromMpiPatient method..."); PRPAIN201306UV02 msg = new PRPAIN201306UV02(); msg.setITSVersion("XML_1.0"); II id = new II(); try { id.setRoot(PropertyAccessor.getInstance().getProperty(PROPERTY_FILE, PROPERTY_NAME)); } catch (PropertyAccessException e) { LOG.error( "PropertyAccessException - Default Assigning Authority property not defined in adapter.properties : {} ", e); } id.setExtension(MessageIdGenerator.generateMessageId()); msg.setId(id); String timestamp = ""; try { GregorianCalendar today = new GregorianCalendar(TimeZone.getTimeZone("GMT")); timestamp = String.valueOf(today.get(GregorianCalendar.YEAR)) + String.valueOf(today.get(GregorianCalendar.MONTH) + 1) + String.valueOf(today.get(GregorianCalendar.DAY_OF_MONTH)) + String.valueOf(today.get(GregorianCalendar.HOUR_OF_DAY)) + String.valueOf(today.get(GregorianCalendar.MINUTE)) + String.valueOf(today.get(GregorianCalendar.SECOND)); } catch (Exception e) { LOG.error("Exception when creating XMLGregorian Date message: {} ", e.getLocalizedMessage(), e); } TSExplicit creationTime = new TSExplicit(); creationTime.setValue(timestamp); msg.setCreationTime(creationTime); II interactionId = new II(); interactionId.setRoot("2.16.840.1.113883.1.6"); interactionId.setExtension("PRPA_IN201306UV02"); msg.setInteractionId(interactionId); CS processingCode = new CS(); processingCode.setCode("P"); msg.setProcessingCode(processingCode); CS processingModeCode = new CS(); processingModeCode.setCode("T"); msg.setProcessingModeCode(processingModeCode); CS ackCode = new CS(); ackCode.setCode("NE"); msg.setAcceptAckCode(ackCode); msg.getAcknowledgement().add(createAck(query)); msg.getReceiver().add(createReceiver(query.getSender())); msg.setSender(createSender(query.getReceiver().get(0))); msg.setControlActProcess(createControlActProcess(patients, query)); LOG.trace("Exiting HL7Parser201306.BuildMessageFromMpiPatient method..."); return msg; }  static PRPAIN201306UV02 buildMessageFromMpiPatient(Patients patients, PRPAIN201305UV02 query);  }
@Test public void testBuildMessageFromMpiPatient() { System.out.println("BuildMessageFromMpiPatient"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305(firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient(firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId); patient.getNames().get(0).setSuffix(expectedSuffix); patient.getNames().get(0).setTitle(expectedTitle); Patients patients = new Patients(); patients.add(patient); PRPAIN201306UV02 result = HL7Parser201306.buildMessageFromMpiPatient(patients, query); PNExplicit pnResult = result.getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1() .getPatient().getPatientPerson().getValue().getName().get(0); PatientName patientName = extractName(pnResult); assertEquals(lastExpectedName, patientName.LastName); assertEquals(firstExpectedName, patientName.FirstName); assertEquals(middleExpectedName, patientName.MiddleName); assertEquals(expectedTitle, patientName.Title); assertEquals(expectedSuffix, patientName.Suffix); }
@Test public void testBuildMessageFromMpiPatientPhoneNumber() { System.out.println("testBuildMessageFromMpiPatient_PhoneNumber"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305(firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient(firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId); patient.getNames().get(0).setSuffix(expectedSuffix); patient.getNames().get(0).setTitle(expectedTitle); patient.getPhoneNumbers().add(new PhoneNumber("7031231234")); Patients patients = new Patients(); patients.add(patient); PRPAIN201306UV02 result = HL7Parser201306.buildMessageFromMpiPatient(patients, query); PRPAMT201310UV02Person person = result.getControlActProcess().getSubject().get(0).getRegistrationEvent() .getSubject1().getPatient().getPatientPerson().getValue(); assertEquals(1, person.getTelecom().size()); assertEquals("7031231234", person.getTelecom().get(0).getValue()); }
@Test public void testBuildMessageFromMpiPatientMultiPhoneNumber() { System.out.println("testBuildMessageFromMpiPatient_MultiPhoneNumber"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305(firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient(firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId); patient.getNames().get(0).setSuffix(expectedSuffix); patient.getNames().get(0).setTitle(expectedTitle); patient.getPhoneNumbers().add(new PhoneNumber("7031231234")); patient.getPhoneNumbers().add(new PhoneNumber("2021231234")); Patients patients = new Patients(); patients.add(patient); PRPAIN201306UV02 result = HL7Parser201306.buildMessageFromMpiPatient(patients, query); PRPAMT201310UV02Person person = result.getControlActProcess().getSubject().get(0).getRegistrationEvent() .getSubject1().getPatient().getPatientPerson().getValue(); assertEquals(2, person.getTelecom().size()); assertEquals("7031231234", person.getTelecom().get(0).getValue()); assertEquals("2021231234", person.getTelecom().get(1).getValue()); }
@Test public void testBuildMessageFromMpiPatientAddress() { System.out.println("testBuildMessageFromMpiPatient_PhoneNumber"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305(firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient(firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId); patient.getNames().get(0).setSuffix(expectedSuffix); patient.getNames().get(0).setTitle(expectedTitle); Address add = new Address(); add.setCity("Chantilly"); add.setState("VA"); add.setStreet1("5155 Parkstone Drive"); add.setStreet2("Att:Developer"); add.setZip("20151"); patient.getAddresses().add(add); Patients patients = new Patients(); patients.add(patient); PRPAIN201306UV02 result = HL7Parser201306.buildMessageFromMpiPatient(patients, query); PRPAMT201310UV02Person person = result.getControlActProcess().getSubject().get(0).getRegistrationEvent() .getSubject1().getPatient().getPatientPerson().getValue(); assertEquals(1, person.getAddr().size()); }
@Test public void testBuildMessageFromMpiPatientMultiAddress() { System.out.println("testBuildMessageFromMpiPatient_MultiAddress"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305(firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient(firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId); patient.getNames().get(0).setSuffix(expectedSuffix); patient.getNames().get(0).setTitle(expectedTitle); Address add = new Address(); add.setCity("Chantilly"); add.setState("VA"); add.setStreet1("5155 Parkstone Drive"); add.setStreet2("Att:Developer"); add.setZip("20151"); Address add2 = new Address(); add2.setCity("Melbourne"); add2.setState("FL"); add2.setStreet1("1025 West NASA Boulevard"); add2.setStreet2("Att:Developer"); add2.setZip("32919-0001"); patient.getAddresses().add(add); patient.getAddresses().add(add2); Patients patients = new Patients(); patients.add(patient); PRPAIN201306UV02 result = HL7Parser201306.buildMessageFromMpiPatient(patients, query); PRPAMT201310UV02Person person = result.getControlActProcess().getSubject().get(0).getRegistrationEvent() .getSubject1().getPatient().getPatientPerson().getValue(); assertEquals(2, person.getAddr().size()); }
@Test public void testBuildMessageFromMpiPatientMultiNames() { System.out.println("BuildMessageFromMpiPatient"); II subjectId = new II(); subjectId.setRoot("2.16.840.1.113883.3.200"); subjectId.setExtension("1234"); String firstExpectedName = "Joe"; String lastExpectedName = "Smith"; String middleExpectedName = "Middle"; String expectedTitle = "Title"; String expectedSuffix = "Suffix"; PRPAIN201305UV02 query = TestHelper.build201305(firstExpectedName, lastExpectedName, "M", "March 1, 1956", subjectId); Identifier patId = new Identifier(); patId.setId("1234"); patId.setOrganizationId("2.16.840.1.113883.3.200"); Patient patient = TestHelper.createMpiPatient(firstExpectedName, lastExpectedName, middleExpectedName, "M", "March 1, 1956", patId, expectedTitle, expectedSuffix); patient.getNames().add(new PersonName("lastname", "firstName")); Patients patients = new Patients(); patients.add(patient); PRPAIN201306UV02 result = HL7Parser201306.buildMessageFromMpiPatient(patients, query); assertEquals(2, result.getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1() .getPatient().getPatientPerson().getValue().getName().size()); PNExplicit pnResult = result.getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1() .getPatient().getPatientPerson().getValue().getName().get(0); PNExplicit pnResult2 = result.getControlActProcess().getSubject().get(0).getRegistrationEvent().getSubject1() .getPatient().getPatientPerson().getValue().getName().get(1); PatientName patientName = extractName(pnResult); PatientName patientName2 = extractName(pnResult2); assertEquals(lastExpectedName, patientName.LastName); assertEquals(firstExpectedName, patientName.FirstName); assertEquals(middleExpectedName, patientName.MiddleName); assertEquals(expectedTitle, patientName.Title); assertEquals(expectedSuffix, patientName.Suffix); assertEquals("lastname", patientName2.LastName); assertEquals("firstName", patientName2.FirstName); }