Search in sources :

Example 1 with AdtToModelMapper

use of com.ibm.streamsx.health.hapi.mapper.AdtToModelMapper in project streamsx.health by IBMStreams.

the class AdtIngest method run.

@Override
public void run() {
    Topology topology = new Topology("AdtIngest");
    AdtToModelMapper mapper = new AdtToModelMapper();
    addDependencies(topology);
    HapiMessageSupplier supplier = new HapiMessageSupplier(getPort());
    supplier.setMessageClass(ADT_AXX.class);
    TStream<Message> messages = topology.endlessSource(supplier);
    // transform message to ADTEvent object
    TStream<ADTEvent> adtEvents = messages.multiTransform(message -> {
        return mapper.messageToModel(message);
    });
    // publish data as JSON
    PublishAdtEvent.publish(adtEvents, getTopic());
    try {
        StreamsContextFactory.getStreamsContext(StreamsContext.Type.DISTRIBUTED).submit(topology);
    } catch (Exception e) {
        TRACE.error("Unable to submit topology", e);
    }
}
Also used : Message(ca.uhn.hl7v2.model.Message) AdtToModelMapper(com.ibm.streamsx.health.hapi.mapper.AdtToModelMapper) ADTEvent(com.ibm.streamsx.health.ingest.types.model.ADTEvent) Topology(com.ibm.streamsx.topology.Topology) HapiMessageSupplier(com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier)

Aggregations

Message (ca.uhn.hl7v2.model.Message)1 HapiMessageSupplier (com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier)1 AdtToModelMapper (com.ibm.streamsx.health.hapi.mapper.AdtToModelMapper)1 ADTEvent (com.ibm.streamsx.health.ingest.types.model.ADTEvent)1 Topology (com.ibm.streamsx.topology.Topology)1