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);
}
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());
}
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));
}
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));
}
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));
}
Aggregations