Search in sources :

Example 26 with ReferenceParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldHandleComplexQuery.

@Test
public void searchForDiagnosticReports_shouldHandleComplexQuery() {
    TokenAndListParam code = new TokenAndListParam().addAnd(new TokenOrListParam().add(new TokenParam(DIAGNOSTIC_REPORT_CODE)));
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_GIVEN)));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.CODED_SEARCH_HANDLER, code).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)));
    DiagnosticReport diagnosticReport = resultList.get(0);
    assertThat(diagnosticReport.getCode().getCodingFirstRep().getCode(), equalTo(CONCEPT_UUID));
    assertThat(diagnosticReport.getIdElement().getIdPart(), equalTo(DIAGNOSTIC_REPORT_UUID));
}
Also used : TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) 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) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) 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 27 with ReferenceParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongPatientFamilyName.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongPatientFamilyName() {
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(WRONG_PATIENT_FAMILY_NAME).setChain(SP_FAMILY)));
    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 28 with ReferenceParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongPatientName.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyCollectionByWrongPatientName() {
    ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(WRONG_PATIENT_GIVEN_NAME).setChain(SP_NAME)));
    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 29 with ReferenceParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldSearchForDiagnosticReportsByMultiplePatientIdentifierOr.

@Test
public void searchForDiagnosticReports_shouldSearchForDiagnosticReportsByMultiplePatientIdentifierOr() {
    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).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)));
    assertThat(resultList.get(0).getSubject().getReference(), endsWith(PATIENT_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 30 with ReferenceParam

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

the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientUuidAnd.

@Test
public void searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientUuidAnd() {
    ReferenceAndListParam referenceParam = new ReferenceAndListParam();
    ReferenceParam patient = new ReferenceParam();
    patient.setValue(PATIENT_UUID);
    ReferenceParam badPatient = new ReferenceParam();
    badPatient.setValue(WRONG_PATIENT_UUID);
    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<DiagnosticReport> resultList = get(results);
    assertThat(results, notNullValue());
    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

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