Initial Release
Smart Patient Summary Generator is an InterSystems IRIS for Health FHIR demo
application. It reads FHIR R4 patient data, builds a compact clinical context,
and uses an AI agent to generate role-specific summaries.
Supported roles:
This project implements the suggested task Smart Patient Summary Generator
for the InterSystems Programming Contest: AI Agents for FHIR.
Contest announcement:
https://community.intersystems.com/post/intersystems-programming-contest-ai-agents-fhir
The application generates:
The workflow uses these FHIR resource types:
| Name | Role | Developer Community Profile |
|---|---|---|
| Jan Rheineck | Developer | https://community.intersystems.com/user/jan-rheineck |
| Niyu Tong | Developer | https://community.intersystems.com/user/niyu-tong |
data/ directory.flowchart LR User["User / Browser"] --> UI["Gradio Web UI"] UI --> App["Python App\nFHIR client + context extractor + AI agent"]App -->|FHIR API if available| IRIS["External IRIS for Health /\nHealthShare FHIR endpoint"] App -->|fallback if unavailable| Data["Local data/*.json\nFHIR Bundles"] App --> Context["Extracted patient context"] Context --> OpenAI["OpenAI API"] OpenAI --> Summary["Role-specific summary"] Summary --> UI
Main components:
src.start: startup entry point. It checks whether the configured usersrc.fhir_loader: posts local FHIR transaction bundles into IRIS.src.fhir_client: reads FHIR resources from IRIS or from local fallback JSON.src.context_extractor: converts FHIR resources into compact clinical text.src.agent: selects the role prompt and calls the OpenAI model.src.app: Gradio web UI.For Open Exchange usage, the Docker Compose default starts only the web app.
Users connect it to their own IRIS for Health or HealthShare FHIR endpoint with
IRIS_BASE_URL.
ED Doctor, Care Manager, Patient, orFamily Caregiver.The app is intended to help demo users and clinicians quickly turn FHIR patient
records into a concise, role-specific summary. It does not replace clinical
judgment.
To use the app:
http://localhost:7860.ED Doctor, Care Manager, Patient, orFamily Caregiver.Generate Summary.Current Issues, Recent Changes, andRisks and Follow-up sections.Reference Data Sources to inspect the FHIR values used by theVideo demo:
Demo steps:
http://localhost:7860.Generate Summary.Current Issues, Recent Changes, and Risks and Follow-up.Reference Data Sources to inspect the FHIR values used by the agent.Clone the repository and enter the project directory:
git clone https://github.com/niyuT96/fhir-patient-summary.git
cd fhir-patient-summary
Create a local environment file:
Copy-Item .env.example .env
notepad .env
Set OPENAI_API_KEY and adjust the IRIS connection settings if you want to
connect to a live IRIS for Health or HealthShare FHIR endpoint. If the endpoint
is unavailable, the app can still run with the local fallback data in data/.
For local Python usage, install dependencies:
pip install -r requirements.txt
For Docker usage, no local Python package installation is required. Docker
installs the Python dependencies inside the image when you run:
docker compose up --build
Make sure .env contains at least:
OPENAI_API_KEY=your-openai-api-key-here
IRIS_USERNAME=superuser
IRIS_PASSWORD=SYS
IRIS_BASE_URL=http://localhost:52773/csp/healthshare/fhir/fhir/r4
FHIR_FALLBACK_PATH=data
LOAD_SAMPLE_BUNDLE=false
Important environment variables:
| Variable | Purpose |
|---|---|
OPENAI_API_KEY |
Required. Used by the OpenAI client. |
IRIS_BASE_URL |
IRIS FHIR R4 endpoint. |
IRIS_USERNAME |
IRIS basic-auth username. |
IRIS_PASSWORD |
IRIS basic-auth password. |
FHIR_FALLBACK_PATH |
File or directory used when IRIS is unavailable. |
LOAD_SAMPLE_BUNDLE |
Whether startup should POST local bundles into IRIS. Default is false. |
Do not commit .env. It may contain secrets.
Choose IRIS_BASE_URL based on how the app is started:
http://localhost:52773/csp/healthshare/fhir/fhir/r4http://host.docker.internal:52773/csp/healthshare/fhir/fhir/r4If the configured IRIS endpoint is unavailable, the app starts in local fallback
mode and reads FHIR bundles from FHIR_FALLBACK_PATH.
The application sends Accept: application/fhir+json for FHIR GET requests.
This is required by some IRIS for Health and HealthShare FHIR endpoints.
This option runs the Python app directly on your computer.
Create and edit .env as described above. If your IRIS server is also running
on your computer, use localhost in IRIS_BASE_URL:
IRIS_BASE_URL=http://localhost:52773/csp/healthshare/fhir/fhir/r4
Install dependencies:
pip install -r requirements.txt
Start the app:
python -m src
Open:
http://localhost:7860
The Docker image packages the web application only. It does not require users
to run a bundled IRIS container. Set IRIS_BASE_URL to the user’s own IRIS for
Health or HealthShare FHIR R4 endpoint.
Create and edit .env as described above. For an IRIS server running on the
host machine, use host.docker.internal because localhost inside the app
container refers to the container itself:
IRIS_BASE_URL=http://host.docker.internal:52773/csp/healthshare/fhir/fhir/r4
If no IRIS server is reachable, the Dockerized app still starts and uses the
local FHIR bundles copied into the image from data/.
Check the configured IRIS FHIR endpoint from PowerShell:
$env:IRIS_BASE_URL="http://localhost:52773/csp/healthshare/fhir/fhir/r4"
$env:IRIS_USERNAME="superuser"
$env:IRIS_PASSWORD="SYS"
.\scripts\check-iris.ps1
Start the Dockerized web app:
docker compose up --build
Or use the helper script:
.\scripts\run-docker.ps1
Detached mode:
.\scripts\run-docker.ps1 -Detached
The UI is available at:
http://localhost:7860
Optional local IRIS development profile:
docker compose --profile local-iris up --build
The local-iris profile is for development only. Open Exchange users are
expected to connect the web app to their own IRIS FHIR endpoint. Starting this
profile creates an IRIS container, but the app can also be tested without it by
using local fallback data.
The app supports both local fallback data and IRIS FHIR Server data.
Local fallback can point to either:
*.json FHIR Bundle filesCurrent recommended setting:
FHIR_FALLBACK_PATH=data
With this setting, the app reads every JSON file directly under data/.
Each JSON file should be a FHIR Bundle. The code reads resources from:
entry[].resource
The FHIR Bundle files in data/ are sourced from the InterSystems
samples-FHIR-resource-repository:
https://github.com/intersystems/samples-FHIR-resource-repository
When IRIS is unavailable, the app uses local fallback data and lists all
Patient resources found. When IRIS is available and LOAD_SAMPLE_BUNDLE=true,
startup attempts to POST each JSON bundle into the configured IRIS FHIR
endpoint. Keep LOAD_SAMPLE_BUNDLE=false when connecting to a user’s existing
FHIR server and no sample data should be written.
The local sample data is synthetic/public FHIR sample data. Do not add real
patient data to this repository.
The model is configured in src.agent.
Current model:
gpt-4o-mini
The prompt is role-specific:
ED_DOCTOR_PROMPTCARE_MANAGER_PROMPTPATIENT_PROMPTFAMILY_CAREGIVER_PROMPTThe application sends the same extracted FHIR patient context to the model for
all roles. The selected role changes the system prompt, so the output is framed
for an ED doctor, care manager, patient, or family caregiver.
Run:
pytest -q
This project was developed with assistance from:
All generated code and documentation were reviewed and adapted by the project
team.
| Field | Value |
|---|---|
| GitHub or GitLab URL | https://github.com/niyuT96/fhir-patient-summary |
| Open Exchange URL | To be added after publication |
| Demo video URL | https://youtu.be/rOKGINwaqDU |
| Team member DC profiles | Jan Rheineck: https://community.intersystems.com/user/jan-rheineck; Niyu Tong: https://community.intersystems.com/user/niyu-tong |
| Contest task | Smart Patient Summary Generator |
| InterSystems product | InterSystems IRIS for Health / HealthShare FHIR |
Suggested short description:
An AI agent for InterSystems IRIS for Health that reads FHIR patient data and
generates role-specific patient summaries for emergency doctors, care managers,
patients, and family caregivers.
This project is licensed under the MIT License. See LICENSE.