Skip to content
Open
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8e2c200
Add initial package and configuration files for FHIR info Gateway
drizzentic May 20, 2024
b0a333c
Add SMART on fhir realms creator
drizzentic May 24, 2024
f6cec06
Platform beta release
drizzentic May 15, 2024
e9979d6
Fix failing tests
drizzentic May 16, 2024
d6f8cb6
Add correct assertion
bradsawadye May 16, 2024
5a7c368
Ensure that the entry property in the bundle is always an array
bradsawadye May 16, 2024
feccb35
Add jempi network for the services to communicate
bradsawadye May 17, 2024
fb5eb07
Fix kafka consumer failing test
drizzentic May 16, 2024
c7ec435
Bump instant version to latest
rcrichton May 16, 2024
399a407
fix version and disable cert verification in console.
drizzentic May 20, 2024
be32707
Update version for mpi mediator
bradsawadye May 21, 2024
57fb197
Adds reprocess config files
ItsMurumba May 22, 2024
76c250c
Cleanup Reprocess package
ItsMurumba May 22, 2024
4601f8f
Change docker images to be configurable env variables
ItsMurumba May 24, 2024
ec18ae1
Format json files
ItsMurumba May 24, 2024
069145f
Format json files
ItsMurumba May 24, 2024
541a056
adding image variable to metadata.json and docker-compose files
brett-onions Apr 16, 2024
e51e516
adding deployment placement
brett-onions Apr 25, 2024
e7b84ad
adding image definition to metadata.json file
brett-onions Apr 16, 2024
417530e
adding placement and image version for pg in metadata file
brett-onions Apr 17, 2024
9769590
Update Kibana image and add KIBANA_IMAGE environment variable
brett-onions Apr 16, 2024
060ca81
add image and max replicas to metadata file
brett-onions Apr 16, 2024
9ca3ad8
Update docker-compose files and package metadata
brett-onions Apr 18, 2024
7d09a73
Update Elasticsearch cluster placement
brett-onions Apr 25, 2024
08c356c
Update Docker Compose files for PostgreSQL and Pgpool
brett-onions Apr 25, 2024
b6963e1
chore: update CLICKHOUSE_IMAGE to version 23.8.14.6
brett-onions May 21, 2024
d624b15
Change the name of the postgres image variable
bradsawadye May 24, 2024
3f25382
Disable the clickhouse test case (temporarily)
bradsawadye May 27, 2024
ec74acd
Fix syntax error
bradsawadye May 27, 2024
ffbe6a9
Run the recipe tests first
bradsawadye May 27, 2024
fc583cf
Fix typo
bradsawadye May 27, 2024
0474393
Fix if statement
bradsawadye May 27, 2024
65797ea
Fix typo in variable name
bradsawadye May 28, 2024
5e7b67a
Refactor
bradsawadye May 28, 2024
f449d8e
Update .vscode/settings.json
drizzentic May 29, 2024
9daa76b
Fix failure in client scopes creation on keycloak
drizzentic May 30, 2024
d3ae2c7
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic May 30, 2024
0e3aacc
parent cbd8b688d9f1973fbeb17415fe1ae55ad3102461
drizzentic May 24, 2024
d109bdc
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic May 30, 2024
44c1194
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Jul 3, 2024
1506798
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Jul 8, 2024
1b68f57
PR feedback
drizzentic Jul 9, 2024
ac4d67f
Update fhir-info-gateway/swarm.sh
drizzentic Jul 10, 2024
892c5c6
Update fhir-info-gateway/swarm.sh
drizzentic Jul 10, 2024
5f2a64c
Update fhir-info-gateway/swarm.sh
drizzentic Jul 10, 2024
a4b770f
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Jul 26, 2024
e4e6edf
Update config.yaml
drizzentic Jul 26, 2024
8a6d8dd
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Jul 29, 2024
759e7ee
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Jul 31, 2024
138558a
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Aug 14, 2024
2b94455
PR feedback
drizzentic Aug 14, 2024
9f4f8ee
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Sep 16, 2024
bb0b7ef
Add the update script to create default clients,roles and mappings
drizzentic Sep 17, 2024
f965914
add config importer to update keycloak
drizzentic Sep 17, 2024
ce3dbcd
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Sep 18, 2024
abfd851
cleanup
drizzentic Sep 18, 2024
4a1ad70
Update docs
drizzentic Jan 17, 2025
52f76c8
Merge branch 'main' into CU-86byv0cyf_Add-initial-package-and-configu…
drizzentic Jan 17, 2025
f03e511
Added images for readme file
sushantpatil1214 Jan 21, 2025
624b9d6
Added images for readme file
sushantpatil1214 Jan 21, 2025
3c6b0d9
Added images for readme file
sushantpatil1214 Jan 21, 2025
09e829d
Added images for readme file
sushantpatil1214 Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ packages:
- database-postgres
- reprocess-mediator
- fhir-ig-importer
- fhir-info-gateway
- openfn
- datalake

Expand All @@ -49,6 +50,7 @@ profiles:
- kafka-unbundler-consumer
- fhir-ig-importer
- reprocess-mediator
- fhir-info-gateway
- datalake
envFiles:
- cdr-dw.env
Expand All @@ -66,6 +68,8 @@ profiles:
- client-registry-jempi
- identity-access-manager-keycloak
- openhim-mapping-mediator
- fhir-ig-importer
- fhir-info-gateway
envFiles:
- cdr.env

Expand Down
2 changes: 2 additions & 0 deletions documentation/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Update environment variables documentation and fix paths

  1. Create the missing documentation/packages/fhir-info-gateway/environment-variables.md file documenting all environment variables:

    • Default variables from README: ACCESS_CHECKER, REALM_URL, GATEWAY_ENDPOINT
    • Additional variables from docker-compose: TOKEN_ISSUER, PROXY_TO, BACKEND_TYPE, RUN_MODE
    • Deployment variables: FHIR_INFO_GATEWAY_INSTANCES, FHIR_INFO_GATEWAY_CPU_LIMIT, etc.
  2. Update paths in SUMMARY.md to use correct directory:

-  - [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 chain

Add missing environment variables documentation.

The SUMMARY.md references an environment variables document that hasn't been provided:

  • packages/fhir-info-gateway/environment-variables.md

Please create this document and include all environment variables listed in the README, along with their:

  • Default values
  • Validation rules
  • Required/Optional status

Run this script to check for the missing file:

🏁 Scripts executed

The 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)
Expand Down
132 changes: 132 additions & 0 deletions documentation/packages/fhir-info-gateway/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance environment variables documentation.

The environment variables table should include:

  • Required/Optional status for each variable
  • Validation rules (e.g., valid values for ACCESS_CHECKER)
  • Security implications (e.g., HTTPS requirements for REALM_URL)


---

## 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

  • Step-by-step instructions for enabling FHIR request routing
  • Configuration parameters and their values
  • Whether this routing should be enabled by default

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
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.
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.


#### 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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.
1. Open Keycloak Admin Console.
2. Navigate to the **Client Scopes** section for the FHIR resource.
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

### Disabling Authentication (Development Only)

- Allow anonymous access via Keycloak settings.
- Update the OpenHIM channel to bypass authentication temporarily.

Comment on lines +102 to +106
Copy link
Contributor

Choose a reason for hiding this comment

The 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:

  • Emphasize this is strictly for development environments
  • Warn against using these settings in production
  • Add steps to re-enable authentication

---

## 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance API testing documentation.

The example request needs:

  1. List of available endpoints and their purposes
  2. Expected response formats and examples
  3. Common error codes and their meanings
  4. Request/response validation against FHIR specifications


### 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

```
8 changes: 8 additions & 0 deletions fhir-info-gateway/docker-compose.dev.yml
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
33 changes: 33 additions & 0 deletions fhir-info-gateway/docker-compose.yml
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:
18 changes: 18 additions & 0 deletions fhir-info-gateway/importer/docker-compose-smart_keycloak.yml
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
36 changes: 36 additions & 0 deletions fhir-info-gateway/importer/docker-compose.config.yml
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
Loading
Loading