<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="MedicationStatementPSAB" />
  <url value="https://www.alberta.ca/fhir/psab/StructureDefinition/MedicationStatementPSAB" />
  <version value="1.2.0" />
  <name value="MedicationStatementPSAB" />
  <title value="MedicationStatement (PS-AB)" />
  <status value="draft" />
  <description value="This profile defines a set of constraints to the FHIR MedicationStatement resource for use in Alberta Patient Summaries (PS-AB). It re-profiles the PS-CA MedicationStatement profile and refines constraints that represent the minimum expectations for the MedicationStatement resource when used in the PS-AB Composition profile." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="MedicationStatement" />
  <baseDefinition value="http://fhir.infoway-inforoute.ca/io/psca/StructureDefinition/medicationstatement-ca-ps" />
  <derivation value="constraint" />
  <differential>
    <element id="MedicationStatement">
      <path value="MedicationStatement" />
      <comment value="MedicationStatement resources included in Alberta Patient Summary Document Bundles have rules that certain attributes are not to be contained in MedicationStatement resource. These are mechanically enforced through invariants at the PS-AB Bundle level." />
    </element>
    <element id="MedicationStatement.status">
      <path value="MedicationStatement.status" />
      <patternCode value="unknown" />
    </element>
    <element id="MedicationStatement.medication[x]">
      <path value="MedicationStatement.medication[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
    </element>
    <element id="MedicationStatement.medication[x]:medicationReference">
      <path value="MedicationStatement.medication[x]" />
      <sliceName value="medicationReference" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/MedicationPSAB" />
      </type>
    </element>
    <element id="MedicationStatement.subject">
      <path value="MedicationStatement.subject" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/PatientPSAB" />
      </type>
    </element>
    <element id="MedicationStatement.effective[x]">
      <path value="MedicationStatement.effective[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="MedicationStatement.effective[x]:effectiveDateTime">
      <path value="MedicationStatement.effective[x]" />
      <sliceName value="effectiveDateTime" />
      <comment value="YYYY-MM-DD format. Partial dates (YYYY only or YYYY-MM only) are accepted. Required for each submitted medication" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MedicationStatement.dosage.text">
      <path value="MedicationStatement.dosage.text" />
      <comment value="since the dosage.doseAndrate does not accommodate any text, Amount of medication per dose could be recorded here" />
    </element>
    <element id="MedicationStatement.dosage.route.text">
      <path value="MedicationStatement.dosage.route.text" />
      <comment value="Optional String: Max Character length (20) [May be full text name (e.g., by mouth) or abbreviation (e.g., PO); as well as non-standardized text] &#xA; Include a 'recommended reference set' for common values, and allow other content as well? (i.e., not validated, but promoting/encouraging usage of standard values)" />
    </element>
    <element id="MedicationStatement.dosage.doseAndRate">
      <path value="MedicationStatement.dosage.doseAndRate" />
      <comment value="If the dose is intended to change over time, depending on local rules/regulations, each change should be captured as a new version of the MedicationRequest with an updated dose, or captured with a new MedicationRequest with the new dose." />
    </element>
  </differential>
</StructureDefinition>