Skip to content

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

Description

@allan-on

Use case/Problem Statement

LocationHierarchy and PractitionerDetail are not FHIR resources; they are custom endpoints on the fhir-gateway-extension. The gateway serves them at the root, as a plain GET:

GET /LocationHierarchy?_id=<id>
GET /PractitionerDetail?keycloak-uuid=<id>

But fhir-web currently requests them like any normal FHIR resource, which produces the wrong URL in two ways:

GET /fhir/LocationHierarchy/_search?_id=<id>
        ^^^^^                 ^^^^^^^
        1. extra /fhir prefix  2. extra /_search suffix

Both are wrong for these endpoints:

  1. The /fhir prefix comes from REACT_APP_FHIR_API_BASE_URL. Custom endpoints live at the gateway root, not under /fhir.
  2. The /_search suffix is added by the shared FHIR client's list() method. The gateway expects a plain GET with query params.

Because the request has the /fhir prefix, the gateway forwards it to the backend HAPI FHIR server instead of the custom endpoint handler.
HAPI then rejects it, responding that LocationHierarchy is not a known/supported resource type (an OperationOutcome error), since it isn't a real FHIR resource.

Result: the location hierarchy tree and practitioner details fail to load when fhir-web points at the fhir-gateway-extension.

Acceptance criteria

Make custom-endpoint calls use GET {gatewayRoot}/{Endpoint}?... (no /fhir, no /_search), with the base URL configurable.

  1. Add a base-URL resolver for custom endpoints that strips a trailing /fhir (or uses an explicit override).

    • packages/react-utils/src/helpers/utils.tsxgetFhirCustomEndpointBaseURL()
  2. Add a config option for the custom-endpoint base, defaulting to the FHIR base with /fhir removed.

    • app/src/configs/env.tsREACT_APP_FHIR_WEB_CUSTOM_ENDPOINT_BASE_URL
    • thread it through app props in app/src/App/utils.tsx
  3. Fix the LocationHierarchy call to use the resolved base and a plain GET (via the existing FHIRServiceClass.customRequest, not list()).

    • packages/fhir-location-management/src/helpers/utils.tsuseGetLocationHierarchy
    • callers: LocationUnitList, AddEditLocationUnit, OrganizationAffiliation
  4. Fix the PractitionerDetail call the same way.

    • packages/fhir-keycloak-user-management/src/components/UserList/Viewdetails/index.tsx
  5. Update tests, env samples, and docs to match the new request URLs and the new config option.

Project Contact

No response

Relevant Information

https://github.com/onaio/fhir-gateway-extension#custom-endpoints

Metadata

Metadata

Assignees

Type

No type

Projects

Status
To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions