<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="MedicationStatementPSAB" />
  <url value="https://www.alberta.ca/fhir/psab/StructureDefinition/MedicationStatementPSAB" />
  <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 SHALL NOT contain any of the following MedicationStatement details: statusReason,  context, dateAsserted, informationSource, derivedFrom, reasonReference, dosage.site, dosage.method, dosage.doseAndRate.type,dosage. doseAndRate.rate[x], dosage.maxDosePerPeriod, dosage.maxDosePerAdministration, dosage.maxDosePerLifetime. These rules 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]:medicationReference">
      <path value="MedicationStatement.medication[x]" />
      <sliceName value="medicationReference" />
      <sliceIsConstraining value="true" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/MedicationPSAB" />
      </type>
    </element>
    <element id="MedicationStatement.medication[x]:medicationCodeableConcept">
      <path value="MedicationStatement.medication[x]" />
      <sliceName value="medicationCodeableConcept" />
      <sliceIsConstraining value="true" />
      <comment value="Supply of medicationReference is preferred over medicationCodeableConcept, however both are allowed in the context of Alberta Patient Summaries" />
      <type>
        <code value="CodeableConcept" />
        <profile value="http://fhir.infoway-inforoute.ca/io/psca/StructureDefinition/CodeableConcept-ca-ps" />
      </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>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
    </element>
    <element id="MedicationStatement.effective[x]:effectiveDateTime">
      <path value="MedicationStatement.effective[x]" />
      <sliceName value="effectiveDateTime" />
      <sliceIsConstraining value="true" />
      <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>