Search in sources :

Example 16 with ReferenceAndListParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongObsResult.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongObsResult() {
    ReferenceAndListParam param = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam(DIAGNOSTIC_REPORT_UUID)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.RESULT_SEARCH_HANDLER, param);
    IBundleProvider diagnosticReports = search(theParams);
    assertThat(diagnosticReports, notNullValue());
    assertThat(diagnosticReports.size(), equalTo(0));
    List<DiagnosticReport> resultList = get(diagnosticReports);
    assertThat(diagnosticReports, notNullValue());
    assertThat(resultList.size(), equalTo(0));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) 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 17 with ReferenceAndListParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongPatientIdentifier.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongPatientIdentifier() {
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(WRONG_PATIENT_IDENTIFIER).setChain(SP_IDENTIFIER)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
    IBundleProvider diagnosticReports = search(theParams);
    assertThat(diagnosticReports, notNullValue());
    assertThat(diagnosticReports.size(), equalTo(0));
    List<DiagnosticReport> resultList = get(diagnosticReports);
    assertThat(resultList, empty());
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) 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 18 with ReferenceAndListParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnDiagnosticReportByPatientName.

@Test
public void searchForDiagnosticReports_shouldReturnDiagnosticReportByPatientName() {
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_NAME)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
    IBundleProvider diagnosticReports = search(theParams);
    assertThat(diagnosticReports, notNullValue());
    assertThat(diagnosticReports.size(), greaterThanOrEqualTo(1));
    List<DiagnosticReport> resultList = get(diagnosticReports);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
    assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) 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 19 with ReferenceAndListParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldSearchForDiagnosticReportsByMultiplePatientFamilyNameOr.

@Test
public void searchForDiagnosticReports_shouldSearchForDiagnosticReportsByMultiplePatientFamilyNameOr() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_FAMILY_NAME);
    patient.setChain(Patient.SP_FAMILY);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_PATIENT_FAMILY_NAME);
    badPatient.setChain(Patient.SP_FAMILY);
    referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
    IBundleProvider results = search(theParams);
    assertThat(results, notNullValue());
    assertThat(results.size(), greaterThanOrEqualTo(1));
    List<DiagnosticReport> resultList = get(results);
    assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) 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 20 with ReferenceAndListParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientIdentifierAnd.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientIdentifierAnd() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_IDENTIFIER);
    patient.setChain(Patient.SP_IDENTIFIER);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_PATIENT_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);
    assertThat(results, notNullValue());
    assertThat(results.size(), equalTo(0));
    List<DiagnosticReport> resultList = get(results);
    assertThat(resultList, empty());
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) FhirDiagnosticReport(org.openmrs.module.fhir2.model.FhirDiagnosticReport) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) 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)

Aggregations

ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)358 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)358 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)358 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)354 Test (org.junit.Test)348 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)275 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)253 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)219 TokenParam (ca.uhn.fhir.rest.param.TokenParam)46 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)43 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 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)19 ArrayList (java.util.ArrayList)17 HashSet (java.util.HashSet)17 Observation (org.hl7.fhir.r4.model.Observation)15