15.1.16. crate_anon.anonymise.patient


Copyright (C) 2015-2018 Rudolf Cardinal (rudolf@pobox.com).

This file is part of CRATE.

CRATE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CRATE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CRATE. If not, see <http://www.gnu.org/licenses/>.


Patient class for CRATE anonymiser.

class crate_anon.anonymise.patient.Patient(pid: Union[int, str], debug: bool = False)[source]

Class representing a patient-specific information, such as PIDs, RIDs, and scrubbers.

get_mpid() → Union[int, str][source]

Return the master patient ID (MPID).

get_mrid() → str[source]

Returns the master RID (encrypted MPID).

get_pid() → Union[int, str][source]

Return the patient ID (PID).

get_rid() → str[source]

Returns the RID (encrypted PID).

get_trid() → int[source]

Returns the transient integer RID (TRID).

unchanged() → bool[source]

Has the scrubber changed, compared to the previous hashed version in the admin database?

crate_anon.anonymise.patient.gen_all_values_for_patient(dbname: str, tablename: str, fields: List[str], pid: Union[int, str]) → Generator[[List[Any], NoneType], NoneType][source]

Generate all sensitive (scrub_src) values for a given patient, from a given source table. Used to build the scrubber.

dbname: source database name table: source table fields: source fields containing scrub_src information pid: patient ID

Yields rows, where each row is a list of values that matches “fields”.