use of ca.uhn.hl7v2.parser.PipeParser in project quickstarts by jboss-switchyard.
the class CamelServiceRoute method configure.
/**
* The Camel route is configured via this method. The from endpoint is required to be a SwitchYard service.
*/
public void configure() {
DataFormat hl7 = new HL7DataFormat();
from("switchyard://HL7Route").unmarshal(hl7).process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
PipeParser pipeParser = new PipeParser();
try {
// Parse the HL7 message
ca.uhn.hl7v2.model.Message message = pipeParser.parse(body);
if (message instanceof QRY_A19) {
// Print out some details from the QRD
QRD qrd = (QRD) message.get("QRD");
System.out.println("Query Date/Time : " + qrd.getQueryDateTime().getTimeOfAnEvent().getValue());
System.out.println("Query Format Code : " + qrd.getQueryFormatCode().getValue());
System.out.println("Query Priority : " + qrd.getQueryPriority().getValue());
System.out.println("Query ID : " + qrd.getQueryID().getValue());
System.out.println("Deferred Response Type : " + qrd.getDeferredResponseType().getValue());
System.out.println("Deferred Response Date/Time : " + qrd.getDeferredResponseDateTime().getTimeOfAnEvent().getValue());
System.out.println("Quantity Limited Request : " + qrd.getQuantityLimitedRequest().getQuantity().getValue());
System.out.println("Query Results Level : " + qrd.getQueryResultsLevel().getValue());
qrd.getQueryID();
}
} catch (Exception e) {
throw e;
}
SwitchYardMessage out = new SwitchYardMessage();
out.setBody(body);
exchange.setOut(out);
}
});
}
use of ca.uhn.hl7v2.parser.PipeParser in project quickstarts by jboss-switchyard.
the class HL7ServiceTest method testCamelRoute.
@Test
public void testCamelRoute() {
StringBuilder in = new StringBuilder();
in.append(LINE_ONE);
in.append("\r");
in.append(LINE_TWO);
String result = processMessage.sendInOut(in).getContent(String.class);
;
PipeParser pipeParser = new PipeParser();
try {
//parse the message string into a Message object
Message message = pipeParser.parse(result);
if (message instanceof QRY_A19) {
QRD qrd = (QRD) message.get("QRD");
ST st = qrd.getQueryID();
Assert.assertTrue(st.getValue().equals("GetPatient"));
} else {
Assert.fail("Message not instance of QRY_A19");
}
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations