use of ca.uhn.fhir.rest.param.ReferenceOrListParam 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));
}
use of ca.uhn.fhir.rest.param.ReferenceOrListParam 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());
}
use of ca.uhn.fhir.rest.param.ReferenceOrListParam in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldReturnEmptyCollectionOfEncountersByWrongSubjectIdentifier.
@Test
public void searchForEncounters_shouldReturnEmptyCollectionOfEncountersByWrongSubjectIdentifier() {
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
ReferenceParam subject = new ReferenceParam();
subject.setValue(WRONG_PATIENT_IDENTIFIER);
subject.setChain(Patient.SP_IDENTIFIER);
subjectReference.addValue(new ReferenceOrListParam().add(subject));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, subjectReference);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, is(empty()));
}
use of ca.uhn.fhir.rest.param.ReferenceOrListParam in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldSearchForEncountersBySubjectGivenName.
@Test
public void searchForEncounters_shouldSearchForEncountersBySubjectGivenName() {
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
ReferenceParam subject = new ReferenceParam();
subject.setValue(PATIENT_GIVEN_NAME);
subject.setChain(Patient.SP_GIVEN);
subjectReference.addValue(new ReferenceOrListParam().add(subject));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, subjectReference);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getId(), equalTo(ENCOUNTER_UUID));
}
use of ca.uhn.fhir.rest.param.ReferenceOrListParam in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldReturnEmptyListOfEncountersByMultipleSubjectNameAnd.
@Test
public void searchForEncounters_shouldReturnEmptyListOfEncountersByMultipleSubjectNameAnd() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_FULL_NAME);
patient.setChain(Patient.SP_NAME);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(WRONG_NAME);
badPatient.setChain(Patient.SP_NAME);
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<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
Aggregations