Search in sources :

Example 86 with MSH

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

the class ORUR01HandlerTest method processMessage_shouldFailIfQuestionDatatypeIsNeitherBooleanNorNumericNorCoded.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailIfQuestionDatatypeIsNeitherBooleanNorNumericNorCoded() throws Exception {
    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|2|NM|19^FAVORITE FOOD, NON-CODED^99DCT||1|||||||||20080206";
    Assert.assertEquals("Text", Context.getConceptService().getConcept(19).getDatatype().getName());
    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 87 with MSH

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

the class ORUR01HandlerTest method processMessage_shouldCreateConceptProposalAndWithObsAlongside.

/**
 * Should create a concept proposal because of the key string in the message
 *
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldCreateConceptProposalAndWithObsAlongside() throws Exception {
    // remember initial occurrence of proposal's text in the model
    int initialOccurrences = Context.getConceptService().getConceptProposals("ASDFASDFASDF").size();
    String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20081006115934||ORU^R01|a1NZBpKqu54QyrWBEUKf|P|2.5|1||||||||3^AMRS.ELD.FORMID\r" + "PID|||7^^^^~asdf^^^^||Joe^ ^Smith||\r" + "PV1||O|1^Bishop Muge||||1^asdf asdf (5-9)|||||||||||||||||||||||||||||||||||||20081003|||||||V\r" + "ORC|RE||||||||20081006115645|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20081004|||||||||20081003\r" + "OBR|3|||1284^PROBLEM LIST^99DCT\r" + "OBX|2|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^ASDFASDFASDF^99DCT|||||||||20081003";
    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("ASDFASDFASDF").size());
}
Also used : Message(ca.uhn.hl7v2.model.Message) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 88 with MSH

use of ca.uhn.hl7v2.model.v26.segment.MSH in project wildfly-camel by wildfly-extras.

the class HL7IntegrationTest method testMarshalUnmarshal.

@Test
@SuppressWarnings("resource")
public void testMarshalUnmarshal() throws Exception {
    final String msg = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4\r";
    final HL7DataFormat format = new HL7DataFormat();
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").marshal(format).unmarshal(format).to("mock:result");
        }
    });
    camelctx.start();
    try {
        HapiContext context = new DefaultHapiContext();
        Parser p = context.getGenericParser();
        Message hapimsg = p.parse(msg);
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Message result = (Message) producer.requestBody("direct:start", hapimsg);
        Assert.assertEquals(hapimsg.toString(), result.toString());
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(ca.uhn.hl7v2.model.Message) HL7DataFormat(org.apache.camel.model.dataformat.HL7DataFormat) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) HapiContext(ca.uhn.hl7v2.HapiContext) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Parser(ca.uhn.hl7v2.parser.Parser) Test(org.junit.Test)

Example 89 with MSH

use of ca.uhn.hl7v2.model.v26.segment.MSH in project pentaho-kettle by pentaho.

the class HL7KettleParser method extractValues.

public static List<HL7Value> extractValues(Message message) throws Exception {
    Terser terser = new Terser(message);
    SegmentFinder finder = terser.getFinder();
    List<HL7Value> values = new ArrayList<HL7Value>();
    int childNr = 1;
    while (finder.hasNextChild()) {
        // next group in the message (MSH, PID, EVN and so on)
        // 
        finder.nextChild();
        Structure[] structures = finder.getCurrentChildReps();
        for (int i = 0; i < structures.length; i++) {
            Structure structure = structures[i];
            parseStructure(values, message, terser, structure, Integer.toString(childNr));
        }
        childNr++;
    }
    return values;
}
Also used : Terser(ca.uhn.hl7v2.util.Terser) SegmentFinder(ca.uhn.hl7v2.util.SegmentFinder) ArrayList(java.util.ArrayList) Structure(ca.uhn.hl7v2.model.Structure)

Aggregations

Message (ca.uhn.hl7v2.model.Message)68 Test (org.junit.Test)64 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)60 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)29 Patient (org.openmrs.Patient)23 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)22 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 MSH (ca.uhn.hl7v2.model.v24.segment.MSH)14 Person (org.openmrs.Person)14 Concept (org.openmrs.Concept)13 Obs (org.openmrs.Obs)13 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)12 ObsService (org.openmrs.api.ObsService)11 ADR_A19 (ca.uhn.hl7v2.model.v24.message.ADR_A19)10 MSA (ca.uhn.hl7v2.model.v24.segment.MSA)10 Encounter (org.openmrs.Encounter)10 Form (org.openmrs.Form)7 HL7Exception (ca.uhn.hl7v2.HL7Exception)6 CX (ca.uhn.hl7v2.model.v25.datatype.CX)6 ArrayList (java.util.ArrayList)5