Search in sources :

Example 16 with OBX

use of ca.uhn.hl7v2.model.v25.segment.OBX in project openmrs-core by openmrs.

the class HL7ServiceTest method getPersonFromNK1_shouldFailIfNoGenderSpecified.

/**
 * @throws HL7Exception
 * @see HL7Service#createPersonFromNK1(NK1)
 */
@Test(expected = HL7Exception.class)
public void getPersonFromNK1_shouldFailIfNoGenderSpecified() 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|||||||||||||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");
}
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) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 17 with OBX

use of ca.uhn.hl7v2.model.v25.segment.OBX in project openmrs-core by openmrs.

the class HL7ServiceTest method resolveLocationId_shouldReturnInternalIdentifierOfLocationIfOnlyLocationNameIsSpecified.

/**
 * @throws HL7Exception
 * @see HL7Service#resolveLocationId(ca.uhn.hl7v2.model.v25.datatype.PL)
 */
@Test
public void resolveLocationId_shouldReturnInternalIdentifierOfLocationIfOnlyLocationNameIsSpecified() 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|99999^0^0^0&Test Location&0||||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;
    PV1 pv1 = oru.getPATIENT_RESULT().getPATIENT().getVISIT().getPV1();
    Assert.assertNotNull("PV1 parsed as null", pv1);
    PL hl7Location = pv1.getAssignedPatientLocation();
    Integer locationId = hl7service.resolveLocationId(hl7Location);
    Assert.assertEquals("Resolved and given locationId shoud be equals", Integer.valueOf(1), locationId);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) PV1(ca.uhn.hl7v2.model.v25.segment.PV1) PL(ca.uhn.hl7v2.model.v25.datatype.PL) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 18 with OBX

use of ca.uhn.hl7v2.model.v25.segment.OBX in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processMessage_shouldFailOnEmptyConceptProposals.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailOnEmptyConceptProposals() throws Exception {
    String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080630094800||ORU^R01|kgWdFt0SVwwClOfJm3pe|P|2.5|1||||||||15^AMRS.ELD.FORMID\r" + "PID|||3^^^^~d3811480^^^^||John3^Doe^||\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20080208|||||||V\r" + "ORC|RE||||||||20080208000000|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBR|1|||1284^PROBLEM LIST^99DCT\r" + "OBX|1|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^^99DCT|||||||||20080208";
    Message hl7message = parser.parse(hl7string);
    router.processMessage(hl7message);
}
Also used : Message(ca.uhn.hl7v2.model.Message) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 19 with OBX

use of ca.uhn.hl7v2.model.v25.segment.OBX in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processNK1_shouldFailIfTheCodingSystemIsNot99REL.

/**
 * @see ORUR01Handler#processNK1(Patient,NK1)
 */
@Test(expected = HL7Exception.class)
public void processNK1_shouldFailIfTheCodingSystemIsNot99REL() throws Exception {
    // process a message with an invalid coding system
    // the patient that is the focus of
    Patient patient = new Patient(3);
    // this hl7 message
    String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||4^AMRS.ELD.FORMID\r" + "PID|||3^^^^||Beren^John^Bondo||\r" + "NK1|1|Jones^Jane^Lee^^RN|3A^Parent^ACKFOO||||||||||||F|19751016|||||||||||||||||2^^^L^PI\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20090714|||||||V\r" + "ORC|RE||||||||20090728165937|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|5497^CD4 COUNT^99DCT||123|||||||||20090714\r" + "OBR|3|||23^FOOD CONSTRUCT^99DCT\r" + "OBX|1|CWE|21^FOOD ASSISTANCE FOR ENTIRE FAMILY^99DCT||22^UNKNOWN^99DCT^2471^UNKNOWN^99NAM|||||||||20090714";
    ORUR01Handler oruHandler = new ORUR01Handler();
    Message hl7message = parser.parse(hl7String);
    ORU_R01 oru = (ORU_R01) hl7message;
    List<NK1> nk1List = oruHandler.getNK1List(oru);
    for (NK1 nk1 : nk1List) oruHandler.processNK1(patient, nk1);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Patient(org.openmrs.Patient) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 20 with OBX

use of ca.uhn.hl7v2.model.v25.segment.OBX in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processMessage_shouldUnderstandFormUuidIfPresent.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldUnderstandFormUuidIfPresent() throws Exception {
    // save original encounter count
    List<Encounter> encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
    Integer originalEncounters = encounters.size();
    // process message
    String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||d9218f76-6c39-45f4-8efa-4c5c6c199f50^AMRS.ELD.FORMUUID\r" + "PID|||3^^^^||Beren^John^Bondo||\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20090714|||||||V\r" + "ORC|RE||||||||20090728165937|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|5497^CD4 COUNT^99DCT||123|||||||||20090714";
    Message hl7message = parser.parse(hl7String);
    router.processMessage(hl7message);
    // make sure an encounter was added
    encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
    Assert.assertEquals(originalEncounters + 1, encounters.size());
    // get last encounter
    Encounter enc = encounters.get(encounters.size() - 1);
    // check the form uuid
    Form form = enc.getForm();
    Assert.assertEquals("d9218f76-6c39-45f4-8efa-4c5c6c199f50", form.getUuid());
}
Also used : Message(ca.uhn.hl7v2.model.Message) Form(org.openmrs.Form) Encounter(org.openmrs.Encounter) Patient(org.openmrs.Patient) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Message (ca.uhn.hl7v2.model.Message)55 Test (org.junit.Test)55 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)55 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)29 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)22 Patient (org.openmrs.Patient)18 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 Concept (org.openmrs.Concept)14 Obs (org.openmrs.Obs)14 Person (org.openmrs.Person)14 ObsService (org.openmrs.api.ObsService)11 CX (ca.uhn.hl7v2.model.v25.datatype.CX)5 Form (org.openmrs.Form)5 RelationshipType (org.openmrs.RelationshipType)5 HL7Exception (ca.uhn.hl7v2.HL7Exception)4 ORC (ca.uhn.hl7v2.model.v25.segment.ORC)4 PV1 (ca.uhn.hl7v2.model.v25.segment.PV1)4 Date (java.util.Date)4 Encounter (org.openmrs.Encounter)4 Relationship (org.openmrs.Relationship)4