use of ca.uhn.hl7v2.model.Message in project beam by apache.
the class HL7v2IOTestUtil method testMessage.
static Message testMessage(String name) {
Message msg = new Message();
msg.setName(name);
return msg;
}
use of ca.uhn.hl7v2.model.Message in project beam by apache.
the class HL7v2MessageCoder method decode.
@Override
public HL7v2Message decode(InputStream inStream) throws CoderException, IOException {
Message msg = new Message();
msg.setName(STRING_CODER.decode(inStream));
msg.setMessageType(STRING_CODER.decode(inStream));
msg.setCreateTime(STRING_CODER.decode(inStream));
msg.setSendTime(STRING_CODER.decode(inStream));
msg.setData(STRING_CODER.decode(inStream));
msg.setSendFacility(STRING_CODER.decode(inStream));
msg.setLabels(MAP_CODER.decode(inStream));
HL7v2Message out = HL7v2Message.fromModel(msg);
out.setSchematizedData(STRING_CODER.decode(inStream));
return out;
}
use of ca.uhn.hl7v2.model.Message in project beam by apache.
the class HL7v2Message method toModel.
/**
* To model message.
*
* @return the message
*/
public Message toModel() {
Message out = new Message();
out.setName(this.getName());
out.setMessageType(this.getMessageType());
out.setSendTime(this.getSendTime());
out.setCreateTime(this.getCreateTime());
out.setData(this.getData());
out.setSendFacility(this.getSendFacility());
if (this.schematizedData != null) {
out.setSchematizedData(new SchematizedData().setData(this.schematizedData));
}
out.setLabels(this.labels);
return out;
}
use of ca.uhn.hl7v2.model.Message in project streamsx.health by IBMStreams.
the class HapiMessageHandler method processMessage.
@Override
public Message processMessage(Message theMessage, Map<String, Object> arg1) throws ReceivingApplicationException, HL7Exception {
server.messageArrived(theMessage);
Message ack;
try {
// Always use the default parser to generate an ack
// HAPI seems to get into trouble if the ADT_AXX superstructure
// is used.
// Internally, when it tries to generate an ack message
// the super structure setting in the model class factory causes the ADT_AXX message
// to get created instead of the ACK getting created. This is to override the model
// class factory so that the proper class can be generated.
theMessage.setParser(ackParser);
ack = theMessage.generateACK();
return ack;
} catch (IOException e) {
TRACE.log(TraceLevel.ERROR, "Unable to generate ack message", e);
}
return theMessage;
}
use of ca.uhn.hl7v2.model.Message in project streamsx.health by IBMStreams.
the class OruR01Ingest method run.
@Override
public void run() {
Topology topology = new Topology("OruR01Ingest");
ObxToSplMapper mapper = new ObxToSplMapper();
addDependencies(topology);
TStream<Message> messages = topology.endlessSource(new HapiMessageSupplier(getPort()));
// transform message to Observation object
TStream<Observation> observationStream = messages.multiTransform(message -> {
return mapper.messageToModel(message);
});
StreamSchema schema = Type.Factory.getStreamSchema(Observation.OBSERVATION_SCHEMA_SPL);
@SuppressWarnings("serial") SPLStream splObservations = SPLStreams.convertStream(observationStream, new BiFunction<Observation, OutputTuple, OutputTuple>() {
@Override
public OutputTuple apply(Observation observation, OutputTuple outTuple) {
return mapper.modelToSpl(observation, outTuple);
}
}, schema);
splObservations.print();
splObservations.publish(getTopic());
try {
StreamsContextFactory.getStreamsContext(StreamsContext.Type.DISTRIBUTED).submit(topology);
} catch (Exception e) {
TRACE.error("Unable to submit topology", e);
}
}
Aggregations