Search in sources :

Example 16 with SearchParameterMap

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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) Matchers.containsString(org.hamcrest.Matchers.containsString) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) HashSet(java.util.HashSet) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 17 with SearchParameterMap

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));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 18 with SearchParameterMap

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));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) DateParam(ca.uhn.fhir.rest.param.DateParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 19 with SearchParameterMap

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));
}
Also used : DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) Condition(org.hl7.fhir.r4.model.Condition) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 20 with SearchParameterMap

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));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)813 Test (org.junit.Test)803 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)802 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)619 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)491 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)282 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)282 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)282 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)264 TokenParam (ca.uhn.fhir.rest.param.TokenParam)240 StringParam (ca.uhn.fhir.rest.param.StringParam)173 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)158 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)127 HashSet (java.util.HashSet)115 Include (ca.uhn.fhir.model.api.Include)108 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)75 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)60 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)57 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)51 Patient (org.hl7.fhir.r4.model.Patient)51