use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.
the class CacheValueSetsProviderIT method testCacheValueSetsEndpointNull.
@Test
public void testCacheValueSetsEndpointNull() throws Exception {
StringAndListParam stringAndListParam = getStringAndListParamFromValueSet("valueset/AcuteInpatient.json");
RequestDetails details = Mockito.mock(RequestDetails.class);
Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, new Endpoint().getIdElement(), stringAndListParam, null, null);
validateOutcome(outcomeResource, "Could not find Endpoint/null");
}
use of org.hl7.fhir.r4.model.Endpoint in project cqf-ruler by DBCG.
the class CacheValueSetsProviderIT method testCacheValueSetsAlreadyExpanded.
// Get help with this....
// @Test
// public void testCacheValueSetsExpandAndAddConcepts() throws Exception {
// Endpoint endpoint = uploadLocalServerEndpoint();
// RequestDetails details = Mockito.mock(RequestDetails.class);
// ValueSet vs = uploadValueSet("valueset/valueset-buprenorphine-and-methadone-medications.json");
// vs.getCompose().getInclude().forEach(include -> {
// assertTrue(!include.hasConcept());
// });
// StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
// IGenericClient localClient = createClient(ourCtx, endpoint);
// // localClient.operation().onServer().named("updateCodeSystems").withNoParameters(Parameters.class).execute();
// Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
// assertTrue(outcomeResource instanceof Bundle);
// Bundle resultBundle = (Bundle) outcomeResource;
// assertTrue(resultBundle.getEntry().size() == 1);
// BundleEntryComponent entry = resultBundle.getEntry().get(0);
// assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
// assertTrue(entry.getResponse().getStatus().equals("200 OK"));
// ValueSet resultingValueSet = localClient.read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet.getCompose().getInclude().forEach(include -> {
// assertTrue(include.hasConcept());
// });
// }
@Test
public void testCacheValueSetsAlreadyExpanded() throws Exception {
Endpoint endpoint = uploadLocalServerEndpoint();
RequestDetails details = Mockito.mock(RequestDetails.class);
ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
assertTrue(outcomeResource instanceof Bundle);
Bundle resultBundle = (Bundle) outcomeResource;
assertEquals(1, resultBundle.getEntry().size());
BundleEntryComponent entry = resultBundle.getEntry().get(0);
assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
assertEquals("200 OK", entry.getResponse().getStatus());
}
use of org.hl7.fhir.r4.model.Endpoint in project himss_2021_sepsis_detection by redhat-na-ssa.
the class GetObservationsSignalEventCommand method getTimeBoxedObservation.
private List<Observation> getTimeBoxedObservation(Patient patient) {
List<Observation> obsList = new ArrayList<>();
Calendar instance = Calendar.getInstance();
instance.add(Calendar.DATE, -1);
Date timeBoxDate = instance.getTime();
String patientID = patient.getId();
String url = fhirURL + "/fhir/Observation?patient=" + patientID + "&_pretty=true";
log.info("getTimeBoxedObservation() fhirUrl endpoint = " + url);
String bundleStr = template.getForEntity(url, String.class).getBody();
Bundle newBundle = fhirCtx.newJsonParser().parseResource(Bundle.class, bundleStr);
for (BundleEntryComponent component : newBundle.getEntry()) {
if (component.getResource() instanceof Observation) {
Observation obs = (Observation) component.getResource();
if (// Adding Observation only if its 24 hrs
obs.getMeta().getLastUpdatedElement().after(timeBoxDate))
obsList.add(obs);
}
}
log.info("getTimedBoxedObservation() Patient Id : " + patientID + " # of Observations = " + obsList.size());
return obsList;
}
use of org.hl7.fhir.r4.model.Endpoint in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskPollingService method updateTasks.
public void updateTasks() {
log.info("Updating tasks from CP Organizations...");
Bundle tasksBundle = openEhrClient.search().forResource(Task.class).include(Task.INCLUDE_FOCUS).include(Task.INCLUDE_OWNER).include(Organization.INCLUDE_ENDPOINT.setRecurse(true)).where(new TokenClientParam("owner:Organization.type").exactly().systemAndCode(OrganizationTypeCode.CP.getSystem(), OrganizationTypeCode.CP.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.FAILED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.REJECTED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.COMPLETED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.CANCELLED.toCode())).where(Task.AUTHORED_ON.before().millis(Date.from(LocalDateTime.now().minusSeconds(10).atZone(ZoneId.systemDefault()).toInstant()))).returnBundle(Bundle.class).execute();
TasksPollingInfo tasksPollingInfo = new TasksPollingBundleExtractor().extract(tasksBundle);
// Collect all entries from every Task bundle for performance considerations.
Bundle updateBundle = new Bundle();
updateBundle.setType(Bundle.BundleType.TRANSACTION);
for (Task task : tasksPollingInfo.getTasks()) {
ServiceRequest serviceRequest = tasksPollingInfo.getServiceRequest(task);
Organization organization = tasksPollingInfo.getOrganization(task);
try {
Endpoint endpoint = tasksPollingInfo.getEndpoint(organization);
combineResult(updateBundle, getUpdateBundle(task, serviceRequest, endpoint));
} catch (TaskPollingUpdateException | CpClientException exc) {
combineResult(updateBundle, failTask(task, serviceRequest, exc.getMessage()));
}
}
// If there is at least one bundle entry - execute a transaction request.
if (updateBundle.getEntry().size() != 0) {
log.info("One or more tasks were changed. Storing updates to EHR...");
openEhrClient.transaction().withBundle(updateBundle).execute();
}
log.info("Task update process finished.");
}
use of org.hl7.fhir.r4.model.Endpoint in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskPollingService method copyTaskFields.
protected void copyTaskFields(Task ehrTask, Task cpTask, Endpoint endpoint) {
ehrTask.setStatus(cpTask.getStatus());
ehrTask.setStatusReason(cpTask.getStatusReason());
ehrTask.setLastModified(cpTask.getLastModified());
int ehrNotesSize = ehrTask.getNote().size();
int cpNotesSize = cpTask.getNote().size();
if (ehrNotesSize < cpNotesSize) {
cpTask.getNote().subList(ehrNotesSize, cpNotesSize).stream().filter(cpComment -> cpComment.getAuthor() instanceof Reference).forEach(cpComment -> {
cpService.externalizeReference(cpComment.getAuthorReference(), endpoint.getAddress());
ehrTask.addNote(cpComment);
});
}
}
Aggregations