Search in sources :

Example 1 with PatientVitals

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;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) ObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent) PatientVitals(com.redhat.naps.process.model.PatientVitals) Observation(org.hl7.fhir.r4.model.Observation)

Example 2 with PatientVitals

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);
    }
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExecutionResults(org.kie.api.executor.ExecutionResults) Observation(org.hl7.fhir.r4.model.Observation) PatientVitals(com.redhat.naps.process.model.PatientVitals) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) Patient(org.hl7.fhir.r4.model.Patient)

Example 3 with PatientVitals

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());
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PatientVitals(com.redhat.naps.process.model.PatientVitals) Patient(org.hl7.fhir.r4.model.Patient) CloudEvent(io.cloudevents.CloudEvent)

Example 4 with PatientVitals

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());
}
Also used : PatientVitals(com.redhat.naps.process.model.PatientVitals) SepsisResponse(com.redhat.naps.process.model.SepsisResponse)

Aggregations

PatientVitals (com.redhat.naps.process.model.PatientVitals)4 Observation (org.hl7.fhir.r4.model.Observation)2 Patient (org.hl7.fhir.r4.model.Patient)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 SepsisResponse (com.redhat.naps.process.model.SepsisResponse)1 CloudEvent (io.cloudevents.CloudEvent)1 Coding (org.hl7.fhir.r4.model.Coding)1 ObservationComponentComponent (org.hl7.fhir.r4.model.Observation.ObservationComponentComponent)1 ExecutionResults (org.kie.api.executor.ExecutionResults)1 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)1 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)1