{
  "resourceType" : "OperationDefinition",
  "id" : "ToFhir",
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: OperationDefinition ToFhir</b></p><a name=\"ToFhir\"> </a><a name=\"hcToFhir\"> </a><p>URL: [base]/$tofhir</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>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 openEHR Composition serialized as a JSON string. Passed as valueString rather than resource to maintain FHIR SDK compatibility.</p>\n</div></td></tr><tr><td>IN</td><td>ehr_id</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#string\">string</a></td><td/><td><div><p>The openEHR EHR identifier associated with the Composition.</p>\n</div></td></tr><tr><td>IN</td><td>patient</td><td/><td>0..1</td><td><a href=\"http://hl7.org/fhir/R4/references.html#Reference\">Reference</a> (<a href=\"http://hl7.org/fhir/R4/patient.html\" title=\"http://hl7.org/fhir/StructureDefinition/Patient\">Patient</a>)</td><td/><td><div><p>Reference to the FHIR Patient resource that is the subject of the Composition. Used to populate subject/patient references in mapped resources.</p>\n</div></td></tr><tr><td>IN</td><td>provenance</td><td/><td>0..1</td><td/><td/><td><div><p>Provenance policy information. The engine resolves remaining provenance data; only the policy is required from the caller.</p>\n</div></td></tr><tr><td>IN</td><td>provenance.policy</td><td/><td>0..*</td><td><a href=\"http://hl7.org/fhir/R4/datatypes.html#uri\">uri</a></td><td/><td><div><p>URI identifying the provenance policy.</p>\n</div></td></tr><tr><td>OUT</td><td>return</td><td/><td>1..1</td><td><a href=\"http://hl7.org/fhir/R4/bundle.html\">Bundle</a></td><td/><td><div><p>A Bundle containing the FHIR resources produced by the mapping. The Bundle type\n(collection, searchset, or document) is context-dependent. An OperationOutcome\nMAY be included as an entry to convey warnings or partial mapping failures.</p>\n</div></td></tr></table></div>"
  },
  "url" : "http://fhirconnect.org/fhir/OperationDefinition/ToFhir",
  "version" : "0.1.0",
  "name" : "ToFhir",
  "title" : "$tofhir — Convert openEHR Composition to FHIR",
  "status" : "draft",
  "kind" : "operation",
  "date" : "2026-05-27T11:19:57+02:00",
  "publisher" : "FHIRConnect",
  "contact" : [{
    "name" : "FHIRConnect",
    "telecom" : [{
      "system" : "url",
      "value" : "https://github.com/SevKohler/FHIRconnect-spec"
    }]
  }],
  "description" : "Converts an openEHR Composition to one or more FHIR resources using a FHIRConnect mapping.\n\nThe operation accepts a FHIR Parameters resource containing the serialized openEHR Composition\nand optional context fields (patient reference, EHR ID, provenance policy). It returns a FHIR Bundle\ncontaining the mapped resources. The Bundle type is implementation-dependent\n(collection, searchset, or document) and is not fixed by this specification.\n\nAn OperationOutcome MAY be included in the returned Bundle to convey warnings or partial failures.",
  "affectsState" : false,
  "code" : "tofhir",
  "system" : true,
  "type" : false,
  "instance" : false,
  "parameter" : [{
    "name" : "composition",
    "use" : "in",
    "min" : 1,
    "max" : "1",
    "documentation" : "The openEHR Composition serialized as a JSON string. Passed as valueString rather than resource to maintain FHIR SDK compatibility.",
    "type" : "string"
  },
  {
    "name" : "ehr_id",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "The openEHR EHR identifier associated with the Composition.",
    "type" : "string"
  },
  {
    "name" : "patient",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Reference to the FHIR Patient resource that is the subject of the Composition. Used to populate subject/patient references in mapped resources.",
    "type" : "Reference",
    "targetProfile" : ["http://hl7.org/fhir/StructureDefinition/Patient"]
  },
  {
    "name" : "provenance",
    "use" : "in",
    "min" : 0,
    "max" : "1",
    "documentation" : "Provenance policy information. The engine resolves remaining provenance data; only the policy is required from the caller.",
    "part" : [{
      "name" : "policy",
      "use" : "in",
      "min" : 0,
      "max" : "*",
      "documentation" : "URI identifying the provenance policy.",
      "type" : "uri"
    }]
  },
  {
    "name" : "return",
    "use" : "out",
    "min" : 1,
    "max" : "1",
    "documentation" : "A Bundle containing the FHIR resources produced by the mapping. The Bundle type\n(collection, searchset, or document) is context-dependent. An OperationOutcome\nMAY be included as an entry to convey warnings or partial mapping failures.",
    "type" : "Bundle"
  }]
}