use of com.ibm.streamsx.health.ingest.types.model.Observation in project streamsx.health by IBMStreams.
the class Test method main.
public static void main(String[] args) throws Exception {
Topology t = new Topology("ConnectorTest");
TStream<Observation> obsStream = SubscribeConnector.subscribe(t, "ingest-physionet");
obsStream.print();
StreamsContextFactory.getStreamsContext(Type.DISTRIBUTED).submit(t).get();
}
use of com.ibm.streamsx.health.ingest.types.model.Observation in project streamsx.health by IBMStreams.
the class HealthcareDataGenerator method loadData.
public void loadData(InputStream is, String filename) throws Exception {
Device device = new Device();
device.setId("HealthcareDataGenerator");
ReadingSource readingSource = new ReadingSource();
readingSource.setDeviceId(device.getId());
readingSource.setSourceType("file");
readingSource.setId(filename);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
// skip first 2 lines
reader.readLine();
String[] uom = reader.readLine().replace("'", "").split(",");
String line = null;
while ((line = reader.readLine()) != null) {
String[] values = line.split(",");
for (int i = 1; i < values.length; i++) {
Reading reading = new Reading();
// convert to milliseconds
Double tsMilli = Double.valueOf(values[0]) * 1000;
reading.setTimestamp(tsMilli.longValue());
reading.setReadingType(new ReadingType(ReadingTypeSystem.STREAMS_CODE_SYSTEM, readingTypeCode));
reading.setUom(uom[i]);
reading.setValue(Double.valueOf(values[i]));
observations.add(new Observation(device, patientId, readingSource, reading));
}
}
}
use of com.ibm.streamsx.health.ingest.types.model.Observation in project streamsx.health by IBMStreams.
the class PatientManipulatorService method build.
public void build() {
TStream<Observation> obsStream = null;
for (String topic : topics) {
TStream<Observation> tstream = SubscribeConnector.subscribe(topo, topic.trim());
if (obsStream == null)
obsStream = tstream;
else
obsStream = obsStream.union(tstream);
}
TSink controlSink = SPLStreams.subscribe(topo, CONTROL_INPUT_TOPIC, JSONSchemas.JSON).convert(t -> t.getString(0)).asType(String.class).sink(new PatientController());
TStream<Observation> modifiedObs = obsStream.modify(new Manipulator());
controlSink.colocate(modifiedObs);
PublishConnector.publishObservation(modifiedObs, getPublishedTopic());
}
use of com.ibm.streamsx.health.ingest.types.model.Observation in project streamsx.health by IBMStreams.
the class AbstractVitalsGenerator method get.
@Override
public Observation get() {
Reading reading = new Reading();
reading.setReadingType(getReadingType());
reading.setTimestamp(++count);
reading.setUom(getUOM());
reading.setValue(vitalsGen.next());
Device device = new Device();
device.setId(getDeviceId());
ReadingSource readingSource = new ReadingSource();
readingSource.setDeviceId(getDeviceId());
readingSource.setSourceType("generated");
return new Observation(device, patientId, readingSource, reading);
}
Aggregations