use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method shouldUpdateReferenceListInOpenmrs.
private void shouldUpdateReferenceListInOpenmrs(Task task, String refType, String refUuid, Consumer<List<Reference>> setFhirReference, Function<FhirTask, Set<FhirReference>> getOpenmrsReference) {
Reference fhirReference = new Reference().setReference(refUuid).setType(refType);
setFhirReference.accept(Collections.singletonList(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);
Collection<FhirReference> resultReference = getOpenmrsReference.apply(result);
assertThat(resultReference, notNullValue());
assertThat(resultReference, hasSize(1));
assertThat(resultReference.iterator().next().getReference(), equalTo(refUuid));
assertThat(resultReference.iterator().next().getType(), equalTo(refType));
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImplTest method toOpenmrsType_shouldReturnNullIfReferenceNull.
@Test
public void toOpenmrsType_shouldReturnNullIfReferenceNull() {
FhirReference result = referenceTranslator.toOpenmrsType(null);
assertThat(result, nullValue());
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImplTest method toOpenmrsType_shouldUpdateFhirReferenceWithReference.
@Test
public void toOpenmrsType_shouldUpdateFhirReferenceWithReference() {
Reference reference = new Reference().setReference(REFERENCE).setType(TYPE);
FhirReference openmrsReference = new FhirReference();
openmrsReference.setReference("some-uuid");
openmrsReference.setType(FhirConstants.SERVICE_REQUEST);
FhirReference result = referenceTranslator.toOpenmrsType(openmrsReference, reference);
assertThat(result, notNullValue());
assertThat(result.getReference(), equalTo(REFERENCE));
assertThat(result.getType(), equalTo(TYPE));
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImplTest method toOpenmrsType_shouldConvertReferenceToFhirReference.
@Test
public void toOpenmrsType_shouldConvertReferenceToFhirReference() {
Reference reference = new Reference().setReference(REFERENCE).setType(TYPE);
FhirReference result = referenceTranslator.toOpenmrsType(reference);
assertThat(result, notNullValue());
assertThat(result.getReference(), equalTo(REFERENCE));
assertThat(result.getType(), equalTo(TYPE));
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImplTest method toFhirResource_shouldConvertFhirReferenceToReference.
@Test
public void toFhirResource_shouldConvertFhirReferenceToReference() {
FhirReference openmrsReference = new FhirReference();
openmrsReference.setReference(REFERENCE);
openmrsReference.setType(TYPE);
Reference result = referenceTranslator.toFhirResource(openmrsReference);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(TYPE));
assertThat(result.getReference(), equalTo(REFERENCE));
}
Aggregations