<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="fiphr-sd-medicationstatement-r4" />
  <url value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-medicationstatement-r4" />
  <version value="0.2" />
  <name value="FIPHRSDMedicationStatementR4" />
  <title value="Finnish PHR Medication Statement Profile" />
  <status value="draft" />
  <experimental value="true" />
  <date value="2020-02-04" />
  <description value="Finnish PHR profile for MedicationStatement Resource. Record of medication being taken by a patient." />
  <purpose value="Finnish PHR profile for MedicationStatement Resource. Record of medication being taken by a patient." />
  <fhirVersion value="4.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="MedicationStatement" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/MedicationStatement" />
  <derivation value="constraint" />
  <snapshot />
  <differential>
    <element id="MedicationStatement">
      <path value="MedicationStatement" />
      <short value="Finnish PHR Medication Statement profile" />
      <definition value="Finnish PHR profile for MedicationStatement Resource. Record of medication being taken by a patient." />
      <comment value="." />
    </element>
    <element id="MedicationStatement.meta.profile">
      <path value="MedicationStatement.meta.profile" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="$this" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="MedicationStatement.meta.profile:fiphrProfile">
      <path value="MedicationStatement.meta.profile" />
      <sliceName value="fiphrProfile" />
      <min value="1" />
      <max value="1" />
      <fixedCanonical value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-medicationstatement-r4" />
    </element>
    <element id="MedicationStatement.language">
      <path value="MedicationStatement.language" />
      <definition value="The base language in which the resource is written. FinnishPHR: codes from the code system urn:ietf:bcp:47" />
      <min value="1" />
      <binding>
        <strength value="required" />
        <description value="A code of human language." />
      </binding>
    </element>
    <element id="MedicationStatement.text">
      <path value="MedicationStatement.text" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.extension">
      <path value="MedicationStatement.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="MedicationStatement.extension:creatingApplication">
      <path value="MedicationStatement.extension" />
      <sliceName value="creatingApplication" />
      <type>
        <code value="Extension" />
        <profile value="http://phr.kanta.fi/StructureDefinition/fiphr-ext-creatingapplication" />
      </type>
    </element>
    <element id="MedicationStatement.identifier">
      <path value="MedicationStatement.identifier" />
      <definition value="A unique identifier assigned to this observation. &#xD;&#xA;Finnish PHR: At least one of the identifiers SHALL be globally unique (e.g. an uuid as the value and 'urn:ietf:rfc:3986' as the system)." />
      <min value="1" />
    </element>
    <element id="MedicationStatement.identifier.use">
      <path value="MedicationStatement.identifier.use" />
      <definition value="The purpose of this identifier. &#xD;&#xA;Finnish PHR: The code 'official' SHALL be only used if the given identifier value is truly globally unique (e.g. an uuid as the value and 'urn:ietf:rfc:3986' as the system)." />
    </element>
    <element id="MedicationStatement.identifier.system">
      <path value="MedicationStatement.identifier.system" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.identifier.value">
      <path value="MedicationStatement.identifier.value" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.basedOn">
      <path value="MedicationStatement.basedOn" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.partOf">
      <path value="MedicationStatement.partOf" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.status">
      <path value="MedicationStatement.status" />
      <short value="FinnishPHR: A code representing the patient or other source's judgment about the state of the medication used that this statement is about" />
      <definition value="FinnishPHR: A code representing the patient or other source's judgment about the state of the medication used that this statement is about." />
      <comment value="FinnishPHR: Either &quot;active&quot;, &quot;intended&quot; or &quot;not-taken&quot;" />
      <requirements value="FinnishPHR: only &quot;active&quot; , &quot;intended&quot; or &quot;not-taken&quot; SHALL be used in Finnish PHR" />
    </element>
    <element id="MedicationStatement.statusReason">
      <path value="MedicationStatement.statusReason" />
      <short value="Reason why medication was not given" />
      <definition value="A code or text indicating why the medication was not taken." />
      <comment value="FinnishPHR: StatusReason is used only with satus &quot;not-taken&quot;. Code preferred." />
      <max value="1" />
    </element>
    <element id="MedicationStatement.statusReason.coding">
      <path value="MedicationStatement.statusReason.coding" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <definition value="FinnishPHR: fiphrStatusReason SHALL be used. Other reason codes MAY be used. &#xD;&#xA;A reference to a code defined by a terminology system." />
    </element>
    <element id="MedicationStatement.statusReason.coding:fiphrStatusReason">
      <path value="MedicationStatement.statusReason.coding" />
      <sliceName value="fiphrStatusReason" />
      <min value="1" />
      <max value="1" />
      <binding>
        <strength value="required" />
        <description value="A coded concept indicating the reason for the status of the statement." />
        <valueSet value="http://phr.kanta.fi/ValueSet/fiphr-vs-reasonnottaken" />
      </binding>
    </element>
    <element id="MedicationStatement.statusReason.coding:fiphrStatusReason.system">
      <path value="MedicationStatement.statusReason.coding.system" />
      <min value="1" />
      <fixedUri value="urn:oid:1.2.246.537.6.600" />
    </element>
    <element id="MedicationStatement.statusReason.coding:fiphrStatusReason.code">
      <path value="MedicationStatement.statusReason.coding.code" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.statusReason.coding:fiphrStatusReason.display">
      <path value="MedicationStatement.statusReason.coding.display" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.category">
      <path value="MedicationStatement.category" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.medication[x]">
      <path value="MedicationStatement.medication[x]" />
      <short value="Finnish PHR: What medication was taken" />
      <definition value="FinnishPHR: Identifies the medication being taken. Code and name of the medication." />
      <comment value="Finnish PHR: There are two options for using this field. Option 1: when the medication can be uniquely identified, SHALL be given the VNR code of the medication and the brand name of the medication which SHALL matct match the name in the pharmaceutical database, Option 2: when the medication can not be uniquely identified SHALL be given a text field, entered in medicationCodeableConcept.text." />
      <type>
        <code value="CodeableConcept" />
      </type>
    </element>
    <element id="MedicationStatement.medication[x].coding">
      <path value="MedicationStatement.medication[x].coding" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <short value="Finnish PHR: VNR coded medication" />
      <definition value="Finnish PHR: VNR coded medication. FiphrMedication SHALL be used. Other medication codes MAY be used." />
      <comment value="Finnish PHR: There are two options for using this field. Option 1: when the medication can be uniquely identified, SHALL be given the VNR code of the medication and the brand name of the medication which SHALL matct match the name in the pharmaceutical database, Option 2: when the medication can not be uniquely identified SHALL be given a text field, entered in medicationCodeableConcept.text." />
      <min value="1" />
    </element>
    <element id="MedicationStatement.medication[x].coding:fiphrMedication">
      <path value="MedicationStatement.medication[x].coding" />
      <sliceName value="fiphrMedication" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="MedicationStatement.medication[x].coding:fiphrMedication.system">
      <path value="MedicationStatement.medication[x].coding.system" />
      <short value="Finnish PHR: VNR code system" />
      <definition value="Finnish PHR: VNR code system" />
      <min value="1" />
      <fixedUri value="urn:oid:1.2.246.537.6.55" />
    </element>
    <element id="MedicationStatement.medication[x].coding:fiphrMedication.code">
      <path value="MedicationStatement.medication[x].coding.code" />
      <short value="Finnish PHR: VNR code defined by VNR code system" />
      <definition value="Finnish PHR: VNR code defined by VNR code system" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.medication[x].coding:fiphrMedication.display">
      <path value="MedicationStatement.medication[x].coding.display" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.medication[x].text">
      <path value="MedicationStatement.medication[x].text" />
      <short value="Finnish PHR: Name of the medication" />
      <definition value="Finnish PHR: Name of the medication" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.subject">
      <path value="MedicationStatement.subject" />
      <short value="FinnishPHR: The person who is/was taking the medication." />
      <definition value="FinnishPHR: The person who is/was taking the medication." />
      <comment value="FinnishPHR: Who this information is about. Usually the same person as the application user, but if the user is storing information on behalf of someone else, the reference to the actual person who is taking the medication." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-patient" />
        <aggregation value="referenced" />
      </type>
    </element>
    <element id="MedicationStatement.subject.reference">
      <path value="MedicationStatement.subject.reference" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.context">
      <path value="MedicationStatement.context" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.effective[x]">
      <path value="MedicationStatement.effective[x]" />
      <short value="The date/time period when the medication was taken" />
      <comment value="This attribute reflects the period over which the patient consumed the medication and is expected to be populated on the Medication Statements. If the medication is still being taken at the time the statement is recorded, the &quot;end&quot; date will be omitted." />
      <min value="1" />
    </element>
    <element id="MedicationStatement.dateAsserted">
      <path value="MedicationStatement.dateAsserted" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.informationSource">
      <path value="MedicationStatement.informationSource" />
      <definition value="The person who provided the information about the taking of this medication." />
      <comment value="Usually the same person as the application user." />
      <type>
        <code value="Reference" />
        <targetProfile value="http://phr.kanta.fi/StructureDefinition/fiphr-sd-patient" />
        <aggregation value="referenced" />
      </type>
    </element>
    <element id="MedicationStatement.informationSource.reference">
      <path value="MedicationStatement.informationSource.reference" />
      <min value="1" />
    </element>
    <element id="MedicationStatement.derivedFrom">
      <path value="MedicationStatement.derivedFrom" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.reasonCode">
      <path value="MedicationStatement.reasonCode" />
      <definition value="FinnishPHR: If there is need to give details of the reason why medication is being/was taken, the details MAY be given in the MedicationStatement.reasonCode.text in text format (ie. stored in text element of codeableConcept). MedicationStatement.reasonCode.coding SHALL NOT be used." />
      <comment value="FinnishPHR: If there is need to give details of the reason why medication is being/was taken, the details MAY be given in the MedicationStatement.reasonCode.text in text format (ie. stored in text element of codeableConcept). MedicationStatement.reasonCode.coding SHALL NOT be used." />
    </element>
    <element id="MedicationStatement.reasonReference">
      <path value="MedicationStatement.reasonReference" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.note">
      <path value="MedicationStatement.note" />
      <definition value="Extra information about the medication statement that is not conveyed by the other attributes." />
    </element>
    <element id="MedicationStatement.dosage.additionalInstruction">
      <path value="MedicationStatement.dosage.additionalInstruction" />
      <comment value="Finnis PHR: use text element." />
    </element>
    <element id="MedicationStatement.dosage.additionalInstruction.coding">
      <path value="MedicationStatement.dosage.additionalInstruction.coding" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.dosage.doseAndRate">
      <path value="MedicationStatement.dosage.doseAndRate" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="MedicationStatement.dosage.doseAndRate.dose[x]">
      <path value="MedicationStatement.dosage.doseAndRate.dose[x]" />
      <min value="1" />
    </element>
  </differential>
</StructureDefinition>