CDA-FHIR-Maps (R4)
0.3.0 - DSTU 1
This page is part of the CDA-FHIR-Maps (R4) (v0.3.0: DSTU 1) based on FHIR R4. . For a full list of available versions, see the Directory of published versions
<StructureMap xmlns="http://hl7.org/fhir">
<id value="BundleToCdaChEmed"/>
<meta>
<versionId value="2"/>
<lastUpdated value="2021-11-04T13:41:21.790+01:00"/>
</meta>
<text>
<status value="generated"/>
<div xmlns="http://www.w3.org/1999/xhtml">
<pre>map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed" = "BundleToCdaChEmed"
// Medication Entries
// 2020-11-11 Michaela Ziegler, copyright ahdis ag, Apache License
// CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed-
// FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html
uses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as target
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as target
uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as target
uses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as target
uses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as target
uses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as target
uses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as target
uses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as target
uses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as target
uses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as target
uses "http://hl7.org/fhir/cda/StructureDefinition/Supply" alias Supply as target
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source
uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as source
uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source
uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as source
uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as source
uses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as source
uses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as source
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda"
imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh"
// source: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html)
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2
group AnnotationComment(source note : Annotation, target act : Act) {
note -> act.classCode = 'ACT' "ACT";
note -> act.moodCode = 'EVN' "EVN";
note -> act.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.2' "templateId";
note -> act.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.40' "templateId";
note -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.2' "templateId";
note -> act.code as code, code.code = '48767-8', code.codeSystem = '2.16.840.1.113883.6.1', code.displayName = 'Annotation comment', code.codeSystemName = 'LOINC' "code";
note.text as noteText -> act.text as text then {
noteText -> text.data = noteText "text";
note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {
extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";
} "id";
note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";
};
note -> act.statusCode as code, code.code = 'completed' "statusCode";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US
group ManufacturedMaterialEntryContentModuleStatement(source bundle : Bundle, source medicationStatement : MedicationStatement, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial) {
medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT";
medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND";
medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule";
medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId";
medication.code as code then {
code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname";
} "name";
medication.code as code then {
// #mtpc.no.brandedmedication
code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then {
extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference";
} "id";
code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference";
code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code";
code where coding.exists() = false -> manufacturedMaterial.code as ce, ce.nullFlavor = 'NA' "nullFlavor";
};
medication.form as form then {
form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode";
};
medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then {
code -> containerPackagedMedicine.classCode = 'CONT' "CONT";
code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE";
code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code";
code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name";
medication.form as form then {
form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode";
};
// Package size
medication.amount as amount then {
amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then {
numerator.value as value -> capacityQuantity.value = value;
numerator.code as unit -> capacityQuantity.unit = unit "unit";
};
};
};
medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then {
ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then {
itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT";
itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND";
itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name";
itemCodeableConcept.coding as coding then {
coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode";
};
} "PharmSubstance";
ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity);
};
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34&effectiveDate=2019-12-11T11:31:52&language=en-US
group MedicationTreatmentPlanItemEntryContentModule(source bundle : Bundle, source medicationStatement : MedicationStatement, target substanceAdministration : SubstanceAdministration) {
medicationStatement -> substanceAdministration.classCode = 'SBADM' "SBADM";
medicationStatement -> substanceAdministration.moodCode = 'INT' "INT";
medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.34' "CH-PHARM-MedicationTreatmentPlanItemEntryContentModule";
medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.7' "IHE-PHARM-MTP";
medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.24' "CCD";
medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7' "PCC-MedicationEntryContentModule";
medicationStatement.identifier as identifier -> substanceAdministration.id as id then IdentifierII(identifier, id) "id";
medicationStatement.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> substanceAdministration.text as text, text.reference as reference then {
extension.valueUrl as valueUrl -> reference.value = valueUrl;
} "narrativeLink";
medicationStatement where extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not() -> substanceAdministration.text as text, text.reference as reference then {
medicationStatement -> reference.value = '#refpdf' "referencetopdf";
} "cat1narrativelink";
medicationStatement -> substanceAdministration.statusCode as statusCode, statusCode.code = 'completed' "code";
medicationStatement.contained as medication where ('#' + $this.id) in %medicationStatement.medicationReference.reference -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then {
medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-TemplateId";
medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-TemplateId";
medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModuleStatement(bundle, medicationStatement, medication, manufacturedMaterial) "manufacturedMaterial";
};
// TODO: AUTHOR1 Medication Treatment Plan Author
medicationStatement where dosage.count() = 1 then {
medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";
} "onylonedosage";
// dosage for normal dosing, as no sequences are present there
medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal') then DosageInstructionsStartStopFrequencySubstanceAdministration(dosage, substanceAdministration) "DosageSubstanceAdministration";
// dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode
medicationStatement.dosage first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship then DosageInstructionsEntryStartStopRoute(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";
// dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable
medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeSubstanceAdministration(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";
medicationStatement.reasonCode as reasonCode -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'RSON', entryRelationship.observation as observation then TreatmentReasonEntryContentModule(reasonCode, observation) "TreatmentReasonEntryContentModule";
medicationStatement.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";
// https://github.com/ehealthsuisse/ch-emed/issues/56
medicationStatement -> substanceAdministration.repeatNumber as repeatNumber, repeatNumber.nullFlavor = 'NI' "repeatNumberDefault";
// TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC)
medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule";
medicationStatement.note as note -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment";
medicationStatement.extension as extension where $this.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-substitution' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionStatement(extension, act) "Substitution";
}
// TODO: Tapered Dose
// medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.8' "taperedDose";
// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35
// dosage for normal dosing (without sequences) (Statement, Prescription)
group DosageInstructionsStartStopFrequencySubstanceAdministration(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {
dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";
dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";
dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenNormal(dosage, substanceAdministration) "effectiveTimeWhen";
dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);
dosage as dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";
}
// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
// dosage for split dosing: effectiveTime (start/stop) & routeCode (Statement, Prescription)
group DosageInstructionsEntryStartStopRoute(source dosage : Dosage, target substanceAdministration : substanceAdministration, target entry : entryRelationship) {
// if the FHIR doucment has no dosage templateId -> create templateId for split dose
dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.9' "splitDose";
dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";
dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);
}
// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
// dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Statement, Prescription)
group DosageInstructionsEntryDosageChangeSubstanceAdministration(source dosage : Dosage, target substanceAdministration : substanceAdministration, target entry : entryRelationship) {
dosage.sequence as sequence -> entry.sequenceNumber as sequenceNumber, sequenceNumber.value = sequence;
dosage -> entry.substanceAdministration as substanceAdministration, substanceAdministration.classCode = 'SBADM', substanceAdministration.moodCode = 'INT' then {
dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenSplit(dosage, substanceAdministration) "effectiveTimeWhen";
dosage as dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";
dosage as dosage -> substanceAdministration as substanceAdministration, substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";
} "dosage";
}
// effective time low and high for dosage (Statement, Prescription)
group EffectiveTimeStartEnd(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {
dosage.timing as timing then {
timing.repeat as repeat then {
repeat.bounds : Period as bounds -> substanceAdministration.effectiveTime = create('IVL_TS') as effectiveTime then {
bounds.start as start -> effectiveTime.low as low then DateTS(start, low) "low";
bounds where start.exists().not() -> effectiveTime.low as low, low.nullFlavor = 'UNK' "NullFlavorLow";
bounds.end as end -> effectiveTime.high as high then DateTS(end, high) "high";
bounds where end.exists().not() -> effectiveTime.high as high, high.nullFlavor = 'UNK' "NullFlavorhigh";
};
};
};
}
// dose quantity for dosage (application schema) (Statement)
group DoseQuantity(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {
dosage.doseAndRate as doseAndRate -> substanceAdministration.doseQuantity as doseQuantity then {
doseAndRate.dose : Quantity as quantity then {
quantity.value as value -> doseQuantity.value = value;
quantity.code as code -> doseQuantity.unit = code;
} "quantity";
} "doseQuantity";
}
// source: reasonCode Coding (e.g. http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-medicationstatement)
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.41
// Treatment Reason (Statement, Prescription)
group TreatmentReasonEntryContentModule(source reasonCode : Coding, target observation : Observation) {
reasonCode -> observation.classCode = 'OBS' "OBS";
reasonCode -> observation.moodCode = 'EVN' "EVN";
reasonCode -> observation.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.41' "TreatmentReasonEntryContentModule";
reasonCode -> observation.code as code, code.code = '75326-9', code.codeSystem = '2.16.840.1.113883.6.1', code.displayName = 'Problem', code.codeSystemName = 'LOINC' "code";
reasonCode.text as reasonText -> observation.text as text then {
reasonText -> text.data = reasonText "text";
reasonCode.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {
extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";
} "id";
reasonCode where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";
};
reasonCode -> observation.statusCode as code, code.code = 'completed' "statusCode";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.45&effectiveDate=2017-01-10T15:34:25&language=en-US
group MTPReferenceEntryContentModule(source ext : Extension, target substanceAdministration : SubstanceAdministration) {
ext -> substanceAdministration.classCode = 'SBADM' "SBADM";
ext -> substanceAdministration.moodCode = 'INT' "INT";
ext -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.10' "referenceTo-MTP-PlanItemGeneralSpecificationTemplateId";
ext -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.45' "CH-PHARM-templateId";
ext.extension as extension where $this.url = 'id' then {
extension.valueIdentifier as valueIdentifier -> substanceAdministration.id as id then IdentifierII(valueIdentifier, id) "id";
} "id";
ext -> substanceAdministration.code as code, code.code = 'MTPItem', code.codeSystem = '1.3.6.1.4.1.19376.1.9.2.2', code.displayName = 'Medication Treatment Plan Item', code.codeSystemName = 'IHE Pharmacy Item Type List' "code";
ext -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";
ext.extension as extension where $this.url = 'externalDocumentId' then {
extension.valueIdentifier as valueIdentifier -> substanceAdministration.reference as reference, reference.typeCode = 'XCRPT', reference.externalDocument as externalDocument, externalDocument.id as id then IdentifierII(valueIdentifier, id) "id";
} "externalDocumentId";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-dosage-nonstructured.html
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.52
// Dosage Instruction (Statement, Prescription)
group DosageInstructionsNonStructuredEntryContentModule(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {
dosage -> substanceAdministration.classCode = 'SBADM' "SBADM";
dosage -> substanceAdministration.moodCode = 'INT' "INT";
dosage -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.52' "templateId";
dosage.text as noteText -> substanceAdministration.text as text then {
noteText -> text.data = noteText "text";
dosage.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {
extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";
} "id";
dosage where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";
};
dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html
// target: Substitution act Contains 1.3.6.1.4.1.19376.1.9.1.3.9.2 IHE Substitution Act Content Module
// Substitution (Dispense)
group SubstitutionDispense(source substitution : Substitution, target act : Act) {
substitution -> act.classCode = 'ACT' "ACT";
substitution -> act.moodCode = 'EVN' "EVN";
substitution -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.2' "templateId";
substitution.type as type -> act.code as code then CodeableConceptCE(type, code) "substitution";
substitution -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US
group ManufacturedMaterialEntryContentModuleDispense(source bundle : Bundle, source medicationDispense : MedicationDispense, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial) {
medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT";
medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND";
medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule";
medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId";
medication.code as code then {
code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname";
} "name";
medication.code as code then {
// #dis.no.brandedmedication
code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then {
extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference";
} "id";
code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference";
code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code";
};
medication.form as form then {
form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode";
};
medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then {
code -> containerPackagedMedicine.classCode = 'CONT' "CONT";
code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE";
code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code";
code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name";
medication.form as form then {
form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode";
};
// Package size
medication.amount as amount then {
amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then {
numerator.value as value -> capacityQuantity.value = value;
numerator.code as unit -> capacityQuantity.unit = unit "unit";
};
};
};
medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then {
ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then {
itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT";
itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND";
itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name";
itemCodeableConcept.coding as coding then {
coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode";
};
} "PharmSubstance";
ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity);
};
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.42
group DispenseItemEntryContentModule(source bundle : Bundle, source medicationDispense : MedicationDispense, target supply : Supply) {
medicationDispense -> supply.classCode = 'SPLY' "SPLY";
medicationDispense -> supply.moodCode = 'EVN' "EVN";
medicationDispense -> supply.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.42' "CH-PHARM-DispenseItemEntryContentModule";
medicationDispense -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.4' "IHE-PHARM-DIS";
medicationDispense -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.3' "supplyEntry";
medicationDispense -> supply.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.34' "CCD";
medicationDispense.identifier as identifier -> supply.id as id then IdentifierII(identifier, id) "id";
medicationDispense.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> supply.text as text, text.reference as reference then {
extension.valueUrl as valueUrl -> reference.value = valueUrl;
} "narrativeLink";
medicationDispense where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> supply.text as text, text.reference as reference, text.reference as reference, reference.value = '#refpdf' "reference";
medicationDispense.contained as medication where ('#' + $this.id) in %medicationDispense.medicationReference.reference -> supply.product as product, product.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then {
medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-TemplateId";
medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-TemplateId";
medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModuleDispense(bundle, medicationDispense, medication, manufacturedMaterial) "manufacturedMaterial";
};
// TODO: AUTHOR1 Medication Treatment Plan Author
medicationDispense.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";
// #24 missing template it if ch-emed-dosage-nonstructured
medicationDispense where dosageInstruction.count() = 1 then {
medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";
} "onylonedosage";
// dosage for normal dosing, as no sequences are present there
medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal') then DosageInstructionsStartStopFrequencySupply(dosage, supply) "DosageSubstanceAdministration";
// dosage for split dosing, as sequences are present there
medicationDispense -> supply.entryRelationship as entryRelationship then {
medicationDispense -> entryRelationship.substanceAdministration as substanceAdministration then {
// split dosing (with sequences): effectiveTime (start/stop) & routeCode & consumable
medicationDispense.dosageInstruction first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration then DosageInstructionsEntryStartStopRouteConsumable(dosage, entryRelationship, substanceAdministration) "DosageSubstanceAdministration";
// split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable
medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeEntryRelationship(dosage, entryRelationship) "DosageSubstanceAdministration";
} "substanceAdministration";
} "entryRelationship";
// TODO: Precondition Criterion
medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule";
// Number of packages
medicationDispense.quantity as quantity -> supply.quantity as supplyQuantity then {
quantity.value as value -> supplyQuantity.value = value;
};
medicationDispense.note as note -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment";
medicationDispense.substitution as substitution -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionDispense(substitution, act) "Substitution";
}
// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35
// dosage for normal dosing (without sequences) (Dispense)
group DosageInstructionsStartStopFrequencySupply(source dosage : Dosage, target supply : Supply) {
dosage -> supply.entryRelationship as entryRelationship then {
dosage -> entryRelationship.typeCode = 'COMP' "COMP";
dosage -> entryRelationship.substanceAdministration as substanceAdministration then {
dosage -> substanceAdministration.classCode = 'SBADM' "SBADM";
dosage -> substanceAdministration.moodCode = 'INT' "INT";
dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.6' "templateId";
dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";
dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";
dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenNormal(dosage, substanceAdministration) "effectiveTimeWhen";
dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);
dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";
dosage -> substanceAdministration as substanceAdministration, substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";
} "substanceAdministration";
} "entryRelationship";
}
// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
// dosage for split dosing: effectiveTime (start/stop) & routeCode & consumable (Dispense)
group DosageInstructionsEntryStartStopRouteConsumable(source dosage : Dosage, target entryRelationship : entryRelationship, target substanceAdministration : SubstanceAdministration) {
dosage -> entryRelationship.typeCode = 'COMP' "COMP";
dosage -> substanceAdministration.classCode = 'SBADM' "SBADM";
dosage -> substanceAdministration.moodCode = 'INT' "INT";
dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.6' "templateId";
dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.9' "splitDose";
dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";
dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);
dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";
}
// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
// dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Dispense)
group DosageInstructionsEntryDosageChangeEntryRelationship(source dosage : Dosage, target entryRelationship : entryRelationship) {
dosage.sequence as sequence -> entryRelationship.sequenceNumber as sequenceNumber, sequenceNumber.value = sequence;
dosage -> entryRelationship.substanceAdministration as substanceAdministration, substanceAdministration.classCode = 'SBADM', substanceAdministration.moodCode = 'INT' then {
dosage as dosage -> substanceAdministration then EffectiveTimeWhenSplit(dosage, substanceAdministration) "effectiveTimeWhen";
dosage as dosage -> substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";
dosage as dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";
} "dosage";
}
// effective time when for normal dosage (Dispense, Statement, Prescription)
group EffectiveTimeWhenNormal(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {
dosage.timing as timing then {
timing.repeat as repeat then {
repeat where $this.when.count() = 1 -> substanceAdministration.effectiveTime = create('EIVL_TS') as effectiveTime, effectiveTime.operator = 'A' then {
repeat.when as when -> effectiveTime.event as event, event.code = when;
} "when";
repeat where $this.when.count() > 1 -> substanceAdministration.effectiveTime = create('SXPR_TS') as effectiveTime, effectiveTime.operator = 'A' then {
repeat.when first as when -> effectiveTime.comp = create('EIVL_TS') as comp then {
when -> comp.event as event, event.code = when "when";
} "comp";
repeat.when not_first as when -> effectiveTime.comp = create('EIVL_TS') as comp, comp.operator = 'I' then {
when -> comp.event as event, event.code = when "when";
} "compnotfirst";
} "when";
};
};
}
// effective time when for split dosage (Dispense, Statement, Prescription)
group EffectiveTimeWhenSplit(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {
dosage.timing as timing then {
timing.repeat as repeat then {
repeat where $this.when.count() = 1 -> substanceAdministration.effectiveTime = create('EIVL_TS') as effectiveTime then {
repeat.when as when -> effectiveTime.event as event, event.code = when;
} "when";
repeat where $this.when.count() > 1 -> substanceAdministration.effectiveTime = create('SXPR_TS') as effectiveTime, effectiveTime.operator = 'A' then {
repeat.when first as when -> effectiveTime.comp = create('EIVL_TS') as comp then {
when -> comp.event as event, event.code = when "when";
} "comp";
repeat.when not_first as when -> effectiveTime.comp = create('EIVL_TS') as comp, comp.operator = 'I' then {
when -> comp.event as event, event.code = when "when";
} "compnotfirst";
} "when";
};
};
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
// target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module
group SubstitutionRequest(source substitution : Substitution, target act : Act) {
substitution -> act.classCode = 'ACT' "ACT";
substitution -> act.moodCode = 'DEF' "DEF";
substitution -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.1' "templateId";
substitution.allowedCodeableConcept as allowedCC -> act.code as code then CodeableConceptCE(allowedCC, code) "substitution";
substitution -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
// target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module
group SubstitutionStatement(source extension : Extension, target act : Act) {
extension -> act.classCode = 'ACT' "ACT";
extension -> act.moodCode = 'DEF' "DEF";
extension -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.1' "templateId";
extension.valueCodeableConcept as valueCC -> act.code as code then CodeableConceptCE(valueCC, code) "extension";
extension -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38
group PrescribedQuantity(source dispenseRequest : DispenseRequest, target supply : Supply) {
dispenseRequest -> supply.classCode = 'SPLY' "SPLY";
dispenseRequest -> supply.moodCode = 'RQO' "RQO";
dispenseRequest -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.8' "templateId";
dispenseRequest -> supply.independentInd as independentInd, independentInd.value = 'false' "independentInd";
// Number of packages
dispenseRequest.quantity as quantity -> supply.quantity as quant then {
quantity.value as value -> quant.value = value;
};
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38
group PrescribedQuantityUnit(source dispenseRequest : DispenseRequest, target supply : Supply) {
dispenseRequest -> supply.classCode = 'SPLY' "SPLY";
dispenseRequest -> supply.moodCode = 'RQO' "RQO";
dispenseRequest -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.8' "TemplateId";
dispenseRequest -> supply.independentInd as independentInd, independentInd.value = 'false' "independentInd";
// Number of packages
dispenseRequest.quantity as quantity -> supply.quantity as quant then {
quantity.value as value -> quant.value = value;
quantity.unit as unit -> quant.unit = unit;
};
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33
group ManufacturedMaterialEntryContentModulePrescription(source bundle : Bundle, source medicationRequest : MedicationRequest, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial, target substanceAdministration : SubstanceAdministration) {
medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT";
medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND";
medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule";
medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId";
medication.code as code then {
code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname";
} "name";
medication.code as code then {
// #pre.no.brandedmedication
code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then {
extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference";
} "id";
code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference";
code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code";
};
medication.form as form then {
form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode";
};
medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then {
code -> containerPackagedMedicine.classCode = 'CONT' "CONT";
code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE";
code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code";
code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name";
medication.form as form then {
form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode";
};
// Package size
medication.amount as amount then {
amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then {
numerator.value as value -> capacityQuantity.value = value;
numerator.code as unit -> capacityQuantity.unit = unit "unit";
};
// IHE-DIS: Case 1: If the product-element contains package information, the unit attribute is not be present
medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.supply as supply then PrescribedQuantity(dispenseRequest, supply) "PrescribedQuantity";
};
// IHE-DIS: Case 2: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system
medication where $this.amount.exists() = false then {
medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.supply as supply then PrescribedQuantityUnit(dispenseRequest, supply) "PrescribedQuantityUnit";
} "noAmount";
};
medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then {
ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then {
itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT";
itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND";
itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name";
itemCodeableConcept.coding as coding then {
coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode";
};
} "PharmSubstance";
ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity);
};
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.43
group PrescriptionItemEntryContentModule(source bundle : Bundle, source medicationRequest : MedicationRequest, target substanceAdministration : SubstanceAdministration) {
medicationRequest -> substanceAdministration.classCode = 'SBADM' "SBADM";
medicationRequest -> substanceAdministration.moodCode = 'INT' "INT";
medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.43' "CH-PHARM-PrescriptionItemEntryContentModule";
medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.2' "PrescriptionItemEntryTemplateId";
medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.24' "CCD";
medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7' "PCC-MedicationEntryContentModule";
medicationRequest.identifier as identifier -> substanceAdministration.id as id then IdentifierII(identifier, id) "id";
medicationRequest.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> substanceAdministration.text as text, text.reference as reference then {
extension.valueUrl as valueUrl -> reference.value = valueUrl;
} "narrativeLink";
medicationRequest where extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not() -> substanceAdministration.text as text, text.reference as reference then {
medicationRequest -> reference.value = '#refpdf' "referencetopdf";
} "cat1narrativelink";
medicationRequest -> substanceAdministration.statusCode as statusCode, statusCode.code = 'completed' "code";
medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.repeatNumber as repeatNumber then {
dispenseRequest.numberOfRepeatsAllowed as number -> repeatNumber.value = number "repeatNumber";
dispenseRequest where numberOfRepeatsAllowed.exists() = false -> repeatNumber.nullFlavor = 'NI' "repeatNumberNull";
};
medicationRequest.contained as medication where ('#' + $this.id) in %medicationRequest.medicationReference.reference -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then {
medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-templateId";
medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-templateId";
medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModulePrescription(bundle, medicationRequest, medication, manufacturedMaterial, substanceAdministration) "manufacturedMaterial";
};
// TODO: AUTHOR1 Medication Treatment Plan Author
medicationRequest where dosageInstruction.count() = 1 then {
medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";
} "onylonedosage";
medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal-medicationrequest') then DosageInstructionsStartStopFrequencySubstanceAdministration(dosage, substanceAdministration) "DosageSubstanceAdministration";
// dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode
medicationRequest.dosageInstruction first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest') -> substanceAdministration.entryRelationship as entryRelationship then DosageInstructionsEntryStartStopRoute(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";
// dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable
medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeSubstanceAdministration(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";
medicationRequest.reasonCode as reasonCode -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'RSON', entryRelationship.observation as observation then TreatmentReasonEntryContentModule(reasonCode, observation) "TreatmentReasonEntryContentModule";
medicationRequest.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";
// TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC)
medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule";
medicationRequest.note as note -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment";
medicationRequest.substitution as substitution -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionRequest(substitution, act) "Substitution";
}
// source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-observation.html
// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.44
group PharmaceuticalAdviceItemEntryContentModule(source bundle : Bundle, source fhirobservation : Observation, target cdaobservation : Observation) {
fhirobservation -> cdaobservation.classCode = 'OBS' "OBS";
fhirobservation -> cdaobservation.moodCode = 'EVN' "EVN";
fhirobservation -> cdaobservation.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.3' "IHE-PHARM-PADV";
fhirobservation -> cdaobservation.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.44' "CH-PHARM-PharmaceuticalAdviceItemEntryContentModule";
fhirobservation.identifier as identifier -> cdaobservation.id as id then IdentifierII(identifier, id) "id";
fhirobservation.code as fhirCode -> cdaobservation.code as cdaCode then CodeableConceptCE(fhirCode, cdaCode);
fhirobservation -> cdaobservation.statusCode as statusCode, statusCode.code = 'completed' "code";
fhirobservation.effectiveDateTime as effectiveDateTime -> cdaobservation.effectiveTime as effectiveTime then {
effectiveDateTime -> effectiveTime.value = effectiveDateTime "value";
} "effectiveTime";
fhirobservation.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> cdaobservation.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";
fhirobservation.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-medicationstatement-changed' -> cdaobservation.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR' then {
bundle.entry as entry then {
entry.fullUrl where ($this in %extension.valueReference.reference) and $this.startsWith('urn:uuid') then {
entry.resource as medicationStatement where $this.ofType(FHIR.MedicationStatement) -> entryRelationship.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(bundle, medicationStatement, substanceAdministration) "MedicationStatement";
} "fullUrlAsUuid";
entry.resource as medicationStatement where $this.ofType(FHIR.MedicationStatement) and (('MedicationStatement' + '/' + $this.id) in %extension.valueReference.reference) -> entryRelationship.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(bundle, medicationStatement, substanceAdministration) "MedicationStatement";
};
} "changedmtp";
fhirobservation.note as note then {
note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> cdaobservation.text as text, text.reference as reference then {
extension.valueUrl as valueUrl -> reference.value = valueUrl;
} "narrativeLink";
note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> cdaobservation.text as text, text.reference as reference, reference.value = '#refpdf' "reference";
};
fhirobservation.note as note -> cdaobservation.text as text then {
note.text as noteText -> text.data = noteText;
note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {
extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";
} "id";
note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";
} "text";
}
</pre>
</div>
</text>
<url value="http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed"/>
<version value="0.3.0"/>
<name value="BundleToCdaChEmed"/>
<status value="draft"/>
<date value="2022-02-11T11:14:39+01:00"/>
<publisher value="ahdis"/>
<contact>
<name value="ahdis"/>
<telecom>
<system value="url"/>
<value value="http://www.ahdis.ch/"/>
</telecom>
</contact>
<description
value="
Medication Entries
2020-11-11 Michaela Ziegler, copyright ahdis ag, Apache License
CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed-
FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html
"/>
<copyright value="CC-BY-SA-4.0"/>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument"/>
<mode value="target"/>
<alias value="ClinicalDocument"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor"/>
<mode value="target"/>
<alias value="AssignedAuthor"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity"/>
<mode value="target"/>
<alias value="AssignedEntity"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/Author"/>
<mode value="target"/>
<alias value="Author"/>
</structure>
<structure>
<url
value="http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization"/>
<mode value="target"/>
<alias value="CustodianOrganization"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/IVL_TS"/>
<mode value="target"/>
<alias value="IVL_TS"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS"/>
<mode value="target"/>
<alias value="EIVL_TS"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/PatientRole"/>
<mode value="target"/>
<alias value="PatientRole"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/RecordTarget"/>
<mode value="target"/>
<alias value="RecordTarget"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/Section"/>
<mode value="target"/>
<alias value="Section"/>
</structure>
<structure>
<url
value="http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration"/>
<mode value="target"/>
<alias value="SubstanceAdministration"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS"/>
<mode value="target"/>
<alias value="SXPR_TS"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/cda/StructureDefinition/Supply"/>
<mode value="target"/>
<alias value="Supply"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Bundle"/>
<mode value="source"/>
<alias value="Bundle"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Composition"/>
<mode value="source"/>
<alias value="Composition"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Patient"/>
<mode value="source"/>
<alias value="Patient"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Practitioner"/>
<mode value="source"/>
<alias value="Practitioner"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Organization"/>
<mode value="source"/>
<alias value="Organization"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/MedicationStatement"/>
<mode value="source"/>
<alias value="MedicationStatement"/>
</structure>
<structure>
<url value="http://hl7.org/fhir/StructureDefinition/Dosage"/>
<mode value="source"/>
<alias value="Dosage"/>
</structure>
<import value="http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes"/>
<import value="http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda"/>
<import value="http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh"/>
<group>
<name value="AnnotationComment"/>
<typeMode value="none"/>
<documentation
value="source: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html)
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2"/>
<input>
<name value="note"/>
<type value="Annotation"/>
<mode value="source"/>
</input>
<input>
<name value="act"/>
<type value="Act"/>
<mode value="target"/>
</input>
<rule>
<name value="ACT"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACT"/>
</parameter>
</target>
</rule>
<rule>
<name value="EVN"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="EVN"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.40"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="code"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="48767-8"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="codeSystem"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.6.1"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="displayName"/>
<transform value="copy"/>
<parameter>
<valueString value="Annotation comment"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="codeSystemName"/>
<transform value="copy"/>
<parameter>
<valueString value="LOINC"/>
</parameter>
</target>
</rule>
<rule>
<name value="text"/>
<source>
<context value="note"/>
<element value="text"/>
<variable value="noteText"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<rule>
<name value="text"/>
<source>
<context value="noteText"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="data"/>
<transform value="copy"/>
<parameter>
<valueId value="noteText"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="note"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="note"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="statusCode"/>
<source>
<context value="note"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="ManufacturedMaterialEntryContentModuleStatement"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="medicationStatement"/>
<type value="MedicationStatement"/>
<mode value="source"/>
</input>
<input>
<name value="medication"/>
<type value="Medication"/>
<mode value="source"/>
</input>
<input>
<name value="manufacturedMaterial"/>
<type value="ManufacturedMaterial"/>
<mode value="target"/>
</input>
<rule>
<name value="MMAT"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MMAT"/>
</parameter>
</target>
</rule>
<rule>
<name value="KIND"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="KIND"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-ManufacturedMaterialContentModule"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.33"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="name"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<rule>
<name value="brandname"/>
<source>
<context value="code"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<rule>
<name value="id"/>
<source>
<context value="code"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="originalText"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
<documentation value="#mtpc.no.brandedmedication"/>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="code"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="originalText"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
<rule>
<name value="code"/>
<source>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
<rule>
<name value="nullFlavor"/>
<source>
<context value="code"/>
<condition value="coding.exists() = false"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<target>
<context value="ce"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="form"/>
<source>
<context value="medication"/>
<element value="form"/>
<variable value="form"/>
</source>
<rule>
<name value="formCode"/>
<source>
<context value="form"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="formCode"/>
<variable value="formCode"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="formCode"/>
</dependent>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="asContent"/>
<variable value="asContent"/>
</target>
<target>
<context value="asContent"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="CONT"/>
</parameter>
</target>
<target>
<context value="asContent"/>
<contextType value="variable"/>
<element value="containerPackagedMedicine"/>
<variable value="containerPackagedMedicine"/>
</target>
<rule>
<name value="CONT"/>
<source>
<context value="code"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="CONT"/>
</parameter>
</target>
</rule>
<rule>
<name value="INSTANCE"/>
<source>
<context value="code"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INSTANCE"/>
</parameter>
</target>
</rule>
<rule>
<name value="pharm-code"/>
<source>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
<rule>
<name value="pharm-name"/>
<source>
<context value="code"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
<rule>
<name value="form"/>
<source>
<context value="medication"/>
<element value="form"/>
<variable value="form"/>
</source>
<rule>
<name value="pharm-formCode"/>
<source>
<context value="form"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="formCode"/>
<variable value="formCode"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="formCode"/>
</dependent>
</rule>
</rule>
<rule>
<name value="amount"/>
<source>
<context value="medication"/>
<element value="amount"/>
<variable value="amount"/>
</source>
<rule>
<name value="numerator"/>
<source>
<context value="amount"/>
<element value="numerator"/>
<variable value="numerator"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="capacityQuantity"/>
<variable value="capacityQuantity"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="numerator"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="capacityQuantity"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<rule>
<name value="unit"/>
<source>
<context value="numerator"/>
<element value="code"/>
<variable value="unit"/>
</source>
<target>
<context value="capacityQuantity"/>
<contextType value="variable"/>
<element value="unit"/>
<transform value="copy"/>
<parameter>
<valueId value="unit"/>
</parameter>
</target>
</rule>
</rule>
<documentation value="Package size"/>
</rule>
</rule>
<rule>
<name value="ingredient"/>
<source>
<context value="medication"/>
<element value="ingredient"/>
<variable value="ingredient"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="ingredient"/>
<variable value="ingredient"/>
</target>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACTI"/>
</parameter>
</target>
<rule>
<name value="PharmSubstance"/>
<source>
<context value="ingredient"/>
<element value="itemCodeableConcept"/>
<variable value="itemCodeableConcept"/>
</source>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="ingredient"/>
<variable value="pharmsubstance"/>
</target>
<rule>
<name value="MMAT"/>
<source>
<context value="itemCodeableConcept"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MMAT"/>
</parameter>
</target>
</rule>
<rule>
<name value="KIND"/>
<source>
<context value="itemCodeableConcept"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="KIND"/>
</parameter>
</target>
</rule>
<rule>
<name value="name"/>
<source>
<context value="itemCodeableConcept"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
<rule>
<name value="coding"/>
<source>
<context value="itemCodeableConcept"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<rule>
<name value="formCode"/>
<source>
<context value="coding"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
</rule>
</rule>
<rule>
<name value="strength"/>
<source>
<context value="ingredient"/>
<element value="strength"/>
<variable value="strength"/>
</source>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="quantity"/>
<variable value="quantity"/>
</target>
<dependent>
<name value="RatioRTOPQPQ"/>
<variable value="strength"/>
<variable value="quantity"/>
</dependent>
</rule>
</rule>
</group>
<group>
<name value="MedicationTreatmentPlanItemEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34&effectiveDate=2019-12-11T11:31:52&language=en-US"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="medicationStatement"/>
<type value="MedicationStatement"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="SBADM"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
</rule>
<rule>
<name value="INT"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-MedicationTreatmentPlanItemEntryContentModule"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.34"/>
</parameter>
</target>
</rule>
<rule>
<name value="IHE-PHARM-MTP"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.7"/>
</parameter>
</target>
</rule>
<rule>
<name value="CCD"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.24"/>
</parameter>
</target>
</rule>
<rule>
<name value="PCC-MedicationEntryContentModule"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="medicationStatement"/>
<element value="identifier"/>
<variable value="identifier"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="id"/>
<variable value="id"/>
</target>
<dependent>
<name value="IdentifierII"/>
<variable value="identifier"/>
<variable value="id"/>
</dependent>
</rule>
<rule>
<name value="narrativeLink"/>
<source>
<context value="medicationStatement"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<rule>
<name value="valueUrl"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="cat1narrativelink"/>
<source>
<context value="medicationStatement"/>
<condition
value="extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not()"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<rule>
<name value="referencetopdf"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="statusCode"/>
</target>
<target>
<context value="statusCode"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
<rule>
<name value="contained"/>
<source>
<context value="medicationStatement"/>
<element value="contained"/>
<variable value="medication"/>
<condition
value="('#' + $this.id) in %medicationStatement.medicationReference.reference"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MANU"/>
</parameter>
</target>
<rule>
<name value="MP-TemplateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="MP-TemplateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.53"/>
</parameter>
</target>
</rule>
<rule>
<name value="manufacturedMaterial"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<dependent>
<name value="ManufacturedMaterialEntryContentModuleStatement"/>
<variable value="bundle"/>
<variable value="medicationStatement"/>
<variable value="medication"/>
<variable value="manufacturedMaterial"/>
</dependent>
</rule>
</rule>
<rule>
<name value="onylonedosage"/>
<source>
<context value="medicationStatement"/>
<condition value="dosage.count() = 1"/>
</source>
<rule>
<name value="normalDose"/>
<source>
<context value="medicationStatement"/>
<element value="dosage"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.1"/>
</parameter>
</target>
</rule>
<documentation value="TODO: AUTHOR1 Medication Treatment Plan Author"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationStatement"/>
<element value="dosage"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal')"/>
</source>
<dependent>
<name
value="DosageInstructionsStartStopFrequencySubstanceAdministration"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
<documentation
value="dosage for normal dosing, as no sequences are present there"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationStatement"/>
<element value="dosage"/>
<listMode value="first"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<dependent>
<name value="DosageInstructionsEntryStartStopRoute"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
<variable value="entryRelationship"/>
</dependent>
<documentation
value="dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationStatement"/>
<element value="dosage"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<dependent>
<name value="DosageInstructionsEntryDosageChangeSubstanceAdministration"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
<variable value="entryRelationship"/>
</dependent>
<documentation
value="dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable"/>
</rule>
<rule>
<name value="TreatmentReasonEntryContentModule"/>
<source>
<context value="medicationStatement"/>
<element value="reasonCode"/>
<variable value="reasonCode"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="RSON"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="observation"/>
<variable value="observation"/>
</target>
<dependent>
<name value="TreatmentReasonEntryContentModule"/>
<variable value="reasonCode"/>
<variable value="observation"/>
</dependent>
</rule>
<rule>
<name value="MTP-Reference"/>
<source>
<context value="medicationStatement"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan'"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="REFR"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="MTPReferenceEntryContentModule"/>
<variable value="extension"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="repeatNumberDefault"/>
<source>
<context value="medicationStatement"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="repeatNumber"/>
<variable value="repeatNumber"/>
</target>
<target>
<context value="repeatNumber"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NI"/>
</parameter>
</target>
<documentation value="https://github.com/ehealthsuisse/ch-emed/issues/56"/>
</rule>
<rule>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<source>
<context value="medicationStatement"/>
<element value="dosage"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
<documentation
value="TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC)"/>
</rule>
<rule>
<name value="AnnotationComment"/>
<source>
<context value="medicationStatement"/>
<element value="note"/>
<variable value="note"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="act"/>
<variable value="act"/>
</target>
<dependent>
<name value="AnnotationComment"/>
<variable value="note"/>
<variable value="act"/>
</dependent>
</rule>
<rule>
<name value="Substitution"/>
<source>
<context value="medicationStatement"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-substitution'"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="act"/>
<variable value="act"/>
</target>
<dependent>
<name value="SubstitutionStatement"/>
<variable value="extension"/>
<variable value="act"/>
</dependent>
</rule>
</group>
<group>
<name value="DosageInstructionsStartStopFrequencySubstanceAdministration"/>
<typeMode value="none"/>
<documentation
value="TODO: Tapered Dose
medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.8' "taperedDose";
source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35
dosage for normal dosing (without sequences) (Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="normalDose"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="effectiveTimeStartEnd"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeStartEnd"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="effectiveTimeWhen"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeWhenNormal"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="route"/>
<source>
<context value="dosage"/>
<element value="route"/>
<variable value="route"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="routeCode"/>
<variable value="routeCode"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="route"/>
<variable value="routeCode"/>
</dependent>
</rule>
<rule>
<name value="doseQuantity"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="DoseQuantity"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
</group>
<group>
<name value="DosageInstructionsEntryStartStopRoute"/>
<typeMode value="none"/>
<documentation
value="source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
dosage for split dosing: effectiveTime (start/stop) & routeCode (Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="substanceAdministration"/>
<mode value="target"/>
</input>
<input>
<name value="entry"/>
<type value="entryRelationship"/>
<mode value="target"/>
</input>
<rule>
<name value="splitDose"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.9"/>
</parameter>
</target>
<documentation
value="if the FHIR doucment has no dosage templateId -> create templateId for split dose"/>
</rule>
<rule>
<name value="effectiveTimeStartEnd"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeStartEnd"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="route"/>
<source>
<context value="dosage"/>
<element value="route"/>
<variable value="route"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="routeCode"/>
<variable value="routeCode"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="route"/>
<variable value="routeCode"/>
</dependent>
</rule>
</group>
<group>
<name value="DosageInstructionsEntryDosageChangeSubstanceAdministration"/>
<typeMode value="none"/>
<documentation
value="source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="substanceAdministration"/>
<mode value="target"/>
</input>
<input>
<name value="entry"/>
<type value="entryRelationship"/>
<mode value="target"/>
</input>
<rule>
<name value="sequence"/>
<source>
<context value="dosage"/>
<element value="sequence"/>
<variable value="sequence"/>
</source>
<target>
<context value="entry"/>
<contextType value="variable"/>
<element value="sequenceNumber"/>
<variable value="sequenceNumber"/>
</target>
<target>
<context value="sequenceNumber"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="sequence"/>
</parameter>
</target>
</rule>
<rule>
<name value="dosage"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="entry"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
<rule>
<name value="effectiveTimeWhen"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeWhenSplit"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="doseQuantity"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="DoseQuantity"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="consumable"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
</rule>
</group>
<group>
<name value="EffectiveTimeStartEnd"/>
<typeMode value="none"/>
<documentation
value="effective time low and high for dosage (Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="timing"/>
<source>
<context value="dosage"/>
<element value="timing"/>
<variable value="timing"/>
</source>
<rule>
<name value="repeat"/>
<source>
<context value="timing"/>
<element value="repeat"/>
<variable value="repeat"/>
</source>
<rule>
<name value="bounds"/>
<source>
<context value="repeat"/>
<type value="Period"/>
<element value="bounds"/>
<variable value="bounds"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="effectiveTime"/>
<variable value="effectiveTime"/>
<transform value="create"/>
<parameter>
<valueString value="IVL_TS"/>
</parameter>
</target>
<rule>
<name value="low"/>
<source>
<context value="bounds"/>
<element value="start"/>
<variable value="start"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="low"/>
<variable value="low"/>
</target>
<dependent>
<name value="DateTS"/>
<variable value="start"/>
<variable value="low"/>
</dependent>
</rule>
<rule>
<name value="NullFlavorLow"/>
<source>
<context value="bounds"/>
<condition value="start.exists().not()"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="low"/>
<variable value="low"/>
</target>
<target>
<context value="low"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="UNK"/>
</parameter>
</target>
</rule>
<rule>
<name value="high"/>
<source>
<context value="bounds"/>
<element value="end"/>
<variable value="end"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="high"/>
<variable value="high"/>
</target>
<dependent>
<name value="DateTS"/>
<variable value="end"/>
<variable value="high"/>
</dependent>
</rule>
<rule>
<name value="NullFlavorhigh"/>
<source>
<context value="bounds"/>
<condition value="end.exists().not()"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="high"/>
<variable value="high"/>
</target>
<target>
<context value="high"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="UNK"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</rule>
</group>
<group>
<name value="DoseQuantity"/>
<typeMode value="none"/>
<documentation
value="dose quantity for dosage (application schema) (Statement)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="doseQuantity"/>
<source>
<context value="dosage"/>
<element value="doseAndRate"/>
<variable value="doseAndRate"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="doseQuantity"/>
<variable value="doseQuantity"/>
</target>
<rule>
<name value="quantity"/>
<source>
<context value="doseAndRate"/>
<type value="Quantity"/>
<element value="dose"/>
<variable value="quantity"/>
</source>
<rule>
<name value="value"/>
<source>
<context value="quantity"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="doseQuantity"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<rule>
<name value="code"/>
<source>
<context value="quantity"/>
<element value="code"/>
<variable value="code"/>
</source>
<target>
<context value="doseQuantity"/>
<contextType value="variable"/>
<element value="unit"/>
<transform value="copy"/>
<parameter>
<valueId value="code"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</group>
<group>
<name value="TreatmentReasonEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: reasonCode Coding (e.g. http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-medicationstatement)
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.41
Treatment Reason (Statement, Prescription)"/>
<input>
<name value="reasonCode"/>
<type value="Coding"/>
<mode value="source"/>
</input>
<input>
<name value="observation"/>
<type value="Observation"/>
<mode value="target"/>
</input>
<rule>
<name value="OBS"/>
<source>
<context value="reasonCode"/>
</source>
<target>
<context value="observation"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="OBS"/>
</parameter>
</target>
</rule>
<rule>
<name value="EVN"/>
<source>
<context value="reasonCode"/>
</source>
<target>
<context value="observation"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="EVN"/>
</parameter>
</target>
</rule>
<rule>
<name value="TreatmentReasonEntryContentModule"/>
<source>
<context value="reasonCode"/>
</source>
<target>
<context value="observation"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.41"/>
</parameter>
</target>
</rule>
<rule>
<name value="code"/>
<source>
<context value="reasonCode"/>
</source>
<target>
<context value="observation"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="75326-9"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="codeSystem"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.6.1"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="displayName"/>
<transform value="copy"/>
<parameter>
<valueString value="Problem"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="codeSystemName"/>
<transform value="copy"/>
<parameter>
<valueString value="LOINC"/>
</parameter>
</target>
</rule>
<rule>
<name value="text"/>
<source>
<context value="reasonCode"/>
<element value="text"/>
<variable value="reasonText"/>
</source>
<target>
<context value="observation"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<rule>
<name value="text"/>
<source>
<context value="reasonText"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="data"/>
<transform value="copy"/>
<parameter>
<valueId value="reasonText"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="reasonCode"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="reasonCode"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="statusCode"/>
<source>
<context value="reasonCode"/>
</source>
<target>
<context value="observation"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="MTPReferenceEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.45&effectiveDate=2017-01-10T15:34:25&language=en-US"/>
<input>
<name value="ext"/>
<type value="Extension"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="SBADM"/>
<source>
<context value="ext"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
</rule>
<rule>
<name value="INT"/>
<source>
<context value="ext"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
</rule>
<rule>
<name value="referenceTo-MTP-PlanItemGeneralSpecificationTemplateId"/>
<source>
<context value="ext"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.10"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-templateId"/>
<source>
<context value="ext"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.45"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="ext"/>
<element value="extension"/>
<variable value="extension"/>
<condition value="$this.url = 'id'"/>
</source>
<rule>
<name value="id"/>
<source>
<context value="extension"/>
<element value="valueIdentifier"/>
<variable value="valueIdentifier"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="id"/>
<variable value="id"/>
</target>
<dependent>
<name value="IdentifierII"/>
<variable value="valueIdentifier"/>
<variable value="id"/>
</dependent>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="ext"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="MTPItem"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="codeSystem"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.2.2"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="displayName"/>
<transform value="copy"/>
<parameter>
<valueString value="Medication Treatment Plan Item"/>
</parameter>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="codeSystemName"/>
<transform value="copy"/>
<parameter>
<valueString value="IHE Pharmacy Item Type List"/>
</parameter>
</target>
</rule>
<rule>
<name value="consumable"/>
<source>
<context value="ext"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
<rule>
<name value="externalDocumentId"/>
<source>
<context value="ext"/>
<element value="extension"/>
<variable value="extension"/>
<condition value="$this.url = 'externalDocumentId'"/>
</source>
<rule>
<name value="id"/>
<source>
<context value="extension"/>
<element value="valueIdentifier"/>
<variable value="valueIdentifier"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="XCRPT"/>
</parameter>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="externalDocument"/>
<variable value="externalDocument"/>
</target>
<target>
<context value="externalDocument"/>
<contextType value="variable"/>
<element value="id"/>
<variable value="id"/>
</target>
<dependent>
<name value="IdentifierII"/>
<variable value="valueIdentifier"/>
<variable value="id"/>
</dependent>
</rule>
</rule>
</group>
<group>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-dosage-nonstructured.html
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.52
Dosage Instruction (Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="SBADM"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
</rule>
<rule>
<name value="INT"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.52"/>
</parameter>
</target>
</rule>
<rule>
<name value="text"/>
<source>
<context value="dosage"/>
<element value="text"/>
<variable value="noteText"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<rule>
<name value="text"/>
<source>
<context value="noteText"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="data"/>
<transform value="copy"/>
<parameter>
<valueId value="noteText"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="dosage"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="dosage"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="consumable"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="SubstitutionDispense"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html
target: Substitution act Contains 1.3.6.1.4.1.19376.1.9.1.3.9.2 IHE Substitution Act Content Module
Substitution (Dispense)"/>
<input>
<name value="substitution"/>
<type value="Substitution"/>
<mode value="source"/>
</input>
<input>
<name value="act"/>
<type value="Act"/>
<mode value="target"/>
</input>
<rule>
<name value="ACT"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACT"/>
</parameter>
</target>
</rule>
<rule>
<name value="EVN"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="EVN"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.9.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="substitution"/>
<source>
<context value="substitution"/>
<element value="type"/>
<variable value="type"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="type"/>
<variable value="code"/>
</dependent>
</rule>
<rule>
<name value="statusCode"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="statusCode"/>
</target>
<target>
<context value="statusCode"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="ManufacturedMaterialEntryContentModuleDispense"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="medicationDispense"/>
<type value="MedicationDispense"/>
<mode value="source"/>
</input>
<input>
<name value="medication"/>
<type value="Medication"/>
<mode value="source"/>
</input>
<input>
<name value="manufacturedMaterial"/>
<type value="ManufacturedMaterial"/>
<mode value="target"/>
</input>
<rule>
<name value="MMAT"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MMAT"/>
</parameter>
</target>
</rule>
<rule>
<name value="KIND"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="KIND"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-ManufacturedMaterialContentModule"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.33"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="name"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<rule>
<name value="brandname"/>
<source>
<context value="code"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<rule>
<name value="id"/>
<source>
<context value="code"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="originalText"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
<documentation value="#dis.no.brandedmedication"/>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="code"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="originalText"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
<rule>
<name value="code"/>
<source>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
</rule>
<rule>
<name value="form"/>
<source>
<context value="medication"/>
<element value="form"/>
<variable value="form"/>
</source>
<rule>
<name value="formCode"/>
<source>
<context value="form"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="formCode"/>
<variable value="formCode"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="formCode"/>
</dependent>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="asContent"/>
<variable value="asContent"/>
</target>
<target>
<context value="asContent"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="CONT"/>
</parameter>
</target>
<target>
<context value="asContent"/>
<contextType value="variable"/>
<element value="containerPackagedMedicine"/>
<variable value="containerPackagedMedicine"/>
</target>
<rule>
<name value="CONT"/>
<source>
<context value="code"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="CONT"/>
</parameter>
</target>
</rule>
<rule>
<name value="INSTANCE"/>
<source>
<context value="code"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INSTANCE"/>
</parameter>
</target>
</rule>
<rule>
<name value="pharm-code"/>
<source>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
<rule>
<name value="pharm-name"/>
<source>
<context value="code"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
<rule>
<name value="form"/>
<source>
<context value="medication"/>
<element value="form"/>
<variable value="form"/>
</source>
<rule>
<name value="pharm-formCode"/>
<source>
<context value="form"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="formCode"/>
<variable value="formCode"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="formCode"/>
</dependent>
</rule>
</rule>
<rule>
<name value="amount"/>
<source>
<context value="medication"/>
<element value="amount"/>
<variable value="amount"/>
</source>
<rule>
<name value="numerator"/>
<source>
<context value="amount"/>
<element value="numerator"/>
<variable value="numerator"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="capacityQuantity"/>
<variable value="capacityQuantity"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="numerator"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="capacityQuantity"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<rule>
<name value="unit"/>
<source>
<context value="numerator"/>
<element value="code"/>
<variable value="unit"/>
</source>
<target>
<context value="capacityQuantity"/>
<contextType value="variable"/>
<element value="unit"/>
<transform value="copy"/>
<parameter>
<valueId value="unit"/>
</parameter>
</target>
</rule>
</rule>
<documentation value="Package size"/>
</rule>
</rule>
<rule>
<name value="ingredient"/>
<source>
<context value="medication"/>
<element value="ingredient"/>
<variable value="ingredient"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="ingredient"/>
<variable value="ingredient"/>
</target>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACTI"/>
</parameter>
</target>
<rule>
<name value="PharmSubstance"/>
<source>
<context value="ingredient"/>
<element value="itemCodeableConcept"/>
<variable value="itemCodeableConcept"/>
</source>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="ingredient"/>
<variable value="pharmsubstance"/>
</target>
<rule>
<name value="MMAT"/>
<source>
<context value="itemCodeableConcept"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MMAT"/>
</parameter>
</target>
</rule>
<rule>
<name value="KIND"/>
<source>
<context value="itemCodeableConcept"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="KIND"/>
</parameter>
</target>
</rule>
<rule>
<name value="name"/>
<source>
<context value="itemCodeableConcept"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
<rule>
<name value="coding"/>
<source>
<context value="itemCodeableConcept"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<rule>
<name value="formCode"/>
<source>
<context value="coding"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
</rule>
</rule>
<rule>
<name value="strength"/>
<source>
<context value="ingredient"/>
<element value="strength"/>
<variable value="strength"/>
</source>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="quantity"/>
<variable value="quantity"/>
</target>
<dependent>
<name value="RatioRTOPQPQ"/>
<variable value="strength"/>
<variable value="quantity"/>
</dependent>
</rule>
</rule>
</group>
<group>
<name value="DispenseItemEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.42"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="medicationDispense"/>
<type value="MedicationDispense"/>
<mode value="source"/>
</input>
<input>
<name value="supply"/>
<type value="Supply"/>
<mode value="target"/>
</input>
<rule>
<name value="SPLY"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SPLY"/>
</parameter>
</target>
</rule>
<rule>
<name value="EVN"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="EVN"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-DispenseItemEntryContentModule"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.42"/>
</parameter>
</target>
</rule>
<rule>
<name value="IHE-PHARM-DIS"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.4"/>
</parameter>
</target>
</rule>
<rule>
<name value="supplyEntry"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.3"/>
</parameter>
</target>
</rule>
<rule>
<name value="CCD"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.34"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="medicationDispense"/>
<element value="identifier"/>
<variable value="identifier"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="id"/>
<variable value="id"/>
</target>
<dependent>
<name value="IdentifierII"/>
<variable value="identifier"/>
<variable value="id"/>
</dependent>
</rule>
<rule>
<name value="narrativeLink"/>
<source>
<context value="medicationDispense"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<rule>
<name value="valueUrl"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="medicationDispense"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
<rule>
<name value="contained"/>
<source>
<context value="medicationDispense"/>
<element value="contained"/>
<variable value="medication"/>
<condition
value="('#' + $this.id) in %medicationDispense.medicationReference.reference"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="product"/>
<variable value="product"/>
</target>
<target>
<context value="product"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MANU"/>
</parameter>
</target>
<rule>
<name value="MP-TemplateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="MP-TemplateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.53"/>
</parameter>
</target>
</rule>
<rule>
<name value="manufacturedMaterial"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<dependent>
<name value="ManufacturedMaterialEntryContentModuleDispense"/>
<variable value="bundle"/>
<variable value="medicationDispense"/>
<variable value="medication"/>
<variable value="manufacturedMaterial"/>
</dependent>
</rule>
</rule>
<rule>
<name value="MTP-Reference"/>
<source>
<context value="medicationDispense"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan'"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="REFR"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="MTPReferenceEntryContentModule"/>
<variable value="extension"/>
<variable value="substanceAdministration"/>
</dependent>
<documentation value="TODO: AUTHOR1 Medication Treatment Plan Author"/>
</rule>
<rule>
<name value="onylonedosage"/>
<source>
<context value="medicationDispense"/>
<condition value="dosageInstruction.count() = 1"/>
</source>
<rule>
<name value="normalDose"/>
<source>
<context value="medicationDispense"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.1"/>
</parameter>
</target>
</rule>
<documentation
value="#24 missing template it if ch-emed-dosage-nonstructured"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationDispense"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal')"/>
</source>
<dependent>
<name value="DosageInstructionsStartStopFrequencySupply"/>
<variable value="dosage"/>
<variable value="supply"/>
</dependent>
<documentation
value="dosage for normal dosing, as no sequences are present there"/>
</rule>
<rule>
<name value="entryRelationship"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<rule>
<name value="substanceAdministration"/>
<source>
<context value="medicationDispense"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationDispense"/>
<element value="dosageInstruction"/>
<listMode value="first"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split')"/>
</source>
<target>
<contextType value="variable"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="DosageInstructionsEntryStartStopRouteConsumable"/>
<variable value="dosage"/>
<variable value="entryRelationship"/>
<variable value="substanceAdministration"/>
</dependent>
<documentation
value="split dosing (with sequences): effectiveTime (start/stop) & routeCode & consumable"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationDispense"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<dependent>
<name value="DosageInstructionsEntryDosageChangeEntryRelationship"/>
<variable value="dosage"/>
<variable value="entryRelationship"/>
</dependent>
<documentation
value="split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable"/>
</rule>
</rule>
<documentation
value="dosage for split dosing, as sequences are present there"/>
</rule>
<rule>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<source>
<context value="medicationDispense"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured')"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
<documentation value="TODO: Precondition Criterion"/>
</rule>
<rule>
<name value="quantity"/>
<source>
<context value="medicationDispense"/>
<element value="quantity"/>
<variable value="quantity"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="quantity"/>
<variable value="supplyQuantity"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="quantity"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="supplyQuantity"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<documentation value="Number of packages"/>
</rule>
<rule>
<name value="AnnotationComment"/>
<source>
<context value="medicationDispense"/>
<element value="note"/>
<variable value="note"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="act"/>
<variable value="act"/>
</target>
<dependent>
<name value="AnnotationComment"/>
<variable value="note"/>
<variable value="act"/>
</dependent>
</rule>
<rule>
<name value="Substitution"/>
<source>
<context value="medicationDispense"/>
<element value="substitution"/>
<variable value="substitution"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="act"/>
<variable value="act"/>
</target>
<dependent>
<name value="SubstitutionDispense"/>
<variable value="substitution"/>
<variable value="act"/>
</dependent>
</rule>
</group>
<group>
<name value="DosageInstructionsStartStopFrequencySupply"/>
<typeMode value="none"/>
<documentation
value="source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35
dosage for normal dosing (without sequences) (Dispense)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="supply"/>
<type value="Supply"/>
<mode value="target"/>
</input>
<rule>
<name value="entryRelationship"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<rule>
<name value="COMP"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
</rule>
<rule>
<name value="substanceAdministration"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<rule>
<name value="SBADM"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
</rule>
<rule>
<name value="INT"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.6"/>
</parameter>
</target>
</rule>
<rule>
<name value="normalDose"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="effectiveTimeStartEnd"/>
<source>
<context value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeStartEnd"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="effectiveTimeWhen"/>
<source>
<context value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeWhenNormal"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="route"/>
<source>
<context value="dosage"/>
<element value="route"/>
<variable value="route"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="routeCode"/>
<variable value="routeCode"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="route"/>
<variable value="routeCode"/>
</dependent>
</rule>
<rule>
<name value="doseQuantity"/>
<source>
<context value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="DoseQuantity"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="consumable"/>
<source>
<context value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</group>
<group>
<name value="DosageInstructionsEntryStartStopRouteConsumable"/>
<typeMode value="none"/>
<documentation
value="source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
dosage for split dosing: effectiveTime (start/stop) & routeCode & consumable (Dispense)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="entryRelationship"/>
<type value="entryRelationship"/>
<mode value="target"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="COMP"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
</rule>
<rule>
<name value="SBADM"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
</rule>
<rule>
<name value="INT"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.6"/>
</parameter>
</target>
</rule>
<rule>
<name value="splitDose"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.9"/>
</parameter>
</target>
</rule>
<rule>
<name value="effectiveTimeStartEnd"/>
<source>
<context value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<variable value="substanceAdministration"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeStartEnd"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="route"/>
<source>
<context value="dosage"/>
<element value="route"/>
<variable value="route"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="routeCode"/>
<variable value="routeCode"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="route"/>
<variable value="routeCode"/>
</dependent>
</rule>
<rule>
<name value="consumable"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="DosageInstructionsEntryDosageChangeEntryRelationship"/>
<typeMode value="none"/>
<documentation
value="source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split
target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36
dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Dispense)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="entryRelationship"/>
<type value="entryRelationship"/>
<mode value="target"/>
</input>
<rule>
<name value="sequence"/>
<source>
<context value="dosage"/>
<element value="sequence"/>
<variable value="sequence"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="sequenceNumber"/>
<variable value="sequenceNumber"/>
</target>
<target>
<context value="sequenceNumber"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="sequence"/>
</parameter>
</target>
</rule>
<rule>
<name value="dosage"/>
<source>
<context value="dosage"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
<rule>
<name value="effectiveTimeWhen"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="EffectiveTimeWhenSplit"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="doseQuantity"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<contextType value="variable"/>
<transform value="copy"/>
<parameter>
<valueId value="substanceAdministration"/>
</parameter>
</target>
<dependent>
<name value="DoseQuantity"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="consumable"/>
<source>
<context value="dosage"/>
<variable value="dosage"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NA"/>
</parameter>
</target>
</rule>
</rule>
</group>
<group>
<name value="EffectiveTimeWhenNormal"/>
<typeMode value="none"/>
<documentation
value="effective time when for normal dosage (Dispense, Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="timing"/>
<source>
<context value="dosage"/>
<element value="timing"/>
<variable value="timing"/>
</source>
<rule>
<name value="repeat"/>
<source>
<context value="timing"/>
<element value="repeat"/>
<variable value="repeat"/>
</source>
<rule>
<name value="when"/>
<source>
<context value="repeat"/>
<condition value="$this.when.count() = 1"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="effectiveTime"/>
<variable value="effectiveTime"/>
<transform value="create"/>
<parameter>
<valueString value="EIVL_TS"/>
</parameter>
</target>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="operator"/>
<transform value="copy"/>
<parameter>
<valueString value="A"/>
</parameter>
</target>
<rule>
<name value="when"/>
<source>
<context value="repeat"/>
<element value="when"/>
<variable value="when"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="event"/>
<variable value="event"/>
</target>
<target>
<context value="event"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueId value="when"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="when"/>
<source>
<context value="repeat"/>
<condition value="$this.when.count() > 1"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="effectiveTime"/>
<variable value="effectiveTime"/>
<transform value="create"/>
<parameter>
<valueString value="SXPR_TS"/>
</parameter>
</target>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="operator"/>
<transform value="copy"/>
<parameter>
<valueString value="A"/>
</parameter>
</target>
<rule>
<name value="comp"/>
<source>
<context value="repeat"/>
<element value="when"/>
<listMode value="first"/>
<variable value="when"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="comp"/>
<variable value="comp"/>
<transform value="create"/>
<parameter>
<valueString value="EIVL_TS"/>
</parameter>
</target>
<rule>
<name value="when"/>
<source>
<context value="when"/>
</source>
<target>
<context value="comp"/>
<contextType value="variable"/>
<element value="event"/>
<variable value="event"/>
</target>
<target>
<context value="event"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueId value="when"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="compnotfirst"/>
<source>
<context value="repeat"/>
<element value="when"/>
<listMode value="not_first"/>
<variable value="when"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="comp"/>
<variable value="comp"/>
<transform value="create"/>
<parameter>
<valueString value="EIVL_TS"/>
</parameter>
</target>
<target>
<context value="comp"/>
<contextType value="variable"/>
<element value="operator"/>
<transform value="copy"/>
<parameter>
<valueString value="I"/>
</parameter>
</target>
<rule>
<name value="when"/>
<source>
<context value="when"/>
</source>
<target>
<context value="comp"/>
<contextType value="variable"/>
<element value="event"/>
<variable value="event"/>
</target>
<target>
<context value="event"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueId value="when"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</rule>
</rule>
</group>
<group>
<name value="EffectiveTimeWhenSplit"/>
<typeMode value="none"/>
<documentation
value="effective time when for split dosage (Dispense, Statement, Prescription)"/>
<input>
<name value="dosage"/>
<type value="Dosage"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="timing"/>
<source>
<context value="dosage"/>
<element value="timing"/>
<variable value="timing"/>
</source>
<rule>
<name value="repeat"/>
<source>
<context value="timing"/>
<element value="repeat"/>
<variable value="repeat"/>
</source>
<rule>
<name value="when"/>
<source>
<context value="repeat"/>
<condition value="$this.when.count() = 1"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="effectiveTime"/>
<variable value="effectiveTime"/>
<transform value="create"/>
<parameter>
<valueString value="EIVL_TS"/>
</parameter>
</target>
<rule>
<name value="when"/>
<source>
<context value="repeat"/>
<element value="when"/>
<variable value="when"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="event"/>
<variable value="event"/>
</target>
<target>
<context value="event"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueId value="when"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="when"/>
<source>
<context value="repeat"/>
<condition value="$this.when.count() > 1"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="effectiveTime"/>
<variable value="effectiveTime"/>
<transform value="create"/>
<parameter>
<valueString value="SXPR_TS"/>
</parameter>
</target>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="operator"/>
<transform value="copy"/>
<parameter>
<valueString value="A"/>
</parameter>
</target>
<rule>
<name value="comp"/>
<source>
<context value="repeat"/>
<element value="when"/>
<listMode value="first"/>
<variable value="when"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="comp"/>
<variable value="comp"/>
<transform value="create"/>
<parameter>
<valueString value="EIVL_TS"/>
</parameter>
</target>
<rule>
<name value="when"/>
<source>
<context value="when"/>
</source>
<target>
<context value="comp"/>
<contextType value="variable"/>
<element value="event"/>
<variable value="event"/>
</target>
<target>
<context value="event"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueId value="when"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="compnotfirst"/>
<source>
<context value="repeat"/>
<element value="when"/>
<listMode value="not_first"/>
<variable value="when"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="comp"/>
<variable value="comp"/>
<transform value="create"/>
<parameter>
<valueString value="EIVL_TS"/>
</parameter>
</target>
<target>
<context value="comp"/>
<contextType value="variable"/>
<element value="operator"/>
<transform value="copy"/>
<parameter>
<valueString value="I"/>
</parameter>
</target>
<rule>
<name value="when"/>
<source>
<context value="when"/>
</source>
<target>
<context value="comp"/>
<contextType value="variable"/>
<element value="event"/>
<variable value="event"/>
</target>
<target>
<context value="event"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueId value="when"/>
</parameter>
</target>
</rule>
</rule>
</rule>
</rule>
</rule>
</group>
<group>
<name value="SubstitutionRequest"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module"/>
<input>
<name value="substitution"/>
<type value="Substitution"/>
<mode value="source"/>
</input>
<input>
<name value="act"/>
<type value="Act"/>
<mode value="target"/>
</input>
<rule>
<name value="ACT"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACT"/>
</parameter>
</target>
</rule>
<rule>
<name value="DEF"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="DEF"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.9.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="substitution"/>
<source>
<context value="substitution"/>
<element value="allowedCodeableConcept"/>
<variable value="allowedCC"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="allowedCC"/>
<variable value="code"/>
</dependent>
</rule>
<rule>
<name value="statusCode"/>
<source>
<context value="substitution"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="statusCode"/>
</target>
<target>
<context value="statusCode"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="SubstitutionStatement"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module"/>
<input>
<name value="extension"/>
<type value="Extension"/>
<mode value="source"/>
</input>
<input>
<name value="act"/>
<type value="Act"/>
<mode value="target"/>
</input>
<rule>
<name value="ACT"/>
<source>
<context value="extension"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACT"/>
</parameter>
</target>
</rule>
<rule>
<name value="DEF"/>
<source>
<context value="extension"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="DEF"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="extension"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.9.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="extension"/>
<source>
<context value="extension"/>
<element value="valueCodeableConcept"/>
<variable value="valueCC"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="valueCC"/>
<variable value="code"/>
</dependent>
</rule>
<rule>
<name value="statusCode"/>
<source>
<context value="extension"/>
</source>
<target>
<context value="act"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="statusCode"/>
</target>
<target>
<context value="statusCode"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
</group>
<group>
<name value="PrescribedQuantity"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38"/>
<input>
<name value="dispenseRequest"/>
<type value="DispenseRequest"/>
<mode value="source"/>
</input>
<input>
<name value="supply"/>
<type value="Supply"/>
<mode value="target"/>
</input>
<rule>
<name value="SPLY"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SPLY"/>
</parameter>
</target>
</rule>
<rule>
<name value="RQO"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="RQO"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.8"/>
</parameter>
</target>
</rule>
<rule>
<name value="independentInd"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="independentInd"/>
<variable value="independentInd"/>
</target>
<target>
<context value="independentInd"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="false"/>
</parameter>
</target>
</rule>
<rule>
<name value="quantity"/>
<source>
<context value="dispenseRequest"/>
<element value="quantity"/>
<variable value="quantity"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="quantity"/>
<variable value="quant"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="quantity"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="quant"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<documentation value="Number of packages"/>
</rule>
</group>
<group>
<name value="PrescribedQuantityUnit"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38"/>
<input>
<name value="dispenseRequest"/>
<type value="DispenseRequest"/>
<mode value="source"/>
</input>
<input>
<name value="supply"/>
<type value="Supply"/>
<mode value="target"/>
</input>
<rule>
<name value="SPLY"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SPLY"/>
</parameter>
</target>
</rule>
<rule>
<name value="RQO"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="RQO"/>
</parameter>
</target>
</rule>
<rule>
<name value="TemplateId"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.8"/>
</parameter>
</target>
</rule>
<rule>
<name value="independentInd"/>
<source>
<context value="dispenseRequest"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="independentInd"/>
<variable value="independentInd"/>
</target>
<target>
<context value="independentInd"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="false"/>
</parameter>
</target>
</rule>
<rule>
<name value="quantity"/>
<source>
<context value="dispenseRequest"/>
<element value="quantity"/>
<variable value="quantity"/>
</source>
<target>
<context value="supply"/>
<contextType value="variable"/>
<element value="quantity"/>
<variable value="quant"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="quantity"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="quant"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<rule>
<name value="unit"/>
<source>
<context value="quantity"/>
<element value="unit"/>
<variable value="unit"/>
</source>
<target>
<context value="quant"/>
<contextType value="variable"/>
<element value="unit"/>
<transform value="copy"/>
<parameter>
<valueId value="unit"/>
</parameter>
</target>
</rule>
<documentation value="Number of packages"/>
</rule>
</group>
<group>
<name value="ManufacturedMaterialEntryContentModulePrescription"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="medicationRequest"/>
<type value="MedicationRequest"/>
<mode value="source"/>
</input>
<input>
<name value="medication"/>
<type value="Medication"/>
<mode value="source"/>
</input>
<input>
<name value="manufacturedMaterial"/>
<type value="ManufacturedMaterial"/>
<mode value="target"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="MMAT"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MMAT"/>
</parameter>
</target>
</rule>
<rule>
<name value="KIND"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="KIND"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-ManufacturedMaterialContentModule"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.33"/>
</parameter>
</target>
</rule>
<rule>
<name value="templateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.1"/>
</parameter>
</target>
</rule>
<rule>
<name value="name"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<rule>
<name value="brandname"/>
<source>
<context value="code"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<rule>
<name value="id"/>
<source>
<context value="code"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="originalText"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
<documentation value="#pre.no.brandedmedication"/>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="code"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="code"/>
</target>
<target>
<context value="code"/>
<contextType value="variable"/>
<element value="originalText"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
<rule>
<name value="code"/>
<source>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
</rule>
<rule>
<name value="form"/>
<source>
<context value="medication"/>
<element value="form"/>
<variable value="form"/>
</source>
<rule>
<name value="formCode"/>
<source>
<context value="form"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="formCode"/>
<variable value="formCode"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="formCode"/>
</dependent>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medication"/>
<element value="code"/>
<variable value="code"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="asContent"/>
<variable value="asContent"/>
</target>
<target>
<context value="asContent"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="CONT"/>
</parameter>
</target>
<target>
<context value="asContent"/>
<contextType value="variable"/>
<element value="containerPackagedMedicine"/>
<variable value="containerPackagedMedicine"/>
</target>
<rule>
<name value="CONT"/>
<source>
<context value="code"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="CONT"/>
</parameter>
</target>
</rule>
<rule>
<name value="INSTANCE"/>
<source>
<context value="code"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INSTANCE"/>
</parameter>
</target>
</rule>
<rule>
<name value="pharm-code"/>
<source>
<context value="code"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
<rule>
<name value="pharm-name"/>
<source>
<context value="code"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
<rule>
<name value="form"/>
<source>
<context value="medication"/>
<element value="form"/>
<variable value="form"/>
</source>
<rule>
<name value="pharm-formCode"/>
<source>
<context value="form"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="formCode"/>
<variable value="formCode"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="formCode"/>
</dependent>
</rule>
</rule>
<rule>
<name value="amount"/>
<source>
<context value="medication"/>
<element value="amount"/>
<variable value="amount"/>
</source>
<rule>
<name value="numerator"/>
<source>
<context value="amount"/>
<element value="numerator"/>
<variable value="numerator"/>
</source>
<target>
<context value="containerPackagedMedicine"/>
<contextType value="variable"/>
<element value="capacityQuantity"/>
<variable value="capacityQuantity"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="numerator"/>
<element value="value"/>
<variable value="value"/>
</source>
<target>
<context value="capacityQuantity"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="value"/>
</parameter>
</target>
</rule>
<rule>
<name value="unit"/>
<source>
<context value="numerator"/>
<element value="code"/>
<variable value="unit"/>
</source>
<target>
<context value="capacityQuantity"/>
<contextType value="variable"/>
<element value="unit"/>
<transform value="copy"/>
<parameter>
<valueId value="unit"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="PrescribedQuantity"/>
<source>
<context value="medicationRequest"/>
<element value="dispenseRequest"/>
<variable value="dispenseRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="supply"/>
<variable value="supply"/>
</target>
<dependent>
<name value="PrescribedQuantity"/>
<variable value="dispenseRequest"/>
<variable value="supply"/>
</dependent>
<documentation
value="IHE-DIS: Case 1: If the product-element contains package information, the unit attribute is not be present"/>
</rule>
<documentation value="Package size"/>
</rule>
<rule>
<name value="noAmount"/>
<source>
<context value="medication"/>
<condition value="$this.amount.exists() = false"/>
</source>
<rule>
<name value="PrescribedQuantityUnit"/>
<source>
<context value="medicationRequest"/>
<element value="dispenseRequest"/>
<variable value="dispenseRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="supply"/>
<variable value="supply"/>
</target>
<dependent>
<name value="PrescribedQuantityUnit"/>
<variable value="dispenseRequest"/>
<variable value="supply"/>
</dependent>
</rule>
<documentation
value="IHE-DIS: Case 2: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system"/>
</rule>
</rule>
<rule>
<name value="ingredient"/>
<source>
<context value="medication"/>
<element value="ingredient"/>
<variable value="ingredient"/>
</source>
<target>
<context value="manufacturedMaterial"/>
<contextType value="variable"/>
<element value="ingredient"/>
<variable value="ingredient"/>
</target>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="ACTI"/>
</parameter>
</target>
<rule>
<name value="PharmSubstance"/>
<source>
<context value="ingredient"/>
<element value="itemCodeableConcept"/>
<variable value="itemCodeableConcept"/>
</source>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="ingredient"/>
<variable value="pharmsubstance"/>
</target>
<rule>
<name value="MMAT"/>
<source>
<context value="itemCodeableConcept"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MMAT"/>
</parameter>
</target>
</rule>
<rule>
<name value="KIND"/>
<source>
<context value="itemCodeableConcept"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="determinerCode"/>
<transform value="copy"/>
<parameter>
<valueString value="KIND"/>
</parameter>
</target>
</rule>
<rule>
<name value="name"/>
<source>
<context value="itemCodeableConcept"/>
<element value="text"/>
<variable value="text"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="name"/>
<variable value="name"/>
</target>
<target>
<context value="name"/>
<contextType value="variable"/>
<element value="other"/>
<transform value="copy"/>
<parameter>
<valueId value="text"/>
</parameter>
</target>
</rule>
<rule>
<name value="coding"/>
<source>
<context value="itemCodeableConcept"/>
<element value="coding"/>
<variable value="coding"/>
</source>
<rule>
<name value="formCode"/>
<source>
<context value="coding"/>
</source>
<target>
<context value="pharmsubstance"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="ce"/>
</target>
<dependent>
<name value="CodingCE"/>
<variable value="coding"/>
<variable value="ce"/>
</dependent>
</rule>
</rule>
</rule>
<rule>
<name value="strength"/>
<source>
<context value="ingredient"/>
<element value="strength"/>
<variable value="strength"/>
</source>
<target>
<context value="ingredient"/>
<contextType value="variable"/>
<element value="quantity"/>
<variable value="quantity"/>
</target>
<dependent>
<name value="RatioRTOPQPQ"/>
<variable value="strength"/>
<variable value="quantity"/>
</dependent>
</rule>
</rule>
</group>
<group>
<name value="PrescriptionItemEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.43"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="medicationRequest"/>
<type value="MedicationRequest"/>
<mode value="source"/>
</input>
<input>
<name value="substanceAdministration"/>
<type value="SubstanceAdministration"/>
<mode value="target"/>
</input>
<rule>
<name value="SBADM"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="SBADM"/>
</parameter>
</target>
</rule>
<rule>
<name value="INT"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="INT"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-PrescriptionItemEntryContentModule"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.43"/>
</parameter>
</target>
</rule>
<rule>
<name value="PrescriptionItemEntryTemplateId"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="CCD"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.24"/>
</parameter>
</target>
</rule>
<rule>
<name value="PCC-MedicationEntryContentModule"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="medicationRequest"/>
<element value="identifier"/>
<variable value="identifier"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="id"/>
<variable value="id"/>
</target>
<dependent>
<name value="IdentifierII"/>
<variable value="identifier"/>
<variable value="id"/>
</dependent>
</rule>
<rule>
<name value="narrativeLink"/>
<source>
<context value="medicationRequest"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<rule>
<name value="valueUrl"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="cat1narrativelink"/>
<source>
<context value="medicationRequest"/>
<condition
value="extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not()"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<rule>
<name value="referencetopdf"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="code"/>
<source>
<context value="medicationRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="statusCode"/>
</target>
<target>
<context value="statusCode"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
<rule>
<name value="dispenseRequest"/>
<source>
<context value="medicationRequest"/>
<element value="dispenseRequest"/>
<variable value="dispenseRequest"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="repeatNumber"/>
<variable value="repeatNumber"/>
</target>
<rule>
<name value="repeatNumber"/>
<source>
<context value="dispenseRequest"/>
<element value="numberOfRepeatsAllowed"/>
<variable value="number"/>
</source>
<target>
<context value="repeatNumber"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="number"/>
</parameter>
</target>
</rule>
<rule>
<name value="repeatNumberNull"/>
<source>
<context value="dispenseRequest"/>
<condition value="numberOfRepeatsAllowed.exists() = false"/>
</source>
<target>
<context value="repeatNumber"/>
<contextType value="variable"/>
<element value="nullFlavor"/>
<transform value="copy"/>
<parameter>
<valueString value="NI"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="contained"/>
<source>
<context value="medicationRequest"/>
<element value="contained"/>
<variable value="medication"/>
<condition
value="('#' + $this.id) in %medicationRequest.medicationReference.reference"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="consumable"/>
<variable value="consumable"/>
</target>
<target>
<context value="consumable"/>
<contextType value="variable"/>
<element value="manufacturedProduct"/>
<variable value="manufacturedProduct"/>
</target>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="MANU"/>
</parameter>
</target>
<rule>
<name value="MP-templateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.2"/>
</parameter>
</target>
</rule>
<rule>
<name value="MP-templateId"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.840.1.113883.10.20.1.53"/>
</parameter>
</target>
</rule>
<rule>
<name value="manufacturedMaterial"/>
<source>
<context value="medication"/>
</source>
<target>
<context value="manufacturedProduct"/>
<contextType value="variable"/>
<element value="manufacturedMaterial"/>
<variable value="manufacturedMaterial"/>
</target>
<dependent>
<name value="ManufacturedMaterialEntryContentModulePrescription"/>
<variable value="bundle"/>
<variable value="medicationRequest"/>
<variable value="medication"/>
<variable value="manufacturedMaterial"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
</rule>
<rule>
<name value="onylonedosage"/>
<source>
<context value="medicationRequest"/>
<condition value="dosageInstruction.count() = 1"/>
</source>
<rule>
<name value="normalDose"/>
<source>
<context value="medicationRequest"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.5.3.1.4.7.1"/>
</parameter>
</target>
</rule>
<documentation value="TODO: AUTHOR1 Medication Treatment Plan Author"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationRequest"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal-medicationrequest')"/>
</source>
<dependent>
<name
value="DosageInstructionsStartStopFrequencySubstanceAdministration"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationRequest"/>
<element value="dosageInstruction"/>
<listMode value="first"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<dependent>
<name value="DosageInstructionsEntryStartStopRoute"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
<variable value="entryRelationship"/>
</dependent>
<documentation
value="dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode"/>
</rule>
<rule>
<name value="DosageSubstanceAdministration"/>
<source>
<context value="medicationRequest"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<dependent>
<name value="DosageInstructionsEntryDosageChangeSubstanceAdministration"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
<variable value="entryRelationship"/>
</dependent>
<documentation
value="dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable"/>
</rule>
<rule>
<name value="TreatmentReasonEntryContentModule"/>
<source>
<context value="medicationRequest"/>
<element value="reasonCode"/>
<variable value="reasonCode"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="RSON"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="observation"/>
<variable value="observation"/>
</target>
<dependent>
<name value="TreatmentReasonEntryContentModule"/>
<variable value="reasonCode"/>
<variable value="observation"/>
</dependent>
</rule>
<rule>
<name value="MTP-Reference"/>
<source>
<context value="medicationRequest"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan'"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="REFR"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="MTPReferenceEntryContentModule"/>
<variable value="extension"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<source>
<context value="medicationRequest"/>
<element value="dosageInstruction"/>
<variable value="dosage"/>
<condition
value="$this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured')"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="DosageInstructionsNonStructuredEntryContentModule"/>
<variable value="dosage"/>
<variable value="substanceAdministration"/>
</dependent>
<documentation
value="TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC)"/>
</rule>
<rule>
<name value="AnnotationComment"/>
<source>
<context value="medicationRequest"/>
<element value="note"/>
<variable value="note"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="act"/>
<variable value="act"/>
</target>
<dependent>
<name value="AnnotationComment"/>
<variable value="note"/>
<variable value="act"/>
</dependent>
</rule>
<rule>
<name value="Substitution"/>
<source>
<context value="medicationRequest"/>
<element value="substitution"/>
<variable value="substitution"/>
</source>
<target>
<context value="substanceAdministration"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="COMP"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="act"/>
<variable value="act"/>
</target>
<dependent>
<name value="SubstitutionRequest"/>
<variable value="substitution"/>
<variable value="act"/>
</dependent>
</rule>
</group>
<group>
<name value="PharmaceuticalAdviceItemEntryContentModule"/>
<typeMode value="none"/>
<documentation
value="source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-observation.html
target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.44"/>
<input>
<name value="bundle"/>
<type value="Bundle"/>
<mode value="source"/>
</input>
<input>
<name value="fhirobservation"/>
<type value="Observation"/>
<mode value="source"/>
</input>
<input>
<name value="cdaobservation"/>
<type value="Observation"/>
<mode value="target"/>
</input>
<rule>
<name value="OBS"/>
<source>
<context value="fhirobservation"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="classCode"/>
<transform value="copy"/>
<parameter>
<valueString value="OBS"/>
</parameter>
</target>
</rule>
<rule>
<name value="EVN"/>
<source>
<context value="fhirobservation"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="moodCode"/>
<transform value="copy"/>
<parameter>
<valueString value="EVN"/>
</parameter>
</target>
</rule>
<rule>
<name value="IHE-PHARM-PADV"/>
<source>
<context value="fhirobservation"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="1.3.6.1.4.1.19376.1.9.1.3.3"/>
</parameter>
</target>
</rule>
<rule>
<name value="CH-PHARM-PharmaceuticalAdviceItemEntryContentModule"/>
<source>
<context value="fhirobservation"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="templateId"/>
<variable value="templateId"/>
</target>
<target>
<context value="templateId"/>
<contextType value="variable"/>
<element value="root"/>
<transform value="copy"/>
<parameter>
<valueString value="2.16.756.5.30.1.1.10.4.44"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="fhirobservation"/>
<element value="identifier"/>
<variable value="identifier"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="id"/>
<variable value="id"/>
</target>
<dependent>
<name value="IdentifierII"/>
<variable value="identifier"/>
<variable value="id"/>
</dependent>
</rule>
<rule>
<name value="code"/>
<source>
<context value="fhirobservation"/>
<element value="code"/>
<variable value="fhirCode"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="code"/>
<variable value="cdaCode"/>
</target>
<dependent>
<name value="CodeableConceptCE"/>
<variable value="fhirCode"/>
<variable value="cdaCode"/>
</dependent>
</rule>
<rule>
<name value="code"/>
<source>
<context value="fhirobservation"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="statusCode"/>
<variable value="statusCode"/>
</target>
<target>
<context value="statusCode"/>
<contextType value="variable"/>
<element value="code"/>
<transform value="copy"/>
<parameter>
<valueString value="completed"/>
</parameter>
</target>
</rule>
<rule>
<name value="effectiveTime"/>
<source>
<context value="fhirobservation"/>
<element value="effectiveDateTime"/>
<variable value="effectiveDateTime"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="effectiveTime"/>
<variable value="effectiveTime"/>
</target>
<rule>
<name value="value"/>
<source>
<context value="effectiveDateTime"/>
</source>
<target>
<context value="effectiveTime"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="effectiveDateTime"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="MTP-Reference"/>
<source>
<context value="fhirobservation"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan'"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="REFR"/>
</parameter>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="MTPReferenceEntryContentModule"/>
<variable value="extension"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
<rule>
<name value="changedmtp"/>
<source>
<context value="fhirobservation"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-medicationstatement-changed'"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="entryRelationship"/>
<variable value="entryRelationship"/>
</target>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="typeCode"/>
<transform value="copy"/>
<parameter>
<valueString value="REFR"/>
</parameter>
</target>
<rule>
<name value="entry"/>
<source>
<context value="bundle"/>
<element value="entry"/>
<variable value="entry"/>
</source>
<rule>
<name value="fullUrlAsUuid"/>
<source>
<context value="entry"/>
<element value="fullUrl"/>
<condition
value="($this in %extension.valueReference.reference) and $this.startsWith('urn:uuid')"/>
</source>
<rule>
<name value="MedicationStatement"/>
<source>
<context value="entry"/>
<element value="resource"/>
<variable value="medicationStatement"/>
<condition value="$this.ofType(FHIR.MedicationStatement)"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="MedicationTreatmentPlanItemEntryContentModule"/>
<variable value="bundle"/>
<variable value="medicationStatement"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
</rule>
<rule>
<name value="MedicationStatement"/>
<source>
<context value="entry"/>
<element value="resource"/>
<variable value="medicationStatement"/>
<condition
value="$this.ofType(FHIR.MedicationStatement) and (('MedicationStatement' + '/' + $this.id) in %extension.valueReference.reference)"/>
</source>
<target>
<context value="entryRelationship"/>
<contextType value="variable"/>
<element value="substanceAdministration"/>
<variable value="substanceAdministration"/>
</target>
<dependent>
<name value="MedicationTreatmentPlanItemEntryContentModule"/>
<variable value="bundle"/>
<variable value="medicationStatement"/>
<variable value="substanceAdministration"/>
</dependent>
</rule>
</rule>
</rule>
<rule>
<name value="note"/>
<source>
<context value="fhirobservation"/>
<element value="note"/>
<variable value="note"/>
</source>
<rule>
<name value="narrativeLink"/>
<source>
<context value="note"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<rule>
<name value="valueUrl"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="note"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="text"/>
<source>
<context value="fhirobservation"/>
<element value="note"/>
<variable value="note"/>
</source>
<target>
<context value="cdaobservation"/>
<contextType value="variable"/>
<element value="text"/>
<variable value="text"/>
</target>
<rule>
<name value="text"/>
<source>
<context value="note"/>
<element value="text"/>
<variable value="noteText"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="data"/>
<transform value="copy"/>
<parameter>
<valueId value="noteText"/>
</parameter>
</target>
</rule>
<rule>
<name value="id"/>
<source>
<context value="note"/>
<element value="extension"/>
<variable value="extension"/>
<condition
value="$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"/>
</source>
<rule>
<name value="reference"/>
<source>
<context value="extension"/>
<element value="valueUrl"/>
<variable value="valueUrl"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueId value="valueUrl"/>
</parameter>
</target>
</rule>
</rule>
<rule>
<name value="reference"/>
<source>
<context value="note"/>
<condition
value="(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"/>
</source>
<target>
<context value="text"/>
<contextType value="variable"/>
<element value="reference"/>
<variable value="reference"/>
</target>
<target>
<context value="reference"/>
<contextType value="variable"/>
<element value="value"/>
<transform value="copy"/>
<parameter>
<valueString value="#refpdf"/>
</parameter>
</target>
</rule>
</rule>
</group>
</StructureMap>