14.2.104. camcops_server.cc_modules.cc_taskfilter

camcops_server/cc_modules/cc_taskfilter.py


Copyright (C) 2012-2019 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 <http://www.gnu.org/licenses/>.


Representation of filtering criteria for tasks.

class camcops_server.cc_modules.cc_taskfilter.TaskClassSortMethod[source]

Enum to represent ways to sort task types (classes).

class camcops_server.cc_modules.cc_taskfilter.TaskFilter[source]

SQLAlchemy ORM object representing task filter criteria.

any_patient_filtering() → bool[source]

Is some sort of patient filtering being applied?

any_specific_patient_filtering() → bool[source]

Are there filters that would restrict to one or a few patients?

(Differs from any_patient_filtering() with respect to sex.)

clear() → None[source]

Clear all parts of the filter.

dates_inconsistent() → bool[source]

Are inconsistent dates specified, such that no tasks should be returned?

filter_query_by_patient(q: sqlalchemy.orm.query.Query, via_index: bool) → sqlalchemy.orm.query.Query[source]

Restricts an query that has already been joined to the camcops_server.cc_modules.cc_patient.Patient class, according to the patient filtering criteria.

Parameters:
Returns:

a revised Query

get_device_names(req: CamcopsRequest) → List[str][source]

Get the names of any devices to which we are restricting.

get_group_names(req: CamcopsRequest) → List[str][source]

Get the names of any groups to which we are restricting.

get_only_iddef() → Union[_ForwardRef('IdNumReference'), NoneType][source]

If a single ID number type/value restriction is being applied, return it, as an camcops_server.cc_modules.cc_simpleobjects.IdNumReference. Otherwise, return None.

get_user_names(req: CamcopsRequest) → List[str][source]

Get the usernames of any uploading users to which we are restricting.

init_on_load()[source]

SQLAlchemy function to recreate after loading from the database.

offers_all_non_anonymous_task_types() → bool[source]

Does this filter offer every single non-anonymous task class? Used for efficiency when using indexes.

offers_all_task_types() → bool[source]

Does this filter offer every single task class? Used for efficiency when using indexes. (Since ignored.)

set_sort_method(sort_method: camcops_server.cc_modules.cc_taskfilter.TaskClassSortMethod) → None[source]

Sets the sorting method for task types.

skip_anonymous_tasks() → bool[source]

Should we skip anonymous tasks?

task_classes

Return a list of task classes permitted by the filter.

Uses caching, since the filter will be called repeatedly.

task_tablename_list

Returns the base table names for all task types permitted by the filter.

camcops_server.cc_modules.cc_taskfilter.all_tracker_task_classes() → List[Type[camcops_server.cc_modules.cc_task.Task]][source]

Returns a list of all task classes that provide tracker information.

camcops_server.cc_modules.cc_taskfilter.sort_task_classes_in_place(classlist: List[Type[camcops_server.cc_modules.cc_task.Task]], sortmethod: camcops_server.cc_modules.cc_taskfilter.TaskClassSortMethod, req: CamcopsRequest = None) → None[source]

Sort a list of task classes in place.

Parameters:
camcops_server.cc_modules.cc_taskfilter.task_classes_from_table_names(tablenames: List[str], sortmethod: camcops_server.cc_modules.cc_taskfilter.TaskClassSortMethod = <TaskClassSortMethod.NONE: 0>) → List[Type[camcops_server.cc_modules.cc_task.Task]][source]

Transforms a list of task base tablenames into a list of task classes, appropriately sorted.

Parameters:
Returns:

a list of task classes, in the order requested

Raises:

KeyError if a table name is invalid