Skip to content

Commit

Permalink
Merge pull request #74 from onaio/use_post_for_fhir_search_requests
Browse files Browse the repository at this point in the history
Switch to HTTP POST for FHIR Search Requests
  • Loading branch information
lincmba authored Jul 23, 2024
2 parents 68b946f + c11af54 commit 8acb65e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exec/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
</parent>

<artifactId>exec</artifactId>
Expand Down Expand Up @@ -70,7 +70,7 @@
<dependency>
<groupId>org.smartregister</groupId>
<artifactId>plugins</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
</parent>

<artifactId>plugins</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.google.fhir.gateway.ExceptionUtil;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.SearchStyleEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.gclient.IQuery;
import ca.uhn.fhir.rest.gclient.ReferenceClientParam;
Expand Down Expand Up @@ -134,7 +135,8 @@ public List<Location> getDescendants(
adminLevelArray));
}

Bundle childLocationBundle = query.returnBundle(Bundle.class).execute();
Bundle childLocationBundle =
query.usingStyle(SearchStyleEnum.POST).returnBundle(Bundle.class).execute();

List<Location> allLocations = new ArrayList<>();
if (parentLocation != null) {
Expand Down Expand Up @@ -262,6 +264,7 @@ private String getSyncStrategy(String applicationId) {
client.search()
.forResource(Composition.class)
.where(Composition.IDENTIFIER.exactly().identifier(applicationId))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.SearchStyleEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;

Expand Down Expand Up @@ -206,6 +207,7 @@ private Composition readCompositionResource(String applicationId, FhirContext fh
client.search()
.forResource(Composition.class)
.where(Composition.IDENTIFIER.exactly().identifier(applicationId))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.smartregister.model.practitioner.PractitionerDetails;
import org.springframework.lang.Nullable;

import ca.uhn.fhir.rest.api.SearchStyleEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.gclient.ReferenceClientParam;

Expand Down Expand Up @@ -200,6 +201,7 @@ private List<String> getOrganizationIdsByLocationIds(List<String> attributedLoca
.where(
OrganizationAffiliation.LOCATION.hasAnyOfIds(
attributedLocationsList))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();

Expand Down Expand Up @@ -351,6 +353,7 @@ private Bundle getGroupsAssignedToPractitioner(String practitionerId) {
Group.CODE
.exactly()
.systemAndCode(HTTP_SNOMED_INFO_SCT, PRACTITIONER_GROUP_CODE))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();
}
Expand Down Expand Up @@ -379,6 +382,7 @@ private Practitioner getPractitionerByIdentifier(String identifier) {
.search()
.forResource(Practitioner.class)
.where(Practitioner.IDENTIFIER.exactly().identifier(identifier))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();

Expand Down Expand Up @@ -407,6 +411,7 @@ private List<CareTeam> getCareTeamsByOrganizationIds(List<String> organizationId
.FORWARD_SLASH
+ it)
.collect(Collectors.toList())))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();

Expand All @@ -425,6 +430,7 @@ private Bundle getCareTeams(String practitionerId) {
Enumerations.ResourceType.PRACTITIONER.toCode()
+ org.smartregister.utils.Constants.FORWARD_SLASH
+ practitionerId))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();
}
Expand All @@ -434,6 +440,7 @@ private Bundle getPractitionerRoles(String practitionerId) {
.search()
.forResource(PractitionerRole.class)
.where(PractitionerRole.PRACTITIONER.hasId(practitionerId))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();
}
Expand All @@ -452,6 +459,7 @@ private Bundle getOrganizationsById(Set<String> organizationIds) {
.where(
new ReferenceClientParam(BaseResource.SP_RES_ID)
.hasAnyOfIds(organizationIds))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();
}
Expand All @@ -468,6 +476,7 @@ private Bundle getOrganizationsById(Set<String> organizationIds) {
.where(
new ReferenceClientParam(BaseResource.SP_RES_ID)
.hasAnyOfIds(locationIds))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();

Expand Down Expand Up @@ -495,6 +504,7 @@ private Bundle getOrganizationAffiliationsByOrganizationIdsBundle(Set<String> or
.where(
OrganizationAffiliation.PRIMARY_ORGANIZATION.hasAnyOfIds(
organizationIds))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(Bundle.class)
.execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import com.auth0.jwt.interfaces.DecodedJWT;

import ca.uhn.fhir.rest.api.SearchStyleEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.gclient.ICriterion;
import ca.uhn.fhir.rest.gclient.IQuery;
Expand Down Expand Up @@ -258,6 +259,7 @@ public void testGetDecendantsWithAdminLevelFiltersReturnsLocationsWithinAdminLev
Mockito.doReturn(queryMock).when(untypedQueryMock).forResource(Location.class);
Mockito.doReturn(queryMock).when(queryMock).where(any(ICriterion.class));
Mockito.doReturn(queryMock).when(queryMock).and(any(ICriterion.class));
Mockito.doReturn(queryMock).when(queryMock).usingStyle(SearchStyleEnum.POST);
Mockito.doReturn(queryMock).when(queryMock).returnBundle(Bundle.class);

Mockito.doReturn(firstBundleMock, secondBundleMock).when(queryMock).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.api.SearchStyleEnum;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.gclient.ICriterion;

Expand All @@ -43,6 +44,7 @@ public void testGetPractitonerDetailsByKeycloakIdNotFound() {
client.search()
.forResource(eq(Practitioner.class))
.where(any(ICriterion.class))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(any())
.execute();

Expand All @@ -61,6 +63,7 @@ public void testGetPractitonerDetailsByKeycloakIdReturnsCorrectPractitioner() {
client.search()
.forResource(eq(Practitioner.class))
.where(any(ICriterion.class))
.usingStyle(SearchStyleEnum.POST)
.returnBundle(any())
.execute();
when(whenPractitionerSearch).thenReturn(getPractitionerBundle());
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.smartregister</groupId>
<artifactId>opensrp-gateway-plugin</artifactId>
<version>2.0.2</version>
<version>2.0.3</version>
<packaging>pom</packaging>

<modules>
Expand Down

0 comments on commit 8acb65e

Please sign in to comment.