{
  "resourceType": "StructureDefinition",
  "id": "DataStandardsWales-DocumentReference",
  "url": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-DocumentReference",
  "version": "1.0.0",
  "name": "DataStandardsWalesDocumentReference",
  "title": "Data Standards Wales Document Reference",
  "status": "active",
  "experimental": false,
  "date": "2026-05-26",
  "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.  It can be used to store the SetSequenceNumber of a document from the Welsh Care Records Service. (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.   It can be used to store the SetSequenceNumber of a document from the Welsh Care Records Service."
      },
      {
        "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 national identifiers issued by the Welsh Care Records Service.",
          "rules": "open"
        },
        "mustSupport": true
      },
      {
        "id": "DocumentReference.identifier:wcrsDocumentId",
        "path": "DocumentReference.identifier",
        "sliceName": "wcrsDocumentId",
        "short": "The WCRS DocumentId.",
        "definition": "The version-specific DocumentId issued by the Welsh Care Records Service.",
        "max": "1"
      },
      {
        "id": "DocumentReference.identifier:wcrsDocumentId.system",
        "path": "DocumentReference.identifier.system",
        "fixedUri": "https://fhir.nhs.wales/Id/wcrs-document-identifier"
      },
      {
        "id": "DocumentReference.identifier:wcrsSupersessionSetId",
        "path": "DocumentReference.identifier",
        "sliceName": "wcrsSupersessionSetId",
        "short": "The WCRS DocumentSupersessionSetId.",
        "definition": "The version-independent DocumentSupersessionSetId issued by the Welsh Care Records Service.",
        "max": "1"
      },
      {
        "id": "DocumentReference.identifier:wcrsSupersessionSetId.system",
        "path": "DocumentReference.identifier.system",
        "fixedUri": "https://fhir.nhs.wales/Id/wcrs-supersession-set-identifier"
      },
      {
        "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-PracticeSettingCode"
        }
      },
      {
        "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"
            ]
          }
        ]
      }
    ]
  }
}