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