use of org.hl7.fhir.r5.model in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMultiplePatientUuidOr.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMultiplePatientUuidOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_UUID);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_UUID);
referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r5.model 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.model 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.model 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.model 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));
}
Aggregations