diff --git a/README.md b/README.md index 27b6b55..ea9896f 100755 --- a/README.md +++ b/README.md @@ -389,7 +389,9 @@ following search parameters are available: - `administrativeLevelMin`: Specifies the minimum administrative level to include in the response. Locations at this level and above will be included. - `administrativeLevelMax`: Specifies the maximum administrative level to - include in the response. Locations at this level and below will be included. If not set, it defaults to the value of `DEFAULT_MAX_ADMIN_LEVEL` set in the `Constants.java` file. + include in the response. Locations at this level and below will be included. + If not set, it defaults to the value of `DEFAULT_MAX_ADMIN_LEVEL` set in the + `Constants.java` file. Behavior based on parameters: diff --git a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java index 7c56d99..e86a9f9 100644 --- a/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java +++ b/plugins/src/main/java/org/smartregister/fhir/gateway/plugins/LocationHierarchyEndpointHelper.java @@ -13,21 +13,20 @@ import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; +import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.r4.model.Binary; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Composition; import org.hl7.fhir.r4.model.Location; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.StringType; -import org.hl7.fhir.instance.model.api.IBaseBundle; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.smartregister.model.location.LocationHierarchy; import org.smartregister.model.location.LocationHierarchyTree; -import com.google.fhir.gateway.ExceptionUtil; - import com.auth0.jwt.interfaces.DecodedJWT; +import com.google.fhir.gateway.ExceptionUtil; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.client.api.IGenericClient; @@ -67,7 +66,8 @@ public LocationHierarchy getLocationHierarchy(String locationId, List ad return locationHierarchy; } - public List getLocationHierarchies(List locationIds, List adminLevels) { + public List getLocationHierarchies( + List locationIds, List adminLevels) { List locationHierarchies = new ArrayList<>(); for (String locationId : locationIds) { locationHierarchies.add(getLocationHierarchy(locationId, adminLevels)); @@ -170,7 +170,7 @@ public Bundle handleIdentifierRequest(HttpServletRequest request, String identif String administrativeLevelMin = request.getParameter(Constants.MIN_ADMIN_LEVEL); String administrativeLevelMax = request.getParameter(Constants.MAX_ADMIN_LEVEL); List adminLevels = - generateAdminLevels(administrativeLevelMin, administrativeLevelMax); + generateAdminLevels(administrativeLevelMin, administrativeLevelMax); String mode = request.getParameter(Constants.MODE); if (Constants.LIST.equals(mode)) { List locationIds = Collections.singletonList(identifier); @@ -190,7 +190,7 @@ public Bundle handleNonIdentifierRequest( String administrativeLevelMin = request.getParameter(Constants.MIN_ADMIN_LEVEL); String administrativeLevelMax = request.getParameter(Constants.MAX_ADMIN_LEVEL); List adminLevels = - generateAdminLevels(administrativeLevelMin, administrativeLevelMax); + generateAdminLevels(administrativeLevelMin, administrativeLevelMax); List selectedSyncLocations = extractSyncLocations(syncLocationsParam); String practitionerId = verifiedJwt.getSubject(); List userRoles = JwtUtils.getUserRolesFromJWT(verifiedJwt); @@ -312,7 +312,7 @@ public Bundle getPaginatedLocations(HttpServletRequest request, List loc for (String identifier : locationIds) { Location parentLocation = getLocationById(identifier); List locations = - getLocationHierarchyLocations(identifier, parentLocation, adminLevels); + getLocationHierarchyLocations(identifier, parentLocation, adminLevels); resourceLocations.addAll(locations); } int totalEntries = resourceLocations.size();