use of ca.uhn.fhir.rest.param.ReferenceParam 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));
}
use of ca.uhn.fhir.rest.param.ReferenceParam 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));
}
use of ca.uhn.fhir.rest.param.ReferenceParam in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnUniqueConditionsByPatientFamilyName.
@Test
public void searchForObsConditions_shouldReturnUniqueConditionsByPatientFamilyName() {
ReferenceParam patientReference = new ReferenceParam(Patient.SP_FAMILY, PATIENT_FAMILY_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));
}
use of ca.uhn.fhir.rest.param.ReferenceParam 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));
}
use of ca.uhn.fhir.rest.param.ReferenceParam 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());
}
Aggregations