14.3.19. crate_anon.crateweb.consent.lookup

crate_anon/crateweb/consent/lookup.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/>.


Core functions to look up patient details from a clinical database.

These functions then send the request to specialized functions according to which type of clinical database is in use.

crate_anon.crateweb.consent.lookup.gen_opt_out_pids_mpids(source_db: str) Generator[Tuple[int | str, int | str], None, None][source]

Generates PID/MPID information for all patients wishing to opt out of the anonymous database.

Parameters:

source_db – the type of the source database; see crate_anon.crateweb.config.constants.ClinicalDatabaseType

Yields:

tuplespid, mpid for each patient opting out

Returns the latest crate_anon.crateweb.consent.models.ConsentMode for this patient from the primary clinical source, or None. Writes to decisions as it goes.

Parameters:
Returns:

a crate_anon.crateweb.consent.models.ConsentMode or None

crate_anon.crateweb.consent.lookup.lookup_patient(nhs_number: int, source_db: str | None = None, save: bool = True, existing_ok: bool = False) PatientLookup[source]

Looks up details of a patient.

Parameters:
  • nhs_number – NHS number

  • source_db – the type of the source database; see crate_anon.crateweb.config.constants.ClinicalDatabaseType

  • save – save the lookup in our admin database?

  • existing_ok – if we have a lookup saved in our admin database, use that? (If False, fetch a new one from the primary source, regardless.)

Returns:

a crate_anon.crateweb.consent.models.PatientLookup