use of org.openmrs.api.db.hibernate.HibernateConceptDAO in project openmrs-module-fhir2 by openmrs.
the class FhirTaskDaoImplTest method saveTask_shouldUpdateInput.
@Test
public void saveTask_shouldUpdateInput() throws Exception {
executeDataSet(CONCEPT_DATA_XML);
HibernateConceptDAO cd = new HibernateConceptDAO();
cd.setSessionFactory(sessionFactory);
FhirTask toUpdate = dao.get(TASK_UUID);
Double someNumericVal = 123123.11;
Concept type = cd.getConceptByUuid(CONCEPT_UUID);
assertThat(type, notNullValue());
FhirTaskInput input = new FhirTaskInput();
input.setValueNumeric(someNumericVal);
input.setType(type);
input.setName("TEMP");
// TODO: why is this not autogenerated?
input.setId(23423);
toUpdate.setInput(Collections.singleton(input));
FhirTask result = dao.get(TASK_UUID);
assertThat(result.getInput(), notNullValue());
assertThat(result.getInput(), not(empty()));
assertThat(result.getInput(), hasItem(hasProperty("type", hasProperty("uuid", equalTo(CONCEPT_UUID)))));
assertThat(result.getInput(), hasItem(hasProperty("valueNumeric", equalTo(someNumericVal))));
}
use of org.openmrs.api.db.hibernate.HibernateConceptDAO 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)))));
}
Aggregations