{
  "resourceType": "StructureDefinition",
  "id": "power-of-attorney-poa",
  "url": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
  "version": "0.1.0",
  "name": "PowerOfAttorneyPoa",
  "title": "Power of Attorney (POA)",
  "status": "active",
  "fhirVersion": "5.0.0",
  "kind": "resource",
  "abstract": false,
  "type": "Consent",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Consent",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Consent.text",
        "path": "Consent.text",
        "short": "Description of POA",
        "mustSupport": true
      },
      {
        "id": "Consent.text.status",
        "path": "Consent.text.status",
        "fixedCode": "generated",
        "mustSupport": true
      },
      {
        "id": "Consent.text.div",
        "path": "Consent.text.div",
        "mustSupport": true
      },
      {
        "id": "Consent.identifier",
        "path": "Consent.identifier",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Consent.status",
        "path": "Consent.status",
        "short": "draft | active | inactive",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/NDI/ValueSet/poa-poa-statuses"
        }
      },
      {
        "id": "Consent.category",
        "path": "Consent.category",
        "mustSupport": true
      },
      {
        "id": "Consent.category.coding",
        "path": "Consent.category.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Consent.category.coding.system",
        "path": "Consent.category.coding.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.category.coding.code",
        "path": "Consent.category.coding.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.subject",
        "path": "Consent.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://electronichealth.se/fhir/NDI/StructureDefinition/patient-data-access"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.subject.reference",
        "path": "Consent.subject.reference",
        "mustSupport": true
      },
      {
        "id": "Consent.subject.identifier",
        "path": "Consent.subject.identifier",
        "constraint": [
          {
            "key": "ndi-personal-identity-number-value-1",
            "human": "A Swedish personal identity number (sv: personnummer) should follow format 198001032385",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/personnummer'"
          },
          {
            "key": "ndi-coordination-number-value-1",
            "human": "A Swedish coordination number (sv: samordningsnummer) should follow format 201903682399",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])([6-9][1-9])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/samordningsnummer'"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.subject.identifier.system",
        "path": "Consent.subject.identifier.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.subject.identifier.value",
        "path": "Consent.subject.identifier.value",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.date",
        "path": "Consent.date",
        "mustSupport": true
      },
      {
        "id": "Consent.period",
        "path": "Consent.period",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.period.start",
        "path": "Consent.period.start",
        "min": 1,
        "constraint": [
          {
            "key": "ndi-dateTime-1",
            "human": "DateTime must be without timestamp",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "$this.toString().contains('T') = false"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.period.end",
        "path": "Consent.period.end",
        "constraint": [
          {
            "key": "ndi-dateTime-1",
            "human": "DateTime must be without timestamp",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "$this.toString().contains('T') = false"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.grantor",
        "path": "Consent.grantor",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://electronichealth.se/fhir/NDI/StructureDefinition/patient-data-access",
              "http://electronichealth.se/fhir/NDI/StructureDefinition/related-person-data-access"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.grantor.reference",
        "path": "Consent.grantor.reference",
        "mustSupport": true
      },
      {
        "id": "Consent.grantor.identifier",
        "path": "Consent.grantor.identifier",
        "constraint": [
          {
            "key": "ndi-personal-identity-number-value-1",
            "human": "A Swedish personal identity number (sv: personnummer) should follow format 198001032385",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/personnummer'"
          },
          {
            "key": "ndi-coordination-number-value-1",
            "human": "A Swedish coordination number (sv: samordningsnummer) should follow format 201903682399",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])([6-9][1-9])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/samordningsnummer'"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.grantor.identifier.system",
        "path": "Consent.grantor.identifier.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.grantor.identifier.value",
        "path": "Consent.grantor.identifier.value",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.grantee",
        "path": "Consent.grantee",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://electronichealth.se/fhir/NDI/StructureDefinition/related-person-data-access"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.grantee.reference",
        "path": "Consent.grantee.reference",
        "mustSupport": true
      },
      {
        "id": "Consent.grantee.identifier",
        "path": "Consent.grantee.identifier",
        "constraint": [
          {
            "key": "ndi-personal-identity-number-value-1",
            "human": "A Swedish personal identity number (sv: personnummer) should follow format 198001032385",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/personnummer'"
          },
          {
            "key": "ndi-coordination-number-value-1",
            "human": "A Swedish coordination number (sv: samordningsnummer) should follow format 201903682399",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])([6-9][1-9])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/samordningsnummer'"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.grantee.identifier.system",
        "path": "Consent.grantee.identifier.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.grantee.identifier.value",
        "path": "Consent.grantee.identifier.value",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.sourceReference",
        "path": "Consent.sourceReference",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/DocumentReference"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.sourceReference.reference",
        "path": "Consent.sourceReference.reference",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.verification",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
            "valueCode": "normative"
          },
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version",
            "valueCode": "4.0.0"
          },
          {
            "url": "http://hl7.org/fhir/StructureDefinition/obligation",
            "extension": [
              {
                "url": "code",
                "valueCode": "SHALL:populate"
              },
              {
                "url": "actor",
                "valueCanonical": "http://electronichealth.se/fhir/NDI/ActorDefinition/power-of-attorney-source-actor-poa"
              }
            ]
          }
        ],
        "path": "Consent.verification",
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verified",
        "path": "Consent.verification.verified",
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verificationType",
        "path": "Consent.verification.verificationType",
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verificationType.coding",
        "path": "Consent.verification.verificationType.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verificationType.coding.system",
        "path": "Consent.verification.verificationType.coding.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verificationType.coding.code",
        "path": "Consent.verification.verificationType.coding.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verifiedWith",
        "path": "Consent.verification.verifiedWith",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verifiedWith.identifier",
        "path": "Consent.verification.verifiedWith.identifier",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verifiedWith.identifier.system",
        "path": "Consent.verification.verifiedWith.identifier.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.verification.verifiedWith.identifier.value",
        "path": "Consent.verification.verifiedWith.identifier.value",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.decision",
        "path": "Consent.decision",
        "min": 1,
        "fixedCode": "permit",
        "mustSupport": true
      },
      {
        "id": "Consent.provision",
        "path": "Consent.provision",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.provision.action",
        "path": "Consent.provision.action",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/NDI/ValueSet/ps-permission-actions"
        }
      },
      {
        "id": "Consent.provision.action.coding",
        "path": "Consent.provision.action.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Consent.provision.action.coding.system",
        "path": "Consent.provision.action.coding.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.provision.action.coding.code",
        "path": "Consent.provision.action.coding.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.provision.documentType",
        "path": "Consent.provision.documentType",
        "short": "EHDS data category",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "http://electronichealth.se/fhir/NDI/ValueSet/ndi-ehds-categories"
        }
      },
      {
        "id": "Consent.provision.documentType.system",
        "path": "Consent.provision.documentType.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.provision.documentType.code",
        "path": "Consent.provision.documentType.code",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.provision.dataPeriod",
        "path": "Consent.provision.dataPeriod",
        "mustSupport": true
      },
      {
        "id": "Consent.provision.dataPeriod.start",
        "path": "Consent.provision.dataPeriod.start",
        "constraint": [
          {
            "key": "ndi-dateTime-1",
            "human": "DateTime must be without timestamp",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "$this.toString().contains('T') = false"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.provision.dataPeriod.end",
        "path": "Consent.provision.dataPeriod.end",
        "constraint": [
          {
            "key": "ndi-dateTime-1",
            "human": "DateTime must be without timestamp",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "$this.toString().contains('T') = false"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data",
        "path": "Consent.provision.data",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "meaning"
            }
          ],
          "rules": "open",
          "ordered": false,
          "description": "Slice data based on meaning"
        },
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data.meaning",
        "path": "Consent.provision.data.meaning",
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data.reference",
        "path": "Consent.provision.data.reference",
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit",
        "path": "Consent.provision.data",
        "sliceName": "fromCaregiverOrUnit",
        "min": 0,
        "max": "*",
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit.meaning",
        "path": "Consent.provision.data.meaning",
        "fixedCode": "authoredby"
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit.reference",
        "path": "Consent.provision.data.reference",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://electronichealth.se/fhir/NDI/StructureDefinition/organization-data-access"
            ]
          }
        ]
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit.reference.reference",
        "path": "Consent.provision.data.reference.reference",
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit.reference.identifier",
        "path": "Consent.provision.data.reference.identifier",
        "constraint": [
          {
            "key": "ndi-organization-identifier-value-1",
            "human": "A Swedish organization identifier (sv: organisationsnummer) should follow format 7999000057",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^\\\\d{6}\\\\d{4}$') or system != 'urn:oid:2.5.4.97'"
          },
          {
            "key": "ndi-personal-identity-number-value-1",
            "human": "A Swedish personal identity number (sv: personnummer) should follow format 198001032385",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/personnummer'"
          },
          {
            "key": "ndi-coordination-number-value-1",
            "human": "A Swedish coordination number (sv: samordningsnummer) should follow format 201903682399",
            "source": "http://electronichealth.se/fhir/NDI/StructureDefinition/power-of-attorney-poa",
            "severity": "error",
            "expression": "value.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])([6-9][1-9])\\\\d{4}$') or system != 'http://electronichealth.se/identifier/samordningsnummer'"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit.reference.identifier.system",
        "path": "Consent.provision.data.reference.identifier.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Consent.provision.data:fromCaregiverOrUnit.reference.identifier.value",
        "path": "Consent.provision.data.reference.identifier.value",
        "min": 1,
        "mustSupport": true
      }
    ]
  }
}