<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-medication" />
  <url value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-medication" />
  <name value="Medication" />
  <title value="Medication" />
  <status value="draft" />
  <description value="Conveys medication details" />
  <purpose value="Conveys medication details" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Medication" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Medication" />
  <derivation value="constraint" />
  <differential>
    <element id="Medication.text">
      <path value="Medication.text" />
      <max value="0" />
    </element>
    <element id="Medication.code">
      <path value="Medication.code" />
      <comment value="Usage Rule - Compounds: To support CPHA backward compatibility, the DIN may be a psedo DIN, or the active DIN/ingredient or the most expensive DIN, or the highest percentage of the compound.   For compounds, description should also be sent as 'text' (medication.code.text) when available.   &#xD;&#xA;Usage Note: This identifies the medication that has been dispensed. A 'code' (Canadian Clinical Drug Data Set (CCDD), or DIN or NPN)  must be provided. A DIN, or an NPN may also be used if a CCDD code is not available.   This has an extensible binding meaning that the CCDD code system should be used but if a code is not available, vendors may also submit a code from the DIN or NPN code system.    Note:  CCDD will encompass all DINs and NPNs.&#xD;&#xA;&#xD;&#xA;CPHA Map:   DIN / GP# / PIN  D.56.03&#xD;&#xA;&#xD;&#xA;Depending on the context of use, the code that was actually selected by the user (prescriber, dispenser, etc.) will have the coding.userSelected set to true.  As described in the coding datatype: &quot;A coding may be marked as a &quot;userSelected&quot; if a user selected the particular coded value in a user interface (e.g. the user selects an item in a pick-list). If a user selected coding exists, it is the preferred choice for performing translations etc. Other codes can only be literal translations to alternative code systems, or codes at a lower level of granularity (e.g. a generic code for a vendor-specific primary one)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.code.coding">
      <path value="Medication.code.coding" />
      <comment value="Usage Note:   Treat as mandatory for all medications.  A code is required or compounds for backwards compatibility.&#xD;&#xA;&#xD;&#xA;Codes may be defined very casually in enumerations, or code lists, up to very formal definitions such as SNOMED CT - see the HL7 v3 Core Principles for more information.  Ordering of codings is undefined and SHALL NOT be used to infer meaning. Generally, at most only one of the coding values will be labeled as UserSelected = true." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.code.coding.system">
      <path value="Medication.code.coding.system" />
      <comment value="CPHA:  No mapping; this is a new data element&#xD;&#xA;&#xD;&#xA;Usage:  Code systems that are acceptable in the message are:&#xD;&#xA;CCDD - https://fhir.infoway-inforoute.ca/CodeSystem/canadianclinicaldrugdataset&#xD;&#xA;DIN - http://hl7.org/fhir/NamingSystem/ca-hc-din&#xD;&#xA;NPN - http://hl7.org/fhir/NamingSystem/ca-hc-npn&#xD;&#xA;Opinions - PIN - 2.16.840.1.113883.5.1102  (source PEI)&#xD;&#xA;Unlisted Compound - http://pharmacyeclaims.ca/FHIR/CodeSystem/unlisted-compound-codes &#xD;&#xA;Adjudicator-specific Psuedo DINs  - Adjudicator specific.  Each adjudicator will provide the &quot;Code system&quot; associated with their set of codes.   Once established this specificaiton can be updated to include&#xD;&#xA;&#xD;&#xA;The URI may be an OID (urn:oid:...) or a UUID (urn:uuid:...).  OIDs and UUIDs SHALL be references to the HL7 OID registry. Otherwise, the URI should come from HL7's list of FHIR defined special URIs or it should reference to some definition that establishes the system clearly and unambiguously." />
      <mustSupport value="true" />
    </element>
    <element id="Medication.code.coding.code">
      <path value="Medication.code.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.code.text">
      <path value="Medication.code.text" />
      <comment value="Usage Note:   Compound names such as &quot;magic mouthwash&quot; can be included here.&#xD;&#xA;&#xD;&#xA;Very often the text is the same as a displayName of one of the codings." />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient">
      <path value="Medication.ingredient" />
      <comment value="Usage Note:  For testing purposes, the limit is 50 ingredients. &#xD;&#xA;Usage Rule:  UPC /GTIN --&gt;  should be sent if available, together with text, otherwise, just text.&#xD;&#xA;Usage Rule:   support multiple active ingredients&#xD;&#xA;The ingredients need not be a complete list.  If an ingredient is not specified, this does not indicate whether an ingredient is present or absent.  If an ingredient is specified it does not mean that all ingredients are specified.  It is possible to specify both inactive and active ingredients." />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.extension:IngredientPercentageTotalCost">
      <path value="Medication.ingredient.extension" />
      <sliceName value="IngredientPercentageTotalCost" />
      <definition value="This represents the percentage of the total cost of the Prescription that this ingredient represents" />
      <comment value="Usage Note:   Vendors must include the percentage of cost that each ingredient represents wherever possible.&#xD;&#xA;CPHA Map:   None; new data element" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/ext-ingredient-percentage-total-cost" />
      </type>
      <mustSupport value="true" />
      <isModifier value="false" />
    </element>
    <element id="Medication.ingredient.extension:ingredientQuantity">
      <path value="Medication.ingredient.extension" />
      <sliceName value="ingredientQuantity" />
      <comment value="Usage:   The quantity of an ingredient within the medication.  Must be specified when known&#xD;&#xA;CPHA Map:  None - new data element&#xD;&#xA;&#xD;&#xA;There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone." />
      <type>
        <code value="Extension" />
        <profile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/ext-IngredientQuantity" />
      </type>
      <mustSupport value="true" />
      <isModifier value="false" />
    </element>
    <element id="Medication.ingredient.extension:ingredientQuantity.value[x]">
      <path value="Medication.ingredient.extension.value[x]" />
    </element>
    <element id="Medication.ingredient.extension:ingredientQuantity.value[x].value">
      <path value="Medication.ingredient.extension.value[x].value" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.extension:ingredientQuantity.value[x].unit">
      <path value="Medication.ingredient.extension.value[x].unit" />
      <mustSupport value="false" />
    </element>
    <element id="Medication.ingredient.extension:ingredientQuantity.value[x].system">
      <path value="Medication.ingredient.extension.value[x].system" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.extension:ingredientQuantity.value[x].code">
      <path value="Medication.ingredient.extension.value[x].code" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.item[x]">
      <path value="Medication.ingredient.item[x]" />
      <comment value="Usage Note:   All ingredients should be codified where possible.   A textual desciption should be provided when coding is not one of the known accepable codings (eg DIN, CCDD, NPN, etc)&#xD;&#xA;Usage Note:   If an ingredient cannot be codified, text must be provided (eg for non drug related items such as water)" />
      <type>
        <code value="CodeableConcept" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.item[x].coding">
      <path value="Medication.ingredient.item[x].coding" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.item[x].coding.system">
      <path value="Medication.ingredient.item[x].coding.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.item[x].coding.code">
      <path value="Medication.ingredient.item[x].coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.item[x].text">
      <path value="Medication.ingredient.item[x].text" />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.isActive">
      <path value="Medication.ingredient.isActive" />
      <comment value="Usage Note:  This must be populated when ingredient is active.   More than one active ingredient may be specified." />
      <mustSupport value="true" />
    </element>
    <element id="Medication.ingredient.strength">
      <path value="Medication.ingredient.strength" />
      <comment value="Usage Note:   May be provided if available and applicable&#xD;&#xA;The Ratio datatype should only be used to express a relationship of two numbers if the relationship cannot be suitably expressed using a Quantity and a common unit.  Where the denominator value is known to be fixed to &quot;1&quot;, Quantity should be used instead of Ratio." />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>