use of org.hl7.fhir.r5.elementmodel.Manager in project himss_2021_sepsis_detection by redhat-na-ssa.
the class FHIRServerWIH method executeWorkItem.
@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
String taskName = (String) workItem.getParameter(FHIRUtil.WORK_ITEM_NAME);
Observation obs = (Observation) workItem.getParameter(FHIRUtil.OBSERVATION);
Encounter eObj = (Encounter) workItem.getParameter(FHIRUtil.ENCOUNTER);
log.warn(taskName + " : " + obs + " : " + eObj);
Map<String, Object> results = workItem.getResults();
manager.completeWorkItem(workItem.getId(), results);
}
use of org.hl7.fhir.r5.elementmodel.Manager 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 org.hl7.fhir.r5.elementmodel.Manager in project org.hl7.fhir.core by hapifhir.
the class IgLoader method loadIgSource.
/**
* @param src can be one of the following:
* <br> - a canonical url for an ig - this will be converted to a package id and loaded into the cache
* <br> - a package id for an ig - this will be loaded into the cache
* <br> - a direct reference to a package ("package.tgz") - this will be extracted by the cache manager, but not put in the cache
* <br> - a folder containing resources - these will be loaded directly
* @param recursive if true and src resolves to a folder, recursively find and load IgSources from that directory
* @param explore should be true if we're trying to load an -ig parameter, and false if we're loading source
*
* @return
* @throws FHIRException
* @throws IOException
*/
public Map<String, byte[]> loadIgSource(String src, boolean recursive, boolean explore) throws FHIRException, IOException {
//
if (Common.isNetworkPath(src)) {
String v = null;
if (src.contains("|")) {
v = src.substring(src.indexOf("|") + 1);
src = src.substring(0, src.indexOf("|"));
}
String pid = explore ? getPackageCacheManager().getPackageId(src) : null;
if (!Utilities.noString(pid))
return fetchByPackage(pid + (v == null ? "" : "#" + v));
else
return fetchFromUrl(src + (v == null ? "" : "|" + v), explore);
}
File f = new File(Utilities.path(src));
if (f.exists()) {
if (f.isDirectory() && new File(Utilities.path(src, "package.tgz")).exists())
return loadPackage(new FileInputStream(Utilities.path(src, "package.tgz")), Utilities.path(src, "package.tgz"));
if (f.isDirectory() && new File(Utilities.path(src, "igpack.zip")).exists())
return readZip(new FileInputStream(Utilities.path(src, "igpack.zip")));
if (f.isDirectory() && new File(Utilities.path(src, "validator.pack")).exists())
return readZip(new FileInputStream(Utilities.path(src, "validator.pack")));
if (f.isDirectory())
return scanDirectory(f, recursive);
if (src.endsWith(".tgz"))
return loadPackage(new FileInputStream(src), src);
if (src.endsWith(".pack"))
return readZip(new FileInputStream(src));
if (src.endsWith("igpack.zip"))
return readZip(new FileInputStream(src));
Manager.FhirFormat fmt = ResourceChecker.checkIsResource(getContext(), isDebug(), TextFile.fileToBytes(f), src, true);
if (fmt != null) {
Map<String, byte[]> res = new HashMap<String, byte[]>();
res.put(Utilities.changeFileExt(src, "." + fmt.getExtension()), TextFile.fileToBytesNCS(src));
return res;
}
} else if ((src.matches(FilesystemPackageCacheManager.PACKAGE_REGEX) || src.matches(FilesystemPackageCacheManager.PACKAGE_VERSION_REGEX)) && !src.endsWith(".zip") && !src.endsWith(".tgz")) {
return fetchByPackage(src);
}
throw new FHIRException("Unable to find/resolve/read " + (explore ? "-ig " : "") + src);
}
Aggregations