{
  "resourceType": "StructureDefinition",
  "id": "Mxx-HealthHub-MedicationStatement",
  "url": "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_MedicationStatement",
  "version": "1.5.0",
  "name": "Mxx_HealthHub_MedicationStatement",
  "status": "active",
  "publisher": "medatixx GmbH & Co. KG",
  "copyright": "medatixx GmbH & Co. KG",
  "description": "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).",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "MedicationStatement",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/MedicationStatement",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "MedicationStatement",
        "path": "MedicationStatement",
        "short": "Patient medication data",
        "definition": "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."
      },
      {
        "id": "MedicationStatement.identifier",
        "path": "MedicationStatement.identifier",
        "max": "0"
      },
      {
        "id": "MedicationStatement.basedOn",
        "path": "MedicationStatement.basedOn",
        "max": "0"
      },
      {
        "id": "MedicationStatement.partOf",
        "path": "MedicationStatement.partOf",
        "max": "0"
      },
      {
        "id": "MedicationStatement.status",
        "path": "MedicationStatement.status",
        "short": "active | completed | stopped",
        "definition": "The medication intake status. Restricted to the three states the PVS status mapping produces: aktiv -> active, beendet -> completed, abgesetzt -> stopped.",
        "min": 1,
        "binding": {
          "strength": "required",
          "valueSet": "https://fhir.medatixx.de/HealthHub/ValueSet/Mxx_HealthHub_VS_MedicationStatementStatus"
        }
      },
      {
        "id": "MedicationStatement.statusReason",
        "path": "MedicationStatement.statusReason",
        "max": "0"
      },
      {
        "id": "MedicationStatement.category",
        "path": "MedicationStatement.category",
        "max": "0"
      },
      {
        "id": "MedicationStatement.medication[x]",
        "path": "MedicationStatement.medication[x]",
        "short": "Medication as inline code (PZN/ATC) or reference to Mxx_HealthHub_Medication",
        "definition": "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.",
        "constraint": [
          {
            "key": "mxx-medstmt-med-1",
            "severity": "error",
            "human": "An inline medication (CodeableConcept) must identify the medication with at least a coding or a text.",
            "expression": "$this is Reference or coding.exists() or text.exists()"
          }
        ],
        "type": [
          {
            "code": "CodeableConcept"
          },
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Medication"
            ]
          }
        ]
      },
      {
        "id": "MedicationStatement.subject",
        "path": "MedicationStatement.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Patient"
            ]
          }
        ]
      },
      {
        "id": "MedicationStatement.context",
        "path": "MedicationStatement.context",
        "max": "0"
      },
      {
        "id": "MedicationStatement.effective[x]",
        "path": "MedicationStatement.effective[x]",
        "short": "When the medication is/was taken",
        "definition": "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": "Period"
          }
        ]
      },
      {
        "id": "MedicationStatement.dateAsserted",
        "path": "MedicationStatement.dateAsserted",
        "short": "Not exposed by this profile",
        "definition": "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": "0"
      },
      {
        "id": "MedicationStatement.informationSource",
        "path": "MedicationStatement.informationSource",
        "max": "0"
      },
      {
        "id": "MedicationStatement.derivedFrom",
        "path": "MedicationStatement.derivedFrom",
        "max": "0"
      },
      {
        "id": "MedicationStatement.reasonCode",
        "path": "MedicationStatement.reasonCode",
        "short": "Indication (ICD-10-GM when available)",
        "definition": "The clinical reason (indication) for the medication. When structured, coded as ICD-10-GM. Often only available as free text.",
        "max": "1"
      },
      {
        "id": "MedicationStatement.reasonCode.coding",
        "path": "MedicationStatement.reasonCode.coding",
        "max": "1"
      },
      {
        "id": "MedicationStatement.reasonCode.coding.system",
        "path": "MedicationStatement.reasonCode.coding.system",
        "fixedUri": "http://fhir.de/CodeSystem/bfarm/icd-10-gm"
      },
      {
        "id": "MedicationStatement.reasonReference",
        "path": "MedicationStatement.reasonReference",
        "max": "0"
      },
      {
        "id": "MedicationStatement.dosage",
        "path": "MedicationStatement.dosage",
        "short": "Dosage instructions",
        "definition": "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."
      },
      {
        "id": "MedicationStatement.dosage.text",
        "path": "MedicationStatement.dosage.text",
        "short": "German dosage notation (e.g., '1-0-1-0')",
        "definition": "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)."
      }
    ]
  }
}