{
  "resourceType": "StructureDefinition",
  "id": "DataStandardsWales-PSOM-ClinicalCircumstanceIdentifier",
  "url": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PSOM-ClinicalCircumstanceIdentifier",
  "name": "DataStandardsWalesPSOMClinicalCircumstanceIdentifier",
  "title": "Data Standards Wales PSOM ClinicalCircumstanceIdentifier",
  "status": "active",
  "publisher": "NHS Wales",
  "contact": [
    {
      "name": "Data Standards",
      "telecom": [
        {
          "system": "email",
          "value": "data.standards@wales.nhs.uk",
          "use": "work"
        }
      ]
    }
  ],
  "description": "The National PSOM Clinical Circumstance Identifier: a nationally governed identifier that is unique across NHS Wales and identifies a single Clinical Circumstance (one Patient + one Clinical Circumstance + one PROMs Pathway = one PSOM CarePlan). The value has the format `<Originating Organisation Code>-<Local Identifier>`: the 5-character Originating Organisation Code of the Health Board/Trust (for example `7A400`), a mandatory hyphen, and the Health Board/Trust's local identifier for the Clinical Circumstance. The Health Board/Trust is also referenced as the Originating Organisation in `.assigner`.",
  "purpose": "To uniquely identify a PSOM Clinical Circumstance across NHS Wales, independent of any local identifier scheme.",
  "copyright": "© 2023 NHS Wales.",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "PROMs-Metadata-2024004",
      "name": "NHS Wales DSCN Metadata Mapping"
    }
  ],
  "kind": "complex-type",
  "abstract": false,
  "type": "Identifier",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Identifier",
  "derivation": "constraint",
  "snapshot": {
    "element": [
      {
        "id": "Identifier",
        "path": "Identifier",
        "short": "National PSOM Clinical Circumstance Identifier",
        "definition": "An identifier - identifies some entity uniquely and unambiguously. Typically this is used for business identifiers.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Identifier",
          "min": 0,
          "max": "*"
        },
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "PSOM-ClinicalCircumstanceIdentifier-01",
            "severity": "error",
            "human": "The value SHALL start with the 5-character Originating Organisation Code (for example 7A400), followed by a hyphen and the local identifier.",
            "expression": "value.matches('^[A-Z0-9]{5}-.+$')",
            "source": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PSOM-ClinicalCircumstanceIdentifier"
          }
        ],
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "v2",
            "map": "CX / EI (occasionally, more often EI maps to a resource id or a URL)"
          },
          {
            "identity": "rim",
            "map": "II - The Identifier class is a little looser than the v3 type II because it allows URIs as well as registered OIDs or GUIDs.  Also maps to Role[classCode=IDENT]"
          },
          {
            "identity": "servd",
            "map": "Identifier"
          }
        ]
      },
      {
        "id": "Identifier.id",
        "path": "Identifier.id",
        "representation": [
          "xmlAttr"
        ],
        "short": "Unique id for inter-element referencing",
        "definition": "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Element.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ],
            "code": "http://hl7.org/fhirpath/System.String"
          }
        ],
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "Identifier.extension",
        "path": "Identifier.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "description": "Extensions are always sliced by (at least) url",
          "rules": "open"
        },
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "Element.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), 'value')])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "Identifier.use",
        "path": "Identifier.use",
        "short": "usual | official | temp | secondary | old (If known)",
        "definition": "The purpose of this identifier.",
        "comment": "Applications can assume that an identifier is permanent unless it explicitly says that it is temporary.",
        "requirements": "Allows the appropriate identifier for a particular context of use to be selected from among a set of identifiers.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Identifier.use",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "code"
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": true,
        "isModifierReason": "This is labeled as \"Is Modifier\" because applications should not mistake a temporary id for a permanent one.",
        "isSummary": true,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "IdentifierUse"
            }
          ],
          "strength": "required",
          "description": "Identifies the purpose for this identifier, if known .",
          "valueSet": "http://hl7.org/fhir/ValueSet/identifier-use|4.0.1"
        },
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "v2",
            "map": "N/A"
          },
          {
            "identity": "rim",
            "map": "Role.code or implied by context"
          }
        ]
      },
      {
        "id": "Identifier.type",
        "path": "Identifier.type",
        "short": "Description of identifier",
        "definition": "A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.",
        "comment": "This element deals only with general categories of identifiers.  It SHOULD not be used for codes that correspond 1..1 with the Identifier.system. Some identifiers may fall into multiple categories due to common usage.   Where the system is known, a type is unnecessary because the type is always part of the system definition. However systems often need to handle identifiers where the system is not known. There is not a 1:1 relationship between type and system, since many different systems have the same type.",
        "requirements": "Allows users to make use of identifiers when the identifier system is not known.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Identifier.type",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isSummary": true,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "IdentifierType"
            }
          ],
          "strength": "extensible",
          "description": "A coded type for an identifier that can be used to determine which identifier to use for a specific purpose.",
          "valueSet": "http://hl7.org/fhir/ValueSet/identifier-type"
        },
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "v2",
            "map": "CE/CNE/CWE"
          },
          {
            "identity": "rim",
            "map": "CD"
          },
          {
            "identity": "orim",
            "map": "fhir:CodeableConcept rdfs:subClassOf dt:CD"
          },
          {
            "identity": "v2",
            "map": "CX.5"
          },
          {
            "identity": "rim",
            "map": "Role.code or implied by context"
          }
        ]
      },
      {
        "id": "Identifier.system",
        "path": "Identifier.system",
        "short": "National PSOM Clinical Circumstance Identifier namespace",
        "definition": "The nationally governed namespace for the National PSOM Clinical Circumstance Identifier.",
        "comment": "Identifier.system is always case sensitive.",
        "requirements": "There are many sets  of identifiers.  To perform matching of two identifiers, we need to know what set we're dealing with. The system identifies a particular set of unique identifiers.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Identifier.system",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "uri"
          }
        ],
        "fixedUri": "https://fhir.nhs.wales/Id/PSOM-ClinicalCircumstance-Identifier",
        "example": [
          {
            "label": "General",
            "valueUri": "http://www.acme.com/identifiers/patient"
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isSummary": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "v2",
            "map": "CX.4 / EI-2-4"
          },
          {
            "identity": "rim",
            "map": "II.root or Role.id.root"
          },
          {
            "identity": "servd",
            "map": "./IdentifierType"
          }
        ]
      },
      {
        "id": "Identifier.value",
        "path": "Identifier.value",
        "short": "Originating Organisation Code, hyphen, local identifier",
        "definition": "The National PSOM Clinical Circumstance Identifier, in the format `<Originating Organisation Code>-<Local Identifier>`:\n\n1. **Originating Organisation Code**: the 5-character code of the Health Board/Trust that assigns the identifier, as used for the Originating Organisation Code (MDDPX002X) in the PSOM data model, for example `7A400`. The first three characters are the ODS code of the Health Board/Trust (`7A4`); the last two characters may denote a site within the Health Board/Trust and are `00` when no particular site applies.\n2. A **hyphen**, which is mandatory.\n3. **Local Identifier**: the Health Board/Trust's own identifier for the Clinical Circumstance. Where a suitable local identifier exists that satisfies the agreed CarePlan semantics (one Patient + one Clinical Circumstance + one PROMs Pathway), it SHALL be used, for example `7A400-1524459454`. Only where no suitable local identifier exists SHALL a new one be generated (see Comments).",
        "comment": "Where no suitable local identifier exists, the Health Board/Trust SHALL generate one by concatenating the following attributes, building on the existing PROMs Pathway ID methodology: Originating Organisation Code, Originating System Code, PROMs Pathway Type, Patient Identifier (typically the NHS Number), Referral Identifier and Pathway Laterality (where applicable). For example `7A400-140-MSK-44444444444-190489414-8`, where `7A400` is the Originating Organisation Code, `140` the Originating System Code, `MSK` the PROMs Pathway Type, `44444444444` the Patient Identifier, `190489414` the Referral Identifier and `8` the Pathway Laterality.\n\nAn existing identifier for the same Patient, Clinical Circumstance and PROMs Pathway SHALL be reused, and SHALL be sent unchanged in all subsequent PSOM messages and NDR submissions.\n\nApart from the Originating Organisation Code, receivers SHALL treat the value as opaque and SHALL NOT derive meaning from the Local Identifier.",
        "requirements": "The Originating Organisation Code prefix keeps the value unique across NHS Wales, while each Health Board/Trust keeps its own local identifier scheme.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Identifier.value",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "string"
          }
        ],
        "example": [
          {
            "label": "General",
            "valueString": "123456"
          },
          {
            "label": "Existing local identifier",
            "valueString": "7A400-1524459454"
          },
          {
            "label": "Generated from PROMs Pathway ID attributes",
            "valueString": "7A400-140-MSK-44444444444-190489414-8"
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isSummary": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "v2",
            "map": "CX.1 / EI.1"
          },
          {
            "identity": "rim",
            "map": "II.extension or II.root if system indicates OID or GUID (Or Role.id.extension or root)"
          },
          {
            "identity": "servd",
            "map": "./Value"
          }
        ]
      },
      {
        "id": "Identifier.period",
        "path": "Identifier.period",
        "short": "Time period when id is/was valid for use",
        "definition": "Time period during which identifier is/was valid for use.",
        "comment": "A Period specifies a range of time; the context of use will specify whether the entire range applies (e.g. \"the patient was an inpatient of the hospital for this time range\") or one value from the range applies (e.g. \"give to the patient between these two times\").\n\nPeriod is not used for a duration (a measure of elapsed time). See [Duration](datatypes.html#Duration).",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Identifier.period",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Period"
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "per-1",
            "severity": "error",
            "human": "If present, start SHALL have a lower value than end",
            "expression": "start.hasValue().not() or end.hasValue().not() or (start <= end)",
            "xpath": "not(exists(f:start/@value)) or not(exists(f:end/@value)) or (xs:dateTime(f:start/@value) <= xs:dateTime(f:end/@value))",
            "source": "http://hl7.org/fhir/StructureDefinition/Period"
          }
        ],
        "isSummary": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "v2",
            "map": "DR"
          },
          {
            "identity": "rim",
            "map": "IVL<TS>[lowClosed=\"true\" and highClosed=\"true\"] or URG<TS>[lowClosed=\"true\" and highClosed=\"true\"]"
          },
          {
            "identity": "v2",
            "map": "CX.7 + CX.8"
          },
          {
            "identity": "rim",
            "map": "Role.effectiveTime or implied by context"
          },
          {
            "identity": "servd",
            "map": "./StartDate and ./EndDate"
          }
        ]
      },
      {
        "id": "Identifier.assigner",
        "path": "Identifier.assigner",
        "short": "Originating Organisation",
        "definition": "The Health Board/Trust that assigned the National PSOM Clinical Circumstance Identifier. This organisation is the Originating Organisation of the Clinical Circumstance. Its ODS code SHALL match the first three characters of the Originating Organisation Code in `.value` (for example the Organization with ODS code `7A4` for value `7A400-1524459454`).",
        "comment": "The Identifier.assigner may omit the .reference element and only contain a .display element reflecting the name or other textual information about the assigning organization.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Identifier.assigner",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization"
            ]
          }
        ],
        "condition": [
          "ele-1"
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ref-1",
            "severity": "error",
            "human": "SHALL have a contained resource if a local reference is provided",
            "expression": "reference.exists() implies (reference.startsWith('#').not() or (reference.substring(1).trace('url') in %rootResource.contained.id.trace('ids')) or (reference='#' and %rootResource!=%resource))",
            "xpath": "not(starts-with(f:reference/@value, '#')) or exists(ancestor::*[self::f:entry or self::f:parameter]/f:resource/f:*/f:contained/f:*[f:id/@value=substring-after(current()/f:reference/@value, '#')]|/*/f:contained/f:*[f:id/@value=substring-after(current()/f:reference/@value, '#')])",
            "source": "http://hl7.org/fhir/StructureDefinition/Reference"
          }
        ],
        "isSummary": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          },
          {
            "identity": "rim",
            "map": "The target of a resource reference is a RIM entry point (Act, Role, or Entity)"
          },
          {
            "identity": "v2",
            "map": "CX.4 / (CX.4,CX.9,CX.10)"
          },
          {
            "identity": "rim",
            "map": "II.assigningAuthorityName but note that this is an improper use by the definition of the field.  Also Role.scoper"
          },
          {
            "identity": "servd",
            "map": "./IdentifierIssuingAuthority"
          },
          {
            "identity": "PROMs-Metadata-2024004",
            "map": "MDDPX002X",
            "comment": "Originating Organisation Code (implicit, main mapping is on Organization.identifier)"
          }
        ]
      }
    ]
  },
  "differential": {
    "element": [
      {
        "id": "Identifier",
        "path": "Identifier",
        "short": "National PSOM Clinical Circumstance Identifier",
        "constraint": [
          {
            "key": "PSOM-ClinicalCircumstanceIdentifier-01",
            "severity": "error",
            "human": "The value SHALL start with the 5-character Originating Organisation Code (for example 7A400), followed by a hyphen and the local identifier.",
            "expression": "value.matches('^[A-Z0-9]{5}-.+$')",
            "source": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PSOM-ClinicalCircumstanceIdentifier"
          }
        ]
      },
      {
        "id": "Identifier.system",
        "path": "Identifier.system",
        "short": "National PSOM Clinical Circumstance Identifier namespace",
        "definition": "The nationally governed namespace for the National PSOM Clinical Circumstance Identifier.",
        "min": 1,
        "fixedUri": "https://fhir.nhs.wales/Id/PSOM-ClinicalCircumstance-Identifier"
      },
      {
        "id": "Identifier.value",
        "path": "Identifier.value",
        "short": "Originating Organisation Code, hyphen, local identifier",
        "definition": "The National PSOM Clinical Circumstance Identifier, in the format `<Originating Organisation Code>-<Local Identifier>`:\n\n1. **Originating Organisation Code**: the 5-character code of the Health Board/Trust that assigns the identifier, as used for the Originating Organisation Code (MDDPX002X) in the PSOM data model, for example `7A400`. The first three characters are the ODS code of the Health Board/Trust (`7A4`); the last two characters may denote a site within the Health Board/Trust and are `00` when no particular site applies.\n2. A **hyphen**, which is mandatory.\n3. **Local Identifier**: the Health Board/Trust's own identifier for the Clinical Circumstance. Where a suitable local identifier exists that satisfies the agreed CarePlan semantics (one Patient + one Clinical Circumstance + one PROMs Pathway), it SHALL be used, for example `7A400-1524459454`. Only where no suitable local identifier exists SHALL a new one be generated (see Comments).",
        "comment": "Where no suitable local identifier exists, the Health Board/Trust SHALL generate one by concatenating the following attributes, building on the existing PROMs Pathway ID methodology: Originating Organisation Code, Originating System Code, PROMs Pathway Type, Patient Identifier (typically the NHS Number), Referral Identifier and Pathway Laterality (where applicable). For example `7A400-140-MSK-44444444444-190489414-8`, where `7A400` is the Originating Organisation Code, `140` the Originating System Code, `MSK` the PROMs Pathway Type, `44444444444` the Patient Identifier, `190489414` the Referral Identifier and `8` the Pathway Laterality.\n\nAn existing identifier for the same Patient, Clinical Circumstance and PROMs Pathway SHALL be reused, and SHALL be sent unchanged in all subsequent PSOM messages and NDR submissions.\n\nApart from the Originating Organisation Code, receivers SHALL treat the value as opaque and SHALL NOT derive meaning from the Local Identifier.",
        "requirements": "The Originating Organisation Code prefix keeps the value unique across NHS Wales, while each Health Board/Trust keeps its own local identifier scheme.",
        "min": 1,
        "example": [
          {
            "label": "Existing local identifier",
            "valueString": "7A400-1524459454"
          },
          {
            "label": "Generated from PROMs Pathway ID attributes",
            "valueString": "7A400-140-MSK-44444444444-190489414-8"
          }
        ]
      },
      {
        "id": "Identifier.assigner",
        "path": "Identifier.assigner",
        "short": "Originating Organisation",
        "definition": "The Health Board/Trust that assigned the National PSOM Clinical Circumstance Identifier. This organisation is the Originating Organisation of the Clinical Circumstance. Its ODS code SHALL match the first three characters of the Originating Organisation Code in `.value` (for example the Organization with ODS code `7A4` for value `7A400-1524459454`).",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "PROMs-Metadata-2024004",
            "map": "MDDPX002X",
            "comment": "Originating Organisation Code (implicit, main mapping is on Organization.identifier)"
          }
        ]
      }
    ]
  }
}