<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: vitagroup HIP</title>
    <description>The latest articles on DEV Community by vitagroup HIP (@vitagrouphip).</description>
    <link>https://dev.to/vitagrouphip</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F10469%2F25daf461-af2a-405d-8189-d48c872c5bbf.png</url>
      <title>DEV Community: vitagroup HIP</title>
      <link>https://dev.to/vitagrouphip</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vitagrouphip"/>
    <language>en</language>
    <item>
      <title>Part 4: Searching for data</title>
      <dc:creator>vitagroup HIP</dc:creator>
      <pubDate>Mon, 17 Mar 2025 10:04:22 +0000</pubDate>
      <link>https://dev.to/vitagrouphip/part-4-searching-for-data-3ji6</link>
      <guid>https://dev.to/vitagrouphip/part-4-searching-for-data-3ji6</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Series by Stefan Spiska, Senior Backend Developer, PEN, vitagroup HIP&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 4 of the series "Vendor neutral interoperability with openEHR and HL7 FHIR"
&lt;/h2&gt;

&lt;p&gt;In the previous sections, it was explored how to &lt;strong&gt;create patients and store data&lt;/strong&gt; in HIP. One of the most significant advantages of an &lt;strong&gt;open data platform&lt;/strong&gt; with standardized formats is the ability to &lt;strong&gt;search for data flexibly&lt;/strong&gt; - not just by ID but using &lt;strong&gt;various clinical or administrative criteria&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example use case: Searching for systolic blood pressure in a specific Encounter&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s assume one wants to find &lt;strong&gt;all systolic blood pressure measurements&lt;/strong&gt; in a specific &lt;strong&gt;Encounter&lt;/strong&gt;, where the &lt;strong&gt;value is ≥ 100 mmHg&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FHIR Approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;FHIR&lt;/strong&gt;, one would search for &lt;strong&gt;Observation&lt;/strong&gt; components with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;code = 8480-6&lt;/strong&gt; (Systolic Blood Pressure)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;valueQuantity.value ≥ 100&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;encounter = &lt;strong&gt;Encounter/74aa52fc-6aff-46aa-9848-e37b013354&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the FHIR search request would be :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Observation/?component-code-value-quantity=8480-6$ge100&amp;amp;encounter=74aa52fc-6aff-46aa-9848-e37b013354
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Translating FHIR Search to openEHR Query
&lt;/h2&gt;

&lt;p&gt;Since the FHIR Observation components  was mapped to the openEHR archetype openEHR-EHR-OBSERVATION.blood_pressure.v2,   the FHIR search has to be translated into an openEHR query.&lt;/p&gt;

&lt;p&gt;Thankfully, EHRbase, as an openEHR server, provides a powerful standardised query language called &lt;a href="https://specifications.openehr.org/releases/QUERY/development/AQL.html" rel="noopener noreferrer"&gt;AQL (Archetype Query Language&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Think of AQL as a combination of XPath and SQL, allowing us to query structured clinical data based on openEHR's Reference Model (&lt;a href="https://specifications.openehr.org/releases/RM/Release-1.1.0" rel="noopener noreferrer"&gt;RM&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic AQL Queries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Selecting Compositions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c FROM COMPOSITION c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;would retrieve all Compositions.&lt;/p&gt;

&lt;p&gt;Selecting Observations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; SELECT o FROM OBSERVATION o
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This retrieves all Observations wich in openEHR are part of a Composition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Selecting specific data fields:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c/uid/value,c/context/start_time/value COMPOSITION c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see from the RM-model definition &lt;a href="https://specifications.openehr.org/releases/RM/development/ehr.html#_composition_class" rel="noopener noreferrer"&gt;EHR Information Model &lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  c/uid/value: Navigate to &lt;strong&gt;uid&lt;/strong&gt; field which is of type &lt;a href="https://specifications.openehr.org/releases/BASE/latest/base_types.html#_uid_based_id_class" rel="noopener noreferrer"&gt;UID_BASED_ID&lt;/a&gt; and thus we can navigate the &lt;strong&gt;value&lt;/strong&gt; field which contains a String containing the uid of this composition&lt;/li&gt;
&lt;li&gt;  c/context/start_time/value: Is the display of start time of the composition&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For archetypes objects like openEHR-EHR-OBSERVATION.blood_pressure.v1 one has  to look up the archetypes to get the parts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT 
o/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude,
o/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/units
FROM OBSERVATION o[openEHR-EHR-OBSERVATION.blood_pressure.v1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Previously it was shown that /data[at0001]/events[at0006]/data[at0003]/items[at0004] in the archetype openEHR-EHR-OBSERVATION.blood_pressure.v2 points to the element containing the DV_QUANTITY with the systolic blood pressure and thus we add the relative parts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;value/magnitude&lt;/li&gt;
&lt;li&gt;value/units&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To get the magnitude and unit.&lt;/p&gt;

&lt;p&gt;Note that&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;o[openEHR-EHR-OBSERVATION.blood_pressure.v1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is just a shorthand for&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;o[archetype_node_id ='openEHR-EHR-OBSERVATION.blood_pressure.v1']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which ensures that only Blood Pressure observations are queried.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Joining data across multiple structures&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can also “join“ objects which are contained in each other using the the CONTAINS clause:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT
   c/uid/value,
   c/context/start_time/value,
   o/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude
FROM EHR e 
  CONTAINS COMPOSITION c 
    contains OBSERVATION o[openEHR-EHR-OBSERVATION.blood_pressure.v1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CONTAINS defines hierarchical relationships within an EHR, similar to a structured &lt;strong&gt;join&lt;/strong&gt; in &lt;strong&gt;SQL&lt;/strong&gt;. In this query, it ensures that &lt;strong&gt;Compositions&lt;/strong&gt; are selected from the EHR, and only &lt;strong&gt;Observations&lt;/strong&gt; within those Compositions are retrieved. This allows querying &lt;strong&gt;structured clinical data&lt;/strong&gt; while maintaining the &lt;strong&gt;context&lt;/strong&gt; of where it is stored.&lt;/p&gt;

&lt;p&gt;So each row&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "rows": [
    [
      "635775de-84fb-4ce4-bf65-71249f28953a::cdr-core-sanity-check.hip-cdr-core-ehrbase-enterprise-cdr-core-dev1.dev3.vg-hip.dev::1",
      "2022-02-03T04:05:06",
      120.0
    ],
    [
      "7d99ae32-64e3-40a7-a11f-5c5fb1aafbc0::cdr-core-sanity-check.hip-cdr-core-ehrbase-enterprise-cdr-core-dev1.dev3.vg-hip.dev::1",
      "2022-03-03T00:00:00",
      123.0
    ]
  ]
}       
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will represent a systolic blood pressure measurement together with the ehr id (patient identifier ) and start time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Searching by Encounter&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the last part ist was shown how encounters are represented as Folders in the HIP, containing Compositions. Thus encounter = encounter/74aa52fc-6aff-46aa-9848-e37b013354  can be represented as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT c 
FROM FOLDER f [openEHR-EHR-FOLDER.episode_of_care.v1]
      contains COMPOSITION c 
WHERE 
  f/uid/value = '74aa52fc-6aff-46aa-9848-e37b013354'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Putting everything together&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Since component-code was mapped to data[at0001]/events[at0006]/data[at0003]/items[at0004] in the Archetype openEHR-EHR-OBSERVATION.blood_pressure.v2 and the Composition was stored in an Encounter with Id = 74aa52fc-6aff-46aa-9848-e37b013354  the FHIR search&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Observation/?component-code-value-quantity=8480-6$ge100&amp;amp;encounter=74aa52fc-6aff-46aa-9848-e37b013354
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;can be represented as the following AQL query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT DISTINCT c 
FROM FOLDER f [openEHR-EHR-FOLDER.episode_of_care.v1]
      contains COMPOSITION c 
              contains OBSERVATION o[openEHR-EHR-OBSERVATION.blood_pressure.v2]
WHERE 
  f/uid/value = '74aa52fc-6aff-46aa-9848-e37b013354'
AND
  o/data[at0001]/events[at0006]/data[at0003]/items[at0004]/magnitude &amp;gt;= 100                
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;strong&gt;HIP-Bridge&lt;/strong&gt; will read the mappings to automatically transform FHIR search Request to AQL, and transforming the resulting data back to FHIR.&lt;/p&gt;

&lt;p&gt;Thus through the capabilities of the HIP Bridge, users can query data in two ways: using FHIR Search or the Archetype Query Language. This ensures   to meet the needs to system integrations and application developers alike with different views and access mechanisms on the data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this blog series, we have explored how HIP (Health Intelligence Platform) enables vendor neutral interoperability by integrating legacy healthcare data into openEHR and HL7 FHIR. We have seen how data can be transformed into FHIR and openEHR formats, ensuring structured, standardised, and semantically rich data storage.&lt;/p&gt;

&lt;p&gt;By leveraging PSPL (Protocol Specific Path Language) and AQL (Archetype Query Language), we demonstrated how data can be mapped, stored, and efficiently queried, allowing healthcare providers to move beyond simple ID-based searches and perform complex, criteria-driven queries. This level of data accessibility and interoperability empowers organizations to build advanced health applications, enhance clinical decision making, and improve patient outcomes.&lt;/p&gt;

&lt;p&gt;With a vendor neutral and standards based approach, HIP provides a future proof foundation for seamless data exchange between healthcare systems. As healthcare continues to evolve, adopting open data models and interoperability frameworks like openEHR and FHIR will be essential for achieving truly connected and patient centric healthcare ecosystems.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the Author – &lt;a href="https://www.linkedin.com/in/stefan-spiska-b77281221/" rel="noopener noreferrer"&gt;Stefan Spiska&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Stefan Spiska is a Senior Software Developer at vitagroup, specializing in interoperability and open platform development in the E-Health sector. With extensive experience in healthcare IT, he is a core developer for the open source openEHR platform, EHRbase (&lt;a href="https://ehrbase.org/" rel="noopener noreferrer"&gt;ehrbase.org&lt;/a&gt;).&lt;/p&gt;

</description>
      <category>interoperability</category>
      <category>openehr</category>
      <category>hl7fhir</category>
      <category>healthdata</category>
    </item>
    <item>
      <title>Part 3: Storing a Blood pressure measurement</title>
      <dc:creator>vitagroup HIP</dc:creator>
      <pubDate>Mon, 17 Mar 2025 10:04:12 +0000</pubDate>
      <link>https://dev.to/vitagrouphip/part-3-storing-a-blood-pressure-measurement-29ge</link>
      <guid>https://dev.to/vitagrouphip/part-3-storing-a-blood-pressure-measurement-29ge</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Series by Stefan Spiska, Senior Backend Developer, PEN, vitagroup HIP&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 3 of the series "Vendor neutral interoperability with openEHR and HL7 FHIR"
&lt;/h2&gt;

&lt;p&gt;Previous examples handled the management of non medical data in HIP.&lt;/p&gt;

&lt;p&gt;Let’s jump to the management of medical data with the example of creating and and in a later part searching a blood pressure in HIP.&lt;/p&gt;

&lt;p&gt;Let’s assume that a hospital has developed an app on the HIP where patients in follow up care can document their blood pressure measurements. The app sends this data as an &lt;a href="https://hl7.org/fhir/R4/observation.html" rel="noopener noreferrer"&gt;HL7 FHIR Observation&lt;/a&gt; to HIP:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "resourceType" : "Observation",
  "id" : "blood-pressure",
  "meta" : {
    "profile" : ["http://hl7.org/fhir/StructureDefinition/vitalsigns"]
  },
  "identifier" : [{
    "system" : "urn:ietf:rfc:3986",
    "value" : "urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281"
  }],
  "status" : "final",
  "category" : [{
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/observation-category",
      "code" : "vital-signs",
      "display" : "Vital Signs"
    }]
  },
  {
    "coding" : [{
      "system" : "http://loinc.org",
      "code" : "85354-9",
      "display" : "Blood pressure panel with all children optional"
    }]
  }],
  "code" : {
    "coding" : [{
      "system" : "http://loinc.org",
      "code" : "85354-9",
      "display" : "Blood pressure panel with all children optional"
    }],
    "text" : "Blood pressure systolic &amp;amp; diastolic"
  },
 "subject" : {
    "reference" : "https://hip.org/Patient/patient-example-01"
  },


  "effectiveDateTime" : "2012-09-17"

  "component" : [{
    "code" : {
      "coding" : [{
        "system" : "http://loinc.org",
        "code" : "8480-6",
        "display" : "Systolic blood pressure"
      }
    },
    "valueQuantity" : {
      "value" : 107,
      "unit" : "mmHg",
      "system" : "http://unitsofmeasure.org",
      "code" : "mm[Hg]"
    }
  },
  {
    "code" : {
      "coding" : [{
        "system" : "http://loinc.org",
        "code" : "8462-4",
        "display" : "Diastolic blood pressure"
      }]
    },
    "valueQuantity" : {
      "value" : 60,
      "unit" : "mmHg",
      "system" : "http://unitsofmeasure.org",
      "code" : "mm[Hg]"
    },

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  openEHR, FHIR – Semantic binding
&lt;/h2&gt;

&lt;p&gt;HIP uses &lt;a href="https://www.ehrbase.org/" rel="noopener noreferrer"&gt;EHRbase&lt;/a&gt; for data storage which implements the &lt;a href="https://www.ehrbase.org/" rel="noopener noreferrer"&gt;openEHR&lt;/a&gt; standard. The biggest difference between openEHR and FHIR is how the semantic bindings are done. &lt;/p&gt;

&lt;p&gt;If one looks at the FHIR definition we get a syntactic structure in the form of an OBSERVATION which contains a list of &lt;a href="https://hl7.org/fhir/observation-definitions.html#Observation.component" rel="noopener noreferrer"&gt;components &lt;/a&gt; which in this case contains a &lt;a href="https://hl7.org/fhir/datatypes.html#Quantity" rel="noopener noreferrer"&gt;Quantity&lt;/a&gt;. But only when we look at the coding and see a LOINC code of 8462-4  then we know from a semantic standpoint that value Quantity represent the diastolic blood pressure.&lt;/p&gt;

&lt;p&gt;In openEHR on the other side we have archetypes which represent a specific medical domain object like a &lt;br&gt;
&lt;a href="https://ckm.openehr.org/ckm/archetypes/1013.1.3574" rel="noopener noreferrer"&gt;blood pressure&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6kli48p0hxccm0phe2q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6kli48p0hxccm0phe2q.png" alt="Image description" width="800" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The important part here is that this is a maximal data set created by medical professionals, ensuring consistency and completeness of clinical data across systems and use-cases.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating an openEHR Template
&lt;/h2&gt;

&lt;p&gt;To integrate FHIR Observation data into HIP, one can use the &lt;a href="https://tools.openehr.org/designer/" rel="noopener noreferrer"&gt;openEHR Archetype Designer&lt;/a&gt; to create a Template (demo-mapping.ehrbase.org.v0).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The template acts as a structured clinical model, combining multiple openEHR Archetypes.&lt;/li&gt;
&lt;li&gt;One can disable elements based on what data are needed (e.g., just systolic and diastolic values).&lt;/li&gt;
&lt;li&gt;Since a template is a collection of constraints on archetypes, interoperability between different templates is ensured.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxn3ru5166wvjtetch3p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqxn3ru5166wvjtetch3p.png" alt="Image description" width="800" height="763"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Mapping FHIR to openEHR Using PSPL
&lt;/h2&gt;

&lt;p&gt;Similar to the HL7 v2 example in the previous part, one can use PSPL to define mappings between FHIR and openEHR.&lt;/p&gt;

&lt;p&gt;For example now on can easily define the mappings for the component with code 8480-6 to the path /data[at0001]/events[at0006]/data[at0003]/items[at0004]/value in the archetype openEHR-EHR-OBSERVATION.blood_pressure.v2 which will contain a &lt;a href="https://specifications.openehr.org/releases/RM/development/data_types.html#_dv_quantity_class" rel="noopener noreferrer"&gt;Dv_Quantity&lt;/a&gt; which represents the systolic blood pressure.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "storageClass": "DvQuantity",
  "storagePath": "/content[openEHR-EHR-OBSERVATION.blood_pressure.v2]/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value",
  "attributes": {
    "magnitude": {
      "type": "rw",
      "dataType": "Double",
      "sourcePath": "component[isList: true, where: 'code.coding[isList: true].code=\"8480-6\"'].valueQuantity.value"
    },
    "units": {
      "type": "rw",
      "dataType": "String",
      "sourcePath": "component[isList: true, where: 'code.coding[isList: true].code=\"8480-6\"'].valueQuantity.code"
    },
    "unitsSystem": {
      "type": "rw",
      "dataType": "String",
      "sourcePath": "component[isList: true, where: 'code.coding[isList: true].code=\"8480-6\"'].valueQuantity.system"
    },
    "unitsDisplayName": {
      "type": "rw",
      "dataType": "String",
      "sourcePath": "component[isList: true, where: 'code.coding[isList: true].code=\"8480-6\"'].valueQuantity.unit"
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By applying similar mappings for all components, the FHIR OBSERVATION can be transformed into an openEHR COMPOSITION (the root class of each document) based on the template.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "_type": "COMPOSITION",
  "name": {
    "_type": "DV_TEXT",
    "value": "demo-mapping.ehrbase.org.v0"
  },
  "archetype_details": {
    "archetype_id": {
      "value": "openEHR-EHR-COMPOSITION.report.v1"
    },
    "template_id": {
      "value": "demo-mapping.ehrbase.org.v0"
    },
    "rm_version": "1.0.4"
  },
  "language": {
    "_type": "CODE_PHRASE",
    "terminology_id": {
      "_type": "TERMINOLOGY_ID",
      "value": "ISO_639-1"
    },
    "code_string": "en"
  },
  "territory": {
    "_type": "CODE_PHRASE",
    "terminology_id": {
      "_type": "TERMINOLOGY_ID",
      "value": "ISO_3166-1"
    },
    "code_string": "DE"
  },
  "category": {
    "_type": "DV_CODED_TEXT",
    "value": "event",
    "defining_code": {
      "_type": "CODE_PHRASE",
      "terminology_id": {
        "_type": "TERMINOLOGY_ID",
        "value": "openehr"
      },
      "code_string": "433"
    }
  },
  "composer": {
    "_type": "PARTY_IDENTIFIED",
    "name": "Max Mustermann"
  },
  "context": {
    "_type": "EVENT_CONTEXT",
    "start_time": {
      "_type": "DV_DATE_TIME",
      "value": "2012-09-17T00:00:00"
    },
    "setting": {
      "_type": "DV_CODED_TEXT",
      "value": "home",
      "defining_code": {
        "_type": "CODE_PHRASE",
        "terminology_id": {
          "_type": "TERMINOLOGY_ID",
          "value": "openehr"
        },
        "code_string": "225"
      }
    }
  },
  "content": [
    {
      "_type": "OBSERVATION",
      "name": {
        "_type": "DV_CODED_TEXT",
        "value": "Blood pressure panel with all children optional",
        "defining_code": {
          "_type": "CODE_PHRASE",
          "terminology_id": {
            "_type": "TERMINOLOGY_ID",
            "value": "http://loinc.org"
          },
          "code_string": "8480-6"
        }
      },
      "archetype_details": {
        "archetype_id": {
          "value": "openEHR-EHR-OBSERVATION.blood_pressure.v2"
        },
        "rm_version": "1.0.4"
      },
      "language": {
        "_type": "CODE_PHRASE",
        "terminology_id": {
          "_type": "TERMINOLOGY_ID",
          "value": "ISO_639-1"
        },
        "code_string": "en"
      },
      "encoding": {
        "_type": "CODE_PHRASE",
        "terminology_id": {
          "_type": "TERMINOLOGY_ID",
          "value": "IANA_character-sets"
        },
        "code_string": "ISO-10646-UTF-1"
      },
      "subject": {
        "_type": "PARTY_SELF"
      },
      "data": {
        "name": {
          "_type": "DV_TEXT",
          "value": "History"
        },
        "origin": {
          "_type": "DV_DATE_TIME",
          "value": "2012-09-17T00:00:00"
        },
        "events": [
          {
            "_type": "POINT_EVENT",
            "name": {
              "_type": "DV_TEXT",
              "value": "Any event"
            },
            "time": {
              "_type": "DV_DATE_TIME",
              "value": "2012-09-17T00:00:00"
            },
            "data": {
              "_type": "ITEM_TREE",
              "name": {
                "_type": "DV_TEXT",
                "value": "blood pressure"
              },
              "items": [
                {
                  "_type": "ELEMENT",
                  "name": {
                    "_type": "DV_TEXT",
                    "value": "Systolic"
                  },
                  "value": {
                    "_type": "DV_QUANTITY",
                    "units": "mm[Hg]",
                    "magnitude": 107
                  },
                  "archetype_node_id": "at0004"
                },
                {
                  "_type": "ELEMENT",
                  "name": {
                    "_type": "DV_TEXT",
                    "value": "Diastolic"
                  },
                  "value": {
                    "_type": "DV_QUANTITY",
                    "units": "mm[Hg]",
                    "magnitude": 60.0
                  },
                  "archetype_node_id": "at0005"
                }
              ],
              "archetype_node_id": "at0003"
            },
            "archetype_node_id": "at0006"
          }
        ],
        "archetype_node_id": "at0001"
      },
      "archetype_node_id": "openEHR-EHR-OBSERVATION.blood_pressure.v2"
    }
  ],
  "archetype_node_id": "openEHR-EHR-COMPOSITION.report.v1"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thus similar to the case of the ADT message in the previous part whenever a FHIR Observation is sent from the App, a Composition with template demo-mapping.ehrbase.org.v0 is created in EHRbase for the patient which is using the app. &lt;/p&gt;

&lt;h2&gt;
  
  
  Dealing with encounter
&lt;/h2&gt;

&lt;p&gt;There is a small thing which remains. In FHIR the encounter for an observation is represented by a reference&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
...
"encounter":{
    "reference" : "https://hip.org//74aa52fc-6aff-46aa-9848-e37b01335411"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In openEhr, Compositions can be put into a virtual directory to represent logical ordering of things:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqh9bunturntyujz32bgq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqh9bunturntyujz32bgq.png" alt="Image description" width="800" height="641"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So the HIP-Bridge will for each encounter create a Folder and put the Composition in the folder representing the Encounter. We will see in the next part how to use this to quickly query for all Compositions in an Encounter. &lt;/p&gt;

</description>
      <category>interoperability</category>
      <category>openehr</category>
      <category>hl7fhir</category>
      <category>healthdata</category>
    </item>
    <item>
      <title>Part 1: Architecture of the HIP-Bridge</title>
      <dc:creator>vitagroup HIP</dc:creator>
      <pubDate>Mon, 17 Mar 2025 10:03:48 +0000</pubDate>
      <link>https://dev.to/vitagrouphip/part-1-architecture-of-the-hip-bridge-4m6h</link>
      <guid>https://dev.to/vitagrouphip/part-1-architecture-of-the-hip-bridge-4m6h</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Series by Stefan Spiska, Senior Backend Developer, PEN, vitagroup HIP&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 1 of the series "Vendor neutral interoperability with openEHR and HL7 FHIR"
&lt;/h2&gt;

&lt;p&gt;To ensure interoperability, data must be extracted from 3rd party applications like HIS (Hospital Information System) or LIS (Laboratory information systems), transformed into open, vendor-neutral formats, and stored within the Platform via the HIP-Bridge:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fleksv86iozs1oft1shnd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fleksv86iozs1oft1shnd.jpg" alt="Image description" width="521" height="711"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://hip.vitagroup.ag/" rel="noopener noreferrer"&gt;HIP&lt;/a&gt;, non medical data is stored separately from medical data in a &lt;a href="https://hl7.org/fhir/" rel="noopener noreferrer"&gt;HL7 FHIR server&lt;/a&gt;. This separation enables fine grained access control, enhancing privacy and security.&lt;/p&gt;

&lt;p&gt;Structured medical data is primarily stored in HIP EHRbase, following the &lt;a href="https://openehr.org/" rel="noopener noreferrer"&gt;openEHR&lt;/a&gt; standard. This ensures that all data is standardised using clinical information models, known as Archetypes and Templates.&lt;/p&gt;

&lt;p&gt;The HIP-Bridge serves as the central integration point for reading and writing data, facilitating data transformation between different formats. Through connectors, it supports data exchange using multiple standard and legacy data formats, ensuring seamless integration with existing healthcare systems.&lt;/p&gt;

&lt;p&gt;Note: HIP Bridge is backed by a powerful mapping framework, where the storage system of the data can be flexible defined. Therefore, medical data could also be stored in the FHIR Server, as well as non medical data can be stored in EHRbase.&lt;/p&gt;

</description>
      <category>interoperability</category>
      <category>openehr</category>
      <category>hl7fhir</category>
      <category>healthdata</category>
    </item>
    <item>
      <title>Vendor neutral interoperability with openEHR and HL7 FHIR</title>
      <dc:creator>vitagroup HIP</dc:creator>
      <pubDate>Mon, 17 Mar 2025 10:03:38 +0000</pubDate>
      <link>https://dev.to/vitagrouphip/vendor-neutral-interoperability-with-openehr-and-hl7-fhir-2mnh</link>
      <guid>https://dev.to/vitagrouphip/vendor-neutral-interoperability-with-openehr-and-hl7-fhir-2mnh</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Series by Stefan Spiska, Senior Backend Developer, PEN, vitagroup HIP&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In today's healthcare landscape, providers often find their data scattered across multiple applications, many of which offer only a limited and fragmented view of patient information due to reliance on legacy data formats. This lack of interoperability is a considerable challenge to achieve efficient and safe patient treatment.&lt;/p&gt;

&lt;p&gt;Open health data platforms, such as the &lt;strong&gt;Health Intelligence Platform&lt;/strong&gt; (&lt;a href="https://hip.vitagroup.ag/" rel="noopener noreferrer"&gt;HIP&lt;/a&gt;), aim to bridge this gap by integrating and transforming medical data. By providing a vendor neutral, standardised, and semantically rich representation of patient data, these platforms enable seamless data integration and the development of health applications based on a standardized view of the data.&lt;/p&gt;

&lt;p&gt;In this series of articles, we will explore the integration component of HIP - the HIP-Bridge. This component acts as a configurable facade, enabling integration with legacy systems while storing data in open, standardised formats such as &lt;strong&gt;&lt;a href="https://openehr.org/" rel="noopener noreferrer"&gt;openEHR&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href="https://hl7.org/fhir/" rel="noopener noreferrer"&gt;HL7 FHIR&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to expect in this series
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Part 1:&lt;/strong&gt; An overview of the &lt;strong&gt;general architecture&lt;/strong&gt; of the &lt;strong&gt;HIP-Bridge&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part 2:&lt;/strong&gt; How to &lt;strong&gt;integrate with a hospital information system (HIS)&lt;/strong&gt; to to create patient and encounter data in HIP.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part 3:&lt;/strong&gt; The process of storing clinical data within the system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part 4:&lt;/strong&gt; How to efficiently &lt;strong&gt;search for and retrieve medical data&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>interoperability</category>
      <category>openehr</category>
      <category>hl7fhir</category>
      <category>healthdata</category>
    </item>
    <item>
      <title>Part 2: Creating a Patient and Encounter from the HIS via HL7v2</title>
      <dc:creator>vitagroup HIP</dc:creator>
      <pubDate>Thu, 13 Mar 2025 10:55:46 +0000</pubDate>
      <link>https://dev.to/vitagrouphip/part-2-creating-a-patient-and-encounter-from-the-his-via-hl7v2-1ea</link>
      <guid>https://dev.to/vitagrouphip/part-2-creating-a-patient-and-encounter-from-the-his-via-hl7v2-1ea</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Series by Stefan Spiska, Senior Backend Developer, PEN, vitagroup HIP&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Part 2 of the series "Vendor neutral interoperability with openEHR and HL7 FHIR"
&lt;/h2&gt;

&lt;p&gt;The first step in integration is typically &lt;strong&gt;patient onboarding&lt;/strong&gt;. In most hospital settings, when a patient is created in the &lt;strong&gt;Hospital Information System (HIS)&lt;/strong&gt;, other systems within the hospital are notified by sending an &lt;strong&gt;&lt;a href="https://www.hl7.org/implement/standards/product_brief.cfm?product_id=185" rel="noopener noreferrer"&gt;HL7 v2 ADT message&lt;/a&gt;&lt;/strong&gt;, such as the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MSH|^~\&amp;amp;|MIRTH|MIRTH_CONNECT|HIS001|MIRTH_CONNECT|20231010121200||ADT^A01|MSG0000001|P|2.3|||NE|NE|CO|8859/1|ES-CO
PID|||6537077^^^^CC||Smith^John||19860705|M
PV1||I|||||||||||||||||22cce64c-8ea1-4ac9-8974-163087171c85
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HL7 v2 defines a &lt;strong&gt;set of structured messages&lt;/strong&gt;, each consisting of different &lt;strong&gt;segments&lt;/strong&gt; separated by line breaks. Each &lt;strong&gt;segment&lt;/strong&gt; is made up of &lt;strong&gt;fields&lt;/strong&gt; separated by a pipe (|), which can be further divided into &lt;strong&gt;components&lt;/strong&gt; (^) and &lt;strong&gt;subcomponents&lt;/strong&gt; (&amp;amp;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common HL7 v2 Segments&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MSH (Message Header):&lt;/strong&gt; Contains metadata about the message.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PID (Patient Identification):&lt;/strong&gt; Holds patient demographic details.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PV1 (Patient Visit):&lt;/strong&gt; Captures information about the patient's hospital encounter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Breakdown&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;MSH-9 (ADT^A01):&lt;/strong&gt; Message type &lt;strong&gt;ADT (Admission, Discharge, Transfer) Admit/Visit Notification&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PID-5 (Smith^John):&lt;/strong&gt; Patient Name.&lt;/li&gt;
&lt;li&gt;** - &lt;strong&gt;PID-5.1 (Smith)&lt;/strong&gt;: Family Name.&lt;/li&gt;
&lt;li&gt;** - &lt;strong&gt;PID-5.2 (John)&lt;/strong&gt;: Given Name.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a &lt;strong&gt;patient is admitted&lt;/strong&gt;, an &lt;strong&gt;HL7 ADT (Admission, Discharge, Transfer) message&lt;/strong&gt; is generated by the &lt;strong&gt;Hospital Information System (HIS)&lt;/strong&gt;,  to inform 3rd party systems in the hospital. The HIP HL7v2 Connector receives the HL7v2 mesages and forwards them towards HIP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Convert HL7v2 to a FHIR Patient and a FHIR Encounter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;PSLP - Protocol Specific Path Language&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To facilitate data mapping between different formats, vitagroup developed PSPL (Protocol Specific Path Language) - a path based navigation and extraction language.&lt;/p&gt;

&lt;p&gt;With PSPL, integration experts can define mappings between various data formats. Elements are identified using expressions similar to XPath or FHIRPath. The language supports operations such as traversal, selection, and filtering of hierarchical data models.&lt;/p&gt;

&lt;p&gt;Using PSPL, we can define mappings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;Patient Identification (PID) segment&lt;/strong&gt; to a &lt;strong&gt;FHIR Patient resource&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Patient Visit (PV1) segment&lt;/strong&gt; to a &lt;strong&gt;FHIR Encounter resource&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Defining a Trigger Condition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before applying mappings, we must define when they should be triggered. The following condition ensures that the mapping applies to any incoming message of type "&lt;strong&gt;ADT&lt;/strong&gt;^&lt;strong&gt;A01&lt;/strong&gt;" (Admit/Visit notification), as specified in the message header:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"createConditions": [
      {
        "condition" : "MSH.9",
        "anyExpectedValue" : [
          "ADT^A01"
        ]
      }
    ]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Mapping an HL7 v2 PID segment to a FHIR Patient resource
&lt;/h2&gt;

&lt;p&gt;Next, we define a mapping between an HL7 v2.3 PID segment and an HL7 FHIR R4 Patient resource:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"sourceProtocol": "HL7v2",
    "sourceProtocolVersions": [
      "2.3"
    ],
    "sourceType": "PID",
    "storageProtocol": "FHIR",
    "storageProtocolVersion": "R4",
    "storageType": "Patient",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A series of mappings between segments and elements is then applied. The snippet below maps &lt;strong&gt;PID.5.1&lt;/strong&gt; (Family Name) to &lt;strong&gt;FHIR Patient’s&lt;/strong&gt; name.family:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;      {
        "storageClass": "String",
        "storagePath": "name[isList: true].family",
        "attributes": {
          "value": {
            "type": "rw",
            "sourcePath": "PID.5.1",
            "dataType": "String"
          }
        }
      }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function isList: true ensures that the name element is represented as a &lt;strong&gt;JSON array&lt;/strong&gt; instead of a single JSON object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resulting FHIR Patient Resource&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thus for the incoming Hl7 v2 message we create a Patient resource as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "resourceType": "Patient",
  "name": [
    {
      "family": "Smith",
      "given": [
        "John"
      ]
    }
  ]
...  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mapping an HL7 v2 PV1 segment to a FHIR Encounter resource&lt;/p&gt;

&lt;p&gt;Some transformations require additional logic. For instance, when creating an &lt;strong&gt;Encounter&lt;/strong&gt; from the &lt;strong&gt;PV1 (Patient Visit)&lt;/strong&gt; segment, &lt;strong&gt;PV1-2&lt;/strong&gt; contains &lt;strong&gt;Patient Class&lt;/strong&gt; (Inpatient, Emergency, etc.). Since &lt;strong&gt;PV1-2&lt;/strong&gt; uses a &lt;strong&gt;HL7 v2 value set&lt;/strong&gt;, it must be translated into the corresponding &lt;strong&gt;FHIR value set&lt;/strong&gt; (&lt;a href="https://terminology.hl7.org/5.1.0/ValueSet-encounter-class.html" rel="noopener noreferrer"&gt;FHIR Encounter Class ValueSet&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;See the following Transformation definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
...
  "definition": {
    "sourceProtocol": "HL7v2",
    "sourceProtocolVersions": [
      "2.3"
    ],
    "sourceType": "PV1",
    "storageProtocol": "FHIR",
    "storageProtocolVersion": "R4",
    "storageType": "Encounter",
    "transformations": [
      {
        "storageClass": "String",
        "storagePath": "class.code",
        "attributes": {
          "value": {
            "type": "rw",
            "sourcePath": "PV1.2[convert: '\"E\" -&amp;gt; \"EMER\"; \"I\" -&amp;gt; \"IMP\"; \"O\" -&amp;gt; \"AMB\"; \"P\" -&amp;gt; \"PRENC\";']",
            "dataType": "String"
          }
        }
      },
      {
        "storageClass": "String",
        "storagePath": "class.system",
        "attributes": {
          "value": {
            "type": "static",
            "sourcePath": "",
            "staticValue": "http://terminology.hl7.org/CodeSystem/v3-ActCode"
          }
        },
        "conditions": [
          {
            "sourcePath": "PV1.2",
            "anyExpectedValue": [
             "E","I","O","P"
           ]  
          }
        ]
      }
   ...   
    ],
...
    "createConditions": [
      {
        "condition" : "MSH.9",
        "anyExpectedValue" : [
          "ADT^A01"
        ]
      }
    ]
  }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation of transformations&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;convert &lt;strong&gt;function&lt;/strong&gt;:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Maps HL7 v2 PV1-2 codes&lt;/strong&gt; (E, I, O, P) to the &lt;strong&gt;FHIR equivalent values&lt;/strong&gt; (EMER, IMP, AMB, PRENC).&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Static mapping for terminology system:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;If a value from &lt;strong&gt;PV1-2&lt;/strong&gt; is found, a &lt;strong&gt;terminology system URL&lt;/strong&gt; is added (&lt;a href="http://terminology.hl7.org/CodeSystem/v3-ActCode" rel="noopener noreferrer"&gt;http://terminology.hl7.org/CodeSystem/v3-ActCode&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a Result we get a correct FHIR &lt;a href="https://hl7.org/fhir/R4/encounter-definitions.html#Encounter.class" rel="noopener noreferrer"&gt;FHIR coding&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"class" : [{
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/v3-ActCode",
      "code" : "IMP"
    }]
  }]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more complex scenarios a FHIR terminology service and concept maps can be used.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linking the FHIR Encounter to the FHIR Patient&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All that left is to connect the Patient and Encounter resource. With the following mapping we ensure that the created Encounter references the create Patient as subject.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
...
  "definition": {
    "sourceProtocol": "HL7v2",
    "sourceProtocolVersions": [
      "2.3"
    ],
    "sourceType": "PV1",
    "storageProtocol": "FHIR",
    "storageProtocolVersion": "R4",
    "storageType": "Encounter",
    "transformations": [
      {
        "storageClass": "String",
        "storagePath": "subject.reference",
        "attributes": {
          "value": {
            "type": "rw",
            "sourcePath": "PID.3.1[isIdValue: 'Patient']",
            "dataType": "String"
          }
        }
      }      
   ...   
    ],
...
    "createConditions": [
      {
        "condition" : "MSH.9",
        "anyExpectedValue" : [
          "ADT^A01"
        ]
      }
    ]
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Workflow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, whenever an &lt;strong&gt;HL7 ADT message&lt;/strong&gt; arrives at &lt;strong&gt;HIP&lt;/strong&gt;, the defined mappings are &lt;strong&gt;triggered&lt;/strong&gt;, and the &lt;strong&gt;HIP-Bridge&lt;/strong&gt; executes the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create  a &lt;strong&gt;FHIR Patient Resource&lt;/strong&gt; and  a &lt;strong&gt;FHIR Encounter&lt;/strong&gt; from the &lt;strong&gt;HL7 ADT message&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Links the &lt;strong&gt;Encounter&lt;/strong&gt; to the &lt;strong&gt;Patient&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Stores &lt;strong&gt;Encounter&lt;/strong&gt; and &lt;strong&gt;Patient&lt;/strong&gt; in the FHIR-Store. &lt;/li&gt;
&lt;li&gt; Should storing fail because the validation does not pass or any other error, a transaction rollback is conducted across all services to ensure data integrity.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>interoperability</category>
      <category>openehr</category>
      <category>hl7fhir</category>
      <category>healthdata</category>
    </item>
  </channel>
</rss>
