Search in sources :

Example 1 with HapiMessageSupplier

use of com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier 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)

Example 2 with HapiMessageSupplier

use of com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier 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);
    }
}
Also used : Message(ca.uhn.hl7v2.model.Message) Topology(com.ibm.streamsx.topology.Topology) HapiMessageSupplier(com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier) StreamSchema(com.ibm.streams.operator.StreamSchema) OutputTuple(com.ibm.streams.operator.OutputTuple) SPLStream(com.ibm.streamsx.topology.spl.SPLStream) ObxToSplMapper(com.ibm.streamsx.health.hapi.mapper.ObxToSplMapper) Observation(com.ibm.streamsx.health.hapi.model.Observation)

Aggregations

Message (ca.uhn.hl7v2.model.Message)2 HapiMessageSupplier (com.ibm.streamsx.health.hapi.internal.HapiMessageSupplier)2 Topology (com.ibm.streamsx.topology.Topology)2 OutputTuple (com.ibm.streams.operator.OutputTuple)1 StreamSchema (com.ibm.streams.operator.StreamSchema)1 AdtToModelMapper (com.ibm.streamsx.health.hapi.mapper.AdtToModelMapper)1 ObxToSplMapper (com.ibm.streamsx.health.hapi.mapper.ObxToSplMapper)1 Observation (com.ibm.streamsx.health.hapi.model.Observation)1 ADTEvent (com.ibm.streamsx.health.ingest.types.model.ADTEvent)1 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)1