<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="Mxx-HealthHub-MedicationStatement" />
  <url value="https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_MedicationStatement" />
  <version value="1.5.0" />
  <name value="Mxx_HealthHub_MedicationStatement" />
  <status value="active" />
  <publisher value="medatixx GmbH &amp; Co. KG" />
  <description value="Medication data from the patient's medication plan as recorded in the PVS. Includes PZN and ATC coding, dosage instructions, and medication status. ATC codes may not be available for all PVS systems (notably x.isynet)." />
  <copyright value="medatixx GmbH &amp; Co. KG" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="MedicationStatement" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/MedicationStatement" />
  <derivation value="constraint" />
  <differential>
    <element id="MedicationStatement">
      <path value="MedicationStatement" />
      <short value="Patient medication data" />
      <definition value="Represents medications from the patient's medication plan (Medikationsplan) as recorded in the practice management system. Includes both active and historical medications with PZN and ATC coding where available." />
    </element>
    <element id="MedicationStatement.identifier">
      <path value="MedicationStatement.identifier" />
      <max value="0" />
    </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="active | completed | stopped" />
      <definition value="The medication intake status. Restricted to the three states the PVS status mapping produces: aktiv -&gt; active, beendet -&gt; completed, abgesetzt -&gt; stopped." />
      <min value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.medatixx.de/HealthHub/ValueSet/Mxx_HealthHub_VS_MedicationStatementStatus" />
      </binding>
    </element>
    <element id="MedicationStatement.statusReason">
      <path value="MedicationStatement.statusReason" />
      <max value="0" />
    </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="Medication as inline code (PZN/ATC) or reference to Mxx_HealthHub_Medication" />
      <definition value="Identifies the medication. A CodeableConcept MAY be used inline when only PZN/ATC codes and the trade name are available. A Reference to a (typically contained) Mxx_HealthHub_Medication SHOULD be used when dosage form, package size, active ingredient or strength are available. The PZN/ATC coding slices and the trade name are defined on Mxx_HealthHub_Medication.code; for the inline CodeableConcept the same systems (http://fhir.de/CodeSystem/ifa/pzn, http://fhir.de/CodeSystem/bfarm/atc) apply by convention." />
      <type>
        <code value="CodeableConcept" />
      </type>
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Medication" />
      </type>
      <constraint>
        <key value="mxx-medstmt-med-1" />
        <severity value="error" />
        <human value="An inline medication (CodeableConcept) must identify the medication with at least a coding or a text." />
        <expression value="$this is Reference or coding.exists() or text.exists()" />
      </constraint>
    </element>
    <element id="MedicationStatement.subject">
      <path value="MedicationStatement.subject" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Patient" />
      </type>
    </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="When the medication is/was taken" />
      <definition value="The period when the medication was prescribed or is being taken. effectivePeriod.start indicates the prescription date (prescribedDate), effectivePeriod.end indicates when the medication was stopped (discontinuedDate, if applicable). Constrained to Period so that the prescription/stop dates map unambiguously and the search result can be sorted by effectivePeriod.start." />
      <type>
        <code value="Period" />
      </type>
    </element>
    <element id="MedicationStatement.dateAsserted">
      <path value="MedicationStatement.dateAsserted" />
      <short value="Not exposed by this profile" />
      <definition value="Not populated: the practice management system provides no documentation/assertion date, only the prescription and discontinuation dates. The search result is therefore sorted by effectivePeriod.start, not dateAsserted." />
      <max value="0" />
    </element>
    <element id="MedicationStatement.informationSource">
      <path value="MedicationStatement.informationSource" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.derivedFrom">
      <path value="MedicationStatement.derivedFrom" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.reasonCode">
      <path value="MedicationStatement.reasonCode" />
      <short value="Indication (ICD-10-GM when available)" />
      <definition value="The clinical reason (indication) for the medication. When structured, coded as ICD-10-GM. Often only available as free text." />
      <max value="1" />
    </element>
    <element id="MedicationStatement.reasonCode.coding">
      <path value="MedicationStatement.reasonCode.coding" />
      <max value="1" />
    </element>
    <element id="MedicationStatement.reasonCode.coding.system">
      <path value="MedicationStatement.reasonCode.coding.system" />
      <fixedUri value="http://fhir.de/CodeSystem/bfarm/icd-10-gm" />
    </element>
    <element id="MedicationStatement.reasonReference">
      <path value="MedicationStatement.reasonReference" />
      <max value="0" />
    </element>
    <element id="MedicationStatement.dosage">
      <path value="MedicationStatement.dosage" />
      <short value="Dosage instructions" />
      <definition value="Dosage instructions for the medication. The text element contains the German dosage notation (e.g., '1-0-1-0' for morning-noon-evening-night). Structured timing and dose may be provided when available." />
    </element>
    <element id="MedicationStatement.dosage.text">
      <path value="MedicationStatement.dosage.text" />
      <short value="German dosage notation (e.g., '1-0-1-0')" />
      <definition value="Free-text dosage instructions, typically in German schema notation: Morning-Noon-Evening-Night (e.g., '1-0-1-0' = 1 tablet morning, none at noon, 1 tablet evening, none at night)." />
    </element>
  </differential>
</StructureDefinition>