· Jul 6, 2023 4m read

GPT meets FHIR: Leveraging the power of Open API specs


FHIR has revolutionized the healthcare industry by providing a standardized data model for building healthcare applications and promoting data exchange between different healthcare systems. As the FHIR standard is based on modern API-driven approaches, making it more accessible to mobile and web developers. However, interacting with FHIR APIs can still be challenging especially when it comes to querying data using natural language.

Introducing the FHIR - AI and OpenAPI Chain application, a solution that allows users to interact with FHIR APIs using natural language queries. Built with OpenAI, LangChain, and Streamlit, this application simplifies the process of querying FHIR APIs and makes it more user-friendly.


What are FHIR OpenAPI Specifications?

OpenAPI Specifications (formerly known as Swagger and currently part of OpenAPI Initiative) have become an essential tool in the world of software development, enabling developers to design, document, and interact with APIs more efficiently. OpenAPI Specifications define a standard, machine-readable format for describing RESTful APIs, providing a clear and consistent way to understand their capabilities and use them effectively.

In the healthcare domain, FHIR emerged as a leading standard for data exchange and interoperability. To enhance the interoperability capabilities of FHIR, HL7 has officially documented the FHIR OpenAPI Specifications, which enable developers to seamlessly integrate FHIR resources and operations into their software solutions.


Benefits of FHIR OpenAPI Specifications:

  1. Standardized API Description: OpenAPI Specifications provide a comprehensive and standardized description of FHIR resources, operations, and interactions. Developers can easily understand the structure and capabilities of FHIR-based APIs, making it easier to build integrations and interact with healthcare systems.
  2. Promotion of Interoperability: Foster collaboration among developers, driving the adoption of FHIR standards and best practices. The specifications provide a common language and framework for discussing FHIR-based integrations and implementations, fostering collaboration among developers.
  3. Enhanced Documentation and Testing: Interactive documentation and test suites for better understanding and validation. Developers can create detailed API documentation, making it easier for other developers to understand and utilize the FHIR-based APIs. Test suites based on the specifications enable comprehensive testing and validation of API integrations, ensuring the reliability and accuracy of healthcare data exchange.
  4. Improved Developer Experience: Automatic generation of client libraries and SDKs for seamless integration. This simplifies the integration process and reduces the time and effort required to incorporate FHIR functionality into their applications


How do FHIR, OpenAI, and OpenAPI Chain work together?

The FHIR - AI and OpenAPI Chain application leverages LangChain to load and parse the OpenAPI specifications (OpenAPI Chain). After which, based on these specifications, the chain of prompts given through OpenAI aims to understand natural language queries and convert them into appropriate FHIR API requests. Users can ask questions in plain language, and the application will interact with the chosen FHIR API to retrieve the relevant information.

For example, a user might ask, "What is the latest blood pressure reading for patient, John Doe (ID 111)?" The application will then translate this query into an FHIR API request, fetch the required data, and present it to the user in an easily understandable format.
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]


Benefits of FHIR - AI and OpenAPI Chain

  1. User-friendly interactions: By allowing users to interact with FHIR APIs using natural language queries, the application makes it easier for non-technical users to access and analyze healthcare data.
  2. Improved efficiency: The application streamlines the process of querying FHIR APIs, reducing the time and effort required to obtain relevant information. Also, it has the potential in reducing the number of clicks (time spent) to find any particular information from the application.
  3. Customizable: The FHIR Standards simplify the retrieval of consistent data from any FHIR server, allowing for easy customization. It can be effortlessly configured to seamlessly integrate with any FHIR API, providing a flexible and adaptable solution for diverse healthcare data requirements.


Getting Started with FHIR - AI and OpenAPI Chain

To start using the FHIR - AI and OpenAPI Chain application, follow these steps:

  1. Obtain an OpenAI API key from the OpenAI Platform.
  2. Get an FHIR Server API endpoint. You can either use your own sample FHIR server (unauthenticated access needed) or create a temporary sample server by following the instructions given in the InterSystems IRIS FHIR Learning platform.
  3. Try the application online or set it up locally using the provided instructions.


By integrating AI and natural language processing capabilities, the FHIR - AI and OpenAPI Chain application offers a more intuitive way to interact with FHIR APIs, making healthcare data more accessible and easier to analyze for users of all technical backgrounds.

Vote for our app in the Grand Prix contest if you find it promising!

If you can think of any potential applications using this implementation, please feel free to share them in the discussion thread.

Discussion (4)0
Log in or sign up to continue

Hi Ikram,

Your video is available on InterSystems Developers YouTube:

⏯️FHIR AI and OpenAPI Chain detailed walkthrough
[This is an embedded link, but you cannot view embedded content directly on the site because you have declined the cookies necessary to access it. To view embedded content, you would need to accept all cookies in your Cookies Settings]

Please enjoy!