Search in sources :

Example 56 with org.hl7.fhir.r5.utils.validation

use of org.hl7.fhir.r5.utils.validation 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 57 with org.hl7.fhir.r5.utils.validation

use of org.hl7.fhir.r5.utils.validation 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 58 with org.hl7.fhir.r5.utils.validation

use of org.hl7.fhir.r5.utils.validation 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 59 with org.hl7.fhir.r5.utils.validation

use of org.hl7.fhir.r5.utils.validation 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)

Example 60 with org.hl7.fhir.r5.utils.validation

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

the class FhirConditionServiceImplTest method create_shouldCreateNewCondition.

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

Aggregations

Test (org.junit.jupiter.api.Test)427 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)334 Test (org.junit.Test)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)104 ArrayList (java.util.ArrayList)101 IOException (java.io.IOException)78 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)70 Date (java.util.Date)65 List (java.util.List)64 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)61 FileOutputStream (java.io.FileOutputStream)59 CodeableReference (org.hl7.fhir.r5.model.CodeableReference)58 File (java.io.File)57 InputStream (java.io.InputStream)51 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)48 Bundle (org.hl7.fhir.dstu3.model.Bundle)48 MethodSource (org.junit.jupiter.params.provider.MethodSource)46 Arrays (java.util.Arrays)45 Collectors (java.util.stream.Collectors)45