use of org.openmrs.hl7.handler.ORUR01Handler in project openmrs-core by openmrs.
the class HL7ServiceTest method getUuidFromIdentifiers_shouldFailIfMultipleDifferentUUIDsExistInIdentifiers.
/**
* @throws HL7Exception
* @see HL7Service#getUuidFromIdentifiers(null)
*/
@Test(expected = HL7Exception.class)
public void getUuidFromIdentifiers_shouldFailIfMultipleDifferentUUIDsExistInIdentifiers() throws HL7Exception {
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~2178037d-f86b-4f12-8d8b-be3ebc220023^^^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);
CX[] identifiers = nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers();
hl7service.getUuidFromIdentifiers(identifiers);
Assert.fail("should have failed");
}
use of org.openmrs.hl7.handler.ORUR01Handler in project openmrs-core by openmrs.
the class HL7ServiceTest method resolvePersonFromIdentifiers_shouldFindAPersonBasedOnAUUID.
/**
* @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());
}
use of org.openmrs.hl7.handler.ORUR01Handler in project openmrs-core by openmrs.
the class HL7ServiceTest method getPersonFromNK1_shouldFailIfAPersonWithTheSameUUIDExists.
/**
* @throws HL7Exception
* @see HL7Service#createPersonFromNK1(NK1)
*/
@Test(expected = HL7Exception.class)
public void getPersonFromNK1_shouldFailIfAPersonWithTheSameUUIDExists() 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);
hl7service.createPersonFromNK1(nk1List.get(0));
Assert.fail("should have thrown an exception");
}
use of org.openmrs.hl7.handler.ORUR01Handler in project openmrs-core by openmrs.
the class HL7ServiceTest method resolvePersonFromIdentifiers_shouldFindAPersonBasedOnAPatientIdentifier.
/**
* @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());
}
use of org.openmrs.hl7.handler.ORUR01Handler in project openmrs-core by openmrs.
the class HL7ServiceTest method getUuidFromIdentifiers_shouldFindAUUIDInAnyPositionOfTheArray.
/**
* @throws HL7Exception
* @see HL7Service#getUuidFromIdentifiers(null)
*/
@Test
public void getUuidFromIdentifiers_shouldFindAUUIDInAnyPositionOfTheArray() throws HL7Exception {
// at the beginning of the list
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~5^^^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);
CX[] identifiers = nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers();
String result = hl7service.getUuidFromIdentifiers(identifiers);
Assert.assertEquals("2178037d-f86b-4f12-8d8b-be3ebc220022", result);
result = null;
// at the end of the list
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|||||||||||||||||5^^^L^PN~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 = (ORU_R01) message;
nk1List = new ORUR01Handler().getNK1List(oru);
identifiers = nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers();
result = hl7service.getUuidFromIdentifiers(identifiers);
Assert.assertEquals("2178037d-f86b-4f12-8d8b-be3ebc220022", result);
result = null;
// middle of the list
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|||||||||||||||||5^^^L^PN~2178037d-f86b-4f12-8d8b-be3ebc220022^^^UUID^v4~101-3^^^MTRH^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 = (ORU_R01) message;
nk1List = new ORUR01Handler().getNK1List(oru);
identifiers = nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers();
result = hl7service.getUuidFromIdentifiers(identifiers);
Assert.assertEquals("2178037d-f86b-4f12-8d8b-be3ebc220022", result);
}
Aggregations