This repository contains tutorials for how to use InterSystems IRIS with an external Python Application to combine FHIR data with generative AI methods.
This repo has 4 main sections:
-
Tutorial: contains several markdown and ipython notebook files:
- How to set up a FHIR server with Docker
- How to create SQL tables from a FHIR Server with FHIR-SQL Builder
- Implementing a vector search
- Creating a chatbot
-
Additional Demos - Some additional tutorials with other ways to use the IRIS FHIR server with Python. This includes:
-
Resources - Some brief introductions that may be useful to get started quickly. These include:
-
Dockerfhir - Files to create a local IRIS-health-community instance and FHIR server with Docker. The main tutorial covers how this should be used.
-
Python - The tutorial is Python based, so will need Python installed on your computer
-
Docker - The IRIS-health instance and FHIR server in all examples are run in a docker container, for this you will need to install Docker
-
Ollama - The last step of the main tutorial is to query a local Large Language model, which I have done through Ollama. If you are interested in using a local chatbot, you're best to install Ollama which can be done from their website.
-
Python Packages - Various other python packages are used throughout, these are listed in the requirements.txt file and can be installed easily:
pip install -r requirements.txt. I've stated whenever a new pacakage is used throughout the demos, so if you'd rather only install the packages you need you can skip this and install the remaining packages when you need them.
The main tutorial demonstrates how FHIR data can be combined with IRIS vector search capabilities to build a powerful tool for medical professionals wanting to quickly understand the medical history of a patient.
We are going to take the data from 'DocumentReference' resources, these consist of clinical notes attached in plain text. This plain text is encoded within the resource and will need to be decoded.
This tutorial is based on a demo created by Simon Sha for the 2025 InterSystems Demo Games. His demonstration is shown here:
This is a start-to-finish tutorial which goes through:
- Create instance of IRIS-health and FHIR server
- Load Data into FHIR Server
- Use the IRIS FHIR-SQL builder to create a SQL table from the FHIR data
- Query this SQL table from Python
- Fetch data using SQL queries.
- Decode Clinical Notes to plain text
- Use a text-embedding model to encode the Clinical Notes to Vectors
- Create a new table in IRIS with these Vectors
- Convert a user query into Vectors
- Perform a rapid Vector search to find related notes
- Create a prompt that includes system instructions, relevant notes, and a user query
- Pass prompt to a Large Language Model
- Return output to user
