use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateOutputReference.
// Task.output
@Test
public void toFhirResource_shouldTranslateOutputReference() {
FhirTask task = new FhirTask();
FhirTaskOutput output = new FhirTaskOutput();
FhirReference outputReference = new FhirReference();
Concept outputType = new Concept();
outputReference.setType(FhirConstants.DIAGNOSTIC_REPORT);
outputReference.setReference(DIAGNOSTIC_REPORT_UUID);
outputType.setUuid(CONCEPT_UUID);
output.setType(outputType);
output.setValueReference(outputReference);
task.setOutput(Collections.singleton(output));
when(conceptTranslator.toFhirResource(outputType)).thenReturn(new CodeableConcept().setCoding(Collections.singletonList(new Coding().setCode(CONCEPT_UUID))));
Task result = shouldTranslateReferenceToFhir(task, FhirConstants.DIAGNOSTIC_REPORT, DIAGNOSTIC_REPORT_UUID, output::setValueReference, t -> (Reference) t.getOutput().iterator().next().getValue());
assertThat(result.getOutput(), hasSize(1));
assertThat(result.getOutput().iterator().next().getType().getCoding().iterator().next().getCode(), equalTo(CONCEPT_UUID));
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method shouldUpdateReferenceInOpenmrs.
private FhirTask shouldUpdateReferenceInOpenmrs(Task task, String refType, String refUuid, Consumer<Reference> setFhirReference, Function<FhirTask, FhirReference> getOpenmrsReference) {
Reference fhirReference = new Reference().setReference(refUuid).setType(refType);
setFhirReference.accept(fhirReference);
FhirReference openmrsReference = new FhirReference();
openmrsReference.setReference(refUuid);
openmrsReference.setType(refType);
FhirTask openmrsTask = new FhirTask();
openmrsTask.setUuid(TASK_UUID);
openmrsTask.setEncounterReference(new FhirReference());
when(referenceTranslator.toOpenmrsType(any(Reference.class))).thenReturn(openmrsReference);
FhirTask result = taskTranslator.toOpenmrsType(openmrsTask, task);
FhirReference resultReference = getOpenmrsReference.apply(result);
assertThat(resultReference, notNullValue());
assertThat(resultReference.getReference(), equalTo(refUuid));
assertThat(resultReference.getType(), equalTo(refType));
return result;
}
Aggregations