use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldSearchForEncountersBySubjectName.
@Test
public void searchForEncounters_shouldSearchForEncountersBySubjectName() {
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
ReferenceParam subject = new ReferenceParam();
subject.setValue(PATIENT_FULL_NAME);
subject.setChain(Patient.SP_NAME);
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 org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldSearchForEncountersBySubjectIdentifier.
@Test
public void searchForEncounters_shouldSearchForEncountersBySubjectIdentifier() {
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
ReferenceParam subject = new ReferenceParam();
subject.setValue(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, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getSubject().getReference(), endsWith(PATIENT_UUID));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldHandleMultipleReverseIncludes.
@Test
public void searchForEncounters_shouldHandleMultipleReverseIncludes() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(ENCOUNTER_UUID));
HashSet<Include> revIncludes = new HashSet<>();
revIncludes.add(new Include("ServiceRequest:encounter"));
revIncludes.add(new Include("MedicationRequest:encounter"));
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 = get(results);
assertThat(results, notNullValue());
// reverse included resources (8 medication request + 3 service request) added as part of the result list
assertThat(resultList.size(), equalTo(12));
assertThat(resultList.subList(1, 12), everyItem(allOf(anyOf(is(instanceOf(MedicationRequest.class)), is(instanceOf(ServiceRequest.class))), hasProperty("encounter", hasProperty("referenceElement", hasProperty("idPart", equalTo(ENCOUNTER_UUID)))))));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldIncludePatientsWithReturnedResults.
@Test
public void searchForEncounters_shouldIncludePatientsWithReturnedResults() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(ENCOUNTER_UUID));
HashSet<Include> includes = new HashSet<>();
includes.add(new Include("Encounter:patient"));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), equalTo(1));
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
// included resource added as part of the result list
assertThat(resultList.size(), equalTo(2));
Encounter returnedEncounter = (Encounter) resultList.iterator().next();
assertThat(resultList, hasItem(allOf(is(instanceOf(Patient.class)), hasProperty("id", equalTo(returnedEncounter.getSubject().getReferenceElement().getIdPart())))));
}
use of org.hl7.fhir.r4.model.Encounter in project openmrs-module-fhir2 by openmrs.
the class EncounterSearchQueryTest method searchForEncounters_shouldSearchForEncountersBySubjectIdentifierAndGivenName.
@Test
public void searchForEncounters_shouldSearchForEncountersBySubjectIdentifierAndGivenName() {
ReferenceAndListParam subjectReference = new ReferenceAndListParam();
ReferenceParam subjectIdentifier = new ReferenceParam();
ReferenceParam subjectGiven = new ReferenceParam();
subjectIdentifier.setValue(PATIENT_IDENTIFIER);
subjectIdentifier.setChain(Patient.SP_IDENTIFIER);
subjectGiven.setValue(PATIENT_GIVEN_NAME);
subjectGiven.setChain(Patient.SP_GIVEN);
subjectReference.addValue(new ReferenceOrListParam().add(subjectIdentifier)).addAnd(new ReferenceOrListParam().add(subjectGiven));
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));
assertThat(((Encounter) resultList.iterator().next()).getSubject().getReference(), endsWith(PATIENT_UUID));
}
Aggregations