<?xml version="1.0" encoding="UTF-8"?>

<OperationDefinition xmlns="http://hl7.org/fhir">
  <id value="ToOpenEhr"/>
  <text>
    <status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: OperationDefinition ToOpenEhr</b></p><a name="ToOpenEhr"> </a><a name="hcToOpenEhr"> </a><p>URL: [base]/$toopenehr</p><h3>Parameters</h3><table class="grid"><tr><td><b>Use</b></td><td><b>Name</b></td><td><b>Scope</b></td><td><b>Cardinality</b></td><td><b>Type</b></td><td><b>Binding</b></td><td><b>Documentation</b></td></tr><tr><td>IN</td><td>bundle</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/bundle.html">Bundle</a></td><td/><td><div><p>The FHIR Bundle containing the resources to be converted to an openEHR Composition.</p>
</div></td></tr><tr><td>OUT</td><td>composition</td><td/><td>1..1</td><td><a href="http://hl7.org/fhir/R4/datatypes.html#string">string</a></td><td/><td><div><p>The resulting openEHR Composition serialized as a JSON string.</p>
</div></td></tr><tr><td>OUT</td><td>outcome</td><td/><td>0..*</td><td><a href="http://hl7.org/fhir/R4/operationoutcome.html">OperationOutcome</a></td><td/><td><div><p>An OperationOutcome conveying warnings or partial mapping failures.</p>
</div></td></tr></table></div>
  </text>
  <url value="http://fhirconnect.org/fhir/OperationDefinition/ToOpenEhr"/>
  <version value="0.1.0"/>
  <name value="ToOpenEhr"/>
  <title value="$toopenehr — Convert FHIR Bundle to openEHR Composition"/>
  <status value="draft"/>
  <kind value="operation"/>
  <date value="2026-05-27T11:19:57+02:00"/>
  <publisher value="FHIRConnect"/>
  <contact>
    <name value="FHIRConnect"/>
    <telecom>
      <system value="url"/>
      <value value="https://github.com/SevKohler/FHIRconnect-spec"/>
    </telecom>
  </contact>
  <description value="Converts a FHIR Bundle to an openEHR Composition using a FHIRConnect mapping.&#xA;&#xA;The operation accepts a FHIR Bundle as input and returns a FHIR Parameters resource&#xA;containing the serialized openEHR Composition as a JSON string.&#xA;&#xA;When the mapping is fully successful the response contains only the `composition` parameter.&#xA;When mapping issues occur (e.g. a source element could not be mapped, a required field was&#xA;absent, or a partial result was produced), an additional `outcome` parameter carrying an&#xA;`OperationOutcome` resource SHOULD be included alongside the `composition`. The presence of&#xA;an `OperationOutcome` does not necessarily mean the composition is absent — a partial result&#xA;MAY be returned together with issues describing what could not be mapped.&#xA;&#xA;Example response with OperationOutcome:&#xA;&#xA;```json&#xA;{&#xA;  &quot;resourceType&quot;: &quot;Parameters&quot;,&#xA;  &quot;parameter&quot;: [&#xA;    {&#xA;      &quot;name&quot;: &quot;composition&quot;,&#xA;      &quot;valueString&quot;: &quot;{\&quot;_type\&quot;: \&quot;COMPOSITION\&quot;, \&quot;name\&quot;: {\&quot;_type\&quot;: \&quot;DV_TEXT\&quot;, \&quot;value\&quot;: \&quot;International Patient Summary\&quot;}, ...}&quot;&#xA;    },&#xA;    {&#xA;      &quot;name&quot;: &quot;outcome&quot;,&#xA;      &quot;resource&quot;: {&#xA;        &quot;resourceType&quot;: &quot;OperationOutcome&quot;,&#xA;        &quot;issue&quot;: [&#xA;          {&#xA;            &quot;severity&quot;: &quot;warning&quot;,&#xA;            &quot;code&quot;: &quot;incomplete&quot;,&#xA;            &quot;details&quot;: {&#xA;              &quot;text&quot;: &quot;Element Observation.effectivePeriod could not be mapped; no corresponding openEHR archetype path found.&quot;&#xA;            }&#xA;          }&#xA;        ]&#xA;      }&#xA;    }&#xA;  ]&#xA;}&#xA;```"/>
  <affectsState value="false"/>
  <code value="toopenehr"/>
  <system value="true"/>
  <type value="false"/>
  <instance value="false"/>
  <parameter>
    <name value="bundle"/>
    <use value="in"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The FHIR Bundle containing the resources to be converted to an openEHR Composition."/>
    <type value="Bundle"/>
  </parameter>
  <parameter>
    <name value="composition"/>
    <use value="out"/>
    <min value="1"/>
    <max value="1"/>
    <documentation value="The resulting openEHR Composition serialized as a JSON string."/>
    <type value="string"/>
  </parameter>
  <parameter>
    <name value="outcome"/>
    <use value="out"/>
    <min value="0"/>
    <max value="*"/>
    <documentation value="An OperationOutcome conveying warnings or partial mapping failures."/>
    <type value="OperationOutcome"/>
  </parameter>
</OperationDefinition>