use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImpl method toFhirResource.
@Override
public Reference toFhirResource(@Nonnull FhirReference openmrsTask) {
Reference fhirReference = null;
if (openmrsTask != null) {
fhirReference = new Reference();
fhirReference.setType(openmrsTask.getType());
fhirReference.setReference(openmrsTask.getReference());
}
return fhirReference;
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImpl method toOpenmrsType.
@Override
public FhirReference toOpenmrsType(@Nonnull Reference fhirReference) {
FhirReference openmrsReference = null;
if (fhirReference != null) {
openmrsReference = new FhirReference();
openmrsReference.setType(fhirReference.getType());
openmrsReference.setReference(fhirReference.getReference());
openmrsReference.setName(fhirReference.getType() + "/" + fhirReference.getReference());
}
return openmrsReference;
}
use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.
the class ReferenceTranslatorImplTest method toOpenmrsType_shouldCreateFhirReferenceIfNull.
@Test
public void toOpenmrsType_shouldCreateFhirReferenceIfNull() {
Reference reference = new Reference().setReference(REFERENCE).setType(TYPE);
FhirReference result = referenceTranslator.toOpenmrsType(null, 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 FhirTaskTranslatorImplTest method shouldTranslateReferenceListToOpenmrs.
private void shouldTranslateReferenceListToOpenmrs(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);
when(referenceTranslator.toOpenmrsType(any(Reference.class))).thenReturn(openmrsReference);
FhirTask result = taskTranslator.toOpenmrsType(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 FhirTaskTranslatorImplTest method shouldTranslateReferenceToOpenmrs.
private FhirTask shouldTranslateReferenceToOpenmrs(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);
when(referenceTranslator.toOpenmrsType(any(Reference.class))).thenReturn(openmrsReference);
FhirTask result = taskTranslator.toOpenmrsType(task);
FhirReference resultReference = getOpenmrsReference.apply(result);
assertThat(resultReference, notNullValue());
assertThat(resultReference.getReference(), equalTo(refUuid));
assertThat(resultReference.getType(), equalTo(refType));
return result;
}
Aggregations