CDA-FHIR-Maps (R4)
0.3.0 - DSTU 1

This page is part of the CDA-FHIR-Maps (R4) (v0.3.0: DSTU 1) based on FHIR R4. . For a full list of available versions, see the Directory of published versions

: Bundle to CDA - JSON Representation

Raw json | Download


{
  "resourceType" : "StructureMap",
  "id" : "BundleToCda",
  "meta" : {
    "versionId" : "3",
    "lastUpdated" : "2022-01-11T22:14:50.980+01:00"
  },
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n         <pre>map &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda&quot; = &quot;BundleToCda&quot;\n\n\n// CDA document\n// 2020-01-16 Oliver Egger, copyright ahdis ag, Apache License\n// CDA:  http://build.fhir.org/ig/ahdis/cda-core-2.0/branches/master/index.html\n// FHIR: http://hl7.org/fhir/r4/\n\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument&quot; alias ClinicalDocument as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Author&quot; alias Author as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/RecordTarget&quot; alias RecordTarget as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Custodian&quot; alias Custodian as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Organization&quot; alias CdaOrganization as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/LegalAuthenticator&quot; alias LegalAuthenticator as target\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Section&quot; alias CdaSection as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; alias Bundle as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Composition&quot; alias Composition as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Practitioner&quot; alias Practitioner as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Patient&quot; alias Patient as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Organization&quot; alias Organization as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/BackboneElement&quot; alias BackboneElement as source\n\nimports &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes&quot;\n\ngroup BundleToCda(source bundle : Bundle, target cda : ClinicalDocument) {\n  bundle -&gt;  cda.recordTarget as recordTarget,  cda.author as author then BundleToClinicalDocument(bundle, recordTarget, author, cda) &quot;bundle&quot;;\n}\n\ngroup BundleToClinicalDocument(source bundle : Bundle, target recordTarget : RecordTarget, target author : Author, target cda : ClinicalDocument) {\n  bundle -&gt; cda.typeId as typeId then {\n    bundle -&gt; typeId.root = '2.16.840.1.113883.1.3' &quot;root&quot;;\n    bundle -&gt; typeId.extension = 'POCD_HD000040' &quot;extension&quot;;\n  } &quot;typeId&quot;;\n  bundle.identifier as identifier -&gt; cda.id as id then IdentifierII(identifier, id) &quot;id&quot;;\n  bundle.timestamp as timestamp -&gt; cda.effectiveTime as effectiveTime then InstantTS(timestamp, effectiveTime) &quot;effectiveTime&quot;;\n  bundle.entry as entry then {\n    entry.resource as resource where $this.ofType(FHIR.Composition) then CompositionClinicalDocument(bundle, resource, recordTarget, author, cda);\n  };\n}\n\n// _________________________ Section Level Templates _________________________\ngroup SectionCdaSection(source bundle : Bundle, source section : BackboneElement, target cdasection : CdaSection) {\n  section.extension as extension where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid' -&gt; cdasection.id as id then {\n    extension.valueIdentifier as valueIdentifier then IdentifierII(valueIdentifier, id) &quot;IdentifierII&quot;;\n  } &quot;valueIdentifier&quot;;\n  section as section where $this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid').exists() = false -&gt; cdasection.id as id then {\n    bundle.identifier as identifier -&gt; cdasection.id as id then IdentifierII(identifier, id) &quot;setId&quot;;\n  } &quot;sectionid&quot;;\n  section.code as code then {\n    code.coding as coding where $this.system = 'http://loinc.org' -&gt; cdasection.code as cdacode then CodingCE(coding, cdacode) &quot;codingsection&quot;;\n  };\n  section.title as title -&gt;  cdasection.title as cdatitle,  cdatitle.data = title;\n  section.text as text then {\n    text.div as div -&gt; cdasection.text = div;\n  };\n}\n\n// _________________________ Entry Level Templates   ________________________\n// _________________________ Header Level Templates _________________________\ngroup CompositionClinicalDocument(source bundle : Bundle, source composition : Composition, target recordTarget : RecordTarget, target author : Author, target cda : ClinicalDocument) {\n  composition.type as type then {\n    type.coding as coding where $this.system = 'http://loinc.org' -&gt; cda.code as code share docCode then CodingCE(coding, code) &quot;code&quot;;\n  };\n  composition.title as title -&gt; cda.title as t then {\n    title -&gt; t.data = title &quot;titleInner&quot;;\n  };\n  composition.confidentiality as conf -&gt; cda.confidentialityCode as cdaconf then {\n    conf -&gt; cdaconf.code = conf &quot;conf&quot;;\n    conf -&gt; cdaconf.codeSystem = '2.16.840.1.113883.5.25' &quot;codeSystem&quot;;\n  } &quot;confidentialityCode&quot;;\n  composition.language as language -&gt;  cda.languageCode as languageCode,  languageCode.code = language &quot;languageCode&quot;;\n  bundle.entry as entry then {\n    entry.fullUrl where ($this in %composition.subject.reference) and $this.startsWith('urn:uuid') then {\n      entry.resource : Patient as patient then PatientRecordTarget(patient, bundle, recordTarget) &quot;patient&quot;;\n    } &quot;uuid&quot;;\n    entry.resource as patient where ('Patient' + '/' + $this.id) in %composition.subject.reference then PatientRecordTarget(patient, bundle, recordTarget) &quot;patient&quot;;\n    entry.fullUrl where ($this in %composition.custodian.reference) and $this.startsWith('urn:uuid') then {\n      entry.resource : Organization as organization -&gt; cda.custodian as custodian then OrganizationCustodian(organization, custodian) &quot;custodian&quot;;\n    } &quot;uuid&quot;;\n    entry.resource as organization where ('Organization' + '/' + $this.id) in %composition.custodian.reference -&gt; cda.custodian as custodian then OrganizationCustodian(organization, custodian) &quot;custodian&quot;;\n    entry.fullUrl where ($this in %composition.author.reference) and $this.startsWith('urn:uuid') then {\n      entry.resource : Practitioner as practitioner then PractitionerAuthor(bundle, composition, practitioner, author) &quot;author&quot;;\n    } &quot;uuid&quot;;\n    entry.resource as practitioner where ('Practitioner' + '/' + $this.id) in %composition.author.reference then PractitionerAuthor(bundle, composition, practitioner, author) &quot;author&quot;;\n    entry.fullUrl where ($this in %composition.attester.party.reference) and $this.startsWith('urn:uuid') then {\n      entry.resource : Practitioner as practitioner -&gt; cda.legalAuthenticator as legalAuthenticator then PractitionerLegalAuthenticator(bundle, composition, practitioner, legalAuthenticator) &quot;legalAuthenticator&quot;;\n    } &quot;uuid&quot;;\n    entry.resource as practitioner where ('Practitioner' + '/' + $this.id) in %composition.attester.party.reference -&gt; cda.legalAuthenticator as legalAuthenticator then PractitionerLegalAuthenticator(bundle, composition, practitioner, legalAuthenticator) &quot;legalAuthenticator&quot;;\n  } &quot;patient&quot;;\n  // source.date -&gt; tgt.effectiveTime &quot;effectiveTime&quot;;\n  composition.section as section where $this.code.exists() = false -&gt; cda.component as component then {\n    section -&gt; component.contextConductionInd = true &quot;contextConductionInd&quot;;\n    section -&gt;  component.structuredBody as structuredBody,  structuredBody.component as component,  component.section as cdasection then SectionCdaSection(bundle, section, cdasection) &quot;cdasection&quot;;\n  };\n}\n\ngroup PatientRecordTarget(source src : Patient, source bundle : Bundle, target tgt : RecordTarget) {\n  src -&gt; tgt.patientRole as patientRole then {\n    src.identifier as identifier -&gt; patientRole.id as id then IdentifierII(identifier, id);\n    src.address as address -&gt; patientRole.addr as ad then AddressAD(address, ad);\n    src -&gt; patientRole.patient as patient then {\n      src.name as humanname -&gt; patient.name as en then HumanNameEN(humanname, en);\n      src.birthDate as birthDate -&gt; patient.birthTime as birthTime then DateTS(birthDate, birthTime);\n      src.gender as v log $this -&gt; patient.administrativeGenderCode as adminGender then {\n        v -&gt; adminGender.code = translate(v, 'http://hl7.org/fhir/ConceptMap/cm-administrative-gender-v3', 'code') &quot;gender&quot;;\n        v -&gt; adminGender.codeSystem = '2.16.840.1.113883.5.1' &quot;codeSytem&quot;;\n        v -&gt; adminGender.codeSystemName = 'HL7 AdministrativeGender' &quot;codeSystemName&quot;;\n        v as v where $this = 'male' -&gt; adminGender.displayName = 'Male' &quot;male&quot;;\n        v as v where $this = 'female' -&gt; adminGender.displayName = 'Female' &quot;female&quot;;\n        v as v where $this = 'other' -&gt; adminGender.displayName = 'Undifferentiated' &quot;other&quot;;\n      };\n    } &quot;patient&quot;;\n    src.telecom as telecom -&gt; patientRole.telecom as tel then ContactPointTEL(telecom, tel);\n    src.managingOrganization as managingOrganization then {\n      bundle.entry as entry then {\n        entry.fullUrl where ($this in %managingOrganization.reference) and $this.startsWith('urn:uuid') -&gt; patientRole.providerOrganization as providerOrganization then Organization2CdaOrganization(managingOrganization, providerOrganization) &quot;providerOrganization&quot;;\n        entry.resource as organization where ('Organization' + '/' + $this.id) in %managingOrganization.reference -&gt; patientRole.providerOrganization as providerOrganization then Organization2CdaOrganization(managingOrganization, providerOrganization) &quot;providerOrganization&quot;;\n      };\n    };\n  } &quot;patientRole&quot;;\n}\n\ngroup PractitionerAuthor(source bundle : Bundle, source composition : Composition, source src : Practitioner, target tgt : Author) {\n  composition.author as srcauthor then {\n    srcauthor.extension as extensionTime where $this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time' then {\n      extensionTime.valueDateTime as valueDateTime -&gt; tgt.time as time then DateTimeTS(valueDateTime, time) &quot;DateTime&quot;;\n    } &quot;extensionTime&quot;;\n  } &quot;srcAuthor&quot;;\n  bundle.timestamp as valueDateTime where composition.author.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time').empty() -&gt; tgt.time as time then DateTimeTS(valueDateTime, time) &quot;DateTimeBundle&quot;;\n  src -&gt; tgt.assignedAuthor as assignedAuthor then {\n    src.identifier as identifier -&gt; assignedAuthor.id as id then IdentifierII(identifier, id) &quot;id&quot;;\n    src.telecom first as telecom -&gt; assignedAuthor.telecom as tel then ContactPointTEL(telecom, tel);\n    src.address as address -&gt; assignedAuthor.addr as ad then AddressAD(address, ad);\n    src.name as name -&gt;  assignedAuthor.assignedPerson as assignedPerson,  assignedPerson.name as en then HumanNameEN(name, en);\n    bundle.entry as entry then {\n      entry.fullUrl where ($this in %composition.author.reference) and $this.startsWith('urn:uuid') then {\n        entry.resource : Organization as organization -&gt; assignedAuthor.representedOrganization as cdaorganization then Organization2CdaOrganization(organization, cdaorganization) &quot;organization&quot;;\n      } &quot;uuid&quot;;\n      entry.resource as organization where ('Organization' + '/' + $this.id) in %composition.author.reference -&gt; assignedAuthor.representedOrganization as cdaorganization then Organization2CdaOrganization(organization, cdaorganization) &quot;organization&quot;;\n    } &quot;patient&quot;;\n  } &quot;assignedAuthor&quot;;\n}\n\ngroup OrganizationCustodian(source src : Organization, target tgt : Custodian) {\n  src -&gt; tgt.assignedCustodian as assignedCustodian then {\n    src -&gt; assignedCustodian.representedCustodianOrganization as representedCustodianOrganization then Organization2CdaOrganizationCustodian(src, representedCustodianOrganization) &quot;representedCustodianOrganization&quot;;\n  } &quot;assignedCustodian&quot;;\n}\n\ngroup Organization2CdaOrganizationCustodian(source src : Organization, target tgt : CdaOrganization) {\n  src.identifier as identifier -&gt; tgt.id as id then IdentifierII(identifier, id) &quot;id&quot;;\n  src.name as name -&gt;  tgt.name as orgname,  orgname.other = name;\n  src.address as address -&gt; tgt.addr as ad then AddressAD(address, ad);\n  // target telecom is 0..1\n  src.telecom first as telecom -&gt; tgt.telecom as tel then ContactPointTEL(telecom, tel);\n}\n\ngroup Organization2CdaOrganization(source src : Organization, target tgt : CdaOrganization) {\n  src.identifier as identifier -&gt; tgt.id as id then IdentifierII(identifier, id) &quot;id&quot;;\n  src.name as name -&gt;  tgt.name as orgname,  orgname.other = name;\n  src.address as address -&gt; tgt.addr as ad then AddressAD(address, ad);\n  src.telecom as telecom -&gt; tgt.telecom as tel then ContactPointTEL(telecom, tel);\n}\n\ngroup PractitionerLegalAuthenticator(source bundle : Bundle, source composition : Composition, source src : Practitioner, target tgt : LegalAuthenticator) {\n  src -&gt;  tgt.templateId as templateId,  templateId.root = '2.16.756.5.30.1.1.10.2.5' &quot;templateId&quot;;\n  composition.attester as attester then {\n    attester.time as srcTime -&gt; tgt.time as time then InstantTS(srcTime, time) &quot;timestamp&quot;;\n  } &quot;time&quot;;\n  // src -&gt; tgt.signatureCode = 'S' &quot;S&quot;;\n  src -&gt;  tgt.signatureCode as signatureCode,  signatureCode.code = 'S' &quot;signature&quot;;\n  src -&gt; tgt.assignedEntity as assignedEntity then {\n    src.identifier as identifier -&gt; assignedEntity.id as id then IdentifierII(identifier, id);\n    src.name as name -&gt;  assignedEntity.assignedPerson as assignedPerson,  assignedPerson.name as en then HumanNameEN(name, en);\n  } &quot;assignedEntity&quot;;\n}\n\n</pre>\n      </div>"
  },
  "url" : "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda",
  "version" : "0.3.0",
  "name" : "BundleToCda",
  "status" : "draft",
  "date" : "2022-02-11T11:14:39+01:00",
  "publisher" : "ahdis",
  "contact" : [
    {
      "name" : "ahdis",
      "telecom" : [
        {
          "system" : "url",
          "value" : "http://www.ahdis.ch/"
        }
      ]
    }
  ],
  "description" : "\r\nCDA document\r\n2020-01-16 Oliver Egger, copyright ahdis ag, Apache License\r\nCDA:  http://build.fhir.org/ig/ahdis/cda-core-2.0/branches/master/index.html\r\nFHIR: http://hl7.org/fhir/r4/\r\n",
  "copyright" : "CC-BY-SA-4.0",
  "structure" : [
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument",
      "mode" : "target",
      "alias" : "ClinicalDocument"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Author",
      "mode" : "target",
      "alias" : "Author"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget",
      "mode" : "target",
      "alias" : "RecordTarget"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Custodian",
      "mode" : "target",
      "alias" : "Custodian"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Organization",
      "mode" : "target",
      "alias" : "CdaOrganization"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/LegalAuthenticator",
      "mode" : "target",
      "alias" : "LegalAuthenticator"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Section",
      "mode" : "target",
      "alias" : "CdaSection"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode" : "source",
      "alias" : "Bundle"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Composition",
      "mode" : "source",
      "alias" : "Composition"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Practitioner",
      "mode" : "source",
      "alias" : "Practitioner"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Patient",
      "mode" : "source",
      "alias" : "Patient"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Organization",
      "mode" : "source",
      "alias" : "Organization"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/BackboneElement",
      "mode" : "source",
      "alias" : "BackboneElement"
    }
  ],
  "import" : [
    "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes"
  ],
  "group" : [
    {
      "name" : "BundleToCda",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "bundle",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "recordTarget",
              "variable" : "recordTarget"
            },
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "author",
              "variable" : "author"
            }
          ],
          "dependent" : [
            {
              "name" : "BundleToClinicalDocument",
              "variable" : [
                "bundle",
                "recordTarget",
                "author",
                "cda"
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "BundleToClinicalDocument",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "recordTarget",
          "type" : "RecordTarget",
          "mode" : "target"
        },
        {
          "name" : "author",
          "type" : "Author",
          "mode" : "target"
        },
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "typeId",
          "source" : [
            {
              "context" : "bundle"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "typeId",
              "variable" : "typeId"
            }
          ],
          "rule" : [
            {
              "name" : "root",
              "source" : [
                {
                  "context" : "bundle"
                }
              ],
              "target" : [
                {
                  "context" : "typeId",
                  "contextType" : "variable",
                  "element" : "root",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.840.1.113883.1.3"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "extension",
              "source" : [
                {
                  "context" : "bundle"
                }
              ],
              "target" : [
                {
                  "context" : "typeId",
                  "contextType" : "variable",
                  "element" : "extension",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "POCD_HD000040"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "id",
          "source" : [
            {
              "context" : "bundle",
              "element" : "identifier",
              "variable" : "identifier"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "id"
            }
          ],
          "dependent" : [
            {
              "name" : "IdentifierII",
              "variable" : [
                "identifier",
                "id"
              ]
            }
          ]
        },
        {
          "name" : "effectiveTime",
          "source" : [
            {
              "context" : "bundle",
              "element" : "timestamp",
              "variable" : "timestamp"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "effectiveTime",
              "variable" : "effectiveTime"
            }
          ],
          "dependent" : [
            {
              "name" : "InstantTS",
              "variable" : [
                "timestamp",
                "effectiveTime"
              ]
            }
          ]
        },
        {
          "name" : "entry",
          "source" : [
            {
              "context" : "bundle",
              "element" : "entry",
              "variable" : "entry"
            }
          ],
          "rule" : [
            {
              "name" : "resource",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "resource",
                  "condition" : "$this.ofType(FHIR.Composition)"
                }
              ],
              "dependent" : [
                {
                  "name" : "CompositionClinicalDocument",
                  "variable" : [
                    "bundle",
                    "resource",
                    "recordTarget",
                    "author",
                    "cda"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "SectionCdaSection",
      "typeMode" : "none",
      "documentation" : "_________________________ Section Level Templates _________________________",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "section",
          "type" : "BackboneElement",
          "mode" : "source"
        },
        {
          "name" : "cdasection",
          "type" : "CdaSection",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "valueIdentifier",
          "source" : [
            {
              "context" : "section",
              "element" : "extension",
              "variable" : "extension",
              "condition" : "$this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid'"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "id"
            }
          ],
          "rule" : [
            {
              "name" : "IdentifierII",
              "source" : [
                {
                  "context" : "extension",
                  "element" : "valueIdentifier",
                  "variable" : "valueIdentifier"
                }
              ],
              "dependent" : [
                {
                  "name" : "IdentifierII",
                  "variable" : [
                    "valueIdentifier",
                    "id"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "sectionid",
          "source" : [
            {
              "context" : "section",
              "variable" : "section",
              "condition" : "$this.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid').exists() = false"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "id"
            }
          ],
          "rule" : [
            {
              "name" : "setId",
              "source" : [
                {
                  "context" : "bundle",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "id",
                  "variable" : "id"
                }
              ],
              "dependent" : [
                {
                  "name" : "IdentifierII",
                  "variable" : [
                    "identifier",
                    "id"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "section",
              "element" : "code",
              "variable" : "code"
            }
          ],
          "rule" : [
            {
              "name" : "codingsection",
              "source" : [
                {
                  "context" : "code",
                  "element" : "coding",
                  "variable" : "coding",
                  "condition" : "$this.system = 'http://loinc.org'"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "cdacode"
                }
              ],
              "dependent" : [
                {
                  "name" : "CodingCE",
                  "variable" : [
                    "coding",
                    "cdacode"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "title",
          "source" : [
            {
              "context" : "section",
              "element" : "title",
              "variable" : "title"
            }
          ],
          "target" : [
            {
              "context" : "cdasection",
              "contextType" : "variable",
              "element" : "title",
              "variable" : "cdatitle"
            },
            {
              "context" : "cdatitle",
              "contextType" : "variable",
              "element" : "data",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "title"
                }
              ]
            }
          ]
        },
        {
          "name" : "text",
          "source" : [
            {
              "context" : "section",
              "element" : "text",
              "variable" : "text"
            }
          ],
          "rule" : [
            {
              "name" : "div",
              "source" : [
                {
                  "context" : "text",
                  "element" : "div",
                  "variable" : "div"
                }
              ],
              "target" : [
                {
                  "context" : "cdasection",
                  "contextType" : "variable",
                  "element" : "text",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "div"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "CompositionClinicalDocument",
      "typeMode" : "none",
      "documentation" : "_________________________ Entry Level Templates   ________________________\r\n_________________________ Header Level Templates _________________________",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "composition",
          "type" : "Composition",
          "mode" : "source"
        },
        {
          "name" : "recordTarget",
          "type" : "RecordTarget",
          "mode" : "target"
        },
        {
          "name" : "author",
          "type" : "Author",
          "mode" : "target"
        },
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "type",
          "source" : [
            {
              "context" : "composition",
              "element" : "type",
              "variable" : "type"
            }
          ],
          "rule" : [
            {
              "name" : "code",
              "source" : [
                {
                  "context" : "type",
                  "element" : "coding",
                  "variable" : "coding",
                  "condition" : "$this.system = 'http://loinc.org'"
                }
              ],
              "target" : [
                {
                  "context" : "cda",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "code",
                  "listMode" : [
                    "share"
                  ],
                  "listRuleId" : "docCode"
                }
              ],
              "dependent" : [
                {
                  "name" : "CodingCE",
                  "variable" : [
                    "coding",
                    "code"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "title",
          "source" : [
            {
              "context" : "composition",
              "element" : "title",
              "variable" : "title"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "rule" : [
            {
              "name" : "titleInner",
              "source" : [
                {
                  "context" : "title"
                }
              ],
              "target" : [
                {
                  "context" : "t",
                  "contextType" : "variable",
                  "element" : "data",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "title"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "confidentialityCode",
          "source" : [
            {
              "context" : "composition",
              "element" : "confidentiality",
              "variable" : "conf"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "confidentialityCode",
              "variable" : "cdaconf"
            }
          ],
          "rule" : [
            {
              "name" : "conf",
              "source" : [
                {
                  "context" : "conf"
                }
              ],
              "target" : [
                {
                  "context" : "cdaconf",
                  "contextType" : "variable",
                  "element" : "code",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "conf"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "codeSystem",
              "source" : [
                {
                  "context" : "conf"
                }
              ],
              "target" : [
                {
                  "context" : "cdaconf",
                  "contextType" : "variable",
                  "element" : "codeSystem",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "2.16.840.1.113883.5.25"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "languageCode",
          "source" : [
            {
              "context" : "composition",
              "element" : "language",
              "variable" : "language"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "languageCode",
              "variable" : "languageCode"
            },
            {
              "context" : "languageCode",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "language"
                }
              ]
            }
          ]
        },
        {
          "name" : "patient",
          "source" : [
            {
              "context" : "bundle",
              "element" : "entry",
              "variable" : "entry"
            }
          ],
          "rule" : [
            {
              "name" : "uuid",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "fullUrl",
                  "condition" : "($this in %composition.subject.reference) and $this.startsWith('urn:uuid')"
                }
              ],
              "rule" : [
                {
                  "name" : "patient",
                  "source" : [
                    {
                      "context" : "entry",
                      "type" : "Patient",
                      "element" : "resource",
                      "variable" : "patient"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "PatientRecordTarget",
                      "variable" : [
                        "patient",
                        "bundle",
                        "recordTarget"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "patient",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "patient",
                  "condition" : "('Patient' + '/' + $this.id) in %composition.subject.reference"
                }
              ],
              "dependent" : [
                {
                  "name" : "PatientRecordTarget",
                  "variable" : [
                    "patient",
                    "bundle",
                    "recordTarget"
                  ]
                }
              ]
            },
            {
              "name" : "uuid",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "fullUrl",
                  "condition" : "($this in %composition.custodian.reference) and $this.startsWith('urn:uuid')"
                }
              ],
              "rule" : [
                {
                  "name" : "custodian",
                  "source" : [
                    {
                      "context" : "entry",
                      "type" : "Organization",
                      "element" : "resource",
                      "variable" : "organization"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "cda",
                      "contextType" : "variable",
                      "element" : "custodian",
                      "variable" : "custodian"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "OrganizationCustodian",
                      "variable" : [
                        "organization",
                        "custodian"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "custodian",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "organization",
                  "condition" : "('Organization' + '/' + $this.id) in %composition.custodian.reference"
                }
              ],
              "target" : [
                {
                  "context" : "cda",
                  "contextType" : "variable",
                  "element" : "custodian",
                  "variable" : "custodian"
                }
              ],
              "dependent" : [
                {
                  "name" : "OrganizationCustodian",
                  "variable" : [
                    "organization",
                    "custodian"
                  ]
                }
              ]
            },
            {
              "name" : "uuid",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "fullUrl",
                  "condition" : "($this in %composition.author.reference) and $this.startsWith('urn:uuid')"
                }
              ],
              "rule" : [
                {
                  "name" : "author",
                  "source" : [
                    {
                      "context" : "entry",
                      "type" : "Practitioner",
                      "element" : "resource",
                      "variable" : "practitioner"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "PractitionerAuthor",
                      "variable" : [
                        "bundle",
                        "composition",
                        "practitioner",
                        "author"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "author",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "practitioner",
                  "condition" : "('Practitioner' + '/' + $this.id) in %composition.author.reference"
                }
              ],
              "dependent" : [
                {
                  "name" : "PractitionerAuthor",
                  "variable" : [
                    "bundle",
                    "composition",
                    "practitioner",
                    "author"
                  ]
                }
              ]
            },
            {
              "name" : "uuid",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "fullUrl",
                  "condition" : "($this in %composition.attester.party.reference) and $this.startsWith('urn:uuid')"
                }
              ],
              "rule" : [
                {
                  "name" : "legalAuthenticator",
                  "source" : [
                    {
                      "context" : "entry",
                      "type" : "Practitioner",
                      "element" : "resource",
                      "variable" : "practitioner"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "cda",
                      "contextType" : "variable",
                      "element" : "legalAuthenticator",
                      "variable" : "legalAuthenticator"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "PractitionerLegalAuthenticator",
                      "variable" : [
                        "bundle",
                        "composition",
                        "practitioner",
                        "legalAuthenticator"
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "legalAuthenticator",
              "source" : [
                {
                  "context" : "entry",
                  "element" : "resource",
                  "variable" : "practitioner",
                  "condition" : "('Practitioner' + '/' + $this.id) in %composition.attester.party.reference"
                }
              ],
              "target" : [
                {
                  "context" : "cda",
                  "contextType" : "variable",
                  "element" : "legalAuthenticator",
                  "variable" : "legalAuthenticator"
                }
              ],
              "dependent" : [
                {
                  "name" : "PractitionerLegalAuthenticator",
                  "variable" : [
                    "bundle",
                    "composition",
                    "practitioner",
                    "legalAuthenticator"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "section",
          "source" : [
            {
              "context" : "composition",
              "element" : "section",
              "variable" : "section",
              "condition" : "$this.code.exists() = false"
            }
          ],
          "target" : [
            {
              "context" : "cda",
              "contextType" : "variable",
              "element" : "component",
              "variable" : "component"
            }
          ],
          "rule" : [
            {
              "name" : "contextConductionInd",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "component",
                  "contextType" : "variable",
                  "element" : "contextConductionInd",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueBoolean" : true
                    }
                  ]
                }
              ]
            },
            {
              "name" : "cdasection",
              "source" : [
                {
                  "context" : "section"
                }
              ],
              "target" : [
                {
                  "context" : "component",
                  "contextType" : "variable",
                  "element" : "structuredBody",
                  "variable" : "structuredBody"
                },
                {
                  "context" : "structuredBody",
                  "contextType" : "variable",
                  "element" : "component",
                  "variable" : "component"
                },
                {
                  "context" : "component",
                  "contextType" : "variable",
                  "element" : "section",
                  "variable" : "cdasection"
                }
              ],
              "dependent" : [
                {
                  "name" : "SectionCdaSection",
                  "variable" : [
                    "bundle",
                    "section",
                    "cdasection"
                  ]
                }
              ]
            }
          ],
          "documentation" : "source.date -> tgt.effectiveTime \"effectiveTime\";"
        }
      ]
    },
    {
      "name" : "PatientRecordTarget",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "Patient",
          "mode" : "source"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "RecordTarget",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "patientRole",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "patientRole",
              "variable" : "patientRole"
            }
          ],
          "rule" : [
            {
              "name" : "identifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "target" : [
                {
                  "context" : "patientRole",
                  "contextType" : "variable",
                  "element" : "id",
                  "variable" : "id"
                }
              ],
              "dependent" : [
                {
                  "name" : "IdentifierII",
                  "variable" : [
                    "identifier",
                    "id"
                  ]
                }
              ]
            },
            {
              "name" : "address",
              "source" : [
                {
                  "context" : "src",
                  "element" : "address",
                  "variable" : "address"
                }
              ],
              "target" : [
                {
                  "context" : "patientRole",
                  "contextType" : "variable",
                  "element" : "addr",
                  "variable" : "ad"
                }
              ],
              "dependent" : [
                {
                  "name" : "AddressAD",
                  "variable" : [
                    "address",
                    "ad"
                  ]
                }
              ]
            },
            {
              "name" : "patient",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "patientRole",
                  "contextType" : "variable",
                  "element" : "patient",
                  "variable" : "patient"
                }
              ],
              "rule" : [
                {
                  "name" : "name",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "name",
                      "variable" : "humanname"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "name",
                      "variable" : "en"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "HumanNameEN",
                      "variable" : [
                        "humanname",
                        "en"
                      ]
                    }
                  ]
                },
                {
                  "name" : "birthDate",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "birthDate",
                      "variable" : "birthDate"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "birthTime",
                      "variable" : "birthTime"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "DateTS",
                      "variable" : [
                        "birthDate",
                        "birthTime"
                      ]
                    }
                  ]
                },
                {
                  "name" : "gender",
                  "source" : [
                    {
                      "context" : "src",
                      "element" : "gender",
                      "variable" : "v",
                      "logMessage" : "$this"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "patient",
                      "contextType" : "variable",
                      "element" : "administrativeGenderCode",
                      "variable" : "adminGender"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "gender",
                      "source" : [
                        {
                          "context" : "v"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "adminGender",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "translate",
                          "parameter" : [
                            {
                              "valueId" : "v"
                            },
                            {
                              "valueString" : "http://hl7.org/fhir/ConceptMap/cm-administrative-gender-v3"
                            },
                            {
                              "valueString" : "code"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codeSytem",
                      "source" : [
                        {
                          "context" : "v"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "adminGender",
                          "contextType" : "variable",
                          "element" : "codeSystem",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "2.16.840.1.113883.5.1"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "codeSystemName",
                      "source" : [
                        {
                          "context" : "v"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "adminGender",
                          "contextType" : "variable",
                          "element" : "codeSystemName",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "HL7 AdministrativeGender"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "male",
                      "source" : [
                        {
                          "context" : "v",
                          "variable" : "v",
                          "condition" : "$this = 'male'"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "adminGender",
                          "contextType" : "variable",
                          "element" : "displayName",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Male"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "female",
                      "source" : [
                        {
                          "context" : "v",
                          "variable" : "v",
                          "condition" : "$this = 'female'"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "adminGender",
                          "contextType" : "variable",
                          "element" : "displayName",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Female"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "other",
                      "source" : [
                        {
                          "context" : "v",
                          "variable" : "v",
                          "condition" : "$this = 'other'"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "adminGender",
                          "contextType" : "variable",
                          "element" : "displayName",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Undifferentiated"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "telecom",
              "source" : [
                {
                  "context" : "src",
                  "element" : "telecom",
                  "variable" : "telecom"
                }
              ],
              "target" : [
                {
                  "context" : "patientRole",
                  "contextType" : "variable",
                  "element" : "telecom",
                  "variable" : "tel"
                }
              ],
              "dependent" : [
                {
                  "name" : "ContactPointTEL",
                  "variable" : [
                    "telecom",
                    "tel"
                  ]
                }
              ]
            },
            {
              "name" : "managingOrganization",
              "source" : [
                {
                  "context" : "src",
                  "element" : "managingOrganization",
                  "variable" : "managingOrganization"
                }
              ],
              "rule" : [
                {
                  "name" : "entry",
                  "source" : [
                    {
                      "context" : "bundle",
                      "element" : "entry",
                      "variable" : "entry"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "providerOrganization",
                      "source" : [
                        {
                          "context" : "entry",
                          "element" : "fullUrl",
                          "condition" : "($this in %managingOrganization.reference) and $this.startsWith('urn:uuid')"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patientRole",
                          "contextType" : "variable",
                          "element" : "providerOrganization",
                          "variable" : "providerOrganization"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "Organization2CdaOrganization",
                          "variable" : [
                            "managingOrganization",
                            "providerOrganization"
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "providerOrganization",
                      "source" : [
                        {
                          "context" : "entry",
                          "element" : "resource",
                          "variable" : "organization",
                          "condition" : "('Organization' + '/' + $this.id) in %managingOrganization.reference"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patientRole",
                          "contextType" : "variable",
                          "element" : "providerOrganization",
                          "variable" : "providerOrganization"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "Organization2CdaOrganization",
                          "variable" : [
                            "managingOrganization",
                            "providerOrganization"
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PractitionerAuthor",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "composition",
          "type" : "Composition",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Practitioner",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "Author",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "srcAuthor",
          "source" : [
            {
              "context" : "composition",
              "element" : "author",
              "variable" : "srcauthor"
            }
          ],
          "rule" : [
            {
              "name" : "extensionTime",
              "source" : [
                {
                  "context" : "srcauthor",
                  "element" : "extension",
                  "variable" : "extensionTime",
                  "condition" : "$this.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time'"
                }
              ],
              "rule" : [
                {
                  "name" : "DateTime",
                  "source" : [
                    {
                      "context" : "extensionTime",
                      "element" : "valueDateTime",
                      "variable" : "valueDateTime"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "tgt",
                      "contextType" : "variable",
                      "element" : "time",
                      "variable" : "time"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "DateTimeTS",
                      "variable" : [
                        "valueDateTime",
                        "time"
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "DateTimeBundle",
          "source" : [
            {
              "context" : "bundle",
              "element" : "timestamp",
              "variable" : "valueDateTime",
              "condition" : "composition.author.extension.where(url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time').empty()"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "time",
              "variable" : "time"
            }
          ],
          "dependent" : [
            {
              "name" : "DateTimeTS",
              "variable" : [
                "valueDateTime",
                "time"
              ]
            }
          ]
        },
        {
          "name" : "assignedAuthor",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "assignedAuthor",
              "variable" : "assignedAuthor"
            }
          ],
          "rule" : [
            {
              "name" : "id",
              "source" : [
                {
                  "context" : "src",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "target" : [
                {
                  "context" : "assignedAuthor",
                  "contextType" : "variable",
                  "element" : "id",
                  "variable" : "id"
                }
              ],
              "dependent" : [
                {
                  "name" : "IdentifierII",
                  "variable" : [
                    "identifier",
                    "id"
                  ]
                }
              ]
            },
            {
              "name" : "telecom",
              "source" : [
                {
                  "context" : "src",
                  "element" : "telecom",
                  "listMode" : "first",
                  "variable" : "telecom"
                }
              ],
              "target" : [
                {
                  "context" : "assignedAuthor",
                  "contextType" : "variable",
                  "element" : "telecom",
                  "variable" : "tel"
                }
              ],
              "dependent" : [
                {
                  "name" : "ContactPointTEL",
                  "variable" : [
                    "telecom",
                    "tel"
                  ]
                }
              ]
            },
            {
              "name" : "address",
              "source" : [
                {
                  "context" : "src",
                  "element" : "address",
                  "variable" : "address"
                }
              ],
              "target" : [
                {
                  "context" : "assignedAuthor",
                  "contextType" : "variable",
                  "element" : "addr",
                  "variable" : "ad"
                }
              ],
              "dependent" : [
                {
                  "name" : "AddressAD",
                  "variable" : [
                    "address",
                    "ad"
                  ]
                }
              ]
            },
            {
              "name" : "name",
              "source" : [
                {
                  "context" : "src",
                  "element" : "name",
                  "variable" : "name"
                }
              ],
              "target" : [
                {
                  "context" : "assignedAuthor",
                  "contextType" : "variable",
                  "element" : "assignedPerson",
                  "variable" : "assignedPerson"
                },
                {
                  "context" : "assignedPerson",
                  "contextType" : "variable",
                  "element" : "name",
                  "variable" : "en"
                }
              ],
              "dependent" : [
                {
                  "name" : "HumanNameEN",
                  "variable" : [
                    "name",
                    "en"
                  ]
                }
              ]
            },
            {
              "name" : "patient",
              "source" : [
                {
                  "context" : "bundle",
                  "element" : "entry",
                  "variable" : "entry"
                }
              ],
              "rule" : [
                {
                  "name" : "uuid",
                  "source" : [
                    {
                      "context" : "entry",
                      "element" : "fullUrl",
                      "condition" : "($this in %composition.author.reference) and $this.startsWith('urn:uuid')"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "organization",
                      "source" : [
                        {
                          "context" : "entry",
                          "type" : "Organization",
                          "element" : "resource",
                          "variable" : "organization"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "assignedAuthor",
                          "contextType" : "variable",
                          "element" : "representedOrganization",
                          "variable" : "cdaorganization"
                        }
                      ],
                      "dependent" : [
                        {
                          "name" : "Organization2CdaOrganization",
                          "variable" : [
                            "organization",
                            "cdaorganization"
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "organization",
                  "source" : [
                    {
                      "context" : "entry",
                      "element" : "resource",
                      "variable" : "organization",
                      "condition" : "('Organization' + '/' + $this.id) in %composition.author.reference"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "assignedAuthor",
                      "contextType" : "variable",
                      "element" : "representedOrganization",
                      "variable" : "cdaorganization"
                    }
                  ],
                  "dependent" : [
                    {
                      "name" : "Organization2CdaOrganization",
                      "variable" : [
                        "organization",
                        "cdaorganization"
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "OrganizationCustodian",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "Organization",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "Custodian",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "assignedCustodian",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "assignedCustodian",
              "variable" : "assignedCustodian"
            }
          ],
          "rule" : [
            {
              "name" : "representedCustodianOrganization",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "assignedCustodian",
                  "contextType" : "variable",
                  "element" : "representedCustodianOrganization",
                  "variable" : "representedCustodianOrganization"
                }
              ],
              "dependent" : [
                {
                  "name" : "Organization2CdaOrganizationCustodian",
                  "variable" : [
                    "src",
                    "representedCustodianOrganization"
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "Organization2CdaOrganizationCustodian",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "Organization",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "CdaOrganization",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "id",
          "source" : [
            {
              "context" : "src",
              "element" : "identifier",
              "variable" : "identifier"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "id"
            }
          ],
          "dependent" : [
            {
              "name" : "IdentifierII",
              "variable" : [
                "identifier",
                "id"
              ]
            }
          ]
        },
        {
          "name" : "name",
          "source" : [
            {
              "context" : "src",
              "element" : "name",
              "variable" : "name"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "name",
              "variable" : "orgname"
            },
            {
              "context" : "orgname",
              "contextType" : "variable",
              "element" : "other",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "name"
                }
              ]
            }
          ]
        },
        {
          "name" : "address",
          "source" : [
            {
              "context" : "src",
              "element" : "address",
              "variable" : "address"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "addr",
              "variable" : "ad"
            }
          ],
          "dependent" : [
            {
              "name" : "AddressAD",
              "variable" : [
                "address",
                "ad"
              ]
            }
          ]
        },
        {
          "name" : "telecom",
          "source" : [
            {
              "context" : "src",
              "element" : "telecom",
              "listMode" : "first",
              "variable" : "telecom"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "telecom",
              "variable" : "tel"
            }
          ],
          "dependent" : [
            {
              "name" : "ContactPointTEL",
              "variable" : [
                "telecom",
                "tel"
              ]
            }
          ],
          "documentation" : "target telecom is 0..1"
        }
      ]
    },
    {
      "name" : "Organization2CdaOrganization",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "Organization",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "CdaOrganization",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "id",
          "source" : [
            {
              "context" : "src",
              "element" : "identifier",
              "variable" : "identifier"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "id"
            }
          ],
          "dependent" : [
            {
              "name" : "IdentifierII",
              "variable" : [
                "identifier",
                "id"
              ]
            }
          ]
        },
        {
          "name" : "name",
          "source" : [
            {
              "context" : "src",
              "element" : "name",
              "variable" : "name"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "name",
              "variable" : "orgname"
            },
            {
              "context" : "orgname",
              "contextType" : "variable",
              "element" : "other",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "name"
                }
              ]
            }
          ]
        },
        {
          "name" : "address",
          "source" : [
            {
              "context" : "src",
              "element" : "address",
              "variable" : "address"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "addr",
              "variable" : "ad"
            }
          ],
          "dependent" : [
            {
              "name" : "AddressAD",
              "variable" : [
                "address",
                "ad"
              ]
            }
          ]
        },
        {
          "name" : "telecom",
          "source" : [
            {
              "context" : "src",
              "element" : "telecom",
              "variable" : "telecom"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "telecom",
              "variable" : "tel"
            }
          ],
          "dependent" : [
            {
              "name" : "ContactPointTEL",
              "variable" : [
                "telecom",
                "tel"
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "PractitionerLegalAuthenticator",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "source"
        },
        {
          "name" : "composition",
          "type" : "Composition",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Practitioner",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "LegalAuthenticator",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "templateId",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "templateId",
              "variable" : "templateId"
            },
            {
              "context" : "templateId",
              "contextType" : "variable",
              "element" : "root",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "2.16.756.5.30.1.1.10.2.5"
                }
              ]
            }
          ]
        },
        {
          "name" : "time",
          "source" : [
            {
              "context" : "composition",
              "element" : "attester",
              "variable" : "attester"
            }
          ],
          "rule" : [
            {
              "name" : "timestamp",
              "source" : [
                {
                  "context" : "attester",
                  "element" : "time",
                  "variable" : "srcTime"
                }
              ],
              "target" : [
                {
                  "context" : "tgt",
                  "contextType" : "variable",
                  "element" : "time",
                  "variable" : "time"
                }
              ],
              "dependent" : [
                {
                  "name" : "InstantTS",
                  "variable" : [
                    "srcTime",
                    "time"
                  ]
                }
              ]
            }
          ]
        },
        {
          "name" : "signature",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "signatureCode",
              "variable" : "signatureCode"
            },
            {
              "context" : "signatureCode",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "S"
                }
              ]
            }
          ],
          "documentation" : "src -> tgt.signatureCode = 'S' \"S\";"
        },
        {
          "name" : "assignedEntity",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "assignedEntity",
              "variable" : "assignedEntity"
            }
          ],
          "rule" : [
            {
              "name" : "identifier",
              "source" : [
                {
                  "context" : "src",
                  "element" : "identifier",
                  "variable" : "identifier"
                }
              ],
              "target" : [
                {
                  "context" : "assignedEntity",
                  "contextType" : "variable",
                  "element" : "id",
                  "variable" : "id"
                }
              ],
              "dependent" : [
                {
                  "name" : "IdentifierII",
                  "variable" : [
                    "identifier",
                    "id"
                  ]
                }
              ]
            },
            {
              "name" : "name",
              "source" : [
                {
                  "context" : "src",
                  "element" : "name",
                  "variable" : "name"
                }
              ],
              "target" : [
                {
                  "context" : "assignedEntity",
                  "contextType" : "variable",
                  "element" : "assignedPerson",
                  "variable" : "assignedPerson"
                },
                {
                  "context" : "assignedPerson",
                  "contextType" : "variable",
                  "element" : "name",
                  "variable" : "en"
                }
              ],
              "dependent" : [
                {
                  "name" : "HumanNameEN",
                  "variable" : [
                    "name",
                    "en"
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}