15.2.162. camcops_server.cc_modules.cc_taskfilter


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/>.

Representation of filtering criteria for tasks.

class camcops_server.cc_modules.cc_taskfilter.TaskClassSortMethod(value)[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.


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.

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.


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() Optional[IdNumReference][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.


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?

property task_classes: List[Type[camcops_server.cc_modules.cc_task.Task]]

Return a list of task classes permitted by the filter.

Uses caching, since the filter will be called repeatedly.

property task_tablename_list: List[str]

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.

camcops_server.cc_modules.cc_taskfilter.task_classes_from_table_names(tablenames: List[str], sortmethod: camcops_server.cc_modules.cc_taskfilter.TaskClassSortMethod = TaskClassSortMethod.NONE) 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.


a list of task classes, in the order requested