Search in sources :

Example 1 with MSH

use of ca.uhn.hl7v2.model.v24.segment.MSH in project camel by apache.

the class HL7DataFormatTest method testUnmarshalWithImplicitBig5Charset.

@Test
public void testUnmarshalWithImplicitBig5Charset() throws Exception {
    String charset = "Big5";
    MockEndpoint mock = getMockEndpoint("mock:unmarshalBig5");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(Message.class);
    mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, null);
    mock.expectedHeaderReceived(Exchange.CHARSET_NAME, charset);
    // Message without explicit encoding in MSH-18, but the unmarshaller "guesses"
    // this time that it is Big5
    byte[] body = createHL7AsString().getBytes(Charset.forName(charset));
    template.sendBody("direct:unmarshalBig5", new ByteArrayInputStream(body));
    assertMockEndpointsSatisfied();
    Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
    assertEquals("2.4", msg.getVersion());
    QRD qrd = (QRD) msg.get("QRD");
    assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ByteArrayInputStream(java.io.ByteArrayInputStream) Test(org.junit.Test)

Example 2 with MSH

use of ca.uhn.hl7v2.model.v24.segment.MSH in project camel by apache.

the class HL7MLLPCodecLongTest method createRouteBuilder.

protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() throws Exception {
            from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec").process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    assertEquals(70010, exchange.getIn().getBody(byte[].class).length);
                    MDM_T02 input = (MDM_T02) exchange.getIn().getBody(Message.class);
                    assertEquals("2.5", input.getVersion());
                    MSH msh = input.getMSH();
                    assertEquals("20071129144629", msh.getDateTimeOfMessage().getTime().getValue());
                    exchange.getOut().setBody("some response");
                }
            }).to("mock:result");
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) MSH(ca.uhn.hl7v2.model.v25.segment.MSH) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(ca.uhn.hl7v2.model.Message) MDM_T02(ca.uhn.hl7v2.model.v25.message.MDM_T02)

Example 3 with MSH

use of ca.uhn.hl7v2.model.v24.segment.MSH in project camel by apache.

the class HL7MLLPCodecStandAndEndBytesTest method createHL7AsMessage.

private static Message createHL7AsMessage() throws Exception {
    ADR_A19 adr = new ADR_A19();
    // Populate the MSH Segment
    MSH mshSegment = adr.getMSH();
    mshSegment.getFieldSeparator().setValue("|");
    mshSegment.getEncodingCharacters().setValue("^~\\&");
    mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
    mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
    mshSegment.getSequenceNumber().setValue("123");
    mshSegment.getMessageType().getMessageType().setValue("ADR");
    mshSegment.getMessageType().getTriggerEvent().setValue("A19");
    // Populate the PID Segment
    MSA msa = adr.getMSA();
    msa.getAcknowledgementCode().setValue("AA");
    msa.getMessageControlID().setValue("123");
    QRD qrd = adr.getQRD();
    qrd.getQueryDateTime().getTimeOfAnEvent().setValue("20080805120000");
    return adr;
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) MSH(ca.uhn.hl7v2.model.v24.segment.MSH) ADR_A19(ca.uhn.hl7v2.model.v24.message.ADR_A19) MSA(ca.uhn.hl7v2.model.v24.segment.MSA)

Example 4 with MSH

use of ca.uhn.hl7v2.model.v24.segment.MSH in project camel by apache.

the class HL7ByteArrayRouteTest method createADT01Message.

private static Message createADT01Message(String msgId) throws Exception {
    ADT_A01 adt = new ADT_A01();
    // Populate the MSH Segment
    MSH mshSegment = adt.getMSH();
    mshSegment.getFieldSeparator().setValue("|");
    mshSegment.getEncodingCharacters().setValue("^~\\&");
    mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
    mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
    mshSegment.getSequenceNumber().setValue("123");
    mshSegment.getMessageType().getMessageType().setValue("ADT");
    mshSegment.getMessageType().getTriggerEvent().setValue("A01");
    mshSegment.getCharacterSet(0).setValue("UNICODE UTF-8");
    // Populate the PID Segment
    PID pid = adt.getPID();
    pid.getPatientName(0).getFamilyName().getSurname().setValue("Döe");
    pid.getPatientName(0).getGivenName().setValue("John");
    pid.getPatientIdentifierList(0).getID().setValue(msgId);
    return adt;
}
Also used : MSH(ca.uhn.hl7v2.model.v24.segment.MSH) PID(ca.uhn.hl7v2.model.v24.segment.PID) ADT_A01(ca.uhn.hl7v2.model.v24.message.ADT_A01)

Example 5 with MSH

use of ca.uhn.hl7v2.model.v24.segment.MSH in project camel by apache.

the class HL7ByteArrayRouteTest method createADR19Message.

private static Message createADR19Message() throws Exception {
    ADR_A19 adr = new ADR_A19();
    // Populate the MSH Segment
    MSH mshSegment = adr.getMSH();
    mshSegment.getFieldSeparator().setValue("|");
    mshSegment.getEncodingCharacters().setValue("^~\\&");
    mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
    mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
    mshSegment.getSequenceNumber().setValue("123");
    mshSegment.getMessageType().getMessageType().setValue("ADR");
    mshSegment.getMessageType().getTriggerEvent().setValue("A19");
    mshSegment.getCharacterSet(0).setValue("UNICODE UTF-8");
    // Populate the PID Segment
    MSA msa = adr.getMSA();
    msa.getAcknowledgementCode().setValue("AA");
    msa.getMessageControlID().setValue("123");
    QRD qrd = adr.getQRD();
    qrd.getQueryDateTime().getTimeOfAnEvent().setValue("20080805120000");
    return adr.getMessage();
}
Also used : QRD(ca.uhn.hl7v2.model.v24.segment.QRD) MSH(ca.uhn.hl7v2.model.v24.segment.MSH) ADR_A19(ca.uhn.hl7v2.model.v24.message.ADR_A19) MSA(ca.uhn.hl7v2.model.v24.segment.MSA)

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