{
  "resourceType": "StructureDefinition",
  "url": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle",
  "version": "1.0.2",
  "name": "KBV_PR_ERP_Bundle",
  "status": "active",
  "date": "2021-09-13",
  "publisher": "Kassenärztliche Bundesvereinigung",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "cda",
      "uri": "http://hl7.org/v3/cda",
      "name": "CDA (R2)"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Bundle",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Bundle",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Bundle",
        "path": "Bundle",
        "constraint": [
          {
            "key": "-erp-compositionPflicht",
            "severity": "error",
            "human": "Die Ressource vom Typ Composition muss genau einmal vorhanden sein",
            "expression": "entry.where(resource is Composition).count()=1",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-angabePruefnummer",
            "severity": "error",
            "human": "Prüfnummer nicht vorhanden, aber Pflicht bei den Kostenträger der Typen \"GKV\", \"BG\", \"SKT\" oder \"UK\"",
            "expression": "(entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='GKV' or entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='SKT' or entry.where(resource is Coverage).resource.type.coding.code='UK')) implies entry.where(resource is Composition).resource.author.identifier.where(system='https://fhir.kbv.de/NamingSystem/KBV_NS_FOR_Pruefnummer').exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-angabeZuzahlung",
            "severity": "error",
            "human": "Zuzahlungsstatus nicht vorhanden, aber Pflicht bei den Kostenträgern der Typen \"GKV\", \"BG\", \"SKT\" oder \"UK\"",
            "expression": "(entry.where(resource is MedicationRequest).exists() and entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='GKV' or entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='SKT' or entry.where(resource is Coverage).resource.type.coding.code='UK')) implies entry.where(resource is MedicationRequest).resource.extension('https://fhir.kbv.de/StructureDefinition/KBV_EX_ERP_StatusCoPayment').exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-angabePLZ",
            "severity": "error",
            "human": "Postleitzahl nicht vorhanden, aber Pflicht bei den Kostentraegern der Typen \"GKV\", \"BG\", \"SKT\" oder \"UK\"",
            "expression": "(entry.where(resource is Patient).exists() and entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='GKV' or entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='SKT' or entry.where(resource is Coverage).resource.type.coding.code='UK')) implies entry.where(resource is Patient).resource.address.postalCode.exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-angabeNrAusstellendePerson",
            "severity": "error",
            "human": "Nummer der ausstellenden Person nicht vorhanden, aber Pflicht, wenn es sich um einen Arzt oder Zahnarzt handelt",
            "expression": "(entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='GKV' or entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='SKT' or entry.where(resource is Coverage).resource.type.coding.code='UK') and (entry.where(resource is Practitioner).resource.qualification.coding.code='00' or entry.where(resource is Practitioner).resource.qualification.coding.code='01')) implies entry.where(resource is Practitioner).resource.identifier.exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-angabeBestriebsstaettennr",
            "severity": "error",
            "human": "Betriebsstaettennummer nicht vorhanden, aber Pflicht, wenn es sich um einen Arzt, Zahnarzt oder Arzt in Weiterbildung handelt",
            "expression": "(entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='GKV' or entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='SKT' or entry.where(resource is Coverage).resource.type.coding.code='UK') and (entry.where(resource is Practitioner).resource.qualification.coding.code='00' or entry.where(resource is Practitioner).resource.qualification.coding.code='01' or entry.where(resource is Practitioner).resource.qualification.coding.code='03')) implies entry.where(resource is Organization).resource.identifier.exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-angabeRechtsgrundlage",
            "severity": "error",
            "human": "Rechtsgrundlage nicht vorhanden, aber Pflicht bei den Kostentraegern der Typen \"GKV\", \"BG\", \"SKT\" oder \"UK\"",
            "expression": "(entry.where(resource is MedicationRequest).exists() and entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='GKV' or entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='SKT' or entry.where(resource is Coverage).resource.type.coding.code='UK')) implies entry.where(resource is Composition).resource.extension('https://fhir.kbv.de/StructureDefinition/KBV_EX_FOR_Legal_basis').exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "-erp-versionComposition",
            "severity": "error",
            "human": "Die Instanz der Composition muss vom Profil KBV_PR_ERP_Composition|1.0.2 sein",
            "expression": "entry.where(resource is Composition).resource.meta.profile = 'https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Composition|1.0.2'",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          },
          {
            "key": "IK-Kostentraeger-BG-UK-Pflicht",
            "severity": "error",
            "human": "Zusätzliches IK des Kostenträger nicht vorhanden, aber Pflicht bei Kostenträgern vom Typ \"BG\" oder \"UK\",",
            "expression": "(entry.where(resource is Coverage).exists() and (entry.where(resource is Coverage).resource.type.coding.code='BG' or entry.where(resource is Coverage).resource.type.coding.code='UK')) implies  entry.select(resource as Coverage).payor.identifier.extension('https://fhir.kbv.de/StructureDefinition/KBV_EX_FOR_Alternative_IK').exists()",
            "source": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle"
          }
        ]
      },
      {
        "id": "Bundle.id",
        "path": "Bundle.id",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.meta",
        "path": "Bundle.meta",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.meta.versionId",
        "path": "Bundle.meta.versionId",
        "max": "0"
      },
      {
        "id": "Bundle.meta.lastUpdated",
        "path": "Bundle.meta.lastUpdated",
        "mustSupport": true
      },
      {
        "id": "Bundle.meta.source",
        "path": "Bundle.meta.source",
        "max": "0"
      },
      {
        "id": "Bundle.meta.profile",
        "path": "Bundle.meta.profile",
        "min": 1,
        "max": "1",
        "fixedCanonical": "https://fhir.kbv.de/StructureDefinition/KBV_PR_ERP_Bundle|1.0.2",
        "mustSupport": true
      },
      {
        "id": "Bundle.meta.security",
        "path": "Bundle.meta.security",
        "max": "0"
      },
      {
        "id": "Bundle.meta.tag",
        "path": "Bundle.meta.tag",
        "max": "0"
      },
      {
        "id": "Bundle.implicitRules",
        "path": "Bundle.implicitRules",
        "max": "0"
      },
      {
        "id": "Bundle.language",
        "path": "Bundle.language",
        "max": "0"
      },
      {
        "id": "Bundle.identifier",
        "path": "Bundle.identifier",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.identifier.use",
        "path": "Bundle.identifier.use",
        "max": "0"
      },
      {
        "id": "Bundle.identifier.type",
        "path": "Bundle.identifier.type",
        "max": "0"
      },
      {
        "id": "Bundle.identifier.system",
        "path": "Bundle.identifier.system",
        "definition": "Für den digitalen Vordruck \"Elektronische Arzneimittelverordnung (Vordruck e160)\" wird die Dokumenten-ID gemäß den Vorgaben der gematik gesetzt.",
        "min": 1,
        "fixedUri": "https://gematik.de/fhir/NamingSystem/PrescriptionID",
        "mustSupport": true
      },
      {
        "id": "Bundle.identifier.value",
        "path": "Bundle.identifier.value",
        "short": "Dokumenten-ID",
        "definition": "Eindeutige Identifikation des Dokuments, bzw. der Verordnung. Diese ID wird mit signiert und sichert damit die Verordnung vor Fälschungen.\r\n\r\nFür den digitalen Vordruck \"Elektronische Arzneimittelverordnung (Vordruck e160)\" wird die Dokumenten-ID gemäß den Vorgaben der gematik gesetzt.",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.identifier.period",
        "path": "Bundle.identifier.period",
        "max": "0"
      },
      {
        "id": "Bundle.identifier.assigner",
        "path": "Bundle.identifier.assigner",
        "max": "0"
      },
      {
        "id": "Bundle.type",
        "path": "Bundle.type",
        "fixedCode": "document",
        "mustSupport": true
      },
      {
        "id": "Bundle.timestamp",
        "path": "Bundle.timestamp",
        "definition": "DateTime wann das Dokument technisch erstellt wurde. \r\nFachlich bildet das Ausstellungsdatum das entscheidende Datum ab",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.total",
        "path": "Bundle.total",
        "max": "0"
      },
      {
        "id": "Bundle.link",
        "path": "Bundle.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry",
        "path": "Bundle.entry",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.entry.link",
        "path": "Bundle.entry.link",
        "max": "0"
      },
      {
        "id": "Bundle.entry.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.entry.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Bundle.entry.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry.request",
        "path": "Bundle.entry.request",
        "max": "0"
      },
      {
        "id": "Bundle.entry.response",
        "path": "Bundle.entry.response",
        "max": "0"
      }
    ]
  }
}