- 
                Notifications
    You must be signed in to change notification settings 
- Fork 9
Add initial package and configuration files for FHIR info Gateway #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8e2c200
              b0a333c
              f6cec06
              e9979d6
              d6f8cb6
              5a7c368
              feccb35
              fb5eb07
              c7ec435
              399a407
              be32707
              57fb197
              76c250c
              4601f8f
              ec18ae1
              069145f
              541a056
              e51e516
              e7b84ad
              417530e
              9769590
              060ca81
              9ca3ad8
              7d09a73
              08c356c
              b6963e1
              d624b15
              3f25382
              ec74acd
              ffbe6a9
              fc583cf
              0474393
              65797ea
              5e7b67a
              f449d8e
              9daa76b
              d3ae2c7
              0e3aacc
              d109bdc
              44c1194
              1506798
              1b68f57
              ac4d67f
              892c5c6
              5f2a64c
              a4b770f
              e4e6edf
              8a6d8dd
              759e7ee
              138558a
              2b94455
              9f4f8ee
              bb0b7ef
              f965914
              ce3dbcd
              abfd851
              4a1ad70
              52f76c8
              f03e511
              624b9d6
              3c6b0d9
              09e829d
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -52,6 +52,8 @@ | |
| - [Reverse Proxy Nginx](packages/reverse-proxy-nginx/README.md) | ||
| - [Local Development](packages/reverse-proxy-nginx/local-development.md) | ||
| - [Environment Variables](packages/reverse-proxy-nginx/environment-variables.md) | ||
| - [FHIR Info Gateway](packages/fhir-info-gateway/README.md) | ||
| - [Environment Variables](packages/fhir-info-gateway/environment-variables.md) | ||
| 
      Comment on lines
    
      +55
     to 
      +56
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Update environment variables documentation and fix paths 
 -  - [FHIR Info Gateway](packages/fhir-info-gateway/README.md)
-    - [Environment Variables](packages/fhir-info-gateway/environment-variables.md)
+  - [FHIR Info Gateway](documentation/packages/fhir-info-gateway/README.md)
+    - [Environment Variables](documentation/packages/fhir-info-gateway/environment-variables.md)🔗 Analysis chainAdd missing environment variables documentation. The SUMMARY.md references an environment variables document that hasn't been provided: 
 Please create this document and include all environment variables listed in the README, along with their: 
 Run this script to check for the missing file: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check if the environment variables documentation exists
if [ ! -f "documentation/packages/fhir-info-gateway/environment-variables.md" ]; then
  echo "Missing file: documentation/packages/fhir-info-gateway/environment-variables.md"
  exit 1
fi
Length of output: 260 Script: #!/bin/bash
# Check if README exists and look for environment variables section
if [ -f "packages/fhir-info-gateway/README.md" ]; then
  echo "=== README Content ==="
  cat "packages/fhir-info-gateway/README.md"
else
  echo "README.md not found"
fi
Length of output: 98 Script: #!/bin/bash
# Check if the package directory exists and list its contents
echo "=== Checking package directory ==="
if [ -d "packages/fhir-info-gateway" ]; then
  echo "Directory exists. Contents:"
  ls -la packages/fhir-info-gateway/
else
  echo "Directory not found at packages/fhir-info-gateway"
fi
# Search for any files related to this package
echo -e "\n=== Searching for related files ==="
fd "fhir-info-gateway" --hidden --no-ignore
Length of output: 419 Script: #!/bin/bash
# Check both potential locations for documentation
echo "=== Checking root package directory ==="
ls -la fhir-info-gateway/
echo -e "\n=== Checking documentation directory ==="
ls -la documentation/packages/fhir-info-gateway/
echo -e "\n=== Checking README content ==="
if [ -f "fhir-info-gateway/README.md" ]; then
  cat "fhir-info-gateway/README.md"
fi
Length of output: 1002 Script: #!/bin/bash
echo "=== Documentation README Content ==="
cat "documentation/packages/fhir-info-gateway/README.md"
echo -e "\n=== Checking for environment variables in docker files ==="
echo "docker-compose.yml:"
cat "fhir-info-gateway/docker-compose.yml"
echo -e "\ndocker-compose.dev.yml:"
cat "fhir-info-gateway/docker-compose.dev.yml"
Length of output: 5220 | ||
| - [OpenFn](packages/openfn/README.md) | ||
| - [Environment Variables](packages/openfn/environment-variables.md) | ||
| - [Reverse Proxy Traefik](packages/reverse-proxy-traefik/README.md) | ||
|  | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,138 @@ | ||||||||||||||||||||||||||||||
| # Table of Contents | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - [Overview](#overview) | ||||||||||||||||||||||||||||||
| - [System Configuration](#system-configuration) | ||||||||||||||||||||||||||||||
| - [Routing FHIR Requests](#routing-fhir-requests) | ||||||||||||||||||||||||||||||
| - [Authentication Setup](#authentication-setup) | ||||||||||||||||||||||||||||||
| - [Client Role Management](#client-role-management) | ||||||||||||||||||||||||||||||
| - [API Testing](#api-testing) | ||||||||||||||||||||||||||||||
| - [References](#references) | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## Overview | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| This document outlines the setup and integration of the FHIR Info Gateway to enhance the handling of FHIR-based requests. The system leverages OpenHIM for routing, Keycloak for authentication, and custom configurations for managing client access and secure data exchange. This setup enables seamless orchestration of Create/Read operations for patient clinical data. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## System Configuration | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Prerequisite Setup | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - **Keycloak Integration**: Keycloak is configured as the primary access token provider. | ||||||||||||||||||||||||||||||
| - **Initialization**: Use the following command to initialize the FHIR Info Gateway package: | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| ./instant-linux package init -n fhir-info-gateway --dev | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Default Environment Variables | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| | Variable | Description | Example Value | | ||||||||||||||||||||||||||||||
| | ------------------ | --------------------------------------- | --------------------------- | | ||||||||||||||||||||||||||||||
| | `ACCESS_CHECKER` | Enables role-based scope checking | `scope` | | ||||||||||||||||||||||||||||||
| | `REALM_URL` | Keycloak realm URL for token generation | `http://localhost:9088` | | ||||||||||||||||||||||||||||||
| | `GATEWAY_ENDPOINT` | Endpoint for FHIR Info Gateway API | `http://localhost:8080/api` | | ||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +32
     to 
      +36
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance environment variables documentation. The environment variables table should include: 
 | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## Routing FHIR Requests | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Updating OpenHIM Channels | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| 1. Navigate to the OpenHIM console. | ||||||||||||||||||||||||||||||
| 2. Update the MPI Channel settings: | ||||||||||||||||||||||||||||||
| - **Channel Name**: MPI Orchestrations | ||||||||||||||||||||||||||||||
| - Ensure all Create/Read requests are routed through the FHIR Info Gateway. | ||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +44
     to 
      +47
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add detailed OpenHIM channel configuration steps. The OpenHIM channel configuration section lacks specific details requested in the PR comments. Please include: 
 Remove the placeholder comment and add detailed configuration steps: - <!-- _Add configuration details here._ -->
+ 3. Configure the following route settings:
+    - Primary Route: http://fhir-info-gateway:3000
+    - Route Type: HTTP
+    - Add additional routes for FHIR resource endpoints
+
+ Note: By default, direct FHIR request routing is disabled. Enable it only for advanced use cases.📝 Committable suggestion
 
        Suggested change
       
 | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| #### Route Configuration Example | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| <!-- _Add configuration details here._ --> | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## Authentication Setup | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Retrieve the User UUID | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| The User UUID is the Keycloak user UUID. Obtain this UUID by querying Keycloak or checking the admin console. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Create a New Client in OpenHIM | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| 1. Use the retrieved Keycloak User UUID as the Client ID. | ||||||||||||||||||||||||||||||
| 2. Create a new client in OpenHIM using this UUID. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Generating Client Credentials | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| Run the following command to generate an access token: | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| curl -X POST -d 'client_id=emr' -d 'username=fhiruser' \ | ||||||||||||||||||||||||||||||
| -d 'password=dev_password_only' -d 'grant_type=password' \ | ||||||||||||||||||||||||||||||
| "http://localhost:9088/realms/platform-realm/protocol/openid-connect/token" | jq | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +74
     to 
      +78
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update client credentials example with default client details. The current example uses generic placeholders. As per PR comments, include the default client and scopes that were added: -curl -X POST -d 'client_id=emr' -d 'username=fhiruser' \
-d 'password=dev_password_only' -d 'grant_type=password' \
"http://localhost:9088/realms/platform-realm/protocol/openid-connect/token" | jq
+curl -X POST \
+  -d 'grant_type=client_credentials' \
+  -d 'client_id=fhir_client' \
+  -d 'client_secret=<your_client_secret>' \
+  "http://localhost:9088/realms/platform-realm/protocol/openid-connect/token" | jq
+
+# Note: Replace <your_client_secret> with the secret generated for your client
+# Default scopes assigned: fhir:read, fhir:write | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| Replace `localhost:9088` with the appropriate Keycloak server address. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Token Usage | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| Include the generated token in the Authorization header of API requests: | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - **In Postman or similar tools**: | ||||||||||||||||||||||||||||||
| - Use the Bearer Token in the Authorization tab. | ||||||||||||||||||||||||||||||
| - Add the token generated in the above step. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## Client Role Management | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Restricting Client Access | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| 1. Open Keycloak Admin Console. | ||||||||||||||||||||||||||||||
| 2. Navigate to the **Client Scopes** section for the FHIR resource. | ||||||||||||||||||||||||||||||
| 3. Update roles and permissions to enforce restricted access. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +98
     to 
      +101
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance client role management section with default roles. As per PR comments, document the default roles and users configured in Keycloak:  1. Open Keycloak Admin Console.
 2. Navigate to the **Client Scopes** section for the FHIR resource.
-3. Update roles and permissions to enforce restricted access.
+3. Default Configuration:
+   - Role: fhir-readonly
+   - Default Client: fhir_client (service account enabled)
+   - Default Scopes: fhir:read, fhir:write
+
+4. Modify roles and permissions:
+   - Navigate to Clients → fhir_client → Service Account Roles
+   - Add/remove roles to modify access levels📝 Committable suggestion
 
        Suggested change
       
 | ||||||||||||||||||||||||||||||
| ### Disabling Authentication (Development Only) | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - Allow anonymous access via Keycloak settings. | ||||||||||||||||||||||||||||||
| - Update the OpenHIM channel to bypass authentication temporarily. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +102
     to 
      +106
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add security warning for development settings. The "Disabling Authentication" section needs a prominent security warning: 
 | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## API Testing | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Testing FHIR Requests | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - Use tools like Postman or cURL. | ||||||||||||||||||||||||||||||
| - Add the Bearer token to the Authorization header. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| #### Example Request | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| curl -X GET \ | ||||||||||||||||||||||||||||||
| -H "Authorization: Bearer <token>" \ | ||||||||||||||||||||||||||||||
| "http://localhost:5001/fhir/Encounter" | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +118
     to 
      +122
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance API testing documentation. The example request needs: 
 | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ### Verifying Responses | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - Ensure that responses comply with FHIR standards and contain the required patient data. | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ## References | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| - **GitHub Pull Request**: FHIR Info Gateway Integration | ||||||||||||||||||||||||||||||
| - **Documentation Commands**: | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||
| ./instant-linux package init -n fhir-info-gateway --dev | ||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| version: '3.9' | ||
|  | ||
| services: | ||
| fhir-info-gateway: | ||
| ports: | ||
| - target: 8080 | ||
| published: 8880 | ||
| mode: host | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| version: "3.9" | ||
| services: | ||
| fhir-info-gateway: | ||
| image: ${FHIR_INFO_GATEWAY_IMAGE} | ||
| networks: | ||
| openhim: | ||
| keycloak: | ||
| default: | ||
| environment: | ||
| TOKEN_ISSUER: ${KC_API_URL}/realms/${KC_REALM_NAME} | ||
| ACCESS_CHECKER: ${ACCESS_CHECKER} | ||
| PROXY_TO: ${GATEWAY_MPI_PROXY_URL} | ||
| BACKEND_TYPE: ${BACKEND_TYPE} | ||
| RUN_MODE: ${RUN_MODE} | ||
| deploy: | ||
| replicas: ${FHIR_INFO_GATEWAY_INSTANCES} | ||
| placement: | ||
| max_replicas_per_node: ${FHIR_INFO_GATEWAY_MAX_REPLICAS_PER_NODE} | ||
| resources: | ||
| limits: | ||
| cpus: ${FHIR_INFO_GATEWAY_CPU_LIMIT} | ||
| memory: ${FHIR_INFO_GATEWAY_MEMORY_LIMIT} | ||
| reservations: | ||
| cpus: ${FHIR_INFO_GATEWAY_CPU_RESERVE} | ||
| memory: ${FHIR_INFO_GATEWAY_MEMORY_RESERVE} | ||
| networks: | ||
| openhim: | ||
| name: openhim_public | ||
| external: true | ||
| keycloak: | ||
| name: keycloak_public | ||
| external: true | ||
| default: | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| version: "3.9" | ||
|  | ||
| services: | ||
| smart-config: | ||
| image: jembi/keycloak-config:v0.0.1 | ||
| networks: | ||
| keycloak: | ||
| environment: | ||
| KEYCLOAK_BASE_URL: ${KC_API_URL} | ||
| KEYCLOAK_USER: ${KC_ADMIN_USERNAME} | ||
| KEYCLOAK_PASSWORD: ${KC_ADMIN_PASSWORD} | ||
| KEYCLOAK_REALM: ${KC_REALM_NAME} | ||
| command: [ "-configFile", "config/backend-services-config.json" ] | ||
|  | ||
| networks: | ||
| keycloak: | ||
| name: keycloak_public | ||
| external: true | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| version: "3.9" | ||
| services: | ||
| update-keycloak-config: | ||
| image: node:erbium-alpine | ||
| environment: | ||
| KEYCLOAK_SERVER_URL: ${KC_API_URL} | ||
| KEYCLOAK_REALM: ${KC_REALM_NAME} | ||
| KEYCLOAK_ADMIN_USER: ${KC_ADMIN_USERNAME} | ||
| KEYCLOAK_ADMIN_PASSWORD: ${KC_ADMIN_PASSWORD} | ||
| command: sh -c "cd / && npm i axios && node keycloakConfig.js" | ||
| configs: | ||
| - source: keycloak-config-importer-updateConfig.js | ||
| target: /keycloakConfig.js | ||
| - source: keycloak-config-importer-updateConfig.json | ||
| target: /keycloak-config.json | ||
| deploy: | ||
| replicas: 1 | ||
| restart_policy: | ||
| condition: none | ||
| networks: | ||
| keycloak: | ||
| configs: | ||
| keycloak-config-importer-updateConfig.js: | ||
| file: ./update-keycloak-config.js | ||
| name: keycloak-config-importer-updateConfig.js-${keycloak_config_importer_updateConfig_js_DIGEST:?err} | ||
| labels: | ||
| name: keycloakConfig | ||
| keycloak-config-importer-updateConfig.json: | ||
| file: ./keycloak-config.json | ||
| name: keycloak-config-importer-updateConfig.json-${keycloak_config_importer_updateConfig_json_DIGEST:?err} | ||
| labels: | ||
| name: keycloakConfigJson | ||
| networks: | ||
| keycloak: | ||
| name: keycloak_public | ||
| external: true | 
Uh oh!
There was an error while loading. Please reload this page.