14.1.14. crate_anon.anonymise.draft_dd

crate_anon/anonymise/draft_dd.py


Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).

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 <https://www.gnu.org/licenses/>.


Draft an anonymisation data dictionary.

crate_anon.anonymise.draft_dd.draft_dd(config: Config, dd_output_filename: str, incremental: bool = False, skip_dd_check: bool = False, explicit_dest_datatype: bool = False, systmone: bool = False, systmone_context: SystmOneContext | None = None, systmone_sre_spec_csv_filename: str | None = None, systmone_append_comments: bool = False, systmone_include_generic: bool = False, systmone_allow_unprefixed_tables: bool = False, systmone_alter_loaded_rows: bool = False, systmone_table_info_in_comments: bool = True) None[source]

Draft a data dictionary, by scanning a source database.

Parameters:
  • config – Anonymisation config object.

  • incremental – If true: make it an incremental data dictionary, using only fields present in the database but absent from the existing data dictionary referred to in the config.

  • dd_output_filename – File for output (‘-’ for stdout).

  • skip_dd_check – If true: skip data dictionary validity check when loading the pre-existing data dictionary in “incremental” mode.

  • explicit_dest_datatype – Make destination datatypes explicit, not implicit. (Primarily for debugging.)

  • systmone – Process data dictionary for SystmOne data?

  • systmone_context – (For SystmOne.) Source database context for SystmOne use.

  • systmone_sre_spec_csv_filename – (For SystmOne.) Optional filename for TPP Strategic Reporting Extract (SRE) specification CSV.

  • systmone_append_comments – (For SystmOne.) Append, rather than replacing, existing comments? Usually better as False – if you use systmone_sre_spec_csv_filename, this will provide better comments.

  • systmone_include_generic – (For SystmOne.) Include all fields that are not known about by this code and treated specially? If False, the config file settings are used (which may omit or include). If True, all such fields are included.

  • systmone_allow_unprefixed_tables – (For SystmOne.) Permit tables that don’t start with the expected prefix? (That prefix is e.g. ‘SR’ for the TPP SRE context, ‘S1_’ for the CPFT Data Warehouse context.) Discouraged; you may get odd tables and views.

  • systmone_alter_loaded_rows – Alter rows that were loaded from disk (not read from a database)? The default is to leave such rows untouched.

  • systmone_table_info_in_comments – Include table descriptions in column comments?

crate_anon.anonymise.draft_dd.main() None[source]

Command-line entry point.