15.2.107. camcops_server.cc_modules.cc_idnumdef

camcops_server/cc_modules/cc_idnumdef.py


Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com).

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='')[source]

Represents an ID number definition.

__init__(which_idnum=None, description='', short_description='', hl7_id_type='', hl7_assigning_authority='', validation_method='')

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). If method is falsy, that’s also valid (no constraints).

Parameters
Returns

valid, why_invalid where valid is bool and why_invalid is str.

Return type

tuple