<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Implementing a New FHIR RDF Specification for Semantic Clinical Data Using a JSON- LD-based Approach</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Deepak K. Sharma</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Eric Prud'hommeaux</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>David Booth</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Kevin J. Peterson</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Daniel J. Stone</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Harold Solbrig</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Guohui Xiao</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Emily Pfaff</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Guoqian Jiang</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mayo Clinic</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Rochester</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Janeiro Digital</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Boston</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yosemite Project</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Somerville</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Free University of Bozen-Bolzano</institution>
          ,
          <country country="IT">Italy</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Johns Hopkins University</institution>
          ,
          <addr-line>Baltimore, MD</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of North Carolina</institution>
          ,
          <addr-line>Chapel Hill, NC</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>FHIR RDF enables operational healthcare data to be linked with RDF data from other communities. FHIR data can be serialized in either JSON, XML or RDF (Turtle), and tools are used to convert between formats. However, currently the tools for converting to/from FHIR RDF involve custom code. JSON-LD 1.1 @context files now have potential to reduce the cost of implementing and maintaining this FHIR RDF conversion. These @context files can be generated automatically during the FHIR specification build process. Used with a standard, off-the-shelf JSON-LD 1.1 processor, these @context files can do most of the work needed for this conversion, though a small amount of pre- or post-processing is still needed. Using the latest FHIR build and server implementations, we created a framework for the FHIR RDF specification implementation by developing two tools to demonstrate this process: a JSON-LD 1.1 @context generator that produces @context files from the FHIR specification; and a command-line tool for batch conversion between FHIR JSON and FHIR RDF. HL7 Fast Healthcare Interoperability Resources (FHIR)[1] is a next generation standards framework for exchanging electronic healthcare data. The Semantic Web Resource Description Framework (RDF) is one of three standard formats for FHIR data: JSON[2], XML[3] and RDF[4] (Turtle). The HL7 FHIR RDF Workgroup is actively working on creating a new version of the FHIR RDF specification, aiming to achieve better utility and ease of use. Early adopters of FHIR RDF uncovered a number of issues, including 1) literal values are nested under blank nodes (BNodes); 2) FHIR References are nested under BNodes; 3) Ordered lists use an extra BNode to include an explicit fhir:index; 4) FHIR RDF uses long predicate names to ensure uniqueness; and 5) FHIR extensions are awkward for RDF users. For this reason, the FHIR RDF Workgroup is now placing greater emphasis on ease of use. To address these problems, we explored the use of JSON for Linked Data, version 1.1. (JSONLD 1.1)[5] as a means to generate an executable definition of the FHIR RDF specification to enable semantics of the FHIR data. Note that JSON-LD is a W3C standard that allows JSON-LD data to be interpreted as a serialization of RDF triples. JSON-LD 1.1 enables the FHIR RDF specification to be defined in a more declarative style, through the use of “@context”. JSON LD @context files act like a schema for the JSON instance data and can be used to interpret and translate JSON data into RDF formats. The same instance data can be interpreted in multiple ways with different sets of JSON LD @context files. While the JSON LD 1.1 approach is an attractive approach, there are some issues uncovered by early adopters[6]. We focus on these issues here to ensure the implemented tools provide a simple and practical way to convert FHIR JSON to RDF. FHIR JSON can be validated with JSON Schema files that are published with FHIR. However, the JSON schema language has limited expressivity. For instance, it doesn't reject mutually</p>
      </abstract>
      <kwd-group>
        <kwd>HL7 FHIR</kwd>
        <kwd>Healthcare</kwd>
        <kwd>JSON-LD</kwd>
        <kwd>Shape Expression</kwd>
        <kwd>ShEx</kwd>
        <kwd>RDF</kwd>
        <kwd>JSON-LD Context</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        exclusive properties. You can better verify conformance with the FHIR specification by converting
the JSON data to RDF and validating the result with Shape Expression (ShEx)[
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] tools.
In Phase I of this effort, we re-implemented the existing FHIR RDF specification (R4) using
JSONLD 1.1 and demonstrated that this was effective and more declarative than the existing
customcode-based approach. The objective in Phase II is to demonstrate the feasibility of the JSON-LD
1.1 based approach to produce executable definitions of a new FHIR RDF specification.
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Methods:</title>
      <sec id="sec-2-1">
        <title>2.1. Creating a draft FHIR RDF R5 specification</title>
        <p>The initial draft version of the FHIR RDF R5 specification addresses the following issues:
• BNodes: FHIR RDF R4 included extra BNodes to express nested values, and references. For
example, in FHIR RDF R4 a status of "final" is represented as fhir:status [fhir:value
“final”], instead of simply fhir:status “final”, which complicates how these
values are queried by a SPARQL query. In R5 we intend to eliminate these extra BNodes.
• Shortened predicate names: the predicate names in FHIR R4 were unnecessarily long and
could be shortened to reduce redundancy and simplify usage, e.g., instead of having separate
fhir:AdverseEvent.identifier and fhir:AllergyIntolerance.identifier
properties, a single shorter fhir:identifier property could be used across multiple
resources.</p>
        <p>The FHIR model is built with resources descending from a common base class
StructureDefinition while data types descend from base classes of Element or
BackboneElement. We shortened the predicate names if they are not core Element or
BackboneElement. An example of this would be predicate fhir:observation.status
transformed to simply fhir:status.
• Extensions: FHIR allows extensions on Resources and on properties in Resources.</p>
        <p>Extensions are classed as "modifying" or "non-modifying"; where modifying extensions
change the interpretation of the enclosing element and must not be interpreted without
understanding the extension. The FHIR RDF group is balancing tensions between RDF's
monotonicity vs. keeping the RDF representation like JSON and XML.</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.2. Developing a @context generator for implementing R5 specification</title>
        <p>
          • JSON LD 1.1 @context Generator: We developed a Java-based JSON LD @context
Generator[
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] that generates JSON-LD 1.1 @contexts[
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] for the new draft specification out of
the StructureDefinitions of the FHIR data models. The FHIR StructureDefinition
resource describes a structure, i.e., a set of data element definitions, and their associated
rules of usage.
• Shape Expression (ShEx) Generator: We also extended the Shape Expression Generator[
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]
in the FHIR Builder to produce the ShEx schemas[
          <xref ref-type="bibr" rid="ref11">11</xref>
          ] of the FHIR data models.
        </p>
      </sec>
      <sec id="sec-2-3">
        <title>2.3. Implementing a JSON-LD command line tool for data transformation</title>
        <p>
          We implemented a JSON-LD 1.1 FHIR RDF Java-based command line tool[
          <xref ref-type="bibr" rid="ref12">12</xref>
          ] to convert the
JSON files of the FHIR R4 and R5 examples into the RDF Turtle representation that conforms to
the new FHIR RDF specification. The command line tool takes care of pre- and post-processing
of FHIR JSON instance data to be properly used with the JSON-LD 1.1 @context files. The
command line tool also supports optional ShEx validation to ensure converted RDF graphs
conformant to the FHIR RDF specification as defined in ShEx schemas.
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3. Results:</title>
      <p>
        The JSON-LD 1.1 @context generator produced 1355 @context files[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] after processing 658
StructureDefinitions of all published FHIR artifacts[
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] - including resources, foundational
elements, patterns and terminologies. The JSON-LD 1.1 @context files produced correct
rendering identifiers and @context files referenced to work together. An example of this is
MedicationRequest.dosageInstruction of resource type Dosage.
      </p>
      <p>JSON-LD 1.1 @context file medicationrequest.context.jsonld contains references to
Dosage type:
"dosageInstruction": {
"@id": "fhir:dosageInstruction",
"@context": "dosage.context.jsonld"
},
This Dosage type is defined in its own @context file dosage.context.jsonld, which defines
Dosage. This example also demonstrates shortening of the name from
fhir:MedicationRequest.dosageInstruction to fhir:dosageInstruction.
_:b10 fhir:dosageInstruction [
fhir:doseAndRate [
fhir:doseQuantity [
fhir:Quantity.code "mg" ;
fhir:Quantity.system &lt;http://unitsofmeasure.org&gt; ;
fhir:Quantity.unit "mg" ;
fhir:Quantity.value "500"^^xsd:decimal
] ;
fhir:Quantity.type [
fhir:CodeableConcept.coding [
fhir:Coding.code "ordered" ;
fhir:Coding.display "Ordered" ;
fhir:Coding.system &lt;http://terminology.hl7.org/CodeSystem/dose-rate-type&gt;
]
] ;
fhir:route [
fhir:CodeableConcept.coding [
fhir:Coding.code "255559005" ;
fhir:Coding.display "Intramuscular (qualifier value)" ;
fhir:Coding.system &lt;http://snomed.info/sct&gt;
]
] ;
fhir:sequence
fhir:text
fhir:timing [
fhir:Timing.repeat [</p>
      <p>fhir:Timing.count
] ] ] ] .</p>
      <p>1
1 ;
"Administer 500mg IM as a single dose";</p>
      <sec id="sec-3-1">
        <title>4. Conclusion:</title>
        <p>generator and a command line tool for batch conversion to/from FHIR RDF, based on JSON-LD
1.1. We demonstrated the feasibility of the JSON-LD-based approach to handle shortened
predicate names while we are still in the process of implementing the features for handling
BNodes and extensions.</p>
        <p>The approach of leveraging JSON-LD @context files to translate FHIR Resources and Instance
data bi-directionally between FHIR JSON and FHIR RDF has potential to reduce the cost of RDF
implementation and maintenance. This also serves to link the FHIR community to other RDF
communities. The ability to bidirectionally serialize FHIR artifacts using JSON-LD 1.1 has its own
challenges and issues that were addressed with a strategy of pre- or post-processing of instance
data and resolving issues with a suite of JSON-LD -based tools. We developed two tools - a
JSON-LD @context generator and a command-line tool for batch conversion - with the latest
FHIR build and server implementations. The output was validated for a) alignment between the
@context files and the ShEx schemas and b) demonstrate to the community the model resulting
from issues in the FHIR RDF community. This paves the way for these tools to be integrated into
the FHIR build process.</p>
        <p>References</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. (HL7).
          <source>The HL7 Fast Healthcare Interoperability Resources (FHIR)</source>
          .
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: http://www.hl7.org/fhir/.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2. ECMA.
          <article-title>The JSON data interchange syntax</article-title>
          .
          <source>2017 September 30th</source>
          ,
          <year>2021</year>
          ]; Available from: https://www.ecma-international.org/publications-and-standards/standards/ecma-404/.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3. (W3C).
          <source>Extensible Markup Language (XML)</source>
          .
          <source>2008 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://www.w3.org/TR/xml/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. (W3C), W.W.W.C.
          <article-title>Resource Description Framework (RDF</article-title>
          ).
          <source>2016 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://www.w3.org/RDF/.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <article-title>5. (W3C). JSON-LD 1.1 - A JSON-based Serialization for Linked Data</article-title>
          .
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://w3c.github.io/json-ld-syntax/.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Solbrig</surname>
            ,
            <given-names>H.R.</given-names>
          </string-name>
          , et al.,
          <string-name>
            <surname>Exploring</surname>
            <given-names>JSON</given-names>
          </string-name>
          -
          <article-title>LD as an Executable Definition of FHIR RDF to Enable</article-title>
          .
          <source>AMIA Annu Symp Proc</source>
          ,
          <year>2020</year>
          .
          <year>2020</year>
          : p.
          <fpage>1140</fpage>
          -
          <lpage>1149</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7. (W3C).
          <source>Shape Expressions Language</source>
          .
          <source>2019 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: http://shex.io/shex-semantics/.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Project</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <article-title>JSON-LD 1.1</article-title>
          .
          <string-name>
            <given-names>Context</given-names>
            <surname>Generator</surname>
          </string-name>
          .
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://github.com/fhircat/org.hl7.fhir.corea.
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Project</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <article-title>JSON-LD context files at FHIRCat</article-title>
          .
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://github.com/fhircat/jsonld_context_files.
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Project</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <string-name>
            <surname>Shape Expression (ShEx) Generator</surname>
          </string-name>
          .
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://github.com/fhircat/org.hl7.fhir.corea.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>(W3C). Shape Expressions (ShEx) Schema</surname>
          </string-name>
          .
          <source>2019 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: http://shex.io/shex-semantics/#shapes-schema.
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Project</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          <article-title>FHIRCat JSON-LD Command line interface</article-title>
          .
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://github.com/fhircat/jsonld-cli.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <article-title>(HL7). The HL7 FHIR Packages at</article-title>
          NPM.
          <source>2021 September 29th</source>
          ,
          <year>2021</year>
          ]; Available from: https://www.npmjs.com/package/hl7.fhir.r4.core.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>