{
  "resourceType": "StructureDefinition",
  "id": "DataStandardsWales-DocumentReference",
  "url": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-DocumentReference",
  "version": "0.1.0",
  "name": "DataStandardsWalesDocumentReference",
  "title": "Data Standards Wales Document Reference",
  "status": "draft",
  "experimental": false,
  "date": "2026-02-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",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentDigitalStatus"
            ]
          }
        ],
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:sourceSystem",
        "path": "DocumentReference.extension",
        "sliceName": "sourceSystem",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-SourceSystem"
            ]
          }
        ],
        "mustSupport": true,
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:versionR5",
        "path": "DocumentReference.extension",
        "sliceName": "versionR5",
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentReference.version"
            ]
          }
        ],
        "mustSupport": true,
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:attesterR5",
        "path": "DocumentReference.extension",
        "sliceName": "attesterR5",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentReference.attester"
            ]
          }
        ],
        "mustSupport": true,
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:errorStatus",
        "path": "DocumentReference.extension",
        "sliceName": "errorStatus",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentErrorStatus"
            ]
          }
        ],
        "mustSupport": true,
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:errorAction",
        "path": "DocumentReference.extension",
        "sliceName": "errorAction",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentErrorAction"
            ]
          }
        ],
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:documentAttribute",
        "path": "DocumentReference.extension",
        "sliceName": "documentAttribute",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.nhs.wales/StructureDefinition/Extension-DataStandardsWales-DocumentAttribute"
            ]
          }
        ],
        "isModifier": false
      },
      {
        "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"
            ]
          }
        ]
      }
    ]
  }
}