Search in sources :

Example 86 with Message

use of com.google.api.services.healthcare.v1.model.Message in project camel by apache.

the class HL7MLLPNettyCodecStandAndEndBytesTest method createRouteBuilder.

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

        public void configure() throws Exception {
            from("netty4:tcp://127.0.0.1:" + getPort() + "?sync=true&decoder=#hl7decoder&encoder=#hl7encoder").process(new Processor() {

                public void process(Exchange exchange) throws Exception {
                    Message input = exchange.getIn().getBody(Message.class);
                    assertEquals("2.4", input.getVersion());
                    QRD qrd = (QRD) input.get("QRD");
                    assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
                    Message response = createHL7AsMessage();
                    exchange.getOut().setBody(response);
                }
            }).to("mock:result");
        }
    };
}
Also used : Exchange(org.apache.camel.Exchange) QRD(ca.uhn.hl7v2.model.v24.segment.QRD) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) Message(ca.uhn.hl7v2.model.Message)

Example 87 with Message

use of com.google.api.services.healthcare.v1.model.Message in project camel by apache.

the class HL7DataFormatTest method testMarshalISO8859.

@Test
public void testMarshalISO8859() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(byte[].class);
    mock.message(0).body(String.class).contains("MSA|AA|123");
    mock.message(0).body(String.class).contains("QRD|20080805120000");
    mock.message(0).body(String.class).not().contains(NONE_ISO_8859_1);
    Message message = createHL7AsMessage();
    template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, "ISO-8859-1");
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 88 with Message

use of com.google.api.services.healthcare.v1.model.Message in project camel by apache.

the class HL7DataFormatTest method testMarshalUTF16InMessage.

@Test
public void testMarshalUTF16InMessage() throws Exception {
    String charsetName = "UTF-16";
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    Message message = createHL7WithCharsetAsMessage(HL7Charset.getHL7Charset(charsetName));
    template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, charsetName);
    assertMockEndpointsSatisfied();
    byte[] body = (byte[]) mock.getExchanges().get(0).getIn().getBody();
    String msg = new String(body, Charset.forName(charsetName));
    assertTrue(msg.contains("MSA|AA|123"));
    assertTrue(msg.contains("QRD|20080805120000"));
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 89 with Message

use of com.google.api.services.healthcare.v1.model.Message in project camel by apache.

the class HL7DataFormatTest method testUnmarshal.

@Test
public void testUnmarshal() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:unmarshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(Message.class);
    mock.expectedHeaderReceived(HL7Constants.HL7_SENDING_APPLICATION, "MYSENDER");
    mock.expectedHeaderReceived(HL7Constants.HL7_SENDING_FACILITY, "MYSENDERAPP");
    mock.expectedHeaderReceived(HL7Constants.HL7_RECEIVING_APPLICATION, "MYCLIENT");
    mock.expectedHeaderReceived(HL7Constants.HL7_RECEIVING_FACILITY, "MYCLIENTAPP");
    mock.expectedHeaderReceived(HL7Constants.HL7_TIMESTAMP, "200612211200");
    mock.expectedHeaderReceived(HL7Constants.HL7_SECURITY, null);
    mock.expectedHeaderReceived(HL7Constants.HL7_MESSAGE_TYPE, "QRY");
    mock.expectedHeaderReceived(HL7Constants.HL7_TRIGGER_EVENT, "A19");
    mock.expectedHeaderReceived(HL7Constants.HL7_MESSAGE_CONTROL, "1234");
    mock.expectedHeaderReceived(HL7Constants.HL7_PROCESSING_ID, "P");
    mock.expectedHeaderReceived(HL7Constants.HL7_VERSION_ID, "2.4");
    mock.expectedHeaderReceived(HL7Constants.HL7_CONTEXT, hl7.getHapiContext());
    mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, null);
    mock.expectedHeaderReceived(Exchange.CHARSET_NAME, "UTF-8");
    String body = createHL7AsString();
    template.sendBody("direct:unmarshal", 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) Test(org.junit.Test)

Example 90 with Message

use of com.google.api.services.healthcare.v1.model.Message in project camel by apache.

the class HL7DataFormatTest method testMarshalUTF8.

@Test
public void testMarshalUTF8() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(byte[].class);
    mock.message(0).body(String.class).contains("MSA|AA|123");
    mock.message(0).body(String.class).contains("QRD|20080805120000");
    mock.message(0).body(String.class).contains(NONE_ISO_8859_1);
    Message message = createHL7AsMessage();
    template.sendBodyAndProperty("direct:marshal", message, Exchange.CHARSET_NAME, "UTF-8");
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

Message (ca.uhn.hl7v2.model.Message)114 Test (org.junit.Test)81 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)60 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)30 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)21 Patient (org.openmrs.Patient)21 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)17 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 Person (org.openmrs.Person)14 ArrayList (java.util.ArrayList)13 HL7Exception (ca.uhn.hl7v2.HL7Exception)12 Concept (org.openmrs.Concept)12 Obs (org.openmrs.Obs)12 ObsService (org.openmrs.api.ObsService)11 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)9 IOException (java.io.IOException)8 Encounter (org.openmrs.Encounter)8 RouteBuilder (org.apache.camel.builder.RouteBuilder)7 Structure (ca.uhn.hl7v2.model.Structure)5 CX (ca.uhn.hl7v2.model.v25.datatype.CX)5