{
  "resourceType": "StructureDefinition",
  "id": "pcm-consent-submit",
  "url": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-consent-submit",
  "version": "0.3.2",
  "name": "PCMConsentSubmit",
  "title": "PCM Consent Submit",
  "status": "active",
  "description": "Closed interaction-specific submit profile for a Service Provider consent request. Clients may assert this profile in meta.profile, but PCM validates the interaction shape independently and does not require the declaration. The business-minimal submit data is status=proposed, patient.identifier, and pcmService. scope=patient-privacy, category=INFA, and the fixed legal policy are mandatory request-envelope values.",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Consent",
  "baseDefinition": "http://fhir.health.gov.il/StructureDefinition/il-core-consent",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Consent.id",
        "path": "Consent.id",
        "comment": "FHIR create metadata. If supplied, PCM ignores it and assigns the logical id."
      },
      {
        "id": "Consent.meta.versionId",
        "path": "Consent.meta.versionId",
        "comment": "Server-managed FHIR metadata. Prohibited in client requests.",
        "max": "0"
      },
      {
        "id": "Consent.meta.lastUpdated",
        "path": "Consent.meta.lastUpdated",
        "comment": "Server-managed FHIR metadata. Prohibited in client requests.",
        "max": "0"
      },
      {
        "id": "Consent.meta.source",
        "path": "Consent.meta.source",
        "max": "0"
      },
      {
        "id": "Consent.meta.profile",
        "path": "Consent.meta.profile",
        "comment": "Clients may assert the interaction-specific request profile, but PCM validates the request shape independently and does not require this declaration."
      },
      {
        "id": "Consent.meta.security",
        "path": "Consent.meta.security",
        "comment": "Prohibited on submit. PCM derives the HTEST security label only from the exact synthetic test-patient identifier.",
        "max": "0"
      },
      {
        "id": "Consent.meta.tag",
        "path": "Consent.meta.tag",
        "max": "0"
      },
      {
        "id": "Consent.implicitRules",
        "path": "Consent.implicitRules",
        "max": "0"
      },
      {
        "id": "Consent.language",
        "path": "Consent.language",
        "max": "0"
      },
      {
        "id": "Consent.text",
        "path": "Consent.text",
        "max": "0"
      },
      {
        "id": "Consent.contained",
        "path": "Consent.contained",
        "max": "0"
      },
      {
        "id": "Consent.extension",
        "path": "Consent.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Consent.extension:businessStatus",
        "path": "Consent.extension",
        "sliceName": "businessStatus",
        "comment": "Prohibited on submit. PCM derives the authoritative business status.",
        "min": 0,
        "max": "0",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://pcm.fhir.health.gov.il/StructureDefinition/ext-consent-business-status"
            ]
          }
        ]
      },
      {
        "id": "Consent.extension:pcmService",
        "path": "Consent.extension",
        "sliceName": "pcmService",
        "comment": "Required on submit. Reference to the active/usable HealthcareService instance being requested. PCM rejects canonical, inactive, pending, rejected, frozen, suspended, cancelled, or otherwise blocked instances, and also rejects requests when the referenced catalog service is not active/usable.",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://pcm.fhir.health.gov.il/StructureDefinition/ext-pcm-service"
            ]
          }
        ]
      },
      {
        "id": "Consent.modifierExtension",
        "path": "Consent.modifierExtension",
        "max": "0"
      },
      {
        "id": "Consent.identifier",
        "path": "Consent.identifier",
        "comment": "Omitted on submit. PCM assigns the returned Consent business identifier.",
        "max": "0"
      },
      {
        "id": "Consent.status",
        "path": "Consent.status",
        "comment": "Required on submit. Consent creation always starts as proposed.",
        "fixedCode": "proposed"
      },
      {
        "id": "Consent.scope",
        "path": "Consent.scope",
        "comment": "Required fixed value on submit. PCM stores scope=patient-privacy."
      },
      {
        "id": "Consent.scope.coding",
        "path": "Consent.scope.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Consent.scope.coding.system",
        "path": "Consent.scope.coding.system",
        "min": 1,
        "fixedUri": "http://terminology.hl7.org/CodeSystem/consentscope"
      },
      {
        "id": "Consent.scope.coding.code",
        "path": "Consent.scope.coding.code",
        "min": 1,
        "fixedCode": "patient-privacy"
      },
      {
        "id": "Consent.category",
        "path": "Consent.category",
        "comment": "Required fixed value on submit. PCM stores category=INFA.",
        "max": "1"
      },
      {
        "id": "Consent.category.coding",
        "path": "Consent.category.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Consent.category.coding.system",
        "path": "Consent.category.coding.system",
        "min": 1,
        "fixedUri": "http://terminology.hl7.org/CodeSystem/v3-ActCode"
      },
      {
        "id": "Consent.category.coding.code",
        "path": "Consent.category.coding.code",
        "min": 1,
        "fixedCode": "INFA"
      },
      {
        "id": "Consent.patient",
        "path": "Consent.patient",
        "comment": "Required on submit. Always a logical patient identifier.",
        "min": 1
      },
      {
        "id": "Consent.patient.reference",
        "path": "Consent.patient.reference",
        "max": "0"
      },
      {
        "id": "Consent.patient.identifier",
        "path": "Consent.patient.identifier",
        "min": 1,
        "constraint": [
          {
            "key": "pcm-consent-patient-id-system",
            "severity": "error",
            "human": "Consent.patient.identifier must use IL national-id, an allowed passport system, or one of the two exact synthetic test identifiers.",
            "expression": "system = 'http://fhir.health.gov.il/identifier/il-national-id' or system.memberOf('http://fhir.health.gov.il/ValueSet/passport-uri') or (system = 'http://fhir.health.gov.il/identifier/il-hdp-test-id' and (value = '1' or value = '2'))",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-consent-submit"
          },
          {
            "key": "pcm-consent-patient-id-value-trimmed",
            "severity": "error",
            "human": "Consent.patient.identifier.value must be non-empty and must not have leading/trailing whitespace.",
            "expression": "value.exists() and value.matches('^\\\\S(.*\\\\S)?$')",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-consent-submit"
          },
          {
            "key": "pcm-consent-patient-il-id-chk",
            "severity": "error",
            "human": "If Consent.patient.identifier.system is IL national-id, the value must be 9 digits and pass the Israeli ID check-digit algorithm.",
            "expression": "system = 'http://fhir.health.gov.il/identifier/il-national-id' implies (value.matches('^[0-9]{9}$') and value.substring(8,1).toInteger()= (10-((value.substring(0,1).toInteger() + value.substring(1,1).toInteger()*2 mod 10 + value.substring(1,1).toInteger()*2 div 10 + value.substring(2,1).toInteger() + value.substring(3,1).toInteger()*2 mod 10 + value.substring(3,1).toInteger()*2 div 10 + value.substring(4,1).toInteger() + value.substring(5,1).toInteger()*2 mod 10 + value.substring(5,1).toInteger()*2 div 10 + value.substring(6,1).toInteger() + value.substring(7,1).toInteger()*2 mod 10 + value.substring(7,1).toInteger()*2 div 10) mod 10)) mod 10)",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-consent-submit"
          }
        ]
      },
      {
        "id": "Consent.patient.identifier.system",
        "path": "Consent.patient.identifier.system",
        "min": 1
      },
      {
        "id": "Consent.patient.identifier.value",
        "path": "Consent.patient.identifier.value",
        "min": 1
      },
      {
        "id": "Consent.dateTime",
        "path": "Consent.dateTime",
        "comment": "Omitted on submit. PCM assigns the creation timestamp.",
        "max": "0"
      },
      {
        "id": "Consent.performer",
        "path": "Consent.performer",
        "max": "0"
      },
      {
        "id": "Consent.organization",
        "path": "Consent.organization",
        "max": "0"
      },
      {
        "id": "Consent.source[x]",
        "path": "Consent.source[x]",
        "max": "0"
      },
      {
        "id": "Consent.source[x]:sourceReference",
        "path": "Consent.source[x]",
        "sliceName": "sourceReference",
        "max": "0",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.health.gov.il/StructureDefinition/il-core-consent",
              "http://fhir.health.gov.il/StructureDefinition/il-core-document-reference",
              "http://hl7.org/fhir/StructureDefinition/Contract",
              "http://fhir.health.gov.il/StructureDefinition/il-core-questionnaire-response"
            ]
          }
        ]
      },
      {
        "id": "Consent.source[x]:sourceAttachment",
        "path": "Consent.source[x]",
        "sliceName": "sourceAttachment",
        "min": 0,
        "max": "0",
        "type": [
          {
            "code": "Attachment"
          }
        ]
      },
      {
        "id": "Consent.policy",
        "path": "Consent.policy",
        "comment": "Required fixed legal policy covered by the Consent request.",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Consent.policy.authority",
        "path": "Consent.policy.authority",
        "min": 1,
        "fixedUri": "https://www.gov.il/"
      },
      {
        "id": "Consent.policy.uri",
        "path": "Consent.policy.uri",
        "min": 1,
        "fixedUri": "https://pcm.fhir.health.gov.il/consent-policy/medical-information-mobility-law-2024"
      },
      {
        "id": "Consent.policyRule",
        "path": "Consent.policyRule",
        "max": "0"
      },
      {
        "id": "Consent.verification",
        "path": "Consent.verification",
        "max": "0"
      },
      {
        "id": "Consent.provision",
        "path": "Consent.provision",
        "comment": "Omitted on submit. Returned resources carry the server-derived provision.",
        "max": "0"
      }
    ]
  }
}