Search in sources :

Example 11 with SearchParameterMap

use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.

the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientGivenName.

@Test
public void searchForObsConditions_shouldReturnConditionByPatientGivenName() {
    ReferenceParam patientReference = new ReferenceParam(Patient.SP_GIVEN, PATIENT_GIVEN_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);
    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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 12 with SearchParameterMap

use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.

the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnEmptyListOfConditionsByMultiplePatientIdentifierAnd.

@Test
public void searchForObsConditions_shouldReturnEmptyListOfConditionsByMultiplePatientIdentifierAnd() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_IDENTIFIER);
    patient.setChain(Patient.SP_IDENTIFIER);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(PATIENT_WRONG_IDENTIFIER);
    badPatient.setChain(Patient.SP_IDENTIFIER);
    referenceParam.addValue(new ReferenceOrListParam().add(patient)).addAnd(new ReferenceOrListParam().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, empty());
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 13 with SearchParameterMap

use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.

the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientUuid.

@Test
public void searchForObsConditions_shouldReturnConditionByPatientUuid() {
    ReferenceParam patientReference = new ReferenceParam(null, PATIENT_UUID);
    ReferenceAndListParam patientList = new ReferenceAndListParam();
    patientList.addAnd(new ReferenceOrListParam().addOr(patientReference));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
    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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 14 with SearchParameterMap

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

Example 15 with SearchParameterMap

use of org.openmrs.module.fhir2.api.search.param.SearchParameterMap in project openmrs-module-fhir2 by openmrs.

the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnUniqueConditionsByPatientGivenName.

@Test
public void searchForObsConditions_shouldReturnUniqueConditionsByPatientGivenName() {
    ReferenceParam patientReference = new ReferenceParam(Patient.SP_GIVEN, PATIENT_GIVEN_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)

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