{
  "resourceType": "StructureDefinition",
  "url": "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_MedicationRequest",
  "version": "1.5.0",
  "name": "Mxx_HealthHub_MedicationRequest",
  "status": "active",
  "publisher": "medatixx GmbH & Co. KG",
  "copyright": "medatixx GmbH & Co. KG",
  "description": "Profile for a medication proposal. Allows either a free-text proposal (medicationCodeableConcept.text) or a PZN-coded proposal via a contained Medication (medicationReference -> Mxx_HealthHub_Medication). When medicationReference is used, the contained Medication must contain at least one PZN coding.",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "MedicationRequest",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/MedicationRequest",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "MedicationRequest",
        "path": "MedicationRequest",
        "constraint": [
          {
            "key": "mr-pzn-required-if-ref",
            "severity": "error",
            "human": "Wenn medicationReference verwendet wird, muss die contained Medication mindestens einen PZN-Coding-Eintrag (system 'http://fhir.de/CodeSystem/ifa/pzn') enthalten.",
            "expression": "(medicationReference.exists() implies contained.ofType(Medication).code.coding.where(system='http://fhir.de/CodeSystem/ifa/pzn').exists())"
          }
        ]
      },
      {
        "id": "MedicationRequest.contained",
        "path": "MedicationRequest.contained",
        "short": "Contained Medication (nur PZN-Pfad)",
        "definition": "Im PZN-Pfad genau eine contained Mxx_HealthHub_Medication, auf die medicationReference.reference per lokaler Fragment-Referenz (#id) zeigt. Im Freitext-Pfad bleibt contained leer.",
        "max": "1"
      },
      {
        "id": "MedicationRequest.identifier",
        "path": "MedicationRequest.identifier",
        "max": "0"
      },
      {
        "id": "MedicationRequest.status",
        "path": "MedicationRequest.status",
        "fixedCode": "active"
      },
      {
        "id": "MedicationRequest.statusReason",
        "path": "MedicationRequest.statusReason",
        "max": "0"
      },
      {
        "id": "MedicationRequest.intent",
        "path": "MedicationRequest.intent",
        "fixedCode": "proposal"
      },
      {
        "id": "MedicationRequest.category",
        "path": "MedicationRequest.category",
        "max": "0"
      },
      {
        "id": "MedicationRequest.priority",
        "path": "MedicationRequest.priority",
        "max": "0"
      },
      {
        "id": "MedicationRequest.doNotPerform",
        "path": "MedicationRequest.doNotPerform",
        "max": "0"
      },
      {
        "id": "MedicationRequest.reported[x]",
        "path": "MedicationRequest.reported[x]",
        "max": "0"
      },
      {
        "id": "MedicationRequest.medication[x]",
        "path": "MedicationRequest.medication[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "rules": "closed"
        },
        "type": [
          {
            "code": "CodeableConcept"
          },
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Medication"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.medication[x]:medicationCodeableConcept",
        "path": "MedicationRequest.medication[x]",
        "sliceName": "medicationCodeableConcept",
        "short": "Freitext-Vorschlag (ohne PZN)",
        "type": [
          {
            "code": "CodeableConcept"
          }
        ]
      },
      {
        "id": "MedicationRequest.medication[x]:medicationCodeableConcept.coding",
        "path": "MedicationRequest.medication[x].coding",
        "max": "0"
      },
      {
        "id": "MedicationRequest.medication[x]:medicationCodeableConcept.text",
        "path": "MedicationRequest.medication[x].text",
        "min": 1
      },
      {
        "id": "MedicationRequest.medication[x]:medicationReference",
        "path": "MedicationRequest.medication[x]",
        "sliceName": "medicationReference",
        "short": "PZN-codierter Vorschlag (contained Medication)",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Medication"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.subject",
        "path": "MedicationRequest.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_Patient"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.subject.type",
        "path": "MedicationRequest.subject.type",
        "max": "0"
      },
      {
        "id": "MedicationRequest.subject.identifier",
        "path": "MedicationRequest.subject.identifier",
        "short": "An identifier intended for computation",
        "definition": "An identifier - identifies some entity uniquely and unambiguously. Typically this is used for business identifiers.",
        "type": [
          {
            "code": "Identifier",
            "profile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_IntermediatePatientIdentifier"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.subject.display",
        "path": "MedicationRequest.subject.display",
        "max": "0"
      },
      {
        "id": "MedicationRequest.encounter",
        "path": "MedicationRequest.encounter",
        "max": "0"
      },
      {
        "id": "MedicationRequest.supportingInformation",
        "path": "MedicationRequest.supportingInformation",
        "max": "0"
      },
      {
        "id": "MedicationRequest.authoredOn",
        "path": "MedicationRequest.authoredOn",
        "max": "0"
      },
      {
        "id": "MedicationRequest.requester",
        "path": "MedicationRequest.requester",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.medatixx.de/HealthHub/StructureDefinition/Mxx_HealthHub_PartnerSystem"
            ]
          }
        ]
      },
      {
        "id": "MedicationRequest.requester.type",
        "path": "MedicationRequest.requester.type",
        "max": "0"
      },
      {
        "id": "MedicationRequest.requester.identifier",
        "path": "MedicationRequest.requester.identifier",
        "max": "0"
      },
      {
        "id": "MedicationRequest.requester.display",
        "path": "MedicationRequest.requester.display",
        "max": "0"
      },
      {
        "id": "MedicationRequest.performer",
        "path": "MedicationRequest.performer",
        "max": "0"
      },
      {
        "id": "MedicationRequest.performerType",
        "path": "MedicationRequest.performerType",
        "max": "0"
      },
      {
        "id": "MedicationRequest.recorder",
        "path": "MedicationRequest.recorder",
        "max": "0"
      },
      {
        "id": "MedicationRequest.reasonCode",
        "path": "MedicationRequest.reasonCode",
        "max": "1"
      },
      {
        "id": "MedicationRequest.reasonCode.coding",
        "path": "MedicationRequest.reasonCode.coding",
        "max": "0"
      },
      {
        "id": "MedicationRequest.reasonCode.text",
        "path": "MedicationRequest.reasonCode.text",
        "min": 1
      },
      {
        "id": "MedicationRequest.reasonReference",
        "path": "MedicationRequest.reasonReference",
        "max": "0"
      },
      {
        "id": "MedicationRequest.instantiatesCanonical",
        "path": "MedicationRequest.instantiatesCanonical",
        "max": "0"
      },
      {
        "id": "MedicationRequest.instantiatesUri",
        "path": "MedicationRequest.instantiatesUri",
        "max": "0"
      },
      {
        "id": "MedicationRequest.basedOn",
        "path": "MedicationRequest.basedOn",
        "max": "0"
      },
      {
        "id": "MedicationRequest.groupIdentifier",
        "path": "MedicationRequest.groupIdentifier",
        "short": "Fachliche Rezeptzugehörigkeit (optional)",
        "definition": "Fachliche Rezeptzugehörigkeit (optional). Möchte eine Partnersoftware mehrere Rezepte zu einem Patienten anfordern, so können diese über einen groupIdentifier zusammengefasst werden. Die Praxissoftware KANN die Rezeptanforderungen dann gruppiert anzeigen. Der Wert (groupIdentifier.value) ist eine UUID (z.B. system urn:ietf:rfc:3986 mit Wert urn:uuid:...); nicht konforme Werte werden abgelehnt."
      },
      {
        "id": "MedicationRequest.courseOfTherapyType",
        "path": "MedicationRequest.courseOfTherapyType",
        "max": "0"
      },
      {
        "id": "MedicationRequest.insurance",
        "path": "MedicationRequest.insurance",
        "max": "0"
      },
      {
        "id": "MedicationRequest.note",
        "path": "MedicationRequest.note",
        "max": "1"
      },
      {
        "id": "MedicationRequest.note.author[x]",
        "path": "MedicationRequest.note.author[x]",
        "max": "0"
      },
      {
        "id": "MedicationRequest.note.time",
        "path": "MedicationRequest.note.time",
        "max": "0"
      },
      {
        "id": "MedicationRequest.dosageInstruction",
        "path": "MedicationRequest.dosageInstruction",
        "max": "0"
      },
      {
        "id": "MedicationRequest.dispenseRequest",
        "path": "MedicationRequest.dispenseRequest",
        "max": "0"
      },
      {
        "id": "MedicationRequest.substitution",
        "path": "MedicationRequest.substitution",
        "max": "0"
      },
      {
        "id": "MedicationRequest.priorPrescription",
        "path": "MedicationRequest.priorPrescription",
        "max": "0"
      },
      {
        "id": "MedicationRequest.detectedIssue",
        "path": "MedicationRequest.detectedIssue",
        "max": "0"
      },
      {
        "id": "MedicationRequest.eventHistory",
        "path": "MedicationRequest.eventHistory",
        "max": "0"
      }
    ]
  }
}