use of com.redhat.naps.process.model.PatientVitals in project himss_2021_sepsis_detection by redhat-na-ssa.
the class GetObservationsSignalEventCommand method buildPatientVitals.
private PatientVitals buildPatientVitals(Patient patient, List<Observation> timeBoxedObservations) {
String obsId = timeBoxedObservations.get(0).getId().split("/")[timeBoxedObservations.get(0).getId().split("/").length - 1];
PatientVitals vitals = new PatientVitals();
vitals.setObservationId(obsId);
for (Observation observation : timeBoxedObservations) {
for (Coding coding : observation.getCode().getCoding()) {
log.info("Coding Display : " + coding.getDisplay());
if (coding.getDisplay().equals(FHIRUtil.TEMP_CODE_STRING))
vitals.setTemp(observation.getValueQuantity().getValue().doubleValue());
if (coding.getDisplay().equals(FHIRUtil.HR_CODE_STRING))
vitals.setHr(observation.getValueQuantity().getValue().doubleValue());
if (coding.getDisplay().equals(FHIRUtil.BLOOD_PRESSURE_STRING)) {
for (ObservationComponentComponent component : observation.getComponent()) {
for (Coding code : component.getCode().getCoding()) {
if (code.getDisplay().equals(FHIRUtil.SBP_CODE_STRING))
vitals.setSbp(component.getValueQuantity().getValue().doubleValue());
if (code.getDisplay().equals(FHIRUtil.DBP_CODE_STRING))
vitals.setDbp(component.getValueQuantity().getValue().doubleValue());
}
}
}
if (coding.getDisplay().equals(FHIRUtil.RESPRATE_CODE_STRING))
vitals.setResp(observation.getValueQuantity().getValue().doubleValue());
if (coding.getDisplay().equals(FHIRUtil.O2SAT_CODE_STRING))
vitals.setO2Sat(observation.getValueQuantity().getValue().doubleValue());
}
}
return vitals;
}
use of com.redhat.naps.process.model.PatientVitals in project himss_2021_sepsis_detection by redhat-na-ssa.
the class GetObservationsSignalEventCommand method execute.
@Override
public ExecutionResults execute(CommandContext ctx) throws Exception {
// NOTE: Make sure this is the actual deploymentId and not an kieserver alias
String deploymentId = (String) ctx.getData("deploymentId");
if (deploymentId == null) {
deploymentId = (String) ctx.getData("DeploymentId");
}
String signal = (String) ctx.getData("Signal");
Long processInstanceId = (Long) ctx.getData("processInstanceId");
if (processInstanceId == null) {
processInstanceId = (Long) ctx.getData("ProcessInstanceId");
}
Patient patientObj = (Patient) ctx.getData(FHIRUtil.EVENT);
if (patientObj == null)
throw new RuntimeException("Context must include: " + FHIRUtil.PATIENT);
List<Observation> obsList = getTimeBoxedObservation(patientObj);
PatientVitals vitals = buildPatientVitals(patientObj, obsList);
// TO-DO: When persisting this list of Observations as part of process instance, upon retrieval of pInstanceVariables ..... the server thread is placed in an infinite loop of JSON processing
// parameters.put("observationList", obsList);
RuntimeManager runtimeManager = RuntimeManagerRegistry.get().getManager(deploymentId);
if (runtimeManager == null) {
throw new IllegalArgumentException("No runtime manager found for deployment id " + deploymentId);
}
RuntimeEngine engine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
log.info("execute() signalling ... : deploymentId = " + deploymentId + " : pInstanceId = " + processInstanceId + " : signal = " + signal);
engine.getKieSession().signalEvent(signal, vitals, processInstanceId);
return new ExecutionResults();
} finally {
runtimeManager.disposeRuntimeEngine(engine);
}
}
use of com.redhat.naps.process.model.PatientVitals in project himss_2021_sepsis_detection by redhat-na-ssa.
the class RiskAssessmentWIH method executeWorkItem.
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
Map<String, Object> parameters = workItem.getParameters();
Patient patient = (Patient) parameters.get(FHIRUtil.PATIENT);
if (patient == null) {
throw new RuntimeException("executeWorkItem() must pass value for " + FHIRUtil.PATIENT);
}
PatientVitals vitals = (PatientVitals) parameters.get(FHIRUtil.PATIENT_VITALS);
if (vitals == null)
throw new RuntimeException("executeWorkItem() must pass value for " + FHIRUtil.PATIENT_VITALS);
String sepsisResponse = (String) parameters.get(FHIRUtil.SEPSIS_RESPONSE);
if (sepsisResponse == null)
throw new RuntimeException("executeWorkItem() must pass value for " + FHIRUtil.SEPSIS_RESPONSE);
String correlationKey = runtimeService.getProcessInstanceById(workItem.getProcessInstanceId()).getCorrelationKey();
log.info("executeWorkItem() will send generate RiskAssessment command regarding patientId = " + patient.getId() + " : correlationKey = " + correlationKey + " : sepsisResponse = " + sepsisResponse + " : obsId = " + vitals.getObservationId());
try {
String patientPayload = fhirCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(patient);
ObjectNode rootNode = objectMapper.createObjectNode();
rootNode.put(FHIRUtil.PATIENT, patientPayload);
rootNode.put(FHIRUtil.SEPSIS_RESPONSE, sepsisResponse);
rootNode.put(FHIRUtil.OBSERVATION_ID, vitals.getObservationId());
rootNode.put(FHIRUtil.CORRELATION_KEY, correlationKey);
String cloudEventPayload = objectMapper.writeValueAsString(rootNode);
CloudEvent cloudEvent = CloudEventBuilder.v1().withId(correlationKey).withSource(URI.create("")).withType(FHIRUtil.GENERATE_RISK_ASSESSMENT).withTime(OffsetDateTime.now()).withData(cloudEventPayload.getBytes()).build();
producer.send(this.generateRiskAssessmentCommandDestination, cloudEvent);
} catch (Exception x) {
x.printStackTrace();
throw new RuntimeException(x);
}
manager.completeWorkItem(workItem.getId(), workItem.getParameters());
}
use of com.redhat.naps.process.model.PatientVitals in project himss_2021_sepsis_detection by redhat-na-ssa.
the class SepsisDetectionWIH method executeWorkItem.
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
PatientVitals vitals = (PatientVitals) workItem.getParameter(FHIRUtil.PATIENT_VITALS);
if (vitals == null)
throw new RuntimeException("must pass the following workItem: " + FHIRUtil.PATIENT_VITALS);
ResponseEntity<SepsisResponse> sResponse = template.postForEntity(aimodelUrl, vitals, SepsisResponse.class);
SepsisResponse response = sResponse.getBody();
workItem.getParameters().put(FHIRUtil.SEPSIS_RESPONSE, Integer.toString(response.getIssepsis()));
log.debug("executeWorkItem() sepsisResponse = " + response.getIssepsis());
manager.completeWorkItem(workItem.getId(), workItem.getParameters());
}
Aggregations