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