use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project Gravity-SDOH-Exchange-RI by FHIR.
the class CpService method create.
public void create(final Task ehrTask, final Endpoint endpoint) throws CpClientException {
Task cpTask = externalizeResource(ehrTask.copy(), identifierSystem);
// TODO: Remove this after Logica bug response
cpTask.setMeta(null);
cpTask.addIdentifier().setSystem(identifierSystem).setValue(ehrTask.getIdElement().getIdPart());
try {
cpClient(endpoint).create().resource(cpTask).execute();
} catch (BaseServerResponseException exc) {
throw new CpClientException(String.format("Could not create a Task with identifier '%s' in CP at '%s'. Reason: %s.", identifierSystem + "|" + ehrTask.getIdElement().getIdPart(), endpoint.getAddress(), exc.getMessage()), exc);
}
}
use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project Gravity-SDOH-Exchange-RI by FHIR.
the class CpService method read.
public TaskInfoHolder read(final String id, final Endpoint endpoint) throws CpClientException {
try {
Bundle taskBundle = cpClient(endpoint).search().forResource(Task.class).where(Task.IDENTIFIER.exactly().systemAndValues(identifierSystem, id)).include(Task.INCLUDE_FOCUS).returnBundle(Bundle.class).execute();
// Additional validation
int tasksSize = FhirUtil.getFromBundle(taskBundle, Task.class).size();
if (tasksSize == 0) {
throw new CpClientException(String.format("No Task is present at '%s' for identifier '%s'.", endpoint.getAddress(), identifierSystem + "|" + id));
} else if (tasksSize > 1) {
throw new CpClientException(String.format("More than one Task is present at '%s' for identifier '%s'.", endpoint.getAddress(), identifierSystem + "|" + id));
}
return new TaskInfoBundleExtractor().extract(taskBundle).stream().findFirst().get();
} catch (BaseServerResponseException exc) {
throw new CpClientException(String.format("Task retrieval failed for identifier '%s' at CP location '%s'. Reason: %s.", identifierSystem + "|" + id, endpoint.getAddress(), exc.getMessage()), exc);
}
}
use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project drug-formulary-ri by HL7-DaVinci.
the class ExampleServerDstu3IT method testWebsocketSubscription.
@Test
public void testWebsocketSubscription() throws Exception {
/*
* Create subscription
*/
Subscription subscription = new Subscription();
subscription.setReason("Monitor new neonatal function (note, age will be determined by the monitor)");
subscription.setStatus(Subscription.SubscriptionStatus.REQUESTED);
subscription.setCriteria("Observation?status=final");
Subscription.SubscriptionChannelComponent channel = new Subscription.SubscriptionChannelComponent();
channel.setType(Subscription.SubscriptionChannelType.WEBSOCKET);
channel.setPayload("application/json");
subscription.setChannel(channel);
MethodOutcome methodOutcome = ourClient.create().resource(subscription).execute();
IIdType mySubscriptionId = methodOutcome.getId();
// Wait for the subscription to be activated
waitForSize(1, () -> ourClient.search().forResource(Subscription.class).where(Subscription.STATUS.exactly().code("active")).cacheControl(new CacheControlDirective().setNoCache(true)).returnBundle(Bundle.class).execute().getEntry().size());
/*
* Attach websocket
*/
WebSocketClient myWebSocketClient = new WebSocketClient();
SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);
myWebSocketClient.start();
URI echoUri = new URI("ws://localhost:" + ourPort + "/hapi-fhir-jpaserver/websocket");
ClientUpgradeRequest request = new ClientUpgradeRequest();
ourLog.info("Connecting to : {}", echoUri);
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
Session session = connection.get(2, TimeUnit.SECONDS);
ourLog.info("Connected to WS: {}", session.isOpen());
/*
* Create a matching resource
*/
Observation obs = new Observation();
obs.setStatus(Observation.ObservationStatus.FINAL);
ourClient.create().resource(obs).execute();
// Give some time for the subscription to deliver
Thread.sleep(2000);
/*
* Ensure that we receive a ping on the websocket
*/
waitForSize(1, () -> mySocketImplementation.myPingCount);
/*
* Clean up
*/
ourClient.delete().resourceById(mySubscriptionId).execute();
}
use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project ab2d by CMSgov.
the class JobProcessorIntegrationTest method when_beneHasNoEobs_notCounted.
@Test
@DisplayName("When bene has no eobs then do not count bene toward statistic")
void when_beneHasNoEobs_notCounted() {
reset(mockBfdClient);
OngoingStubbing<IBaseBundle> stubbing = when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong(), any()));
stubbing = andThenAnswerEobs(stubbing, 0, 95);
stubbing.thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle()).thenReturn(BundleUtils.createBundle());
var processedJob = cut.process(job.getJobUuid());
assertEquals(JobStatus.SUCCESSFUL, processedJob.getStatus());
assertEquals(COMPLETED_PERCENT, processedJob.getStatusMessage());
assertNotNull(processedJob.getExpiresAt());
assertNotNull(processedJob.getCompletedAt());
List<LoggableEvent> beneSearchEvents = loggerEventRepository.load(ContractSearchEvent.class);
assertEquals(1, beneSearchEvents.size());
ContractSearchEvent event = (ContractSearchEvent) beneSearchEvents.get(0);
assertEquals(JOB_UUID, event.getJobId());
assertEquals(100, event.getBenesExpected());
assertEquals(100, event.getBenesSearched());
assertEquals(CONTRACT_NAME, event.getContractNumber());
assertEquals(95, event.getBenesWithEobs());
final List<JobOutput> jobOutputs = processedJob.getJobOutputs();
assertFalse(jobOutputs.isEmpty());
}
use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project ab2d by CMSgov.
the class PatientClaimsProcessorUnitTest method process_whenPatientHasDataWithBadLastUpdated.
@Test
void process_whenPatientHasDataWithBadLastUpdated() throws ExecutionException, InterruptedException {
ExplanationOfBenefit firstEob = eob.copy();
eob.getMeta().setLastUpdated(null);
org.hl7.fhir.dstu3.model.Bundle bundle1 = EobTestDataUtil.createBundle(eob.copy());
ExplanationOfBenefit eob2 = eob.copy();
// now set the last updated date to a time before the since date (which is attribution date here)
eob2.getMeta().setLastUpdated(new Date(LATER_ATT_DATE.toInstant().toEpochMilli() - 1000));
final org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent bundleEntryComponent = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent();
bundleEntryComponent.setResource(eob2);
bundle1.addEntry(bundleEntryComponent);
ExplanationOfBenefit eob3 = eob.copy();
eob2.getMeta().setLastUpdated(new Date());
final org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent bundleEntryComponent3 = new org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent();
bundleEntryComponent3.setResource(eob3);
bundle1.addEntry(bundleEntryComponent3);
assertEquals(3, bundle1.getEntry().size());
PatientClaimsRequest request2 = new PatientClaimsRequest(List.of(coverageSummary), LATER_ATT_DATE, LATER_ATT_DATE, "client", "job", "contractNum", Contract.ContractType.NORMAL, noOpToken, STU3, tmpEfsMountDir.getAbsolutePath());
when(mockBfdClient.requestEOBFromServer(STU3, patientId, request2.getAttTime())).thenReturn(bundle1);
cut.process(request2).get();
}
Aggregations