Search in sources :

Example 11 with PV1

use of ca.uhn.hl7v2.model.v26.segment.PV1 in project openmrs-core by openmrs.

the class HL7ServiceTest method processHL7Message_shouldParseMessageTypeSuppliedByModule.

/**
 * @see HL7Service#processHL7Message(Message)
 */
@Test
@Ignore("TRUNK-3945")
public void processHL7Message_shouldParseMessageTypeSuppliedByModule() throws Exception {
    Properties props = super.getRuntimeProperties();
    props.setProperty(ModuleConstants.RUNTIMEPROPERTY_MODULE_LIST_TO_LOAD, "org/openmrs/hl7/include/examplehl7handlers-0.1.omod");
    // the above module provides a handler for messages of type "ADR" with trigger "A19"
    ModuleUtil.startup(props);
    // the application context cannot restart here to load in the moduleApplicationContext that
    // calls the setHL7Handlers method so we're doing it manually here
    Class<Application> c = (Class<Application>) Context.loadClass("org.openmrs.module.examplehl7handlers.ADRHandler");
    Application classInstance = c.newInstance();
    HashMap<String, Application> map = new HashMap<>();
    map.put("ADR_A19", classInstance);
    HL7ServiceImpl.getInstance().setHL7Handlers(map);
    HL7Service hl7service = Context.getHL7Service();
    Message message = hl7service.parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ADR^A19|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\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");
    Assert.assertNotNull(message);
    try {
        hl7service.processHL7Message(message);
        Assert.fail("Should not be here. The ADR_A19 parser provided by the module throws an ApplicationException.");
    } catch (HL7Exception e) {
        if (e.getCause() != null)
            Assert.assertEquals("In ADR A19 parser", e.getCause().getMessage());
        else {
            log.error("unable to parse message", e);
            Assert.fail("something bad happened, check the log statement 1 line up");
        }
    }
    ModuleUtil.shutdown();
}
Also used : Message(ca.uhn.hl7v2.model.Message) HashMap(java.util.HashMap) HL7Exception(ca.uhn.hl7v2.HL7Exception) Properties(java.util.Properties) Application(ca.uhn.hl7v2.app.Application) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with PV1

use of ca.uhn.hl7v2.model.v26.segment.PV1 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());
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 13 with PV1

use of ca.uhn.hl7v2.model.v26.segment.PV1 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);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) CX(ca.uhn.hl7v2.model.v25.datatype.CX) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 14 with PV1

use of ca.uhn.hl7v2.model.v26.segment.PV1 in project openmrs-core by openmrs.

the class HL7ServiceTest method getUuidFromIdentifiers_shouldNotFailIfNoAssigningAuthorityIsFound.

/**
 * @throws HL7Exception
 * @see HL7Service#getUuidFromIdentifiers(null)
 */
@Test
public void getUuidFromIdentifiers_shouldNotFailIfNoAssigningAuthorityIsFound() 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|||||||||||||||||5^^^^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);
    CX[] identifiers = nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers();
    hl7service.getUuidFromIdentifiers(identifiers);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) CX(ca.uhn.hl7v2.model.v25.datatype.CX) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 15 with PV1

use of ca.uhn.hl7v2.model.v26.segment.PV1 in project openmrs-core by openmrs.

the class HL7ServiceTest method resolvePersonFromIdentifiers_shouldReturnNullIfNoPersonIsFound.

/**
 * @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);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Message (ca.uhn.hl7v2.model.Message)58 Test (org.junit.Test)58 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)58 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)27 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)22 Patient (org.openmrs.Patient)22 Person (org.openmrs.Person)15 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 Concept (org.openmrs.Concept)13 Obs (org.openmrs.Obs)13 ObsService (org.openmrs.api.ObsService)11 Encounter (org.openmrs.Encounter)10 HL7Exception (ca.uhn.hl7v2.HL7Exception)6 CX (ca.uhn.hl7v2.model.v25.datatype.CX)6 Form (org.openmrs.Form)6 Provider (org.openmrs.Provider)6 PL (ca.uhn.hl7v2.model.v25.datatype.PL)4 PV1 (ca.uhn.hl7v2.model.v25.segment.PV1)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4