Search in sources :

Example 11 with Message

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

the class HL7DataFormatTest method testUnmarshalWithExplicitUTF16Charset.

@Test
public void testUnmarshalWithExplicitUTF16Charset() throws Exception {
    String charset = "UTF-16";
    MockEndpoint mock = getMockEndpoint("mock:unmarshal");
    mock.expectedMessageCount(1);
    mock.message(0).body().isInstanceOf(Message.class);
    mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, HL7Charset.getHL7Charset(charset).getHL7CharsetName());
    mock.expectedHeaderReceived(Exchange.CHARSET_NAME, charset);
    // Message with explicit encoding in MSH-18
    byte[] body = createHL7WithCharsetAsString(HL7Charset.UTF_16).getBytes(Charset.forName(charset));
    template.sendBodyAndHeader("direct:unmarshal", new ByteArrayInputStream(body), Exchange.CHARSET_NAME, charset);
    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 12 with Message

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

the class HL7DataFormatTest method testMarshal.

@Test
public void testMarshal() 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");
    Message message = createHL7AsMessage();
    template.sendBody("direct:marshal", message);
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 13 with Message

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

the class MessageValidatorTest method testDefaultHapiContext.

@Test
public void testDefaultHapiContext() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:test4");
    mock.expectedMessageCount(1);
    Message msg = createADT01Message();
    template.sendBody("direct:test4", msg);
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 14 with Message

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

the class MessageValidatorTest method testCustomHapiContext.

@Test(expected = CamelExecutionException.class)
public void testCustomHapiContext() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:test5");
    mock.expectedMessageCount(0);
    Message msg = createADT01Message();
    template.sendBody("direct:test5", msg);
    assertMockEndpointsSatisfied();
}
Also used : Message(ca.uhn.hl7v2.model.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 15 with Message

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

the class MessageValidatorTest method testDynamicCustomHapiContext.

@Test(expected = CamelExecutionException.class)
public void testDynamicCustomHapiContext() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:test6");
    mock.expectedMessageCount(0);
    Message msg = createADT01Message();
    msg.setParser(customContext.getPipeParser());
    template.sendBody("direct:test6", msg);
    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