<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="KBV-PR-EAU-Bundle" />
  <url value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
  <version value="1.1.0_cc" />
  <name value="KBV_PR_EAU_Bundle" />
  <status value="draft" />
  <experimental value="false" />
  <date value="2022-05-13" />
  <publisher value="Kassenärztliche Bundesvereinigung" />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="v2" />
    <uri value="http://hl7.org/v2" />
    <name value="HL7 v2 Mapping" />
  </mapping>
  <mapping>
    <identity value="rim" />
    <uri value="http://hl7.org/v3" />
    <name value="RIM Mapping" />
  </mapping>
  <mapping>
    <identity value="cda" />
    <uri value="http://hl7.org/v3/cda" />
    <name value="CDA (R2)" />
  </mapping>
  <mapping>
    <identity value="w5" />
    <uri value="http://hl7.org/fhir/fivews" />
    <name value="FiveWs Pattern Mapping" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Bundle" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Bundle" />
  <derivation value="constraint" />
  <differential>
    <element id="Bundle">
      <path value="Bundle" />
      <constraint>
        <key value="Composition-pflicht" />
        <severity value="error" />
        <human value="Die Ressource vom Typ Composition muss genau einmal vorhanden sein" />
        <expression value="entry.where(resource is Composition).count()=1" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="Composition-Pruefnummer" />
        <severity value="error" />
        <human value="Die Prüfnummer ist nicht vorhanden, ist aber bei den Kostentraegern vom Typ &quot;GKV&quot;, &quot;BG&quot;, &quot;SKT&quot; oder &quot;UK&quot; ein Pflichtelement." />
        <expression value="( 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 value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="PostalCode" />
        <severity value="error" />
        <human value="Die Postleitzahl ist nicht vorhanden, sie ist aber bei den Kostentraegern vom Typ &quot;GKV&quot;, &quot;BG&quot;, &quot;SKT&quot;, &quot;PKV&quot; oder &quot;UK&quot; ein Pflichtelement." />
        <expression value="(        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' or         entry.where(resource is Coverage).resource.type.coding.code='PKV') implies                 entry.where(resource is Patient).resource.address.postalCode.exists()" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="Rechtsgrundlage-Pflicht" />
        <severity value="error" />
        <human value="Die Rechtsgrundlage ist nicht vorhanden, sie ist aber bei den Kostentraegern vom Typ &quot;GKV&quot;, &quot;BG&quot;, &quot;SKT&quot;, &quot;PKV&quot; oder &quot;UK&quot; ein Pflichtelement." />
        <expression value="(       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' or        entry.where(resource is Coverage).resource.type.coding.code='PKV') implies        entry.where(resource is Composition).resource.extension('https://fhir.kbv.de/StructureDefinition/KBV_EX_FOR_Legal_basis').exists()" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="unique-ServiceRequest" />
        <severity value="error" />
        <human value="Die Einträge für die Instanz ServiceRequest müssen im Dokument eindeutig sein." />
        <expression value="entry.select(resource as ServiceRequest).code.coding.code.isDistinct()" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="TypeComposition" />
        <severity value="error" />
        <human value="Die Instanz der Composition muss vom Profil KBV_PR_EAU_Composition|1.0.3 sein" />
        <expression value="entry.where(resource is Composition).resource.meta.profile = 'https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Composition|1.1.0_cc'" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="angabeNrAusstellendePerson" />
        <severity value="error" />
        <human value="Nummer der ausstellenden Person ist nicht vorhanden, aber Pflicht, wenn es sich um einen Arzt oder Zahnarzt handelt" />
        <expression value="(          (         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' or          entry.where(resource is Coverage).resource.type.coding.code='PKV') and (          entry.where(resource is Practitioner).resource.qualification.code.coding.code='00' or           entry.where(resource is Practitioner).resource.qualification.code.coding.code='01' or           entry.where(resource is Practitioner).resource.qualification.code.coding.code='04')        ) implies entry.where(resource is Practitioner).resource.identifier.exists()" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="angabeBestriebsstaettennr" />
        <severity value="error" />
        <human value="Betriebsstaettennummer nicht vorhanden, aber Pflicht, wenn es sich um einen Arzt, Zahnarzt oder Arzt in Weiterbildung handelt" />
        <expression value="(        (         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.code.coding.code='00' or           entry.where(resource is Practitioner).resource.qualification.code.coding.code='01' or           entry.where(resource is Practitioner).resource.qualification.code.coding.code='03' or           entry.where(resource is Practitioner).resource.qualification.code.coding.code='04')                  ) implies         entry.where(resource is Organization).resource.identifier.exists()" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="angabeAUseitErstbescheinigung" />
        <severity value="error" />
        <human value="Die Angabe arbeitsunfaehig seit ist nicht gesetzt, muss aber bei einer Erstbescheinigung gesetzt werden." />
        <expression value="(         entry.where(resource is Composition).resource.type.coding.where(system = 'https://fhir.kbv.de/CodeSystem/KBV_CS_EAU_AU_Type').code = 'ERST'          or         entry.where(resource is Composition).resource.type.coding.where(system = 'https://fhir.kbv.de/CodeSystem/KBV_CS_EAU_AU_Type').code = 'ERST_END'         )implies(         entry.select(resource as Condition).where(meta.profile = 'https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Condition_AU|1.1.0_cc').onsetPeriod.start.exists()        )" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="angabeAUseitFolgebescheinigung" />
        <severity value="error" />
        <human value="Die Angabe arbeitsunfaehig seit darf  bei einer Folgebescheinigung nicht gesetzt werden." />
        <expression value="(entry.where(resource is Composition).resource.type.coding.where(system = 'https://fhir.kbv.de/CodeSystem/KBV_CS_EAU_AU_Type').code = 'FOLGE' or entry.where(resource is Composition).resource.type.coding.where(system = 'https://fhir.kbv.de/CodeSystem/KBV_CS_EAU_AU_Type').code = 'FOLGE_END')implies(entry.select(resource as Condition).where(meta.profile = 'https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Condition_AU|1.1.0_cc').onsetPeriod.start.empty())" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="PflichtVersichertenIDbeiGKV" />
        <severity value="error" />
        <human value="Wenn der Kostentraeger GKV ist und eine Versichertennummer uebertragen wird, dann muss die Versichertennummer von der GKV sein." />
        <expression value="entry.where(resource is Coverage).resource.type.coding.code='GKV' and entry.where(resource is Patient).resource.identifier.exists() implies entry.where(resource is Patient).resource.identifier.type.coding.code='GKV'" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="PflichtVersichertenIDbeiPKV" />
        <severity value="error" />
        <human value="Wenn der Kostentraeger PKV ist und eine Versichertennummer uebertragen wird, dann muss die Versichertennummer von der PKV sein." />
        <expression value="entry.where(resource is Coverage).resource.type.coding.code='PKV' and entry.where(resource is Patient).resource.identifier.exists() implies entry.where(resource is Patient).resource.identifier.type.coding.code='PKV'" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
      <constraint>
        <key value="PflichtVersichertenIDbeiKVK" />
        <severity value="error" />
        <human value="Wenn der Kostentraeger SKT ist und eine Versichertennummer uebertragen wird, dann muss die Versichertennummer von der SKT sein." />
        <expression value="entry.where(resource is Coverage).resource.type.coding.code='SKT' and entry.where(resource is Patient).resource.identifier.exists() implies entry.where(resource is Patient).resource.identifier.type.coding.code='kvk'" />
        <source value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle" />
      </constraint>
    </element>
    <element id="Bundle.id">
      <path value="Bundle.id" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.meta">
      <path value="Bundle.meta" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.meta.versionId">
      <path value="Bundle.meta.versionId" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.lastUpdated">
      <path value="Bundle.meta.lastUpdated" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.meta.source">
      <path value="Bundle.meta.source" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.profile">
      <path value="Bundle.meta.profile" />
      <min value="1" />
      <max value="1" />
      <fixedCanonical value="https://fhir.kbv.de/StructureDefinition/KBV_PR_EAU_Bundle|1.1.0_cc" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.meta.security">
      <path value="Bundle.meta.security" />
      <max value="0" />
    </element>
    <element id="Bundle.meta.tag">
      <path value="Bundle.meta.tag" />
      <max value="0" />
    </element>
    <element id="Bundle.implicitRules">
      <path value="Bundle.implicitRules" />
      <max value="0" />
    </element>
    <element id="Bundle.language">
      <path value="Bundle.language" />
      <max value="0" />
    </element>
    <element id="Bundle.identifier">
      <path value="Bundle.identifier" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.identifier.use">
      <path value="Bundle.identifier.use" />
      <max value="0" />
    </element>
    <element id="Bundle.identifier.type">
      <path value="Bundle.identifier.type" />
      <max value="0" />
    </element>
    <element id="Bundle.identifier.system">
      <path value="Bundle.identifier.system" />
      <definition value="Festlegung damit eine UUID kommt" />
      <min value="1" />
      <fixedUri value="urn:ietf:rfc:3986" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.identifier.value">
      <path value="Bundle.identifier.value" />
      <definition value="Eindeutige UUID" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.identifier.period">
      <path value="Bundle.identifier.period" />
      <max value="0" />
    </element>
    <element id="Bundle.identifier.assigner">
      <path value="Bundle.identifier.assigner" />
      <max value="0" />
    </element>
    <element id="Bundle.type">
      <path value="Bundle.type" />
      <fixedCode value="document" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.timestamp">
      <path value="Bundle.timestamp" />
      <definition value="DateTime wann das Dokument technisch erstellt wurde. &#xD;&#xA;Fachlich bildet das Ausstellungsdatum das entscheidende Datum ab" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.total">
      <path value="Bundle.total" />
      <max value="0" />
    </element>
    <element id="Bundle.link">
      <path value="Bundle.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry">
      <path value="Bundle.entry" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry.link">
      <path value="Bundle.entry.link" />
      <max value="0" />
    </element>
    <element id="Bundle.entry.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry.request">
      <path value="Bundle.entry.request" />
      <max value="0" />
    </element>
    <element id="Bundle.entry.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.signature">
      <path value="Bundle.signature" />
      <max value="0" />
    </element>
    <element id="Bundle.signature.who.reference">
      <path value="Bundle.signature.who.reference" />
      <min value="1" />
    </element>
    <element id="Bundle.signature.who.type">
      <path value="Bundle.signature.who.type" />
      <max value="0" />
    </element>
    <element id="Bundle.signature.who.identifier">
      <path value="Bundle.signature.who.identifier" />
      <max value="0" />
    </element>
    <element id="Bundle.signature.who.display">
      <path value="Bundle.signature.who.display" />
      <max value="0" />
    </element>
  </differential>
</StructureDefinition>