use of ca.uhn.fhir.rest.param.ReferenceAndListParam in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientFamilyNameAnd.
@Test
public void searchForDiagnosticReports_shouldReturnEmptyListOfDiagnosticReportsByMultiplePatientFamilyNameAnd() {
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)).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());
}
use of ca.uhn.fhir.rest.param.ReferenceAndListParam in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportSearchQueryTest method searchForDiagnosticReports_shouldAddNotNullPatientToReturnedResults.
@Test
public void searchForDiagnosticReports_shouldAddNotNullPatientToReturnedResults() {
ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_IDENTIFIER).setChain(Patient.SP_IDENTIFIER)));
HashSet<Include> includes = new HashSet<>();
Include include = new Include("DiagnosticReport:patient");
includes.add(include);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
IBundleProvider results = search(theParams);
assertThat(results.size(), equalTo(2));
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(results, notNullValue());
// included resource added as part of the result list
assertThat(resultList.size(), equalTo(3));
DiagnosticReport returnedDiagnosticReport = (DiagnosticReport) resultList.iterator().next();
assertThat(resultList, hasItem(allOf(is(instanceOf(Patient.class)), hasProperty("id", equalTo(returnedDiagnosticReport.getSubject().getReferenceElement().getIdPart())))));
}
use of ca.uhn.fhir.rest.param.ReferenceAndListParam 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));
}
use of ca.uhn.fhir.rest.param.ReferenceAndListParam 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());
}
use of ca.uhn.fhir.rest.param.ReferenceAndListParam 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());
}
Aggregations