CDA to FHIR Maps
0.1.0 - ci-build IT

CDA to FHIR Maps - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

: CDA to FHIR - PSS - XML Representation

Draft as of 2024-04-11

Raw xml | Download



<StructureMap xmlns="http://hl7.org/fhir">
  <id value="cda2fhirPs"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
         <pre>map &quot;http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirPs&quot; = &quot;cda2fhirPs&quot;

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/AssociatedEntity&quot; alias AssociatedEntity as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization&quot; alias CustodianOrganization as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/OrganizationPartOf&quot; alias OrganizationPartOf as queried
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/Organization&quot; alias rapresentedOrganization 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/cda/StructureDefinition/AD&quot; alias AD as source
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/Encounter&quot; alias Encounter as produced
uses &quot;http://hl7.org/fhir/StructureDefinition/Person&quot; alias Patient as produced
uses &quot;http://hl7.org/fhir/StructureDefinition/List&quot; alias List 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
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/Act&quot; alias Act as produced
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/IVL-PQ&quot; alias IVL_PQ as source
uses &quot;http://hl7.org/fhir/cda/StructureDefinition/PQ&quot; alias PQ as source
uses &quot;http://hl7.org/fhir/StructureDefinition/SimpleQuantity&quot; alias SimpleQuantity as target

imports &quot;http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirDataTypes&quot;
imports &quot;http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirHeader&quot;

group CdaToBundle(source cda : ClinicalDocument, target bundle : Bundle) {
  cda -&gt;  bundle.entry as e,  e.request = create('BackboneElement') as request,  request.method = 'POST',  e.resource = create('Composition') as composition,  composition.id = uuid() as uuid1,  e.fullUrl = append('https://example/Composition/', uuid1),  request.url = 'Composition',  bundle.entry as e2,  e2.request = create('BackboneElement') as requestPAT,  requestPAT.method = 'PUT',  e2.resource = create('Patient') as patient,  patient.id = uuid() as uuid2,  e2.fullUrl = append('https://example/Patient/', uuid2),  bundle.entry as e3,  e3.request = create('BackboneElement') as request,  request.method = 'POST',  e3.resource = create('Encounter') as encounter,  encounter.id = uuid() as uuid3,  e3.fullUrl = append('https://example/Encounter/', uuid3),  request.url = 'Encounter',  bundle.entry as e4,  e4.request = create('BackboneElement') as request,  request.method = 'POST',  e4.resource = create('DocumentReference') as DocumentReference,  DocumentReference.id = uuid() as uuid4,  e4.fullUrl = append('https://example/DocumentReference/', uuid4),  request.url = 'DocumentReference' then {
    cda then ClinicalDocumentToBundle(cda, patient, composition, encounter, bundle, DocumentReference) &quot;cdatobundle&quot;;
    cda.recordTarget as recordTarget then {
      recordTarget.patientRole as patient then {
        patient.id as id -&gt; patient.identifier as identifier then {
          id.root as r -&gt; identifier.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
          id.extension as ext1 -&gt; identifier.value = ext1 &quot;value&quot;;
          id.assigningAuthorityName as s -&gt;  identifier.assigner as a,  a.display = s;
        } &quot;idfr&quot;;
        patient.id as id where (root = '2.16.840.1.113883.2.9.4.3.2') or (root = '2.16.840.1.113883.2.9.4.3.7') or (root = '2.16.840.1.113883.2.9.4.3.3') or (root = '2.16.840.1.113883.2.9.4.3.17') or (root = '2.16.840.1.113883.2.9.4.3.18') or (root = '2.16.840.1.113883.2.9.2.10.4.1.1') or (root = '2.16.840.1.113883.2.9.2.20.4.1.1') or (root = '2.16.840.1.113883.2.9.2.30.4.1.1') or (root = '2.16.840.1.113883.2.9.2.41.4.1.1') or (root = '2.16.840.1.113883.2.9.2.42.4.1.1') or (root = '2.16.840.1.113883.2.9.2.50.4.1.1') or (root = '2.16.840.1.113883.2.9.2.60.4.1.1') or (root = '2.16.840.1.113883.2.9.2.70.4.1.1') or (root = '2.16.840.1.113883.2.9.2.80.4.1.1') or (root = '2.16.840.1.113883.2.9.2.90.4.1.1') or (root = '2.16.840.1.113883.2.9.2.100.4.1.1') or (root = '2.16.840.1.113883.2.9.2.110.4.1.1') or (root = '2.16.840.1.113883.2.9.2.120.4.1.1') or (root = '2.16.840.1.113883.2.9.2.130.4.1.1') or (root = '2.16.840.1.113883.2.9.2.140.4.1.1') or (root = '2.16.840.1.113883.2.9.2.150.4.1.1') or (root = '2.16.840.1.113883.2.9.2.160.4.1.1') or (root = '2.16.840.1.113883.2.9.2.170.4.1.1') or (root = '2.16.840.1.113883.2.9.2.180.4.1.1') or (root = '2.16.840.1.113883.2.9.2.190.4.1.1') or (root = '2.16.840.1.113883.2.9.2.200.4.1.1') or (root = '2.16.840.1.113883.2.9.2.10.4.1') or (root = '2.16.840.1.113883.2.9.2.20.4.1') or (root = '2.16.840.1.113883.2.9.2.30.4.1') or (root = '2.16.840.1.113883.2.9.2.41.4.1') or (root = '2.16.840.1.113883.2.9.2.42.4.1') or (root = '2.16.840.1.113883.2.9.2.50.4.1') or (root = '2.16.840.1.113883.2.9.2.60.4.1') or (root = '2.16.840.1.113883.2.9.2.70.4.1') or (root = '2.16.840.1.113883.2.9.2.80.4.1') or (root = '2.16.840.1.113883.2.9.2.90.4.1') or (root = '2.16.840.1.113883.2.9.2.100.4.1') or (root = '2.16.840.1.113883.2.9.2.110.4.1') or (root = '2.16.840.1.113883.2.9.2.120.4.1') or (root = '2.16.840.1.113883.2.9.2.130.4.1') or (root = '2.16.840.1.113883.2.9.2.140.4.1') or (root = '2.16.840.1.113883.2.9.2.150.4.1') or (root = '2.16.840.1.113883.2.9.2.160.4.1') or (root = '2.16.840.1.113883.2.9.2.170.4.1') or (root = '2.16.840.1.113883.2.9.2.180.4.1') or (root = '2.16.840.1.113883.2.9.2.190.4.1') or (root = '2.16.840.1.113883.2.9.2.200.4.1') or (root = '2.16.840.1.113883.2.9.4.3.15') then {
          id.extension as ext -&gt; requestPAT.url = append('Patient?identifier=', ext) &quot;UUID&quot;;
        } &quot;ext&quot;;
      } &quot;recPat&quot;;
    } &quot;patient&quot;;
  } &quot;ClinicalDocumentToBody&quot;;
}

group ClinicalDocumentToBundle(source cda : ClinicalDocument, target patient : Patient, target composition : Composition, target encounter : Encounter, target bundle : Bundle, target DocumentReference : DocumentReference) {
  cda -&gt; encounter.status = 'finished' &quot;finished&quot;;
  cda -&gt; encounter.class = create('Coding') as coding then {
    cda -&gt; coding.code = 'summary' &quot;code&quot;;
  } &quot;coding&quot;;
  cda -&gt; bundle.id = uuid() &quot;id&quot;;
  cda.id -&gt; bundle.identifier &quot;identifier&quot;;
  cda -&gt; bundle.type = 'transaction' &quot;type&quot;;
  // cda.effectiveTime -&gt; bundle.timestamp;
  cda -&gt; bundle.timestamp = (timestamp.now()) &quot;date&quot;;
  cda then ClinicalDocumentComposition(cda, composition, patient, encounter, bundle, DocumentReference) &quot;composition&quot;;
  cda.component as component then {
    component.structuredBody as body then {
      body.component as component then {
        component.section as srcSection then {
          srcSection.code -&gt; composition.section as tgtSection then ClinicalDocumentSection(cda, srcSection, patient, tgtSection, bundle, encounter, composition);
        };
      };
    } &quot;body&quot;;
  } &quot;diagnostic&quot;;
}

group ClinicalDocumentSection(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter, target composition : Composition) {
  src.title as t -&gt; tgt.title = (t.dataString);
  src.code -&gt; tgt.code;
  src.entry as entry then {
    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;;
    // sezioni che sono strutturate
    src.code where (code = '30954-2') then {
      entry.organizer as organizer -&gt;  bundle.entry as e0,  e0.request = create('BackboneElement') as request,  request.method = 'POST',  e0.resource = create('DiagnosticReport') as dia,  dia.id = uuid() as uuid0,  e0.fullUrl = append('https://example/DiagnosticReport/', uuid0),  request.url = 'DiagnosticReport',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/DiagnosticReport/' + %dia.id) then DiagnosticReportFunction(organizer, patient, enc, dia, bundle) &quot;diagnostic&quot;;
    } &quot;entryObs&quot;;
    src.code where (code = '29762-2') or (code = '10162-6') then {
      entry.observation as observation -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Observation') as obs1,  obs1.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Observation/', uuid1),  request.url = 'Observation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obs1.id) then Observation(observation, patient, enc, obs1, bundle) &quot;obs1&quot;;
    } &quot;entryObs&quot;;
    src.code where (code = '8716-3') or (code = '47420-5') then {
      entry.organizer as organizer -&gt;  bundle.entry as e2,  e2.request = create('BackboneElement') as request,  request.method = 'POST',  e2.resource = create('Observation') as obs2,  obs2.id = uuid() as uuid2,  e2.fullUrl = append('https://example/Observation/', uuid2),  request.url = 'Observation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obs2.id) then ObservationOrganizer(src, organizer, patient, enc, obs2, bundle) &quot;obs2&quot;;
      entry.observation as organizer -&gt;  bundle.entry as e2,  e2.request = create('BackboneElement') as request,  request.method = 'POST',  e2.resource = create('Observation') as obs2,  obs2.id = uuid() as uuid2,  e2.fullUrl = append('https://example/Observation/', uuid2),  request.url = 'Observation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obs2.id) then ObservationOrganizer(src, organizer, patient, enc, obs2, bundle) &quot;obs2&quot;;
    } &quot;organizer&quot;;
    src.code where code = '11450-4' then {
      entry.act as act -&gt;  bundle.entry as e3,  e3.request = create('BackboneElement') as request,  request.method = 'POST',  e3.resource = create('Condition') as condition,  condition.id = uuid() as uuid3,  e3.fullUrl = append('https://example/Condition/', uuid3),  request.url = 'Condition',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Condition/' + %condition.id) then ConditionFunction(act, condition, patient, enc, bundle) &quot;condition&quot;;
    } &quot;listaDeiProblemi&quot;;
    src.code where (code = '48765-2') then {
      entry.act as act -&gt;  bundle.entry as e5,  e5.request = create('BackboneElement') as request,  request.method = 'POST',  e5.resource = create('AllergyIntolerance') as allergy,  allergy.id = uuid() as uuid5,  e5.fullUrl = append('https://example/AllergyIntolerance/', uuid5),  request.url = 'AllergyIntolerance',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/AllergyIntolerance/' + %allergy.id) then allergyFunction(act, allergy, patient, enc) &quot;allergy&quot;;
    } &quot;entryAct&quot;;
    src.code where code = '10160-0' then {
      entry.substanceAdministration as subAdmin -&gt;  bundle.entry as e6,  e6.request = create('BackboneElement') as request,  request.method = 'POST',  e6.resource = create('MedicationStatement') as medicationstatement,  medicationstatement.id = uuid() as uuid6,  e6.fullUrl = append('https://example/MedicationStatement/', uuid6),  request.url = 'MedicationStatement',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/MedicationStatement/' + %medicationstatement.id) then MedicationStatement(subAdmin, medicationstatement, patient, enc, bundle) &quot;TerapiaFarmacologica&quot;;
    } &quot;terapia&quot;;
    src.code where code = '11369-6' then {
      entry.substanceAdministration as subVACC -&gt;  bundle.entry as e7,  e7.request = create('BackboneElement') as request,  request.method = 'POST',  e7.resource = create('Immunization') as immunization,  immunization.id = uuid() as uuid7,  e7.fullUrl = append('https://example/Immunization/', uuid7),  request.url = 'Immunization',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Immunization/' + %immunization.id) then Immunization(subVACC, patient, enc, immunization, bundle) &quot;immunization&quot;;
    } &quot;vacc&quot;;
    src.code where code = '10157-6' then {
      entry.organizer as organizer -&gt;  bundle.entry as e12,  e12.request = create('BackboneElement') as request,  request.method = 'POST',  e12.resource = create('FamilyMemberHistory') as familyMember,  familyMember.id = uuid() as uuid12,  e12.fullUrl = append('https://example/FamilyMemberHistory/', uuid12),  request.url = 'FamilyMemberHistory',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/FamilyMemberHistory/' + %familyMember.id) then FamilyMemberFunction(organizer, familyMember, patient) &quot;family&quot;;
    } &quot;family&quot;;
    src.code where code = '46264-8' then {
      entry.supply as supply -&gt;  bundle.entry as e8,  e8.request = create('BackboneElement') as request,  request.method = 'POST',  e8.resource = create('Procedure') as procedure,  procedure.id = uuid() as uuid8,  e8.fullUrl = append('https://example/Procedure/', uuid8),  request.url = 'Procedure',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Procedure/' + %procedure.id) then Procedure(supply, patient, enc, procedure, bundle) &quot;protesi&quot;;
    } &quot;impianti&quot;;
    src.code where code = '47519-4' then {
      entry.procedure as procedure -&gt;  bundle.entry as e9,  e9.request = create('BackboneElement') as request,  request.method = 'POST',  e9.resource = create('Procedure') as procedure2,  procedure2.id = uuid() as uuid9,  e9.fullUrl = append('https://example/Procedure/', uuid9),  request.url = 'Procedure',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Procedure/' + %procedure2.id) then Procedure(procedure, patient, enc, procedure2, bundle) &quot;tratt&quot;;
    } &quot;trattamentiProcedure&quot;;
    src.code where code = '46240-8' then {
      // entry.encounter as encounter -&gt; enc then{
      entry.encounter as encounter -&gt;  bundle.entry as e9,  e9.request = create('BackboneElement') as request,  request.method = 'POST',  e9.resource = create('Encounter') as encounterF,  encounterF.id = uuid() as uuid9,  e9.fullUrl = append('https://example/Encounter/', uuid9),  request.url = 'Encounter',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounterF.id) then EncounterFunction(encounter, patient, enc, encounterF, bundle);
    } &quot;visiteRicoveri&quot;;
    src.code where code = '57827-8' then {
      entry.act as act -&gt;  bundle.entry as e13,  e13.request = create('BackboneElement') as request,  request.method = 'POST',  e13.resource = create('Coverage') as coverage,  coverage.id = uuid() as uuid13,  e13.fullUrl = append('https://example/Coverage/', uuid13),  request.url = 'Coverage',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Coverage/' + %coverage.id) then Coverage(act, patient, enc, coverage, bundle) &quot;esen&quot;;
    } &quot;esenzioni&quot;;
    src.code where code = 'PSSIT99' then {
      entry.act as act -&gt;  bundle.entry as e14,  e14.request = create('BackboneElement') as request,  request.method = 'POST',  e14.resource = create('OrganizationAffiliation') as affiliation,  affiliation.id = uuid() as uuid14,  e14.fullUrl = append('https://example/OrganizationAffiliation/', uuid14),  request.url = 'OrganizationAffiliation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/OrganizationAffiliation/' + %affiliation.id) then OrganizationAffiliation(act, patient, enc, affiliation, bundle) &quot;OrgAffiliation&quot;;
    } &quot;retiPatologia&quot;;
  };
  src where src.entry.exists() then {
    src.code where code = '18776-5' then {
      src -&gt;  bundle.entry as e11,  e11.request = create('BackboneElement') as request,  request.method = 'POST',  e11.resource = create('CarePlan') as careplan,  careplan.id = uuid() as uuid11,  e11.fullUrl = append('https://example/CarePlan/', uuid11),  request.url = 'CarePlan',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/CarePlan/' + %careplan.id) then {
        src.entry as entry then CarePlanFunction(entry, careplan, patient, enc, bundle) &quot;prestazioni&quot;;
      } &quot;pianiCura&quot;;
    } &quot;raccoglitore&quot;;
  } &quot;esiste&quot;;
  src where src.entry.exists().not() then {
    // Anmanesi Familiare narrativa
    src.code where code = '10157-6' then {
      src.text as text -&gt;  bundle.entry as e12,  e12.request = create('BackboneElement') as request,  request.method = 'POST',  e12.resource = create('FamilyMemberHistory') as familyMember,  familyMember.id = uuid() as uuid12,  e12.fullUrl = append('https://example/FamilyMemberHistory/', uuid12),  request.url = 'FamilyMemberHistory',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/FamilyMemberHistory/' + %familyMember.id) then {
        src -&gt;  familyMember.patient = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
        src -&gt; familyMember.status = 'health-unknown' &quot;statusS&quot;;
        text -&gt; familyMember.note as note then {
          text as t -&gt; note.text = t &quot;reference&quot;;
        } &quot;reference&quot;;
        text -&gt; familyMember.relationship = create('CodeableConcept') as relation then {
          text as txt -&gt; relation.text = txt &quot;text&quot;;
        } &quot;medication&quot;;
      } &quot;family&quot;;
    } &quot;familyraccoglitore&quot;;
    // Piano di cura narrativa
    src.code where code = '18776-5' then {
      src.text as text -&gt;  bundle.entry as e11,  e11.request = create('BackboneElement') as request,  request.method = 'POST',  e11.resource = create('CarePlan') as careplan,  careplan.id = uuid() as uuid11,  e11.fullUrl = append('https://example/CarePlan/', uuid11),  request.url = 'CarePlan',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/CarePlan/' + %careplan.id) then {
        src -&gt;  careplan.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
        // src-&gt; careplan.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;
        src -&gt; careplan.status = 'active' &quot;status&quot;;
        src -&gt; careplan.intent = 'order' &quot;intent&quot;;
        text -&gt; careplan.note as note then {
          text as t -&gt; note.text = t &quot;reference&quot;;
        } &quot;reference&quot;;
      } &quot;pianiCura&quot;;
    } &quot;raccoglitore&quot;;
    // sezioni che sono narrative
    src.code where (code = '30954-2') or (code = '29762-2') or (code = '8716-3') or (code = '47420-5') or (code = '42348-3') then {
      src.text as text -&gt;  bundle.entry as e13,  e13.request = create('BackboneElement') as request,  request.method = 'POST',  e13.resource = create('Observation') as obs1,  obs1.id = uuid() as uuid13,  e13.fullUrl = append('https://example/Observation/', uuid13),  request.url = 'Observation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obs1.id) then {
        src -&gt;  obs1.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
        // src -&gt; obs1.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;
        src -&gt; obs1.status = 'preliminary' &quot;obsst&quot;;
        src.code -&gt; obs1.code &quot;obscde&quot;;
        src -&gt; obs1.status = 'final' &quot;statusS&quot;;
        text -&gt; obs1.note as note then {
          text as t -&gt; note.text = create('string') as textNote then EDstring(t, textNote) &quot;note&quot;;
        } &quot;narrative&quot;;
      } &quot;txtsec&quot;;
    } &quot;narrative&quot;;
  } &quot;code&quot;;
  src.component as component then {
    component.section as sec -&gt; tgt.section as tgtSection then ClinicalDocumentSection(cda, sec, patient, tgtSection, bundle, enc, dReport);
  };
}

group Procedure(source src : cdaElement, target patient : Patient, target encounter : Encounter, target tgt : Procedure, target bundle : Bundle) {
  // toASK
  src.text as tx -&gt; tgt.note as note then {
    tx.reference as reff -&gt; note.text = (reff.value) &quot;r&quot;;
  } &quot;tx&quot;;
  src.templateId where root = '2.16.840.1.113883.2.9.10.1.4.3.10.3' then {
    src.effectiveTime as effectiveTime -&gt; tgt.performed = (effectiveTime.value);
    src.code -&gt; tgt.code;
  } &quot;ref&quot;;
  src -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  src.statusCode as s then {
    s.code as cos -&gt; tgt.status = translate(cos, '#EventStatus', 'code') &quot;codeS&quot;;
  } &quot;status&quot;;
  src where statusCode.exists().not() -&gt; tgt.status = 'unknown' &quot;status2&quot;;
  src.templateId where root = '2.16.840.1.113883.2.9.10.1.4.3.9.1' then {
    src -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Device') as deviceRes,  deviceRes.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Device/', uuid1),  request.url = 'Device',  tgt.usedReference = create('Reference') as reference,  reference.reference = ('https://example/Device/' + %deviceRes.id) then {
      src -&gt;  deviceRes.patient = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
      src.code -&gt; deviceRes.type;
    } &quot;device&quot;;
    src.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.performed = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
    src.effectiveTime as effectiveTime where (low.exists()) -&gt; tgt.performed = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
  } &quot;presenzaProtesiImpianto&quot;;
  src.templateId where root = '2.16.840.1.113883.2.9.10.1.4.3.9.2' then {
    src.code as code -&gt; tgt.note as note then {
      code.displayName as displayName -&gt; note.text = (displayName) &quot;text&quot;;
    } &quot;note&quot;;
  } &quot;assenza&quot;;
  src.templateId where root = '2.16.840.1.113883.2.9.10.1.4.3.11.1' then {
    src.id -&gt; tgt.identifier;
    src.code -&gt; tgt.code;
    src.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.performed = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
    src.effectiveTime as effectiveTime where (low.exists()) -&gt; tgt.performed = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
    src.entryRelationship as entryR then {
      entryR.observation as observation -&gt;  bundle.entry as e3,  e3.request = create('BackboneElement') as request,  request.method = 'POST',  e3.resource = create('Observation') as obs1,  obs1.id = uuid() as uuid3,  e3.fullUrl = append('https://example/Observation/', uuid3),  request.url = 'Observation',  tgt.reasonReference = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obs1.id) then Observation(observation, patient, encounter, obs1, bundle);
    } &quot;entryRelProcedure&quot;;
  } &quot;procedureTrattamenti&quot;;
}

group Observation(source cda, target patient : Patient, target encounter : Encounter, target ob : Observation, target bundle : Bundle) {
  cda -&gt;  ob.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // cda-&gt; ob.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  cda.id -&gt; ob.identifier;
  cda.code -&gt; ob.code;
  cda -&gt; ob.status = 'final' &quot;Stats&quot;;
  // value datatype
  cda.value : ST as st -&gt;  ob.value = create('string'),  ob.value = (st.dataString);
  cda.value : BL as boolean -&gt; ob.value = (boolean.value) &quot;boolean&quot;;
  cda.value : INT as int -&gt; ob.value = (int.value) &quot;intval&quot;;
  cda.value : CE as val then {
    val -&gt; ob.value = create('CodeableConcept') as ce then {
      val.originalText as originalText then {
        originalText.reference as reference -&gt; ce.text = (reference.value);
      };
      val -&gt; ce.coding as coding then {
        val.code as code -&gt; coding.code = cast(code, 'string');
        val.codeSystem as system -&gt; coding.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
        val.displayName as display -&gt; coding.display = cast(display, 'string');
      } &quot;code&quot;;
      val.translation as translation -&gt; ce.coding as coding then {
        translation.code as code -&gt; coding.code = cast(code, 'string');
        translation.codeSystem as system -&gt; coding.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
        translation.displayName as display -&gt; coding.display = cast(display, 'string');
        translation.qualifier as qualifier then {
          qualifier.value as value -&gt; ce.coding as coding then {
            value.code as code -&gt; coding.code = cast(code, 'string');
            value.codeSystem as system -&gt; coding.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
            value.displayName as display -&gt; coding.display = cast(display, 'string');
          };
        };
      };
    } &quot;coding&quot;;
  } &quot;val&quot;;
  cda.value : CD as val then {
    val -&gt; ob.value = create('CodeableConcept') as ce then {
      val.originalText as originalText then {
        originalText.reference as reference -&gt; ce.text = (reference.value);
      };
      val -&gt; ce.coding as coding then {
        val.code as code -&gt; coding.code = cast(code, 'string');
        val.codeSystem as system -&gt; coding.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
        val.displayName as display -&gt; coding.display = cast(display, 'string');
      } &quot;code&quot;;
      val.translation as translation -&gt; ce.coding as coding then {
        translation.code as code -&gt; coding.code = cast(code, 'string');
        translation.codeSystem as system -&gt; coding.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
        translation.displayName as display -&gt; coding.display = cast(display, 'string');
        translation.qualifier as qualifier then {
          qualifier.value as value -&gt; ce.coding as coding then {
            value.code as code -&gt; coding.code = cast(code, 'string');
            value.codeSystem as system -&gt; coding.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
            value.displayName as display -&gt; coding.display = cast(display, 'string');
          };
        };
      };
    } &quot;coding&quot;;
  } &quot;val&quot;;
  cda.value : PQ as val then {
    val -&gt; ob.value = create('Quantity') as quantity then {
      val.value as value -&gt; quantity.value = value;
      val.unit as unit -&gt; quantity.unit = unit;
    } &quot;quantity&quot;;
  } &quot;valueQuantity&quot;;
  cda.effectiveTime as effectiveTime where (value.exists()) -&gt; ob.effective = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
  cda.effectiveTime as effectiveTime where (low.exists()) -&gt; ob.effective = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
  cda.text as text -&gt; ob.note as note then {
    text.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
  } &quot;note&quot;;
  cda.statusCode as s then {
    s.code as cos -&gt; ob.status = translate(cos, '#OBSstatus', 'code') &quot;codeS&quot;;
  } &quot;status&quot;;
  // toASK è giusto siano invertiti?
  cda.methodCode -&gt; ob.method;
  cda.interpretationCode -&gt; ob.interpretation;
  cda.targetSiteCode -&gt; ob.bodySite;
  // added
  cda.referenceRange as refrange then {
    refrange.observationRange as obsrange then {
      obsrange.value as val -&gt; ob.referenceRange = create('BackboneElement') as refrangeFH then {
        val -&gt; refrangeFH.low = create('SimpleQuantity') as lowfhir then {
          val.low as l -&gt; lowfhir.value = (l.value) &quot;val&quot;;
          val.low as l -&gt; lowfhir.unit = (l.unit) &quot;val&quot;;
        } &quot;de&quot;;
        val -&gt; refrangeFH.high = create('SimpleQuantity') as highfhir then {
          val.high as h -&gt; highfhir.value = (h.value) &quot;val&quot;;
          val.high as h -&gt; highfhir.unit = (h.unit) &quot;val&quot;;
        } &quot;de&quot;;
      } &quot;refFhir&quot;;
    } &quot;obsrange&quot;;
  } &quot;regrange&quot;;
}

group ObservationOrganizer(source section : section, source cda : organizer, target patient : Patient, target encounter : Encounter, target ob : Observation, target bundle : Bundle) {
  cda -&gt;  ob.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // cda-&gt; ob.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  cda.id -&gt; ob.identifier;
  section.code -&gt; ob.code;
  cda -&gt; ob.status = 'final' &quot;Stats&quot;;
  cda.effectiveTime as effectiveTime where (value.exists()) -&gt; ob.effective = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
  cda.effectiveTime as effectiveTime where (low.exists()) -&gt; ob.effective = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
  cda.text as text -&gt; ob.note as note then {
    text.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
  } &quot;note&quot;;
  cda.statusCode as s then {
    s.code as cos -&gt; ob.status = translate(cos, '#OBSstatus', 'code') &quot;codeS&quot;;
  } &quot;status&quot;;
  cda.component as component then {
    component.observation as observation -&gt;  bundle.entry as ei,  ei.request = create('BackboneElement') as request,  request.method = 'POST',  ei.resource = create('Observation') as obsi,  obsi.id = uuid() as uuidi,  ei.fullUrl = append('https://example/Observation/', uuidi),  request.url = 'Observation',  ob.hasMember = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obsi.id) then Observation(observation, patient, encounter, obsi, bundle) &quot;hasMember&quot;;
  };
}

group Coverage(source src : act, target patient : Patient, target encounter : Encounter, target tgt : Coverage, target bundle : Bundle) {
  src -&gt;  tgt.beneficiary = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  src -&gt;  tgt.payor = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  src.id as id -&gt; tgt.identifier as idf then {
    id -&gt; idf.value = (id.root) &quot;ID&quot;;
  };
  src.code -&gt; tgt.type;
  src.statusCode as statusCode then {
    statusCode.code as s -&gt; tgt.status = translate(s, '#FinancialStatus', 'code') &quot;status&quot;;
  } &quot;sc&quot;;
  src where statusCode.exists().not() -&gt; tgt.status = 'active' &quot;statusAbsent&quot;;
  // src.effectiveTime as effectiveTime -&gt; tgt.period as period then{
  src.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.period = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
  src.effectiveTime as effectiveTime where (low.exists()) -&gt; tgt.period = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
  src.entryRelationship as entryRelationship then {
    entryRelationship.act as ac -&gt; tgt.class as class then {
      ac.text as text -&gt; class.type as type then {
        text.reference as reference -&gt; type.text = (reference.value) &quot;value&quot;;
      } &quot;ref&quot;;
      ac -&gt; class.value = 'commenti' &quot;note&quot;;
    } &quot;QUI&quot;;
  } &quot;entryr&quot;;
}

group allergyFunction(source src : cdaElement, target tgt : AllergyIntolerance, target patient : Patient, target encounter : Encounter) {
  src -&gt;  tgt.patient = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  src.effectiveTime as effTime then {
    effTime.low as l -&gt; tgt.recordedDate as r then TSDateTime(l, r) &quot;value&quot;;
  } &quot;efftime&quot;;
  src.entryRelationship as entryRelationship1 then {
    entryRelationship1.observation as observation1 then {
      observation1.id -&gt; tgt.identifier;
      observation1.templateId where root = '2.16.840.1.113883.2.9.10.1.4.3.1.4' -&gt; tgt.code as code then {
        observation1 -&gt; code.coding as coding then {
          observation1 -&gt; coding.code = 'No known allergy' &quot;code&quot;;
        } &quot;code&quot;;
        src.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.onset = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
        src.effectiveTime as effectiveTime -&gt; tgt.onset = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
      } &quot;Noallergy&quot;;
      observation1.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.onset = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
      observation1.effectiveTime as effectiveTime -&gt; tgt.onset = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
      observation1.value as code then {
        code.code as code1 -&gt; tgt.type = translate(code1, '#AllergyTypeMap', 'code') &quot;type&quot;;
        code.code as code1 -&gt; tgt.category = translate(code1, '#AllergyCategoryMap', 'code') &quot;category&quot;;
      } &quot;code&quot;;
      // toASK qui dovrei fare un controllo sul code
      observation1.value -&gt; tgt.code;
      observation1.participant as participant -&gt; tgt.reaction as reaction then {
        observation1.entryRelationship as entryRelationship2 where (typeCode = 'MFST') then {
          entryRelationship2.observation as observation2 then {
            observation2.value -&gt; reaction.manifestation &quot;manifestation&quot;;
            observation2.code -&gt; reaction.manifestation &quot;manifestation&quot;;
            observation2.text as tx then {
              tx.reference as reff -&gt; reaction.description = (reff.value) &quot;tx&quot;;
            } &quot;tx&quot;;
            observation2.effectiveTime as effectiveTime then {
              effectiveTime.low as low -&gt; reaction.onset = create('dateTime') as value then TSDateTime(low, value) &quot;valuePeriodLow&quot;;
              effectiveTime.high as high -&gt; tgt.lastOccurrence = create('dateTime') as value then TSDateTime(high, value) &quot;valuePeriodHigh&quot;;
            } &quot;low&quot;;
          } &quot;observ2&quot;;
        } &quot;entryR2&quot;;
        participant.participantRole as participantRole then {
          participantRole.playingEntity as playingEntity then {
            playingEntity.code -&gt; reaction.substance &quot;reaction&quot;;
          };
        };
      };
      observation1.entryRelationship as entryRelationship2 where (typeCode = 'MFST') then {
        entryRelationship2.observation as observation2 where observation1.participant.exists().not() -&gt; tgt.reaction as reaction then {
          observation2.value -&gt; reaction.manifestation &quot;manifestation&quot;;
          observation2.text as tx then {
            tx.reference as reff -&gt; reaction.description = (reff.value) &quot;tx&quot;;
          } &quot;tx&quot;;
          observation2.effectiveTime as effectiveTime then {
            effectiveTime.low as low -&gt; reaction.onset = create('dateTime') as value then TSDateTime(low, value) &quot;valuePeriodLow&quot;;
          } &quot;low&quot;;
        } &quot;observ2&quot;;
      } &quot;entryR2&quot;;
      observation1.entryRelationship as entryRelationship3 where (typeCode = 'SUBJ') then {
        entryRelationship3.observation as observation3 then {
          observation3.value as value then {
            value.code as c -&gt; tgt.criticality = translate(c, '#CricalityMap', 'code') &quot;value&quot;;
          } &quot;criticality&quot;;
        } &quot;observ3&quot;;
        entryRelationship3.act as act -&gt; tgt.note as note then {
          act.text as text then {
            text.reference as reference -&gt; note.text = (reference.value);
          } &quot;note&quot;;
        };
      } &quot;entryR3&quot;;
      observation1.entryRelationship as entryRelationship4 where (typeCode = 'REFR') then {
        entryRelationship4.observation as observation4 then {
          observation4 -&gt; tgt.clinicalStatus as clinicalStatus then {
            observation4.value as value then {
              value as valu -&gt; clinicalStatus.coding = create('Coding') as coding then {
                valu where (code = 'LA9041-0') -&gt; coding.code = 'resolved' &quot;code&quot;;
                valu where (code = 'LA18632-2') -&gt; coding.code = 'inactive' &quot;code&quot;;
                valu where (code = 'LA16666-2') -&gt; coding.code = 'active' &quot;code&quot;;
                valu -&gt; coding.system = 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical' &quot;system&quot;;
                valu.displayName as display -&gt; coding.display = cast(display, 'string') &quot;display&quot;;
              } &quot;coding&quot;;
            };
            observation4.text as tx then {
              tx.reference as ref -&gt; clinicalStatus.text = (ref.value);
            } &quot;tx&quot;;
          } &quot;clinicalStatus&quot;;
        } &quot;observ4&quot;;
      } &quot;entryR4&quot;;
    };
  } &quot;entryrelationship&quot;;
}

group MedicationStatement(source src : substanceAdministration, target tgt : MedicationStatement, target patient : Patient, target encounter : Encounter, target bundle : Bundle) {
  src -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // src -&gt; tgt.context = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  src.statusCode -&gt; tgt.status &quot;status&quot;;
  src.id -&gt; tgt.identifier;
  src.text as text -&gt; tgt.note as note then {
    text.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
  } &quot;note&quot;;
  src.effectiveTime as eff where (value.exists()) -&gt; tgt.effective = create('dateTime') as value then TSDateTime(eff, value) &quot;value1&quot;;
  src.effectiveTime : IVL_TS as eff -&gt; tgt.effective = create('Period') as value then IVLTSPeriod(eff, value) &quot;valuePeriod&quot;;
  src -&gt; tgt.dosage = create('Dosage') as dosage then {
    src.effectiveTime : PIVL_TS as eff then {
      eff -&gt; dosage.timing = create('Timing') as timing then periodTiming(eff, timing) &quot;cod&quot;;
    } &quot;eff&quot;;
    src where (src.doseQuantity.exists() or src.rateQuantity.exists() or src.routeCode.exists() or src.approachSiteCode.exists()) then {
      src.doseQuantity as doseQuant then {
        doseQuant.originalText as ot then {
          ot.reference -&gt; dosage.text;
        } &quot;ot&quot;;
        doseQuant -&gt; dosage.doseAndRate as dosageRate then {
          doseQuant -&gt; dosageRate.dose = create('Range') as d then {
            doseQuant -&gt; d.low = create('SimpleQuantity') as l then {
              doseQuant.low as lo -&gt; l.value = (lo.value);
              doseQuant.low as lo -&gt; l.unit = (lo.unit);
            } &quot;low&quot;;
            doseQuant -&gt; d.high = create('SimpleQuantity') as h then {
              doseQuant.high as hi -&gt; h.value = (hi.value);
              doseQuant.high as hi -&gt; h.unit = (hi.unit);
            } &quot;low&quot;;
          } &quot;d&quot;;
        } &quot;dosageRate&quot;;
      };
      src.rateQuantity as rateQuantity then {
        rateQuantity.originalText as ot then {
          ot.reference -&gt; dosage.text;
        } &quot;ot&quot;;
        rateQuantity -&gt; dosage.doseAndRate as dosageRate then {
          rateQuantity -&gt; dosageRate.rate = create('Range') as d then {
            rateQuantity -&gt; d.low = create('SimpleQuantity') as l then {
              rateQuantity.low as lo -&gt; l.value = (lo.value);
              rateQuantity.low as lo -&gt; l.unit = (lo.unit);
            } &quot;low&quot;;
            rateQuantity -&gt; d.high = create('SimpleQuantity') as h then {
              rateQuantity.high as hi -&gt; h.value = (hi.value);
              rateQuantity.high as hi -&gt; h.unit = (hi.unit);
            } &quot;high&quot;;
          } &quot;r&quot;;
        } &quot;dosageRate&quot;;
      } &quot;rate&quot;;
      src.routeCode -&gt; dosage.route &quot;route&quot;;
      src.approachSiteCode -&gt; dosage.site &quot;site&quot;;
      src.targetSiteCode -&gt; dosage.site &quot;site&quot;;
    } &quot;route&quot;;
  } &quot;dos&quot;;
  src.consumable as consumable then {
    consumable.manufacturedProduct as manufacturedProduct -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Medication') as medication,  medication.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Medication/', uuid1),  request.url = 'Medication',  tgt.medication = create('Reference') as medref,  medref.reference = ('https://example/Medication/' + %medication.id) then Medication(src, medication, patient, bundle) &quot;medication&quot;;
  };
}

group periodTiming(source effectiveTime : PIVL_TS, target timing : Timing) {
  effectiveTime -&gt; timing.repeat as r then {
    effectiveTime.period as p -&gt; r.period = (p.value);
    effectiveTime.period as p -&gt; r.periodUnit = (p.unit);
  } &quot;repeat&quot;;
}

group Medication(source src : substanceAdministration, target tgt : Medication, target patient : Patient, target bundle : Bundle) {
  src.consumable as consumable then {
    consumable.manufacturedProduct as manufacturedProduct then {
      manufacturedProduct.manufacturedMaterial as manufacturedMaterial then {
        manufacturedMaterial.code -&gt; tgt.code &quot;CE&quot;;
        src.administrationUnitCode -&gt; tgt.form &quot;form&quot;;
      } &quot;material&quot;;
    } &quot;product&quot;;
  };
  src.entryRelationship as entryR then {
    entryR.observation as observation then {
      observation.code where displayName = 'Grammatura' -&gt; tgt.ingredient as ingredient then {
        src.consumable as consumable then {
          consumable.manufacturedProduct as manufacturedProduct then {
            manufacturedProduct.manufacturedMaterial as manufacturedMaterial then {
              manufacturedMaterial.code as code -&gt; ingredient.item = create('CodeableConcept') as value then CECodeableConcept(code, value) &quot;CE&quot;;
            } &quot;material&quot;;
          } &quot;product&quot;;
        };
        observation.value as value -&gt; ingredient.strength as strength then {
          value -&gt; strength.numerator as numerator then {
            value -&gt; numerator.value = (value.value) &quot;valueN&quot;;
          } &quot;numerator&quot;;
          value -&gt; strength.denominator as denominator then {
            value -&gt; denominator.value = 1 &quot;valueD&quot;;
          } &quot;denominator&quot;;
        } &quot;strenght&quot;;
      } &quot;ingredient&quot;;
      observation.code where displayName = 'Quantità nella Confezione' then {
        observation.value as value -&gt; tgt.amount as amount then {
          value -&gt; amount.numerator as numerator then {
            value -&gt; numerator.value = (value.value) &quot;valueN&quot;;
          } &quot;numerator&quot;;
          value -&gt; amount.denominator as denominator then {
            value -&gt; denominator.value = 1 &quot;valueD&quot;;
          } &quot;denominator&quot;;
        } &quot;amount&quot;;
      } &quot;quantita&quot;;
    } &quot;obs&quot;;
  } &quot;entryR&quot;;
}

group Immunization(source substance : substanceAdministration, target patient : Patient, target encounter : Encounter, target tgt : Immunization, target bundle : Bundle) {
  substance -&gt;  tgt.patient = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;patientRef&quot;;
  // substance -&gt; tgt.encounter  = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;encounterRef&quot;;
  substance.id as id -&gt; tgt.identifier as idf then {
    id.root as r -&gt; idf.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
  };
  substance.text as text -&gt; tgt.note as note then {
    text.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
  } &quot;note&quot;;
  substance.statusCode as statusc where (code = 'completed') -&gt; tgt.status = 'completed';
  substance.statusCode as statusc where (code = 'aborted') -&gt; tgt.status = 'final';
  substance.statusCode as statusc where (code = 'suspended') -&gt; tgt.status = 'enterer-in-error';
  substance.statusCode as statusc where (code = 'cancelled') -&gt; tgt.status = 'not-done';
  substance.effectiveTime as time -&gt; tgt.occurrence = create('dateTime') as value then TSDateTime(time, value) &quot;efftime&quot;;
  substance.routeCode -&gt; tgt.route;
  substance.approachSiteCode -&gt; tgt.site;
  substance -&gt; tgt.doseQuantity = create('SimpleQuantity') as quantity then {
    substance.doseQuantity as q then {
      q -&gt; quantity.value = (q.value) &quot;val&quot;;
      q -&gt; quantity.unit = (q.unit) &quot;uni&quot;;
    } &quot;qua&quot;;
  } &quot;q&quot;;
  substance.consumable as cons then {
    cons.manufacturedProduct as manufact then {
      manufact.manufacturedMaterial as manufactmat then {
        manufactmat.code -&gt; tgt.vaccineCode;
        manufactmat.lotNumberText as t -&gt; tgt.lotNumber = (t.dataString);
      } &quot;manufactmat&quot;;
      manufact.manufacturerOrganization as manufactOrg -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'PUT',  e1.resource = create('Organization') as organization then {
        manufactOrg.id as id -&gt; organization.identifier as identifier then {
          id.root as r -&gt; identifier.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
          id.extension as ext -&gt; identifier.value = ext then {
            manufactOrg -&gt; request.url = append('Organization?identifier=', ext) &quot;UUID&quot;;
          } &quot;ext&quot;;
          id.assigningAuthorityName as s -&gt;  identifier.assigner as a,  a.display = s;
          id.root as r then {
            id.extension as ext -&gt;  organization.id = (r + '-' + ext) as uuid,  e1.fullUrl = append('https://example/', uuid),  tgt.manufacturer = create('Reference') as reference,  reference.reference = ('https://example/' + %organization.id) &quot;idasi&quot;;
          } &quot;r&quot;;
        } &quot;identifier&quot;;
        manufactOrg.name as n -&gt; organization.name = (n.other);
        manufactOrg -&gt; organization.meta as meta then {
          manufactOrg -&gt; meta.tag = create('Coding') as coding then {
            manufactOrg -&gt; coding.system = 'http://algoritmodiscoring' &quot;system&quot;;
            manufactOrg -&gt; coding.code = 'ClinicalDocument/body/Vaccinazioni/manufacturerOrganization' &quot;code&quot;;
          } &quot;coding&quot;;
        } &quot;meta&quot;;
      } &quot;manufactOrg&quot;;
    } &quot;manufact&quot;;
  } &quot;cons&quot;;
  substance.participant as part -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'PUT',  e1.resource = create('Location') as location,  location.id = uuid() as uuid1 then {
    part -&gt; location.meta as meta then {
      part -&gt; meta.tag = create('Coding') as coding then {
        part -&gt; coding.system = 'http://algoritmodiscoring' &quot;system&quot;;
        part -&gt; coding.code = 'ClinicalDocument/body/Vaccinazione/participant' &quot;code&quot;;
      } &quot;coding&quot;;
    } &quot;meta&quot;;
    part.participantRole as partRole then {
      partRole.id as id -&gt; location.identifier as identifier then {
        id.root as r -&gt; identifier.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
        id.extension as ext -&gt; identifier.value = ext then {
          partRole -&gt; request.url = append('Location?identifier=', ext) &quot;UUID&quot;;
        } &quot;ext&quot;;
        id.assigningAuthorityName as s -&gt;  identifier.assigner as a,  a.display = s;
        id.root as r then {
          id.extension as ext -&gt;  location.id = (r + '-' + ext) as uuid,  e1.fullUrl = append('https://example/Location', uuid),  tgt.location = create('Reference') as reference,  reference.reference = ('https://example/' + %location.id) &quot;idasi&quot;;
        } &quot;r&quot;;
      } &quot;identifier&quot;;
    } &quot;role&quot;;
  } &quot;part&quot;;
  substance.entryRelationship as entrirel1 then {
    entrirel1.observation as obs then {
      obs.code where (code = '30973-2') then {
        obs -&gt; tgt.protocolApplied = create('BackboneElement') as prot then {
          obs.value as v then {
            v.value as int -&gt; prot.doseNumber = (int.toString());
          };
        } &quot;val&quot;;
      } &quot;codecontrol&quot;;
    } &quot;obs&quot;;
  } &quot;entrirel1&quot;;
  substance.entryRelationship as entrirel2 then {
    entrirel2.observation as obs then {
      obs.code where (code = '59781-5') then {
        obs.value as value then {
          value.high as h then {
            h.value as value -&gt; tgt.expirationDate = truncate(value, 10);
          } &quot;val&quot;;
        };
      } &quot;codecontrol&quot;;
    } &quot;obs&quot;;
  } &quot;entrirel2&quot;;
  substance.entryRelationship as entrirel4 then {
    entrirel4.observation as obs then {
      obs.code where (code = '59785-6') -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Observation') as observation,  observation.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Observation/', uuid1),  request.url = 'Observation',  tgt.reasonReference = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %observation.id) then {
        obs then Observation1(entrirel4, patient, tgt, bundle, enc, observation) &quot;observation&quot;;
      } &quot;codecontrol&quot;;
    } &quot;obs&quot;;
  } &quot;entrirel4&quot;;
  substance.entryRelationship as entrirel5 then {
    entrirel5.observation as obs then {
      obs.code where (code = '75321-0') or (code = '5321-0') -&gt; tgt.reaction as reaction then {
        obs -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Observation') as observation,  observation.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Observation/', uuid1),  request.url = 'Observation',  reaction.detail = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %observation.id) then Observation(obs, patient, encounter, observation, bundle) &quot;observation&quot;;
      } &quot;codecontrol&quot;;
    } &quot;obs&quot;;
  } &quot;entrirel5&quot;;
  substance.entryRelationship as entrirel5 then {
    entrirel5.act as act then {
      act.text as tx -&gt; tgt.note as note then {
        tx.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
      } &quot;note&quot;;
    } &quot;obs&quot;;
  } &quot;entrirel5&quot;;
}

group ConditionFunction(source src : cdaElement, target tgt : Condition, target patient : patient, target encounter : encounter, target bundle : Bundle) {
  src.id -&gt; tgt.identifier;
  src -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  src.statusCode as stscode -&gt; tgt.verificationStatus as verifstatus then {
    stscode as codeS -&gt; verifstatus.coding = create('Coding') as coding then {
      codeS.code -&gt; coding.code = 'confirmed';
      codeS -&gt; coding.system = 'http://terminology.hl7.org/CodeSystem/condition-ver-status' &quot;system&quot;;
      codeS -&gt; coding.display = cast('Confirmed', 'string') &quot;display&quot;;
    } &quot;coding&quot;;
  } &quot;verifstatus&quot;;
  src where entryRelationship.exists().not() then {
    src.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.onset = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
    src.effectiveTime as effectiveTime -&gt; tgt.onset = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
  } &quot;onset&quot;;
  src.entryRelationship as entryRelationship then {
    entryRelationship.observation as obsentry then {
      // toASK
      obsentry.value -&gt; tgt.code;
      obsentry.code -&gt; tgt.category;
      obsentry.effectiveTime as effectiveTime where (value.exists()) -&gt; tgt.onset = create('dateTime') as value then TSDateTime(effectiveTime, value) &quot;value1&quot;;
      obsentry.effectiveTime as effectiveTime -&gt; tgt.onset = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
      obsentry.text as text -&gt; tgt.note as note then {
        text.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
      } &quot;note&quot;;
      obsentry.entryRelationship as entryR2 then {
        entryR2.observation as obsentry2 then {
          obsentry2.code where code = '89261-2' then {
            obsentry2 -&gt;  tgt.evidence as evidence,  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Observation') as obsy,  obsy.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Observation/', uuid1),  request.url = 'Observation',  evidence.detail = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obsy.id) then Observation(obsentry2, patient, encounter, obsy, bundle) &quot;observation&quot;;
          } &quot;observation&quot;;
          obsentry2.code where code = '33999-4' then {
            obsentry2.value as value -&gt; tgt.clinicalStatus as clinicalstatus then {
              value as val -&gt; clinicalstatus.coding = create('Coding') as coding then {
                val where (code = 'LA9041-0') -&gt; coding.code = 'resolved' &quot;code&quot;;
                val where (code = 'LA18632-2') -&gt; coding.code = 'inactive' &quot;code&quot;;
                val where (code = 'LA16666-2') -&gt; coding.code = 'active' &quot;code&quot;;
                val -&gt; coding.system = 'http://terminology.hl7.org/CodeSystem/condition-clinical' &quot;system&quot;;
                val.displayName as display -&gt; coding.display = cast(display, 'string') &quot;display&quot;;
              } &quot;coding&quot;;
              obsentry2.text as text then {
                text.reference as reference -&gt; clinicalstatus.text = (reference.value) &quot;text&quot;;
              };
            } &quot;clinicalstatus&quot;;
          } &quot;clinicalStatus2&quot;;
          obsentry2.code where code = 'SEV' then {
            obsentry2.value -&gt; tgt.severity;
          } &quot;severity&quot;;
        };
        entryR2.act as act then {
          act.text as text -&gt; tgt.note as note then {
            text.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
          } &quot;note&quot;;
        };
      } &quot;entryR&quot;;
    } &quot;EntryRelObsevation&quot;;
  } &quot;entryR&quot;;
}

group FamilyMemberFunction(source src : organizer, target tgt : FamilyMemberHistory, target patient : patient) {
  src -&gt;  tgt.patient = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;patReference&quot;;
  src.id -&gt; tgt.identifier;
  src.statusCode -&gt; tgt.status;
  src.effectiveTime as effectiveTime -&gt; tgt.date = create('date') as value then TSDate(effectiveTime, value) &quot;date&quot;;
  src.subject as subject then {
    subject.relatedSubject as relatedSubject then {
      relatedSubject.code -&gt; tgt.relationship &quot;relationshipCode&quot;;
      relatedSubject.subject as subject -&gt; tgt.sex as sex then {
        subject.administrativeGenderCode as administrativeGenderCode -&gt; sex.coding as coding then {
          administrativeGenderCode.code as sexCode -&gt; coding.code = translate(sexCode, '#cm-v3-administrative-gender', 'code') &quot;gender&quot;;
          administrativeGenderCode -&gt; coding.system = 'http://hl7.org/fhir/administrative-gender' &quot;system&quot;;
          administrativeGenderCode.displayName as dn -&gt; coding.display = dn;
        } &quot;coding&quot;;
      };
    } &quot;relatedSub&quot;;
  } &quot;relationship&quot;;
  src.component as component -&gt; tgt.condition as condition then {
    component.observation as observation then {
      observation.code -&gt; condition.code;
      observation.text as text -&gt; tgt.note as note then {
        text.reference as reference -&gt; note.text = (reference.value) &quot;value&quot;;
      } &quot;reference&quot;;
      observation.statusCode -&gt; tgt.status;
      // observation.effectiveTime as effectiveTime -&gt; condition.onset = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
      observation.value -&gt; condition.outcome &quot;codeable&quot;;
      observation.entryRelationship as entryR then {
        entryR.observation as obs then {
          obs where (code.code = '35267-4') then {
            obs.value as value -&gt; condition.onset = create('Age') as Age then {
              value.value as valueAge -&gt; Age.value = valueAge &quot;age&quot;;
              value.unit as unit -&gt; Age.code = unit;
              value.unit as unit -&gt; Age.unit = unit;
              value -&gt; Age.system = 'http://unitsofmeasure.org' &quot;system&quot;;
            };
          } &quot;insorgenza&quot;;
          obs where (code.code = '39016-1') then {
            obs.value as value -&gt; tgt.deceased = create('Age') as Age then {
              value.value as valueAge -&gt; Age.value = valueAge &quot;age&quot;;
              value.unit as unit -&gt; Age.code = unit;
              value.unit as unit -&gt; Age.unit = unit;
              value -&gt; Age.system = 'http://unitsofmeasure.org' &quot;system&quot;;
            };
          } &quot;death&quot;;
        } &quot;obser&quot;;
      } &quot;EntryRel&quot;;
    };
  };
}

group Practitioner(source src : performer, target tgt : Encounter, target bundle : Bundle) {
  src -&gt;  bundle.entry as e22,  e22.request = create('BackboneElement') as request,  request.method = 'PUT',  e22.resource = create('Practitioner') as practitioner1 then {
    src.assignedEntity as assignedEntity -&gt; tgt.participant as participant then {
      src.time as time where (value.exists()) -&gt; participant.period = create('dateTime') as value then TSDateTime(time, value) &quot;value1&quot;;
      src.time as time where (low.exists()) -&gt; participant.period = create('Period') as value then IVLTSPeriod(time, value) &quot;valuePeriod&quot;;
      // src.time as time -&gt; participant.period as period then{
      assignedEntity.id as id -&gt; practitioner1.identifier as identifier then {
        id.root as r -&gt; identifier.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
        id.extension as ext -&gt; identifier.value = ext &quot;ext&quot;;
        id.assigningAuthorityName as s -&gt;  identifier.assigner as a,  a.display = s;
        id.root as r then {
          id.extension as ext -&gt;  practitioner1.id = (r + '-' + ext) as uuid22,  e22.fullUrl = append('https://example/Practitioner/', uuid22),  participant.individual = create('Reference') as reference,  reference.reference = ('https://example/Practitioner/' + %practitioner1.id) &quot;id&quot;;
        } &quot;r&quot;;
      } &quot;identifier&quot;;
      assignedEntity.id as id where (root = '2.16.840.1.113883.2.9.4.3.2') then {
        id.extension as ext -&gt; request.url = append('Practitioner?identifier=', ext) &quot;UUID&quot;;
      } &quot;2&quot;;
      assignedEntity.id as id where (root != '2.16.840.1.113883.2.9.4.3.2') then {
        id.extension as ext -&gt; request.url = append('Practitioner?identifier=', ext) &quot;UUID&quot;;
      } &quot;diverso&quot;;
      assignedEntity -&gt; practitioner1.meta as meta then {
        src -&gt; meta.tag = create('Coding') as coding then {
          src -&gt; coding.system = 'http://algoritmodiscoring' &quot;system&quot;;
          src -&gt; coding.code = 'ClinicalDocument/body/VisiteRicoveri/performer/' &quot;code&quot;;
        } &quot;coding&quot;;
      } &quot;meta&quot;;
      assignedEntity.addr -&gt; practitioner1.address;
      assignedEntity.telecom -&gt; practitioner1.telecom;
      assignedEntity.assignedPerson as person then {
        person.name -&gt; practitioner1.name;
        person.birthTime -&gt; practitioner1.birthDate;
      } &quot;partname&quot;;
    } &quot;participant&quot;;
  } &quot;resurceCreation&quot;;
}

group CarePlanFunction(source src : entry, target tgt : CarePlan, target patient : Patient, target encounter : Encounter, target bundle : Bundle) {
  src -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  src -&gt; tgt.status = 'unknown' &quot;status&quot;;
  src -&gt; tgt.intent = 'plan' &quot;intent&quot;;
  src -&gt; tgt.activity as activity then {
    src -&gt; activity.detail as detail then {
      src.observation as observation then {
        observation then {
          observation -&gt; detail.status = 'unknown' &quot;status&quot;;
          observation -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Observation') as obs1,  obs1.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Observation/', uuid1),  request.url = 'Observation',  detail.reasonReference = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obs1.id) then Observation(observation, patient, encounter, obs1, bundle) &quot;obs1&quot;;
        } &quot;activity&quot;;
      } &quot;entryObs&quot;;
      src.substanceAdministration as substanceAdministration -&gt; tgt.activity as activity then {
        substanceAdministration -&gt;  bundle.entry as e2,  e2.request = create('BackboneElement') as request,  request.method = 'POST',  e2.resource = create('MedicationRequest') as medre1,  medre1.id = uuid() as uuid2,  e2.fullUrl = append('https://example/MedicationRequest/', uuid2),  request.url = 'MedicationRequest',  activity.reference = create('Reference') as reference,  reference.reference = ('https://example/MedicationRequest/' + %medre1.id) then MedicationRequest(substanceAdministration, patient, encounter, medre1, bundle) &quot;Terapie&quot;;
      } &quot;entrySub&quot;;
      src.procedure as procedureC -&gt;  bundle.entry as e8,  e8.request = create('BackboneElement') as request,  request.method = 'POST',  e8.resource = create('Procedure') as procedure,  procedure.id = uuid() as uuid8,  e8.fullUrl = append('https://example/Procedure/', uuid8),  request.url = 'Procedure',  activity.outcomeReference = create('Reference') as reference,  reference.reference = ('https://example/Procedure/' + %procedure.id) then Procedure(procedureC, patient, encounter, procedure, bundle) &quot;proc&quot;;
      src.encounter as encounterCDA -&gt;  bundle.entry as e3,  e3.request = create('BackboneElement') as request,  request.method = 'POST',  e3.resource = create('Encounter') as encounterFHIR,  encounterFHIR.id = uuid() as uuid3,  e3.fullUrl = append('https://example/Encounter/', uuid3),  request.url = 'Encounter',  tgt.encounter = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounterFHIR.id) then {
        // encounterCDA -&gt; encounterFHIR.partOf = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;encounterHeader&quot;;
        encounterCDA -&gt;  encounterFHIR.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;refPatient&quot;;
        encounterCDA.id -&gt; encounterFHIR.identifier;
        encounterCDA.statusCode -&gt; encounterFHIR.status;
        encounterCDA where statusCode.exists().not() -&gt; encounterFHIR.status = 'unknown' &quot;status&quot;;
        encounterCDA.code as code -&gt; encounterFHIR.class as class then {
          code.code as code -&gt; class.code = cast(code, 'string');
          code.codeSystem as system -&gt; class.system = translate(system, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri');
          code.displayName as display -&gt; class.display = cast(display, 'string');
        } &quot;class&quot;;
        encounterCDA.text as text -&gt; encounterFHIR.type as type then {
          text.reference as reference -&gt; type.text = (reference.value) &quot;value&quot;;
        };
        encounterCDA.effectiveTime as effectiveTime -&gt; encounterFHIR.period = create('Period') as period then {
          effectiveTime -&gt; period.start = create('dateTime') as start then TSDateTime(effectiveTime, start) &quot;val&quot;;
        } &quot;efft&quot;;
      } &quot;viste&quot;;
      src.act as act then {
        act.id -&gt; tgt.identifier;
        act.code -&gt; activity.outcomeCodeableConcept;
        act.text as text -&gt; activity.progress = create('Annotation') as progress then {
          text.reference as reference -&gt; progress.text = (reference.value) &quot;value&quot;;
        };
        act.effectiveTime as effectiveTime -&gt; detail.scheduled = create('Period') as period then {
          effectiveTime -&gt; period.start = create('dateTime') as start then TSDateTime(effectiveTime, start) &quot;val&quot;;
        } &quot;efft&quot;;
        act -&gt; detail.status = 'completed' &quot;status&quot;;
      };
    } &quot;detail&quot;;
  } &quot;activityIni&quot;;
}

group MedicationRequest(source src : substanceAdministration, target patient : Patient, target encounter : Encounter, target tgt : MedicationRequest, target bundle : Bundle) {
  // default  + mandatory
  src -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // src -&gt; tgt.encounter = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;
  src -&gt; tgt.intent = 'order' &quot;intent&quot;;
  src where statusCode.exists().not() -&gt; tgt.status = 'unknown' &quot;st&quot;;
  src.statusCode as sc then {
    sc.code as cos -&gt; tgt.status = translate(cos, '#MedicationStatusMap', 'code') &quot;codeS&quot;;
  } &quot;status&quot;;
  src.id -&gt; tgt.identifier;
  src.text as txt -&gt; tgt.note as note then {
    txt.reference as reference -&gt; note.text = (reference.value) &quot;text&quot;;
  } &quot;note&quot;;
  src.effectiveTime : IVL_TS as eff -&gt; tgt.dosageInstruction = create('Dosage') as dosage then {
    eff -&gt; dosage.timing = create('Timing') as timing then {
      eff -&gt; timing.repeat as rep then {
        eff -&gt; rep.bounds = create('Period') as value then IVLTSPeriod(eff, value) &quot;valuePeriod&quot;;
      } &quot;rep&quot;;
    } &quot;timing&quot;;
  } &quot;period&quot;;
  src.effectiveTime : EIVL_TS as effe -&gt; tgt.dosageInstruction = create('Dosage') as dosage then {
    effe -&gt; dosage.timing = create('Timing') as timing then {
      effe -&gt; timing.repeat as rep then {
        effe.eventCode as ev -&gt; rep.when = (ev.code);
      } &quot;rep&quot;;
    } &quot;timing&quot;;
  } &quot;period&quot;;
  src.effectiveTime : IVL_TS as eff -&gt;  tgt.dosageInstruction = create('Dosage') as dosage,  dosage.timing = create('Timing') as timing,  timing.event = (eff.value) &quot;tim&quot;;
  src.effectiveTime : PIVL_TS as eff -&gt; tgt.dosageInstruction = create('Dosage') as dosage then {
    eff -&gt; dosage.timing = create('Timing') as timing then periodTiming(eff, timing) &quot;cod&quot;;
  } &quot;eff&quot;;
  src where (src.doseQuantity.exists() or src.rateQuantity.exists()) then {
    src -&gt; tgt.dosageInstruction = create('Dosage') as dosageInstruction then {
      src.doseQuantity as doseQuant then {
        doseQuant.originalText as ot then {
          ot.reference -&gt; dosageInstruction.text;
        } &quot;ot&quot;;
        doseQuant -&gt; dosageInstruction.doseAndRate as dosageRate then {
          doseQuant -&gt; dosageRate.dose = create('Range') as d then {
            doseQuant -&gt; d.low = create('SimpleQuantity') as l then {
              doseQuant.low as lo -&gt; l.value = (lo.value);
              doseQuant.low as lo -&gt; l.unit = (lo.unit);
            } &quot;low&quot;;
            doseQuant -&gt; d.high = create('SimpleQuantity') as h then {
              doseQuant.high as hi -&gt; h.value = (hi.value);
              doseQuant.high as hi -&gt; h.unit = (hi.unit);
            } &quot;low&quot;;
          } &quot;d&quot;;
        } &quot;dosageRate&quot;;
      };
      src.rateQuantity as rateQuantity then {
        rateQuantity.originalText as ot then {
          ot.reference -&gt; dosageInstruction.text;
        } &quot;ot&quot;;
        rateQuantity -&gt; dosageInstruction.doseAndRate as dosageRate then {
          rateQuantity -&gt; dosageRate.rate = create('Range') as d then {
            rateQuantity -&gt; d.low = create('SimpleQuantity') as l then {
              rateQuantity.low as lo -&gt; l.value = (lo.value);
              rateQuantity.low as lo -&gt; l.unit = (lo.unit);
            } &quot;low&quot;;
            rateQuantity -&gt; d.high = create('SimpleQuantity') as h then {
              rateQuantity.high as hi -&gt; h.value = (hi.value);
              rateQuantity.high as hi -&gt; h.unit = (hi.unit);
            } &quot;high&quot;;
          } &quot;r&quot;;
        } &quot;dosageRate&quot;;
      } &quot;rate&quot;;
      src.routeCode -&gt; dosageInstruction.route &quot;route&quot;;
      src.approachSiteCode -&gt; dosageInstruction.site &quot;site&quot;;
      src.targetSiteCode -&gt; dosageInstruction.site &quot;site&quot;;
    } &quot;dosageIn&quot;;
  } &quot;condition&quot;;
  src.consumable as consumable -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Medication') as medication,  medication.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Medication/', uuid1),  request.url = 'Medication',  tgt.medication = create('Reference') as medref,  medref.reference = ('https://example/Medication/' + %medication.id) then Medication(src, medication, patient, bundle) &quot;medication&quot;;
  src.entryRelationship as entryRelationship then {
    entryRelationship.supply as supply -&gt; tgt.dispenseRequest as dispenseRequest then {
      supply.quantity as quantityCDA -&gt; dispenseRequest.quantity as quantityFHIR then {
        quantityCDA -&gt; quantityFHIR.value = (quantityCDA.value) &quot;value&quot;;
      };
    };
  } &quot;entryR&quot;;
  src.participant as participant then {
    participant then Practitioner(participant, tgt, bundle) &quot;function&quot;;
    participant.effectiveTime -&gt; tgt.authoredOn &quot;autor&quot;;
  } &quot;Partecipant&quot;;
}

group OrganizationAffiliation(source src : act, target patient : Patient, target enc : Encounter, target tgt : OrganizationAffiliation, target bundle : Bundle) {
  src.id -&gt; tgt.identifier;
  // src.code -&gt; tgt.specialty as specialty then{
  src.statusCode where code = 'active' -&gt; tgt.active = true;
  src.statusCode where (code = 'active').not() -&gt; tgt.active = false;
  src.effectiveTime as eff -&gt; tgt.period;
  // src.code -&gt; tgt.specialty;
  src -&gt; tgt.specialty = create('CodeableConcept') as spec then {
    src.code as code then {
      code -&gt; spec.coding = create('Coding') as cd then {
        code -&gt; cd.code = (code.code) &quot;code&quot;;
        code -&gt; cd.display = (code.displayName) &quot;code&quot;;
        code.codeSystem as r -&gt; cd.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
      } &quot;cd&quot;;
    } &quot;spec&quot;;
    src.entryRelationship as entry then {
      entry.act as a then {
        a.text as tx then {
          tx.reference as reff -&gt; spec.text = (reff.value);
        } &quot;ref&quot;;
      };
    } &quot;entry&quot;;
  } &quot;a&quot;;
}

group DiagnosticReportFunction(source src : organizer, target patient : Patient, target enc : Encounter, target tgt : DiagnosticReport, target bundle : Bundle) {
  src -&gt;  tgt.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;
  // src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;
  src.code -&gt; tgt.code;
  src.statusCode where code = 'completed' -&gt; tgt.status = 'final';
  src.effectiveTime as eff where (value.exists()) -&gt; tgt.effective = create('dateTime') as value then TSDateTime(eff, value) &quot;value1&quot;;
  src.effectiveTime as eff where (low.exists()) -&gt; tgt.effective = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;
  src.component as component then {
    component.observation as observation -&gt;  bundle.entry as ei,  ei.request = create('BackboneElement') as request,  request.method = 'POST',  ei.resource = create('Observation') as obsi,  obsi.id = uuid() as uuidi,  ei.fullUrl = append('https://example/Observation/', uuidi),  request.url = 'Observation',  tgt.result = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %obsi.id) then Observation(observation, patient, enc, obsi, bundle) &quot;hasMember&quot;;
  };
}

group EncounterFunction(source src : cdaElement, target patient : Patient, target encounter : Encounter, target tgt : Encounter, target bundle : Bundle) {
  src.id -&gt; tgt.identifier;
  src.statusCode -&gt; tgt.status;
  src where statusCode.exists().not() -&gt; tgt.status = 'unknown' &quot;status&quot;;
  src.code as code -&gt; tgt.class as class then {
    code -&gt; class.code = (code.code) &quot;code&quot;;
    code -&gt; class.display = (code.displayName) &quot;display&quot;;
    code.codeSystem as r -&gt; class.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
  } &quot;co&quot;;
  // src.effectiveTime as effective -&gt; tgt.period as period then{
  src where effectiveTime.low.exists() or effectiveTime.high.exists() then {
    src.effectiveTime as eff -&gt; tgt.period = create('Period') as period then IVLTSPeriod(eff, period);
  } &quot;where&quot;;
  // effectiveTime = time-stamp
  src where effectiveTime.low.exists().not() or effectiveTime.high.exists().not() then {
    src.effectiveTime as effectivetime1 -&gt; tgt.period = create('Period') as period then {
      effectivetime1 -&gt; period.start = create('dateTime') as start then TSDateTime(effectivetime1, start) &quot;val&quot;;
    } &quot;efft&quot;;
  } &quot;where&quot;;
  // src.effectiveTime as eff where (value.exists()) -&gt; tgt.period = create('dateTime') as value then TSDateTime(eff, value) &quot;value1&quot;;
  src.text as tx -&gt; tgt.type as ty then {
    tx.reference as reff -&gt; ty.text = (reff.value) &quot;textType&quot;;
  };
  src.performer as performer -&gt; tgt.participant as part then {
    performer -&gt; part.period as period then {
      performer.time as time -&gt; period.start as start then TSDateTime(time, start) &quot;val&quot;;
    } &quot;period&quot;;
    performer.assignedEntity as assentity -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('PractitionerRole') as practitionerRole,  practitionerRole.id = uuid() as uuid1,  e1.fullUrl = append('https://example/PractitionerRole/', uuid1),  request.url = 'PractitionerRole',  tgt.participant = create('BackboneElement') as participant1,  participant1.individual = create('Reference') as referencepart,  referencepart.reference = ('https://example/PractitionerRole/' + %practitionerRole.id) then {
      assentity.code -&gt; practitionerRole.code;
      assentity -&gt;  bundle.entry as e2,  e2.request = create('BackboneElement') as request,  request.method = 'PUT',  e2.resource = create('Practitioner') as practitioner then {
        assentity -&gt; practitioner.meta as meta then {
          assentity -&gt; meta.tag = create('Coding') as coding then {
            assentity -&gt; coding.system = 'http://algoritmodiscoring' &quot;system&quot;;
            assentity -&gt; coding.code = 'ClinicalDocument/body/encounter/performer' &quot;code&quot;;
          } &quot;coding&quot;;
        } &quot;meta&quot;;
        assentity.id as id -&gt; practitioner.identifier as identifier then {
          id.root as r -&gt; identifier.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;
          id.extension as ext -&gt; identifier.value = ext then {
            assentity -&gt; request.url = append('Practitioner?identifier=', ext) &quot;UUID&quot;;
          } &quot;ext&quot;;
          id.assigningAuthorityName as s -&gt;  identifier.assigner as a,  a.display = s;
          id.root as r then {
            id.extension as ext -&gt;  practitioner.id = (r + '-' + ext) as uuid2,  e2.fullUrl = append('https://example/Practitioner/', uuid2),  practitionerRole.practitioner = create('Reference') as reference,  reference.reference = ('https://example/Practitioner/' + %practitioner.id) &quot;performer&quot;;
          } &quot;r&quot;;
        } &quot;identifier&quot;;
        assentity.id as id where (root = '2.16.840.1.113883.2.9.4.3.2') then {
          id.extension as ext -&gt; request.url = append('Practitioner?identifier=', ext) &quot;UUID&quot;;
        } &quot;2&quot;;
        assentity.id as id where (root != '2.16.840.1.113883.2.9.4.3.2') then {
          id.extension as ext -&gt; request.url = append('Practitioner?identifier=', ext) &quot;UUID&quot;;
        } &quot;2&quot;;
        assentity.addr -&gt; practitioner.address;
        assentity.telecom -&gt; practitioner.telecom;
        assentity.assignedPerson as person then {
          person.name -&gt; practitioner.name;
          person.birthTime as birthTime then {
            birthTime.value as date -&gt; practitioner.birthDate = truncate(date, 10);
          } &quot;birth&quot;;
        } &quot;name&quot;;
      } &quot;assignedEntity&quot;;
    } &quot;performer&quot;;
  } &quot;01&quot;;
}

</pre>
      </div>
  </text>
  <url value="http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirPs"/>
  <version value="0.1.0"/>
  <name value="cda2fhirPs"/>
  <status value="draft"/>
  <date value="2024-04-11T15:38:19+02:00"/>
  <publisher value="HL7 Italy"/>
  <contact>
    <name value="HL7 Italy"/>
    <telecom>
      <system value="url"/>
      <value value="http://hl7.it"/>
    </telecom>
  </contact>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="IT"/>
      <display value="Italy"/>
    </coding>
  </jurisdiction>
  <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/AssociatedEntity"/>
    <mode value="queried"/>
    <alias value="AssociatedEntity"/>
  </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/OrganizationPartOf"/>
    <mode value="queried"/>
    <alias value="OrganizationPartOf"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/Organization"/>
    <mode value="queried"/>
    <alias value="rapresentedOrganization"/>
  </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/cda/StructureDefinition/AD"/>
    <mode value="source"/>
    <alias value="AD"/>
  </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/Encounter"/>
    <mode value="produced"/>
    <alias value="Encounter"/>
  </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/List"/>
    <mode value="produced"/>
    <alias value="List"/>
  </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>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/Act"/>
    <mode value="produced"/>
    <alias value="Act"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/IVL-PQ"/>
    <mode value="source"/>
    <alias value="IVL_PQ"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/cda/StructureDefinition/PQ"/>
    <mode value="source"/>
    <alias value="PQ"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/SimpleQuantity"/>
    <mode value="target"/>
    <alias value="SimpleQuantity"/>
  </structure>
  <import value="http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirDataTypes"/>
  <import value="http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirHeader"/>
  <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="request"/>
        <variable value="request"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="POST"/>
        </parameter>
      </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="uuid1"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://example/Composition/"/>
        </parameter>
        <parameter>
          <valueId value="uuid1"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Composition"/>
        </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="request"/>
        <variable value="requestPAT"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="requestPAT"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="PUT"/>
        </parameter>
      </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="https://example/Patient/"/>
        </parameter>
        <parameter>
          <valueId value="uuid2"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e3"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="request"/>
        <variable value="request"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="POST"/>
        </parameter>
      </target>
      <target>
        <context value="e3"/>
        <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="uuid3"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e3"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://example/Encounter/"/>
        </parameter>
        <parameter>
          <valueId value="uuid3"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Encounter"/>
        </parameter>
      </target>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e4"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="request"/>
        <variable value="request"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="POST"/>
        </parameter>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="DocumentReference"/>
        <transform value="create"/>
        <parameter>
          <valueString value="DocumentReference"/>
        </parameter>
      </target>
      <target>
        <context value="DocumentReference"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid4"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e4"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://example/DocumentReference/"/>
        </parameter>
        <parameter>
          <valueId value="uuid4"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="DocumentReference"/>
        </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="encounter"/>
          <variable value="bundle"/>
          <variable value="DocumentReference"/>
        </dependent>
      </rule>
      <rule>
        <name value="patient"/>
        <source>
          <context value="cda"/>
          <element value="recordTarget"/>
          <variable value="recordTarget"/>
        </source>
        <rule>
          <name value="recPat"/>
          <source>
            <context value="recordTarget"/>
            <element value="patientRole"/>
            <variable value="patient"/>
          </source>
          <rule>
            <name value="idfr"/>
            <source>
              <context value="patient"/>
              <element value="id"/>
              <variable value="id"/>
            </source>
            <target>
              <context value="patient"/>
              <contextType value="variable"/>
              <element value="identifier"/>
              <variable value="identifier"/>
            </target>
            <rule>
              <name value="root1"/>
              <source>
                <context value="id"/>
                <element value="root"/>
                <variable value="r"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="translate"/>
                <parameter>
                  <valueId value="r"/>
                </parameter>
                <parameter>
                  <valueString
                               value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
                </parameter>
                <parameter>
                  <valueString value="uri"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="value"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext1"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="ext1"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="assigningAuthorityName"/>
              <source>
                <context value="id"/>
                <element value="assigningAuthorityName"/>
                <variable value="s"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="assigner"/>
                <variable value="a"/>
              </target>
              <target>
                <context value="a"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="s"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="ext"/>
            <source>
              <context value="patient"/>
              <element value="id"/>
              <variable value="id"/>
              <condition
                         value="(root = '2.16.840.1.113883.2.9.4.3.2') or (root = '2.16.840.1.113883.2.9.4.3.7') or (root = '2.16.840.1.113883.2.9.4.3.3') or (root = '2.16.840.1.113883.2.9.4.3.17') or (root = '2.16.840.1.113883.2.9.4.3.18') or (root = '2.16.840.1.113883.2.9.2.10.4.1.1') or (root = '2.16.840.1.113883.2.9.2.20.4.1.1') or (root = '2.16.840.1.113883.2.9.2.30.4.1.1') or (root = '2.16.840.1.113883.2.9.2.41.4.1.1') or (root = '2.16.840.1.113883.2.9.2.42.4.1.1') or (root = '2.16.840.1.113883.2.9.2.50.4.1.1') or (root = '2.16.840.1.113883.2.9.2.60.4.1.1') or (root = '2.16.840.1.113883.2.9.2.70.4.1.1') or (root = '2.16.840.1.113883.2.9.2.80.4.1.1') or (root = '2.16.840.1.113883.2.9.2.90.4.1.1') or (root = '2.16.840.1.113883.2.9.2.100.4.1.1') or (root = '2.16.840.1.113883.2.9.2.110.4.1.1') or (root = '2.16.840.1.113883.2.9.2.120.4.1.1') or (root = '2.16.840.1.113883.2.9.2.130.4.1.1') or (root = '2.16.840.1.113883.2.9.2.140.4.1.1') or (root = '2.16.840.1.113883.2.9.2.150.4.1.1') or (root = '2.16.840.1.113883.2.9.2.160.4.1.1') or (root = '2.16.840.1.113883.2.9.2.170.4.1.1') or (root = '2.16.840.1.113883.2.9.2.180.4.1.1') or (root = '2.16.840.1.113883.2.9.2.190.4.1.1') or (root = '2.16.840.1.113883.2.9.2.200.4.1.1') or (root = '2.16.840.1.113883.2.9.2.10.4.1') or (root = '2.16.840.1.113883.2.9.2.20.4.1') or (root = '2.16.840.1.113883.2.9.2.30.4.1') or (root = '2.16.840.1.113883.2.9.2.41.4.1') or (root = '2.16.840.1.113883.2.9.2.42.4.1') or (root = '2.16.840.1.113883.2.9.2.50.4.1') or (root = '2.16.840.1.113883.2.9.2.60.4.1') or (root = '2.16.840.1.113883.2.9.2.70.4.1') or (root = '2.16.840.1.113883.2.9.2.80.4.1') or (root = '2.16.840.1.113883.2.9.2.90.4.1') or (root = '2.16.840.1.113883.2.9.2.100.4.1') or (root = '2.16.840.1.113883.2.9.2.110.4.1') or (root = '2.16.840.1.113883.2.9.2.120.4.1') or (root = '2.16.840.1.113883.2.9.2.130.4.1') or (root = '2.16.840.1.113883.2.9.2.140.4.1') or (root = '2.16.840.1.113883.2.9.2.150.4.1') or (root = '2.16.840.1.113883.2.9.2.160.4.1') or (root = '2.16.840.1.113883.2.9.2.170.4.1') or (root = '2.16.840.1.113883.2.9.2.180.4.1') or (root = '2.16.840.1.113883.2.9.2.190.4.1') or (root = '2.16.840.1.113883.2.9.2.200.4.1') or (root = '2.16.840.1.113883.2.9.4.3.15')"/>
            </source>
            <rule>
              <name value="UUID"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="requestPAT"/>
                <contextType value="variable"/>
                <element value="url"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Patient?identifier="/>
                </parameter>
                <parameter>
                  <valueId value="ext"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </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="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="DocumentReference"/>
      <type value="DocumentReference"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="finished"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="finished"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="coding"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="encounter"/>
        <contextType value="variable"/>
        <element value="class"/>
        <variable value="coding"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Coding"/>
        </parameter>
      </target>
      <rule>
        <name value="code"/>
        <source>
          <context value="cda"/>
        </source>
        <target>
          <context value="coding"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="summary"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <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="transaction"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="date"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="timestamp"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="timestamp.now()"/>
        </parameter>
      </target>
      <documentation value="cda.effectiveTime -&gt; bundle.timestamp;"/>
    </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="encounter"/>
        <variable value="bundle"/>
        <variable value="DocumentReference"/>
      </dependent>
    </rule>
    <rule>
      <name value="diagnostic"/>
      <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"/>
          </source>
          <rule>
            <name value="section"/>
            <source>
              <context value="component"/>
              <element value="section"/>
              <variable value="srcSection"/>
            </source>
            <rule>
              <name value="code"/>
              <source>
                <context value="srcSection"/>
                <element value="code"/>
              </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"/>
                <variable value="encounter"/>
                <variable value="composition"/>
              </dependent>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ClinicalDocumentSection"/>
    <typeMode value="none"/>
    <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="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="enc"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="composition"/>
      <type value="Composition"/>
      <mode value="target"/>
    </input>
    <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="entry"/>
      <source>
        <context value="src"/>
        <element value="entry"/>
        <variable value="entry"/>
      </source>
      <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="entryObs"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="(code = '30954-2')"/>
        </source>
        <rule>
          <name value="diagnostic"/>
          <source>
            <context value="entry"/>
            <element value="organizer"/>
            <variable value="organizer"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e0"/>
          </target>
          <target>
            <context value="e0"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e0"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="dia"/>
            <transform value="create"/>
            <parameter>
              <valueString value="DiagnosticReport"/>
            </parameter>
          </target>
          <target>
            <context value="dia"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid0"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e0"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/DiagnosticReport/"/>
            </parameter>
            <parameter>
              <valueId value="uuid0"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="DiagnosticReport"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/DiagnosticReport/' + %dia.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="DiagnosticReportFunction"/>
            <variable value="organizer"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="dia"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
        <documentation value="sezioni che sono strutturate"/>
      </rule>
      <rule>
        <name value="entryObs"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="(code = '29762-2') or (code = '10162-6')"/>
        </source>
        <rule>
          <name value="obs1"/>
          <source>
            <context value="entry"/>
            <element value="observation"/>
            <variable value="observation"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e1"/>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="obs1"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="obs1"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid1"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Observation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid1"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Observation/' + %obs1.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Observation"/>
            <variable value="observation"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="obs1"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="organizer"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="(code = '8716-3') or (code = '47420-5')"/>
        </source>
        <rule>
          <name value="obs2"/>
          <source>
            <context value="entry"/>
            <element value="organizer"/>
            <variable value="organizer"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e2"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="obs2"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="obs2"/>
            <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="https://example/Observation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid2"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Observation/' + %obs2.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ObservationOrganizer"/>
            <variable value="src"/>
            <variable value="organizer"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="obs2"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
        <rule>
          <name value="obs2"/>
          <source>
            <context value="entry"/>
            <element value="observation"/>
            <variable value="organizer"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e2"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="obs2"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="obs2"/>
            <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="https://example/Observation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid2"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Observation/' + %obs2.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ObservationOrganizer"/>
            <variable value="src"/>
            <variable value="organizer"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="obs2"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="listaDeiProblemi"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '11450-4'"/>
        </source>
        <rule>
          <name value="condition"/>
          <source>
            <context value="entry"/>
            <element value="act"/>
            <variable value="act"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e3"/>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="condition"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Condition"/>
            </parameter>
          </target>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid3"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Condition/"/>
            </parameter>
            <parameter>
              <valueId value="uuid3"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Condition"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Condition/' + %condition.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="ConditionFunction"/>
            <variable value="act"/>
            <variable value="condition"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="entryAct"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="(code = '48765-2')"/>
        </source>
        <rule>
          <name value="allergy"/>
          <source>
            <context value="entry"/>
            <element value="act"/>
            <variable value="act"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e5"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="allergy"/>
            <transform value="create"/>
            <parameter>
              <valueString value="AllergyIntolerance"/>
            </parameter>
          </target>
          <target>
            <context value="allergy"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid5"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e5"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/AllergyIntolerance/"/>
            </parameter>
            <parameter>
              <valueId value="uuid5"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="AllergyIntolerance"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/AllergyIntolerance/' + %allergy.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="allergyFunction"/>
            <variable value="act"/>
            <variable value="allergy"/>
            <variable value="patient"/>
            <variable value="enc"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="terapia"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '10160-0'"/>
        </source>
        <rule>
          <name value="TerapiaFarmacologica"/>
          <source>
            <context value="entry"/>
            <element value="substanceAdministration"/>
            <variable value="subAdmin"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e6"/>
          </target>
          <target>
            <context value="e6"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e6"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="medicationstatement"/>
            <transform value="create"/>
            <parameter>
              <valueString value="MedicationStatement"/>
            </parameter>
          </target>
          <target>
            <context value="medicationstatement"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid6"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e6"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/MedicationStatement/"/>
            </parameter>
            <parameter>
              <valueId value="uuid6"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="MedicationStatement"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/MedicationStatement/' + %medicationstatement.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="MedicationStatement"/>
            <variable value="subAdmin"/>
            <variable value="medicationstatement"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="vacc"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '11369-6'"/>
        </source>
        <rule>
          <name value="immunization"/>
          <source>
            <context value="entry"/>
            <element value="substanceAdministration"/>
            <variable value="subVACC"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e7"/>
          </target>
          <target>
            <context value="e7"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e7"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="immunization"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Immunization"/>
            </parameter>
          </target>
          <target>
            <context value="immunization"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid7"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e7"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Immunization/"/>
            </parameter>
            <parameter>
              <valueId value="uuid7"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Immunization"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Immunization/' + %immunization.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Immunization"/>
            <variable value="subVACC"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="immunization"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="family"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '10157-6'"/>
        </source>
        <rule>
          <name value="family"/>
          <source>
            <context value="entry"/>
            <element value="organizer"/>
            <variable value="organizer"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e12"/>
          </target>
          <target>
            <context value="e12"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e12"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="familyMember"/>
            <transform value="create"/>
            <parameter>
              <valueString value="FamilyMemberHistory"/>
            </parameter>
          </target>
          <target>
            <context value="familyMember"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid12"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e12"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/FamilyMemberHistory/"/>
            </parameter>
            <parameter>
              <valueId value="uuid12"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="FamilyMemberHistory"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/FamilyMemberHistory/' + %familyMember.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="FamilyMemberFunction"/>
            <variable value="organizer"/>
            <variable value="familyMember"/>
            <variable value="patient"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="impianti"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '46264-8'"/>
        </source>
        <rule>
          <name value="protesi"/>
          <source>
            <context value="entry"/>
            <element value="supply"/>
            <variable value="supply"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e8"/>
          </target>
          <target>
            <context value="e8"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e8"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="procedure"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Procedure"/>
            </parameter>
          </target>
          <target>
            <context value="procedure"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid8"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e8"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Procedure/"/>
            </parameter>
            <parameter>
              <valueId value="uuid8"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Procedure"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Procedure/' + %procedure.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Procedure"/>
            <variable value="supply"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="procedure"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="trattamentiProcedure"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '47519-4'"/>
        </source>
        <rule>
          <name value="tratt"/>
          <source>
            <context value="entry"/>
            <element value="procedure"/>
            <variable value="procedure"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e9"/>
          </target>
          <target>
            <context value="e9"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e9"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="procedure2"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Procedure"/>
            </parameter>
          </target>
          <target>
            <context value="procedure2"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid9"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e9"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Procedure/"/>
            </parameter>
            <parameter>
              <valueId value="uuid9"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Procedure"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Procedure/' + %procedure2.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Procedure"/>
            <variable value="procedure"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="procedure2"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="visiteRicoveri"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '46240-8'"/>
        </source>
        <rule>
          <name value="encounter"/>
          <source>
            <context value="entry"/>
            <element value="encounter"/>
            <variable value="encounter"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e9"/>
          </target>
          <target>
            <context value="e9"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e9"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="encounterF"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Encounter"/>
            </parameter>
          </target>
          <target>
            <context value="encounterF"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid9"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e9"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Encounter/"/>
            </parameter>
            <parameter>
              <valueId value="uuid9"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Encounter"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Encounter/' + %encounterF.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="EncounterFunction"/>
            <variable value="encounter"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="encounterF"/>
            <variable value="bundle"/>
          </dependent>
          <documentation
                         value="entry.encounter as encounter -&gt; enc then{"/>
        </rule>
      </rule>
      <rule>
        <name value="esenzioni"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '57827-8'"/>
        </source>
        <rule>
          <name value="esen"/>
          <source>
            <context value="entry"/>
            <element value="act"/>
            <variable value="act"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e13"/>
          </target>
          <target>
            <context value="e13"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e13"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="coverage"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Coverage"/>
            </parameter>
          </target>
          <target>
            <context value="coverage"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid13"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e13"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Coverage/"/>
            </parameter>
            <parameter>
              <valueId value="uuid13"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Coverage"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Coverage/' + %coverage.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Coverage"/>
            <variable value="act"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="coverage"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="retiPatologia"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = 'PSSIT99'"/>
        </source>
        <rule>
          <name value="OrgAffiliation"/>
          <source>
            <context value="entry"/>
            <element value="act"/>
            <variable value="act"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e14"/>
          </target>
          <target>
            <context value="e14"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e14"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="affiliation"/>
            <transform value="create"/>
            <parameter>
              <valueString value="OrganizationAffiliation"/>
            </parameter>
          </target>
          <target>
            <context value="affiliation"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid14"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e14"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/OrganizationAffiliation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid14"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="OrganizationAffiliation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/OrganizationAffiliation/' + %affiliation.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="OrganizationAffiliation"/>
            <variable value="act"/>
            <variable value="patient"/>
            <variable value="enc"/>
            <variable value="affiliation"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="esiste"/>
      <source>
        <context value="src"/>
        <condition value="src.entry.exists()"/>
      </source>
      <rule>
        <name value="raccoglitore"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '18776-5'"/>
        </source>
        <rule>
          <name value="pianiCura"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e11"/>
          </target>
          <target>
            <context value="e11"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e11"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="careplan"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CarePlan"/>
            </parameter>
          </target>
          <target>
            <context value="careplan"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid11"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e11"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/CarePlan/"/>
            </parameter>
            <parameter>
              <valueId value="uuid11"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="CarePlan"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/CarePlan/' + %careplan.id"/>
            </parameter>
          </target>
          <rule>
            <name value="prestazioni"/>
            <source>
              <context value="src"/>
              <element value="entry"/>
              <variable value="entry"/>
            </source>
            <dependent>
              <name value="CarePlanFunction"/>
              <variable value="entry"/>
              <variable value="careplan"/>
              <variable value="patient"/>
              <variable value="enc"/>
              <variable value="bundle"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="src"/>
        <condition value="src.entry.exists().not()"/>
      </source>
      <rule>
        <name value="familyraccoglitore"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '10157-6'"/>
        </source>
        <rule>
          <name value="family"/>
          <source>
            <context value="src"/>
            <element value="text"/>
            <variable value="text"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e12"/>
          </target>
          <target>
            <context value="e12"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e12"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="familyMember"/>
            <transform value="create"/>
            <parameter>
              <valueString value="FamilyMemberHistory"/>
            </parameter>
          </target>
          <target>
            <context value="familyMember"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid12"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e12"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/FamilyMemberHistory/"/>
            </parameter>
            <parameter>
              <valueId value="uuid12"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="FamilyMemberHistory"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/FamilyMemberHistory/' + %familyMember.id"/>
            </parameter>
          </target>
          <rule>
            <name value="reference"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="familyMember"/>
              <contextType value="variable"/>
              <element value="patient"/>
              <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="'https://example/Patient/' + %patient.id"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="statusS"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="familyMember"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="health-unknown"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="reference"/>
            <source>
              <context value="text"/>
            </source>
            <target>
              <context value="familyMember"/>
              <contextType value="variable"/>
              <element value="note"/>
              <variable value="note"/>
            </target>
            <rule>
              <name value="reference"/>
              <source>
                <context value="text"/>
                <variable value="t"/>
              </source>
              <target>
                <context value="note"/>
                <contextType value="variable"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="t"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="medication"/>
            <source>
              <context value="text"/>
            </source>
            <target>
              <context value="familyMember"/>
              <contextType value="variable"/>
              <element value="relationship"/>
              <variable value="relation"/>
              <transform value="create"/>
              <parameter>
                <valueString value="CodeableConcept"/>
              </parameter>
            </target>
            <rule>
              <name value="text"/>
              <source>
                <context value="text"/>
                <variable value="txt"/>
              </source>
              <target>
                <context value="relation"/>
                <contextType value="variable"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="txt"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <documentation value="Anmanesi Familiare narrativa"/>
      </rule>
      <rule>
        <name value="raccoglitore"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition value="code = '18776-5'"/>
        </source>
        <rule>
          <name value="pianiCura"/>
          <source>
            <context value="src"/>
            <element value="text"/>
            <variable value="text"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e11"/>
          </target>
          <target>
            <context value="e11"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e11"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="careplan"/>
            <transform value="create"/>
            <parameter>
              <valueString value="CarePlan"/>
            </parameter>
          </target>
          <target>
            <context value="careplan"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid11"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e11"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/CarePlan/"/>
            </parameter>
            <parameter>
              <valueId value="uuid11"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="CarePlan"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/CarePlan/' + %careplan.id"/>
            </parameter>
          </target>
          <rule>
            <name value="reference"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="careplan"/>
              <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="'https://example/Patient/' + %patient.id"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="careplan"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="active"/>
              </parameter>
            </target>
            <documentation
                           value="src-&gt; careplan.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;"/>
          </rule>
          <rule>
            <name value="intent"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="careplan"/>
              <contextType value="variable"/>
              <element value="intent"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="order"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="reference"/>
            <source>
              <context value="text"/>
            </source>
            <target>
              <context value="careplan"/>
              <contextType value="variable"/>
              <element value="note"/>
              <variable value="note"/>
            </target>
            <rule>
              <name value="reference"/>
              <source>
                <context value="text"/>
                <variable value="t"/>
              </source>
              <target>
                <context value="note"/>
                <contextType value="variable"/>
                <element value="text"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="t"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <documentation value="Piano di cura narrativa"/>
      </rule>
      <rule>
        <name value="narrative"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <condition
                     value="(code = '30954-2') or (code = '29762-2') or (code = '8716-3') or (code = '47420-5') or (code = '42348-3')"/>
        </source>
        <rule>
          <name value="txtsec"/>
          <source>
            <context value="src"/>
            <element value="text"/>
            <variable value="text"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e13"/>
          </target>
          <target>
            <context value="e13"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e13"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="obs1"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="obs1"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid13"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e13"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Observation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid13"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <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="'https://example/Observation/' + %obs1.id"/>
            </parameter>
          </target>
          <rule>
            <name value="reference"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="obs1"/>
              <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="'https://example/Patient/' + %patient.id"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="obsst"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="obs1"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="preliminary"/>
              </parameter>
            </target>
            <documentation
                           value="src -&gt; obs1.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;"/>
          </rule>
          <rule>
            <name value="obscde"/>
            <source>
              <context value="src"/>
              <element value="code"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="obs1"/>
              <contextType value="variable"/>
              <element value="code"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
          <rule>
            <name value="statusS"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="obs1"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="final"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="narrative"/>
            <source>
              <context value="text"/>
            </source>
            <target>
              <context value="obs1"/>
              <contextType value="variable"/>
              <element value="note"/>
              <variable value="note"/>
            </target>
            <rule>
              <name value="note"/>
              <source>
                <context value="text"/>
                <variable value="t"/>
              </source>
              <target>
                <context value="note"/>
                <contextType value="variable"/>
                <element value="text"/>
                <variable value="textNote"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="string"/>
                </parameter>
              </target>
              <dependent>
                <name value="EDstring"/>
                <variable value="t"/>
                <variable value="textNote"/>
              </dependent>
            </rule>
          </rule>
        </rule>
        <documentation value="sezioni che sono narrative"/>
      </rule>
    </rule>
    <rule>
      <name value="component"/>
      <source>
        <context value="src"/>
        <element value="component"/>
        <variable value="component"/>
      </source>
      <rule>
        <name value="section"/>
        <source>
          <context value="component"/>
          <element value="section"/>
          <variable value="sec"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="section"/>
          <variable value="tgtSection"/>
        </target>
        <dependent>
          <name value="ClinicalDocumentSection"/>
          <variable value="cda"/>
          <variable value="sec"/>
          <variable value="patient"/>
          <variable value="tgtSection"/>
          <variable value="bundle"/>
          <variable value="enc"/>
          <variable value="dReport"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Procedure"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="cdaElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Procedure"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="tx"/>
      <source>
        <context value="src"/>
        <element value="text"/>
        <variable value="tx"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <rule>
        <name value="r"/>
        <source>
          <context value="tx"/>
          <element value="reference"/>
          <variable value="reff"/>
        </source>
        <target>
          <context value="note"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reff.value"/>
          </parameter>
        </target>
      </rule>
      <documentation value="toASK"/>
    </rule>
    <rule>
      <name value="ref"/>
      <source>
        <context value="src"/>
        <element value="templateId"/>
        <condition value="root = '2.16.840.1.113883.2.9.10.1.4.3.10.3'"/>
      </source>
      <rule>
        <name value="effectiveTime"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="performed"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="effectiveTime.value"/>
          </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>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="s"/>
      </source>
      <rule>
        <name value="codeS"/>
        <source>
          <context value="s"/>
          <element value="code"/>
          <variable value="cos"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="cos"/>
          </parameter>
          <parameter>
            <valueString value="#EventStatus"/>
          </parameter>
          <parameter>
            <valueString value="code"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="status2"/>
      <source>
        <context value="src"/>
        <condition value="statusCode.exists().not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="unknown"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="presenzaProtesiImpianto"/>
      <source>
        <context value="src"/>
        <element value="templateId"/>
        <condition value="root = '2.16.840.1.113883.2.9.10.1.4.3.9.1'"/>
      </source>
      <rule>
        <name value="device"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e1"/>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="request"/>
          <transform value="create"/>
          <parameter>
            <valueString value="BackboneElement"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="deviceRes"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Device"/>
          </parameter>
        </target>
        <target>
          <context value="deviceRes"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid1"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="https://example/Device/"/>
          </parameter>
          <parameter>
            <valueId value="uuid1"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Device"/>
          </parameter>
        </target>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="usedReference"/>
          <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="'https://example/Device/' + %deviceRes.id"/>
          </parameter>
        </target>
        <rule>
          <name value="reference"/>
          <source>
            <context value="src"/>
          </source>
          <target>
            <context value="deviceRes"/>
            <contextType value="variable"/>
            <element value="patient"/>
            <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="'https://example/Patient/' + %patient.id"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="src"/>
            <element value="code"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="deviceRes"/>
            <contextType value="variable"/>
            <element value="type"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
      </rule>
      <rule>
        <name value="value1"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
          <condition value="(value.exists())"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="performed"/>
          <variable value="value"/>
          <transform value="create"/>
          <parameter>
            <valueString value="dateTime"/>
          </parameter>
        </target>
        <dependent>
          <name value="TSDateTime"/>
          <variable value="effectiveTime"/>
          <variable value="value"/>
        </dependent>
      </rule>
      <rule>
        <name value="valuePeriod"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
          <condition value="(low.exists())"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="performed"/>
          <variable value="value"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Period"/>
          </parameter>
        </target>
        <dependent>
          <name value="IVLTSPeriod"/>
          <variable value="effectiveTime"/>
          <variable value="value"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="assenza"/>
      <source>
        <context value="src"/>
        <element value="templateId"/>
        <condition value="root = '2.16.840.1.113883.2.9.10.1.4.3.9.2'"/>
      </source>
      <rule>
        <name value="note"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <variable value="code"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="note"/>
          <variable value="note"/>
        </target>
        <rule>
          <name value="text"/>
          <source>
            <context value="code"/>
            <element value="displayName"/>
            <variable value="displayName"/>
          </source>
          <target>
            <context value="note"/>
            <contextType value="variable"/>
            <element value="text"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="displayName"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="procedureTrattamenti"/>
      <source>
        <context value="src"/>
        <element value="templateId"/>
        <condition value="root = '2.16.840.1.113883.2.9.10.1.4.3.11.1'"/>
      </source>
      <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="code"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
      <rule>
        <name value="value1"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
          <condition value="(value.exists())"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="performed"/>
          <variable value="value"/>
          <transform value="create"/>
          <parameter>
            <valueString value="dateTime"/>
          </parameter>
        </target>
        <dependent>
          <name value="TSDateTime"/>
          <variable value="effectiveTime"/>
          <variable value="value"/>
        </dependent>
      </rule>
      <rule>
        <name value="valuePeriod"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
          <condition value="(low.exists())"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="performed"/>
          <variable value="value"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Period"/>
          </parameter>
        </target>
        <dependent>
          <name value="IVLTSPeriod"/>
          <variable value="effectiveTime"/>
          <variable value="value"/>
        </dependent>
      </rule>
      <rule>
        <name value="entryRelProcedure"/>
        <source>
          <context value="src"/>
          <element value="entryRelationship"/>
          <variable value="entryR"/>
        </source>
        <rule>
          <name value="observation"/>
          <source>
            <context value="entryR"/>
            <element value="observation"/>
            <variable value="observation"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e3"/>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="obs1"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="obs1"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid3"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Observation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid3"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="reasonReference"/>
            <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="'https://example/Observation/' + %obs1.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Observation"/>
            <variable value="observation"/>
            <variable value="patient"/>
            <variable value="encounter"/>
            <variable value="obs1"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Observation"/>
    <typeMode value="none"/>
    <input>
      <name value="cda"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ob"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="ob"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="id"/>
      <source>
        <context value="cda"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
      <documentation
                     value="cda-&gt; ob.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="cda"/>
        <element value="code"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="code"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="Stats"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value"/>
      <source>
        <context value="cda"/>
        <type value="ST"/>
        <element value="value"/>
        <variable value="st"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="string"/>
        </parameter>
      </target>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="st.dataString"/>
        </parameter>
      </target>
      <documentation value="value datatype"/>
    </rule>
    <rule>
      <name value="boolean"/>
      <source>
        <context value="cda"/>
        <type value="BL"/>
        <element value="value"/>
        <variable value="boolean"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="boolean.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="intval"/>
      <source>
        <context value="cda"/>
        <type value="INT"/>
        <element value="value"/>
        <variable value="int"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="value"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="int.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="val"/>
      <source>
        <context value="cda"/>
        <type value="CE"/>
        <element value="value"/>
        <variable value="val"/>
      </source>
      <rule>
        <name value="coding"/>
        <source>
          <context value="val"/>
        </source>
        <target>
          <context value="ob"/>
          <contextType value="variable"/>
          <element value="value"/>
          <variable value="ce"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <rule>
          <name value="originalText"/>
          <source>
            <context value="val"/>
            <element value="originalText"/>
            <variable value="originalText"/>
          </source>
          <rule>
            <name value="reference"/>
            <source>
              <context value="originalText"/>
              <element value="reference"/>
              <variable value="reference"/>
            </source>
            <target>
              <context value="ce"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="reference.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="val"/>
          </source>
          <target>
            <context value="ce"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="coding"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="val"/>
              <element value="code"/>
              <variable value="code"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="code"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="codeSystem"/>
            <source>
              <context value="val"/>
              <element value="codeSystem"/>
              <variable value="system"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="system"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="displayName"/>
            <source>
              <context value="val"/>
              <element value="displayName"/>
              <variable value="display"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="display"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="translation"/>
          <source>
            <context value="val"/>
            <element value="translation"/>
            <variable value="translation"/>
          </source>
          <target>
            <context value="ce"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="coding"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="translation"/>
              <element value="code"/>
              <variable value="code"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="code"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="codeSystem"/>
            <source>
              <context value="translation"/>
              <element value="codeSystem"/>
              <variable value="system"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="system"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="displayName"/>
            <source>
              <context value="translation"/>
              <element value="displayName"/>
              <variable value="display"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="display"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="qualifier"/>
            <source>
              <context value="translation"/>
              <element value="qualifier"/>
              <variable value="qualifier"/>
            </source>
            <rule>
              <name value="value"/>
              <source>
                <context value="qualifier"/>
                <element value="value"/>
                <variable value="value"/>
              </source>
              <target>
                <context value="ce"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <variable value="coding"/>
              </target>
              <rule>
                <name value="code"/>
                <source>
                  <context value="value"/>
                  <element value="code"/>
                  <variable value="code"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="cast"/>
                  <parameter>
                    <valueId value="code"/>
                  </parameter>
                  <parameter>
                    <valueString value="string"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeSystem"/>
                <source>
                  <context value="value"/>
                  <element value="codeSystem"/>
                  <variable value="system"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="translate"/>
                  <parameter>
                    <valueId value="system"/>
                  </parameter>
                  <parameter>
                    <valueString
                                 value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
                  </parameter>
                  <parameter>
                    <valueString value="uri"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="displayName"/>
                <source>
                  <context value="value"/>
                  <element value="displayName"/>
                  <variable value="display"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="display"/>
                  <transform value="cast"/>
                  <parameter>
                    <valueId value="display"/>
                  </parameter>
                  <parameter>
                    <valueString value="string"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="val"/>
      <source>
        <context value="cda"/>
        <type value="CD"/>
        <element value="value"/>
        <variable value="val"/>
      </source>
      <rule>
        <name value="coding"/>
        <source>
          <context value="val"/>
        </source>
        <target>
          <context value="ob"/>
          <contextType value="variable"/>
          <element value="value"/>
          <variable value="ce"/>
          <transform value="create"/>
          <parameter>
            <valueString value="CodeableConcept"/>
          </parameter>
        </target>
        <rule>
          <name value="originalText"/>
          <source>
            <context value="val"/>
            <element value="originalText"/>
            <variable value="originalText"/>
          </source>
          <rule>
            <name value="reference"/>
            <source>
              <context value="originalText"/>
              <element value="reference"/>
              <variable value="reference"/>
            </source>
            <target>
              <context value="ce"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="reference.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="val"/>
          </source>
          <target>
            <context value="ce"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="coding"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="val"/>
              <element value="code"/>
              <variable value="code"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="code"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="codeSystem"/>
            <source>
              <context value="val"/>
              <element value="codeSystem"/>
              <variable value="system"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="system"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="displayName"/>
            <source>
              <context value="val"/>
              <element value="displayName"/>
              <variable value="display"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="display"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="translation"/>
          <source>
            <context value="val"/>
            <element value="translation"/>
            <variable value="translation"/>
          </source>
          <target>
            <context value="ce"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="coding"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="translation"/>
              <element value="code"/>
              <variable value="code"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="code"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="codeSystem"/>
            <source>
              <context value="translation"/>
              <element value="codeSystem"/>
              <variable value="system"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="system"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="displayName"/>
            <source>
              <context value="translation"/>
              <element value="displayName"/>
              <variable value="display"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="cast"/>
              <parameter>
                <valueId value="display"/>
              </parameter>
              <parameter>
                <valueString value="string"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="qualifier"/>
            <source>
              <context value="translation"/>
              <element value="qualifier"/>
              <variable value="qualifier"/>
            </source>
            <rule>
              <name value="value"/>
              <source>
                <context value="qualifier"/>
                <element value="value"/>
                <variable value="value"/>
              </source>
              <target>
                <context value="ce"/>
                <contextType value="variable"/>
                <element value="coding"/>
                <variable value="coding"/>
              </target>
              <rule>
                <name value="code"/>
                <source>
                  <context value="value"/>
                  <element value="code"/>
                  <variable value="code"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="cast"/>
                  <parameter>
                    <valueId value="code"/>
                  </parameter>
                  <parameter>
                    <valueString value="string"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="codeSystem"/>
                <source>
                  <context value="value"/>
                  <element value="codeSystem"/>
                  <variable value="system"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="translate"/>
                  <parameter>
                    <valueId value="system"/>
                  </parameter>
                  <parameter>
                    <valueString
                                 value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
                  </parameter>
                  <parameter>
                    <valueString value="uri"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="displayName"/>
                <source>
                  <context value="value"/>
                  <element value="displayName"/>
                  <variable value="display"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="display"/>
                  <transform value="cast"/>
                  <parameter>
                    <valueId value="display"/>
                  </parameter>
                  <parameter>
                    <valueString value="string"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="valueQuantity"/>
      <source>
        <context value="cda"/>
        <type value="PQ"/>
        <element value="value"/>
        <variable value="val"/>
      </source>
      <rule>
        <name value="quantity"/>
        <source>
          <context value="val"/>
        </source>
        <target>
          <context value="ob"/>
          <contextType value="variable"/>
          <element value="value"/>
          <variable value="quantity"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Quantity"/>
          </parameter>
        </target>
        <rule>
          <name value="value"/>
          <source>
            <context value="val"/>
            <element value="value"/>
            <variable value="value"/>
          </source>
          <target>
            <context value="quantity"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="value"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="unit"/>
          <source>
            <context value="val"/>
            <element value="unit"/>
            <variable value="unit"/>
          </source>
          <target>
            <context value="quantity"/>
            <contextType value="variable"/>
            <element value="unit"/>
            <transform value="copy"/>
            <parameter>
              <valueId value="unit"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="value1"/>
      <source>
        <context value="cda"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
        <condition value="(value.exists())"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="valuePeriod"/>
      <source>
        <context value="cda"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
        <condition value="(low.exists())"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Period"/>
        </parameter>
      </target>
      <dependent>
        <name value="IVLTSPeriod"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="note"/>
      <source>
        <context value="cda"/>
        <element value="text"/>
        <variable value="text"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <rule>
        <name value="text"/>
        <source>
          <context value="text"/>
          <element value="reference"/>
          <variable value="reference"/>
        </source>
        <target>
          <context value="note"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reference.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="cda"/>
        <element value="statusCode"/>
        <variable value="s"/>
      </source>
      <rule>
        <name value="codeS"/>
        <source>
          <context value="s"/>
          <element value="code"/>
          <variable value="cos"/>
        </source>
        <target>
          <context value="ob"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="cos"/>
          </parameter>
          <parameter>
            <valueString value="#OBSstatus"/>
          </parameter>
          <parameter>
            <valueString value="code"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="methodCode"/>
      <source>
        <context value="cda"/>
        <element value="methodCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="method"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
      <documentation value="toASK è giusto siano invertiti?"/>
    </rule>
    <rule>
      <name value="interpretationCode"/>
      <source>
        <context value="cda"/>
        <element value="interpretationCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="interpretation"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="targetSiteCode"/>
      <source>
        <context value="cda"/>
        <element value="targetSiteCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="bodySite"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="regrange"/>
      <source>
        <context value="cda"/>
        <element value="referenceRange"/>
        <variable value="refrange"/>
      </source>
      <rule>
        <name value="obsrange"/>
        <source>
          <context value="refrange"/>
          <element value="observationRange"/>
          <variable value="obsrange"/>
        </source>
        <rule>
          <name value="refFhir"/>
          <source>
            <context value="obsrange"/>
            <element value="value"/>
            <variable value="val"/>
          </source>
          <target>
            <context value="ob"/>
            <contextType value="variable"/>
            <element value="referenceRange"/>
            <variable value="refrangeFH"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <rule>
            <name value="de"/>
            <source>
              <context value="val"/>
            </source>
            <target>
              <context value="refrangeFH"/>
              <contextType value="variable"/>
              <element value="low"/>
              <variable value="lowfhir"/>
              <transform value="create"/>
              <parameter>
                <valueString value="SimpleQuantity"/>
              </parameter>
            </target>
            <rule>
              <name value="val"/>
              <source>
                <context value="val"/>
                <element value="low"/>
                <variable value="l"/>
              </source>
              <target>
                <context value="lowfhir"/>
                <contextType value="variable"/>
                <element value="value"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="l.value"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="val"/>
              <source>
                <context value="val"/>
                <element value="low"/>
                <variable value="l"/>
              </source>
              <target>
                <context value="lowfhir"/>
                <contextType value="variable"/>
                <element value="unit"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="l.unit"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="de"/>
            <source>
              <context value="val"/>
            </source>
            <target>
              <context value="refrangeFH"/>
              <contextType value="variable"/>
              <element value="high"/>
              <variable value="highfhir"/>
              <transform value="create"/>
              <parameter>
                <valueString value="SimpleQuantity"/>
              </parameter>
            </target>
            <rule>
              <name value="val"/>
              <source>
                <context value="val"/>
                <element value="high"/>
                <variable value="h"/>
              </source>
              <target>
                <context value="highfhir"/>
                <contextType value="variable"/>
                <element value="value"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="h.value"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="val"/>
              <source>
                <context value="val"/>
                <element value="high"/>
                <variable value="h"/>
              </source>
              <target>
                <context value="highfhir"/>
                <contextType value="variable"/>
                <element value="unit"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="h.unit"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="added"/>
    </rule>
  </group>
  <group>
    <name value="ObservationOrganizer"/>
    <typeMode value="none"/>
    <input>
      <name value="section"/>
      <type value="section"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="cda"/>
      <type value="organizer"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="ob"/>
      <type value="Observation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="ob"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="id"/>
      <source>
        <context value="cda"/>
        <element value="id"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
      <documentation
                     value="cda-&gt; ob.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="code"/>
      <source>
        <context value="section"/>
        <element value="code"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="code"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="Stats"/>
      <source>
        <context value="cda"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value1"/>
      <source>
        <context value="cda"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
        <condition value="(value.exists())"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="valuePeriod"/>
      <source>
        <context value="cda"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
        <condition value="(low.exists())"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Period"/>
        </parameter>
      </target>
      <dependent>
        <name value="IVLTSPeriod"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="note"/>
      <source>
        <context value="cda"/>
        <element value="text"/>
        <variable value="text"/>
      </source>
      <target>
        <context value="ob"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <rule>
        <name value="text"/>
        <source>
          <context value="text"/>
          <element value="reference"/>
          <variable value="reference"/>
        </source>
        <target>
          <context value="note"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reference.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="cda"/>
        <element value="statusCode"/>
        <variable value="s"/>
      </source>
      <rule>
        <name value="codeS"/>
        <source>
          <context value="s"/>
          <element value="code"/>
          <variable value="cos"/>
        </source>
        <target>
          <context value="ob"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="cos"/>
          </parameter>
          <parameter>
            <valueString value="#OBSstatus"/>
          </parameter>
          <parameter>
            <valueString value="code"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="component"/>
      <source>
        <context value="cda"/>
        <element value="component"/>
        <variable value="component"/>
      </source>
      <rule>
        <name value="hasMember"/>
        <source>
          <context value="component"/>
          <element value="observation"/>
          <variable value="observation"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="ei"/>
        </target>
        <target>
          <context value="ei"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="request"/>
          <transform value="create"/>
          <parameter>
            <valueString value="BackboneElement"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="ei"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="obsi"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <target>
          <context value="obsi"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuidi"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="ei"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="https://example/Observation/"/>
          </parameter>
          <parameter>
            <valueId value="uuidi"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <target>
          <context value="ob"/>
          <contextType value="variable"/>
          <element value="hasMember"/>
          <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="'https://example/Observation/' + %obsi.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="Observation"/>
          <variable value="observation"/>
          <variable value="patient"/>
          <variable value="encounter"/>
          <variable value="obsi"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Coverage"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="act"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Coverage"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="beneficiary"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="payor"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="id"/>
      <source>
        <context value="src"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="idf"/>
      </target>
      <rule>
        <name value="ID"/>
        <source>
          <context value="id"/>
        </source>
        <target>
          <context value="idf"/>
          <contextType value="variable"/>
          <element value="value"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="id.root"/>
          </parameter>
        </target>
      </rule>
    </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="sc"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="statusCode"/>
      </source>
      <rule>
        <name value="status"/>
        <source>
          <context value="statusCode"/>
          <element value="code"/>
          <variable value="s"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="s"/>
          </parameter>
          <parameter>
            <valueString value="#FinancialStatus"/>
          </parameter>
          <parameter>
            <valueString value="code"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="statusAbsent"/>
      <source>
        <context value="src"/>
        <condition value="statusCode.exists().not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="active"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value1"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
        <condition value="(value.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="period"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
      <documentation
                     value="src.effectiveTime as effectiveTime -&gt; tgt.period as period then{"/>
    </rule>
    <rule>
      <name value="valuePeriod"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
        <condition value="(low.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="period"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Period"/>
        </parameter>
      </target>
      <dependent>
        <name value="IVLTSPeriod"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="entryr"/>
      <source>
        <context value="src"/>
        <element value="entryRelationship"/>
        <variable value="entryRelationship"/>
      </source>
      <rule>
        <name value="QUI"/>
        <source>
          <context value="entryRelationship"/>
          <element value="act"/>
          <variable value="ac"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="class"/>
          <variable value="class"/>
        </target>
        <rule>
          <name value="ref"/>
          <source>
            <context value="ac"/>
            <element value="text"/>
            <variable value="text"/>
          </source>
          <target>
            <context value="class"/>
            <contextType value="variable"/>
            <element value="type"/>
            <variable value="type"/>
          </target>
          <rule>
            <name value="value"/>
            <source>
              <context value="text"/>
              <element value="reference"/>
              <variable value="reference"/>
            </source>
            <target>
              <context value="type"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="reference.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="note"/>
          <source>
            <context value="ac"/>
          </source>
          <target>
            <context value="class"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="commenti"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="allergyFunction"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="cdaElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="AllergyIntolerance"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="efftime"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="effTime"/>
      </source>
      <rule>
        <name value="value"/>
        <source>
          <context value="effTime"/>
          <element value="low"/>
          <variable value="l"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="recordedDate"/>
          <variable value="r"/>
        </target>
        <dependent>
          <name value="TSDateTime"/>
          <variable value="l"/>
          <variable value="r"/>
        </dependent>
      </rule>
      <documentation
                     value="src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="entryrelationship"/>
      <source>
        <context value="src"/>
        <element value="entryRelationship"/>
        <variable value="entryRelationship1"/>
      </source>
      <rule>
        <name value="observation"/>
        <source>
          <context value="entryRelationship1"/>
          <element value="observation"/>
          <variable value="observation1"/>
        </source>
        <rule>
          <name value="id"/>
          <source>
            <context value="observation1"/>
            <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="Noallergy"/>
          <source>
            <context value="observation1"/>
            <element value="templateId"/>
            <condition value="root = '2.16.840.1.113883.2.9.10.1.4.3.1.4'"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="code"/>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="observation1"/>
            </source>
            <target>
              <context value="code"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="coding"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="observation1"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="No known allergy"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="value1"/>
            <source>
              <context value="src"/>
              <element value="effectiveTime"/>
              <variable value="effectiveTime"/>
              <condition value="(value.exists())"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="onset"/>
              <variable value="value"/>
              <transform value="create"/>
              <parameter>
                <valueString value="dateTime"/>
              </parameter>
            </target>
            <dependent>
              <name value="TSDateTime"/>
              <variable value="effectiveTime"/>
              <variable value="value"/>
            </dependent>
          </rule>
          <rule>
            <name value="valuePeriod"/>
            <source>
              <context value="src"/>
              <element value="effectiveTime"/>
              <variable value="effectiveTime"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="onset"/>
              <variable value="value"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Period"/>
              </parameter>
            </target>
            <dependent>
              <name value="IVLTSPeriod"/>
              <variable value="effectiveTime"/>
              <variable value="value"/>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="value1"/>
          <source>
            <context value="observation1"/>
            <element value="effectiveTime"/>
            <variable value="effectiveTime"/>
            <condition value="(value.exists())"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="onset"/>
            <variable value="value"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="effectiveTime"/>
            <variable value="value"/>
          </dependent>
        </rule>
        <rule>
          <name value="valuePeriod"/>
          <source>
            <context value="observation1"/>
            <element value="effectiveTime"/>
            <variable value="effectiveTime"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="onset"/>
            <variable value="value"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Period"/>
            </parameter>
          </target>
          <dependent>
            <name value="IVLTSPeriod"/>
            <variable value="effectiveTime"/>
            <variable value="value"/>
          </dependent>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="observation1"/>
            <element value="value"/>
            <variable value="code"/>
          </source>
          <rule>
            <name value="type"/>
            <source>
              <context value="code"/>
              <element value="code"/>
              <variable value="code1"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="type"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="code1"/>
              </parameter>
              <parameter>
                <valueString value="#AllergyTypeMap"/>
              </parameter>
              <parameter>
                <valueString value="code"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="category"/>
            <source>
              <context value="code"/>
              <element value="code"/>
              <variable value="code1"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="category"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="code1"/>
              </parameter>
              <parameter>
                <valueString value="#AllergyCategoryMap"/>
              </parameter>
              <parameter>
                <valueString value="code"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="value"/>
          <source>
            <context value="observation1"/>
            <element value="value"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
          <documentation value="toASK qui dovrei fare un controllo sul code"/>
        </rule>
        <rule>
          <name value="participant"/>
          <source>
            <context value="observation1"/>
            <element value="participant"/>
            <variable value="participant"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="reaction"/>
            <variable value="reaction"/>
          </target>
          <rule>
            <name value="entryR2"/>
            <source>
              <context value="observation1"/>
              <element value="entryRelationship"/>
              <variable value="entryRelationship2"/>
              <condition value="(typeCode = 'MFST')"/>
            </source>
            <rule>
              <name value="observ2"/>
              <source>
                <context value="entryRelationship2"/>
                <element value="observation"/>
                <variable value="observation2"/>
              </source>
              <rule>
                <name value="manifestation"/>
                <source>
                  <context value="observation2"/>
                  <element value="value"/>
                  <variable value="vvv"/>
                </source>
                <target>
                  <context value="reaction"/>
                  <contextType value="variable"/>
                  <element value="manifestation"/>
                  <variable value="vvv"/>
                  <transform value="create"/>
                </target>
              </rule>
              <rule>
                <name value="manifestation"/>
                <source>
                  <context value="observation2"/>
                  <element value="code"/>
                  <variable value="vvv"/>
                </source>
                <target>
                  <context value="reaction"/>
                  <contextType value="variable"/>
                  <element value="manifestation"/>
                  <variable value="vvv"/>
                  <transform value="create"/>
                </target>
              </rule>
              <rule>
                <name value="tx"/>
                <source>
                  <context value="observation2"/>
                  <element value="text"/>
                  <variable value="tx"/>
                </source>
                <rule>
                  <name value="tx"/>
                  <source>
                    <context value="tx"/>
                    <element value="reference"/>
                    <variable value="reff"/>
                  </source>
                  <target>
                    <context value="reaction"/>
                    <contextType value="variable"/>
                    <element value="description"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="reff.value"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="low"/>
                <source>
                  <context value="observation2"/>
                  <element value="effectiveTime"/>
                  <variable value="effectiveTime"/>
                </source>
                <rule>
                  <name value="valuePeriodLow"/>
                  <source>
                    <context value="effectiveTime"/>
                    <element value="low"/>
                    <variable value="low"/>
                  </source>
                  <target>
                    <context value="reaction"/>
                    <contextType value="variable"/>
                    <element value="onset"/>
                    <variable value="value"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="dateTime"/>
                    </parameter>
                  </target>
                  <dependent>
                    <name value="TSDateTime"/>
                    <variable value="low"/>
                    <variable value="value"/>
                  </dependent>
                </rule>
                <rule>
                  <name value="valuePeriodHigh"/>
                  <source>
                    <context value="effectiveTime"/>
                    <element value="high"/>
                    <variable value="high"/>
                  </source>
                  <target>
                    <context value="tgt"/>
                    <contextType value="variable"/>
                    <element value="lastOccurrence"/>
                    <variable value="value"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="dateTime"/>
                    </parameter>
                  </target>
                  <dependent>
                    <name value="TSDateTime"/>
                    <variable value="high"/>
                    <variable value="value"/>
                  </dependent>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="participantRole"/>
            <source>
              <context value="participant"/>
              <element value="participantRole"/>
              <variable value="participantRole"/>
            </source>
            <rule>
              <name value="playingEntity"/>
              <source>
                <context value="participantRole"/>
                <element value="playingEntity"/>
                <variable value="playingEntity"/>
              </source>
              <rule>
                <name value="reaction"/>
                <source>
                  <context value="playingEntity"/>
                  <element value="code"/>
                  <variable value="vvv"/>
                </source>
                <target>
                  <context value="reaction"/>
                  <contextType value="variable"/>
                  <element value="substance"/>
                  <variable value="vvv"/>
                  <transform value="create"/>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="entryR2"/>
          <source>
            <context value="observation1"/>
            <element value="entryRelationship"/>
            <variable value="entryRelationship2"/>
            <condition value="(typeCode = 'MFST')"/>
          </source>
          <rule>
            <name value="observ2"/>
            <source>
              <context value="entryRelationship2"/>
              <element value="observation"/>
              <variable value="observation2"/>
              <condition value="observation1.participant.exists().not()"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="reaction"/>
              <variable value="reaction"/>
            </target>
            <rule>
              <name value="manifestation"/>
              <source>
                <context value="observation2"/>
                <element value="value"/>
                <variable value="vvv"/>
              </source>
              <target>
                <context value="reaction"/>
                <contextType value="variable"/>
                <element value="manifestation"/>
                <variable value="vvv"/>
                <transform value="create"/>
              </target>
            </rule>
            <rule>
              <name value="tx"/>
              <source>
                <context value="observation2"/>
                <element value="text"/>
                <variable value="tx"/>
              </source>
              <rule>
                <name value="tx"/>
                <source>
                  <context value="tx"/>
                  <element value="reference"/>
                  <variable value="reff"/>
                </source>
                <target>
                  <context value="reaction"/>
                  <contextType value="variable"/>
                  <element value="description"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="reff.value"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="low"/>
              <source>
                <context value="observation2"/>
                <element value="effectiveTime"/>
                <variable value="effectiveTime"/>
              </source>
              <rule>
                <name value="valuePeriodLow"/>
                <source>
                  <context value="effectiveTime"/>
                  <element value="low"/>
                  <variable value="low"/>
                </source>
                <target>
                  <context value="reaction"/>
                  <contextType value="variable"/>
                  <element value="onset"/>
                  <variable value="value"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="dateTime"/>
                  </parameter>
                </target>
                <dependent>
                  <name value="TSDateTime"/>
                  <variable value="low"/>
                  <variable value="value"/>
                </dependent>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="entryR3"/>
          <source>
            <context value="observation1"/>
            <element value="entryRelationship"/>
            <variable value="entryRelationship3"/>
            <condition value="(typeCode = 'SUBJ')"/>
          </source>
          <rule>
            <name value="observ3"/>
            <source>
              <context value="entryRelationship3"/>
              <element value="observation"/>
              <variable value="observation3"/>
            </source>
            <rule>
              <name value="criticality"/>
              <source>
                <context value="observation3"/>
                <element value="value"/>
                <variable value="value"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="value"/>
                  <element value="code"/>
                  <variable value="c"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="criticality"/>
                  <transform value="translate"/>
                  <parameter>
                    <valueId value="c"/>
                  </parameter>
                  <parameter>
                    <valueString value="#CricalityMap"/>
                  </parameter>
                  <parameter>
                    <valueString value="code"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="act"/>
            <source>
              <context value="entryRelationship3"/>
              <element value="act"/>
              <variable value="act"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="note"/>
              <variable value="note"/>
            </target>
            <rule>
              <name value="note"/>
              <source>
                <context value="act"/>
                <element value="text"/>
                <variable value="text"/>
              </source>
              <rule>
                <name value="reference"/>
                <source>
                  <context value="text"/>
                  <element value="reference"/>
                  <variable value="reference"/>
                </source>
                <target>
                  <context value="note"/>
                  <contextType value="variable"/>
                  <element value="text"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="reference.value"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="entryR4"/>
          <source>
            <context value="observation1"/>
            <element value="entryRelationship"/>
            <variable value="entryRelationship4"/>
            <condition value="(typeCode = 'REFR')"/>
          </source>
          <rule>
            <name value="observ4"/>
            <source>
              <context value="entryRelationship4"/>
              <element value="observation"/>
              <variable value="observation4"/>
            </source>
            <rule>
              <name value="clinicalStatus"/>
              <source>
                <context value="observation4"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="clinicalStatus"/>
                <variable value="clinicalStatus"/>
              </target>
              <rule>
                <name value="value"/>
                <source>
                  <context value="observation4"/>
                  <element value="value"/>
                  <variable value="value"/>
                </source>
                <rule>
                  <name value="coding"/>
                  <source>
                    <context value="value"/>
                    <variable value="valu"/>
                  </source>
                  <target>
                    <context value="clinicalStatus"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="code"/>
                    <source>
                      <context value="valu"/>
                      <condition value="(code = 'LA9041-0')"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="resolved"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="code"/>
                    <source>
                      <context value="valu"/>
                      <condition value="(code = 'LA18632-2')"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="inactive"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="code"/>
                    <source>
                      <context value="valu"/>
                      <condition value="(code = 'LA16666-2')"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="active"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="system"/>
                    <source>
                      <context value="valu"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="display"/>
                    <source>
                      <context value="valu"/>
                      <element value="displayName"/>
                      <variable value="display"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="cast"/>
                      <parameter>
                        <valueId value="display"/>
                      </parameter>
                      <parameter>
                        <valueString value="string"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
              <rule>
                <name value="tx"/>
                <source>
                  <context value="observation4"/>
                  <element value="text"/>
                  <variable value="tx"/>
                </source>
                <rule>
                  <name value="reference"/>
                  <source>
                    <context value="tx"/>
                    <element value="reference"/>
                    <variable value="ref"/>
                  </source>
                  <target>
                    <context value="clinicalStatus"/>
                    <contextType value="variable"/>
                    <element value="text"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="ref.value"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MedicationStatement"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="substanceAdministration"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="MedicationStatement"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
      <documentation
                     value="src -&gt; tgt.context = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <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="note"/>
      <source>
        <context value="src"/>
        <element value="text"/>
        <variable value="text"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <rule>
        <name value="text"/>
        <source>
          <context value="text"/>
          <element value="reference"/>
          <variable value="reference"/>
        </source>
        <target>
          <context value="note"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reference.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="value1"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
        <condition value="(value.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="eff"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="valuePeriod"/>
      <source>
        <context value="src"/>
        <type value="IVL_TS"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Period"/>
        </parameter>
      </target>
      <dependent>
        <name value="IVLTSPeriod"/>
        <variable value="eff"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="dos"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosage"/>
        <variable value="dosage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Dosage"/>
        </parameter>
      </target>
      <rule>
        <name value="eff"/>
        <source>
          <context value="src"/>
          <type value="PIVL_TS"/>
          <element value="effectiveTime"/>
          <variable value="eff"/>
        </source>
        <rule>
          <name value="cod"/>
          <source>
            <context value="eff"/>
          </source>
          <target>
            <context value="dosage"/>
            <contextType value="variable"/>
            <element value="timing"/>
            <variable value="timing"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Timing"/>
            </parameter>
          </target>
          <dependent>
            <name value="periodTiming"/>
            <variable value="eff"/>
            <variable value="timing"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="route"/>
        <source>
          <context value="src"/>
          <condition
                     value="(src.doseQuantity.exists() or src.rateQuantity.exists() or src.routeCode.exists() or src.approachSiteCode.exists())"/>
        </source>
        <rule>
          <name value="doseQuantity"/>
          <source>
            <context value="src"/>
            <element value="doseQuantity"/>
            <variable value="doseQuant"/>
          </source>
          <rule>
            <name value="ot"/>
            <source>
              <context value="doseQuant"/>
              <element value="originalText"/>
              <variable value="ot"/>
            </source>
            <rule>
              <name value="reference"/>
              <source>
                <context value="ot"/>
                <element value="reference"/>
                <variable value="vvv"/>
              </source>
              <target>
                <context value="dosage"/>
                <contextType value="variable"/>
                <element value="text"/>
                <variable value="vvv"/>
                <transform value="create"/>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="dosageRate"/>
            <source>
              <context value="doseQuant"/>
            </source>
            <target>
              <context value="dosage"/>
              <contextType value="variable"/>
              <element value="doseAndRate"/>
              <variable value="dosageRate"/>
            </target>
            <rule>
              <name value="d"/>
              <source>
                <context value="doseQuant"/>
              </source>
              <target>
                <context value="dosageRate"/>
                <contextType value="variable"/>
                <element value="dose"/>
                <variable value="d"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Range"/>
                </parameter>
              </target>
              <rule>
                <name value="low"/>
                <source>
                  <context value="doseQuant"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="low"/>
                  <variable value="l"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="low"/>
                <source>
                  <context value="doseQuant"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="high"/>
                  <variable value="h"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="rate"/>
          <source>
            <context value="src"/>
            <element value="rateQuantity"/>
            <variable value="rateQuantity"/>
          </source>
          <rule>
            <name value="ot"/>
            <source>
              <context value="rateQuantity"/>
              <element value="originalText"/>
              <variable value="ot"/>
            </source>
            <rule>
              <name value="reference"/>
              <source>
                <context value="ot"/>
                <element value="reference"/>
                <variable value="vvv"/>
              </source>
              <target>
                <context value="dosage"/>
                <contextType value="variable"/>
                <element value="text"/>
                <variable value="vvv"/>
                <transform value="create"/>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="dosageRate"/>
            <source>
              <context value="rateQuantity"/>
            </source>
            <target>
              <context value="dosage"/>
              <contextType value="variable"/>
              <element value="doseAndRate"/>
              <variable value="dosageRate"/>
            </target>
            <rule>
              <name value="r"/>
              <source>
                <context value="rateQuantity"/>
              </source>
              <target>
                <context value="dosageRate"/>
                <contextType value="variable"/>
                <element value="rate"/>
                <variable value="d"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Range"/>
                </parameter>
              </target>
              <rule>
                <name value="low"/>
                <source>
                  <context value="rateQuantity"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="low"/>
                  <variable value="l"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="high"/>
                <source>
                  <context value="rateQuantity"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="high"/>
                  <variable value="h"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="route"/>
          <source>
            <context value="src"/>
            <element value="routeCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="dosage"/>
            <contextType value="variable"/>
            <element value="route"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="site"/>
          <source>
            <context value="src"/>
            <element value="approachSiteCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="dosage"/>
            <contextType value="variable"/>
            <element value="site"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="site"/>
          <source>
            <context value="src"/>
            <element value="targetSiteCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="dosage"/>
            <contextType value="variable"/>
            <element value="site"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="consumable"/>
      <source>
        <context value="src"/>
        <element value="consumable"/>
        <variable value="consumable"/>
      </source>
      <rule>
        <name value="medication"/>
        <source>
          <context value="consumable"/>
          <element value="manufacturedProduct"/>
          <variable value="manufacturedProduct"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e1"/>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="request"/>
          <transform value="create"/>
          <parameter>
            <valueString value="BackboneElement"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="medication"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Medication"/>
          </parameter>
        </target>
        <target>
          <context value="medication"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid1"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="https://example/Medication/"/>
          </parameter>
          <parameter>
            <valueId value="uuid1"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Medication"/>
          </parameter>
        </target>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="medication"/>
          <variable value="medref"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="medref"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString
                         value="'https://example/Medication/' + %medication.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="Medication"/>
          <variable value="src"/>
          <variable value="medication"/>
          <variable value="patient"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="periodTiming"/>
    <typeMode value="none"/>
    <input>
      <name value="effectiveTime"/>
      <type value="PIVL_TS"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="timing"/>
      <type value="Timing"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="repeat"/>
      <source>
        <context value="effectiveTime"/>
      </source>
      <target>
        <context value="timing"/>
        <contextType value="variable"/>
        <element value="repeat"/>
        <variable value="r"/>
      </target>
      <rule>
        <name value="period"/>
        <source>
          <context value="effectiveTime"/>
          <element value="period"/>
          <variable value="p"/>
        </source>
        <target>
          <context value="r"/>
          <contextType value="variable"/>
          <element value="period"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="p.value"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="period"/>
        <source>
          <context value="effectiveTime"/>
          <element value="period"/>
          <variable value="p"/>
        </source>
        <target>
          <context value="r"/>
          <contextType value="variable"/>
          <element value="periodUnit"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="p.unit"/>
          </parameter>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Medication"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="substanceAdministration"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Medication"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="consumable"/>
      <source>
        <context value="src"/>
        <element value="consumable"/>
        <variable value="consumable"/>
      </source>
      <rule>
        <name value="product"/>
        <source>
          <context value="consumable"/>
          <element value="manufacturedProduct"/>
          <variable value="manufacturedProduct"/>
        </source>
        <rule>
          <name value="material"/>
          <source>
            <context value="manufacturedProduct"/>
            <element value="manufacturedMaterial"/>
            <variable value="manufacturedMaterial"/>
          </source>
          <rule>
            <name value="CE"/>
            <source>
              <context value="manufacturedMaterial"/>
              <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="form"/>
            <source>
              <context value="src"/>
              <element value="administrationUnitCode"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="form"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="entryR"/>
      <source>
        <context value="src"/>
        <element value="entryRelationship"/>
        <variable value="entryR"/>
      </source>
      <rule>
        <name value="obs"/>
        <source>
          <context value="entryR"/>
          <element value="observation"/>
          <variable value="observation"/>
        </source>
        <rule>
          <name value="ingredient"/>
          <source>
            <context value="observation"/>
            <element value="code"/>
            <condition value="displayName = 'Grammatura'"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="ingredient"/>
            <variable value="ingredient"/>
          </target>
          <rule>
            <name value="consumable"/>
            <source>
              <context value="src"/>
              <element value="consumable"/>
              <variable value="consumable"/>
            </source>
            <rule>
              <name value="product"/>
              <source>
                <context value="consumable"/>
                <element value="manufacturedProduct"/>
                <variable value="manufacturedProduct"/>
              </source>
              <rule>
                <name value="material"/>
                <source>
                  <context value="manufacturedProduct"/>
                  <element value="manufacturedMaterial"/>
                  <variable value="manufacturedMaterial"/>
                </source>
                <rule>
                  <name value="CE"/>
                  <source>
                    <context value="manufacturedMaterial"/>
                    <element value="code"/>
                    <variable value="code"/>
                  </source>
                  <target>
                    <context value="ingredient"/>
                    <contextType value="variable"/>
                    <element value="item"/>
                    <variable value="value"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="CodeableConcept"/>
                    </parameter>
                  </target>
                  <dependent>
                    <name value="CECodeableConcept"/>
                    <variable value="code"/>
                    <variable value="value"/>
                  </dependent>
                </rule>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="strenght"/>
            <source>
              <context value="observation"/>
              <element value="value"/>
              <variable value="value"/>
            </source>
            <target>
              <context value="ingredient"/>
              <contextType value="variable"/>
              <element value="strength"/>
              <variable value="strength"/>
            </target>
            <rule>
              <name value="numerator"/>
              <source>
                <context value="value"/>
              </source>
              <target>
                <context value="strength"/>
                <contextType value="variable"/>
                <element value="numerator"/>
                <variable value="numerator"/>
              </target>
              <rule>
                <name value="valueN"/>
                <source>
                  <context value="value"/>
                </source>
                <target>
                  <context value="numerator"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="value.value"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="denominator"/>
              <source>
                <context value="value"/>
              </source>
              <target>
                <context value="strength"/>
                <contextType value="variable"/>
                <element value="denominator"/>
                <variable value="denominator"/>
              </target>
              <rule>
                <name value="valueD"/>
                <source>
                  <context value="value"/>
                </source>
                <target>
                  <context value="denominator"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueInteger value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="quantita"/>
          <source>
            <context value="observation"/>
            <element value="code"/>
            <condition value="displayName = 'Quantità nella Confezione'"/>
          </source>
          <rule>
            <name value="amount"/>
            <source>
              <context value="observation"/>
              <element value="value"/>
              <variable value="value"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="amount"/>
              <variable value="amount"/>
            </target>
            <rule>
              <name value="numerator"/>
              <source>
                <context value="value"/>
              </source>
              <target>
                <context value="amount"/>
                <contextType value="variable"/>
                <element value="numerator"/>
                <variable value="numerator"/>
              </target>
              <rule>
                <name value="valueN"/>
                <source>
                  <context value="value"/>
                </source>
                <target>
                  <context value="numerator"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="value.value"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="denominator"/>
              <source>
                <context value="value"/>
              </source>
              <target>
                <context value="amount"/>
                <contextType value="variable"/>
                <element value="denominator"/>
                <variable value="denominator"/>
              </target>
              <rule>
                <name value="valueD"/>
                <source>
                  <context value="value"/>
                </source>
                <target>
                  <context value="denominator"/>
                  <contextType value="variable"/>
                  <element value="value"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueInteger value="1"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Immunization"/>
    <typeMode value="none"/>
    <input>
      <name value="substance"/>
      <type value="substanceAdministration"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Immunization"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="patientRef"/>
      <source>
        <context value="substance"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="id"/>
      <source>
        <context value="substance"/>
        <element value="id"/>
        <variable value="id"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="identifier"/>
        <variable value="idf"/>
      </target>
      <rule>
        <name value="root1"/>
        <source>
          <context value="id"/>
          <element value="root"/>
          <variable value="r"/>
        </source>
        <target>
          <context value="idf"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="r"/>
          </parameter>
          <parameter>
            <valueString
                         value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
          </parameter>
          <parameter>
            <valueString value="uri"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="substance -&gt; tgt.encounter  = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;encounterRef&quot;;"/>
    </rule>
    <rule>
      <name value="note"/>
      <source>
        <context value="substance"/>
        <element value="text"/>
        <variable value="text"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <rule>
        <name value="text"/>
        <source>
          <context value="text"/>
          <element value="reference"/>
          <variable value="reference"/>
        </source>
        <target>
          <context value="note"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reference.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="statusCode"/>
      <source>
        <context value="substance"/>
        <element value="statusCode"/>
        <variable value="statusc"/>
        <condition value="(code = 'completed')"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="completed"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="statusCode"/>
      <source>
        <context value="substance"/>
        <element value="statusCode"/>
        <variable value="statusc"/>
        <condition value="(code = 'aborted')"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="statusCode"/>
      <source>
        <context value="substance"/>
        <element value="statusCode"/>
        <variable value="statusc"/>
        <condition value="(code = 'suspended')"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="enterer-in-error"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="statusCode"/>
      <source>
        <context value="substance"/>
        <element value="statusCode"/>
        <variable value="statusc"/>
        <condition value="(code = 'cancelled')"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="not-done"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="efftime"/>
      <source>
        <context value="substance"/>
        <element value="effectiveTime"/>
        <variable value="time"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="occurrence"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="time"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="routeCode"/>
      <source>
        <context value="substance"/>
        <element value="routeCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="route"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="approachSiteCode"/>
      <source>
        <context value="substance"/>
        <element value="approachSiteCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="site"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="q"/>
      <source>
        <context value="substance"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="doseQuantity"/>
        <variable value="quantity"/>
        <transform value="create"/>
        <parameter>
          <valueString value="SimpleQuantity"/>
        </parameter>
      </target>
      <rule>
        <name value="qua"/>
        <source>
          <context value="substance"/>
          <element value="doseQuantity"/>
          <variable value="q"/>
        </source>
        <rule>
          <name value="val"/>
          <source>
            <context value="q"/>
          </source>
          <target>
            <context value="quantity"/>
            <contextType value="variable"/>
            <element value="value"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="q.value"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="uni"/>
          <source>
            <context value="q"/>
          </source>
          <target>
            <context value="quantity"/>
            <contextType value="variable"/>
            <element value="unit"/>
            <transform value="evaluate"/>
            <parameter>
              <valueString value="q.unit"/>
            </parameter>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="cons"/>
      <source>
        <context value="substance"/>
        <element value="consumable"/>
        <variable value="cons"/>
      </source>
      <rule>
        <name value="manufact"/>
        <source>
          <context value="cons"/>
          <element value="manufacturedProduct"/>
          <variable value="manufact"/>
        </source>
        <rule>
          <name value="manufactmat"/>
          <source>
            <context value="manufact"/>
            <element value="manufacturedMaterial"/>
            <variable value="manufactmat"/>
          </source>
          <rule>
            <name value="code"/>
            <source>
              <context value="manufactmat"/>
              <element value="code"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="vaccineCode"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
          <rule>
            <name value="lotNumberText"/>
            <source>
              <context value="manufactmat"/>
              <element value="lotNumberText"/>
              <variable value="t"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="lotNumber"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="t.dataString"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="manufactOrg"/>
          <source>
            <context value="manufact"/>
            <element value="manufacturerOrganization"/>
            <variable value="manufactOrg"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e1"/>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="PUT"/>
            </parameter>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="organization"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Organization"/>
            </parameter>
          </target>
          <rule>
            <name value="identifier"/>
            <source>
              <context value="manufactOrg"/>
              <element value="id"/>
              <variable value="id"/>
            </source>
            <target>
              <context value="organization"/>
              <contextType value="variable"/>
              <element value="identifier"/>
              <variable value="identifier"/>
            </target>
            <rule>
              <name value="root1"/>
              <source>
                <context value="id"/>
                <element value="root"/>
                <variable value="r"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="translate"/>
                <parameter>
                  <valueId value="r"/>
                </parameter>
                <parameter>
                  <valueString
                               value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
                </parameter>
                <parameter>
                  <valueString value="uri"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="ext"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="ext"/>
                </parameter>
              </target>
              <rule>
                <name value="UUID"/>
                <source>
                  <context value="manufactOrg"/>
                </source>
                <target>
                  <context value="request"/>
                  <contextType value="variable"/>
                  <element value="url"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="Organization?identifier="/>
                  </parameter>
                  <parameter>
                    <valueId value="ext"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="assigningAuthorityName"/>
              <source>
                <context value="id"/>
                <element value="assigningAuthorityName"/>
                <variable value="s"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="assigner"/>
                <variable value="a"/>
              </target>
              <target>
                <context value="a"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="s"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="r"/>
              <source>
                <context value="id"/>
                <element value="root"/>
                <variable value="r"/>
              </source>
              <rule>
                <name value="idasi"/>
                <source>
                  <context value="id"/>
                  <element value="extension"/>
                  <variable value="ext"/>
                </source>
                <target>
                  <context value="organization"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="uuid"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="r + '-' + ext"/>
                  </parameter>
                </target>
                <target>
                  <context value="e1"/>
                  <contextType value="variable"/>
                  <element value="fullUrl"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="https://example/"/>
                  </parameter>
                  <parameter>
                    <valueId value="uuid"/>
                  </parameter>
                </target>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="manufacturer"/>
                  <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="'https://example/' + %organization.id"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="name"/>
            <source>
              <context value="manufactOrg"/>
              <element value="name"/>
              <variable value="n"/>
            </source>
            <target>
              <context value="organization"/>
              <contextType value="variable"/>
              <element value="name"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="n.other"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="meta"/>
            <source>
              <context value="manufactOrg"/>
            </source>
            <target>
              <context value="organization"/>
              <contextType value="variable"/>
              <element value="meta"/>
              <variable value="meta"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="manufactOrg"/>
              </source>
              <target>
                <context value="meta"/>
                <contextType value="variable"/>
                <element value="tag"/>
                <variable value="coding"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <rule>
                <name value="system"/>
                <source>
                  <context value="manufactOrg"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://algoritmodiscoring"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="code"/>
                <source>
                  <context value="manufactOrg"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="ClinicalDocument/body/Vaccinazioni/manufacturerOrganization"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="part"/>
      <source>
        <context value="substance"/>
        <element value="participant"/>
        <variable value="part"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e1"/>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="request"/>
        <variable value="request"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="PUT"/>
        </parameter>
      </target>
      <target>
        <context value="e1"/>
        <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="uuid1"/>
        <transform value="uuid"/>
      </target>
      <rule>
        <name value="meta"/>
        <source>
          <context value="part"/>
        </source>
        <target>
          <context value="location"/>
          <contextType value="variable"/>
          <element value="meta"/>
          <variable value="meta"/>
        </target>
        <rule>
          <name value="coding"/>
          <source>
            <context value="part"/>
          </source>
          <target>
            <context value="meta"/>
            <contextType value="variable"/>
            <element value="tag"/>
            <variable value="coding"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Coding"/>
            </parameter>
          </target>
          <rule>
            <name value="system"/>
            <source>
              <context value="part"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="http://algoritmodiscoring"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="part"/>
            </source>
            <target>
              <context value="coding"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="copy"/>
              <parameter>
                <valueString
                             value="ClinicalDocument/body/Vaccinazione/participant"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="role"/>
        <source>
          <context value="part"/>
          <element value="participantRole"/>
          <variable value="partRole"/>
        </source>
        <rule>
          <name value="identifier"/>
          <source>
            <context value="partRole"/>
            <element value="id"/>
            <variable value="id"/>
          </source>
          <target>
            <context value="location"/>
            <contextType value="variable"/>
            <element value="identifier"/>
            <variable value="identifier"/>
          </target>
          <rule>
            <name value="root1"/>
            <source>
              <context value="id"/>
              <element value="root"/>
              <variable value="r"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="r"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="ext"/>
            <source>
              <context value="id"/>
              <element value="extension"/>
              <variable value="ext"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ext"/>
              </parameter>
            </target>
            <rule>
              <name value="UUID"/>
              <source>
                <context value="partRole"/>
              </source>
              <target>
                <context value="request"/>
                <contextType value="variable"/>
                <element value="url"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Location?identifier="/>
                </parameter>
                <parameter>
                  <valueId value="ext"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="assigningAuthorityName"/>
            <source>
              <context value="id"/>
              <element value="assigningAuthorityName"/>
              <variable value="s"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="assigner"/>
              <variable value="a"/>
            </target>
            <target>
              <context value="a"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="s"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="r"/>
            <source>
              <context value="id"/>
              <element value="root"/>
              <variable value="r"/>
            </source>
            <rule>
              <name value="idasi"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="location"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="uuid"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="r + '-' + ext"/>
                </parameter>
              </target>
              <target>
                <context value="e1"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="https://example/Location"/>
                </parameter>
                <parameter>
                  <valueId value="uuid"/>
                </parameter>
              </target>
              <target>
                <context value="tgt"/>
                <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="'https://example/' + %location.id"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="entrirel1"/>
      <source>
        <context value="substance"/>
        <element value="entryRelationship"/>
        <variable value="entrirel1"/>
      </source>
      <rule>
        <name value="obs"/>
        <source>
          <context value="entrirel1"/>
          <element value="observation"/>
          <variable value="obs"/>
        </source>
        <rule>
          <name value="codecontrol"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <condition value="(code = '30973-2')"/>
          </source>
          <rule>
            <name value="val"/>
            <source>
              <context value="obs"/>
            </source>
            <target>
              <context value="tgt"/>
              <contextType value="variable"/>
              <element value="protocolApplied"/>
              <variable value="prot"/>
              <transform value="create"/>
              <parameter>
                <valueString value="BackboneElement"/>
              </parameter>
            </target>
            <rule>
              <name value="value"/>
              <source>
                <context value="obs"/>
                <element value="value"/>
                <variable value="v"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="v"/>
                  <element value="value"/>
                  <variable value="int"/>
                </source>
                <target>
                  <context value="prot"/>
                  <contextType value="variable"/>
                  <element value="doseNumber"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="int.toString()"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="entrirel2"/>
      <source>
        <context value="substance"/>
        <element value="entryRelationship"/>
        <variable value="entrirel2"/>
      </source>
      <rule>
        <name value="obs"/>
        <source>
          <context value="entrirel2"/>
          <element value="observation"/>
          <variable value="obs"/>
        </source>
        <rule>
          <name value="codecontrol"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <condition value="(code = '59781-5')"/>
          </source>
          <rule>
            <name value="value"/>
            <source>
              <context value="obs"/>
              <element value="value"/>
              <variable value="value"/>
            </source>
            <rule>
              <name value="val"/>
              <source>
                <context value="value"/>
                <element value="high"/>
                <variable value="h"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="h"/>
                  <element value="value"/>
                  <variable value="value"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="expirationDate"/>
                  <transform value="truncate"/>
                  <parameter>
                    <valueId value="value"/>
                  </parameter>
                  <parameter>
                    <valueInteger value="10"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="entrirel4"/>
      <source>
        <context value="substance"/>
        <element value="entryRelationship"/>
        <variable value="entrirel4"/>
      </source>
      <rule>
        <name value="obs"/>
        <source>
          <context value="entrirel4"/>
          <element value="observation"/>
          <variable value="obs"/>
        </source>
        <rule>
          <name value="codecontrol"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <condition value="(code = '59785-6')"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e1"/>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="observation"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="observation"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid1"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e1"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Observation/"/>
            </parameter>
            <parameter>
              <valueId value="uuid1"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Observation"/>
            </parameter>
          </target>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="reasonReference"/>
            <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="'https://example/Observation/' + %observation.id"/>
            </parameter>
          </target>
          <rule>
            <name value="observation"/>
            <source>
              <context value="obs"/>
            </source>
            <dependent>
              <name value="Observation1"/>
              <variable value="entrirel4"/>
              <variable value="patient"/>
              <variable value="tgt"/>
              <variable value="bundle"/>
              <variable value="enc"/>
              <variable value="observation"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="entrirel5"/>
      <source>
        <context value="substance"/>
        <element value="entryRelationship"/>
        <variable value="entrirel5"/>
      </source>
      <rule>
        <name value="obs"/>
        <source>
          <context value="entrirel5"/>
          <element value="observation"/>
          <variable value="obs"/>
        </source>
        <rule>
          <name value="codecontrol"/>
          <source>
            <context value="obs"/>
            <element value="code"/>
            <condition value="(code = '75321-0') or (code = '5321-0')"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="reaction"/>
            <variable value="reaction"/>
          </target>
          <rule>
            <name value="observation"/>
            <source>
              <context value="obs"/>
            </source>
            <target>
              <context value="bundle"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable value="e1"/>
            </target>
            <target>
              <context value="e1"/>
              <contextType value="variable"/>
              <element value="request"/>
              <variable value="request"/>
              <transform value="create"/>
              <parameter>
                <valueString value="BackboneElement"/>
              </parameter>
            </target>
            <target>
              <context value="request"/>
              <contextType value="variable"/>
              <element value="method"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="POST"/>
              </parameter>
            </target>
            <target>
              <context value="e1"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="observation"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <target>
              <context value="observation"/>
              <contextType value="variable"/>
              <element value="id"/>
              <variable value="uuid1"/>
              <transform value="uuid"/>
            </target>
            <target>
              <context value="e1"/>
              <contextType value="variable"/>
              <element value="fullUrl"/>
              <transform value="append"/>
              <parameter>
                <valueString value="https://example/Observation/"/>
              </parameter>
              <parameter>
                <valueId value="uuid1"/>
              </parameter>
            </target>
            <target>
              <context value="request"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="Observation"/>
              </parameter>
            </target>
            <target>
              <context value="reaction"/>
              <contextType value="variable"/>
              <element value="detail"/>
              <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="'https://example/Observation/' + %observation.id"/>
              </parameter>
            </target>
            <dependent>
              <name value="Observation"/>
              <variable value="obs"/>
              <variable value="patient"/>
              <variable value="encounter"/>
              <variable value="observation"/>
              <variable value="bundle"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="entrirel5"/>
      <source>
        <context value="substance"/>
        <element value="entryRelationship"/>
        <variable value="entrirel5"/>
      </source>
      <rule>
        <name value="obs"/>
        <source>
          <context value="entrirel5"/>
          <element value="act"/>
          <variable value="act"/>
        </source>
        <rule>
          <name value="note"/>
          <source>
            <context value="act"/>
            <element value="text"/>
            <variable value="tx"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <rule>
            <name value="text"/>
            <source>
              <context value="tx"/>
              <element value="reference"/>
              <variable value="reference"/>
            </source>
            <target>
              <context value="note"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="reference.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="ConditionFunction"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="cdaElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Condition"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <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="reference"/>
      <source>
        <context value="src"/>
      </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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="verifstatus"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="stscode"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="verificationStatus"/>
        <variable value="verifstatus"/>
      </target>
      <rule>
        <name value="coding"/>
        <source>
          <context value="stscode"/>
          <variable value="codeS"/>
        </source>
        <target>
          <context value="verifstatus"/>
          <contextType value="variable"/>
          <element value="coding"/>
          <variable value="coding"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Coding"/>
          </parameter>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="codeS"/>
            <element value="code"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="code"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="confirmed"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="system"/>
          <source>
            <context value="codeS"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="system"/>
            <transform value="copy"/>
            <parameter>
              <valueString
                           value="http://terminology.hl7.org/CodeSystem/condition-ver-status"/>
            </parameter>
          </target>
        </rule>
        <rule>
          <name value="display"/>
          <source>
            <context value="codeS"/>
          </source>
          <target>
            <context value="coding"/>
            <contextType value="variable"/>
            <element value="display"/>
            <transform value="cast"/>
            <parameter>
              <valueString value="Confirmed"/>
            </parameter>
            <parameter>
              <valueString value="string"/>
            </parameter>
          </target>
        </rule>
      </rule>
      <documentation
                     value="src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="onset"/>
      <source>
        <context value="src"/>
        <condition value="entryRelationship.exists().not()"/>
      </source>
      <rule>
        <name value="value1"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
          <condition value="(value.exists())"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="onset"/>
          <variable value="value"/>
          <transform value="create"/>
          <parameter>
            <valueString value="dateTime"/>
          </parameter>
        </target>
        <dependent>
          <name value="TSDateTime"/>
          <variable value="effectiveTime"/>
          <variable value="value"/>
        </dependent>
      </rule>
      <rule>
        <name value="valuePeriod"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectiveTime"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="onset"/>
          <variable value="value"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Period"/>
          </parameter>
        </target>
        <dependent>
          <name value="IVLTSPeriod"/>
          <variable value="effectiveTime"/>
          <variable value="value"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="entryR"/>
      <source>
        <context value="src"/>
        <element value="entryRelationship"/>
        <variable value="entryRelationship"/>
      </source>
      <rule>
        <name value="EntryRelObsevation"/>
        <source>
          <context value="entryRelationship"/>
          <element value="observation"/>
          <variable value="obsentry"/>
        </source>
        <rule>
          <name value="value"/>
          <source>
            <context value="obsentry"/>
            <element value="value"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
          <documentation value="toASK"/>
        </rule>
        <rule>
          <name value="code"/>
          <source>
            <context value="obsentry"/>
            <element value="code"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="category"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="value1"/>
          <source>
            <context value="obsentry"/>
            <element value="effectiveTime"/>
            <variable value="effectiveTime"/>
            <condition value="(value.exists())"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="onset"/>
            <variable value="value"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="effectiveTime"/>
            <variable value="value"/>
          </dependent>
        </rule>
        <rule>
          <name value="valuePeriod"/>
          <source>
            <context value="obsentry"/>
            <element value="effectiveTime"/>
            <variable value="effectiveTime"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="onset"/>
            <variable value="value"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Period"/>
            </parameter>
          </target>
          <dependent>
            <name value="IVLTSPeriod"/>
            <variable value="effectiveTime"/>
            <variable value="value"/>
          </dependent>
        </rule>
        <rule>
          <name value="note"/>
          <source>
            <context value="obsentry"/>
            <element value="text"/>
            <variable value="text"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <rule>
            <name value="text"/>
            <source>
              <context value="text"/>
              <element value="reference"/>
              <variable value="reference"/>
            </source>
            <target>
              <context value="note"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="reference.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="entryR"/>
          <source>
            <context value="obsentry"/>
            <element value="entryRelationship"/>
            <variable value="entryR2"/>
          </source>
          <rule>
            <name value="observation"/>
            <source>
              <context value="entryR2"/>
              <element value="observation"/>
              <variable value="obsentry2"/>
            </source>
            <rule>
              <name value="observation"/>
              <source>
                <context value="obsentry2"/>
                <element value="code"/>
                <condition value="code = '89261-2'"/>
              </source>
              <rule>
                <name value="observation"/>
                <source>
                  <context value="obsentry2"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="evidence"/>
                  <variable value="evidence"/>
                </target>
                <target>
                  <context value="bundle"/>
                  <contextType value="variable"/>
                  <element value="entry"/>
                  <variable value="e1"/>
                </target>
                <target>
                  <context value="e1"/>
                  <contextType value="variable"/>
                  <element value="request"/>
                  <variable value="request"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="BackboneElement"/>
                  </parameter>
                </target>
                <target>
                  <context value="request"/>
                  <contextType value="variable"/>
                  <element value="method"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="POST"/>
                  </parameter>
                </target>
                <target>
                  <context value="e1"/>
                  <contextType value="variable"/>
                  <element value="resource"/>
                  <variable value="obsy"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Observation"/>
                  </parameter>
                </target>
                <target>
                  <context value="obsy"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="uuid1"/>
                  <transform value="uuid"/>
                </target>
                <target>
                  <context value="e1"/>
                  <contextType value="variable"/>
                  <element value="fullUrl"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="https://example/Observation/"/>
                  </parameter>
                  <parameter>
                    <valueId value="uuid1"/>
                  </parameter>
                </target>
                <target>
                  <context value="request"/>
                  <contextType value="variable"/>
                  <element value="url"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="Observation"/>
                  </parameter>
                </target>
                <target>
                  <context value="evidence"/>
                  <contextType value="variable"/>
                  <element value="detail"/>
                  <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="'https://example/Observation/' + %obsy.id"/>
                  </parameter>
                </target>
                <dependent>
                  <name value="Observation"/>
                  <variable value="obsentry2"/>
                  <variable value="patient"/>
                  <variable value="encounter"/>
                  <variable value="obsy"/>
                  <variable value="bundle"/>
                </dependent>
              </rule>
            </rule>
            <rule>
              <name value="clinicalStatus2"/>
              <source>
                <context value="obsentry2"/>
                <element value="code"/>
                <condition value="code = '33999-4'"/>
              </source>
              <rule>
                <name value="clinicalstatus"/>
                <source>
                  <context value="obsentry2"/>
                  <element value="value"/>
                  <variable value="value"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="clinicalStatus"/>
                  <variable value="clinicalstatus"/>
                </target>
                <rule>
                  <name value="coding"/>
                  <source>
                    <context value="value"/>
                    <variable value="val"/>
                  </source>
                  <target>
                    <context value="clinicalstatus"/>
                    <contextType value="variable"/>
                    <element value="coding"/>
                    <variable value="coding"/>
                    <transform value="create"/>
                    <parameter>
                      <valueString value="Coding"/>
                    </parameter>
                  </target>
                  <rule>
                    <name value="code"/>
                    <source>
                      <context value="val"/>
                      <condition value="(code = 'LA9041-0')"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="resolved"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="code"/>
                    <source>
                      <context value="val"/>
                      <condition value="(code = 'LA18632-2')"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="inactive"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="code"/>
                    <source>
                      <context value="val"/>
                      <condition value="(code = 'LA16666-2')"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="code"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString value="active"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="system"/>
                    <source>
                      <context value="val"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="system"/>
                      <transform value="copy"/>
                      <parameter>
                        <valueString
                                     value="http://terminology.hl7.org/CodeSystem/condition-clinical"/>
                      </parameter>
                    </target>
                  </rule>
                  <rule>
                    <name value="display"/>
                    <source>
                      <context value="val"/>
                      <element value="displayName"/>
                      <variable value="display"/>
                    </source>
                    <target>
                      <context value="coding"/>
                      <contextType value="variable"/>
                      <element value="display"/>
                      <transform value="cast"/>
                      <parameter>
                        <valueId value="display"/>
                      </parameter>
                      <parameter>
                        <valueString value="string"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
                <rule>
                  <name value="text"/>
                  <source>
                    <context value="obsentry2"/>
                    <element value="text"/>
                    <variable value="text"/>
                  </source>
                  <rule>
                    <name value="text"/>
                    <source>
                      <context value="text"/>
                      <element value="reference"/>
                      <variable value="reference"/>
                    </source>
                    <target>
                      <context value="clinicalstatus"/>
                      <contextType value="variable"/>
                      <element value="text"/>
                      <transform value="evaluate"/>
                      <parameter>
                        <valueString value="reference.value"/>
                      </parameter>
                    </target>
                  </rule>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="severity"/>
              <source>
                <context value="obsentry2"/>
                <element value="code"/>
                <condition value="code = 'SEV'"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="obsentry2"/>
                  <element value="value"/>
                  <variable value="vvv"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="severity"/>
                  <variable value="vvv"/>
                  <transform value="create"/>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="act"/>
            <source>
              <context value="entryR2"/>
              <element value="act"/>
              <variable value="act"/>
            </source>
            <rule>
              <name value="note"/>
              <source>
                <context value="act"/>
                <element value="text"/>
                <variable value="text"/>
              </source>
              <target>
                <context value="tgt"/>
                <contextType value="variable"/>
                <element value="note"/>
                <variable value="note"/>
              </target>
              <rule>
                <name value="text"/>
                <source>
                  <context value="text"/>
                  <element value="reference"/>
                  <variable value="reference"/>
                </source>
                <target>
                  <context value="note"/>
                  <contextType value="variable"/>
                  <element value="text"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="reference.value"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="FamilyMemberFunction"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="organizer"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="FamilyMemberHistory"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="patient"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="patReference"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="patient"/>
        <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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
    </rule>
    <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="statusCode"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="date"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="effectiveTime"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="date"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="date"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDate"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="relationship"/>
      <source>
        <context value="src"/>
        <element value="subject"/>
        <variable value="subject"/>
      </source>
      <rule>
        <name value="relatedSub"/>
        <source>
          <context value="subject"/>
          <element value="relatedSubject"/>
          <variable value="relatedSubject"/>
        </source>
        <rule>
          <name value="relationshipCode"/>
          <source>
            <context value="relatedSubject"/>
            <element value="code"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="relationship"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="subject"/>
          <source>
            <context value="relatedSubject"/>
            <element value="subject"/>
            <variable value="subject"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="sex"/>
            <variable value="sex"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="subject"/>
              <element value="administrativeGenderCode"/>
              <variable value="administrativeGenderCode"/>
            </source>
            <target>
              <context value="sex"/>
              <contextType value="variable"/>
              <element value="coding"/>
              <variable value="coding"/>
            </target>
            <rule>
              <name value="gender"/>
              <source>
                <context value="administrativeGenderCode"/>
                <element value="code"/>
                <variable value="sexCode"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="translate"/>
                <parameter>
                  <valueId value="sexCode"/>
                </parameter>
                <parameter>
                  <valueString value="#cm-v3-administrative-gender"/>
                </parameter>
                <parameter>
                  <valueString value="code"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="system"/>
              <source>
                <context value="administrativeGenderCode"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="http://hl7.org/fhir/administrative-gender"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="displayName"/>
              <source>
                <context value="administrativeGenderCode"/>
                <element value="displayName"/>
                <variable value="dn"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="dn"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="component"/>
      <source>
        <context value="src"/>
        <element value="component"/>
        <variable value="component"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="condition"/>
        <variable value="condition"/>
      </target>
      <rule>
        <name value="observation"/>
        <source>
          <context value="component"/>
          <element value="observation"/>
          <variable value="observation"/>
        </source>
        <rule>
          <name value="code"/>
          <source>
            <context value="observation"/>
            <element value="code"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="reference"/>
          <source>
            <context value="observation"/>
            <element value="text"/>
            <variable value="text"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="note"/>
            <variable value="note"/>
          </target>
          <rule>
            <name value="value"/>
            <source>
              <context value="text"/>
              <element value="reference"/>
              <variable value="reference"/>
            </source>
            <target>
              <context value="note"/>
              <contextType value="variable"/>
              <element value="text"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="reference.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="statusCode"/>
          <source>
            <context value="observation"/>
            <element value="statusCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="status"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="codeable"/>
          <source>
            <context value="observation"/>
            <element value="value"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="condition"/>
            <contextType value="variable"/>
            <element value="outcome"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
          <documentation
                         value="observation.effectiveTime as effectiveTime -&gt; condition.onset = create('Period') as value then IVLTSPeriod(effectiveTime, value) &quot;valuePeriod&quot;;"/>
        </rule>
        <rule>
          <name value="EntryRel"/>
          <source>
            <context value="observation"/>
            <element value="entryRelationship"/>
            <variable value="entryR"/>
          </source>
          <rule>
            <name value="obser"/>
            <source>
              <context value="entryR"/>
              <element value="observation"/>
              <variable value="obs"/>
            </source>
            <rule>
              <name value="insorgenza"/>
              <source>
                <context value="obs"/>
                <condition value="(code.code = '35267-4')"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="obs"/>
                  <element value="value"/>
                  <variable value="value"/>
                </source>
                <target>
                  <context value="condition"/>
                  <contextType value="variable"/>
                  <element value="onset"/>
                  <variable value="Age"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Age"/>
                  </parameter>
                </target>
                <rule>
                  <name value="age"/>
                  <source>
                    <context value="value"/>
                    <element value="value"/>
                    <variable value="valueAge"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="valueAge"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="unit"/>
                  <source>
                    <context value="value"/>
                    <element value="unit"/>
                    <variable value="unit"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="unit"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="unit"/>
                  <source>
                    <context value="value"/>
                    <element value="unit"/>
                    <variable value="unit"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="unit"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="system"/>
                  <source>
                    <context value="value"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://unitsofmeasure.org"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
            <rule>
              <name value="death"/>
              <source>
                <context value="obs"/>
                <condition value="(code.code = '39016-1')"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="obs"/>
                  <element value="value"/>
                  <variable value="value"/>
                </source>
                <target>
                  <context value="tgt"/>
                  <contextType value="variable"/>
                  <element value="deceased"/>
                  <variable value="Age"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="Age"/>
                  </parameter>
                </target>
                <rule>
                  <name value="age"/>
                  <source>
                    <context value="value"/>
                    <element value="value"/>
                    <variable value="valueAge"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="valueAge"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="unit"/>
                  <source>
                    <context value="value"/>
                    <element value="unit"/>
                    <variable value="unit"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="code"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="unit"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="unit"/>
                  <source>
                    <context value="value"/>
                    <element value="unit"/>
                    <variable value="unit"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueId value="unit"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="system"/>
                  <source>
                    <context value="value"/>
                  </source>
                  <target>
                    <context value="Age"/>
                    <contextType value="variable"/>
                    <element value="system"/>
                    <transform value="copy"/>
                    <parameter>
                      <valueString value="http://unitsofmeasure.org"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="Practitioner"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="performer"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="resurceCreation"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e22"/>
      </target>
      <target>
        <context value="e22"/>
        <contextType value="variable"/>
        <element value="request"/>
        <variable value="request"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="PUT"/>
        </parameter>
      </target>
      <target>
        <context value="e22"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="practitioner1"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Practitioner"/>
        </parameter>
      </target>
      <rule>
        <name value="participant"/>
        <source>
          <context value="src"/>
          <element value="assignedEntity"/>
          <variable value="assignedEntity"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="participant"/>
          <variable value="participant"/>
        </target>
        <rule>
          <name value="value1"/>
          <source>
            <context value="src"/>
            <element value="time"/>
            <variable value="time"/>
            <condition value="(value.exists())"/>
          </source>
          <target>
            <context value="participant"/>
            <contextType value="variable"/>
            <element value="period"/>
            <variable value="value"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="time"/>
            <variable value="value"/>
          </dependent>
        </rule>
        <rule>
          <name value="valuePeriod"/>
          <source>
            <context value="src"/>
            <element value="time"/>
            <variable value="time"/>
            <condition value="(low.exists())"/>
          </source>
          <target>
            <context value="participant"/>
            <contextType value="variable"/>
            <element value="period"/>
            <variable value="value"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Period"/>
            </parameter>
          </target>
          <dependent>
            <name value="IVLTSPeriod"/>
            <variable value="time"/>
            <variable value="value"/>
          </dependent>
        </rule>
        <rule>
          <name value="identifier"/>
          <source>
            <context value="assignedEntity"/>
            <element value="id"/>
            <variable value="id"/>
          </source>
          <target>
            <context value="practitioner1"/>
            <contextType value="variable"/>
            <element value="identifier"/>
            <variable value="identifier"/>
          </target>
          <rule>
            <name value="root1"/>
            <source>
              <context value="id"/>
              <element value="root"/>
              <variable value="r"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="r"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="ext"/>
            <source>
              <context value="id"/>
              <element value="extension"/>
              <variable value="ext"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="ext"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="assigningAuthorityName"/>
            <source>
              <context value="id"/>
              <element value="assigningAuthorityName"/>
              <variable value="s"/>
            </source>
            <target>
              <context value="identifier"/>
              <contextType value="variable"/>
              <element value="assigner"/>
              <variable value="a"/>
            </target>
            <target>
              <context value="a"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="copy"/>
              <parameter>
                <valueId value="s"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="r"/>
            <source>
              <context value="id"/>
              <element value="root"/>
              <variable value="r"/>
            </source>
            <rule>
              <name value="id"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="practitioner1"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="uuid22"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="r + '-' + ext"/>
                </parameter>
              </target>
              <target>
                <context value="e22"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="https://example/Practitioner/"/>
                </parameter>
                <parameter>
                  <valueId value="uuid22"/>
                </parameter>
              </target>
              <target>
                <context value="participant"/>
                <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="'https://example/Practitioner/' + %practitioner1.id"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <documentation
                         value="src.time as time -&gt; participant.period as period then{"/>
        </rule>
        <rule>
          <name value="2.16.840.1.113883.2.9.4.3.2"/>
          <source>
            <context value="assignedEntity"/>
            <element value="id"/>
            <variable value="id"/>
            <condition value="(root = '2.16.840.1.113883.2.9.4.3.2')"/>
          </source>
          <rule>
            <name value="UUID"/>
            <source>
              <context value="id"/>
              <element value="extension"/>
              <variable value="ext"/>
            </source>
            <target>
              <context value="request"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="append"/>
              <parameter>
                <valueString value="Practitioner?identifier="/>
              </parameter>
              <parameter>
                <valueId value="ext"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="diverso"/>
          <source>
            <context value="assignedEntity"/>
            <element value="id"/>
            <variable value="id"/>
            <condition value="(root != '2.16.840.1.113883.2.9.4.3.2')"/>
          </source>
          <rule>
            <name value="UUID"/>
            <source>
              <context value="id"/>
              <element value="extension"/>
              <variable value="ext"/>
            </source>
            <target>
              <context value="request"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="append"/>
              <parameter>
                <valueString value="Practitioner?identifier="/>
              </parameter>
              <parameter>
                <valueId value="ext"/>
              </parameter>
            </target>
          </rule>
        </rule>
        <rule>
          <name value="meta"/>
          <source>
            <context value="assignedEntity"/>
          </source>
          <target>
            <context value="practitioner1"/>
            <contextType value="variable"/>
            <element value="meta"/>
            <variable value="meta"/>
          </target>
          <rule>
            <name value="coding"/>
            <source>
              <context value="src"/>
            </source>
            <target>
              <context value="meta"/>
              <contextType value="variable"/>
              <element value="tag"/>
              <variable value="coding"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Coding"/>
              </parameter>
            </target>
            <rule>
              <name value="system"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="http://algoritmodiscoring"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="code"/>
              <source>
                <context value="src"/>
              </source>
              <target>
                <context value="coding"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="copy"/>
                <parameter>
                  <valueString
                               value="ClinicalDocument/body/VisiteRicoveri/performer/"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="addr"/>
          <source>
            <context value="assignedEntity"/>
            <element value="addr"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="practitioner1"/>
            <contextType value="variable"/>
            <element value="address"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="telecom"/>
          <source>
            <context value="assignedEntity"/>
            <element value="telecom"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="practitioner1"/>
            <contextType value="variable"/>
            <element value="telecom"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="partname"/>
          <source>
            <context value="assignedEntity"/>
            <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="practitioner1"/>
              <contextType value="variable"/>
              <element value="name"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
          <rule>
            <name value="birthTime"/>
            <source>
              <context value="person"/>
              <element value="birthTime"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="practitioner1"/>
              <contextType value="variable"/>
              <element value="birthDate"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="CarePlanFunction"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="entry"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="CarePlan"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </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="unknown"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="intent"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="intent"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="plan"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="activityIni"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="activity"/>
        <variable value="activity"/>
      </target>
      <rule>
        <name value="detail"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="activity"/>
          <contextType value="variable"/>
          <element value="detail"/>
          <variable value="detail"/>
        </target>
        <rule>
          <name value="entryObs"/>
          <source>
            <context value="src"/>
            <element value="observation"/>
            <variable value="observation"/>
          </source>
          <rule>
            <name value="activity"/>
            <source>
              <context value="observation"/>
            </source>
            <rule>
              <name value="status"/>
              <source>
                <context value="observation"/>
              </source>
              <target>
                <context value="detail"/>
                <contextType value="variable"/>
                <element value="status"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="unknown"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="obs1"/>
              <source>
                <context value="observation"/>
              </source>
              <target>
                <context value="bundle"/>
                <contextType value="variable"/>
                <element value="entry"/>
                <variable value="e1"/>
              </target>
              <target>
                <context value="e1"/>
                <contextType value="variable"/>
                <element value="request"/>
                <variable value="request"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="BackboneElement"/>
                </parameter>
              </target>
              <target>
                <context value="request"/>
                <contextType value="variable"/>
                <element value="method"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="POST"/>
                </parameter>
              </target>
              <target>
                <context value="e1"/>
                <contextType value="variable"/>
                <element value="resource"/>
                <variable value="obs1"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Observation"/>
                </parameter>
              </target>
              <target>
                <context value="obs1"/>
                <contextType value="variable"/>
                <element value="id"/>
                <variable value="uuid1"/>
                <transform value="uuid"/>
              </target>
              <target>
                <context value="e1"/>
                <contextType value="variable"/>
                <element value="fullUrl"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="https://example/Observation/"/>
                </parameter>
                <parameter>
                  <valueId value="uuid1"/>
                </parameter>
              </target>
              <target>
                <context value="request"/>
                <contextType value="variable"/>
                <element value="url"/>
                <transform value="copy"/>
                <parameter>
                  <valueString value="Observation"/>
                </parameter>
              </target>
              <target>
                <context value="detail"/>
                <contextType value="variable"/>
                <element value="reasonReference"/>
                <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="'https://example/Observation/' + %obs1.id"/>
                </parameter>
              </target>
              <dependent>
                <name value="Observation"/>
                <variable value="observation"/>
                <variable value="patient"/>
                <variable value="encounter"/>
                <variable value="obs1"/>
                <variable value="bundle"/>
              </dependent>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="entrySub"/>
          <source>
            <context value="src"/>
            <element value="substanceAdministration"/>
            <variable value="substanceAdministration"/>
          </source>
          <target>
            <context value="tgt"/>
            <contextType value="variable"/>
            <element value="activity"/>
            <variable value="activity"/>
          </target>
          <rule>
            <name value="Terapie"/>
            <source>
              <context value="substanceAdministration"/>
            </source>
            <target>
              <context value="bundle"/>
              <contextType value="variable"/>
              <element value="entry"/>
              <variable value="e2"/>
            </target>
            <target>
              <context value="e2"/>
              <contextType value="variable"/>
              <element value="request"/>
              <variable value="request"/>
              <transform value="create"/>
              <parameter>
                <valueString value="BackboneElement"/>
              </parameter>
            </target>
            <target>
              <context value="request"/>
              <contextType value="variable"/>
              <element value="method"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="POST"/>
              </parameter>
            </target>
            <target>
              <context value="e2"/>
              <contextType value="variable"/>
              <element value="resource"/>
              <variable value="medre1"/>
              <transform value="create"/>
              <parameter>
                <valueString value="MedicationRequest"/>
              </parameter>
            </target>
            <target>
              <context value="medre1"/>
              <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="https://example/MedicationRequest/"/>
              </parameter>
              <parameter>
                <valueId value="uuid2"/>
              </parameter>
            </target>
            <target>
              <context value="request"/>
              <contextType value="variable"/>
              <element value="url"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="MedicationRequest"/>
              </parameter>
            </target>
            <target>
              <context value="activity"/>
              <contextType value="variable"/>
              <element value="reference"/>
              <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="'https://example/MedicationRequest/' + %medre1.id"/>
              </parameter>
            </target>
            <dependent>
              <name value="MedicationRequest"/>
              <variable value="substanceAdministration"/>
              <variable value="patient"/>
              <variable value="encounter"/>
              <variable value="medre1"/>
              <variable value="bundle"/>
            </dependent>
          </rule>
        </rule>
        <rule>
          <name value="proc"/>
          <source>
            <context value="src"/>
            <element value="procedure"/>
            <variable value="procedureC"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e8"/>
          </target>
          <target>
            <context value="e8"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e8"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="procedure"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Procedure"/>
            </parameter>
          </target>
          <target>
            <context value="procedure"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid8"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e8"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Procedure/"/>
            </parameter>
            <parameter>
              <valueId value="uuid8"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Procedure"/>
            </parameter>
          </target>
          <target>
            <context value="activity"/>
            <contextType value="variable"/>
            <element value="outcomeReference"/>
            <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="'https://example/Procedure/' + %procedure.id"/>
            </parameter>
          </target>
          <dependent>
            <name value="Procedure"/>
            <variable value="procedureC"/>
            <variable value="patient"/>
            <variable value="encounter"/>
            <variable value="procedure"/>
            <variable value="bundle"/>
          </dependent>
        </rule>
        <rule>
          <name value="viste"/>
          <source>
            <context value="src"/>
            <element value="encounter"/>
            <variable value="encounterCDA"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e3"/>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="POST"/>
            </parameter>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="encounterFHIR"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Encounter"/>
            </parameter>
          </target>
          <target>
            <context value="encounterFHIR"/>
            <contextType value="variable"/>
            <element value="id"/>
            <variable value="uuid3"/>
            <transform value="uuid"/>
          </target>
          <target>
            <context value="e3"/>
            <contextType value="variable"/>
            <element value="fullUrl"/>
            <transform value="append"/>
            <parameter>
              <valueString value="https://example/Encounter/"/>
            </parameter>
            <parameter>
              <valueId value="uuid3"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="url"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="Encounter"/>
            </parameter>
          </target>
          <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="'https://example/Encounter/' + %encounterFHIR.id"/>
            </parameter>
          </target>
          <rule>
            <name value="refPatient"/>
            <source>
              <context value="encounterCDA"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <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="'https://example/Patient/' + %patient.id"/>
              </parameter>
            </target>
            <documentation
                           value="encounterCDA -&gt; encounterFHIR.partOf = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;encounterHeader&quot;;"/>
          </rule>
          <rule>
            <name value="id"/>
            <source>
              <context value="encounterCDA"/>
              <element value="id"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <contextType value="variable"/>
              <element value="identifier"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
          <rule>
            <name value="statusCode"/>
            <source>
              <context value="encounterCDA"/>
              <element value="statusCode"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <contextType value="variable"/>
              <element value="status"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="encounterCDA"/>
              <condition value="statusCode.exists().not()"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="unknown"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="class"/>
            <source>
              <context value="encounterCDA"/>
              <element value="code"/>
              <variable value="code"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <contextType value="variable"/>
              <element value="class"/>
              <variable value="class"/>
            </target>
            <rule>
              <name value="code"/>
              <source>
                <context value="code"/>
                <element value="code"/>
                <variable value="code"/>
              </source>
              <target>
                <context value="class"/>
                <contextType value="variable"/>
                <element value="code"/>
                <transform value="cast"/>
                <parameter>
                  <valueId value="code"/>
                </parameter>
                <parameter>
                  <valueString value="string"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="codeSystem"/>
              <source>
                <context value="code"/>
                <element value="codeSystem"/>
                <variable value="system"/>
              </source>
              <target>
                <context value="class"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="translate"/>
                <parameter>
                  <valueId value="system"/>
                </parameter>
                <parameter>
                  <valueString
                               value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
                </parameter>
                <parameter>
                  <valueString value="uri"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="displayName"/>
              <source>
                <context value="code"/>
                <element value="displayName"/>
                <variable value="display"/>
              </source>
              <target>
                <context value="class"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="cast"/>
                <parameter>
                  <valueId value="display"/>
                </parameter>
                <parameter>
                  <valueString value="string"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="text"/>
            <source>
              <context value="encounterCDA"/>
              <element value="text"/>
              <variable value="text"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <contextType value="variable"/>
              <element value="type"/>
              <variable value="type"/>
            </target>
            <rule>
              <name value="value"/>
              <source>
                <context value="text"/>
                <element value="reference"/>
                <variable value="reference"/>
              </source>
              <target>
                <context value="type"/>
                <contextType value="variable"/>
                <element value="text"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="reference.value"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="efft"/>
            <source>
              <context value="encounterCDA"/>
              <element value="effectiveTime"/>
              <variable value="effectiveTime"/>
            </source>
            <target>
              <context value="encounterFHIR"/>
              <contextType value="variable"/>
              <element value="period"/>
              <variable value="period"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Period"/>
              </parameter>
            </target>
            <rule>
              <name value="val"/>
              <source>
                <context value="effectiveTime"/>
              </source>
              <target>
                <context value="period"/>
                <contextType value="variable"/>
                <element value="start"/>
                <variable value="start"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="dateTime"/>
                </parameter>
              </target>
              <dependent>
                <name value="TSDateTime"/>
                <variable value="effectiveTime"/>
                <variable value="start"/>
              </dependent>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="act"/>
          <source>
            <context value="src"/>
            <element value="act"/>
            <variable value="act"/>
          </source>
          <rule>
            <name value="id"/>
            <source>
              <context value="act"/>
              <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="act"/>
              <element value="code"/>
              <variable value="vvv"/>
            </source>
            <target>
              <context value="activity"/>
              <contextType value="variable"/>
              <element value="outcomeCodeableConcept"/>
              <variable value="vvv"/>
              <transform value="create"/>
            </target>
          </rule>
          <rule>
            <name value="text"/>
            <source>
              <context value="act"/>
              <element value="text"/>
              <variable value="text"/>
            </source>
            <target>
              <context value="activity"/>
              <contextType value="variable"/>
              <element value="progress"/>
              <variable value="progress"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Annotation"/>
              </parameter>
            </target>
            <rule>
              <name value="value"/>
              <source>
                <context value="text"/>
                <element value="reference"/>
                <variable value="reference"/>
              </source>
              <target>
                <context value="progress"/>
                <contextType value="variable"/>
                <element value="text"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="reference.value"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="efft"/>
            <source>
              <context value="act"/>
              <element value="effectiveTime"/>
              <variable value="effectiveTime"/>
            </source>
            <target>
              <context value="detail"/>
              <contextType value="variable"/>
              <element value="scheduled"/>
              <variable value="period"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Period"/>
              </parameter>
            </target>
            <rule>
              <name value="val"/>
              <source>
                <context value="effectiveTime"/>
              </source>
              <target>
                <context value="period"/>
                <contextType value="variable"/>
                <element value="start"/>
                <variable value="start"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="dateTime"/>
                </parameter>
              </target>
              <dependent>
                <name value="TSDateTime"/>
                <variable value="effectiveTime"/>
                <variable value="start"/>
              </dependent>
            </rule>
          </rule>
          <rule>
            <name value="status"/>
            <source>
              <context value="act"/>
            </source>
            <target>
              <context value="detail"/>
              <contextType value="variable"/>
              <element value="status"/>
              <transform value="copy"/>
              <parameter>
                <valueString value="completed"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
  <group>
    <name value="MedicationRequest"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="substanceAdministration"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="MedicationRequest"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </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="'https://example/Patient/' + %patient.id"/>
        </parameter>
      </target>
      <documentation value="default  + mandatory"/>
    </rule>
    <rule>
      <name value="intent"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="intent"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="order"/>
        </parameter>
      </target>
      <documentation
                     value="src -&gt; tgt.encounter = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %encounter.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="st"/>
      <source>
        <context value="src"/>
        <condition value="statusCode.exists().not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="unknown"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="sc"/>
      </source>
      <rule>
        <name value="codeS"/>
        <source>
          <context value="sc"/>
          <element value="code"/>
          <variable value="cos"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="status"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="cos"/>
          </parameter>
          <parameter>
            <valueString value="#MedicationStatusMap"/>
          </parameter>
          <parameter>
            <valueString value="code"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <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="note"/>
      <source>
        <context value="src"/>
        <element value="text"/>
        <variable value="txt"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="note"/>
        <variable value="note"/>
      </target>
      <rule>
        <name value="text"/>
        <source>
          <context value="txt"/>
          <element value="reference"/>
          <variable value="reference"/>
        </source>
        <target>
          <context value="note"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reference.value"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="period"/>
      <source>
        <context value="src"/>
        <type value="IVL_TS"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosageInstruction"/>
        <variable value="dosage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Dosage"/>
        </parameter>
      </target>
      <rule>
        <name value="timing"/>
        <source>
          <context value="eff"/>
        </source>
        <target>
          <context value="dosage"/>
          <contextType value="variable"/>
          <element value="timing"/>
          <variable value="timing"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Timing"/>
          </parameter>
        </target>
        <rule>
          <name value="rep"/>
          <source>
            <context value="eff"/>
          </source>
          <target>
            <context value="timing"/>
            <contextType value="variable"/>
            <element value="repeat"/>
            <variable value="rep"/>
          </target>
          <rule>
            <name value="valuePeriod"/>
            <source>
              <context value="eff"/>
            </source>
            <target>
              <context value="rep"/>
              <contextType value="variable"/>
              <element value="bounds"/>
              <variable value="value"/>
              <transform value="create"/>
              <parameter>
                <valueString value="Period"/>
              </parameter>
            </target>
            <dependent>
              <name value="IVLTSPeriod"/>
              <variable value="eff"/>
              <variable value="value"/>
            </dependent>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="period"/>
      <source>
        <context value="src"/>
        <type value="EIVL_TS"/>
        <element value="effectiveTime"/>
        <variable value="effe"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosageInstruction"/>
        <variable value="dosage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Dosage"/>
        </parameter>
      </target>
      <rule>
        <name value="timing"/>
        <source>
          <context value="effe"/>
        </source>
        <target>
          <context value="dosage"/>
          <contextType value="variable"/>
          <element value="timing"/>
          <variable value="timing"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Timing"/>
          </parameter>
        </target>
        <rule>
          <name value="rep"/>
          <source>
            <context value="effe"/>
          </source>
          <target>
            <context value="timing"/>
            <contextType value="variable"/>
            <element value="repeat"/>
            <variable value="rep"/>
          </target>
          <rule>
            <name value="eventCode"/>
            <source>
              <context value="effe"/>
              <element value="eventCode"/>
              <variable value="ev"/>
            </source>
            <target>
              <context value="rep"/>
              <contextType value="variable"/>
              <element value="when"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="ev.code"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="tim"/>
      <source>
        <context value="src"/>
        <type value="IVL_TS"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosageInstruction"/>
        <variable value="dosage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Dosage"/>
        </parameter>
      </target>
      <target>
        <context value="dosage"/>
        <contextType value="variable"/>
        <element value="timing"/>
        <variable value="timing"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Timing"/>
        </parameter>
      </target>
      <target>
        <context value="timing"/>
        <contextType value="variable"/>
        <element value="event"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString value="eff.value"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="eff"/>
      <source>
        <context value="src"/>
        <type value="PIVL_TS"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="dosageInstruction"/>
        <variable value="dosage"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Dosage"/>
        </parameter>
      </target>
      <rule>
        <name value="cod"/>
        <source>
          <context value="eff"/>
        </source>
        <target>
          <context value="dosage"/>
          <contextType value="variable"/>
          <element value="timing"/>
          <variable value="timing"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Timing"/>
          </parameter>
        </target>
        <dependent>
          <name value="periodTiming"/>
          <variable value="eff"/>
          <variable value="timing"/>
        </dependent>
      </rule>
    </rule>
    <rule>
      <name value="condition"/>
      <source>
        <context value="src"/>
        <condition
                   value="(src.doseQuantity.exists() or src.rateQuantity.exists())"/>
      </source>
      <rule>
        <name value="dosageIn"/>
        <source>
          <context value="src"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="dosageInstruction"/>
          <variable value="dosageInstruction"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Dosage"/>
          </parameter>
        </target>
        <rule>
          <name value="doseQuantity"/>
          <source>
            <context value="src"/>
            <element value="doseQuantity"/>
            <variable value="doseQuant"/>
          </source>
          <rule>
            <name value="ot"/>
            <source>
              <context value="doseQuant"/>
              <element value="originalText"/>
              <variable value="ot"/>
            </source>
            <rule>
              <name value="reference"/>
              <source>
                <context value="ot"/>
                <element value="reference"/>
                <variable value="vvv"/>
              </source>
              <target>
                <context value="dosageInstruction"/>
                <contextType value="variable"/>
                <element value="text"/>
                <variable value="vvv"/>
                <transform value="create"/>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="dosageRate"/>
            <source>
              <context value="doseQuant"/>
            </source>
            <target>
              <context value="dosageInstruction"/>
              <contextType value="variable"/>
              <element value="doseAndRate"/>
              <variable value="dosageRate"/>
            </target>
            <rule>
              <name value="d"/>
              <source>
                <context value="doseQuant"/>
              </source>
              <target>
                <context value="dosageRate"/>
                <contextType value="variable"/>
                <element value="dose"/>
                <variable value="d"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Range"/>
                </parameter>
              </target>
              <rule>
                <name value="low"/>
                <source>
                  <context value="doseQuant"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="low"/>
                  <variable value="l"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="low"/>
                <source>
                  <context value="doseQuant"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="high"/>
                  <variable value="h"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="doseQuant"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="rate"/>
          <source>
            <context value="src"/>
            <element value="rateQuantity"/>
            <variable value="rateQuantity"/>
          </source>
          <rule>
            <name value="ot"/>
            <source>
              <context value="rateQuantity"/>
              <element value="originalText"/>
              <variable value="ot"/>
            </source>
            <rule>
              <name value="reference"/>
              <source>
                <context value="ot"/>
                <element value="reference"/>
                <variable value="vvv"/>
              </source>
              <target>
                <context value="dosageInstruction"/>
                <contextType value="variable"/>
                <element value="text"/>
                <variable value="vvv"/>
                <transform value="create"/>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="dosageRate"/>
            <source>
              <context value="rateQuantity"/>
            </source>
            <target>
              <context value="dosageInstruction"/>
              <contextType value="variable"/>
              <element value="doseAndRate"/>
              <variable value="dosageRate"/>
            </target>
            <rule>
              <name value="r"/>
              <source>
                <context value="rateQuantity"/>
              </source>
              <target>
                <context value="dosageRate"/>
                <contextType value="variable"/>
                <element value="rate"/>
                <variable value="d"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Range"/>
                </parameter>
              </target>
              <rule>
                <name value="low"/>
                <source>
                  <context value="rateQuantity"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="low"/>
                  <variable value="l"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="low"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="low"/>
                    <variable value="lo"/>
                  </source>
                  <target>
                    <context value="l"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="lo.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
              <rule>
                <name value="high"/>
                <source>
                  <context value="rateQuantity"/>
                </source>
                <target>
                  <context value="d"/>
                  <contextType value="variable"/>
                  <element value="high"/>
                  <variable value="h"/>
                  <transform value="create"/>
                  <parameter>
                    <valueString value="SimpleQuantity"/>
                  </parameter>
                </target>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="value"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.value"/>
                    </parameter>
                  </target>
                </rule>
                <rule>
                  <name value="high"/>
                  <source>
                    <context value="rateQuantity"/>
                    <element value="high"/>
                    <variable value="hi"/>
                  </source>
                  <target>
                    <context value="h"/>
                    <contextType value="variable"/>
                    <element value="unit"/>
                    <transform value="evaluate"/>
                    <parameter>
                      <valueString value="hi.unit"/>
                    </parameter>
                  </target>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
        <rule>
          <name value="route"/>
          <source>
            <context value="src"/>
            <element value="routeCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="dosageInstruction"/>
            <contextType value="variable"/>
            <element value="route"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="site"/>
          <source>
            <context value="src"/>
            <element value="approachSiteCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="dosageInstruction"/>
            <contextType value="variable"/>
            <element value="site"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="site"/>
          <source>
            <context value="src"/>
            <element value="targetSiteCode"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="dosageInstruction"/>
            <contextType value="variable"/>
            <element value="site"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="medication"/>
      <source>
        <context value="src"/>
        <element value="consumable"/>
        <variable value="consumable"/>
      </source>
      <target>
        <context value="bundle"/>
        <contextType value="variable"/>
        <element value="entry"/>
        <variable value="e1"/>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="request"/>
        <variable value="request"/>
        <transform value="create"/>
        <parameter>
          <valueString value="BackboneElement"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="method"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="POST"/>
        </parameter>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="resource"/>
        <variable value="medication"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Medication"/>
        </parameter>
      </target>
      <target>
        <context value="medication"/>
        <contextType value="variable"/>
        <element value="id"/>
        <variable value="uuid1"/>
        <transform value="uuid"/>
      </target>
      <target>
        <context value="e1"/>
        <contextType value="variable"/>
        <element value="fullUrl"/>
        <transform value="append"/>
        <parameter>
          <valueString value="https://example/Medication/"/>
        </parameter>
        <parameter>
          <valueId value="uuid1"/>
        </parameter>
      </target>
      <target>
        <context value="request"/>
        <contextType value="variable"/>
        <element value="url"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="Medication"/>
        </parameter>
      </target>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="medication"/>
        <variable value="medref"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Reference"/>
        </parameter>
      </target>
      <target>
        <context value="medref"/>
        <contextType value="variable"/>
        <element value="reference"/>
        <transform value="evaluate"/>
        <parameter>
          <valueString
                       value="'https://example/Medication/' + %medication.id"/>
        </parameter>
      </target>
      <dependent>
        <name value="Medication"/>
        <variable value="src"/>
        <variable value="medication"/>
        <variable value="patient"/>
        <variable value="bundle"/>
      </dependent>
    </rule>
    <rule>
      <name value="entryR"/>
      <source>
        <context value="src"/>
        <element value="entryRelationship"/>
        <variable value="entryRelationship"/>
      </source>
      <rule>
        <name value="supply"/>
        <source>
          <context value="entryRelationship"/>
          <element value="supply"/>
          <variable value="supply"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="dispenseRequest"/>
          <variable value="dispenseRequest"/>
        </target>
        <rule>
          <name value="quantity"/>
          <source>
            <context value="supply"/>
            <element value="quantity"/>
            <variable value="quantityCDA"/>
          </source>
          <target>
            <context value="dispenseRequest"/>
            <contextType value="variable"/>
            <element value="quantity"/>
            <variable value="quantityFHIR"/>
          </target>
          <rule>
            <name value="value"/>
            <source>
              <context value="quantityCDA"/>
            </source>
            <target>
              <context value="quantityFHIR"/>
              <contextType value="variable"/>
              <element value="value"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="quantityCDA.value"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
    </rule>
    <rule>
      <name value="Partecipant"/>
      <source>
        <context value="src"/>
        <element value="participant"/>
        <variable value="participant"/>
      </source>
      <rule>
        <name value="function"/>
        <source>
          <context value="participant"/>
        </source>
        <dependent>
          <name value="Practitioner"/>
          <variable value="participant"/>
          <variable value="tgt"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
      <rule>
        <name value="autor"/>
        <source>
          <context value="participant"/>
          <element value="effectiveTime"/>
          <variable value="vvv"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="authoredOn"/>
          <variable value="vvv"/>
          <transform value="create"/>
        </target>
      </rule>
    </rule>
  </group>
  <group>
    <name value="OrganizationAffiliation"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="act"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="enc"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="OrganizationAffiliation"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <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="statusCode"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <condition value="code = 'active'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="active"/>
        <transform value="copy"/>
        <parameter>
          <valueBoolean value="true"/>
        </parameter>
      </target>
      <documentation value="src.code -&gt; tgt.specialty as specialty then{"/>
    </rule>
    <rule>
      <name value="statusCode"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <condition value="(code = 'active').not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="active"/>
        <transform value="copy"/>
        <parameter>
          <valueBoolean value="false"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="effectiveTime"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="period"/>
      </target>
    </rule>
    <rule>
      <name value="a"/>
      <source>
        <context value="src"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="specialty"/>
        <variable value="spec"/>
        <transform value="create"/>
        <parameter>
          <valueString value="CodeableConcept"/>
        </parameter>
      </target>
      <rule>
        <name value="spec"/>
        <source>
          <context value="src"/>
          <element value="code"/>
          <variable value="code"/>
        </source>
        <rule>
          <name value="cd"/>
          <source>
            <context value="code"/>
          </source>
          <target>
            <context value="spec"/>
            <contextType value="variable"/>
            <element value="coding"/>
            <variable value="cd"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Coding"/>
            </parameter>
          </target>
          <rule>
            <name value="code"/>
            <source>
              <context value="code"/>
            </source>
            <target>
              <context value="cd"/>
              <contextType value="variable"/>
              <element value="code"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="code.code"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="code"/>
            <source>
              <context value="code"/>
            </source>
            <target>
              <context value="cd"/>
              <contextType value="variable"/>
              <element value="display"/>
              <transform value="evaluate"/>
              <parameter>
                <valueString value="code.displayName"/>
              </parameter>
            </target>
          </rule>
          <rule>
            <name value="root1"/>
            <source>
              <context value="code"/>
              <element value="codeSystem"/>
              <variable value="r"/>
            </source>
            <target>
              <context value="cd"/>
              <contextType value="variable"/>
              <element value="system"/>
              <transform value="translate"/>
              <parameter>
                <valueId value="r"/>
              </parameter>
              <parameter>
                <valueString
                             value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
              </parameter>
              <parameter>
                <valueString value="uri"/>
              </parameter>
            </target>
          </rule>
        </rule>
      </rule>
      <rule>
        <name value="entry"/>
        <source>
          <context value="src"/>
          <element value="entryRelationship"/>
          <variable value="entry"/>
        </source>
        <rule>
          <name value="act"/>
          <source>
            <context value="entry"/>
            <element value="act"/>
            <variable value="a"/>
          </source>
          <rule>
            <name value="ref"/>
            <source>
              <context value="a"/>
              <element value="text"/>
              <variable value="tx"/>
            </source>
            <rule>
              <name value="reference"/>
              <source>
                <context value="tx"/>
                <element value="reference"/>
                <variable value="reff"/>
              </source>
              <target>
                <context value="spec"/>
                <contextType value="variable"/>
                <element value="text"/>
                <transform value="evaluate"/>
                <parameter>
                  <valueString value="reff.value"/>
                </parameter>
              </target>
            </rule>
          </rule>
        </rule>
      </rule>
      <documentation value="src.code -&gt; tgt.specialty;"/>
    </rule>
  </group>
  <group>
    <name value="DiagnosticReportFunction"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="organizer"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="enc"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="DiagnosticReport"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reference"/>
      <source>
        <context value="src"/>
      </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="'https://example/Patient/' + %patient.id"/>
        </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>
      <documentation
                     value="src -&gt; tgt.encounter=create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;"/>
    </rule>
    <rule>
      <name value="statusCode"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <condition value="code = 'completed'"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="final"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="value1"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
        <condition value="(value.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="dateTime"/>
        </parameter>
      </target>
      <dependent>
        <name value="TSDateTime"/>
        <variable value="eff"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="valuePeriod"/>
      <source>
        <context value="src"/>
        <element value="effectiveTime"/>
        <variable value="eff"/>
        <condition value="(low.exists())"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="effective"/>
        <variable value="value"/>
        <transform value="create"/>
        <parameter>
          <valueString value="Period"/>
        </parameter>
      </target>
      <dependent>
        <name value="IVLTSPeriod"/>
        <variable value="effectiveTime"/>
        <variable value="value"/>
      </dependent>
    </rule>
    <rule>
      <name value="component"/>
      <source>
        <context value="src"/>
        <element value="component"/>
        <variable value="component"/>
      </source>
      <rule>
        <name value="hasMember"/>
        <source>
          <context value="component"/>
          <element value="observation"/>
          <variable value="observation"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="ei"/>
        </target>
        <target>
          <context value="ei"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="request"/>
          <transform value="create"/>
          <parameter>
            <valueString value="BackboneElement"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="ei"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="obsi"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <target>
          <context value="obsi"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuidi"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="ei"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="https://example/Observation/"/>
          </parameter>
          <parameter>
            <valueId value="uuidi"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="Observation"/>
          </parameter>
        </target>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="result"/>
          <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="'https://example/Observation/' + %obsi.id"/>
          </parameter>
        </target>
        <dependent>
          <name value="Observation"/>
          <variable value="observation"/>
          <variable value="patient"/>
          <variable value="enc"/>
          <variable value="obsi"/>
          <variable value="bundle"/>
        </dependent>
      </rule>
    </rule>
  </group>
  <group>
    <name value="EncounterFunction"/>
    <typeMode value="none"/>
    <input>
      <name value="src"/>
      <type value="cdaElement"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="patient"/>
      <type value="Patient"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="encounter"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="tgt"/>
      <type value="Encounter"/>
      <mode value="target"/>
    </input>
    <input>
      <name value="bundle"/>
      <type value="Bundle"/>
      <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="statusCode"/>
      <source>
        <context value="src"/>
        <element value="statusCode"/>
        <variable value="vvv"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <variable value="vvv"/>
        <transform value="create"/>
      </target>
    </rule>
    <rule>
      <name value="status"/>
      <source>
        <context value="src"/>
        <condition value="statusCode.exists().not()"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="status"/>
        <transform value="copy"/>
        <parameter>
          <valueString value="unknown"/>
        </parameter>
      </target>
    </rule>
    <rule>
      <name value="co"/>
      <source>
        <context value="src"/>
        <element value="code"/>
        <variable value="code"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="class"/>
        <variable value="class"/>
      </target>
      <rule>
        <name value="code"/>
        <source>
          <context value="code"/>
        </source>
        <target>
          <context value="class"/>
          <contextType value="variable"/>
          <element value="code"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="code.code"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="display"/>
        <source>
          <context value="code"/>
        </source>
        <target>
          <context value="class"/>
          <contextType value="variable"/>
          <element value="display"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="code.displayName"/>
          </parameter>
        </target>
      </rule>
      <rule>
        <name value="root1"/>
        <source>
          <context value="code"/>
          <element value="codeSystem"/>
          <variable value="r"/>
        </source>
        <target>
          <context value="class"/>
          <contextType value="variable"/>
          <element value="system"/>
          <transform value="translate"/>
          <parameter>
            <valueId value="r"/>
          </parameter>
          <parameter>
            <valueString
                         value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
          </parameter>
          <parameter>
            <valueString value="uri"/>
          </parameter>
        </target>
      </rule>
    </rule>
    <rule>
      <name value="where"/>
      <source>
        <context value="src"/>
        <condition
                   value="effectiveTime.low.exists() or effectiveTime.high.exists()"/>
      </source>
      <rule>
        <name value="effectiveTime"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="eff"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="period"/>
          <variable value="period"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Period"/>
          </parameter>
        </target>
        <dependent>
          <name value="IVLTSPeriod"/>
          <variable value="eff"/>
          <variable value="period"/>
        </dependent>
      </rule>
      <documentation
                     value="src.effectiveTime as effective -&gt; tgt.period as period then{"/>
    </rule>
    <rule>
      <name value="where"/>
      <source>
        <context value="src"/>
        <condition
                   value="effectiveTime.low.exists().not() or effectiveTime.high.exists().not()"/>
      </source>
      <rule>
        <name value="efft"/>
        <source>
          <context value="src"/>
          <element value="effectiveTime"/>
          <variable value="effectivetime1"/>
        </source>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="period"/>
          <variable value="period"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Period"/>
          </parameter>
        </target>
        <rule>
          <name value="val"/>
          <source>
            <context value="effectivetime1"/>
          </source>
          <target>
            <context value="period"/>
            <contextType value="variable"/>
            <element value="start"/>
            <variable value="start"/>
            <transform value="create"/>
            <parameter>
              <valueString value="dateTime"/>
            </parameter>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="effectivetime1"/>
            <variable value="start"/>
          </dependent>
        </rule>
      </rule>
      <documentation value="effectiveTime = time-stamp"/>
    </rule>
    <rule>
      <name value="text"/>
      <source>
        <context value="src"/>
        <element value="text"/>
        <variable value="tx"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="type"/>
        <variable value="ty"/>
      </target>
      <rule>
        <name value="textType"/>
        <source>
          <context value="tx"/>
          <element value="reference"/>
          <variable value="reff"/>
        </source>
        <target>
          <context value="ty"/>
          <contextType value="variable"/>
          <element value="text"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString value="reff.value"/>
          </parameter>
        </target>
      </rule>
      <documentation
                     value="src.effectiveTime as eff where (value.exists()) -&gt; tgt.period = create('dateTime') as value then TSDateTime(eff, value) &quot;value1&quot;;"/>
    </rule>
    <rule>
      <name value="01"/>
      <source>
        <context value="src"/>
        <element value="performer"/>
        <variable value="performer"/>
      </source>
      <target>
        <context value="tgt"/>
        <contextType value="variable"/>
        <element value="participant"/>
        <variable value="part"/>
      </target>
      <rule>
        <name value="period"/>
        <source>
          <context value="performer"/>
        </source>
        <target>
          <context value="part"/>
          <contextType value="variable"/>
          <element value="period"/>
          <variable value="period"/>
        </target>
        <rule>
          <name value="val"/>
          <source>
            <context value="performer"/>
            <element value="time"/>
            <variable value="time"/>
          </source>
          <target>
            <context value="period"/>
            <contextType value="variable"/>
            <element value="start"/>
            <variable value="start"/>
          </target>
          <dependent>
            <name value="TSDateTime"/>
            <variable value="time"/>
            <variable value="start"/>
          </dependent>
        </rule>
      </rule>
      <rule>
        <name value="performer"/>
        <source>
          <context value="performer"/>
          <element value="assignedEntity"/>
          <variable value="assentity"/>
        </source>
        <target>
          <context value="bundle"/>
          <contextType value="variable"/>
          <element value="entry"/>
          <variable value="e1"/>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="request"/>
          <variable value="request"/>
          <transform value="create"/>
          <parameter>
            <valueString value="BackboneElement"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="method"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="POST"/>
          </parameter>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="resource"/>
          <variable value="practitionerRole"/>
          <transform value="create"/>
          <parameter>
            <valueString value="PractitionerRole"/>
          </parameter>
        </target>
        <target>
          <context value="practitionerRole"/>
          <contextType value="variable"/>
          <element value="id"/>
          <variable value="uuid1"/>
          <transform value="uuid"/>
        </target>
        <target>
          <context value="e1"/>
          <contextType value="variable"/>
          <element value="fullUrl"/>
          <transform value="append"/>
          <parameter>
            <valueString value="https://example/PractitionerRole/"/>
          </parameter>
          <parameter>
            <valueId value="uuid1"/>
          </parameter>
        </target>
        <target>
          <context value="request"/>
          <contextType value="variable"/>
          <element value="url"/>
          <transform value="copy"/>
          <parameter>
            <valueString value="PractitionerRole"/>
          </parameter>
        </target>
        <target>
          <context value="tgt"/>
          <contextType value="variable"/>
          <element value="participant"/>
          <variable value="participant1"/>
          <transform value="create"/>
          <parameter>
            <valueString value="BackboneElement"/>
          </parameter>
        </target>
        <target>
          <context value="participant1"/>
          <contextType value="variable"/>
          <element value="individual"/>
          <variable value="referencepart"/>
          <transform value="create"/>
          <parameter>
            <valueString value="Reference"/>
          </parameter>
        </target>
        <target>
          <context value="referencepart"/>
          <contextType value="variable"/>
          <element value="reference"/>
          <transform value="evaluate"/>
          <parameter>
            <valueString
                         value="'https://example/PractitionerRole/' + %practitionerRole.id"/>
          </parameter>
        </target>
        <rule>
          <name value="code"/>
          <source>
            <context value="assentity"/>
            <element value="code"/>
            <variable value="vvv"/>
          </source>
          <target>
            <context value="practitionerRole"/>
            <contextType value="variable"/>
            <element value="code"/>
            <variable value="vvv"/>
            <transform value="create"/>
          </target>
        </rule>
        <rule>
          <name value="assignedEntity"/>
          <source>
            <context value="assentity"/>
          </source>
          <target>
            <context value="bundle"/>
            <contextType value="variable"/>
            <element value="entry"/>
            <variable value="e2"/>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="request"/>
            <variable value="request"/>
            <transform value="create"/>
            <parameter>
              <valueString value="BackboneElement"/>
            </parameter>
          </target>
          <target>
            <context value="request"/>
            <contextType value="variable"/>
            <element value="method"/>
            <transform value="copy"/>
            <parameter>
              <valueString value="PUT"/>
            </parameter>
          </target>
          <target>
            <context value="e2"/>
            <contextType value="variable"/>
            <element value="resource"/>
            <variable value="practitioner"/>
            <transform value="create"/>
            <parameter>
              <valueString value="Practitioner"/>
            </parameter>
          </target>
          <rule>
            <name value="meta"/>
            <source>
              <context value="assentity"/>
            </source>
            <target>
              <context value="practitioner"/>
              <contextType value="variable"/>
              <element value="meta"/>
              <variable value="meta"/>
            </target>
            <rule>
              <name value="coding"/>
              <source>
                <context value="assentity"/>
              </source>
              <target>
                <context value="meta"/>
                <contextType value="variable"/>
                <element value="tag"/>
                <variable value="coding"/>
                <transform value="create"/>
                <parameter>
                  <valueString value="Coding"/>
                </parameter>
              </target>
              <rule>
                <name value="system"/>
                <source>
                  <context value="assentity"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="system"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString value="http://algoritmodiscoring"/>
                  </parameter>
                </target>
              </rule>
              <rule>
                <name value="code"/>
                <source>
                  <context value="assentity"/>
                </source>
                <target>
                  <context value="coding"/>
                  <contextType value="variable"/>
                  <element value="code"/>
                  <transform value="copy"/>
                  <parameter>
                    <valueString
                                 value="ClinicalDocument/body/encounter/performer"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="identifier"/>
            <source>
              <context value="assentity"/>
              <element value="id"/>
              <variable value="id"/>
            </source>
            <target>
              <context value="practitioner"/>
              <contextType value="variable"/>
              <element value="identifier"/>
              <variable value="identifier"/>
            </target>
            <rule>
              <name value="root1"/>
              <source>
                <context value="id"/>
                <element value="root"/>
                <variable value="r"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="system"/>
                <transform value="translate"/>
                <parameter>
                  <valueId value="r"/>
                </parameter>
                <parameter>
                  <valueString
                               value="http://hl7.org/fhir/ConceptMap/special-oid2uri"/>
                </parameter>
                <parameter>
                  <valueString value="uri"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="ext"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="value"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="ext"/>
                </parameter>
              </target>
              <rule>
                <name value="UUID"/>
                <source>
                  <context value="assentity"/>
                </source>
                <target>
                  <context value="request"/>
                  <contextType value="variable"/>
                  <element value="url"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="Practitioner?identifier="/>
                  </parameter>
                  <parameter>
                    <valueId value="ext"/>
                  </parameter>
                </target>
              </rule>
            </rule>
            <rule>
              <name value="assigningAuthorityName"/>
              <source>
                <context value="id"/>
                <element value="assigningAuthorityName"/>
                <variable value="s"/>
              </source>
              <target>
                <context value="identifier"/>
                <contextType value="variable"/>
                <element value="assigner"/>
                <variable value="a"/>
              </target>
              <target>
                <context value="a"/>
                <contextType value="variable"/>
                <element value="display"/>
                <transform value="copy"/>
                <parameter>
                  <valueId value="s"/>
                </parameter>
              </target>
            </rule>
            <rule>
              <name value="r"/>
              <source>
                <context value="id"/>
                <element value="root"/>
                <variable value="r"/>
              </source>
              <rule>
                <name value="performer"/>
                <source>
                  <context value="id"/>
                  <element value="extension"/>
                  <variable value="ext"/>
                </source>
                <target>
                  <context value="practitioner"/>
                  <contextType value="variable"/>
                  <element value="id"/>
                  <variable value="uuid2"/>
                  <transform value="evaluate"/>
                  <parameter>
                    <valueString value="r + '-' + ext"/>
                  </parameter>
                </target>
                <target>
                  <context value="e2"/>
                  <contextType value="variable"/>
                  <element value="fullUrl"/>
                  <transform value="append"/>
                  <parameter>
                    <valueString value="https://example/Practitioner/"/>
                  </parameter>
                  <parameter>
                    <valueId value="uuid2"/>
                  </parameter>
                </target>
                <target>
                  <context value="practitionerRole"/>
                  <contextType value="variable"/>
                  <element value="practitioner"/>
                  <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="'https://example/Practitioner/' + %practitioner.id"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
          <rule>
            <name value="2.16.840.1.113883.2.9.4.3.2"/>
            <source>
              <context value="assentity"/>
              <element value="id"/>
              <variable value="id"/>
              <condition value="(root = '2.16.840.1.113883.2.9.4.3.2')"/>
            </source>
            <rule>
              <name value="UUID"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="request"/>
                <contextType value="variable"/>
                <element value="url"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Practitioner?identifier="/>
                </parameter>
                <parameter>
                  <valueId value="ext"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="2.16.840.1.113883.2.9.4.3.2"/>
            <source>
              <context value="assentity"/>
              <element value="id"/>
              <variable value="id"/>
              <condition value="(root != '2.16.840.1.113883.2.9.4.3.2')"/>
            </source>
            <rule>
              <name value="UUID"/>
              <source>
                <context value="id"/>
                <element value="extension"/>
                <variable value="ext"/>
              </source>
              <target>
                <context value="request"/>
                <contextType value="variable"/>
                <element value="url"/>
                <transform value="append"/>
                <parameter>
                  <valueString value="Practitioner?identifier="/>
                </parameter>
                <parameter>
                  <valueId value="ext"/>
                </parameter>
              </target>
            </rule>
          </rule>
          <rule>
            <name value="addr"/>
            <source>
              <context value="assentity"/>
              <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="assentity"/>
              <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="assentity"/>
              <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>
              <name value="birth"/>
              <source>
                <context value="person"/>
                <element value="birthTime"/>
                <variable value="birthTime"/>
              </source>
              <rule>
                <name value="value"/>
                <source>
                  <context value="birthTime"/>
                  <element value="value"/>
                  <variable value="date"/>
                </source>
                <target>
                  <context value="practitioner"/>
                  <contextType value="variable"/>
                  <element value="birthDate"/>
                  <transform value="truncate"/>
                  <parameter>
                    <valueId value="date"/>
                  </parameter>
                  <parameter>
                    <valueInteger value="10"/>
                  </parameter>
                </target>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
</StructureMap>