{
  "resourceType": "StructureDefinition",
  "id": "va-pghd-patient-base-v1.0",
  "url": "https://veteran.apps.va.gov/smart-pgd-fhir/v2/StructureDefinition/va-pghd-patient-base-v1.0",
  "version": "1.0",
  "name": "VAPghdPatientProfileBase",
  "title": "VA PGHD Patient Base Profile for Mobile App Data",
  "status": "active",
  "date": "2022-09-01",
  "description": "VA PGHD Patient base profile defining the common constraints for all PGHD patients. It should have at least 1 ICN identifier with ICN type, and the right VA ICN system (urn:oid:2.16.840.1.113883.4.349) and ICN value format ([0-9]{10}V[0-9]{6}). The local identifier type code - ICN is defined in the VA PGHD code system.",
  "purpose": "This is the PGHD patient base profile defining the common constraints for all VA PGHD patient profiles. Other PGHD patient profiles should derive from this base profile. It requires at least 1 ICN identifier with 'ICN' type.",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Patient",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Patient",
        "path": "Patient",
        "short": "PGHD Governance Rules for Patients",
        "constraint": [
          {
            "key": "pghd-meta-tag-1",
            "severity": "error",
            "human": "A Patient must have exactly one meta tag, with system = 'https://wiki.mobilehealth.va.gov/x/Onc1C', a code, and a display value",
            "expression": "meta.tag.count() = 1 and meta.tag.exists(system = 'https://wiki.mobilehealth.va.gov/x/Onc1C' and code.exists() and display.exists())"
          },
          {
            "key": "pghd-patient-identifier-1",
            "severity": "error",
            "human": "A Patient identifier must have both system and value properties",
            "expression": "identifier.all(system.exists() and value.exists())"
          },
          {
            "key": "pghd-patient-identifier-icn-1",
            "severity": "error",
            "human": "A Patient must have exactly one ICN identifier, having type.text or type.coding.code = 'ICN', system = 'urn:oid:2.16.840.1.113883.4.349' or 'urn:uuid:2.16.840.1.113883.4.349', and a value matching 0000000000V000000 (where 0 indicates a decimal digit)",
            "expression": "(identifier.where((type.text = 'ICN' or type.coding.where(code = 'ICN').count() = 1) and 'urn:oid:2.16.840.1.113883.4.349,urn:uuid:2.16.840.1.113883.4.349'.contains($this.system) and value.matches('[0-9]{10}V[0-9]{6}'))).count() = 1"
          },
          {
            "key": "pghd-patient-identifier-icn-2",
            "severity": "warning",
            "human": "Patient ICN system of 'urn:uuid:2.16.840.1.113883.4.349' is deprecated; use system 'urn:oid:2.16.840.1.113883.4.349' instead",
            "expression": "identifier.exists(system = 'urn:uuid:2.16.840.1.113883.4.349').not()"
          },
          {
            "key": "pghd-patient-identifier-type-1",
            "severity": "warning",
            "human": "Patient identifier type.text is deprecated; use type.coding instead",
            "expression": "identifier.type.text.exists().not()"
          },
          {
            "key": "pghd-patient-identifier-type-2",
            "severity": "error",
            "human": "Patient identifier type.text and type.coding.code values must be one of 'ICN', 'VALIDIC', OR 'EDIPI'",
            "expression": "identifier.all((type.text.exists() implies 'ICN,VALIDIC,EDIPI'.contains($this.type.text)))"
          },
          {
            "key": "pghd-patient-identifier-type-3",
            "severity": "error",
            "human": "Patient identifier type must have exactly one of text or coding properties",
            "expression": "(identifier.type.text.exists() and identifier.type.coding.exists()).not()"
          },
          {
            "key": "pghd-patient-codesystem-1",
            "severity": "warning",
            "human": "CodeSystem url https://mobile.va.gov/fhir/codesystem/pghd is deprecated; use https://connectedcare.va.gov/pghd/code-system-v1.1 instead",
            "expression": "identifier.type.coding.exists(system = 'https://mobile.va.gov/fhir/codesystem/pghd').not()"
          }
        ]
      },
      {
        "id": "Patient.identifier.type",
        "path": "Patient.identifier.type",
        "binding": {
          "strength": "required",
          "description": "PGHD identifier types.",
          "valueSet": "https://veteran.apps.va.gov/smart-pgd-fhir/v2/ValueSet/va-pghd-identifier-type-v1.0"
        }
      }
    ]
  }
}