/** * gets a relative based on an NK1 segment * * @param nk1 an NK1 segment from the HL7 request * @return a matching Person or null if not found * @throws HL7Exception */ private Person getRelative(NK1 nk1) throws HL7Exception { // if there are no associated party identifiers, the person will not exist if (nk1.getNextOfKinAssociatedPartySIdentifiers().length < 1) { return null; } // find the related person via given IDs return Context.getHL7Service().resolvePersonFromIdentifiers(nk1.getNextOfKinAssociatedPartySIdentifiers()); }
/** * @throws HL7Exception * @see HL7Service#resolvePersonFromIdentifiers(null) */ @Test public void resolvePersonFromIdentifiers_shouldReturnNullIfNoPersonIsFound() throws HL7Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); HL7Service hl7service = Context.getHL7Service(); Message message = hl7service .parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||1000^^^L^PN||||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212"); ORU_R01 oru = (ORU_R01) message; List<NK1> nk1List = new ORUR01Handler().getNK1List(oru); Assert.assertEquals("too many NK1s parsed out", 1, nk1List.size()); Person result = hl7service.resolvePersonFromIdentifiers(nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers()); Assert.assertNull("should not have found a person", result); }
/** * @throws HL7Exception * @see HL7Service#resolvePersonFromIdentifiers(null) */ @Test public void resolvePersonFromIdentifiers_shouldFindAPersonBasedOnAPatientIdentifier() throws HL7Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); HL7Service hl7service = Context.getHL7Service(); Message message = hl7service .parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||1234^^^Test Identifier Type^PT||||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212"); ORU_R01 oru = (ORU_R01) message; List<NK1> nk1List = new ORUR01Handler().getNK1List(oru); Assert.assertEquals("too many NK1s parsed out", 1, nk1List.size()); Person result = hl7service.resolvePersonFromIdentifiers(nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers()); Assert.assertNotNull("should have found a person", result); Assert.assertEquals("found the wrong person", 2, result.getId().intValue()); }
/** * @throws HL7Exception * @see HL7Service#resolvePersonFromIdentifiers(null) */ @Test public void resolvePersonFromIdentifiers_shouldFindAPersonBasedOnAUUID() throws HL7Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); HL7Service hl7service = Context.getHL7Service(); Message message = hl7service .parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||2178037d-f86b-4f12-8d8b-be3ebc220022^^^UUID^v4||||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212"); ORU_R01 oru = (ORU_R01) message; List<NK1> nk1List = new ORUR01Handler().getNK1List(oru); Assert.assertEquals("too many NK1s parsed out", 1, nk1List.size()); Person result = hl7service.resolvePersonFromIdentifiers(nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers()); Assert.assertNotNull("should have found a person", result); Assert.assertEquals("found the wrong person", 2, result.getId().intValue()); }
/** * @throws HL7Exception * @see HL7Service#resolvePersonFromIdentifiers(null) */ @Test public void resolvePersonFromIdentifiers_shouldFindAPersonBasedOnTheInternalPersonID() throws HL7Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); HL7Service hl7service = Context.getHL7Service(); Message message = hl7service .parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||2^^^L^PN||||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212"); ORU_R01 oru = (ORU_R01) message; List<NK1> nk1List = new ORUR01Handler().getNK1List(oru); Assert.assertEquals("too many NK1s parsed out", 1, nk1List.size()); Person result = hl7service.resolvePersonFromIdentifiers(nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers()); Assert.assertNotNull("should have found a person", result); Assert.assertEquals("found the wrong person", 2, result.getId().intValue()); }