{
  "resourceType": "StructureDefinition",
  "id": "DataStandardsWales-DocumentReference",
  "url": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-DocumentReference",
  "version": "0.0.1",
  "name": "DataStandardsWalesDocumentReference",
  "title": "Data Standards Wales Document Reference",
  "status": "draft",
  "experimental": true,
  "date": "2025-08-18",
  "publisher": "NHS Wales",
  "copyright": "2025 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": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-DocumentReference.version"
            ]
          }
        ],
        "mustSupport": true,
        "isModifier": false
      },
      {
        "id": "DocumentReference.extension:attesterR5",
        "path": "DocumentReference.extension",
        "sliceName": "attesterR5",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-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",
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "https://fhir.nhs.wales/ValueSet/DataStandardsWales-DocumentType"
        }
      },
      {
        "id": "DocumentReference.category",
        "path": "DocumentReference.category",
        "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.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://simplifier.net/hl7-fhir--uk-core-r4-stu2-sequence2/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"
            ]
          }
        ]
      }
    ]
  }
}