15.2.126. camcops_server.cc_modules.cc_idnumdef¶
camcops_server/cc_modules/cc_idnumdef.py
Copyright (C) 2012, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CamCOPS.
CamCOPS 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.
CamCOPS 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 CamCOPS. If not, see <https://www.gnu.org/licenses/>.
ID number definitions.
- class camcops_server.cc_modules.cc_idnumdef.IdNumDefinition(which_idnum=None, description='', short_description='', hl7_id_type='', hl7_assigning_authority='', validation_method='', fhir_id_system='')[source]¶
Represents an ID number definition.
- __init__(which_idnum=None, description='', short_description='', hl7_id_type='', hl7_assigning_authority='', validation_method='', fhir_id_system='')¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class camcops_server.cc_modules.cc_idnumdef.IdNumValidationMethod[source]¶
Constants representing ways that CamCOPS knows to validate ID numbers.
- camcops_server.cc_modules.cc_idnumdef.get_idnum_definitions(dbsession: sqlalchemy.orm.session.Session) List[camcops_server.cc_modules.cc_idnumdef.IdNumDefinition] [source]¶
Get all ID number definitions from the database, in order.
- camcops_server.cc_modules.cc_idnumdef.validate_id_number(req: CamcopsRequest, idnum: Optional[int], method: str) Tuple[bool, str] [source]¶
Validates an ID number according to a method (as per
IdNumValidationMethod
).If the number is
None
, that’s valid (that’s an ID policy failure, not a number validation failure). Ifmethod
is falsy, that’s also valid (no constraints).- Parameters
idnum – the ID number, or
None
method –
- Returns
valid, why_invalid
wherevalid
isbool
andwhy_invalid
isstr
.- Return type
tuple