{
  "resourceType": "StructureDefinition",
  "id": "51533f7f-1fa3-4866-a200-01618d377455",
  "url": "https://fhir.nhs.uk/StructureDefinition/England-PractitionerRole",
  "name": "EnglandPractitionerRole",
  "status": "draft",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "PractitionerRole",
  "baseDefinition": "https://fhir.hl7.org.uk/StructureDefinition/UKCore-PractitionerRole",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "PractitionerRole",
        "path": "PractitionerRole",
        "constraint": [
          {
            "key": "role-spurious",
            "severity": "warning",
            "human": "Spurious Code format must be G6NNNNNN or G7NNNNNN",
            "expression": "identifier.where(system='https://fhir.hl7.org.uk/Id/nhsbsa-spurious-code').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/nhsbsa-spurious-code').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/nhsbsa-spurious-code').value.matches('^[G]{1}[67]{1}[0-9]{6}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-sds-role-profile",
            "severity": "warning",
            "human": "SDS Role Profile Id must be 12 digits",
            "expression": "identifier.where(system='https://fhir.nhs.uk/Id/sds-role-profile-id').exists().not() or (identifier.where(system='https://fhir.nhs.uk/Id/sds-role-profile-id').exists()  and identifier.where(system='https://fhir.nhs.uk/Id/sds-role-profile-id').value.matches('^[0-9]{12}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          }
        ]
      },
      {
        "id": "PractitionerRole.extension",
        "path": "PractitionerRole.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        },
        "min": 0
      },
      {
        "id": "PractitionerRole.identifier",
        "path": "PractitionerRole.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "mustSupport": true
      },
      {
        "id": "PractitionerRole.identifier:sdsRoleProfileID",
        "path": "PractitionerRole.identifier",
        "sliceName": "sdsRoleProfileID",
        "min": 0,
        "max": "1"
      },
      {
        "id": "PractitionerRole.identifier:sdsRoleProfileID.system",
        "path": "PractitionerRole.identifier.system",
        "fixedUri": "https://fhir.nhs.uk/Id/sds-role-profile-id"
      },
      {
        "id": "PractitionerRole.identifier:nhsbsaSpuriousCode",
        "path": "PractitionerRole.identifier",
        "sliceName": "nhsbsaSpuriousCode",
        "max": "1"
      },
      {
        "id": "PractitionerRole.identifier:nhsbsaSpuriousCode.system",
        "path": "PractitionerRole.identifier.system",
        "fixedUri": "https://fhir.hl7.org.uk/Id/nhsbsa-spurious-code"
      },
      {
        "id": "PractitionerRole.practitioner",
        "path": "PractitionerRole.practitioner",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-Practitioner"
            ]
          }
        ],
        "constraint": [
          {
            "key": "nhsd-2",
            "severity": "warning",
            "human": "An identifier reference plus a display name or resource reference must be provided",
            "expression": "(reference.exists() or (identifier.exists() and display.exists()))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-nmc",
            "severity": "warning",
            "human": "NMC must be of the format NNANNNNA",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/nmc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/nmc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/nmc-number').value.matches('^[0-9]{2}[A-Z]{1}[0-9]{4}[A-Z]{1}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-gmp",
            "severity": "warning",
            "human": "GMP must be of the format GNNNNNNN and not be a spurious code (starts with G6 or G7)",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/gmp-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/gmp-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/gmp-number').value.matches('^[G]{1}[01234589]{1}[0-9]{6}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-gmc",
            "severity": "warning",
            "human": "GMC must be of the format CNNNNNNN",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/gmc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/gmc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/gmc-number').value.matches('^[C]{1}[0-9]{7}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-gphc",
            "severity": "warning",
            "human": "GPHC must be of the format NNNNNNN",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/gphc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/gphc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/gphc-number').value.matches('^[0-9]{7}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-hcpc",
            "severity": "warning",
            "human": "HCPC must be of the format AANNNNNN",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/hcpc-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/hcpc-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/hcpc-number').value.matches('^[A-Z]{2}[0-9]{6}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-din",
            "severity": "warning",
            "human": "DIN format must be NNNNNN",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.hl7.org.uk/Id/din-number').exists().not() or (identifier.where(system='https://fhir.hl7.org.uk/Id/din-number').exists()  and identifier.where(system='https://fhir.hl7.org.uk/Id/din-number').value.matches('^[0-9]{6}$'))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          },
          {
            "key": "role-sds-user",
            "severity": "warning",
            "human": "Professional code (GMC, GMP, NMC, etc) is preferred.",
            "expression": "identifier.exists().not() or identifier.where(system='https://fhir.nhs.uk/Id/sds-user-id').exists().not()",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "PractitionerRole.organization",
        "path": "PractitionerRole.organization",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-Organization"
            ]
          }
        ],
        "constraint": [
          {
            "key": "nhsd-1",
            "severity": "error",
            "human": "PractitionerRole.organization - An identifier reference plus a display name or resource reference must be provided",
            "expression": "(reference.exists() or (identifier.exists() and display.exists()))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "PractitionerRole.organization.identifier.system",
        "path": "PractitionerRole.organization.identifier.system",
        "min": 1
      },
      {
        "id": "PractitionerRole.organization.identifier.value",
        "path": "PractitionerRole.organization.identifier.value",
        "min": 1
      },
      {
        "id": "PractitionerRole.code.coding",
        "path": "PractitionerRole.code.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "PractitionerRole.code.coding.system",
        "path": "PractitionerRole.code.coding.system",
        "min": 1
      },
      {
        "id": "PractitionerRole.code.coding.code",
        "path": "PractitionerRole.code.coding.code",
        "min": 1
      },
      {
        "id": "PractitionerRole.code.coding:sdsJobRoleName",
        "path": "PractitionerRole.code.coding",
        "sliceName": "sdsJobRoleName",
        "max": "1"
      },
      {
        "id": "PractitionerRole.code.coding:sdsJobRoleName.system",
        "path": "PractitionerRole.code.coding.system",
        "fixedUri": "https://fhir.hl7org.uk/CodeSystem/UKCore-SDSJobRoleName"
      },
      {
        "id": "PractitionerRole.specialty.coding",
        "path": "PractitionerRole.specialty.coding",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "PractitionerRole.specialty.coding.system",
        "path": "PractitionerRole.specialty.coding.system",
        "min": 1
      },
      {
        "id": "PractitionerRole.specialty.coding.code",
        "path": "PractitionerRole.specialty.coding.code",
        "min": 1
      },
      {
        "id": "PractitionerRole.specialty.coding.display",
        "path": "PractitionerRole.specialty.coding.display",
        "min": 1
      },
      {
        "id": "PractitionerRole.specialty.coding:NHSDataDictionarySpecialty",
        "path": "PractitionerRole.specialty.coding",
        "sliceName": "NHSDataDictionarySpecialty",
        "binding": {
          "strength": "required",
          "description": "NHS Data Dictionary Specialty",
          "valueSet": "https://fhir.nhs.uk/ValueSet/NHSDataModelAndDictionary-clinical-specialty"
        }
      },
      {
        "id": "PractitionerRole.specialty.coding:NHSDataDictionarySpecialty.system",
        "path": "PractitionerRole.specialty.coding.system",
        "fixedUri": "https://fhir.nhs.uk/CodeSystem/NHSDataModelAndDictionary-clinical-specialty"
      },
      {
        "id": "PractitionerRole.specialty.coding:SNOMEDSpecialty",
        "path": "PractitionerRole.specialty.coding",
        "sliceName": "SNOMEDSpecialty",
        "binding": {
          "strength": "preferred",
          "description": "Specific specialty associated with the agency.",
          "valueSet": "http://hl7.org/fhir/ValueSet/c80-practice-codes"
        }
      },
      {
        "id": "PractitionerRole.specialty.coding:SNOMEDSpecialty.system",
        "path": "PractitionerRole.specialty.coding.system",
        "fixedUri": "http://snomed.info/sct"
      },
      {
        "id": "PractitionerRole.healthcareService",
        "path": "PractitionerRole.healthcareService",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.uk/StructureDefinition/NHSDigital-HealthcareService"
            ]
          }
        ],
        "constraint": [
          {
            "key": "nhsd-4",
            "severity": "error",
            "human": "PractitionerRole.healthcareService - An identifier reference plus a display name or resource reference must be provided",
            "expression": "(reference.exists() or (identifier.exists() and display.exists()))",
            "source": "https://fhir.nhs.uk/StructureDefinition/NHSDigital-PractitionerRole"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "PractitionerRole.healthcareService.identifier.system",
        "path": "PractitionerRole.healthcareService.identifier.system",
        "min": 1
      },
      {
        "id": "PractitionerRole.healthcareService.identifier.value",
        "path": "PractitionerRole.healthcareService.identifier.value",
        "min": 1
      },
      {
        "id": "PractitionerRole.telecom",
        "path": "PractitionerRole.telecom",
        "mustSupport": true
      },
      {
        "id": "PractitionerRole.telecom.value",
        "path": "PractitionerRole.telecom.value",
        "min": 1
      },
      {
        "id": "PractitionerRole.telecom.use",
        "path": "PractitionerRole.telecom.use",
        "min": 1
      }
    ]
  }
}