@Test public void testHashornAPIBridge() throws Exception { ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn"); InputStream is=getClass().getResourceAsStream("JsDeviceDriver0.js"); engine.eval(new InputStreamReader(is)); Invocable invocable = (Invocable) engine; invocable.invokeFunction("start"); Object result = invocable.invokeFunction("readObservations"); invocable.invokeFunction("stop"); Date asOf = new Date(); Set<Observation> set = new HashSet<>(); ScriptObjectMirror som = (ScriptObjectMirror)result; if(som.isArray()) { Set<String> keys = som.keySet(); for(String key: keys) { ScriptObjectMirror o = (ScriptObjectMirror) som.get(key); String code = (String) ((ScriptObjectMirror) o.get("valueQuantity")).get("code"); Number value = (Number) ((ScriptObjectMirror) o.get("valueQuantity")).get("value"); set.add(FhirDevice.createObservation(code, value.doubleValue(), asOf)); } } Assert.assertTrue("Failed to populate dataset", set.size() != 0); }
public static Observation createObservation(String metricId, Number value, Date asOf) { Observation obs = new Observation(); obs.setValue(new QuantityDt(value.doubleValue()).setUnits(MDC_DIM_DIMLESS.VALUE).setCode(metricId).setSystem("OpenICE")); obs.setApplies(new DateTimeDt(asOf, TemporalPrecisionEnum.SECOND, TimeZone.getTimeZone("UTC"))); obs.setStatus(ObservationStatusEnum.PRELIMINARY); return obs; }
FhirDevice extends AbstractConnectedDevice { public static Observation createObservation(String metricId, Number value, Date asOf) { Observation obs = new Observation(); obs.setValue(new QuantityDt(value.doubleValue()).setUnits(MDC_DIM_DIMLESS.VALUE).setCode(metricId).setSystem("OpenICE")); obs.setApplies(new DateTimeDt(asOf, TemporalPrecisionEnum.SECOND, TimeZone.getTimeZone("UTC"))); obs.setStatus(ObservationStatusEnum.PRELIMINARY); return obs; } }
FhirDevice extends AbstractConnectedDevice { public static Observation createObservation(String metricId, Number value, Date asOf) { Observation obs = new Observation(); obs.setValue(new QuantityDt(value.doubleValue()).setUnits(MDC_DIM_DIMLESS.VALUE).setCode(metricId).setSystem("OpenICE")); obs.setApplies(new DateTimeDt(asOf, TemporalPrecisionEnum.SECOND, TimeZone.getTimeZone("UTC"))); obs.setStatus(ObservationStatusEnum.PRELIMINARY); return obs; } FhirDevice(Subscriber subscriber, Publisher publisher, EventLoop eventLoop); }
FhirDevice extends AbstractConnectedDevice { public static Observation createObservation(String metricId, Number value, Date asOf) { Observation obs = new Observation(); obs.setValue(new QuantityDt(value.doubleValue()).setUnits(MDC_DIM_DIMLESS.VALUE).setCode(metricId).setSystem("OpenICE")); obs.setApplies(new DateTimeDt(asOf, TemporalPrecisionEnum.SECOND, TimeZone.getTimeZone("UTC"))); obs.setStatus(ObservationStatusEnum.PRELIMINARY); return obs; } FhirDevice(Subscriber subscriber, Publisher publisher, EventLoop eventLoop); static Observation createObservation(String metricId, Number value, Date asOf); boolean connect(String address); void connect(ScheduledExecutorService executor); void disconnect(); }
FhirDevice extends AbstractConnectedDevice { public static Observation createObservation(String metricId, Number value, Date asOf) { Observation obs = new Observation(); obs.setValue(new QuantityDt(value.doubleValue()).setUnits(MDC_DIM_DIMLESS.VALUE).setCode(metricId).setSystem("OpenICE")); obs.setApplies(new DateTimeDt(asOf, TemporalPrecisionEnum.SECOND, TimeZone.getTimeZone("UTC"))); obs.setStatus(ObservationStatusEnum.PRELIMINARY); return obs; } FhirDevice(Subscriber subscriber, Publisher publisher, EventLoop eventLoop); static Observation createObservation(String metricId, Number value, Date asOf); boolean connect(String address); void connect(ScheduledExecutorService executor); void disconnect();  }