use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestSearchQueryTest method searchForServiceRequests_shouldReturnServiceRequestsByPatientGivenName.
@Test
public void searchForServiceRequests_shouldReturnServiceRequestsByPatientGivenName() {
ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_GIVEN)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(4));
List<ServiceRequest> resources = get(results);
assertThat(resources, not(empty()));
assertThat(resources, everyItem(hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo(PATIENT_UUID))))));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestSearchQueryTest method searchForServiceRequests_shouldReturnServiceRequestsByPatientUuidAndPatientGivenName.
@Test
public void searchForServiceRequests_shouldReturnServiceRequestsByPatientUuidAndPatientGivenName() {
ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_UUID))).addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME).setChain(Patient.SP_GIVEN)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(4));
List<ServiceRequest> resources = get(results);
assertThat(resources, not(empty()));
assertThat(resources, everyItem(hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo(PATIENT_UUID))))));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ServiceRequestSearchQueryTest method searchForServiceRequests_shouldReturnServiceRequestsByPatientName.
@Test
public void searchForServiceRequests_shouldReturnServiceRequestsByPatientName() {
ReferenceAndListParam patientReference = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(PATIENT_GIVEN_NAME + " " + PATIENT_FAMILY_NAME).setChain(Patient.SP_NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientReference);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(4));
List<ServiceRequest> resources = get(results);
assertThat(resources, not(empty()));
assertThat(resources, everyItem(hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo(PATIENT_UUID))))));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class PatientSearchQueryTest method searchForPatients_shouldReverseIncludeMedicationRequestsWithReturnedResults.
@Test
public void searchForPatients_shouldReverseIncludeMedicationRequestsWithReturnedResults() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PATIENT_OTHER3_UUID));
HashSet<Include> revIncludes = new HashSet<>();
revIncludes.add(new Include("MedicationRequest:patient"));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.REVERSE_INCLUDE_SEARCH_HANDLER, revIncludes);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(results, notNullValue());
// reverse included resources added as part of the result list
assertThat(resultList.size(), equalTo(9));
assertThat(resultList.subList(1, 9), everyItem(allOf(is(instanceOf(MedicationRequest.class)), hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo(PATIENT_OTHER3_UUID)))))));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class PatientSearchQueryTest method searchForPatients_shouldReverseIncludeProcedureRequestsWithReturnedResults.
@Test
public void searchForPatients_shouldReverseIncludeProcedureRequestsWithReturnedResults() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(PATIENT_OTHER3_UUID));
HashSet<Include> revIncludes = new HashSet<>();
revIncludes.add(new Include("ProcedureRequest:patient"));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.REVERSE_INCLUDE_SEARCH_HANDLER, revIncludes);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<IBaseResource> resultList = results.getResources(START_INDEX, END_INDEX);
assertThat(results, notNullValue());
// reverse included resources added as part of the result list
assertThat(resultList.size(), equalTo(4));
assertThat(resultList.subList(1, 4), everyItem(allOf(is(instanceOf(ServiceRequest.class)), hasProperty("subject", hasProperty("referenceElement", hasProperty("idPart", equalTo(PATIENT_OTHER3_UUID)))))));
}
Aggregations