Search in sources :

Example 56 with Encounter

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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 57 with Encounter

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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) Encounter(org.hl7.fhir.r4.model.Encounter) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 58 with Encounter

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)))))));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) TokenParam(ca.uhn.fhir.rest.param.TokenParam) Include(ca.uhn.fhir.model.api.Include) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) HashSet(java.util.HashSet) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 59 with Encounter

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())))));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) Include(ca.uhn.fhir.model.api.Include) Encounter(org.hl7.fhir.r4.model.Encounter) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) HashSet(java.util.HashSet) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 60 with Encounter

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));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) Encounter(org.hl7.fhir.r4.model.Encounter) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)238 Encounter (org.hl7.fhir.r4.model.Encounter)166 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)100 Test (org.junit.jupiter.api.Test)93 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)87 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)79 Reference (org.hl7.fhir.r4.model.Reference)71 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)66 ArrayList (java.util.ArrayList)64 Resource (org.hl7.fhir.r4.model.Resource)61 Bundle (org.hl7.fhir.r4.model.Bundle)60 Date (java.util.Date)57 Encounter (org.hl7.fhir.dstu3.model.Encounter)55 Coding (org.hl7.fhir.r4.model.Coding)51 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)49 Reference (org.hl7.fhir.dstu3.model.Reference)48 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)43 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)41 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)38 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)37