CDA to FHIR Maps
0.1.0 - ci-build Italy flag

CDA to FHIR Maps, published by HL7 Italy. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/hl7-it/cda2fhir/ and changes regularly. See the Directory of published versions

: CDA to FHIR - PRESCRIZIONE FARMACEUTICA - JSON Representation

Draft as of 2024-09-15

Raw json | Download


{
  "resourceType" : "StructureMap",
  "id" : "cda2fhirMedPrescription",
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n         <pre>map &quot;http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirMedPrescription&quot; = &quot;cda2fhirMedPrescription&quot;\n\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument&quot; alias ClinicalDocument as source\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor&quot; alias AssignedAuthor as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity&quot; alias AssignedEntity as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/AssociatedEntity&quot; alias AssociatedEntity as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization&quot; alias CustodianOrganization as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/OrganizationPartOf&quot; alias OrganizationPartOf as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Organization&quot; alias rapresentedOrganization as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Section&quot; alias Section as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/PatientRole&quot; alias PatientRole as queried\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/AD&quot; alias AD as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/Bundle&quot; alias Bundle as target\nuses &quot;http://hl7.org/fhir/StructureDefinition/Composition&quot; alias Composition as produced\nuses &quot;http://hl7.org/fhir/StructureDefinition/Patient&quot; alias Patient as produced\nuses &quot;http://hl7.org/fhir/StructureDefinition/Encounter&quot; alias Encounter as produced\nuses &quot;http://hl7.org/fhir/StructureDefinition/Person&quot; alias Patient as produced\nuses &quot;http://hl7.org/fhir/StructureDefinition/Practitioner&quot; alias Practitioner as produced\nuses &quot;http://hl7.org/fhir/StructureDefinition/Organization&quot; alias Organization as produced\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/Act&quot; alias Act as produced\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/IVL-PQ&quot; alias IVL_PQ as source\nuses &quot;http://hl7.org/fhir/cda/StructureDefinition/PQ&quot; alias PQ as source\nuses &quot;http://hl7.org/fhir/StructureDefinition/SimpleQuantity&quot; alias SimpleQuantity as target\n\nimports &quot;http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirDataTypes&quot;\nimports &quot;http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirHeader&quot;\n\ngroup CdaToBundle(source cda : ClinicalDocument, target bundle : Bundle) {\n  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 e5,  e5.request = create('BackboneElement') as request,  request.method = 'POST',  e5.resource = create('DocumentReference') as DocumentReference,  DocumentReference.id = uuid() as uuid5,  e5.fullUrl = append('https://example/DocumentReference/', uuid5),  request.url = 'DocumentReference' then {\n    cda then ClinicalDocumentToBundle(cda, patient, composition, encounter, bundle, DocumentReference) &quot;cdatobundle&quot;;\n    cda.recordTarget as recordTarget then {\n      recordTarget.patientRole as patient then {\n        patient.id as id -&gt; patient.identifier as identifier then {\n          id.root as r -&gt; identifier.system = translate(r, 'http://hl7.org/fhir/ConceptMap/special-oid2uri', 'uri') &quot;root1&quot;;\n          id.extension as ext -&gt; identifier.value = ext;\n          id.assigningAuthorityName as s -&gt;  identifier.assigner as a,  a.display = s;\n        } &quot;record&quot;;\n        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 {\n          id.extension as ext -&gt; requestPAT.url = append('Patient?identifier=', ext) &quot;UUID&quot;;\n        } &quot;ext&quot;;\n      } &quot;recPat&quot;;\n    } &quot;patient&quot;;\n  } &quot;ClinicalDocumentToBody&quot;;\n}\n\ngroup ClinicalDocumentToBundle(source cda : ClinicalDocument, target patient : Patient, target composition : Composition, target encounter : Encounter, target bundle : Bundle, target DocumentReference : DocumentReference) {\n  cda -&gt; bundle.id = uuid() &quot;id&quot;;\n  cda.id -&gt; bundle.identifier &quot;identifier&quot;;\n  cda -&gt; bundle.type = 'transaction' &quot;type&quot;;\n  cda -&gt; bundle.timestamp = (timestamp.now()) &quot;date&quot;;\n  cda then ClinicalDocumentComposition(cda, composition, patient, encounter, bundle, DocumentReference) &quot;composition&quot;;\n  cda.component as component then {\n    component.structuredBody as body then {\n      body -&gt;  bundle.entry as e1,  e1.request = create('BackboneElement') as request,  request.method = 'POST',  e1.resource = create('Coverage') as coverage,  coverage.id = uuid() as uuid1,  e1.fullUrl = append('https://example/Coverage/', uuid1),  request.url = 'Coverage' then {\n        body -&gt;  bundle.entry as e2,  e2.request = create('BackboneElement') as request,  request.method = 'POST',  e2.resource = create('MedicationRequest') as medRq,  medRq.id = uuid() as uuid1,  e2.fullUrl = append('https://example/MedicationRequest/', uuid1),  request.url = 'MedicationRequest' then {\n          body.component as component then {\n            // discretizzi il primo livello di component\n            component.section as srcSection then {\n              srcSection.code where (code = '57827-8') -&gt; composition.section as tgtSection then ClinicalDocumentSectionEsenzioni(cda, srcSection, patient, tgtSection, bundle, encounter, coverage) &quot;esenz&quot;;\n              srcSection.code where (code = '57828-6') -&gt; composition.section as tgtSection then ClinicalDocumentSectionPrescrizioneFarmaceutica(cda, srcSection, patient, tgtSection, bundle, encounter, coverage, medRq) &quot;prescfarm&quot;;\n              srcSection.code where (code = '48767-8') -&gt; composition.section as tgtSection then ClinicalDocumentSectionAnnotazioni(cda, srcSection, patient, tgtSection, bundle, encounter, medRq) &quot;annot&quot;;\n              srcSection.code where (code = '51851-4') -&gt; composition.section as tgtSection then ClinicalDocumentSectionMessaggioRegionale(cda, srcSection, patient, tgtSection, bundle, encounter, medRq) &quot;messregg&quot;;\n              srcSection.code where (code = '8716-3') -&gt; composition.section as tgtSection then ClinicalDocumentSectionParametriVitali(cda, srcSection, patient, tgtSection, bundle, encounter) &quot;paramvit&quot;;\n              srcSection.code where (code = '48765-2') -&gt; composition.section as tgtSection then ClinicalDocumentSectionAllergieaiFarmaci(cda, srcSection, patient, tgtSection, bundle, encounter) &quot;allergfarm&quot;;\n              srcSection.code where (code = '47420-5') -&gt; composition.section as tgtSection then ClinicalDocumentSectionStatoClinicoPaziente(cda, srcSection, patient, tgtSection, bundle, encounter) &quot;statclinpaz&quot;;\n            } &quot;cov&quot;;\n          };\n        } &quot;medreq&quot;;\n      } &quot;coverage&quot;;\n    } &quot;body&quot;;\n  };\n}\n\ngroup ClinicalDocumentSectionEsenzioni(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter, target coverage : Coverage) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src.text as cdaText -&gt;  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Coverage/' + %coverage.id),  tgt.text as fhirText then {\n    cdaText -&gt; fhirText.status = 'generated' &quot;narrativeStatus&quot;;\n    cdaText as t -&gt; fhirText.div = t &quot;narrativeText&quot;;\n    src.entry as srcse then {\n      srcse.act as srcsec then {\n        srcsec.code -&gt; coverage.type;\n        srcsec.code as srctxt then {\n          srctxt -&gt; coverage.type as typetxt then {\n            srctxt.originalText as ref then {\n              ref.reference as t then {\n                t.value as l -&gt; typetxt.text = l &quot;reference&quot;;\n              } &quot;tcf&quot;;\n            } &quot;rfde&quot;;\n          } &quot;reftxt&quot;;\n        } &quot;origtxt&quot;;\n        srcsec where coverage.status.exists().not() then {\n          srcsec -&gt; coverage.status = 'active' &quot;status&quot;;\n        } &quot;statuscode&quot;;\n        srcsec -&gt;  coverage.beneficiary = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;\n        srcsec -&gt;  coverage.payor = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;\n      } &quot;cdaText&quot;;\n    } &quot;secact&quot;;\n  } &quot;cff&quot;;\n}\n\ngroup ClinicalDocumentSectionPrescrizioneFarmaceutica(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter, target coverage : Coverage, target medRq : MedicationRequest) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src.text as cdaText -&gt;  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/MedicationRequest/' + %medRq.id),  tgt.text as fhirText then {\n    src.id -&gt; medRq.identifier;\n    cdaText -&gt; fhirText.status = 'generated' &quot;narrativeStatus&quot;;\n    cdaText as t -&gt; fhirText.div = t &quot;narrativeText&quot;;\n    cdaText -&gt;  medRq.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;\n    cdaText -&gt;  medRq.encounter = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;\n    cdaText -&gt; medRq.status = 'active' &quot;status&quot;;\n    cdaText -&gt; medRq.intent = 'order' &quot;intent&quot;;\n    src.entry as srcent then {\n      srcent.substanceAdministration as subAdm then {\n        subAdm.effectiveTime : IVL_TS as eff -&gt; medRq.dosageInstruction = create('Dosage') as dosage then {\n          subAdm -&gt; dosage.timing = create('Timing') as tim then {\n            subAdm -&gt; tim.repeat as repeat then {\n              eff -&gt; repeat.bounds = create('Period') as period then IVLTSPeriod(eff, period) &quot;boundsperiod&quot;;\n              eff.width as width then {\n                width.value as v -&gt; repeat.duration = v;\n                width.unit as u -&gt; repeat.durationUnit = u;\n              };\n            } &quot;repeat&quot;;\n          } &quot;timing&quot;;\n        } &quot;dosage&quot;;\n        subAdm.effectiveTime as eff -&gt; medRq.dosageInstruction = create('Dosage') as dosage then {\n          subAdm -&gt; dosage.timing = create('Timing') as tim then {\n            eff where eff.low.exists().not() and eff.high.exists().not() then {\n              eff.value as v -&gt; tim.event = create('dateTime') as event then TSDateTime(v, event) &quot;evnt&quot;;\n            } &quot;effct1&quot;;\n          } &quot;timing1&quot;;\n        } &quot;dosage1&quot;;\n        subAdm.effectiveTime : PIVL_TS as effp -&gt; medRq.dosageInstruction = create('Dosage') as dosage then {\n          effp -&gt; dosage.timing = create('Timing') as timing then {\n            effp -&gt; timing then periodTiming(effp, timing) &quot;cod&quot;;\n            effp where effp.phase.exists() then {\n              effp.phase as phase -&gt; timing.repeat as r then {\n                phase.low -&gt; r.bounds = create('Period') as period then {\n                  phase.low -&gt; period.start &quot;lo&quot;;\n                };\n                phase.width as wid then {\n                  wid.value as v -&gt; r.duration = v &quot;vals&quot;;\n                  wid.unit as u -&gt; r.durationUnit = u;\n                } &quot;dur&quot;;\n              } &quot;rep&quot;;\n            } &quot;phase&quot;;\n          } &quot;timing&quot;;\n        } &quot;eff&quot;;\n        subAdm.effectiveTime : EIVL_TS as effe -&gt; medRq.dosageInstruction = create('Dosage') as dosage then {\n          effe -&gt; dosage.timing = create('Timing') as timing then {\n            effe -&gt; timing.repeat as r then {\n              effe.event -&gt; r.when;\n              effe.offset as offset then {\n                offset.low as v then {\n                  v.value as o -&gt; r.offset = o &quot;barabar&quot;;\n                } &quot;offs&quot;;\n              } &quot;poi&quot;;\n            } &quot;lkj&quot;;\n          } &quot;ghj&quot;;\n        } &quot;eff&quot;;\n        subAdm.doseQuantity as doseQuant -&gt; medRq.dosageInstruction = create('Dosage') as dosage then {\n          doseQuant.originalText as ot then {\n            ot.reference -&gt; dosage.text;\n          } &quot;ot&quot;;\n          doseQuant -&gt; dosage.doseAndRate as dosageRate then {\n            doseQuant -&gt; dosageRate.dose = create('Range') as d then {\n              doseQuant -&gt; d.low = create('SimpleQuantity') as l then {\n                doseQuant.low as lo -&gt; l.value = (lo.value);\n                doseQuant.low as lo -&gt; l.unit = (lo.unit);\n              } &quot;low&quot;;\n              doseQuant -&gt; d.high = create('SimpleQuantity') as h then {\n                doseQuant.high as hi -&gt; h.value = (hi.value);\n                doseQuant.high as hi -&gt; h.unit = (hi.unit);\n              } &quot;low&quot;;\n            } &quot;d&quot;;\n          } &quot;dosageRate&quot;;\n        } &quot;doseQuant&quot;;\n        subAdm -&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',  medRq.medication = create('Reference') as reference,  reference.reference = ('https://example/Medication/' + %medication.id) then {\n          subAdm.consumable as cons then {\n            cons.manufacturedProduct as manuprod then {\n              manuprod.manufacturedLabeledDrug as manudrug then {\n                manudrug.code -&gt; medication.code;\n                manudrug -&gt; medication.identifier as medid then {\n                  manudrug.name -&gt; medid.value;\n                } &quot;idmedname&quot;;\n                manudrug.code as srctxt then {\n                  srctxt -&gt; medication.code as typetxt then {\n                    srctxt.originalText as ref then {\n                      ref.reference as reference then {\n                        reference.value as l -&gt; typetxt.text = l &quot;reference&quot;;\n                      } &quot;tcf&quot;;\n                    } &quot;tcfg&quot;;\n                  } &quot;reftxtd&quot;;\n                } &quot;origtxtd&quot;;\n              } &quot;manudrug&quot;;\n              manuprod.manufacturedMaterial as manufact then {\n                manufact.code -&gt; medication.code;\n                manufact.code as srctxt then {\n                  srctxt -&gt; medication.code as typetxt then {\n                    srctxt.originalText as ref then {\n                      ref.reference as reference then {\n                        reference.value as l -&gt; typetxt.text = l &quot;reference&quot;;\n                      } &quot;tcf&quot;;\n                    } &quot;tcfg&quot;;\n                  } &quot;reftxt&quot;;\n                } &quot;origtxt&quot;;\n                manufact.ingredient as ingredient -&gt; medication.ingredient as ing then {\n                  ingredient.quantity as quantity -&gt; ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) &quot;strength&quot;;\n                  manufact -&gt;  ing.item = create('CodeableConcept') as ingcode,  ingcode.text = (%manufact.name.other) &quot;ingredientCode&quot;;\n                } &quot;ingr&quot;;\n                manufact.formCode -&gt; medication.form;\n                manufact -&gt; medication.identifier as medid &quot;transl&quot;;\n              } &quot;manuFact&quot;;\n            } &quot;manumat&quot;;\n          } &quot;cons&quot;;\n          subAdm.entryRelationship as entryrel1 then {\n            entryrel1.supply as sup -&gt; medRq.dispenseRequest as dispreq then {\n              sup -&gt; dispreq.quantity = create('SimpleQuantity') as quantity then {\n                sup.quantity as q -&gt; quantity.value = (q.value);\n              } &quot;quantity&quot;;\n            };\n          } &quot;entry1&quot;;\n          subAdm.entryRelationship as entryrel2 where (typeCode = 'REFR') then {\n            subAdm -&gt;  medRq.insurance = create('Reference') as reference,  reference.reference = ('https://example/Coverage/' + %coverage.id) then {\n              entryrel2.act as act2 -&gt; coverage.costToBeneficiary as cost then {\n                act2 -&gt; cost.value = create('SimpleQuantity') as val then {\n                  act2 -&gt; val.value = '0' &quot;bnm&quot;;\n                } &quot;beneficmoney&quot;;\n                act2 -&gt; cost.exception as except then {\n                  act2.code -&gt; except.type;\n                } &quot;exept&quot;;\n              } &quot;act2&quot;;\n            } &quot;Cover&quot;;\n          } &quot;entry2&quot;;\n          subAdm.entryRelationship as entryrel3 where (typeCode = 'RSON') then {\n            entryrel3.observation as obs3 where (classCode = 'OBS') then {\n              obs3.code -&gt; medRq.reasonCode;\n              obs3.text as text then {\n                text -&gt; medRq.reasonCode as ce then {\n                  // text.reference as reference-&gt; ce.text=reference;\n                  text.reference as reference then {\n                    reference.value as l -&gt; ce.text = l &quot;reference&quot;;\n                  } &quot;tcf&quot;;\n                } &quot;originltext&quot;;\n              } &quot;txt&quot;;\n            } &quot;obs3&quot;;\n          } &quot;entry2&quot;;\n          subAdm.entryRelationship as entryrel4 where (typeCode = 'SUBJ') then {\n            entryrel4.observation as obs3 -&gt; medRq.substitution as sub then {\n              obs3.code as Code -&gt; sub.allowed = create('CodeableConcept') as allowed then CECodeableConcept(Code, allowed);\n              obs3.entryRelationship as entry then {\n                entry.observation as obs4 then {\n                  obs4.code -&gt; sub.reason;\n                } &quot;obs4&quot;;\n              } &quot;entry&quot;;\n            } &quot;obs&quot;;\n          } &quot;code&quot;;\n          subAdm.entryRelationship as entryrel2 where (typeCode = 'SUBJ') then {\n            entryrel2.act as act2 where (classCode = 'ACT') then {\n              act2.text as text -&gt; medRq.note as note then {\n                text.reference as t then {\n                  t.value as l -&gt; note.text = l &quot;reference&quot;;\n                } &quot;tcx&quot;;\n              } &quot;reference&quot;;\n            } &quot;obs3&quot;;\n          } &quot;entry2&quot;;\n        } &quot;subsadm&quot;;\n      } &quot;subadm&quot;;\n    } &quot;hnjh&quot;;\n  } &quot;xxx&quot;;\n}\n\n// ------------Sezione Annotazioni-----------------------------------------------------------------------------------------------------------------------------------------\ngroup ClinicalDocumentSectionAnnotazioni(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter, target medRq : MedicationRequest) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src.text as cdaText -&gt;  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/MedicationRequest/' + %medRq.id),  tgt.text as fhirText then {\n    cdaText -&gt; fhirText.status = 'generated' &quot;narrativeStatus&quot;;\n    cdaText as t -&gt; fhirText.div = t &quot;narrativeText&quot;;\n    src.entry as entry then {\n      entry.act as act then {\n        act.text as text -&gt; medRq.note as note then {\n          text.reference as t then {\n            t.value as l -&gt; note.text = l &quot;reference&quot;;\n          } &quot;tcx&quot;;\n        } &quot;reference&quot;;\n      };\n    };\n  } &quot;entry&quot;;\n}\n\n// ------------Sezione Messaggio Regionale-----------------------------------------------------------------------------------------------------------------------------------------\ngroup ClinicalDocumentSectionMessaggioRegionale(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter, target medRq : MedicationRequest) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src.text as cdaText -&gt;  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/MedicationRequest/' + %medRq.id) then {\n    cdaText as text -&gt; medRq.note as note then {\n      text as t -&gt; note.text = t &quot;reference&quot;;\n    } &quot;nota&quot;;\n  } &quot;entry&quot;;\n}\n\n// ------------Sezione Parametri Vitali-----------------------------------------------------------------------------------------------------------------------------------------\ngroup ClinicalDocumentSectionParametriVitali(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src.text as cdaText -&gt;  bundle.entry as e8,  e8.request = create('BackboneElement') as request,  request.method = 'POST',  e8.resource = create('Observation') as Observation,  Observation.id = uuid() as uuid8,  e8.fullUrl = append('https://example/Observation/', uuid8),  request.url = 'Observation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %Observation.id) then {\n    src -&gt;  Observation.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;\n    src -&gt;  Observation.encounter = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;\n    src.code -&gt; Observation.code;\n    src where Observation.statusCode.exists().not() then {\n      src -&gt; Observation.status = 'final' &quot;status&quot;;\n    } &quot;statuscode&quot;;\n    cdaText -&gt; Observation.note as note then {\n      cdaText as t -&gt; note.text = t &quot;reference&quot;;\n    } &quot;reference&quot;;\n  } &quot;nota&quot;;\n}\n\n// ------------Sezione Allergie_Intolleranze-----------------------------------------------------------------------------------------------------------------------------------------\ngroup ClinicalDocumentSectionAllergieaiFarmaci(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src -&gt;  bundle.entry as e9,  e9.request = create('BackboneElement') as request,  request.method = 'POST',  e9.resource = create('AllergyIntolerance') as allergyIntolerance,  allergyIntolerance.id = uuid() as uuid9,  e9.fullUrl = append('https://example/AllergyIntolerance/', uuid9),  request.url = 'AllergyIntolerance',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/AllergyIntolerance/' + %allergyIntolerance.id) then {\n    src -&gt;  allergyIntolerance.patient = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;\n    src -&gt; allergyIntolerance.clinicalStatus = create('CodeableConcept') as status then {\n      src -&gt; status.text = 'string' &quot;text&quot;;\n      src -&gt; status.coding = create('Coding') as coding then {\n        src -&gt; coding.code = 'active' &quot;active&quot;;\n        src -&gt; coding.system = 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical' &quot;system&quot;;\n      } &quot;coding&quot;;\n    } &quot;allergy&quot;;\n    src.text as cdaText -&gt; allergyIntolerance.note as note then {\n      cdaText as t -&gt; note.text = t &quot;reference&quot;;\n    } &quot;reference&quot;;\n  } &quot;nota&quot;;\n}\n\n// ------------Sezione Stato Clinico del Paziente----------------------------------------------------------------------------------------------------------------------------------------\ngroup ClinicalDocumentSectionStatoClinicoPaziente(source cda : ClinicalDocument, source src : Section, target patient : Patient, target tgt, target bundle : Bundle, target enc : Encounter) {\n  src.title as t -&gt; tgt.title = (t.dataString);\n  src.code -&gt; tgt.code;\n  src.text as cdaText -&gt;  bundle.entry as e7,  e7.request = create('BackboneElement') as request,  request.method = 'POST',  e7.resource = create('Observation') as Observation,  Observation.id = uuid() as uuid7,  e7.fullUrl = append('https://example/Observation/', uuid7),  request.url = 'Observation',  tgt.entry = create('Reference') as reference,  reference.reference = ('https://example/Observation/' + %Observation.id) then {\n    src -&gt;  Observation.subject = create('Reference') as reference,  reference.reference = ('https://example/Patient/' + %patient.id) &quot;reference&quot;;\n    src -&gt;  Observation.encounter = create('Reference') as reference,  reference.reference = ('https://example/Encounter/' + %enc.id) &quot;reference&quot;;\n    src.code -&gt; Observation.code;\n    src where Observation.statusCode.exists().not() then {\n      src -&gt; Observation.status = 'final' &quot;status&quot;;\n    } &quot;statuscode&quot;;\n    cdaText -&gt; Observation.note as note then {\n      cdaText as t -&gt; note.text = t &quot;reference&quot;;\n    } &quot;reference&quot;;\n  } &quot;nota&quot;;\n}\n\ngroup periodTiming(source effectiveTime : PIVL_TS, target timing : Timing) {\n  effectiveTime -&gt; timing.repeat as r then {\n    effectiveTime.period as p -&gt; r.period = (p.value);\n    effectiveTime.period as p -&gt; r.periodUnit = (p.unit);\n  } &quot;repeat&quot;;\n}\n\ngroup EmedRTOPQPQRatio(source src : RTO_PQ_PQ, target tgt : Ratio) {\n  src.numerator as numerator -&gt; tgt.numerator as targetNumerator then EmedPQQuantity(numerator, targetNumerator);\n  src.denominator as denominator -&gt; tgt.denominator as targetDenominator then EmedPQQuantity(denominator, targetDenominator);\n}\n\ngroup EmedPQQuantity(source src : PQ, target tgt : Quantity) {\n  src.value as value -&gt; tgt.value = value;\n  src.unit as unit -&gt; tgt.code = unit;\n  src.unit as unit -&gt; tgt.system = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system);\n  src.unit as unit -&gt; tgt.unit = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display);\n}\n\n</pre>\n      </div>"
  },
  "url" : "http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirMedPrescription",
  "version" : "0.1.0",
  "name" : "cda2fhirMedPrescription",
  "status" : "draft",
  "date" : "2024-09-15T08:16:12+00:00",
  "publisher" : "HL7 Italy",
  "contact" : [
    {
      "name" : "HL7 Italy",
      "telecom" : [
        {
          "system" : "url",
          "value" : "http://hl7.it"
        }
      ]
    }
  ],
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "urn:iso:std:iso:3166",
          "code" : "IT",
          "display" : "Italy"
        }
      ]
    }
  ],
  "structure" : [
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument",
      "mode" : "source",
      "alias" : "ClinicalDocument"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor",
      "mode" : "queried",
      "alias" : "AssignedAuthor"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity",
      "mode" : "queried",
      "alias" : "AssignedEntity"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/AssociatedEntity",
      "mode" : "queried",
      "alias" : "AssociatedEntity"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization",
      "mode" : "queried",
      "alias" : "CustodianOrganization"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/OrganizationPartOf",
      "mode" : "queried",
      "alias" : "OrganizationPartOf"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Organization",
      "mode" : "queried",
      "alias" : "rapresentedOrganization"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Section",
      "mode" : "queried",
      "alias" : "Section"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/PatientRole",
      "mode" : "queried",
      "alias" : "PatientRole"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/AD",
      "mode" : "source",
      "alias" : "AD"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode" : "target",
      "alias" : "Bundle"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Composition",
      "mode" : "produced",
      "alias" : "Composition"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Patient",
      "mode" : "produced",
      "alias" : "Patient"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Encounter",
      "mode" : "produced",
      "alias" : "Encounter"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Person",
      "mode" : "produced",
      "alias" : "Patient"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Practitioner",
      "mode" : "produced",
      "alias" : "Practitioner"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/Organization",
      "mode" : "produced",
      "alias" : "Organization"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/Act",
      "mode" : "produced",
      "alias" : "Act"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/IVL-PQ",
      "mode" : "source",
      "alias" : "IVL_PQ"
    },
    {
      "url" : "http://hl7.org/fhir/cda/StructureDefinition/PQ",
      "mode" : "source",
      "alias" : "PQ"
    },
    {
      "url" : "http://hl7.org/fhir/StructureDefinition/SimpleQuantity",
      "mode" : "target",
      "alias" : "SimpleQuantity"
    }
  ],
  "import" : [
    🔗 "http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirDataTypes"🔗 ,
    "http://hl7.it/fhir/cda2fhir/StructureMap/cda2fhirHeader"
  ],
  "group" : [
    {
      "name" : "CdaToBundle",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "ClinicalDocumentToBody",
          "source" : [
            {
              "context" : "cda"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e"
            },
            {
              "context" : "e",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "e",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "composition",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Composition"
                }
              ]
            },
            {
              "context" : "composition",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid1",
              "transform" : "uuid"
            },
            {
              "context" : "e",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/Composition/"
                },
                {
                  "valueId" : "uuid1"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "Composition"
                }
              ]
            },
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e2"
            },
            {
              "context" : "e2",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "requestPAT",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "requestPAT",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "PUT"
                }
              ]
            },
            {
              "context" : "e2",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "patient",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Patient"
                }
              ]
            },
            {
              "context" : "patient",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid2",
              "transform" : "uuid"
            },
            {
              "context" : "e2",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/Patient/"
                },
                {
                  "valueId" : "uuid2"
                }
              ]
            },
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e3"
            },
            {
              "context" : "e3",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "e3",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "encounter",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Encounter"
                }
              ]
            },
            {
              "context" : "encounter",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid3",
              "transform" : "uuid"
            },
            {
              "context" : "e3",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/Encounter/"
                },
                {
                  "valueId" : "uuid3"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "Encounter"
                }
              ]
            },
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e5"
            },
            {
              "context" : "e5",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "e5",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "DocumentReference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "DocumentReference"
                }
              ]
            },
            {
              "context" : "DocumentReference",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid5",
              "transform" : "uuid"
            },
            {
              "context" : "e5",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/DocumentReference/"
                },
                {
                  "valueId" : "uuid5"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "DocumentReference"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "cdatobundle",
              "source" : [
                {
                  "context" : "cda"
                }
              ],
              "dependent" : [
                {
                  "name" : "ClinicalDocumentToBundle",
                  "variable" : [
                    "cda",
                    "patient",
                    "composition",
                    "encounter",
                    "bundle",
                    "DocumentReference"
                  ]
                }
              ]
            },
            {
              "name" : "patient",
              "source" : [
                {
                  "context" : "cda",
                  "element" : "recordTarget",
                  "variable" : "recordTarget"
                }
              ],
              "rule" : [
                {
                  "name" : "recPat",
                  "source" : [
                    {
                      "context" : "recordTarget",
                      "element" : "patientRole",
                      "variable" : "patient"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "record",
                      "source" : [
                        {
                          "context" : "patient",
                          "element" : "id",
                          "variable" : "id"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "patient",
                          "contextType" : "variable",
                          "element" : "identifier",
                          "variable" : "identifier"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "root1",
                          "source" : [
                            {
                              "context" : "id",
                              "element" : "root",
                              "variable" : "r"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "identifier",
                              "contextType" : "variable",
                              "element" : "system",
                              "transform" : "translate",
                              "parameter" : [
                                {
                                  "valueId" : "r"
                                },
                                {
                                  "valueString" : "http://hl7.org/fhir/ConceptMap/special-oid2uri"
                                },
                                {
                                  "valueString" : "uri"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "extension",
                          "source" : [
                            {
                              "context" : "id",
                              "element" : "extension",
                              "variable" : "ext"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "identifier",
                              "contextType" : "variable",
                              "element" : "value",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "ext"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "assigningAuthorityName",
                          "source" : [
                            {
                              "context" : "id",
                              "element" : "assigningAuthorityName",
                              "variable" : "s"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "identifier",
                              "contextType" : "variable",
                              "element" : "assigner",
                              "variable" : "a"
                            },
                            {
                              "context" : "a",
                              "contextType" : "variable",
                              "element" : "display",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueId" : "s"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "ext",
                      "source" : [
                        {
                          "context" : "patient",
                          "element" : "id",
                          "variable" : "id",
                          "condition" : "(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')"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "UUID",
                          "source" : [
                            {
                              "context" : "id",
                              "element" : "extension",
                              "variable" : "ext"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "requestPAT",
                              "contextType" : "variable",
                              "element" : "url",
                              "transform" : "append",
                              "parameter" : [
                                {
                                  "valueString" : "Patient?identifier="
                                },
                                {
                                  "valueId" : "ext"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentToBundle",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "composition",
          "type" : "Composition",
          "mode" : "target"
        },
        {
          "name" : "encounter",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "DocumentReference",
          "type" : "DocumentReference",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "id",
          "source" : [
            {
              "context" : "cda"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "id",
              "transform" : "uuid"
            }
          ]
        },
        {
          "name" : "identifier",
          "source" : [
            {
              "context" : "cda",
              "element" : "id",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "identifier",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "type",
          "source" : [
            {
              "context" : "cda"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "type",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "transaction"
                }
              ]
            }
          ]
        },
        {
          "name" : "date",
          "source" : [
            {
              "context" : "cda"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "timestamp",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "timestamp.now()"
                }
              ]
            }
          ]
        },
        {
          "name" : "composition",
          "source" : [
            {
              "context" : "cda"
            }
          ],
          "dependent" : [
            {
              "name" : "ClinicalDocumentComposition",
              "variable" : [
                "cda",
                "composition",
                "patient",
                "encounter",
                "bundle",
                "DocumentReference"
              ]
            }
          ]
        },
        {
          "name" : "component",
          "source" : [
            {
              "context" : "cda",
              "element" : "component",
              "variable" : "component"
            }
          ],
          "rule" : [
            {
              "name" : "body",
              "source" : [
                {
                  "context" : "component",
                  "element" : "structuredBody",
                  "variable" : "body"
                }
              ],
              "rule" : [
                {
                  "name" : "coverage",
                  "source" : [
                    {
                      "context" : "body"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "bundle",
                      "contextType" : "variable",
                      "element" : "entry",
                      "variable" : "e1"
                    },
                    {
                      "context" : "e1",
                      "contextType" : "variable",
                      "element" : "request",
                      "variable" : "request",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "BackboneElement"
                        }
                      ]
                    },
                    {
                      "context" : "request",
                      "contextType" : "variable",
                      "element" : "method",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "POST"
                        }
                      ]
                    },
                    {
                      "context" : "e1",
                      "contextType" : "variable",
                      "element" : "resource",
                      "variable" : "coverage",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Coverage"
                        }
                      ]
                    },
                    {
                      "context" : "coverage",
                      "contextType" : "variable",
                      "element" : "id",
                      "variable" : "uuid1",
                      "transform" : "uuid"
                    },
                    {
                      "context" : "e1",
                      "contextType" : "variable",
                      "element" : "fullUrl",
                      "transform" : "append",
                      "parameter" : [
                        {
                          "valueString" : "https://example/Coverage/"
                        },
                        {
                          "valueId" : "uuid1"
                        }
                      ]
                    },
                    {
                      "context" : "request",
                      "contextType" : "variable",
                      "element" : "url",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "Coverage"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "medreq",
                      "source" : [
                        {
                          "context" : "body"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "e2"
                        },
                        {
                          "context" : "e2",
                          "contextType" : "variable",
                          "element" : "request",
                          "variable" : "request",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "BackboneElement"
                            }
                          ]
                        },
                        {
                          "context" : "request",
                          "contextType" : "variable",
                          "element" : "method",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "POST"
                            }
                          ]
                        },
                        {
                          "context" : "e2",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "medRq",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "MedicationRequest"
                            }
                          ]
                        },
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "uuid1",
                          "transform" : "uuid"
                        },
                        {
                          "context" : "e2",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "https://example/MedicationRequest/"
                            },
                            {
                              "valueId" : "uuid1"
                            }
                          ]
                        },
                        {
                          "context" : "request",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "MedicationRequest"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "component",
                          "source" : [
                            {
                              "context" : "body",
                              "element" : "component",
                              "variable" : "component"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "cov",
                              "source" : [
                                {
                                  "context" : "component",
                                  "element" : "section",
                                  "variable" : "srcSection"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "esenz",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '57827-8')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionEsenzioni",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter",
                                        "coverage"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "prescfarm",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '57828-6')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionPrescrizioneFarmaceutica",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter",
                                        "coverage",
                                        "medRq"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "annot",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '48767-8')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionAnnotazioni",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter",
                                        "medRq"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "messregg",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '51851-4')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionMessaggioRegionale",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter",
                                        "medRq"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "paramvit",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '8716-3')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionParametriVitali",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "allergfarm",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '48765-2')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionAllergieaiFarmaci",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "statclinpaz",
                                  "source" : [
                                    {
                                      "context" : "srcSection",
                                      "element" : "code",
                                      "condition" : "(code = '47420-5')"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "composition",
                                      "contextType" : "variable",
                                      "element" : "section",
                                      "variable" : "tgtSection"
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "ClinicalDocumentSectionStatoClinicoPaziente",
                                      "variable" : [
                                        "cda",
                                        "srcSection",
                                        "patient",
                                        "tgtSection",
                                        "bundle",
                                        "encounter"
                                      ]
                                    }
                                  ]
                                }
                              ],
                              "documentation" : "discretizzi il primo livello di component"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionEsenzioni",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "coverage",
          "type" : "Coverage",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "cff",
          "source" : [
            {
              "context" : "src",
              "element" : "text",
              "variable" : "cdaText"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/Coverage/' + %coverage.id"
                }
              ]
            },
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "text",
              "variable" : "fhirText"
            }
          ],
          "rule" : [
            {
              "name" : "narrativeStatus",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "fhirText",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "generated"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "narrativeText",
              "source" : [
                {
                  "context" : "cdaText",
                  "variable" : "t"
                }
              ],
              "target" : [
                {
                  "context" : "fhirText",
                  "contextType" : "variable",
                  "element" : "div",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "t"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "secact",
              "source" : [
                {
                  "context" : "src",
                  "element" : "entry",
                  "variable" : "srcse"
                }
              ],
              "rule" : [
                {
                  "name" : "cdaText",
                  "source" : [
                    {
                      "context" : "srcse",
                      "element" : "act",
                      "variable" : "srcsec"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "code",
                      "source" : [
                        {
                          "context" : "srcsec",
                          "element" : "code",
                          "variable" : "vvv"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coverage",
                          "contextType" : "variable",
                          "element" : "type",
                          "variable" : "vvv",
                          "transform" : "create"
                        }
                      ]
                    },
                    {
                      "name" : "origtxt",
                      "source" : [
                        {
                          "context" : "srcsec",
                          "element" : "code",
                          "variable" : "srctxt"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "reftxt",
                          "source" : [
                            {
                              "context" : "srctxt"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "coverage",
                              "contextType" : "variable",
                              "element" : "type",
                              "variable" : "typetxt"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "rfde",
                              "source" : [
                                {
                                  "context" : "srctxt",
                                  "element" : "originalText",
                                  "variable" : "ref"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "tcf",
                                  "source" : [
                                    {
                                      "context" : "ref",
                                      "element" : "reference",
                                      "variable" : "t"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "reference",
                                      "source" : [
                                        {
                                          "context" : "t",
                                          "element" : "value",
                                          "variable" : "l"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "typetxt",
                                          "contextType" : "variable",
                                          "element" : "text",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueId" : "l"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "statuscode",
                      "source" : [
                        {
                          "context" : "srcsec",
                          "condition" : "coverage.status.exists().not()"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "status",
                          "source" : [
                            {
                              "context" : "srcsec"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "coverage",
                              "contextType" : "variable",
                              "element" : "status",
                              "transform" : "copy",
                              "parameter" : [
                                {
                                  "valueString" : "active"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "reference",
                      "source" : [
                        {
                          "context" : "srcsec"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coverage",
                          "contextType" : "variable",
                          "element" : "beneficiary",
                          "variable" : "reference",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "reference",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "'https://example/Patient/' + %patient.id"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "reference",
                      "source" : [
                        {
                          "context" : "srcsec"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coverage",
                          "contextType" : "variable",
                          "element" : "payor",
                          "variable" : "reference",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "reference",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "'https://example/Patient/' + %patient.id"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionPrescrizioneFarmaceutica",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "coverage",
          "type" : "Coverage",
          "mode" : "target"
        },
        {
          "name" : "medRq",
          "type" : "MedicationRequest",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "xxx",
          "source" : [
            {
              "context" : "src",
              "element" : "text",
              "variable" : "cdaText"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/MedicationRequest/' + %medRq.id"
                }
              ]
            },
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "text",
              "variable" : "fhirText"
            }
          ],
          "rule" : [
            {
              "name" : "id",
              "source" : [
                {
                  "context" : "src",
                  "element" : "id",
                  "variable" : "vvv"
                }
              ],
              "target" : [
                {
                  "context" : "medRq",
                  "contextType" : "variable",
                  "element" : "identifier",
                  "variable" : "vvv",
                  "transform" : "create"
                }
              ]
            },
            {
              "name" : "narrativeStatus",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "fhirText",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "generated"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "narrativeText",
              "source" : [
                {
                  "context" : "cdaText",
                  "variable" : "t"
                }
              ],
              "target" : [
                {
                  "context" : "fhirText",
                  "contextType" : "variable",
                  "element" : "div",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "t"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "medRq",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Patient/' + %patient.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "medRq",
                  "contextType" : "variable",
                  "element" : "encounter",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Encounter/' + %enc.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "status",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "medRq",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "active"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "intent",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "medRq",
                  "contextType" : "variable",
                  "element" : "intent",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "order"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "hnjh",
              "source" : [
                {
                  "context" : "src",
                  "element" : "entry",
                  "variable" : "srcent"
                }
              ],
              "rule" : [
                {
                  "name" : "subadm",
                  "source" : [
                    {
                      "context" : "srcent",
                      "element" : "substanceAdministration",
                      "variable" : "subAdm"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "dosage",
                      "source" : [
                        {
                          "context" : "subAdm",
                          "type" : "IVL_TS",
                          "element" : "effectiveTime",
                          "variable" : "eff"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "dosageInstruction",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "timing",
                          "source" : [
                            {
                              "context" : "subAdm"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "dosage",
                              "contextType" : "variable",
                              "element" : "timing",
                              "variable" : "tim",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Timing"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "repeat",
                              "source" : [
                                {
                                  "context" : "subAdm"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "tim",
                                  "contextType" : "variable",
                                  "element" : "repeat",
                                  "variable" : "repeat"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "boundsperiod",
                                  "source" : [
                                    {
                                      "context" : "eff"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "repeat",
                                      "contextType" : "variable",
                                      "element" : "bounds",
                                      "variable" : "period",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "Period"
                                        }
                                      ]
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "IVLTSPeriod",
                                      "variable" : [
                                        "eff",
                                        "period"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "width",
                                  "source" : [
                                    {
                                      "context" : "eff",
                                      "element" : "width",
                                      "variable" : "width"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "value",
                                      "source" : [
                                        {
                                          "context" : "width",
                                          "element" : "value",
                                          "variable" : "v"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "repeat",
                                          "contextType" : "variable",
                                          "element" : "duration",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueId" : "v"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "unit",
                                      "source" : [
                                        {
                                          "context" : "width",
                                          "element" : "unit",
                                          "variable" : "u"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "repeat",
                                          "contextType" : "variable",
                                          "element" : "durationUnit",
                                          "transform" : "copy",
                                          "parameter" : [
                                            {
                                              "valueId" : "u"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "dosage1",
                      "source" : [
                        {
                          "context" : "subAdm",
                          "element" : "effectiveTime",
                          "variable" : "eff"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "dosageInstruction",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "timing1",
                          "source" : [
                            {
                              "context" : "subAdm"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "dosage",
                              "contextType" : "variable",
                              "element" : "timing",
                              "variable" : "tim",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Timing"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "effct1",
                              "source" : [
                                {
                                  "context" : "eff",
                                  "condition" : "eff.low.exists().not() and eff.high.exists().not()"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "evnt",
                                  "source" : [
                                    {
                                      "context" : "eff",
                                      "element" : "value",
                                      "variable" : "v"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "tim",
                                      "contextType" : "variable",
                                      "element" : "event",
                                      "variable" : "event",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "dateTime"
                                        }
                                      ]
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "TSDateTime",
                                      "variable" : [
                                        "v",
                                        "event"
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "eff",
                      "source" : [
                        {
                          "context" : "subAdm",
                          "type" : "PIVL_TS",
                          "element" : "effectiveTime",
                          "variable" : "effp"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "dosageInstruction",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "timing",
                          "source" : [
                            {
                              "context" : "effp"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "dosage",
                              "contextType" : "variable",
                              "element" : "timing",
                              "variable" : "timing",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Timing"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "cod",
                              "source" : [
                                {
                                  "context" : "effp"
                                }
                              ],
                              "target" : [
                                {
                                  "contextType" : "variable",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "timing"
                                    }
                                  ]
                                }
                              ],
                              "dependent" : [
                                {
                                  "name" : "periodTiming",
                                  "variable" : [
                                    "effp",
                                    "timing"
                                  ]
                                }
                              ]
                            },
                            {
                              "name" : "phase",
                              "source" : [
                                {
                                  "context" : "effp",
                                  "condition" : "effp.phase.exists()"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "rep",
                                  "source" : [
                                    {
                                      "context" : "effp",
                                      "element" : "phase",
                                      "variable" : "phase"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "timing",
                                      "contextType" : "variable",
                                      "element" : "repeat",
                                      "variable" : "r"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "low",
                                      "source" : [
                                        {
                                          "context" : "phase",
                                          "element" : "low"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "r",
                                          "contextType" : "variable",
                                          "element" : "bounds",
                                          "variable" : "period",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "Period"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "lo",
                                          "source" : [
                                            {
                                              "context" : "phase",
                                              "element" : "low",
                                              "variable" : "vvv"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "period",
                                              "contextType" : "variable",
                                              "element" : "start",
                                              "variable" : "vvv",
                                              "transform" : "create"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "dur",
                                      "source" : [
                                        {
                                          "context" : "phase",
                                          "element" : "width",
                                          "variable" : "wid"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "vals",
                                          "source" : [
                                            {
                                              "context" : "wid",
                                              "element" : "value",
                                              "variable" : "v"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "r",
                                              "contextType" : "variable",
                                              "element" : "duration",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueId" : "v"
                                                }
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "unit",
                                          "source" : [
                                            {
                                              "context" : "wid",
                                              "element" : "unit",
                                              "variable" : "u"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "r",
                                              "contextType" : "variable",
                                              "element" : "durationUnit",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueId" : "u"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "eff",
                      "source" : [
                        {
                          "context" : "subAdm",
                          "type" : "EIVL_TS",
                          "element" : "effectiveTime",
                          "variable" : "effe"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "dosageInstruction",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "ghj",
                          "source" : [
                            {
                              "context" : "effe"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "dosage",
                              "contextType" : "variable",
                              "element" : "timing",
                              "variable" : "timing",
                              "transform" : "create",
                              "parameter" : [
                                {
                                  "valueString" : "Timing"
                                }
                              ]
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "lkj",
                              "source" : [
                                {
                                  "context" : "effe"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "timing",
                                  "contextType" : "variable",
                                  "element" : "repeat",
                                  "variable" : "r"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "event",
                                  "source" : [
                                    {
                                      "context" : "effe",
                                      "element" : "event",
                                      "variable" : "vvv"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "r",
                                      "contextType" : "variable",
                                      "element" : "when",
                                      "variable" : "vvv",
                                      "transform" : "create"
                                    }
                                  ]
                                },
                                {
                                  "name" : "poi",
                                  "source" : [
                                    {
                                      "context" : "effe",
                                      "element" : "offset",
                                      "variable" : "offset"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "offs",
                                      "source" : [
                                        {
                                          "context" : "offset",
                                          "element" : "low",
                                          "variable" : "v"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "barabar",
                                          "source" : [
                                            {
                                              "context" : "v",
                                              "element" : "value",
                                              "variable" : "o"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "r",
                                              "contextType" : "variable",
                                              "element" : "offset",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueId" : "o"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "doseQuant",
                      "source" : [
                        {
                          "context" : "subAdm",
                          "element" : "doseQuantity",
                          "variable" : "doseQuant"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "dosageInstruction",
                          "variable" : "dosage",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Dosage"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "ot",
                          "source" : [
                            {
                              "context" : "doseQuant",
                              "element" : "originalText",
                              "variable" : "ot"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "reference",
                              "source" : [
                                {
                                  "context" : "ot",
                                  "element" : "reference",
                                  "variable" : "vvv"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosage",
                                  "contextType" : "variable",
                                  "element" : "text",
                                  "variable" : "vvv",
                                  "transform" : "create"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "dosageRate",
                          "source" : [
                            {
                              "context" : "doseQuant"
                            }
                          ],
                          "target" : [
                            {
                              "context" : "dosage",
                              "contextType" : "variable",
                              "element" : "doseAndRate",
                              "variable" : "dosageRate"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "d",
                              "source" : [
                                {
                                  "context" : "doseQuant"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "dosageRate",
                                  "contextType" : "variable",
                                  "element" : "dose",
                                  "variable" : "d",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Range"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "low",
                                  "source" : [
                                    {
                                      "context" : "doseQuant"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "d",
                                      "contextType" : "variable",
                                      "element" : "low",
                                      "variable" : "l",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "SimpleQuantity"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "low",
                                      "source" : [
                                        {
                                          "context" : "doseQuant",
                                          "element" : "low",
                                          "variable" : "lo"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "l",
                                          "contextType" : "variable",
                                          "element" : "value",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "lo.value"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "low",
                                      "source" : [
                                        {
                                          "context" : "doseQuant",
                                          "element" : "low",
                                          "variable" : "lo"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "l",
                                          "contextType" : "variable",
                                          "element" : "unit",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "lo.unit"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "low",
                                  "source" : [
                                    {
                                      "context" : "doseQuant"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "d",
                                      "contextType" : "variable",
                                      "element" : "high",
                                      "variable" : "h",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "SimpleQuantity"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "high",
                                      "source" : [
                                        {
                                          "context" : "doseQuant",
                                          "element" : "high",
                                          "variable" : "hi"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "h",
                                          "contextType" : "variable",
                                          "element" : "value",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "hi.value"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "high",
                                      "source" : [
                                        {
                                          "context" : "doseQuant",
                                          "element" : "high",
                                          "variable" : "hi"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "h",
                                          "contextType" : "variable",
                                          "element" : "unit",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "hi.unit"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "subsadm",
                      "source" : [
                        {
                          "context" : "subAdm"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "bundle",
                          "contextType" : "variable",
                          "element" : "entry",
                          "variable" : "e1"
                        },
                        {
                          "context" : "e1",
                          "contextType" : "variable",
                          "element" : "request",
                          "variable" : "request",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "BackboneElement"
                            }
                          ]
                        },
                        {
                          "context" : "request",
                          "contextType" : "variable",
                          "element" : "method",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "POST"
                            }
                          ]
                        },
                        {
                          "context" : "e1",
                          "contextType" : "variable",
                          "element" : "resource",
                          "variable" : "medication",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Medication"
                            }
                          ]
                        },
                        {
                          "context" : "medication",
                          "contextType" : "variable",
                          "element" : "id",
                          "variable" : "uuid1",
                          "transform" : "uuid"
                        },
                        {
                          "context" : "e1",
                          "contextType" : "variable",
                          "element" : "fullUrl",
                          "transform" : "append",
                          "parameter" : [
                            {
                              "valueString" : "https://example/Medication/"
                            },
                            {
                              "valueId" : "uuid1"
                            }
                          ]
                        },
                        {
                          "context" : "request",
                          "contextType" : "variable",
                          "element" : "url",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "Medication"
                            }
                          ]
                        },
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "medication",
                          "variable" : "reference",
                          "transform" : "create",
                          "parameter" : [
                            {
                              "valueString" : "Reference"
                            }
                          ]
                        },
                        {
                          "context" : "reference",
                          "contextType" : "variable",
                          "element" : "reference",
                          "transform" : "evaluate",
                          "parameter" : [
                            {
                              "valueString" : "'https://example/Medication/' + %medication.id"
                            }
                          ]
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "cons",
                          "source" : [
                            {
                              "context" : "subAdm",
                              "element" : "consumable",
                              "variable" : "cons"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "manumat",
                              "source" : [
                                {
                                  "context" : "cons",
                                  "element" : "manufacturedProduct",
                                  "variable" : "manuprod"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "manudrug",
                                  "source" : [
                                    {
                                      "context" : "manuprod",
                                      "element" : "manufacturedLabeledDrug",
                                      "variable" : "manudrug"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "code",
                                      "source" : [
                                        {
                                          "context" : "manudrug",
                                          "element" : "code",
                                          "variable" : "vvv"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "code",
                                          "variable" : "vvv",
                                          "transform" : "create"
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "idmedname",
                                      "source" : [
                                        {
                                          "context" : "manudrug"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "identifier",
                                          "variable" : "medid"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "name",
                                          "source" : [
                                            {
                                              "context" : "manudrug",
                                              "element" : "name",
                                              "variable" : "vvv"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "medid",
                                              "contextType" : "variable",
                                              "element" : "value",
                                              "variable" : "vvv",
                                              "transform" : "create"
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "origtxtd",
                                      "source" : [
                                        {
                                          "context" : "manudrug",
                                          "element" : "code",
                                          "variable" : "srctxt"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "reftxtd",
                                          "source" : [
                                            {
                                              "context" : "srctxt"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "medication",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "variable" : "typetxt"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "tcfg",
                                              "source" : [
                                                {
                                                  "context" : "srctxt",
                                                  "element" : "originalText",
                                                  "variable" : "ref"
                                                }
                                              ],
                                              "rule" : [
                                                {
                                                  "name" : "tcf",
                                                  "source" : [
                                                    {
                                                      "context" : "ref",
                                                      "element" : "reference",
                                                      "variable" : "reference"
                                                    }
                                                  ],
                                                  "rule" : [
                                                    {
                                                      "name" : "reference",
                                                      "source" : [
                                                        {
                                                          "context" : "reference",
                                                          "element" : "value",
                                                          "variable" : "l"
                                                        }
                                                      ],
                                                      "target" : [
                                                        {
                                                          "context" : "typetxt",
                                                          "contextType" : "variable",
                                                          "element" : "text",
                                                          "transform" : "copy",
                                                          "parameter" : [
                                                            {
                                                              "valueId" : "l"
                                                            }
                                                          ]
                                                        }
                                                      ]
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "manuFact",
                                  "source" : [
                                    {
                                      "context" : "manuprod",
                                      "element" : "manufacturedMaterial",
                                      "variable" : "manufact"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "code",
                                      "source" : [
                                        {
                                          "context" : "manufact",
                                          "element" : "code",
                                          "variable" : "vvv"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "code",
                                          "variable" : "vvv",
                                          "transform" : "create"
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "origtxt",
                                      "source" : [
                                        {
                                          "context" : "manufact",
                                          "element" : "code",
                                          "variable" : "srctxt"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "reftxt",
                                          "source" : [
                                            {
                                              "context" : "srctxt"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "medication",
                                              "contextType" : "variable",
                                              "element" : "code",
                                              "variable" : "typetxt"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "tcfg",
                                              "source" : [
                                                {
                                                  "context" : "srctxt",
                                                  "element" : "originalText",
                                                  "variable" : "ref"
                                                }
                                              ],
                                              "rule" : [
                                                {
                                                  "name" : "tcf",
                                                  "source" : [
                                                    {
                                                      "context" : "ref",
                                                      "element" : "reference",
                                                      "variable" : "reference"
                                                    }
                                                  ],
                                                  "rule" : [
                                                    {
                                                      "name" : "reference",
                                                      "source" : [
                                                        {
                                                          "context" : "reference",
                                                          "element" : "value",
                                                          "variable" : "l"
                                                        }
                                                      ],
                                                      "target" : [
                                                        {
                                                          "context" : "typetxt",
                                                          "contextType" : "variable",
                                                          "element" : "text",
                                                          "transform" : "copy",
                                                          "parameter" : [
                                                            {
                                                              "valueId" : "l"
                                                            }
                                                          ]
                                                        }
                                                      ]
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "ingr",
                                      "source" : [
                                        {
                                          "context" : "manufact",
                                          "element" : "ingredient",
                                          "variable" : "ingredient"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "ingredient",
                                          "variable" : "ing"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "strength",
                                          "source" : [
                                            {
                                              "context" : "ingredient",
                                              "element" : "quantity",
                                              "variable" : "quantity"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "ing",
                                              "contextType" : "variable",
                                              "element" : "strength",
                                              "variable" : "strength",
                                              "transform" : "create",
                                              "parameter" : [
                                                {
                                                  "valueString" : "Ratio"
                                                }
                                              ]
                                            }
                                          ],
                                          "dependent" : [
                                            {
                                              "name" : "EmedRTOPQPQRatio",
                                              "variable" : [
                                                "quantity",
                                                "strength"
                                              ]
                                            }
                                          ]
                                        },
                                        {
                                          "name" : "ingredientCode",
                                          "source" : [
                                            {
                                              "context" : "manufact"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "ing",
                                              "contextType" : "variable",
                                              "element" : "item",
                                              "variable" : "ingcode",
                                              "transform" : "create",
                                              "parameter" : [
                                                {
                                                  "valueString" : "CodeableConcept"
                                                }
                                              ]
                                            },
                                            {
                                              "context" : "ingcode",
                                              "contextType" : "variable",
                                              "element" : "text",
                                              "transform" : "evaluate",
                                              "parameter" : [
                                                {
                                                  "valueString" : "%manufact.name.other"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "formCode",
                                      "source" : [
                                        {
                                          "context" : "manufact",
                                          "element" : "formCode",
                                          "variable" : "vvv"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "form",
                                          "variable" : "vvv",
                                          "transform" : "create"
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "transl",
                                      "source" : [
                                        {
                                          "context" : "manufact"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medication",
                                          "contextType" : "variable",
                                          "element" : "identifier",
                                          "variable" : "medid"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "entry1",
                          "source" : [
                            {
                              "context" : "subAdm",
                              "element" : "entryRelationship",
                              "variable" : "entryrel1"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "supply",
                              "source" : [
                                {
                                  "context" : "entryrel1",
                                  "element" : "supply",
                                  "variable" : "sup"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medRq",
                                  "contextType" : "variable",
                                  "element" : "dispenseRequest",
                                  "variable" : "dispreq"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "quantity",
                                  "source" : [
                                    {
                                      "context" : "sup"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "dispreq",
                                      "contextType" : "variable",
                                      "element" : "quantity",
                                      "variable" : "quantity",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "SimpleQuantity"
                                        }
                                      ]
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "quantity",
                                      "source" : [
                                        {
                                          "context" : "sup",
                                          "element" : "quantity",
                                          "variable" : "q"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "quantity",
                                          "contextType" : "variable",
                                          "element" : "value",
                                          "transform" : "evaluate",
                                          "parameter" : [
                                            {
                                              "valueString" : "q.value"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "entry2",
                          "source" : [
                            {
                              "context" : "subAdm",
                              "element" : "entryRelationship",
                              "variable" : "entryrel2",
                              "condition" : "(typeCode = 'REFR')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "Cover",
                              "source" : [
                                {
                                  "context" : "subAdm"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medRq",
                                  "contextType" : "variable",
                                  "element" : "insurance",
                                  "variable" : "reference",
                                  "transform" : "create",
                                  "parameter" : [
                                    {
                                      "valueString" : "Reference"
                                    }
                                  ]
                                },
                                {
                                  "context" : "reference",
                                  "contextType" : "variable",
                                  "element" : "reference",
                                  "transform" : "evaluate",
                                  "parameter" : [
                                    {
                                      "valueString" : "'https://example/Coverage/' + %coverage.id"
                                    }
                                  ]
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "act2",
                                  "source" : [
                                    {
                                      "context" : "entryrel2",
                                      "element" : "act",
                                      "variable" : "act2"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "coverage",
                                      "contextType" : "variable",
                                      "element" : "costToBeneficiary",
                                      "variable" : "cost"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "beneficmoney",
                                      "source" : [
                                        {
                                          "context" : "act2"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "cost",
                                          "contextType" : "variable",
                                          "element" : "value",
                                          "variable" : "val",
                                          "transform" : "create",
                                          "parameter" : [
                                            {
                                              "valueString" : "SimpleQuantity"
                                            }
                                          ]
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "bnm",
                                          "source" : [
                                            {
                                              "context" : "act2"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "val",
                                              "contextType" : "variable",
                                              "element" : "value",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueString" : "0"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    },
                                    {
                                      "name" : "exept",
                                      "source" : [
                                        {
                                          "context" : "act2"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "cost",
                                          "contextType" : "variable",
                                          "element" : "exception",
                                          "variable" : "except"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "code",
                                          "source" : [
                                            {
                                              "context" : "act2",
                                              "element" : "code",
                                              "variable" : "vvv"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "except",
                                              "contextType" : "variable",
                                              "element" : "type",
                                              "variable" : "vvv",
                                              "transform" : "create"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "entry2",
                          "source" : [
                            {
                              "context" : "subAdm",
                              "element" : "entryRelationship",
                              "variable" : "entryrel3",
                              "condition" : "(typeCode = 'RSON')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "obs3",
                              "source" : [
                                {
                                  "context" : "entryrel3",
                                  "element" : "observation",
                                  "variable" : "obs3",
                                  "condition" : "(classCode = 'OBS')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "code",
                                  "source" : [
                                    {
                                      "context" : "obs3",
                                      "element" : "code",
                                      "variable" : "vvv"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medRq",
                                      "contextType" : "variable",
                                      "element" : "reasonCode",
                                      "variable" : "vvv",
                                      "transform" : "create"
                                    }
                                  ]
                                },
                                {
                                  "name" : "txt",
                                  "source" : [
                                    {
                                      "context" : "obs3",
                                      "element" : "text",
                                      "variable" : "text"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "originltext",
                                      "source" : [
                                        {
                                          "context" : "text"
                                        }
                                      ],
                                      "target" : [
                                        {
                                          "context" : "medRq",
                                          "contextType" : "variable",
                                          "element" : "reasonCode",
                                          "variable" : "ce"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "tcf",
                                          "source" : [
                                            {
                                              "context" : "text",
                                              "element" : "reference",
                                              "variable" : "reference"
                                            }
                                          ],
                                          "rule" : [
                                            {
                                              "name" : "reference",
                                              "source" : [
                                                {
                                                  "context" : "reference",
                                                  "element" : "value",
                                                  "variable" : "l"
                                                }
                                              ],
                                              "target" : [
                                                {
                                                  "context" : "ce",
                                                  "contextType" : "variable",
                                                  "element" : "text",
                                                  "transform" : "copy",
                                                  "parameter" : [
                                                    {
                                                      "valueId" : "l"
                                                    }
                                                  ]
                                                }
                                              ]
                                            }
                                          ],
                                          "documentation" : "text.reference as reference-> ce.text=reference;"
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "code",
                          "source" : [
                            {
                              "context" : "subAdm",
                              "element" : "entryRelationship",
                              "variable" : "entryrel4",
                              "condition" : "(typeCode = 'SUBJ')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "obs",
                              "source" : [
                                {
                                  "context" : "entryrel4",
                                  "element" : "observation",
                                  "variable" : "obs3"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "medRq",
                                  "contextType" : "variable",
                                  "element" : "substitution",
                                  "variable" : "sub"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "code",
                                  "source" : [
                                    {
                                      "context" : "obs3",
                                      "element" : "code",
                                      "variable" : "Code"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "sub",
                                      "contextType" : "variable",
                                      "element" : "allowed",
                                      "variable" : "allowed",
                                      "transform" : "create",
                                      "parameter" : [
                                        {
                                          "valueString" : "CodeableConcept"
                                        }
                                      ]
                                    }
                                  ],
                                  "dependent" : [
                                    {
                                      "name" : "CECodeableConcept",
                                      "variable" : [
                                        "Code",
                                        "allowed"
                                      ]
                                    }
                                  ]
                                },
                                {
                                  "name" : "entry",
                                  "source" : [
                                    {
                                      "context" : "obs3",
                                      "element" : "entryRelationship",
                                      "variable" : "entry"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "obs4",
                                      "source" : [
                                        {
                                          "context" : "entry",
                                          "element" : "observation",
                                          "variable" : "obs4"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "code",
                                          "source" : [
                                            {
                                              "context" : "obs4",
                                              "element" : "code",
                                              "variable" : "vvv"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "sub",
                                              "contextType" : "variable",
                                              "element" : "reason",
                                              "variable" : "vvv",
                                              "transform" : "create"
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name" : "entry2",
                          "source" : [
                            {
                              "context" : "subAdm",
                              "element" : "entryRelationship",
                              "variable" : "entryrel2",
                              "condition" : "(typeCode = 'SUBJ')"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "obs3",
                              "source" : [
                                {
                                  "context" : "entryrel2",
                                  "element" : "act",
                                  "variable" : "act2",
                                  "condition" : "(classCode = 'ACT')"
                                }
                              ],
                              "rule" : [
                                {
                                  "name" : "reference",
                                  "source" : [
                                    {
                                      "context" : "act2",
                                      "element" : "text",
                                      "variable" : "text"
                                    }
                                  ],
                                  "target" : [
                                    {
                                      "context" : "medRq",
                                      "contextType" : "variable",
                                      "element" : "note",
                                      "variable" : "note"
                                    }
                                  ],
                                  "rule" : [
                                    {
                                      "name" : "tcx",
                                      "source" : [
                                        {
                                          "context" : "text",
                                          "element" : "reference",
                                          "variable" : "t"
                                        }
                                      ],
                                      "rule" : [
                                        {
                                          "name" : "reference",
                                          "source" : [
                                            {
                                              "context" : "t",
                                              "element" : "value",
                                              "variable" : "l"
                                            }
                                          ],
                                          "target" : [
                                            {
                                              "context" : "note",
                                              "contextType" : "variable",
                                              "element" : "text",
                                              "transform" : "copy",
                                              "parameter" : [
                                                {
                                                  "valueId" : "l"
                                                }
                                              ]
                                            }
                                          ]
                                        }
                                      ]
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionAnnotazioni",
      "typeMode" : "none",
      "documentation" : "------------Sezione Annotazioni-----------------------------------------------------------------------------------------------------------------------------------------",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "medRq",
          "type" : "MedicationRequest",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "entry",
          "source" : [
            {
              "context" : "src",
              "element" : "text",
              "variable" : "cdaText"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/MedicationRequest/' + %medRq.id"
                }
              ]
            },
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "text",
              "variable" : "fhirText"
            }
          ],
          "rule" : [
            {
              "name" : "narrativeStatus",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "fhirText",
                  "contextType" : "variable",
                  "element" : "status",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueString" : "generated"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "narrativeText",
              "source" : [
                {
                  "context" : "cdaText",
                  "variable" : "t"
                }
              ],
              "target" : [
                {
                  "context" : "fhirText",
                  "contextType" : "variable",
                  "element" : "div",
                  "transform" : "copy",
                  "parameter" : [
                    {
                      "valueId" : "t"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "entry",
              "source" : [
                {
                  "context" : "src",
                  "element" : "entry",
                  "variable" : "entry"
                }
              ],
              "rule" : [
                {
                  "name" : "act",
                  "source" : [
                    {
                      "context" : "entry",
                      "element" : "act",
                      "variable" : "act"
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "reference",
                      "source" : [
                        {
                          "context" : "act",
                          "element" : "text",
                          "variable" : "text"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "medRq",
                          "contextType" : "variable",
                          "element" : "note",
                          "variable" : "note"
                        }
                      ],
                      "rule" : [
                        {
                          "name" : "tcx",
                          "source" : [
                            {
                              "context" : "text",
                              "element" : "reference",
                              "variable" : "t"
                            }
                          ],
                          "rule" : [
                            {
                              "name" : "reference",
                              "source" : [
                                {
                                  "context" : "t",
                                  "element" : "value",
                                  "variable" : "l"
                                }
                              ],
                              "target" : [
                                {
                                  "context" : "note",
                                  "contextType" : "variable",
                                  "element" : "text",
                                  "transform" : "copy",
                                  "parameter" : [
                                    {
                                      "valueId" : "l"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionMessaggioRegionale",
      "typeMode" : "none",
      "documentation" : "------------Sezione Messaggio Regionale-----------------------------------------------------------------------------------------------------------------------------------------",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        },
        {
          "name" : "medRq",
          "type" : "MedicationRequest",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "entry",
          "source" : [
            {
              "context" : "src",
              "element" : "text",
              "variable" : "cdaText"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/MedicationRequest/' + %medRq.id"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "nota",
              "source" : [
                {
                  "context" : "cdaText",
                  "variable" : "text"
                }
              ],
              "target" : [
                {
                  "context" : "medRq",
                  "contextType" : "variable",
                  "element" : "note",
                  "variable" : "note"
                }
              ],
              "rule" : [
                {
                  "name" : "reference",
                  "source" : [
                    {
                      "context" : "text",
                      "variable" : "t"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "note",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "t"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionParametriVitali",
      "typeMode" : "none",
      "documentation" : "------------Sezione Parametri Vitali-----------------------------------------------------------------------------------------------------------------------------------------",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "nota",
          "source" : [
            {
              "context" : "src",
              "element" : "text",
              "variable" : "cdaText"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e8"
            },
            {
              "context" : "e8",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "e8",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "Observation",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Observation"
                }
              ]
            },
            {
              "context" : "Observation",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid8",
              "transform" : "uuid"
            },
            {
              "context" : "e8",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/Observation/"
                },
                {
                  "valueId" : "uuid8"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "Observation"
                }
              ]
            },
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/Observation/' + %Observation.id"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Patient/' + %patient.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "encounter",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Encounter/' + %enc.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "code",
              "source" : [
                {
                  "context" : "src",
                  "element" : "code",
                  "variable" : "vvv"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "vvv",
                  "transform" : "create"
                }
              ]
            },
            {
              "name" : "statuscode",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "Observation.statusCode.exists().not()"
                }
              ],
              "rule" : [
                {
                  "name" : "status",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "Observation",
                      "contextType" : "variable",
                      "element" : "status",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "final"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "note",
                  "variable" : "note"
                }
              ],
              "rule" : [
                {
                  "name" : "reference",
                  "source" : [
                    {
                      "context" : "cdaText",
                      "variable" : "t"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "note",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "t"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionAllergieaiFarmaci",
      "typeMode" : "none",
      "documentation" : "------------Sezione Allergie_Intolleranze-----------------------------------------------------------------------------------------------------------------------------------------",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "nota",
          "source" : [
            {
              "context" : "src"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e9"
            },
            {
              "context" : "e9",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "e9",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "allergyIntolerance",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "AllergyIntolerance"
                }
              ]
            },
            {
              "context" : "allergyIntolerance",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid9",
              "transform" : "uuid"
            },
            {
              "context" : "e9",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/AllergyIntolerance/"
                },
                {
                  "valueId" : "uuid9"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "AllergyIntolerance"
                }
              ]
            },
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/AllergyIntolerance/' + %allergyIntolerance.id"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "allergyIntolerance",
                  "contextType" : "variable",
                  "element" : "patient",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Patient/' + %patient.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "allergy",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "allergyIntolerance",
                  "contextType" : "variable",
                  "element" : "clinicalStatus",
                  "variable" : "status",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule" : [
                {
                  "name" : "text",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "status",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "string"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name" : "coding",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "status",
                      "contextType" : "variable",
                      "element" : "coding",
                      "variable" : "coding",
                      "transform" : "create",
                      "parameter" : [
                        {
                          "valueString" : "Coding"
                        }
                      ]
                    }
                  ],
                  "rule" : [
                    {
                      "name" : "active",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "code",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "active"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name" : "system",
                      "source" : [
                        {
                          "context" : "src"
                        }
                      ],
                      "target" : [
                        {
                          "context" : "coding",
                          "contextType" : "variable",
                          "element" : "system",
                          "transform" : "copy",
                          "parameter" : [
                            {
                              "valueString" : "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "src",
                  "element" : "text",
                  "variable" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "allergyIntolerance",
                  "contextType" : "variable",
                  "element" : "note",
                  "variable" : "note"
                }
              ],
              "rule" : [
                {
                  "name" : "reference",
                  "source" : [
                    {
                      "context" : "cdaText",
                      "variable" : "t"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "note",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "t"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "ClinicalDocumentSectionStatoClinicoPaziente",
      "typeMode" : "none",
      "documentation" : "------------Sezione Stato Clinico del Paziente----------------------------------------------------------------------------------------------------------------------------------------",
      "input" : [
        {
          "name" : "cda",
          "type" : "ClinicalDocument",
          "mode" : "source"
        },
        {
          "name" : "src",
          "type" : "Section",
          "mode" : "source"
        },
        {
          "name" : "patient",
          "type" : "Patient",
          "mode" : "target"
        },
        {
          "name" : "tgt",
          "mode" : "target"
        },
        {
          "name" : "bundle",
          "type" : "Bundle",
          "mode" : "target"
        },
        {
          "name" : "enc",
          "type" : "Encounter",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "title",
          "source" : [
            {
              "context" : "src",
              "element" : "title",
              "variable" : "t"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "title",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "t.dataString"
                }
              ]
            }
          ]
        },
        {
          "name" : "code",
          "source" : [
            {
              "context" : "src",
              "element" : "code",
              "variable" : "vvv"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "variable" : "vvv",
              "transform" : "create"
            }
          ]
        },
        {
          "name" : "nota",
          "source" : [
            {
              "context" : "src",
              "element" : "text",
              "variable" : "cdaText"
            }
          ],
          "target" : [
            {
              "context" : "bundle",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "e7"
            },
            {
              "context" : "e7",
              "contextType" : "variable",
              "element" : "request",
              "variable" : "request",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "BackboneElement"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "method",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "POST"
                }
              ]
            },
            {
              "context" : "e7",
              "contextType" : "variable",
              "element" : "resource",
              "variable" : "Observation",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Observation"
                }
              ]
            },
            {
              "context" : "Observation",
              "contextType" : "variable",
              "element" : "id",
              "variable" : "uuid7",
              "transform" : "uuid"
            },
            {
              "context" : "e7",
              "contextType" : "variable",
              "element" : "fullUrl",
              "transform" : "append",
              "parameter" : [
                {
                  "valueString" : "https://example/Observation/"
                },
                {
                  "valueId" : "uuid7"
                }
              ]
            },
            {
              "context" : "request",
              "contextType" : "variable",
              "element" : "url",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueString" : "Observation"
                }
              ]
            },
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "entry",
              "variable" : "reference",
              "transform" : "create",
              "parameter" : [
                {
                  "valueString" : "Reference"
                }
              ]
            },
            {
              "context" : "reference",
              "contextType" : "variable",
              "element" : "reference",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'https://example/Observation/' + %Observation.id"
                }
              ]
            }
          ],
          "rule" : [
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "subject",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Patient/' + %patient.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "src"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "encounter",
                  "variable" : "reference",
                  "transform" : "create",
                  "parameter" : [
                    {
                      "valueString" : "Reference"
                    }
                  ]
                },
                {
                  "context" : "reference",
                  "contextType" : "variable",
                  "element" : "reference",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "'https://example/Encounter/' + %enc.id"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "code",
              "source" : [
                {
                  "context" : "src",
                  "element" : "code",
                  "variable" : "vvv"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "code",
                  "variable" : "vvv",
                  "transform" : "create"
                }
              ]
            },
            {
              "name" : "statuscode",
              "source" : [
                {
                  "context" : "src",
                  "condition" : "Observation.statusCode.exists().not()"
                }
              ],
              "rule" : [
                {
                  "name" : "status",
                  "source" : [
                    {
                      "context" : "src"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "Observation",
                      "contextType" : "variable",
                      "element" : "status",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueString" : "final"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name" : "reference",
              "source" : [
                {
                  "context" : "cdaText"
                }
              ],
              "target" : [
                {
                  "context" : "Observation",
                  "contextType" : "variable",
                  "element" : "note",
                  "variable" : "note"
                }
              ],
              "rule" : [
                {
                  "name" : "reference",
                  "source" : [
                    {
                      "context" : "cdaText",
                      "variable" : "t"
                    }
                  ],
                  "target" : [
                    {
                      "context" : "note",
                      "contextType" : "variable",
                      "element" : "text",
                      "transform" : "copy",
                      "parameter" : [
                        {
                          "valueId" : "t"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "periodTiming",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "effectiveTime",
          "type" : "PIVL_TS",
          "mode" : "source"
        },
        {
          "name" : "timing",
          "type" : "Timing",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "repeat",
          "source" : [
            {
              "context" : "effectiveTime"
            }
          ],
          "target" : [
            {
              "context" : "timing",
              "contextType" : "variable",
              "element" : "repeat",
              "variable" : "r"
            }
          ],
          "rule" : [
            {
              "name" : "period",
              "source" : [
                {
                  "context" : "effectiveTime",
                  "element" : "period",
                  "variable" : "p"
                }
              ],
              "target" : [
                {
                  "context" : "r",
                  "contextType" : "variable",
                  "element" : "period",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "p.value"
                    }
                  ]
                }
              ]
            },
            {
              "name" : "period",
              "source" : [
                {
                  "context" : "effectiveTime",
                  "element" : "period",
                  "variable" : "p"
                }
              ],
              "target" : [
                {
                  "context" : "r",
                  "contextType" : "variable",
                  "element" : "periodUnit",
                  "transform" : "evaluate",
                  "parameter" : [
                    {
                      "valueString" : "p.unit"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "EmedRTOPQPQRatio",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "RTO_PQ_PQ",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "Ratio",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "numerator",
          "source" : [
            {
              "context" : "src",
              "element" : "numerator",
              "variable" : "numerator"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "numerator",
              "variable" : "targetNumerator"
            }
          ],
          "dependent" : [
            {
              "name" : "EmedPQQuantity",
              "variable" : [
                "numerator",
                "targetNumerator"
              ]
            }
          ]
        },
        {
          "name" : "denominator",
          "source" : [
            {
              "context" : "src",
              "element" : "denominator",
              "variable" : "denominator"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "denominator",
              "variable" : "targetDenominator"
            }
          ],
          "dependent" : [
            {
              "name" : "EmedPQQuantity",
              "variable" : [
                "denominator",
                "targetDenominator"
              ]
            }
          ]
        }
      ]
    },
    {
      "name" : "EmedPQQuantity",
      "typeMode" : "none",
      "input" : [
        {
          "name" : "src",
          "type" : "PQ",
          "mode" : "source"
        },
        {
          "name" : "tgt",
          "type" : "Quantity",
          "mode" : "target"
        }
      ],
      "rule" : [
        {
          "name" : "value",
          "source" : [
            {
              "context" : "src",
              "element" : "value",
              "variable" : "value"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "value",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "value"
                }
              ]
            }
          ]
        },
        {
          "name" : "unit",
          "source" : [
            {
              "context" : "src",
              "element" : "unit",
              "variable" : "unit"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "code",
              "transform" : "copy",
              "parameter" : [
                {
                  "valueId" : "unit"
                }
              ]
            }
          ]
        },
        {
          "name" : "unit",
          "source" : [
            {
              "context" : "src",
              "element" : "unit",
              "variable" : "unit"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "system",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system"
                }
              ]
            }
          ]
        },
        {
          "name" : "unit",
          "source" : [
            {
              "context" : "src",
              "element" : "unit",
              "variable" : "unit"
            }
          ],
          "target" : [
            {
              "context" : "tgt",
              "contextType" : "variable",
              "element" : "unit",
              "transform" : "evaluate",
              "parameter" : [
                {
                  "valueString" : "'http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}