Search in sources :

Example 16 with FhirReference

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;
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) FhirReference(org.openmrs.module.fhir2.model.FhirReference)

Example 17 with 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;
}
Also used : FhirReference(org.openmrs.module.fhir2.model.FhirReference)

Example 18 with FhirReference

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));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) FhirReference(org.openmrs.module.fhir2.model.FhirReference) FhirReference(org.openmrs.module.fhir2.model.FhirReference) Test(org.junit.Test)

Example 19 with FhirReference

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));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) Reference(org.hl7.fhir.r4.model.Reference) FhirReference(org.openmrs.module.fhir2.model.FhirReference) FhirReference(org.openmrs.module.fhir2.model.FhirReference)

Example 20 with FhirReference

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;
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) Reference(org.hl7.fhir.r4.model.Reference) FhirReference(org.openmrs.module.fhir2.model.FhirReference) FhirReference(org.openmrs.module.fhir2.model.FhirReference)

Aggregations

FhirReference (org.openmrs.module.fhir2.model.FhirReference)22 FhirTask (org.openmrs.module.fhir2.model.FhirTask)13 Test (org.junit.Test)12 Reference (org.hl7.fhir.r4.model.Reference)11 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)6 Task (org.hl7.fhir.r4.model.Task)3 Concept (org.openmrs.Concept)3 FhirTaskOutput (org.openmrs.module.fhir2.model.FhirTaskOutput)3 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 Coding (org.hl7.fhir.r4.model.Coding)1 HibernateConceptDAO (org.openmrs.api.db.hibernate.HibernateConceptDAO)1