{
  "resourceType": "StructureDefinition",
  "id": "profile-Patient-base",
  "url": "https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-base",
  "name": "PatientBase",
  "title": "Recipient Base Profile",
  "status": "active",
  "experimental": false,
  "description": "Information about a recipient used across all use cases",
  "fhirVersion": "5.0.0",
  "mapping": [
    {
      "identity": "BPCS",
      "name": "Internal BPCS API"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Patient",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Patient.meta",
        "path": "Patient.meta"
      },
      {
        "id": "Patient.meta.extension:effectiveDate",
        "path": "Patient.meta.extension",
        "sliceName": "effectiveDate",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://bpcs.exchange/fhir/StructureDefinition/ext-Meta-effectiveDate"
            ]
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.effModDt, RecipientDTO.recEffDate (which it maps to depends on whether the record represents a create or an update)"
          }
        ]
      },
      {
        "id": "Patient.extension:contactApplicationMember",
        "path": "Patient.extension",
        "sliceName": "contactApplicationMember",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://bpcs.exchange/fhir/StructureDefinition/ext-Patient-ContactApplicationMemberFlag"
            ]
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.contactApplicationMember"
          }
        ]
      },
      {
        "id": "Patient.identifier",
        "path": "Patient.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "use"
            },
            {
              "type": "value",
              "path": "type"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Patient.identifier:odbNum",
        "path": "Patient.identifier",
        "sliceName": "odbNum",
        "constraint": [
          {
            "key": "bpcs-odb1",
            "severity": "error",
            "human": "Must have an ODB number value unless the system is for an associate family member, in which case it can be empty when creating a recipient",
            "expression": "value.empty() implies system='https://bpcs.exchange/fhir/NamingSystem/afm'"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Patient.identifier:odbNum.use",
        "path": "Patient.identifier.use",
        "comment": "Distinguishes current ODBNumber from cross-reference numbers",
        "min": 1,
        "patternCode": "official",
        "mustSupport": true
      },
      {
        "id": "Patient.identifier:odbNum.system",
        "path": "Patient.identifier.system",
        "short": "Distinguishes type of primary identifier",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://bpcs.exchange/fhir/ValueSet/vs-ODBTypes"
        },
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.odbFlag, FamilyMemberDTO.odbFlag"
          }
        ]
      },
      {
        "id": "Patient.identifier:odbNum.value",
        "path": "Patient.identifier.value",
        "maxLength": 10,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.odbNum, FamilyMemberDTO.odbNum, ContactDTO.odbNum, FamilyHistoryDTO.contactOdbEligNo"
          }
        ]
      },
      {
        "id": "Patient.identifier:xref",
        "path": "Patient.identifier",
        "sliceName": "xref",
        "definition": "Alternate PHNs",
        "mustSupport": true
      },
      {
        "id": "Patient.identifier:xref.use",
        "path": "Patient.identifier.use",
        "comment": "Distinguishes current ODBNumber from cross-reference numbers",
        "min": 1,
        "patternCode": "old",
        "mustSupport": true
      },
      {
        "id": "Patient.identifier:xref.system",
        "path": "Patient.identifier.system",
        "short": "Distinguishes type of xref identifier",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://bpcs.exchange/fhir/ValueSet/vs-ODBTypes"
        },
        "mapping": [
          {
            "identity": "BPCS",
            "map": "CrossReferenceValuesDTO.idType"
          }
        ]
      },
      {
        "id": "Patient.identifier:xref.value",
        "path": "Patient.identifier.value",
        "min": 1,
        "maxLength": 10,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "CrossReferenceValuesDTO.id"
          }
        ]
      },
      {
        "id": "Patient.name",
        "path": "Patient.name",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.name.family",
        "path": "Patient.name.family",
        "min": 1,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.lastName, FamilyMemberDTO.lastName, ContactDTO.lastName"
          }
        ]
      },
      {
        "id": "Patient.name.given",
        "path": "Patient.name.given",
        "comment": "First name is first repetition, middle name is second repetition",
        "min": 1,
        "max": "2",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.firstName, RecipientDTO.middleName, FamilyMemberDTO.firstName, FamilyMemberDTO.lastName, ContactDTO.firstName, ContactDTO.lastName"
          }
        ]
      },
      {
        "id": "Patient.telecom",
        "path": "Patient.telecom",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            },
            {
              "type": "value",
              "path": "use"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.telecom:homePhone",
        "path": "Patient.telecom",
        "sliceName": "homePhone",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.telecom:homePhone.system",
        "path": "Patient.telecom.system",
        "min": 1,
        "patternCode": "phone"
      },
      {
        "id": "Patient.telecom:homePhone.value",
        "path": "Patient.telecom.value",
        "min": 1,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO.telephone, RecipientAddressDTO.phone (last 7 characters), RecipientAddressDTO.telephoneArea (1st 3 characters), ContactDTO.homePhoneNum"
          }
        ]
      },
      {
        "id": "Patient.telecom:homePhone.use",
        "path": "Patient.telecom.use",
        "min": 1,
        "patternCode": "home"
      },
      {
        "id": "Patient.telecom:workPhone",
        "path": "Patient.telecom",
        "sliceName": "workPhone",
        "comment": "Work phone numbers are only captured if the recipient is the 'contact' for a family coverage",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.telecom:workPhone.system",
        "path": "Patient.telecom.system",
        "min": 1,
        "patternCode": "phone"
      },
      {
        "id": "Patient.telecom:workPhone.value",
        "path": "Patient.telecom.value",
        "comment": "If there is an extension, separate concatenate it with ' ext:' as a separator from the base number.",
        "min": 1,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "ContactDTO.workPhoneNum, ContactDTO.workPhoneExt"
          }
        ]
      },
      {
        "id": "Patient.telecom:workPhone.use",
        "path": "Patient.telecom.use",
        "min": 1,
        "patternCode": "work"
      },
      {
        "id": "Patient.telecom:email",
        "path": "Patient.telecom",
        "sliceName": "email",
        "short": "A contact email for the individual",
        "definition": "A contact email(e.g. a telephone number or an email address) by which the individual may be contacted.",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.telecom:email.system",
        "path": "Patient.telecom.system",
        "patternCode": "email",
        "mustSupport": true
      },
      {
        "id": "Patient.telecom:email.value",
        "path": "Patient.telecom.value",
        "mustSupport": true
      },
      {
        "id": "Patient.gender",
        "path": "Patient.gender",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://bpcs.exchange/fhir/ValueSet/vs-administrative-gender"
        },
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.sex, FamilyMemberDTO.sex"
          }
        ]
      },
      {
        "id": "Patient.birthDate",
        "path": "Patient.birthDate",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.birthDate, FamilyMemberDTO.birthDate"
          }
        ]
      },
      {
        "id": "Patient.deceased[x]",
        "path": "Patient.deceased[x]",
        "type": [
          {
            "code": "dateTime"
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.deathDate, FamilyMemberDTO.deathDate"
          }
        ]
      },
      {
        "id": "Patient.address",
        "path": "Patient.address",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "type"
            }
          ],
          "rules": "open"
        },
        "mustSupport": true
      },
      {
        "id": "Patient.address:mailing",
        "path": "Patient.address",
        "sliceName": "mailing",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO"
          }
        ]
      },
      {
        "id": "Patient.address:mailing.type",
        "path": "Patient.address.type",
        "min": 1,
        "patternCode": "postal"
      },
      {
        "id": "Patient.address:mailing.line",
        "path": "Patient.address.line",
        "short": "First line of an address. Usually will contain the street number and street name. Second line of an address. Usually will contain an apartment number, rural route or other similar information.",
        "min": 1,
        "max": "2",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO.address1 (1st repetition), RecipientAddressDTO.address2 (2nd repetition)"
          }
        ]
      },
      {
        "id": "Patient.address:mailing.city",
        "path": "Patient.address.city",
        "min": 1,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO.city"
          }
        ]
      },
      {
        "id": "Patient.address:mailing.state",
        "path": "Patient.address.state",
        "min": 1,
        "maxLength": 2,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://bpcs.exchange/fhir/ValueSet/vs-Province"
        },
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO.province"
          }
        ]
      },
      {
        "id": "Patient.address:mailing.postalCode",
        "path": "Patient.address.postalCode",
        "min": 1,
        "maxLength": 10,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO.postalCode"
          }
        ]
      },
      {
        "id": "Patient.address:mailing.country",
        "path": "Patient.address.country",
        "min": 1,
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://bpcs.exchange/fhir/ValueSet/vs-Country"
        },
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientAddressDTO.country"
          }
        ]
      },
      {
        "id": "Patient.communication",
        "path": "Patient.communication",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.communication.language",
        "path": "Patient.communication.language",
        "mustSupport": true,
        "binding": {
          "strength": "required",
          "valueSet": "https://bpcs.exchange/fhir/ValueSet/vs-Language"
        }
      },
      {
        "id": "Patient.communication.language.coding",
        "path": "Patient.communication.language.coding",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Patient.communication.language.coding.system",
        "path": "Patient.communication.language.coding.system",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Patient.communication.language.coding.code",
        "path": "Patient.communication.language.coding.code",
        "min": 1,
        "mustSupport": true,
        "mapping": [
          {
            "identity": "BPCS",
            "map": "RecipientDTO.language"
          }
        ]
      },
      {
        "id": "Patient.communication.preferred",
        "path": "Patient.communication.preferred",
        "patternBoolean": true,
        "mustSupport": true
      }
    ]
  }
}