{
  "resourceType": "StructureDefinition",
  "url": "http://fhirtestbg.de/test/StructureDefinition/BGPatient",
  "name": "BGPatient",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Patient",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Patient.identifier",
        "path": "Patient.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1,
        "max": "2"
      },
      {
        "id": "Patient.identifier:PID",
        "path": "Patient.identifier",
        "sliceName": "PID",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Patient.identifier:PID.system",
        "path": "Patient.identifier.system",
        "min": 1,
        "fixedUri": "http://bg.de/fhir/pid"
      },
      {
        "id": "Patient.identifier:PID.value",
        "path": "Patient.identifier.value",
        "min": 1
      },
      {
        "id": "Patient.identifier:GKVID",
        "path": "Patient.identifier",
        "sliceName": "GKVID",
        "max": "1",
        "type": [
          {
            "code": "Identifier",
            "profile": [
              "http://fhir.de/StructureDefinition/identifier-kvid-10"
            ]
          }
        ]
      },
      {
        "id": "Patient.identifier:PKVID",
        "path": "Patient.identifier",
        "sliceName": "PKVID",
        "max": "1",
        "type": [
          {
            "code": "Identifier",
            "profile": [
              "http://fhir.de/StructureDefinition/identifier-pkv-kvid-10"
            ]
          }
        ]
      },
      {
        "id": "Patient.name",
        "path": "Patient.name",
        "min": 1
      },
      {
        "id": "Patient.name.family",
        "path": "Patient.name.family",
        "min": 1
      },
      {
        "id": "Patient.name.given",
        "path": "Patient.name.given",
        "min": 1
      },
      {
        "id": "Patient.gender",
        "path": "Patient.gender",
        "min": 1
      },
      {
        "id": "Patient.birthDate",
        "path": "Patient.birthDate",
        "min": 1
      },
      {
        "id": "Patient.address",
        "path": "Patient.address",
        "short": "Eine Adresse gemäß postalischer Konventionen",
        "definition": "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.\r\n\r\nDie verwendeten Extensions in diesem Profil bilden die Struktur der Adresse ab, wie sie im VSDM-Format der elektronischen Versichertenkarte verwendet wird.\r\n\r\nInsbesondere 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": "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": "Address",
            "profile": [
              "http://fhir.de/StructureDefinition/address-de-basis"
            ]
          }
        ],
        "example": [
          {
            "label": "Beispiel für einfache Adresse",
            "valueAddress": {
              "use": "home",
              "type": "postal",
              "line": [
                "Musterweg 42"
              ],
              "city": "Musterhausen",
              "postalCode": "99999"
            }
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "add-1",
            "severity": "error",
            "human": "Wenn die Extension 'Hausnummer' verwendet wird, muss auch Address.line gefüllt werden",
            "expression": "line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber').empty() or $this.hasValue())",
            "source": "http://fhir.de/StructureDefinition/address-de-basis"
          },
          {
            "key": "add-2",
            "severity": "error",
            "human": "Wenn die Extension 'Strasse' verwendet wird, muss auch Address.line gefüllt werden",
            "expression": "line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName').empty() or $this.hasValue())",
            "source": "http://fhir.de/StructureDefinition/address-de-basis"
          },
          {
            "key": "add-3",
            "severity": "error",
            "human": "Wenn die Extension 'Postfach' verwendet wird, muss auch Address.line gefüllt werden",
            "expression": "line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-postBox').empty() or $this.hasValue())",
            "source": "http://fhir.de/StructureDefinition/address-de-basis"
          },
          {
            "key": "add-4",
            "severity": "warning",
            "human": "Eine Postfach-Adresse darf nicht vom Type \"physical\" oder \"both\" sein.",
            "expression": "line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-postBox').empty() or $this.hasValue()) or type='postal' or type.empty()",
            "source": "http://fhir.de/StructureDefinition/address-de-basis"
          },
          {
            "key": "add-5",
            "severity": "error",
            "human": "Wenn die Extension 'Adresszusatz' verwendet wird, muss auch Address.line gefüllt werden",
            "expression": "line.all($this.extension('http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-additionalLocator').empty() or $this.hasValue())",
            "source": "http://fhir.de/StructureDefinition/address-de-basis"
          },
          {
            "key": "add-6",
            "severity": "warning",
            "human": "Wenn die Extension 'Postfach' verwendet wird, dürfen die Extensions 'Strasse' und 'Hausnummer' nicht verwendet werden",
            "expression": "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": "http://fhir.de/StructureDefinition/address-de-basis"
          },
          {
            "key": "add-7",
            "severity": "warning",
            "human": "Wenn die Extension 'Precinct' (Stadtteil) verwendet wird, dann muss diese Information auch als separates line-item abgebildet sein.",
            "expression": "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": "http://fhir.de/StructureDefinition/address-de-basis"
          }
        ]
      }
    ]
  }
}