From W3C Wiki
Jump to: navigation, search


HL7 has garnered a lot of attention around a project called FHIR (Fast Healthcare Interoperability Resources). For instance, the US Integrated Program Office has selected FHIR as an exchange format between US DOD's AHLTA and the US Vererances Administration's VISTA EHR sysem¹. This task is to provide useful RDF representations of FHIR resources, with the goal that the Semantic Web advantages of simple, uniform representation and connectivity within a greater network are manifest in that RDF representation.

¹ HIT Standards Committee NwHIN Power Team Transport Standards for Consumer / Exchanges: Preliminary June 19, 2013

RDF representation of FHIR resoruces


Given an XML representation of a FHIR resource, e.g.:

<DiagnosticReport xmlns="http://hl7.org/fhir">
    <type value="Patient"/>
    <reference value="patient/@pat2"/>
  <diagnosticTime value="2011-03-04T08:30:00+11:00"/>
	<system value="http://loinc.org"/>
        <code value="15430-2"/>
	<display value="FULL BLOOD EXAMINATION"/>
      <type value="Observation"/>
      <reference value="#r1"/>

with some embedded or linked clinical observations:

    <Observation id="r1">
	  <system value="http://loinc.org"/>
	  <code value="718-7"/>
	  <display value="Haemoglobin"/>
	<value value="176"/>
	<units value="g/L"/>
	<system value="http://unitsofmeasure.org"/>
	<code value="g/L"/>

we represent the information in RDF as:

[] a fhir:DiagnosticReport;
  :subject [
    a fhir:Reference;
    Reference:reference <patient/@pat2>
  :results [
    :results_name [
      a fhir:Codeable;
        Codeable:coding [
          a fhir:Coding;
          Coding:system [a fhir:Uri; fhir:value <http://loinc.org>];
          Coding:code  [a fhir:Code; fhir:value "15430-2"];
          Coding:display  [a fhir:String; fhir:value "FULL BLOOD EXAMINATION"];
    :results_result [
      a fhir:Reference;
      Reference:reference _:r1

with corresponding clinical observations:

_:r1 a fhir:Observation;
  Observation:name [
    a fhir:Coding;
    Coding:system [a fhir:Uri; fhir:value <http://loinc.org/>];
    Coding:code [a fhir:Code; fhir:value "718-7"];
    Coding:display [a fhir:String; fhir:value "Haemoglobin"]
  Observation:valueQuantity [
     a fhir:Quantity;
     Quantity:value [a fhir:Decimal; fhir:value "176"^^xsd:decimal];
     Quantity:units [a fhir:String; fhir:value "g/L"];
     Quantity:system [a fhir:Uri; fhir:value <http://unitsofmeasure.org>];
     Quantity:code [a fhir:Code; fhir:value "g/L"]

fhir-rdf XSLT


  1. clone github repo
  2. cd generic
  3. $(make site) to download Josh Mandel's nightly FHIR build. This creates a directory site/ with files like allergyintolerance.profile.json
  4. $(make transform.xml) creates a file transform.xsl which can be used to translate FHIR XML examples like allergyintolerance-example to XML.

How it works

The process is driven by the Makefile.

  1. xslt_defs.xml: calls generate_xslt_defs.py to parse site/*.profile.xml and create monolithing XML resource definition xslt_defs.xml
  2. transform.xsl: concatonates a tiny top of an XSLT file head.xml with xslt_defs.xml and a more complex tail.xml to produce transform.xsl

tail.xml's match="/" calls the root templates which are either <xsl:template match="atom:feed" mode="root"> for packaging (needs to be updated to current encapsulation scheme) or or <xsl:template match="*" mode="root"> for everything else. The latter calls the workhorse ResourceRoot template which iteratively crawls through the FHIR Resource's XML matching it against elements in the tree from xslt_defs.xml. This includes a generic transformation for most properties and specific overrides:

OWL representation of FHIR Schema

derived ontology


{ :someNarrative Narrative:status fhir:generated . }
{ :someNarrative Narrative:status [
      CodeableConcept:coding [
        fhir:system fhir:sysID,
        Coding:code "generated"
    ] .