use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByOnsetDate.
@Test
public void searchForObsConditions_shouldReturnConditionByOnsetDate() {
DateRangeParam onsetDate = new DateRangeParam(new DateParam("eq" + ONSET_DATE_TIME));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "obsDatetime", onsetDate);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getOnsetDateTimeType().getValue().toString(), containsString(ONSET_DATE));
assertThat(resultList.size(), equalTo(2));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMatchingUuidAndLastUpdated.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMatchingUuidAndLastUpdated() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(EXISTING_OBS_CONDITION_UUID));
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(DATE_CREATED).setLowerBound(DATE_CREATED);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(equalTo(1)));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(EXISTING_OBS_CONDITION_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByCode.
@Test
public void searchForObsConditions_shouldReturnConditionByCode() {
TokenAndListParam listParam = new TokenAndListParam();
listParam.addValue(new TokenOrListParam().add(new TokenParam(CODE_SYSTEM_1, CODE_VALUE_1)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, listParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getCode().getCodingFirstRep().getCode(), equalTo(CONCEPT_ID_1));
assertThat(resultList.size(), equalTo(2));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class FhirTaskServiceImplTest method getTask_shouldRetrieveTaskByUuid.
@Test
public void getTask_shouldRetrieveTaskByUuid() {
FhirTask task = new FhirTask();
org.hl7.fhir.r4.model.Task translatedTask = new org.hl7.fhir.r4.model.Task();
task.setUuid(TASK_UUID);
translatedTask.setId(TASK_UUID);
when(dao.get(TASK_UUID)).thenReturn(task);
when(translator.toFhirResource(task)).thenReturn(translatedTask);
org.hl7.fhir.r4.model.Task result = fhirTaskService.get(TASK_UUID);
assertThat(result, notNullValue());
assertThat(result, equalTo(translatedTask));
}
use of org.hl7.fhir.r5.utils.validation 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));
}
Aggregations