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

: CDA to Bundle - XML Representation

Raw xml | Download



<StructureMap xmlns="http://hl7.org/fhir">
  <id value="CdaToBundle"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
         <pre>map &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToBundle&quot; = &quot;CdaToBundle&quot;

// CDA document
// 2020-01-16 Oliver Egger, copyright ahdis ag, Apache License
// CDA:  http://build.fhir.org/ig/ahdis/cda-core-2.0/branches/master/index.html
// FHIR: http://hl7.org/fhir/r4/

conceptmap &quot;cm-v3-administrative-gender&quot; {
  prefix s = &quot;http://terminology.hl7.org/ValueSet/v3-AdministrativeGender&quot;
  prefix t = &quot;http://hl7.org/fhir/ValueSet/administrative-gender&quot;

  s:M == t:male
  s:F == t:female
}

uses &quot;http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument&quot; alias ClinicalDocument as source
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor&quot; alias AssignedAuthor as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity&quot; alias AssignedEntity as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization&quot; alias CustodianOrganization as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/Section&quot; alias Section as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/PatientRole&quot; alias PatientRole as queried
uses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; alias Bundle as target
uses &quot;http://hl7.org/fhir/StructureDefinition/Composition&quot; alias Composition as produced
uses &quot;http://hl7.org/fhir/StructureDefinition/Patient&quot; alias Patient as produced
uses &quot;http://hl7.org/fhir/StructureDefinition/Person&quot; alias Patient as produced
uses &quot;http://hl7.org/fhir/StructureDefinition/Practitioner&quot; alias Practitioner as produced
uses &quot;http://hl7.org/fhir/StructureDefinition/Organization&quot; alias Organization as produced

imports &quot;http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToFhirTypes&quot;

group CdaToBundle(source cda : ClinicalDocument, target bundle : Bundle) {
  cda -&gt;  bundle.entry as e,  e.resource = create('Composition') as composition,  composition.id = uuid() as uuid,  e.fullUrl = append('urn:uuid:', uuid),  bundle.entry as e2,  e2.resource = create('Patient') as patient,  patient.id = uuid() as uuid2,  e2.fullUrl = append('urn:uuid:', uuid2) then {
    cda then ClinicalDocumentToBundle(cda, patient, composition, bundle) &quot;cdatobundle&quot;;
  } &quot;ClinicalDocumentToBody&quot;;
}

group ClinicalDocumentToBundle(source cda : ClinicalDocument, target patient : Patient, target composition : Composition, target bundle : Bundle) {
  cda -&gt; bundle.id = uuid() &quot;id&quot;;
  cda.id -&gt; bundle.identifier &quot;identifier&quot;;
  cda -&gt; bundle.type = 'document' &quot;type&quot;;
  cda.effectiveTime -&gt; bundle.timestamp;
  cda then ClinicalDocumentComposition(cda, composition, patient, bundle) &quot;composition&quot;;
  cda.component as component then {
    component.structuredBody as body then {
      body.component as component log 'component' then {
        component.section as srcSection where $this.code.empty() -&gt; composition.section as tgtSection then ClinicalDocumentSection(cda, srcSection, patient, tgtSection, bundle);
      };
    } &quot;body&quot;;
  };
}

// _________________________ Section Level Templates _________________________
group ClinicalDocumentSection(source cda : ClinicalDocument, source src : Section, source patient : Patient, target tgt, target bundle : Bundle) {
  src.id as id where ($this.root = %cda.id.root) = false -&gt; tgt.extension as ext then ChExtEprSectionId(id, ext) &quot;sectionId&quot;;
  src.title as t -&gt; tgt.title = (t.dataString);
  src.code -&gt; tgt.code;
  src.text as cdaText -&gt; tgt.text as fhirText then {
    cdaText -&gt; fhirText.status = 'generated' &quot;narrativeStatus&quot;;
    cdaText as t -&gt; fhirText.div = t &quot;narrativeText&quot;;
  } &quot;cdaText&quot;;
  src.section as srcSection -&gt; tgt.section as tgtSection then ClinicalDocumentSection(cda, srcSection, patient, tgtSection, bundle);
}

// _________________________ Entry Level Templates   ________________________
// _________________________ Header Level Templates _________________________
group ClinicalDocumentComposition(source src : ClinicalDocument, target tgt : Composition, target patientResource : Patient, target bundle : Bundle) {
  src.languageCode -&gt; tgt.language;
  src.id where src.setId.exists().not() -&gt; tgt.identifier &quot;identifier&quot;;
  src.setId -&gt; tgt.identifier &quot;identifier&quot;;
  src -&gt; tgt.status = 'final' &quot;status&quot;;
  src.code -&gt; tgt.type;
  src.title as t -&gt; tgt.title = (t.dataString);
  src.recordTarget as recordTarget then {
    recordTarget.patientRole as patient -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %patientResource.id) then ClinicalDocumentPatientRole(patient, patientResource, bundle) &quot;subject&quot;;
  } &quot;patientRole&quot;;
  src.componentOf as comp -&gt;  bundle.entry as e,  e.resource = create('Encounter') as encounter,  encounter.id = uuid() as uuid,  e.fullUrl = append('urn:uuid:', uuid) then {
    comp.encompassingEncounter as srcEnc -&gt;  tgt.encounter = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %encounter.id) then ClinicalDocumentEncounter(srcEnc, bundle, encounter) &quot;srcEncounter&quot;;
  } &quot;encompassingEncounter&quot;;
  src.effectiveTime -&gt; tgt.date;
  src.author as srcAuthor -&gt;  bundle.entry as e,  e.resource = create('Practitioner') as practitioner,  practitioner.id = uuid() as uuid2,  e.fullUrl = append('urn:uuid:', uuid2),  tgt.author = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %practitioner.id) then {
    srcAuthor.time as time -&gt; reference.extension as exttime then ChExtEprTime(time, exttime);
    srcAuthor.assignedAuthor as assignedAuthor then {
      assignedAuthor.id -&gt; practitioner.identifier;
      assignedAuthor.addr -&gt; practitioner.address;
      assignedAuthor.telecom -&gt; practitioner.telecom;
      assignedAuthor.assignedPerson as person then {
        person.name -&gt; practitioner.name;
      } &quot;name&quot;;
      assignedAuthor.representedOrganization as srcOrg -&gt;  bundle.entry as e2,  e2.resource = create('Organization') as organization,  organization.id = uuid() as uuid3,  e2.fullUrl = append('urn:uuid:', uuid3),  tgt.author = create('Reference') as reference2,  reference2.reference = ('urn:uuid:' + %organization.id) then ClinicalDocumentOrganization(srcOrg, organization);
    } &quot;author&quot;;
  } &quot;srcAuthor&quot;;
  src.confidentialityCode -&gt; tgt.confidentiality;
  src.legalAuthenticator as legalAuth -&gt;  bundle.entry as e,  e.resource = create('Practitioner') as practitioner,  practitioner.id = uuid() as uuid2,  e.fullUrl = append('urn:uuid:', uuid2) then {
    legalAuth -&gt; tgt.attester as attester then {
      legalAuth -&gt; attester.mode = 'legal' &quot;mode&quot;;
      legalAuth.time -&gt; attester.time;
      legalAuth.assignedEntity as entity -&gt;  attester.party = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %practitioner.id) then ClinicalDocumentEntityPractitioner(entity, practitioner) &quot;entity&quot;;
    } &quot;attester&quot;;
  } &quot;legalAuth&quot;;
  src.authenticator as auth -&gt;  bundle.entry as e,  e.resource = create('Practitioner') as practitioner,  practitioner.id = uuid() as uuid2,  e.fullUrl = append('urn:uuid:', uuid2) then {
    auth -&gt; tgt.attester as attester then {
      auth -&gt; attester.mode = 'official' &quot;mode&quot;;
      auth.time -&gt; attester.time;
      auth.assignedEntity as entity -&gt;  attester.party = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %practitioner.id) then ClinicalDocumentEntityPractitioner(entity, practitioner) &quot;entity&quot;;
    } &quot;attester&quot;;
  } &quot;auth&quot;;
  src.custodian as custodian -&gt; bundle.entry as e then {
    custodian.assignedCustodian as assignedCustodian -&gt;  e.resource = create('Organization') as organization,  organization.id = uuid() as uuid3,  e.fullUrl = append('urn:uuid:', uuid3) then {
      assignedCustodian.representedCustodianOrganization as srcOrg -&gt;  tgt.custodian = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %organization.id) then ClinicalDocumentOrganization(srcOrg, organization) &quot;assignedCustodian&quot;;
    } &quot;custodian&quot;;
  } &quot;cust&quot;;
  src.documentationOf as docOf then {
    docOf.serviceEvent as serviceEvent -&gt; tgt.event as event then {
      serviceEvent.code -&gt; event.code &quot;eventCode&quot;;
      serviceEvent.effectiveTime -&gt; event.period &quot;eventTime&quot;;
    } &quot;docOf&quot;;
  };
  src.relatedDocument as relatedDoc -&gt; tgt.relatesTo as relates then {
    relatedDoc.typeCode -&gt; relates.code;
    relatedDoc.parentDocument as parentDoc then {
      parentDoc.setId -&gt; relates.targetIdentifier;
    } &quot;parentDoc&quot;;
  } &quot;relatedDoc&quot;;
}

group ClinicalDocumentEntityPractitioner(source src : AssignedEntity, target tgt : Practitioner) {
  src.id -&gt; tgt.identifier;
  src.addr -&gt; tgt.address;
  src.telecom -&gt; tgt.telecom;
  src.assignedPerson as person then {
    person.name -&gt; tgt.name;
  } &quot;name&quot;;
}

group ClinicalDocumentOrganization(source src : CustodianOrganization, target tgt : Organization) {
  src.id -&gt; tgt.identifier;
  src.name as v -&gt; tgt.name = (v.other);
  src.telecom -&gt; tgt.telecom;
  src.addr -&gt; tgt.address;
}

group ClinicalDocumentPatientRole(source src : PatientRole, target tgt : Patient, target bundle : Bundle) {
  // src.id -&gt; tgt.identifier;
  src -&gt; tgt.identifier as identifier then {
    src.id as id -&gt;  identifier.type as type,  type.coding as coding,  coding.system as system,  coding.code as code then {
      src -&gt; system.value = 'http://terminology.hl7.org/CodeSystem/v2-0203' &quot;system&quot;;
      src -&gt; code.value = 'MR' &quot;code&quot;;
      id.extension as extension -&gt;  identifier.value as value,  value.value = extension;
      id.root as root -&gt;  identifier.system as system,  system.value = append('urn:oid:', root);
    };
  } &quot;identifier&quot;;
  src.addr -&gt; tgt.address;
  src.telecom -&gt; tgt.telecom;
  src.patient as patient then {
    patient.name -&gt; tgt.name;
    patient.administrativeGenderCode as gender then {
      gender.code as v -&gt; tgt.gender = translate(v, '#cm-v3-administrative-gender', 'code') &quot;gender&quot;;
    } &quot;gender&quot;;
    patient.birthTime -&gt; tgt.birthDate &quot;birthDate&quot;;
    patient.deceasedInd as indicator where patient.deceasedTime.empty() -&gt; tgt.deceased = create('boolean') as bool then boolean(indicator, bool) &quot;deceasedBL&quot;;
    patient.deceasedTime -&gt; tgt.deceased;
    patient.maritalStatusCode -&gt; tgt.maritalStatus &quot;maritalStatus&quot;;
    patient.languageCommunication as language -&gt; tgt.communication as communication then {
      language.languageCode -&gt; communication.language &quot;communication&quot;;
    } &quot;language&quot;;
  };
  src.providerOrganization as org -&gt;  bundle.entry as e,  e.resource = create('Organization') as organization,  organization.id = uuid() as uuid3,  e.fullUrl = append('urn:uuid:', uuid3) then {
    org -&gt;  tgt.managingOrganization = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %organization.id) &quot;reference&quot;;
    org.id -&gt; organization.identifier;
    org.name as v -&gt; organization.name = (v.other);
    org.telecom -&gt; organization.telecom;
    org.addr -&gt; organization.address;
  } &quot;organization&quot;;
}

group ClinicalDocumentEncounter(source src : EncompassingEncounter, target bundle : Bundle, target tgt : Encounter) {
  src.id -&gt; tgt.identifier;
  src.code -&gt; tgt.type;
  src.effectiveTime -&gt; tgt.period;
  src where admissionReferralSourceCode.exists() or dischargeDispositionCode.exists() -&gt; tgt.hospitalization as hosp then {
    src.admissionReferralSourceCode -&gt; hosp.admitSource &quot;adminReferral&quot;;
    src.dischargeDispositionCode -&gt; hosp.dischargeDisposition &quot;discDisposition&quot;;
  } &quot;hospitalization&quot;;
  src.encounterParticipant as srcPart -&gt; tgt.participant as tgtPart then {
    srcPart.typeCode as code -&gt; tgtPart.type = cc('http://terminology.hl7.org/CodeSystem/v3-ParticipationType', code);
    srcPart.time -&gt; tgtPart.period;
    srcPart.assignedEntity as entity -&gt;  bundle.entry as e,  e.resource = create('Practitioner') as practitioner,  practitioner.id = uuid() as uuid2,  e.fullUrl = append('urn:uuid:', uuid2) then {
      entity -&gt;  tgtPart.individual = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %practitioner.id) then ClinicalDocumentEntityPractitioner(entity, practitioner) &quot;entry&quot;;
    } &quot;entity&quot;;
  } &quot;participant&quot;;
  src.location as srcLocation then {
    srcLocation.healthCareFacility as facility -&gt;  bundle.entry as e,  e.resource = create('Location') as location,  location.id = uuid() as uuid2,  e.fullUrl = append('urn:uuid:', uuid2) then {
      facility -&gt;  tgt.location as tgtLocation,  tgtLocation.location = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %location.id) then ClinicalDocumentLocation(facility, bundle, location) &quot;facLocation&quot;;
    } &quot;facility&quot;;
  };
}

group ClinicalDocumentLocation(source src : HealthCareFacility, target bundle : Bundle, target tgt : Location) {
  src.id -&gt; tgt.identifier;
  src.code -&gt; tgt.type;
  src.location as location then {
    // place names are usually stored with no parts    location.name as srcName -&gt; tgt.name = cast(srcName, 'string');
    location.addr -&gt; tgt.address;
    location.serviceProviderOrganization as srcOrg -&gt;  bundle.entry as e,  e.resource = create('Organization') as organization,  organization.id = uuid() as uuid3,  e.fullUrl = append('urn:uuid:', uuid3) then {
      srcOrg -&gt;  tgt.managingOrganization = create('Reference') as reference,  reference.reference = ('urn:uuid:' + %organization.id) then ClinicalDocumentOrganization(srcOrg, organization) &quot;organization&quot;;
    } &quot;org&quot;;
  };
}

// source dataEnterer: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.2.7
// source author: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.840.1.113883.10.12.102
// target: https://build.fhir.org/ig/hl7ch/ch-core//StructureDefinition-ch-ext-epr-time.html
group ChExtEprTime(source src : TSDateTime, target ext : Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time' &quot;url&quot;;
  src -&gt; ext.value = create('dateTime') as value then TSDateTime(src, value) &quot;value&quot;;
}

// https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.3.45
// target: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-ext-epr-sectionid.html
group ChExtEprSectionId(source src : II, target ext : Extension) {
  src -&gt; ext.url = 'http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid' &quot;url&quot;;
  src -&gt; ext.value = create('Identifier') as value then II(src, value) &quot;value&quot;;
}

// _________________________ Template Type not specified  ___________________
group NarrativeLink(source url, target ext : Extension) {
  url -&gt; ext.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' &quot;url&quot;;
  url -&gt;  ext.value = create('url') as value,  value.value = url &quot;value&quot;;
}

</pre>
      </div>
  </text>
  <contained>
    <ConceptMap>
      <id value="cm-v3-administrative-gender"/>
      <status value="draft"/>
      <group>
        <source
                value="http://terminology.hl7.org/ValueSet/v3-AdministrativeGender"/>
        <target value="http://hl7.org/fhir/ValueSet/administrative-gender"/>
        <element>
          <code value="M"/>
          <target>
            <code value="male"/>
            <equivalence value="equivalent"/>
          </target>
        </element>
        <element>
          <code value="F"/>
          <target>
            <code value="female"/>
            <equivalence value="equivalent"/>
          </target>
        </element>
      </group>
    </ConceptMap>
  </contained>
  <extension url="http://fhir.ch/reference">
    <valueReference>
      <reference value="#cm-v3-administrative-gender"/>
    </valueReference>
  </extension>
  <url value="http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToBundle"/>
  <version value="0.3.0"/>
  <name value="CdaToBundle"/>
  <status value="draft"/>
  <date value="2022-02-11T11:14:39+01:00"/>
  <publisher value="ahdis"/>
  <contact>
    <name value="ahdis"/>
    <telecom>
      <system value="url"/>
      <value value="http://www.ahdis.ch/"/>
    </telecom>
  </contact>
  <description
               value="CDA document 2020-01-16 Oliver Egger, copyright ahdis ag, Apache License CDA:  http://build.fhir.org/ig/ahdis/cda-core-2.0/branches/master/index.html FHIR: http://hl7.org/fhir/r4/"/>
  <copyright value="CC-BY-SA-4.0"/>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument"/>
    <mode value="source"/>
    <alias value="ClinicalDocument"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor"/>
    <mode value="queried"/>
    <alias value="AssignedAuthor"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity"/>
    <mode value="queried"/>
    <alias value="AssignedEntity"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization"/>
    <mode value="queried"/>
    <alias value="CustodianOrganization"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/Section"/>
    <mode value="queried"/>
    <alias value="Section"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/PatientRole"/>
    <mode value="queried"/>
    <alias value="PatientRole"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
    <mode value="target"/>
    <alias value="Bundle"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Composition"/>
    <mode value="produced"/>
    <alias value="Composition"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
    <mode value="produced"/>
    <alias value="Patient"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Person"/>
    <mode value="produced"/>
    <alias value="Patient"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Practitioner"/>
    <mode value="produced"/>
    <alias value="Practitioner"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Organization"/>
    <mode value="produced"/>
    <alias value="Organization"/>
  </structure>
  <import value="http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToFhirTypes"/>
  <group>
    <name value="CdaToBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="cda"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="ClinicalDocumentToBody"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="composition"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Composition"/>
        </parameter>
      </target>
      <target>
        <context value="composition"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e2"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="patient"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Patient"/>
        </parameter>
      </target>
      <target>
        <context value="patient"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e2"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <rule>
        <name value="cdatobundle"/>
        <source>
          <context value="cda"/>
        </source>
        <dependent>
          <name value="ClinicalDocumentToBundle"/>
          <variable value="cda"/>
          <variable value="patient"/>
          <variable value="composition"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentToBundle"/>
    <typeMode value="none"/>
    <input>
      <name value="cda"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="id"/>
        <transform value="uuid"/>
      </target>
    </rule>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="cda"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="type"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="type"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="document"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="effectiveTime"/>
      <source>
        <context value="cda"/>
        <element value="effectiveTime"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="timestamp"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="composition"/>
      <source>
        <context value="cda"/>
      </source>
      <dependent>
        <name value="ClinicalDocumentComposition"/>
        <variable value="cda"/>
        <variable value="composition"/>
        <variable value="patient"/>
        <variable value="bundle"/>
      </dependent>
    </rule>
    <rule>
      <name value="component"/>
      <source>
        <context value="cda"/>
        <element value="component"/>
        <variable value="component"/>
      </source>
      <rule>
        <name value="body"/>
        <source>
          <context value="component"/>
          <element value="structuredBody"/>
          <variable value="body"/>
        </source>
        <rule>
          <name value="component"/>
          <source>
            <context value="body"/>
            <element value="component"/>
            <variable value="component"/>
            <logMessage value="&#39;component&#39;"/>
          </source>
          <rule>
            <name value="section"/>
            <source>
              <context value="component"/>
              <element value="section"/>
              <variable value="srcSection"/>
              <condition value="$this.code.empty()"/>
            </source>
            <target>
              <context value="composition"/>
              <contextType value="variable"/>
              <element value="section"/>
              <variable value="tgtSection"/>
            </target>
            <dependent>
              <name value="ClinicalDocumentSection"/>
              <variable value="cda"/>
              <variable value="srcSection"/>
              <variable value="patient"/>
              <variable value="tgtSection"/>
              <variable value="bundle"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentSection"/>
    <typeMode value="none"/>
    <documentation
                   value="_________________________ Section Level Templates _________________________"/>
    <input>
      <name value="cda"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="src"/>
      <type value="Section"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="sectionId"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="id"/>
        <condition value="($this.root = %cda.id.root) = false"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="extension"/>
        <variable value="ext"/>
      </target>
      <dependent>
        <name value="ChExtEprSectionId"/>
        <variable value="id"/>
        <variable value="ext"/>
      </dependent>
    </rule>
    <rule>
      <name value="title"/>
      <source>
        <context value="src"/>
        <element value="title"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="t.dataString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="code"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="cdaText"/>
      <source>
        <context value="src"/>
        <element value="text"/>
        <variable value="cdaText"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="text"/>
        <variable value="fhirText"/>
      </target>
      <rule>
        <name value="narrativeStatus"/>
        <source>
          <context value="cdaText"/>
        </source>
        <target>
          <context value="fhirText"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="generated"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="narrativeText"/>
        <source>
          <context value="cdaText"/>
          <variable value="t"/>
        </source>
        <target>
          <context value="fhirText"/>
          <contextType value="variable"/>
          <element value="div"/>
          <transform value="copy"/>
          <parameter>
            <valueId value="t"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="section"/>
      <source>
        <context value="src"/>
        <element value="section"/>
        <variable value="srcSection"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="section"/>
        <variable value="tgtSection"/>
      </target>
      <dependent>
        <name value="ClinicalDocumentSection"/>
        <variable value="cda"/>
        <variable value="srcSection"/>
        <variable value="patient"/>
        <variable value="tgtSection"/>
        <variable value="bundle"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentComposition"/>
    <typeMode value="none"/>
    <documentation
                   value="_________________________ Entry Level Templates   ________________________ _________________________ Header Level Templates _________________________"/>
    <input>
      <name value="src"/>
      <type value="ClinicalDocument"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patientResource"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="languageCode"/>
      <source>
        <context value="src"/>
        <element value="languageCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="language"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="vvv"/>
        <condition value="src.setId.exists().not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
        <element value="setId"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="title"/>
      <source>
        <context value="src"/>
        <element value="title"/>
        <variable value="t"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="title"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="t.dataString"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="patientRole"/>
      <source>
        <context value="src"/>
        <element value="recordTarget"/>
        <variable value="recordTarget"/>
      </source>
      <rule>
        <name value="subject"/>
        <source>
          <context value="recordTarget"/>
          <element value="patientRole"/>
          <variable value="patient"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="subject"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="&#39;urn:uuid:&#39; + %patientResource.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="ClinicalDocumentPatientRole"/>
          <variable value="patient"/>
          <variable value="patientResource"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="encompassingEncounter"/>
      <source>
        <context value="src"/>
        <element value="componentOf"/>
        <variable value="comp"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="encounter"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Encounter"/>
        </parameter>
      </target>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid"/>
        </parameter>
      </target>
      <rule>
        <name value="srcEncounter"/>
        <source>
          <context value="comp"/>
          <element value="encompassingEncounter"/>
          <variable value="srcEnc"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="encounter"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="&#39;urn:uuid:&#39; + %encounter.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="ClinicalDocumentEncounter"/>
          <variable value="srcEnc"/>
          <variable value="bundle"/>
          <variable value="encounter"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="effectiveTime"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="date"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="srcAuthor"/>
      <source>
        <context value="src"/>
        <element value="author"/>
        <variable value="srcAuthor"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="author"/>
        <variable value="reference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="reference"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="&#39;urn:uuid:&#39; + %practitioner.id"/>
        </parameter>
      </target>
      <rule>
        <name value="time"/>
        <source>
          <context value="srcAuthor"/>
          <element value="time"/>
          <variable value="time"/>
        </source>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="extension"/>
          <variable value="exttime"/>
        </target>
        <dependent>
          <name value="ChExtEprTime"/>
          <variable value="time"/>
          <variable value="exttime"/>
        </dependent>
      </rule>
      <rule>
        <name value="author"/>
        <source>
          <context value="srcAuthor"/>
          <element value="assignedAuthor"/>
          <variable value="assignedAuthor"/>
        </source>
        <rule>
          <name value="id"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="id"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="identifier"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="addr"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="addr"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="telecom"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="telecom"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="practitioner"/>
            <contextType value="variable"/>
            <element value="telecom"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="name"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="assignedPerson"/>
            <variable value="person"/>
          </source>
          <rule>
            <name value="name"/>
            <source>
              <context value="person"/>
              <element value="name"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="practitioner"/>
              <contextType value="variable"/>
              <element value="name"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="representedOrganization"/>
          <source>
            <context value="assignedAuthor"/>
            <element value="representedOrganization"/>
            <variable value="srcOrg"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e2"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="organization"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Organization"/>
            </parameter>
          </target>
          <target>
            <context value="organization"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid3"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:uuid:"/>
            </parameter>
            <parameter>
              <valueId value="uuid3"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="author"/>
            <variable value="reference2"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference2"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %organization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentOrganization"/>
            <variable value="srcOrg"/>
            <variable value="organization"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="confidentialityCode"/>
      <source>
        <context value="src"/>
        <element value="confidentialityCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="confidentiality"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="legalAuth"/>
      <source>
        <context value="src"/>
        <element value="legalAuthenticator"/>
        <variable value="legalAuth"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <rule>
        <name value="attester"/>
        <source>
          <context value="legalAuth"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="attester"/>
          <variable value="attester"/>
        </target>
        <rule>
          <name value="mode"/>
          <source>
            <context value="legalAuth"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="mode"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="legal"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="time"/>
          <source>
            <context value="legalAuth"/>
            <element value="time"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="time"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="entity"/>
          <source>
            <context value="legalAuth"/>
            <element value="assignedEntity"/>
            <variable value="entity"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="party"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %practitioner.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentEntityPractitioner"/>
            <variable value="entity"/>
            <variable value="practitioner"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="auth"/>
      <source>
        <context value="src"/>
        <element value="authenticator"/>
        <variable value="auth"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <target>
        <context value="practitioner"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid2"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <rule>
        <name value="attester"/>
        <source>
          <context value="auth"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="attester"/>
          <variable value="attester"/>
        </target>
        <rule>
          <name value="mode"/>
          <source>
            <context value="auth"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="mode"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="official"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="time"/>
          <source>
            <context value="auth"/>
            <element value="time"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="time"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="entity"/>
          <source>
            <context value="auth"/>
            <element value="assignedEntity"/>
            <variable value="entity"/>
          </source>
          <target>
            <context value="attester"/>
            <contextType value="variable"/>
            <element value="party"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %practitioner.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentEntityPractitioner"/>
            <variable value="entity"/>
            <variable value="practitioner"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="cust"/>
      <source>
        <context value="src"/>
        <element value="custodian"/>
        <variable value="custodian"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <rule>
        <name value="custodian"/>
        <source>
          <context value="custodian"/>
          <element value="assignedCustodian"/>
          <variable value="assignedCustodian"/>
        </source>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid3"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid3"/>
          </parameter>
        </target>
        <rule>
          <name value="assignedCustodian"/>
          <source>
            <context value="assignedCustodian"/>
            <element value="representedCustodianOrganization"/>
            <variable value="srcOrg"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="custodian"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %organization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentOrganization"/>
            <variable value="srcOrg"/>
            <variable value="organization"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="documentationOf"/>
      <source>
        <context value="src"/>
        <element value="documentationOf"/>
        <variable value="docOf"/>
      </source>
      <rule>
        <name value="docOf"/>
        <source>
          <context value="docOf"/>
          <element value="serviceEvent"/>
          <variable value="serviceEvent"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="event"/>
          <variable value="event"/>
        </target>
        <rule>
          <name value="eventCode"/>
          <source>
            <context value="serviceEvent"/>
            <element value="code"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="event"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="eventTime"/>
          <source>
            <context value="serviceEvent"/>
            <element value="effectiveTime"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="event"/>
            <contextType value="variable"/>
            <element value="period"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="relatedDoc"/>
      <source>
        <context value="src"/>
        <element value="relatedDocument"/>
        <variable value="relatedDoc"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="relatesTo"/>
        <variable value="relates"/>
      </target>
      <rule>
        <name value="typeCode"/>
        <source>
          <context value="relatedDoc"/>
          <element value="typeCode"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="relates"/>
          <contextType value="variable"/>
          <element value="code"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="parentDoc"/>
        <source>
          <context value="relatedDoc"/>
          <element value="parentDocument"/>
          <variable value="parentDoc"/>
        </source>
        <rule>
          <name value="setId"/>
          <source>
            <context value="parentDoc"/>
            <element value="setId"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="relates"/>
            <contextType value="variable"/>
            <element value="targetIdentifier"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentEntityPractitioner"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="AssignedEntity"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Practitioner"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="addr"/>
      <source>
        <context value="src"/>
        <element value="addr"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="telecom"/>
      <source>
        <context value="src"/>
        <element value="telecom"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="name"/>
      <source>
        <context value="src"/>
        <element value="assignedPerson"/>
        <variable value="person"/>
      </source>
      <rule>
        <name value="name"/>
        <source>
          <context value="person"/>
          <element value="name"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="name"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentOrganization"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="CustodianOrganization"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Organization"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="name"/>
      <source>
        <context value="src"/>
        <element value="name"/>
        <variable value="v"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="name"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="v.other"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="telecom"/>
      <source>
        <context value="src"/>
        <element value="telecom"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="addr"/>
      <source>
        <context value="src"/>
        <element value="addr"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentPatientRole"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="PatientRole"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="identifier"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="identifier"/>
      </target>
      <rule>
        <name value="id"/>
        <source>
          <context value="src"/>
          <element value="id"/>
          <variable value="id"/>
        </source>
        <target>
          <context value="identifier"/>
          <contextType value="variable"/>
          <element value="type"/>
          <variable value="type"/>
        </target>
        <target>
          <context value="type"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="system"/>
          <variable value="system"/>
        </target>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <variable value="code"/>
        </target>
        <rule>
          <name value="system"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="system"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="http://terminology.hl7.org/CodeSystem/v2-0203"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="code"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="MR"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="extension"/>
          <source>
            <context value="id"/>
            <element value="extension"/>
            <variable value="extension"/>
          </source>
          <target>
            <context value="identifier"/>
            <contextType value="variable"/>
            <element value="value"/>
            <variable value="value"/>
          </target>
          <target>
            <context value="value"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="extension"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="root"/>
          <source>
            <context value="id"/>
            <element value="root"/>
            <variable value="root"/>
          </source>
          <target>
            <context value="identifier"/>
            <contextType value="variable"/>
            <element value="system"/>
            <variable value="system"/>
          </target>
          <target>
            <context value="system"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="append"/>
            <parameter>
              <valueString value="urn:oid:"/>
            </parameter>
            <parameter>
              <valueId value="root"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <documentation value="src.id -&gt; tgt.identifier;"/>
    </rule>
    <rule>
      <name value="addr"/>
      <source>
        <context value="src"/>
        <element value="addr"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="address"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="telecom"/>
      <source>
        <context value="src"/>
        <element value="telecom"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="telecom"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="patient"/>
      <source>
        <context value="src"/>
        <element value="patient"/>
        <variable value="patient"/>
      </source>
      <rule>
        <name value="name"/>
        <source>
          <context value="patient"/>
          <element value="name"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="name"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="gender"/>
        <source>
          <context value="patient"/>
          <element value="administrativeGenderCode"/>
          <variable value="gender"/>
        </source>
        <rule>
          <name value="gender"/>
          <source>
            <context value="gender"/>
            <element value="code"/>
            <variable value="v"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="gender"/>
            <transform value="translate"/>
            <parameter>
              <valueId value="v"/>
            </parameter>
            <parameter>
              <valueString value="#cm-v3-administrative-gender"/>
            </parameter>
            <parameter>
              <valueString value="code"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="birthDate"/>
        <source>
          <context value="patient"/>
          <element value="birthTime"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="birthDate"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="deceasedBL"/>
        <source>
          <context value="patient"/>
          <element value="deceasedInd"/>
          <variable value="indicator"/>
          <condition value="patient.deceasedTime.empty()"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="deceased"/>
          <variable value="bool"/>
          <transform value="create"/>
          <parameter>
            <valueString value="boolean"/>
          </parameter>
        </target>
        <dependent>
          <name value="boolean"/>
          <variable value="indicator"/>
          <variable value="bool"/>
        </dependent>
      </rule>
      <rule>
        <name value="deceasedTime"/>
        <source>
          <context value="patient"/>
          <element value="deceasedTime"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="deceased"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="maritalStatus"/>
        <source>
          <context value="patient"/>
          <element value="maritalStatusCode"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="maritalStatus"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="language"/>
        <source>
          <context value="patient"/>
          <element value="languageCommunication"/>
          <variable value="language"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="communication"/>
          <variable value="communication"/>
        </target>
        <rule>
          <name value="communication"/>
          <source>
            <context value="language"/>
            <element value="languageCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="communication"/>
            <contextType value="variable"/>
            <element value="language"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="organization"/>
      <source>
        <context value="src"/>
        <element value="providerOrganization"/>
        <variable value="org"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="organization"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Organization"/>
        </parameter>
      </target>
      <target>
        <context value="organization"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="urn:uuid:"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <rule>
        <name value="reference"/>
        <source>
          <context value="org"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="managingOrganization"/>
          <variable value="reference"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="reference"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="&#39;urn:uuid:&#39; + %organization.id"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="id"/>
        <source>
          <context value="org"/>
          <element value="id"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="identifier"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="name"/>
        <source>
          <context value="org"/>
          <element value="name"/>
          <variable value="v"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="name"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="v.other"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="telecom"/>
        <source>
          <context value="org"/>
          <element value="telecom"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="telecom"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="addr"/>
        <source>
          <context value="org"/>
          <element value="addr"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="address"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentEncounter"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="EncompassingEncounter"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="effectiveTime"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="period"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="hospitalization"/>
      <source>
        <context value="src"/>
        <condition
                   value="admissionReferralSourceCode.exists() or dischargeDispositionCode.exists()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="hospitalization"/>
        <variable value="hosp"/>
      </target>
      <rule>
        <name value="adminReferral"/>
        <source>
          <context value="src"/>
          <element value="admissionReferralSourceCode"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="hosp"/>
          <contextType value="variable"/>
          <element value="admitSource"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="discDisposition"/>
        <source>
          <context value="src"/>
          <element value="dischargeDispositionCode"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="hosp"/>
          <contextType value="variable"/>
          <element value="dischargeDisposition"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="participant"/>
      <source>
        <context value="src"/>
        <element value="encounterParticipant"/>
        <variable value="srcPart"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="participant"/>
        <variable value="tgtPart"/>
      </target>
      <rule>
        <name value="typeCode"/>
        <source>
          <context value="srcPart"/>
          <element value="typeCode"/>
          <variable value="code"/>
        </source>
        <target>
          <context value="tgtPart"/>
          <contextType value="variable"/>
          <element value="type"/>
          <transform value="cc"/>
          <parameter>
            <valueString
                         value="http://terminology.hl7.org/CodeSystem/v3-ParticipationType"/>
          </parameter>
          <parameter>
            <valueId value="code"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="time"/>
        <source>
          <context value="srcPart"/>
          <element value="time"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgtPart"/>
          <contextType value="variable"/>
          <element value="period"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="entity"/>
        <source>
          <context value="srcPart"/>
          <element value="assignedEntity"/>
          <variable value="entity"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitioner"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Practitioner"/>
          </parameter>
        </target>
        <target>
          <context value="practitioner"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid2"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid2"/>
          </parameter>
        </target>
        <rule>
          <name value="entry"/>
          <source>
            <context value="entity"/>
          </source>
          <target>
            <context value="tgtPart"/>
            <contextType value="variable"/>
            <element value="individual"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %practitioner.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentEntityPractitioner"/>
            <variable value="entity"/>
            <variable value="practitioner"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="location"/>
      <source>
        <context value="src"/>
        <element value="location"/>
        <variable value="srcLocation"/>
      </source>
      <rule>
        <name value="facility"/>
        <source>
          <context value="srcLocation"/>
          <element value="healthCareFacility"/>
          <variable value="facility"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="location"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Location"/>
          </parameter>
        </target>
        <target>
          <context value="location"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid2"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid2"/>
          </parameter>
        </target>
        <rule>
          <name value="facLocation"/>
          <source>
            <context value="facility"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="location"/>
            <variable value="tgtLocation"/>
          </target>
          <target>
            <context value="tgtLocation"/>
            <contextType value="variable"/>
            <element value="location"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %location.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentLocation"/>
            <variable value="facility"/>
            <variable value="bundle"/>
            <variable value="location"/>
          </dependent>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentLocation"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="HealthCareFacility"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Location"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="location"/>
      <source>
        <context value="src"/>
        <element value="location"/>
        <variable value="location"/>
      </source>
      <rule>
        <name value="addr"/>
        <source>
          <context value="location"/>
          <element value="addr"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="address"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
        <documentation
                       value="place names are usually stored with no parts    location.name as srcName -&gt; tgt.name = cast(srcName, &#39;string&#39;);"/>
      </rule>
      <rule>
        <name value="org"/>
        <source>
          <context value="location"/>
          <element value="serviceProviderOrganization"/>
          <variable value="srcOrg"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="organization"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Organization"/>
          </parameter>
        </target>
        <target>
          <context value="organization"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid3"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="urn:uuid:"/>
          </parameter>
          <parameter>
            <valueId value="uuid3"/>
          </parameter>
        </target>
        <rule>
          <name value="organization"/>
          <source>
            <context value="srcOrg"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="managingOrganization"/>
            <variable value="reference"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Reference"/>
            </parameter>
          </target>
          <target>
            <context value="reference"/>
            <contextType value="variable"/>
            <element value="reference"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="&#39;urn:uuid:&#39; + %organization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ClinicalDocumentOrganization"/>
            <variable value="srcOrg"/>
            <variable value="organization"/>
          </dependent>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ChExtEprTime"/>
    <typeMode value="none"/>
    <documentation
                   value="source dataEnterer: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.2.7 source author: https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.840.1.113883.10.12.102 target: https://build.fhir.org/ig/hl7ch/ch-core//StructureDefinition-ch-ext-epr-time.html"/>
    <input>
      <name value="src"/>
      <type value="TSDateTime"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-time"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="src"/>
        <variable value="value"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="ChExtEprSectionId"/>
    <typeMode value="none"/>
    <documentation
                   value="https://art-decor.org/art-decor/decor-templates--hl7chcda-?id=2.16.756.5.30.1.1.10.3.45 target: http://build.fhir.org/ig/hl7ch/ch-core/branches/master/StructureDefinition-ch-ext-epr-sectionid.html"/>
    <input>
      <name value="src"/>
      <type value="II"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://fhir.ch/ig/ch-core/StructureDefinition/ch-ext-epr-sectionid"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Identifier"/>
        </parameter>
      </target>
      <dependent>
        <name value="II"/>
        <variable value="src"/>
        <variable value="value"/>
      </dependent>
    </rule>
  </group>
  <group>
    <name value="NarrativeLink"/>
    <typeMode value="none"/>
    <documentation
                   value="_________________________ Template Type not specified  ___________________"/>
    <input>
      <name value="url"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="ext"/>
      <type value="Extension"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="url"/>
      <source>
        <context value="url"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString
                       value="http://hl7.org/fhir/StructureDefinition/narrativeLink"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value"/>
      <source>
        <context value="url"/>
      </source>
      <target>
        <context value="ext"/>
        <contextType value="variable"/>
        <element value="value"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="url"/>
        </parameter>
      </target>
      <target>
        <context value="value"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="copy"/>
        <parameter>
          <valueId value="url"/>
        </parameter>
      </target>
    </rule>
  </group>
</StructureMap>