Search in sources :

Example 56 with OBR

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

the class ORUR01HandlerTest method processMessage_shouldNotCreateProblemListObservationWithConceptProposals.

/**
 * Tests that a ConceptProposal row can be written by the processor
 *
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldNotCreateProblemListObservationWithConceptProposals() throws Exception {
    ObsService obsService = Context.getObsService();
    ConceptService conceptService = Context.getConceptService();
    EncounterService encService = Context.getEncounterService();
    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^SEVERO DOLOR DE CABEZA^99DCT|||||||||20080208";
    Message hl7message = parser.parse(hl7String);
    router.processMessage(hl7message);
    Patient patient = new Patient(3);
    // check for any obs
    assertEquals("There should not be any obs created for #3", 0, obsService.getObservationsByPerson(patient).size());
    // check for a new encounter
    assertEquals("There should be 1 new encounter created for #3", 1, encService.getEncountersByPatient(patient).size());
    // check for the proposed concept
    List<ConceptProposal> proposedConcepts = conceptService.getConceptProposals("SEVERO DOLOR DE CABEZA");
    assertEquals("There should be a proposed concept by this name", 1, proposedConcepts.size());
    assertEquals(encService.getEncountersByPatient(patient).get(0), proposedConcepts.get(0).getEncounter());
}
Also used : Message(ca.uhn.hl7v2.model.Message) ConceptProposal(org.openmrs.ConceptProposal) Patient(org.openmrs.Patient) ObsService(org.openmrs.api.ObsService) ConceptService(org.openmrs.api.ConceptService) EncounterService(org.openmrs.api.EncounterService) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 57 with OBR

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

the class ORUR01HandlerTest method parseObs_shouldAddMultipleCommentsForAnObservationAsOneComment.

/**
 * @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
 */
@Test
public void parseObs_shouldAddMultipleCommentsForAnObservationAsOneComment() throws Exception {
    ObsService os = Context.getObsService();
    String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\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||1|||||||||20080206\r" + "NTE|1|L|This is a comment\r" + "NTE|2|L|that spans two lines\r" + "OBX|2|NM|5497^CD4, BY FACS^99DCT||2|||||||||20080206";
    // the expected question for the obs in the hl7 message has to be
    // numeric
    Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
    List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
    Message hl7message = parser.parse(hl7string);
    router.processMessage(hl7message);
    List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
    // get the new observation with a not-null comment; not interested in
    // the other one
    Obs newObservation = null;
    int thisIndex = 0;
    while (newObservation == null && thisIndex < newList.size()) {
        Obs newObs = newList.get(thisIndex++);
        if (!oldList.contains(newObs) && !newObs.isObsGrouping() && newObs.getComment() != null)
            newObservation = newObs;
    }
    Assert.assertEquals("This is a comment that spans two lines", newObservation.getComment());
}
Also used : Concept(org.openmrs.Concept) Obs(org.openmrs.Obs) Message(ca.uhn.hl7v2.model.Message) ObsService(org.openmrs.api.ObsService) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 58 with OBR

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

the class ORUR01HandlerTest method processMessage_shouldCreateBasicConceptProposal.

/**
 * Should create a concept proposal because of the key string in the message
 *
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldCreateBasicConceptProposal() throws Exception {
    // remember initial occurrence of proposal's text in the model
    int initialOccurrences = Context.getConceptService().getConceptProposals("PELVIC MASS").size();
    String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080924022306||ORU^R01|Z185fTD0YozQ5kvQZD7i|P|2.5|1||||||||3^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Joe^S^Mith||\r" + "PV1||O|1^Unknown Module 2||||1^Joe (1-1)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080219085345|1^Joe\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|18|DT|5096^RETURN VISIT DATE^99DCT||20080506|||||||||20080212\r" + "OBR|19|||1284^PROBLEM LIST^99DCT\r" + "OBX|1|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^PELVIC MASS^99DCT|||||||||20080212";
    Message hl7message = parser.parse(hl7string);
    router.processMessage(hl7message);
    // make sure that the proposal was added
    Assert.assertEquals("Processing of the HL7 message did not result in the new proposal being added to the model", initialOccurrences + 1, Context.getConceptService().getConceptProposals("PELVIC MASS").size());
}
Also used : Message(ca.uhn.hl7v2.model.Message) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 59 with OBR

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

the class ORUR01HandlerTest method processMessage_shouldFailOnEmptyConceptAnswers.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailOnEmptyConceptAnswers() 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" + "OBX|1|CWE|5497^CD4, BY FACS^99DCT||^^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 60 with OBR

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

the class ORUR01HandlerTest method processMessage_shouldSetComplexDataForObsWithComplexConcepts.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldSetComplexDataForObsWithComplexConcepts() throws Exception {
    ObsHandler handler = new ObsHandler();
    final String handlerName = "NeigborHandler";
    final String data = "{\"firstname\":\"Horatio\"}";
    Context.getObsService().registerHandler(handlerName, handler);
    try {
        String hl7string = "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" + "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|ED|6043^uiNEIHBOR^99DCT||^^^^" + data + "|||||||||20080206\r";
        Message hl7message = parser.parse(hl7string);
        router.processMessage(hl7message);
    } finally {
        Context.getObsService().removeHandler(handlerName);
    }
    Assert.assertEquals(data, handler.getCreatedObs().getComplexData().getData());
}
Also used : Message(ca.uhn.hl7v2.model.Message) ComplexObsHandler(org.openmrs.obs.ComplexObsHandler) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Message (ca.uhn.hl7v2.model.Message)60 Test (org.junit.Test)60 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)60 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)29 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)22 Patient (org.openmrs.Patient)22 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 Encounter (org.openmrs.Encounter)9 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 Provider (org.openmrs.Provider)4