Search in sources :

Example 11 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 FhirReference openmrsReference, @Nonnull Reference fhirReference) {
    if (fhirReference != null) {
        if (openmrsReference == 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 12 with FhirReference

use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.

the class TaskTranslatorImpl method translateToOutputReference.

private FhirTaskOutput translateToOutputReference(Task.TaskOutputComponent taskOutputComponent) {
    FhirReference outputReference = referenceTranslator.toOpenmrsType((Reference) taskOutputComponent.getValue());
    Concept type = conceptTranslator.toOpenmrsType(taskOutputComponent.getType());
    FhirTaskOutput output = new FhirTaskOutput();
    output.setValueReference(outputReference);
    output.setType(type);
    output.setName("TaskOutputComponent/" + output.getUuid());
    return output;
}
Also used : CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Concept(org.openmrs.Concept) FhirTaskOutput(org.openmrs.module.fhir2.model.FhirTaskOutput) FhirReference(org.openmrs.module.fhir2.model.FhirReference)

Example 13 with FhirReference

use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.

the class FhirTaskDaoImplTest method saveTask_shouldUpdateBasedOnReferences.

@Test
public void saveTask_shouldUpdateBasedOnReferences() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference basedOnReference = new FhirReference();
    basedOnReference.setType(FhirConstants.SERVICE_REQUEST);
    basedOnReference.setReference(BASED_ON_ORDER_UUID);
    basedOnReference.setName("TEMP");
    toUpdate.setBasedOnReferences(Collections.singleton(basedOnReference));
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getBasedOnReferences(), notNullValue());
    assertThat(result.getBasedOnReferences().size(), greaterThan(0));
    assertThat(result.getBasedOnReferences(), hasItem(hasProperty("type", equalTo(FhirConstants.SERVICE_REQUEST))));
    assertThat(result.getBasedOnReferences(), hasItem(hasProperty("reference", equalTo(BASED_ON_ORDER_UUID))));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirReference(org.openmrs.module.fhir2.model.FhirReference) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 14 with FhirReference

use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.

the class FhirTaskDaoImplTest method saveTask_shouldUpdateOwnerReference.

@Test
public void saveTask_shouldUpdateOwnerReference() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference ownerReference = new FhirReference();
    ownerReference.setType(FhirConstants.PRACTITIONER);
    ownerReference.setReference(USER_UUID);
    ownerReference.setName("TEMP");
    toUpdate.setOwnerReference(ownerReference);
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getOwnerReference(), notNullValue());
    assertThat(result.getOwnerReference().getId(), notNullValue());
    assertThat(result.getOwnerReference().getType(), equalTo(FhirConstants.PRACTITIONER));
    assertThat(result.getOwnerReference().getReference(), equalTo(USER_UUID));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirReference(org.openmrs.module.fhir2.model.FhirReference) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 15 with FhirReference

use of org.openmrs.module.fhir2.model.FhirReference in project openmrs-module-fhir2 by openmrs.

the class FhirTaskDaoImplTest method saveTask_shouldUpdateForReference.

@Test
public void saveTask_shouldUpdateForReference() {
    FhirTask toUpdate = dao.get(TASK_UUID);
    FhirReference forReference = new FhirReference();
    forReference.setType(FhirConstants.PATIENT);
    forReference.setReference(PATIENT_ID);
    forReference.setName("TEMP");
    toUpdate.setForReference(forReference);
    dao.createOrUpdate(toUpdate);
    FhirTask result = dao.get(TASK_UUID);
    assertThat(result.getForReference(), notNullValue());
    assertThat(result.getForReference().getId(), notNullValue());
    assertThat(result.getForReference().getType(), equalTo(FhirConstants.PATIENT));
    assertThat(result.getForReference().getReference(), equalTo(PATIENT_ID));
}
Also used : FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirReference(org.openmrs.module.fhir2.model.FhirReference) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) 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