Search in sources :

Example 6 with FhirReference

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));
}
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 7 with FhirReference

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

Example 8 with FhirReference

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));
}
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 9 with FhirReference

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));
}
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 10 with FhirReference

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));
}
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)

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