Search in sources :

Example 71 with org.hl7.fhir.r5.model

use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.

the class FhirTaskServiceImplTest method updateTask_shouldUpdateExistingTask.

@Test
public void updateTask_shouldUpdateExistingTask() {
    org.hl7.fhir.r4.model.Task fhirTask = new org.hl7.fhir.r4.model.Task();
    FhirTask openmrsTask = new FhirTask();
    FhirTask updatedOpenmrsTask = new FhirTask();
    fhirTask.setId(TASK_UUID);
    fhirTask.setStatus(FHIR_NEW_TASK_STATUS);
    fhirTask.setIntent(FHIR_TASK_INTENT);
    openmrsTask.setUuid(TASK_UUID);
    openmrsTask.setStatus(OPENMRS_TASK_STATUS);
    openmrsTask.setIntent(OPENMRS_TASK_INTENT);
    updatedOpenmrsTask.setUuid(TASK_UUID);
    updatedOpenmrsTask.setStatus(OPENMRS_NEW_TASK_STATUS);
    openmrsTask.setIntent(OPENMRS_TASK_INTENT);
    when(translator.toOpenmrsType(openmrsTask, fhirTask)).thenReturn(updatedOpenmrsTask);
    when(dao.createOrUpdate(updatedOpenmrsTask)).thenReturn(updatedOpenmrsTask);
    when(dao.get(TASK_UUID)).thenReturn(openmrsTask);
    when(translator.toFhirResource(updatedOpenmrsTask)).thenReturn(fhirTask);
    org.hl7.fhir.r4.model.Task result = fhirTaskService.update(TASK_UUID, fhirTask);
    assertThat(result, notNullValue());
    assertThat(result, equalTo(fhirTask));
}
Also used : Task(org.hl7.fhir.r4.model.Task) Task(org.hl7.fhir.r4.model.Task) FhirTask(org.openmrs.module.fhir2.model.FhirTask) FhirTask(org.openmrs.module.fhir2.model.FhirTask) Test(org.junit.Test)

Example 72 with org.hl7.fhir.r5.model

use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.

the class FhirPatientServiceImplTest method setUp.

@Before
public void setUp() {
    patientService = new FhirPatientServiceImpl() {

        @Override
        protected void validateObject(Patient object) {
        }
    };
    patientService.setDao(dao);
    patientService.setTranslator(patientTranslator);
    patientService.setSearchQuery(searchQuery);
    patientService.setSearchQueryInclude(searchQueryInclude);
    PersonName name = new PersonName();
    name.setFamilyName(PATIENT_FAMILY_NAME);
    name.setGivenName(PATIENT_GIVEN_NAME);
    patient = new Patient();
    patient.setUuid(PATIENT_UUID);
    patient.setGender("M");
    patient.addName(name);
    PersonAddress address = new PersonAddress();
    address.setCityVillage(CITY);
    address.setStateProvince(STATE);
    address.setPostalCode(POSTAL_CODE);
    address.setCountry(COUNTRY);
    HumanName humanName = new HumanName();
    humanName.addGiven(PATIENT_GIVEN_NAME);
    humanName.setFamily(PATIENT_FAMILY_NAME);
    fhirPatient = new org.hl7.fhir.r4.model.Patient();
    fhirPatient.setId(PATIENT_UUID);
    fhirPatient.addName(humanName);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) PersonAddress(org.openmrs.PersonAddress) Patient(org.openmrs.Patient) Before(org.junit.Before)

Example 73 with org.hl7.fhir.r5.model

use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.

the class FhirConditionServiceImplTest method delete_shouldDeleteExistingCondition.

@Test
public void delete_shouldDeleteExistingCondition() {
    when(dao.delete(OBS_UUID)).thenReturn(obsCondition);
    when(translator.toFhirResource(obsCondition)).thenReturn(condition);
    org.hl7.fhir.r4.model.Condition result = fhirConditionService.delete(OBS_UUID);
    assertThat(result, notNullValue());
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Test(org.junit.Test)

Example 74 with org.hl7.fhir.r5.model

use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.

the class FhirConditionServiceImplTest method update_shouldUpdateExistingObsCondition.

@Test
public void update_shouldUpdateExistingObsCondition() {
    when(dao.get(OBS_UUID)).thenReturn(obsCondition);
    when(translator.toFhirResource(obsCondition)).thenReturn(condition);
    when(dao.createOrUpdate(obsCondition)).thenReturn(obsCondition);
    when(translator.toOpenmrsType(any(Obs.class), any(org.hl7.fhir.r4.model.Condition.class))).thenReturn(obsCondition);
    org.hl7.fhir.r4.model.Condition result = fhirConditionService.update(OBS_UUID, condition);
    assertThat(result, notNullValue());
    assertThat(result.getId(), notNullValue());
    assertThat(result.getId(), equalTo(OBS_UUID));
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Obs(org.openmrs.Obs) Condition(org.hl7.fhir.r4.model.Condition) Test(org.junit.Test)

Example 75 with org.hl7.fhir.r5.model

use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.

the class FhirConditionServiceImplTest method update_shouldThrowExceptionWhenIdIsNull.

@Test
public void update_shouldThrowExceptionWhenIdIsNull() {
    org.hl7.fhir.r4.model.Condition condition = new org.hl7.fhir.r4.model.Condition();
    assertThrows(InvalidRequestException.class, () -> fhirConditionService.update(null, condition));
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Condition(org.hl7.fhir.r4.model.Condition) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)435 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)289 ArrayList (java.util.ArrayList)112 FHIRException (org.hl7.fhir.exceptions.FHIRException)111 IOException (java.io.IOException)84 List (java.util.List)73 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)68 FileOutputStream (java.io.FileOutputStream)66 File (java.io.File)61 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 InputStream (java.io.InputStream)55 TableModel (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 Bundle (org.hl7.fhir.dstu3.model.Bundle)49 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Collectors (java.util.stream.Collectors)48 Arrays (java.util.Arrays)46