FHIR resource models are defined using structure definitions that can be quite complex due to the use of type choice elements, content references, slicing, etc. While trying to get my head around all these details, I created an interactive explorer for these models (see below) that works directly off the structure definitions.
FHIR (Fast Healthcare Interoperability Resources) is a standard for exchanging healthcare information electronically. It is designed to be easy to implement and use, with the ultimate goal of improving the interoperability of healthcare systems.
The building blocks of FHIR—FHIR resources—are the individual pieces of data that are exchanged between systems. Examples of FHIR resources are Patient, Observation, and MedicationRequest.
Each FHIR resource is a tree structure made of individual fields/data elements. These structures are formally defined using FHIR structure definition resources.
Structure definitions are FHIR's core infrastructure/conformance resources. They provide the mechanism for defining all FHIR types, including resources.
If you read the full docs on structure definitions, you'll see that they are both very powerful and complex—which is necessary if the goal is to be able to define FHIR structures/models in a flexible, reusable, and machine-processable way. To me, some of the most notable and cool features of structure/element definitions include type choice elements, content references, FHIRPath-based constraints, and slicing.
As I was trying to get my head around all these details, I started experimenting with programmatically parsing/interpreting structure definitions and visualizing the encoded FHIR resource models. As a result, I created an interactive tree view/explorer for these models that you can play with below.
The demo below works directly off the structure definitions from the base FHIR specifications (multiple FHIR versions).
There are some interesting cases in which you can go infinitely deep into the tree. For example, the PlanDefinition resource has an element called action which has sub-actions which has sub-actions and so on. In such cases, the structure definitions are traversed recursively as you expand the tree nodes.
Another tricky part of rendering the tree is the handling of type choice elements. An example of type choice element is value[x] in the Observation resource.
The official FHIR specification provides a similar tree view for FHIR resource models that uses icons to help visually distinguish the different types of elements.
Instead of using the same raster icons, I created my own vector versions to give them a more modern, fresh look. I made them optically consistent with the icons used in Visual Studio Code.
Made by Anton Vasetenkov.
If you want to say hi, you can reach me on LinkedIn or via email. If you like my work, you can support me by buying me a coffee.