<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="http://fhirtestbg.de/test/StructureDefinition/BGPatient" />
  <name value="BGPatient" />
  <status value="draft" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Patient" />
  <derivation value="constraint" />
  <differential>
    <element id="Patient.identifier">
      <path value="Patient.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
      <max value="2" />
    </element>
    <element id="Patient.identifier:PID">
      <path value="Patient.identifier" />
      <sliceName value="PID" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Patient.identifier:PID.system">
      <path value="Patient.identifier.system" />
      <min value="1" />
      <fixedUri value="http://bg.de/fhir/pid" />
    </element>
    <element id="Patient.identifier:PID.value">
      <path value="Patient.identifier.value" />
      <min value="1" />
    </element>
    <element id="Patient.identifier:GKVID">
      <path value="Patient.identifier" />
      <sliceName value="GKVID" />
      <max value="1" />
      <type>
        <code value="Identifier" />
        <profile value="http://fhir.de/StructureDefinition/identifier-kvid-10" />
      </type>
    </element>
    <element id="Patient.identifier:PKVID">
      <path value="Patient.identifier" />
      <sliceName value="PKVID" />
      <max value="1" />
      <type>
        <code value="Identifier" />
        <profile value="http://fhir.de/StructureDefinition/identifier-pkv-kvid-10" />
      </type>
    </element>
    <element id="Patient.name">
      <path value="Patient.name" />
      <min value="1" />
    </element>
    <element id="Patient.name.family">
      <path value="Patient.name.family" />
      <min value="1" />
    </element>
    <element id="Patient.name.given">
      <path value="Patient.name.given" />
      <min value="1" />
    </element>
    <element id="Patient.gender">
      <path value="Patient.gender" />
      <min value="1" />
    </element>
    <element id="Patient.birthDate">
      <path value="Patient.birthDate" />
      <min value="1" />
    </element>
    <element id="Patient.address">
      <path value="Patient.address" />
      <short value="Eine Adresse gemäß postalischer Konventionen" />
      <definition value="Eine Adresse gemäß postalischer Konventionen (im Gegensatz zu bspw. GPS-Koordinaten). Die Adresse kann sowohl zur Zustellung von Postsendungen oder zum Aufsuchen von Orten, die keine gültige Postadresse haben, verwendet werden.&#xD;&#xA;&#xD;&#xA;Die verwendeten Extensions in diesem Profil bilden die Struktur der Adresse ab, wie sie im VSDM-Format der elektronischen Versichertenkarte verwendet wird.&#xD;&#xA;&#xD;&#xA;Insbesondere bei ausländischen Adresse oder Adressen, die nicht durch Einlesen einer elektronischen Versichertenkarte erfasst wurden, sind abweichende Strukturen möglich. Die Verwendung der Extensions ist nicht verpflichtend." />
      <comment value="Note: address is intended to describe postal addresses for administrative purposes, not to describe absolute geographical coordinates.  Postal addresses are often used as proxies for physical locations (also see the [Location](location.html#) resource)." />
      <type>
        <code value="Address" />
        <profile value="http://fhir.de/StructureDefinition/address-de-basis" />
      </type>
      <example>
        <label value="Beispiel für einfache Adresse" />
        <valueAddress>
          <use value="home" />
          <type value="postal" />
          <line value="Musterweg 42" />
          <city value="Musterhausen" />
          <postalCode value="99999" />
        </valueAddress>
      </example>
      <constraint>
        <key value="ele-1" />
        <severity value="error" />
        <human value="All FHIR elements must have a @value or children" />
        <expression value="hasValue() or (children().count() &gt; id.count())" />
        <xpath value="@value|f:*|h:div" />
        <source value="http://hl7.org/fhir/StructureDefinition/Element" />
      </constraint>
      <constraint>
        <key value="add-1" />
        <severity value="error" />
        <human value="Wenn die Extension 'Hausnummer' verwendet wird, muss auch Address.line gefüllt werden" />
        <expression value="line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber').empty() or $this.hasValue())" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
      <constraint>
        <key value="add-2" />
        <severity value="error" />
        <human value="Wenn die Extension 'Strasse' verwendet wird, muss auch Address.line gefüllt werden" />
        <expression value="line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName').empty() or $this.hasValue())" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
      <constraint>
        <key value="add-3" />
        <severity value="error" />
        <human value="Wenn die Extension 'Postfach' verwendet wird, muss auch Address.line gefüllt werden" />
        <expression value="line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-postBox').empty() or $this.hasValue())" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
      <constraint>
        <key value="add-4" />
        <severity value="warning" />
        <human value="Eine Postfach-Adresse darf nicht vom Type &quot;physical&quot; oder &quot;both&quot; sein." />
        <expression value="line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-postBox').empty() or $this.hasValue()) or type='postal' or type.empty()" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
      <constraint>
        <key value="add-5" />
        <severity value="error" />
        <human value="Wenn die Extension 'Adresszusatz' verwendet wird, muss auch Address.line gefüllt werden" />
        <expression value="line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator').empty() or $this.hasValue())" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
      <constraint>
        <key value="add-6" />
        <severity value="warning" />
        <human value="Wenn die Extension 'Postfach' verwendet wird, dürfen die Extensions 'Strasse' und 'Hausnummer' nicht verwendet werden" />
        <expression value="line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-postBox').empty() or ($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName').empty() and $this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber').empty()))" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
      <constraint>
        <key value="add-7" />
        <severity value="warning" />
        <human value="Wenn die Extension 'Precinct' (Stadtteil) verwendet wird, dann muss diese Information auch als separates line-item abgebildet sein." />
        <expression value="extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-precinct').empty() or all(line contains extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-precinct').value.ofType(string))" />
        <source value="http://fhir.de/StructureDefinition/address-de-basis" />
      </constraint>
    </element>
  </differential>
</StructureDefinition>