{
  "resourceType": "StructureDefinition",
  "url": "https://fhir.nhs.wales/StructureDefinition/CDR-Patient-Bronze",
  "name": "CDRPatientBronze",
  "status": "draft",
  "description": "Constrains the Data Standards Wales Patient profile for application-managed Patient records held within the Care Data Repository (CDR). These records are created and maintained by source applications where an appropriate WDS-managed or PAS-managed Patient record is not available.",
  "purpose": "Defines the requirements for application-managed Patient records within the CDR, including the use of a CDR application patient identifier and identification of the source application responsible for managing the record. This supports applications that need to create and maintain a Patient record independently of WDS or PAS, such as the Choose Pharmacy application",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Patient",
  "baseDefinition": "https://fhir.nhs.wales/StructureDefinition/DataStandardsWales-Patient",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Patient.identifier",
        "path": "Patient.identifier",
        "slicing": {
          "rules": "open"
        },
        "min": 1,
        "max": "1"
      },
      {
        "id": "Patient.identifier:nhsNumber",
        "path": "Patient.identifier",
        "sliceName": "nhsNumber",
        "max": "0"
      },
      {
        "id": "Patient.identifier:abuhbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "abuhbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:bcuhbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "bcuhbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:cavuhbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "cavuhbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:ctmuhbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "ctmuhbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:hduhbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "hduhbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:pthbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "pthbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:sbuhbPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "sbuhbPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:vunhstCaniscIdentifier",
        "path": "Patient.identifier",
        "sliceName": "vunhstCaniscIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:vunhstPasIdentifier",
        "path": "Patient.identifier",
        "sliceName": "vunhstPasIdentifier",
        "max": "0"
      },
      {
        "id": "Patient.identifier:applicationManagedPatientIdentifier",
        "path": "Patient.identifier",
        "sliceName": "applicationManagedPatientIdentifier",
        "definition": "An identifier for this patient. The applicationManagedPatientIdentifier SHALL use a UUID as its value to ensure that the combination of identifier system and value is globally unique.",
        "comment": "The applicationManagedPatientIdentifier SHALL use a UUID as its value to ensure that the combination of identifier system and value is globally unique.",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Patient.identifier:applicationManagedPatientIdentifier.system",
        "path": "Patient.identifier.system",
        "fixedUri": "https://fhir.nhs.wales/Id/cdr-application-patient-identifier"
      },
      {
        "id": "Patient.identifier:applicationManagedPatientIdentifier.value",
        "path": "Patient.identifier.value",
        "constraint": [
          {
            "key": "cdr-patient-2",
            "requirements": "The application-managed patient identifier SHALL be a UUID.",
            "severity": "error",
            "human": "cdr-patient-2",
            "expression": "matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')"
          }
        ]
      },
      {
        "id": "Patient.name",
        "path": "Patient.name",
        "comment": "A patient may have multiple names with different uses or applicable periods. For animals, the name is a \"HumanName\" in the sense that is assigned and used by humans and has the same patterns. This field is mandatory for CDR.",
        "min": 1
      },
      {
        "id": "Patient.gender",
        "path": "Patient.gender",
        "definition": "Administrative Gender - the gender that the patient is considered to have for administration and record keeping purposes. This field is mandatory for CDR.",
        "min": 1
      },
      {
        "id": "Patient.birthDate",
        "path": "Patient.birthDate",
        "comment": "At least an estimated year should be provided as a guess if the real DOB is unknown  There is a standard extension \"patient-birthTime\" available that should be used where Time is required (such as in maternity/infant care systems). This field is mandatory for CDR.",
        "min": 1
      },
      {
        "id": "Patient.address",
        "path": "Patient.address",
        "min": 1
      },
      {
        "id": "Patient.generalPractitioner",
        "path": "Patient.generalPractitioner",
        "max": "1"
      },
      {
        "id": "Patient.managingOrganization",
        "path": "Patient.managingOrganization",
        "max": "0"
      }
    ]
  }
}