Search in sources :

Example 1 with HibernateConceptDAO

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))));
}
Also used : Concept(org.openmrs.Concept) HibernateConceptDAO(org.openmrs.api.db.hibernate.HibernateConceptDAO) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTaskInput(org.openmrs.module.fhir2.model.FhirTaskInput) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 2 with HibernateConceptDAO

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)))));
}
Also used : Concept(org.openmrs.Concept) HibernateConceptDAO(org.openmrs.api.db.hibernate.HibernateConceptDAO) FhirTaskOutput(org.openmrs.module.fhir2.model.FhirTaskOutput) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirReference(org.openmrs.module.fhir2.model.FhirReference) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Concept (org.openmrs.Concept)2 HibernateConceptDAO (org.openmrs.api.db.hibernate.HibernateConceptDAO)2 FhirTask (org.openmrs.module.fhir2.model.FhirTask)2 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)2 FhirReference (org.openmrs.module.fhir2.model.FhirReference)1 FhirTaskInput (org.openmrs.module.fhir2.model.FhirTaskInput)1 FhirTaskOutput (org.openmrs.module.fhir2.model.FhirTaskOutput)1