CHATGPT on FHIR: Generative AI and the Future of Healthcare Interoperability

How Large Language Models, Generative AI, and applications such as ChatGPT will add a new component to today’s FHIR Healthcare Interoperability Architecture

FHIR Healthcare Interoperability Architecture Today

My role as CTO at Green Room Technologies is helping health tech companies understand the evolving FHIR Healthcare Interoperability Architecture for sharing healthcare information among providers, payers, and patients. 

Over the last 10 years, I have seen FHIR evolve from its inception to the data exchange standard it is today. I  am really excited about how the latest developments in Large Language Models, Generative AI, and applications such as ChatGPT may dramatically transform the future course of healthcare interoperability architecture and impact how data is managed and shared.   

Current FHIR Healthcare Interoperability Architecture

Key components of this architecture have included the HL7 FHIR data exchange standard that establishes a common healthcare data format, a common API, a SMART on FHIR framework for launching third-party applications from an EHR, and a CDS Hooks framework for registering applications to be launched from an EHR at specific points in a clinical workflow. 

These components are being used today to implement applications by HL7 FHIR Accelerator projects that focus on solving various interoperability problems in healthcare. An example of this can be found in the FHIR Implementation Guide for prior authorization support created by the Da Vinci FHIR Accelerator project. SMART on FHIR and CDS Hooks components are used to implement and coordinate the communication between a provider and an insurance company needed to request the prior authorization needed for a patient medical procedure.  

The FHIR, SMART on FHIR, and CDS Hooks architecture is also being used to implement business and clinical analytics within the existing workflow of a healthcare organization. FHIR provides a common format for the data needed for training machine learning models and SMART on FHIR and CDS Hooks provide a common framework for invoking predictive analytics. 

ChatGPT Understands the FHIR Healthcare Interoperability Architecture

Large Language Models, Generative AI, and applications such as ChatGPT add a new component to this FHIR Healthcare Interoperability Architecture. ChatGPT offers conversational interactions with users that are superior to previous generations of natural language processing. ChatGPT can translate text interactions with users into interactions with computer systems using standardized message protocols. Capturing more of the semantics of a particular application in a message protocol will improve the accuracy of the ChatGPT translation.  

For example, training of the Large Language Model used by ChatGPT included knowledge about the SQL query language so ChatGPT can translate user text input into SQL queries given the proper construction of Prompts. But the Prompts must contain the definition of the tables in the database and ChatGPT must infer the meaning of the table and column names. 

ChatGPT training has also included knowledge of the FHIR data model, FHIR API, SMART on FHIR, and CDS Hooks. ChatGPT does not have to infer the meaning of a FHIR schema because it is defined in the standard. I have done some initial testing of the capabilities of ChatGPT with respect to FHIR and found various types of problems with the response to my Prompts. Some problems were solved through a conversation where I pointed out an error in the response that ChatGPT then corrected. In other conversations, ChatGPT would correct one error which would then cause another error.  

With varying results, I have asked ChatGPT to  

  • Create a text summary of the patient data in a Bundle of FHIR resources 
  • Create a set of FHIR resources that represent a text summary that I provide 
  • Create the string for a FHIR Search API call for patient data described in a text summary 
  • Create the Python source code for executing a FHIR Search API call and displaying the FHIR resources that are returned by the Search 

These interactions with ChatGPT have highlighted where fine-tuning Large Language Models like ChatGPT is necessary to meet the requirements in healthcare. I will cover these fine-tuning efforts by various groups in future blogs.

Integrating ChatGPT in the FHIR Healthcare  Interoperability Architecture Using LangChain

A critical step in the integration of ChatGPT in the FHIR Healthcare Interoperability Architecture is defining a framework for communicating with ChatGPT and other Generative AI modules. LangChain is an open-source Python project that provides a software framework for using Prompts that contain the information necessary for ChatGPT to: 

  • Translate human-generated text to:  
    • data such as FHIR resources, rows in a relational database table, etc. 
    • data for LangChain Tools that execute API calls such as SQL queries on a relational database, FHIR Search API calls on a FHIR repository, WolframAlpha API calls, Google search API calls, etc. 
  • Translate the contents of relational tables, FHIR Resources, etc. to human-understandable text summaries
  • Translate human-generated text into the definition of a sequence of Actions such as LangChain Tool executions

LangChain provides a set of predefined Tools for interacting with commonly used APIs such as SQL queries and Google Search. The definition of each LangChain Tool includes information for ChatGPT about when the Tool should be used and the arguments that should be passed to the Tool for execution. Developers can implement new LangChain tools by following the base LangChain Tool format.  

The LangChain GitHub repository does not contain a FHIR Tool as I write this blog. Please contact me if you are interested in collaborating on its creation and maintenance. 

LangChain also provides a set of predefined Agents for specific types of applications such as chatbots. A LangChain Agent uses ChatGPT to determine which actions to take and in what order. An action can either be using a tool and observing its output, or returning a response to the user. 

OpenAI and Microsoft provide similar capabilities to LangChain using ChatGPT Plugins but LangChain enables the use of other Large Language Models such as Bard from Google, LLaMA from Meta, and open source models from Hugging Face. 

FHIR Healthcare Interoperability Architecture in the Future

Over time, ChatGPT and other Large Language Models will become an integral component of the FHIR Healthcare Interoperability Architecture as their accuracy improves through improved prompt engineering and fine-tuning of healthcare models with feedback from healthcare experts. 

Initially, the focus will be on improving the interaction between systems and users by summarizing complex FHIR patient data for users or assisting users in formulating complex questions about patient data. But software frameworks such as LangChain will enable ChatGPT and other Large Language Models to become first-class services that can both participate in complex healthcare processes and modify those processes. 

The bottom line is that fine-tuning of ChatGPT and other Large Language Models will be required before they can be trusted. I will report on my results as well as the results of others who are investigating ChatGPT and FHIR in future blogs.  

I will also discuss results from others who are investigating how well ChatGPT is able to understand, translate, and manipulate other higher-level models and languages such as BPM+ and OWL/SPARQL and the fine-tuning that will be necessary in order to make a generative AI application such as ChatGPT a trusted component in an interoperability architecture.