Search in sources :

Example 96 with ReferenceParam

use of ca.uhn.fhir.rest.param.ReferenceParam in project openmrs-module-fhir2 by openmrs.

the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantIdentifierOr.

@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultipleParticipantIdentifierOr() {
    ReferenceAndListParam participantReference = new ReferenceAndListParam();
    ReferenceParam participant = new ReferenceParam();
    participant.setValue(PARTICIPANT_IDENTIFIER);
    participant.setChain(Practitioner.SP_IDENTIFIER);
    ReferenceParam badParticipant = new ReferenceParam();
    badParticipant.setValue(WRONG_IDENTIFIER);
    badParticipant.setChain(Practitioner.SP_IDENTIFIER);
    participantReference.addValue(new ReferenceOrListParam().add(participant).add(badParticipant));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participantReference);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(13));
    List<MedicationRequest> resultList = get(results);
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(equalTo(10)));
    assertThat(resultList.get(0).getRequester().getIdentifier().getValue(), equalTo(PARTICIPANT_IDENTIFIER));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) 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 97 with ReferenceParam

use of ca.uhn.fhir.rest.param.ReferenceParam in project openmrs-module-fhir2 by openmrs.

the class MedicationRequestSearchQueryTest method searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientIdentifierOr.

@Test
public void searchForMedicationRequests_shouldSearchForMedicationRequestsByMultiplePatientIdentifierOr() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_IDENTIFIER);
    patient.setChain(Patient.SP_IDENTIFIER);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_IDENTIFIER);
    badPatient.setChain(Patient.SP_IDENTIFIER);
    referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    List<MedicationRequest> resultList = get(results);
    assertThat(results, notNullValue());
    assertThat(resultList, not(empty()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) 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 98 with ReferenceParam

use of ca.uhn.fhir.rest.param.ReferenceParam in project openmrs-module-fhir2 by openmrs.

the class ObservationSearchQueryTest method searchForObs_shouldSearchForObsByMultiplePatientUuidOr.

@Test
public void searchForObs_shouldSearchForObsByMultiplePatientUuidOr() {
    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()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
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 99 with ReferenceParam

use of ca.uhn.fhir.rest.param.ReferenceParam in project openmrs-module-fhir2 by openmrs.

the class ObservationSearchQueryTest method searchForLastnObs_shouldHandleNoCategoryRequest.

@Test
public void searchForLastnObs_shouldHandleNoCategoryRequest() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_UUID);
    referenceParam.addValue(new ReferenceOrListParam().add(patient));
    TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam().setSystem(FhirTestConstants.LOINC_SYSTEM_URL).setValue(LOINC_SYSTOLIC_BP), new TokenParam().setSystem(FhirTestConstants.CIEL_SYSTEM_URN).setValue(CIEL_DIASTOLIC_BP));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, code).addParameter(FhirConstants.MAX_SEARCH_HANDLER, new NumberParam(2)).addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam).addParameter(FhirConstants.LASTN_OBSERVATION_SEARCH_HANDLER, new StringParam());
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    List<IBaseResource> resultList = get(results);
    assertThat(resultList.size(), equalTo(2));
    assertThat(resultList, everyItem(anyOf(allOf(is(instanceOf(Observation.class))))));
    assertThat(resultList, isSortedAndWithinMax(2));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) Observation(org.hl7.fhir.r4.model.Observation) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) StringParam(ca.uhn.fhir.rest.param.StringParam) NumberParam(ca.uhn.fhir.rest.param.NumberParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) 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 100 with ReferenceParam

use of ca.uhn.fhir.rest.param.ReferenceParam in project openmrs-module-fhir2 by openmrs.

the class ObservationSearchQueryTest method searchForObs_shouldSearchForObsByMultiplePatientIdentifierOr.

@Test
public void searchForObs_shouldSearchForObsByMultiplePatientIdentifierOr() {
    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).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()));
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList, everyItem(hasProperty("subject", hasProperty("reference", endsWith(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)

Aggregations

ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)468 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)460 Test (org.junit.Test)452 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)358 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)354 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)275 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)253 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)221 TokenParam (ca.uhn.fhir.rest.param.TokenParam)47 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)45 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)37 NumberParam (ca.uhn.fhir.rest.param.NumberParam)33 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)32 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)28 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)26 FhirDiagnosticReport (org.openmrs.module.fhir2.model.FhirDiagnosticReport)26 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)20 ArrayList (java.util.ArrayList)20 HashSet (java.util.HashSet)19 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)19