{
  "resourceType": "StructureDefinition",
  "id": "pcm-organization-parent",
  "url": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent",
  "version": "0.4.2",
  "name": "PCMOrganizationParent",
  "title": "PCM Parent Organization",
  "status": "active",
  "description": "Root organization in PCM representing the onboarded parent legal entity. Created and identified by PCM during manual onboarding. Parent identity and active state are controlled by MoH/PCM; the organization may update contact details only.",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Organization",
  "baseDefinition": "http://fhir.health.gov.il/StructureDefinition/il-core-organization",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Organization",
        "path": "Organization",
        "constraint": [
          {
            "key": "pcm-parent-active-moh-identifier",
            "severity": "error",
            "human": "An active Parent Organization requires exactly one applicable MoH institution-symbol or approved paying-entity identifier.",
            "expression": "active = false or (identifier.where(system = 'http://institutions.health.gov.il/Institutions').count() + identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh').count() = 1)",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent"
          },
          {
            "key": "pcm-parent-payer-identifier",
            "severity": "error",
            "human": "A Parent paying-entity identifier must be one of the approved unique organization codes; generic code 400 is not accepted.",
            "expression": "identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh').value.all($this = '101' or $this = '102' or $this = '103' or $this = '104' or $this = '406' or $this = '401' or $this = '405' or $this = '402' or $this = '300')",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent"
          },
          {
            "key": "pcm-parent-hmo-identifier",
            "severity": "error",
            "human": "An HMO Parent uses one of the four unique HMO paying-entity codes and not an institution symbol; those four codes are valid only for an HMO Parent.",
            "expression": "(type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '73').exists() implies (identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and (value = '101' or value = '102' or value = '103' or value = '104')).count() = 1 and identifier.where(system = 'http://institutions.health.gov.il/Institutions').empty())) and (identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and (value = '101' or value = '102' or value = '103' or value = '104')).exists() implies type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '73').exists())",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent"
          },
          {
            "key": "pcm-parent-institution-identifier",
            "severity": "error",
            "human": "A general-hospital or geriatric-medical-center Parent uses an institution symbol and not a paying-entity identifier.",
            "expression": "type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and (code = '1' or code = '22')).exists() implies (identifier.where(system = 'http://institutions.health.gov.il/Institutions').count() = 1 and identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh').empty())",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent"
          },
          {
            "key": "pcm-parent-public-entity-identifier",
            "severity": "error",
            "human": "Structurally distinguishable public-entity Parent types use their decided paying-entity code, and those codes are limited to their matching institution type.",
            "expression": "(type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '71').exists() implies identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and value = '406').count() = 1) and (type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '75').exists() implies identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and value = '401').count() = 1) and (type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '87').exists() implies identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and value = '405').count() = 1) and (identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and value = '406').exists() implies type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '71').exists()) and (identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and value = '401').exists() implies type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '75').exists()) and (identifier.where(system = 'http://fhir.health.gov.il/cs/paying-entity-moh' and value = '405').exists() implies type.coding.where(system = 'http://fhir.health.gov.il/cs/institution-type-moh' and code = '87').exists())",
            "source": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent"
          }
        ]
      },
      {
        "id": "Organization.id",
        "path": "Organization.id",
        "min": 1
      },
      {
        "id": "Organization.meta",
        "path": "Organization.meta",
        "min": 1
      },
      {
        "id": "Organization.meta.lastUpdated",
        "path": "Organization.meta.lastUpdated",
        "comment": "Server-managed timestamp of the most recent authoritative resource change.",
        "min": 1
      },
      {
        "id": "Organization.meta.profile",
        "path": "Organization.meta.profile",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "$this"
            }
          ],
          "rules": "open"
        },
        "comment": "PCM includes the applicable server-return profile URL; additional compatible profile URLs are allowed.",
        "min": 1
      },
      {
        "id": "Organization.meta.profile:pcmProfile",
        "path": "Organization.meta.profile",
        "sliceName": "pcmProfile",
        "min": 1,
        "max": "1",
        "fixedCanonical": "http://pcm.fhir.health.gov.il/StructureDefinition/pcm-organization-parent"
      },
      {
        "id": "Organization.identifier",
        "path": "Organization.identifier",
        "comment": "PCM-managed identifiers. Every Parent has one PCM Organization business identifier and, where the type-specific mapping is resolved, the applicable MoH identifier. Organization-facing writes cannot add, replace, or remove these values.",
        "min": 1
      },
      {
        "id": "Organization.identifier:moh-inst-symbol",
        "path": "Organization.identifier",
        "sliceName": "moh-inst-symbol",
        "comment": "PCM records this identifier for hospitals and other institution-registry participants where the approved type mapping requires it."
      },
      {
        "id": "Organization.identifier:moe-inst",
        "path": "Organization.identifier",
        "sliceName": "moe-inst",
        "max": "0"
      },
      {
        "id": "Organization.identifier:moh-hospital-department",
        "path": "Organization.identifier",
        "sliceName": "moh-hospital-department",
        "max": "0"
      },
      {
        "id": "Organization.identifier:paying-entity-moh",
        "path": "Organization.identifier",
        "sliceName": "paying-entity-moh",
        "comment": "PCM records the approved paying-entity identifier only for organization types with a specific unique code. Generic code 400 is not a unique organization identifier."
      },
      {
        "id": "Organization.identifier:pcmOrganizationId",
        "path": "Organization.identifier",
        "sliceName": "pcmOrganizationId",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Organization.identifier:pcmOrganizationId.use",
        "path": "Organization.identifier.use",
        "min": 1,
        "fixedCode": "official"
      },
      {
        "id": "Organization.identifier:pcmOrganizationId.system",
        "path": "Organization.identifier.system",
        "fixedUri": "http://pcm.fhir.health.gov.il/identifier/pcm-organization-id"
      },
      {
        "id": "Organization.active",
        "path": "Organization.active",
        "comment": "MoH/PCM-controlled participation state. Organizations cannot set this through the client FHIR API. An inactive Parent prevents operational use of its children without rewriting each child's independently MoH/PCM-controlled active value.",
        "min": 1
      },
      {
        "id": "Organization.type",
        "path": "Organization.type",
        "comment": "Parent organization classification is MoH/PCM-controlled and not writable by organizations through the client FHIR API.",
        "min": 2
      },
      {
        "id": "Organization.type:pcmOrgType",
        "path": "Organization.type",
        "sliceName": "pcmOrgType",
        "comment": "Marks this Organization as a PCM Parent Organization.",
        "min": 1,
        "max": "1",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "parent-org",
              "system": "http://pcm.fhir.health.gov.il/cs/pcm-org-type"
            }
          ]
        }
      },
      {
        "id": "Organization.type:pcmOrgType.coding",
        "path": "Organization.type.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Organization.type:pcmOrgType.coding.system",
        "path": "Organization.type.coding.system",
        "min": 1,
        "fixedUri": "http://pcm.fhir.health.gov.il/cs/pcm-org-type"
      },
      {
        "id": "Organization.type:pcmOrgType.coding.code",
        "path": "Organization.type.coding.code",
        "min": 1,
        "fixedCode": "parent-org"
      },
      {
        "id": "Organization.name",
        "path": "Organization.name",
        "comment": "Parent organization name is MoH/PCM-controlled and not writable by organizations through the client FHIR API."
      },
      {
        "id": "Organization.alias",
        "path": "Organization.alias",
        "max": "0"
      },
      {
        "id": "Organization.telecom",
        "path": "Organization.telecom",
        "comment": "Parent organization telecom is MoH/PCM-controlled; organization-managed operational contacts are represented in contact."
      },
      {
        "id": "Organization.address",
        "path": "Organization.address",
        "comment": "Parent organization address is MoH/PCM-controlled and not writable by organizations through the client FHIR API."
      },
      {
        "id": "Organization.partOf",
        "path": "Organization.partOf",
        "max": "0"
      },
      {
        "id": "Organization.contact",
        "path": "Organization.contact",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "purpose.coding.code"
            }
          ],
          "rules": "open"
        },
        "comment": "The organization SHOULD supply ADMIN, PATINF, and SEC contacts. Additional purpose-coded contacts are allowed. Parent contacts are the fallback for a child that does not override the same purpose."
      },
      {
        "id": "Organization.contact.purpose",
        "path": "Organization.contact.purpose",
        "min": 1,
        "binding": {
          "strength": "extensible",
          "valueSet": "http://pcm.fhir.health.gov.il/ValueSet/pcm-contactentity-type"
        }
      },
      {
        "id": "Organization.contact:admin",
        "path": "Organization.contact",
        "sliceName": "admin",
        "comment": "Administrative enquiries contact.",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Organization.contact:admin.purpose.coding",
        "path": "Organization.contact.purpose.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Organization.contact:admin.purpose.coding.system",
        "path": "Organization.contact.purpose.coding.system",
        "min": 1,
        "fixedUri": "http://terminology.hl7.org/CodeSystem/contactentity-type"
      },
      {
        "id": "Organization.contact:admin.purpose.coding.code",
        "path": "Organization.contact.purpose.coding.code",
        "min": 1,
        "fixedCode": "ADMIN"
      },
      {
        "id": "Organization.contact:patientInfo",
        "path": "Organization.contact",
        "sliceName": "patientInfo",
        "comment": "Patient information / patient-facing enquiries contact.",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Organization.contact:patientInfo.purpose.coding",
        "path": "Organization.contact.purpose.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Organization.contact:patientInfo.purpose.coding.system",
        "path": "Organization.contact.purpose.coding.system",
        "min": 1,
        "fixedUri": "http://terminology.hl7.org/CodeSystem/contactentity-type"
      },
      {
        "id": "Organization.contact:patientInfo.purpose.coding.code",
        "path": "Organization.contact.purpose.coding.code",
        "min": 1,
        "fixedCode": "PATINF"
      },
      {
        "id": "Organization.contact:security",
        "path": "Organization.contact",
        "sliceName": "security",
        "comment": "Security / InfoSec / incident response contact.",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Organization.contact:security.purpose.coding",
        "path": "Organization.contact.purpose.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Organization.contact:security.purpose.coding.system",
        "path": "Organization.contact.purpose.coding.system",
        "min": 1,
        "fixedUri": "http://pcm.fhir.health.gov.il/cs/pcm-contactentity-type"
      },
      {
        "id": "Organization.contact:security.purpose.coding.code",
        "path": "Organization.contact.purpose.coding.code",
        "min": 1,
        "fixedCode": "SEC"
      },
      {
        "id": "Organization.endpoint",
        "path": "Organization.endpoint",
        "max": "0"
      }
    ]
  }
}