{
  "resourceType": "StructureDefinition",
  "id": "DataStandardsWales-DocumentReference",
  "url": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-DocumentReference",
  "version": "1.1.0",
  "name": "DataStandardsWalesDocumentReference",
  "title": "Data Standards Wales Document Reference",
  "status": "active",
  "experimental": false,
  "date": "2026-06-30",
  "publisher": "NHS Wales",
  "copyright": "2026 NHS Wales",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "DocumentReference",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/DocumentReference",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "DocumentReference.extension",
        "path": "DocumentReference.extension",
        "min": 1
      },
      {
        "id": "DocumentReference.extension:digitalStatus",
        "path": "DocumentReference.extension",
        "sliceName": "digitalStatus",
        "short": "born-digital-document | scanned-paper-document | UNK",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentDigitalStatus"
            ]
          }
        ],
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:digitalStatus.value[x]",
        "path": "DocumentReference.extension.value[x]",
        "requirements": "Mandatory for use in NHS Wales."
      },
      {
        "id": "DocumentReference.extension:versionR5",
        "path": "DocumentReference.extension",
        "sliceName": "versionR5",
        "short": "R5: An explicitly assigned identifer of a variation of the content in the DocumentReference",
        "definition": "R5: `DocumentReference.version`.  This is a business version identifier, not a resource version id. (Backport from FHIR R5.)",
        "comment": "While each resource, including the DocumentReference itself, has its own version identifier, this is a formal identifier for the logical version of the DocumentReference as a whole. It would remain constant if the resources were moved to a new server, and all got new individual resource versions, for example.",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-DocumentReference.version"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "DocumentReference.extension:versionR5.extension",
        "path": "DocumentReference.extension.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.extension:versionR5.value[x]",
        "path": "DocumentReference.extension.value[x]",
        "definition": "An explicitly assigned identifer of a variation of the content in the DocumentReference.  This is a business version identifier, not a resource version id."
      },
      {
        "id": "DocumentReference.extension:attesterR5",
        "path": "DocumentReference.extension",
        "sliceName": "attesterR5",
        "short": "R5: Attests to accuracy of the document",
        "definition": "R5: `DocumentReference.attester`.  A participant who has authenticated the accuracy of the document.",
        "comment": "Only list each attester once.",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-DocumentReference.attester"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:mode",
        "path": "DocumentReference.extension.extension",
        "sliceName": "mode",
        "short": "R5: personal | professional | legal | official",
        "definition": "R5: `DocumentReference.attester.mode`. Indicates the level of authority of the attestation.",
        "comment": "Element `DocumentReference.attester.mode` is part of an existing definition because parent element `DocumentReference.attester` requires a cross-version extension.",
        "requirements": "Indicates the level of authority of the attestation. Element `DocumentReference.attester.mode` is part of an existing definition because parent element `DocumentReference.attester` requires a cross-version extension."
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:mode.extension",
        "path": "DocumentReference.extension.extension.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:time",
        "path": "DocumentReference.extension.extension",
        "sliceName": "time",
        "short": "R5: When the document was attested",
        "definition": "R5: `DocumentReference.attester.time`. Identifies when the information in the document was deemed accurate.  (Things may have changed since then.)",
        "comment": "Element `DocumentReference.attester.time` is part of an existing definition because parent element `DocumentReference.attester` requires a cross-version extension.",
        "requirements": "Element `DocumentReference.attester.time` is part of an existing definition because parent element `DocumentReference.attester` requires a cross-version extension."
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:time.extension",
        "path": "DocumentReference.extension.extension.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:party",
        "path": "DocumentReference.extension.extension",
        "sliceName": "party",
        "definition": "R5: `DocumentReference.attester.party`. Identifies who has taken on the responsibility for accuracy of the document content.",
        "comment": "Element `DocumentReference.attester.party` is part of an existing definition because parent element `DocumentReference.attester` requires a cross-version extension.",
        "requirements": "Element `DocumentReference.attester.party` is part of an existing definition because parent element `DocumentReference.attester` requires a cross-version extension."
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:party.extension",
        "path": "DocumentReference.extension.extension.extension",
        "max": "0"
      },
      {
        "id": "DocumentReference.extension:attesterR5.extension:party.value[x]",
        "path": "DocumentReference.extension.extension.value[x]",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Patient",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Practitioner",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PractitionerRole",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.masterIdentifier",
        "path": "DocumentReference.masterIdentifier",
        "max": "0"
      },
      {
        "id": "DocumentReference.identifier",
        "path": "DocumentReference.identifier",
        "slicing": {
          "description": "Slices provided for the different types of identifiers supported by the NHS Wales Care Documents Service.",
          "rules": "open"
        },
        "mustSupport": true
      },
      {
        "id": "DocumentReference.identifier:documentId",
        "path": "DocumentReference.identifier",
        "sliceName": "documentId",
        "short": "The version-specific document identifier.",
        "definition": "The version-specific document identifier, centrally generated by the NHS Wales Care Documents Service.",
        "max": "1"
      },
      {
        "id": "DocumentReference.identifier:documentId.system",
        "path": "DocumentReference.identifier.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.wales/Id/document-identifier",
        "example": [
          {
            "label": "Care Documents Service (fixed for slice)",
            "valueUri": "https://fhir.nhs.wales/Id/document-identifier"
          }
        ]
      },
      {
        "id": "DocumentReference.identifier:documentId.value",
        "path": "DocumentReference.identifier.value",
        "comment": "A UUID version 7 identifier in all cases.",
        "min": 1,
        "example": [
          {
            "label": "Care Documents Service documentId",
            "valueString": "019efd68-0230-75d4-abab-af73d057f0f8"
          }
        ]
      },
      {
        "id": "DocumentReference.identifier:supersessionSetId",
        "path": "DocumentReference.identifier",
        "sliceName": "supersessionSetId",
        "short": "The version-independent document identifier.",
        "definition": "The version-independent document identifier, centrally generated by the NHS Wales Care Documents Service.",
        "max": "1"
      },
      {
        "id": "DocumentReference.identifier:supersessionSetId.system",
        "path": "DocumentReference.identifier.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.wales/Id/supersession-set-identifier",
        "example": [
          {
            "label": "Care Documents Service (fixed for slice)",
            "valueUri": "https://fhir.nhs.wales/Id/supersession-set-identifier"
          }
        ]
      },
      {
        "id": "DocumentReference.identifier:supersessionSetId.value",
        "path": "DocumentReference.identifier.value",
        "comment": "A UUID version 7 identifier in all cases.",
        "min": 1,
        "example": [
          {
            "label": "Care Documents Service supersessionSetId",
            "valueString": "019efd68-0230-75d4-abab-af73d057f0f8"
          }
        ]
      },
      {
        "id": "DocumentReference.identifier:externalSupersessionSetId",
        "path": "DocumentReference.identifier",
        "sliceName": "externalSupersessionSetId",
        "short": "The external (source system) identifier for the document.",
        "definition": "The version-independent document supersession set identifier issued by the source system.",
        "max": "1"
      },
      {
        "id": "DocumentReference.identifier:externalSupersessionSetId.system",
        "path": "DocumentReference.identifier.system",
        "min": 1,
        "fixedUri": "https://fhir.nhs.wales/Id/external-supersession-set-identifier",
        "example": [
          {
            "label": "Care Documents Service (fixed value)",
            "valueUri": "https://fhir.nhs.wales/Id/external-supersession-set-identifier"
          }
        ]
      },
      {
        "id": "DocumentReference.identifier:externalSupersessionSetId.value",
        "path": "DocumentReference.identifier.value",
        "definition": "A composite identifier value identifying both the source system and the unique identifier for the document within that system, independent of the document version.",
        "comment": "The value is constructed using the three digit issuing authority code for the source system, followed by the unique identifier issued by that system.  The two components are tilde (~) separated.",
        "min": 1,
        "example": [
          {
            "label": "Care Documents Service externalSupersessionSetId",
            "valueString": "231~660756"
          }
        ]
      },
      {
        "id": "DocumentReference.docStatus",
        "path": "DocumentReference.docStatus",
        "mustSupport": true
      },
      {
        "id": "DocumentReference.type",
        "path": "DocumentReference.type",
        "short": "Kind of document",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "https://fhir.nhs.wales/ValueSet/DataStandardsWales-DocumentType"
        }
      },
      {
        "id": "DocumentReference.category",
        "path": "DocumentReference.category",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "https://fhir.nhs.wales/ValueSet/DataStandardsWales-DocumentCategory"
        }
      },
      {
        "id": "DocumentReference.subject",
        "path": "DocumentReference.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Patient",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Practitioner",
              "http://hl7.org/fhir/StructureDefinition/Group",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Device"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "DocumentReference.date",
        "path": "DocumentReference.date",
        "mustSupport": true
      },
      {
        "id": "DocumentReference.author",
        "path": "DocumentReference.author",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Practitioner",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PractitionerRole",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Device",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Patient",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-RelatedPerson"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "DocumentReference.authenticator",
        "path": "DocumentReference.authenticator",
        "max": "0",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Practitioner",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PractitionerRole",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization"
            ]
          }
        ],
        "mustSupport": false
      },
      {
        "id": "DocumentReference.custodian",
        "path": "DocumentReference.custodian",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "DocumentReference.relatesTo.target",
        "path": "DocumentReference.relatesTo.target",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-DocumentReference"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.securityLabel",
        "path": "DocumentReference.securityLabel",
        "mustSupport": true
      },
      {
        "id": "DocumentReference.content.attachment.language",
        "path": "DocumentReference.content.attachment.language",
        "short": "Human language of the content",
        "definition": "The human language of the content. Within NHS Wales, the three character ISO 639-3 code should be used where possible e.g. \"eng\" for English, \"cym\" for Welsh.",
        "requirements": "Users need to be able to choose between the languages in a set of attachments. ISO 639-3 is a subset of the BCP 47 standard."
      },
      {
        "id": "DocumentReference.content.format",
        "path": "DocumentReference.content.format",
        "definition": "An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType. This optional field is not part of the formal metadata standard for document submission in Wales.  It should not be confused with mime type which is stored as content.attachment.contentType."
      },
      {
        "id": "DocumentReference.context.encounter",
        "path": "DocumentReference.context.encounter",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Encounter",
              "http://hl7.org/fhir/StructureDefinition/EpisodeOfCare"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.context.practiceSetting",
        "path": "DocumentReference.context.practiceSetting",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://fhir.hl7.org.uk/ValueSet/UKCore-CareSettingType"
        }
      },
      {
        "id": "DocumentReference.context.sourcePatientInfo",
        "path": "DocumentReference.context.sourcePatientInfo",
        "max": "0",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Patient"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.context.related",
        "path": "DocumentReference.context.related",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Resource",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Practitioner",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-PractitionerRole",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Organization",
              "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Location"
            ]
          }
        ]
      }
    ]
  }
}