Skip to content

Call configurable custom gateway endpoints (LocationHierarchy & PractitionerDetail) - #1559

Open
allan-on wants to merge 6 commits into
onaio:mainfrom
nawitech:feature/call-configurable-custom-end-points
Open

Call configurable custom gateway endpoints (LocationHierarchy & PractitionerDetail)#1559
allan-on wants to merge 6 commits into
onaio:mainfrom
nawitech:feature/call-configurable-custom-end-points

Conversation

@allan-on

@allan-on allan-on commented Jul 6, 2026

Copy link
Copy Markdown

closes #1558

Changes included with this PR

  • New resolver getFhirCustomEndpointBaseURL(fhirBaseURL, override) in @opensrp/react-utils — returns the override if set, else fhirBaseURL with a trailing /fhir stripped.
  • New optional config REACT_APP_FHIR_WEB_CUSTOM_ENDPOINT_BASE_URL (confd key /react/app/fhir/web/custom/endpoint/base/url). Self-defaults: if unset, derives from REACT_APP_FHIR_API_BASE_URL by stripping /fhir. Only needs setting if custom endpoints live on a different host.
  • Rewired LocationHierarchy and PractitionerDetail calls (location management, user management, org affiliation) to use the custom-endpoint base + bare resource path.
  • Docs + .env.sample / confd template / env config updated.

Checklist

  • tests are included and passing
  • documentation is changed or added
  • Internationalization:
    • Ensure all strings are internationalized.
  • Role-Based Access:
    • Verify that all user actions have appropriate role-based access permissions set.

allan-on added 6 commits July 1, 2026 18:27
Add getFhirCustomEndpointBaseURL to react-utils. It resolves the base
URL for custom (non-FHIR) gateway endpoints by stripping a trailing
/fhir, or using an explicit override. Custom endpoints such as
LocationHierarchy and PractitionerDetail are served at the gateway
root, not under /fhir.
LocationHierarchy is a custom endpoint served at the gateway root as a
plain GET. Request it via customRequest against the resolved custom
base instead of FHIRServiceClass.list(), which wrongly produced
/fhir/LocationHierarchy/_search.

Thread an optional fhirCustomEndpointBaseURL prop through the hierarchy
call sites (LocationUnitList, AddEditLocationUnit, OrganizationAffiliation)
and update the affected tests.
PractitionerDetail is a custom endpoint served at the gateway root as a
plain GET. Request it via customRequest against the resolved custom
base instead of FHIRServiceClass.list(), and thread the custom-endpoint
base prop through the user details view. Update tests.
Add REACT_APP_FHIR_WEB_CUSTOM_ENDPOINT_BASE_URL (defaults to the FHIR
base with a trailing /fhir stripped) and thread it through the app prop
bundles and routes.

Also repairs pre-existing gaps where the location list and user details
routes did not pass fhirBaseURL to their components.
Add REACT_APP_FHIR_WEB_CUSTOM_ENDPOINT_BASE_URL to the env samples and
the docker config template, and document the custom-endpoint base URL
behaviour in env.md, getting-started.md and the docker deployment guide.
Add /react/app/fhir/web/custom/endpoint/base/url to the confd watch
keys so the custom-endpoint base URL override can be supplied at
runtime in Docker deployments.

Without this key confd would not fetch the value from the backend,
leaving the config.js.tmpl getv fallback to the empty default. The
template already emits REACT_APP_FHIR_WEB_CUSTOM_ENDPOINT_BASE_URL
and env.ts already reads it; this closes the runtime-config chain.
@allan-on

allan-on commented Jul 6, 2026

Copy link
Copy Markdown
Author

Testing

Validated against a vanilla hapiproject/hapi:v7.0.0 backend behind onaio/fhir-gateway-plugin:v3.0.5, isolating the fhir-web version as the only variable:

fhir-web Path called Result
v3.3.2 (unfixed) /fhir/LocationHierarchy/_search?_id=ke HAPI-0302 ❌
this branch /LocationHierarchy?_id=ke (gateway root) populated LocationHierarchyTree, tree renders ✅
fhir_web_issue_using_vanilla_hapi fixed_valid_hierarchy_using_vanilla_hapi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement/Feature Request]: fhir-web calls custom (non-FHIR) endpoints with the wrong URL

2 participants