use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class ProvenanceTranslatorImplTest method shouldGetCreateProvenanceForOpenmrsMetadata.
@Test
public void shouldGetCreateProvenanceForOpenmrsMetadata() {
Provenance provenance = taskProvenanceTranslator.getCreateProvenance(task);
assertThat(provenance, notNullValue());
assertThat(provenance.getId(), notNullValue());
}
use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestTranslatorImplTest method toFhirResource_shouldTranslateToFhirResourceWithReplacesFieldGivenRevisedOrder.
@Test
public void toFhirResource_shouldTranslateToFhirResourceWithReplacesFieldGivenRevisedOrder() {
discontinuedTestOrder.setAction(Order.Action.REVISE);
List<Task> tasks = setUpBasedOnScenario(Task.TaskStatus.ACCEPTED);
when(taskService.searchForTasks(any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(tasks, PREFERRED_PAGE_SIZE, COUNT));
ServiceRequest result = translator.toFhirResource(discontinuedTestOrder);
assertThat(result, notNullValue());
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(DISCONTINUED_TEST_ORDER_UUID));
assertThat(result.getReplaces().get(0).getReference(), equalTo(PRIOR_SERVICE_REQUEST_REFERENCE));
assertThat(result.getReplaces().get(0).getIdentifier().getValue(), equalTo(TEST_ORDER_NUMBER));
}
use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestTranslatorImplTest method setUpBasedOnScenario.
private List<Task> setUpBasedOnScenario(Task.TaskStatus status) {
Reference basedOnRef = new Reference();
Task task = new Task();
task.setStatus(status);
basedOnRef.setReference("ServiceRequest/" + SERVICE_REQUEST_UUID);
basedOnRef.setType("ServiceRequest");
task.addBasedOn(basedOnRef);
return Collections.singletonList(task);
}
use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestTranslatorImplTest method toFhirResource_shouldTranslateToFhirResourceWithReplacesFieldGivenDiscontinuedOrder.
@Test
public void toFhirResource_shouldTranslateToFhirResourceWithReplacesFieldGivenDiscontinuedOrder() {
discontinuedTestOrder.setAction(Order.Action.DISCONTINUE);
List<Task> tasks = setUpBasedOnScenario(Task.TaskStatus.REJECTED);
when(taskService.searchForTasks(any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(tasks, PREFERRED_PAGE_SIZE, COUNT));
ServiceRequest result = translator.toFhirResource(discontinuedTestOrder);
assertThat(result, notNullValue());
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(DISCONTINUED_TEST_ORDER_UUID));
assertThat(result.getReplaces().get(0).getReference(), equalTo(PRIOR_SERVICE_REQUEST_REFERENCE));
assertThat(result.getReplaces().get(0).getIdentifier().getValue(), equalTo(TEST_ORDER_NUMBER));
}
use of org.hl7.fhir.r5.model.Task in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestTranslatorImpl method determineServiceRequestPerformer.
private Reference determineServiceRequestPerformer(String orderUuid) {
IBundleProvider results = taskService.searchForTasks(new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam("ServiceRequest", null, orderUuid))), null, null, null, null, null, null);
Collection<Task> serviceRequestTasks = results.getResources(START_INDEX, END_INDEX).stream().map(p -> (Task) p).collect(Collectors.toList());
if (serviceRequestTasks.size() != 1) {
return null;
}
return serviceRequestTasks.iterator().next().getOwner();
}
Aggregations