FHIR Converter

About the tool

FHIR resources can be serialized in multiple formats including XML, JSON, and RDF (Turtle). This tool allows you to translate FHIR resources between these formats online.

Demo

The format of the input FHIR resource to convert from.
The XML serialization of the FHIR resource.
The format of the output FHIR resource to convert to.
Press Convert to see the result.

About FHIR

FHIR (Fast Healthcare Interoperability Resources) is a standard for healthcare information exchange. Its flexibility and ease of use make it a popular choice for healthcare systems and applications.

The FHIR specification defines multiple serialization formats for representing FHIR resources including XML, JSON, and RDF (Turtle). All of these formats are supposed to be interchangeable (round-trippable) and be able to represent the same content. Conversion between these formats is a common task in FHIR development.

Motivation

I came up with the idea for this tool while tinkering with the fantastic HAPI FHIR library and learning how to use it to work with FHIR data. I hope that you find it useful for running quick/one-off conversions, whether you need to test your FHIR integration or work with mixed-format FHIR data.

This tool also allows you explore/better understand the different FHIR representations and perhaps gain deeper insights into your FHIR data. At the same time, it serves as a demonstration of the power of the HAPI FHIR library.

How does it work?

The tool uses the Java-based HAPI FHIR library for parsing and re-serializing FHIR resources. The library supports multiple serialization formats including XML, JSON, and RDF (Turtle).

Pretty printing is on by defailt, making the output easier to read and analyze. You can turn it off if you need the compact version.

A note about the Turtle format

Initially, I was using HAPI FHIR's parsers/serializers that implement the ca.uhn.fhir.parser.IParser interface to perform re-serialization. In case of RDF, this is done by the instance of the ca.uhn.fhir.parser.RDFParser class. This is the approach described in the HAPI FHIR documentation.

The output of ca.uhn.fhir.parser.RDFParser, however, did not match what you see in the FHIR specification (see this example), so I started looking for the actual class used to generate the Turtle examples in the specification build. It turned out that the specification build used the org.hl7.fhir.r4.elementmodel.TurtleParser class, so I updated my code to use these org.hl7.fhir.r4.elementmodel.* classes for converting FHIR resources.

I also found the third RDF parser/serializer (org.hl7.fhir.r4.formats.RdfParser) in the codebase, but it wasn't what was used for the specification build, so I didn't use it in the tool.

See also

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.