use of org.openmrs.module.fhir2.model.FhirTaskOutput in project openmrs-module-fhir2 by openmrs.
the class FhirTaskDaoImplTest method saveTask_shouldUpdateOutput.
@Test
public void saveTask_shouldUpdateOutput() throws Exception {
executeDataSet(CONCEPT_DATA_XML);
HibernateConceptDAO cd = new HibernateConceptDAO();
cd.setSessionFactory(sessionFactory);
FhirTask toUpdate = dao.get(TASK_UUID);
FhirReference outputReference = new FhirReference();
outputReference.setType(FhirConstants.DIAGNOSTIC_REPORT);
outputReference.setReference(DIAGNOSTIC_REPORT_UUID);
outputReference.setName("TEMP");
Concept type = cd.getConceptByUuid(CONCEPT_UUID);
assertThat(type, notNullValue());
FhirTaskOutput output = new FhirTaskOutput();
output.setValueReference(outputReference);
output.setType(type);
output.setName("TEMP");
// TODO: why is this not autogenerated?
output.setId(23423);
toUpdate.setOutput(Collections.singleton(output));
FhirTask result = dao.get(TASK_UUID);
assertThat(result.getOutput(), notNullValue());
assertThat(result.getOutput(), not(empty()));
assertThat(result.getOutput(), hasItem(hasProperty("type", hasProperty("uuid", equalTo(CONCEPT_UUID)))));
assertThat(result.getOutput(), hasItem(hasProperty("valueReference", hasProperty("reference", equalTo(DIAGNOSTIC_REPORT_UUID)))));
}
use of org.openmrs.module.fhir2.model.FhirTaskOutput in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toOpenmrsType_shouldUpdateOutputReference.
@Test
public void toOpenmrsType_shouldUpdateOutputReference() {
Task task = new Task();
Task.TaskOutputComponent output = new Task.TaskOutputComponent();
Reference outputReference = new Reference().setReference(DIAGNOSTIC_REPORT_UUID).setType(FhirConstants.DIAGNOSTIC_REPORT);
CodeableConcept outputType = new CodeableConcept().setText("some text");
output.setType(outputType).setValue(outputReference);
Concept openmrsOutputType = new Concept();
openmrsOutputType.setUuid(CONCEPT_UUID);
task.setOutput(Collections.singletonList(output));
FhirTask openmrsTask = new FhirTask();
openmrsTask.setUuid(TASK_UUID);
openmrsTask.setOutput(Collections.singleton(new FhirTaskOutput()));
when(conceptTranslator.toOpenmrsType(outputType)).thenReturn(openmrsOutputType);
FhirTask result = shouldUpdateReferenceInOpenmrs(task, FhirConstants.DIAGNOSTIC_REPORT, DIAGNOSTIC_REPORT_UUID, output::setValue, t -> t.getOutput().iterator().next().getValueReference());
assertThat(result.getOutput(), hasSize(1));
assertThat(result.getOutput().iterator().next().getType().getUuid(), equalTo(CONCEPT_UUID));
}
use of org.openmrs.module.fhir2.model.FhirTaskOutput 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.FhirTaskOutput in project openmrs-module-fhir2 by openmrs.
the class TaskTranslatorImpl method translateFromOutputReferences.
private Task.TaskOutputComponent translateFromOutputReferences(FhirTaskOutput openmrsOutput) {
Reference ref = referenceTranslator.toFhirResource(openmrsOutput.getValueReference());
CodeableConcept type = conceptTranslator.toFhirResource(openmrsOutput.getType());
return new Task.TaskOutputComponent().setType(type).setValue(ref);
}
use of org.openmrs.module.fhir2.model.FhirTaskOutput in project openmrs-module-fhir2 by openmrs.
the class FhirTaskTranslatorImplTest method toFhirResource_shouldTranslateOutputReference.
// Task.output
@Test
public void toFhirResource_shouldTranslateOutputReference() {
FhirTask task = new FhirTask();
FhirTaskOutput output = new FhirTaskOutput();
FhirReference outputReference = new FhirReference();
Concept outputType = new Concept();
outputReference.setType(FhirConstants.DIAGNOSTIC_REPORT);
outputReference.setReference(DIAGNOSTIC_REPORT_UUID);
outputType.setUuid(CONCEPT_UUID);
output.setType(outputType);
output.setValueReference(outputReference);
task.setOutput(Collections.singleton(output));
when(conceptTranslator.toFhirResource(outputType)).thenReturn(new CodeableConcept().setCoding(Collections.singletonList(new Coding().setCode(CONCEPT_UUID))));
Task result = shouldTranslateReferenceToFhir(task, FhirConstants.DIAGNOSTIC_REPORT, DIAGNOSTIC_REPORT_UUID, output::setValueReference, t -> (Reference) t.getOutput().iterator().next().getValue());
assertThat(result.getOutput(), hasSize(1));
assertThat(result.getOutput().iterator().next().getType().getCoding().iterator().next().getCode(), equalTo(CONCEPT_UUID));
}
Aggregations