use of ca.uhn.hl7v2.model.Message 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();
}
use of ca.uhn.hl7v2.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());
}
use of ca.uhn.hl7v2.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();
}
use of ca.uhn.hl7v2.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();
}
use of ca.uhn.hl7v2.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();
}
Aggregations