Skip to main content

patient_identity

Deriving a BitfountPatientID from a patient's name and date of birth.

One derivation, shared by every step route that has name parts rather than a ready-made ID: ehr_query (which reads them off an EHR patient record) and patient_enrichment (which reads them off a supplied file). Both wrap generate_bitfount_patient_id, so a patient reaching us down either route — or down the imaging route that hashes a DICOM name directly — keys the same ID. A second derivation that drifted from it would split one patient into two across the caches that key on this value.

Module

Functions

bitfount_patient_id_from_name_dob

def bitfount_patient_id_from_name_dob(    name: str | None, dob: str | date | datetime | None,)> str | None:

Generate a BitfountPatientID from a full name and date of birth.

Wraps generate_bitfount_patient_id on a single-row DataFrame so every name-and-DOB route produces IDs identical to the imaging-file route.

A date of birth that will not parse is not rejected here: the underlying safe_format_date falls back to hashing the cell as written, so a dob of "N/A" or "unknown" returns a well-formed ID keyed on that literal string rather than None. A caller for whom the ID's purpose is to join to a patient identified elsewhere therefore gets an ID that joins to nobody, and cannot tell that from a real one; a caller that needs those rows rejected has to check the date itself before calling.

Arguments

  • name: The full name, in any form split_full_name accepts — typically the caret form full_name_from_parts builds.
  • dob: The date of birth, in any form pd.to_datetime accepts.

Returns The ID, or None when the name is missing, the name has no given and family pair to key on, the date of birth is missing, or generation fails.

full_name_from_parts

def full_name_from_parts(family_name: str | None, given_name: str | None)> str | None:

Build a full-name string from family/given name parts.

The parts are joined in the DICOM Family^Given form rather than with a space. Everything that consumes this string re-parses it with split_full_name, and a space-separated name is ambiguous there: it is read as Given Family, so "Doe Jane" would come back as given "Doe" and family "Jane". The caret form states which component is which, so the parts survive the round trip and this route derives the same BitfountPatientID as the imaging-file route does for the same patient.

Arguments

  • family_name: The family name, if the source states one.
  • given_name: The given name, if the source states one.

Returns The caret-joined name, or None when neither part is available.