{
  "resourceType": "StructureDefinition",
  "id": "ncr-diagnosis-bundle",
  "url": "http://fhir.iknl.nl/fhir/iknl-ncr-ehr-r4/StructureDefinition/ncr-diagnosis-bundle",
  "name": "NcrDiagnosisBundle",
  "status": "draft",
  "date": "2024-03-21T16:43:59.6734344+00:00",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Bundle",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Bundle",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Bundle",
        "path": "Bundle",
        "constraint": [
          {
            "key": "ncrdiag-0",
            "severity": "error",
            "human": "A Patient in this bundle conforms to NcrEhrPatient",
            "expression": "entry.resource.ofType(Patient).conformsTo('http://fhir.iknl.nl/fhir/iknl-ncr-ehr-r4/StructureDefinition/ncr-ehr-patient').allTrue()"
          },
          {
            "key": "ncrdiag-1",
            "severity": "error",
            "human": "A EpisodeOfCare in this bundle conforms to NcrEhrEpisodeOfCare",
            "expression": "entry.resource.ofType(EpisodeOfCare).conformsTo('http://fhir.iknl.nl/fhir/iknl-ncr-ehr-r4/StructureDefinition/ncr-ehr-episode-of-care').allTrue()"
          },
          {
            "key": "ncrdiag-2",
            "severity": "error",
            "human": "When the bundle contains no episode of care resource, Patient.active must be false.",
            "expression": "entry.resource.ofType(EpisodeOfCare).exists() or entry.resource.ofType(Patient).active.allFalse()"
          }
        ]
      },
      {
        "id": "Bundle.meta",
        "path": "Bundle.meta",
        "min": 1
      },
      {
        "id": "Bundle.meta.tag",
        "path": "Bundle.meta.tag",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Bundle.meta.tag:processing-target",
        "path": "Bundle.meta.tag",
        "sliceName": "processing-target",
        "min": 1,
        "max": "1",
        "patternCoding": {
          "system": "http://fhir.iknl.nl/fhir/iknl-ncr-ehr-r4/NamingSystem/processing-target",
          "code": "NKR_ODIA"
        }
      },
      {
        "id": "Bundle.entry",
        "path": "Bundle.entry",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "resolve()"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Bundle.entry:patient",
        "path": "Bundle.entry",
        "sliceName": "patient",
        "max": "1"
      },
      {
        "id": "Bundle.entry:patient.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "Resource",
            "profile": [
              "http://fhir.iknl.nl/fhir/iknl-ncr-ehr-r4/StructureDefinition/ncr-ehr-patient"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:patient.resource.identifier",
        "path": "Bundle.entry.resource.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Bundle.entry:patient.resource.name",
        "path": "Bundle.entry.resource.name",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "use"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Bundle.entry:patient.resource.telecom",
        "path": "Bundle.entry.resource.telecom",
        "slicing": {
          "discriminator": [
            {
              "type": "profile",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Bundle.entry:patient.resource.address.country.extension:countryCode",
        "path": "Bundle.entry.resource.address.country.extension",
        "sliceName": "countryCode"
      },
      {
        "id": "Bundle.entry:patient.resource.address.country.extension:countryCode.value[x].coding",
        "path": "Bundle.entry.resource.address.country.extension.value[x].coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Bundle.entry:patient.resource.contact.relationship",
        "path": "Bundle.entry.resource.contact.relationship",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Bundle.entry:patient.resource.contact.telecom",
        "path": "Bundle.entry.resource.contact.telecom",
        "slicing": {
          "discriminator": [
            {
              "type": "profile",
              "path": "$this"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Bundle.entry:episode-of-care",
        "path": "Bundle.entry",
        "sliceName": "episode-of-care",
        "max": "1"
      },
      {
        "id": "Bundle.entry:episode-of-care.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "Resource",
            "profile": [
              "http://fhir.iknl.nl/fhir/iknl-ncr-ehr-r4/StructureDefinition/ncr-ehr-episode-of-care"
            ]
          }
        ]
      }
    ]
  }
}