use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnUniqueConditionsByPatientFamilyName.
@Test
public void searchForObsConditions_shouldReturnUniqueConditionsByPatientFamilyName() {
ReferenceParam patientReference = new ReferenceParam(Patient.SP_FAMILY, PATIENT_FAMILY_NAME);
ReferenceAndListParam patientList = new ReferenceAndListParam();
patientList.addValue(new ReferenceOrListParam().add(patientReference));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(2));
Set<String> resultSet = new HashSet<>(dao.getSearchResultUuids(theParams));
assertThat(resultSet.size(), equalTo(2));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnMultipleConditionsByCodeListAndNoSystem.
@Test
public void searchForObsConditions_shouldReturnMultipleConditionsByCodeListAndNoSystem() {
TokenAndListParam listParam = new TokenAndListParam();
listParam.addValue(new TokenOrListParam().add(new TokenParam(CONCEPT_ID_1)).add(new TokenParam(CONCEPT_ID_2)));
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(resultList.size(), equalTo(2));
}
use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap 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.openmrs.module.fhir2.api.search.param.SearchParameterMap 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.openmrs.module.fhir2.api.search.param.SearchParameterMap 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));
}
Aggregations