15.2.159. camcops_server.cc_modules.cc_task

camcops_server/cc_modules/cc_task.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/>.


Represents CamCOPS tasks.

Core task export methods:

Format

Comment

HTML

The task in a user-friendly format.

PDF

Essentially the HTML output, but with page headers and (for clinician tasks) a signature block, and without additional HTML administrative hyperlinks.

XML

Centres on the task with its subdata integrated.

TSV

Tab-separated value format.

SQL

As part of an SQL or SQLite download.

class camcops_server.cc_modules.cc_task.Task(**kwargs)[source]

Abstract base class for all tasks.

Note:

all_fields_not_none(fields: List[str]) bool[source]

Are all specified fields not None?

classmethod all_subclasses_by_longname(req: CamcopsRequest) List[Type[Task]][source]

Return all task classes, ordered by long name.

classmethod all_subclasses_by_shortname() List[Type[camcops_server.cc_modules.cc_task.Task]][source]

Return all task classes, ordered by short name.

classmethod all_subclasses_by_tablename() List[Type[camcops_server.cc_modules.cc_task.Task]][source]

Return all task classes, ordered by table name.

classmethod all_tables() List[sqlalchemy.sql.schema.Table][source]

Returns all table classes (primary table plus any ancillary tables).

classmethod all_tables_with_min_client_version() Dict[str, semantic_version.base.Version][source]

Returns a dictionary mapping all this task’s table names (primary and ancillary) to the corresponding minimum client version.

all_truthy(fields: List[str]) bool[source]

Do all the specified fields evaluate to True (are they all truthy)?

any_fields_none(fields: List[str]) bool[source]

Are any specified fields None?

any_fields_null_or_empty_str(fields: List[str]) bool[source]

Are any specified fields either None or the empty string?

any_patient_idnums_invalid(req: CamcopsRequest) bool[source]

Do we have a patient who has any invalid ID numbers?

Parameters

req – a camcops_server.cc_modules.cc_request.CamcopsRequest

apply_special_note(req: CamcopsRequest, note: str, from_console: bool = False) None[source]

Manually applies a special note to a task.

Applies it to all predecessor/successor versions as well. WRITES TO THE DATABASE.

are_all_fields_not_null_or_empty_str(fields: List[str]) bool[source]

Are all specified fields neither None nor the empty string?

audit(req: CamcopsRequest, details: str, from_console: bool = False) None[source]

Audits actions to this task.

cancel_from_export_log(req: CamcopsRequest, from_console: bool = False) None[source]

Marks all instances of this task as “cancelled” in the export log, so it will be resent.

contains_all_strings(strings: List[str]) bool[source]

Does this task contain all the specified strings?

Parameters

strings – list of strings; each string must be present in at least one of our text columns

Returns

are all strings present?

contains_text(text: str) bool[source]

Does this task contain the specified text?

Parameters

text – string that must be present in at least one of our text columns

Returns

is the strings present?

count_booleans(fields: List[str]) int[source]

How many of the specified fields evaluate to True (are truthy)?

count_where(fields: List[str], wherevalues: List[Any]) int[source]

Count how many values for the specified fields are in wherevalues.

count_wherenot(fields: List[str], notvalues: List[Any]) int[source]

Count how many values for the specified fields are NOT in notvalues.

delete_entirely(req: CamcopsRequest) None[source]

Completely delete this task, its lineage, and its dependants.

dump() None[source]

Dump a description of the task instance to the Python log, for debugging.

classmethod extrastrings_exist(req: CamcopsRequest) bool[source]

Does the server have any extra strings for this task?

property fhir_when_task_created: str

Time of task creation, in a FHIR-compatible format.

field_contents_invalid_because() List[str][source]

Explains why contents are invalid.

field_contents_valid() bool[source]

Checks field contents validity.

This is a high-speed function that doesn’t bother with explanations, since we use it for lots of task is_complete() calculations.

static fieldnames_from_list(prefix: str, suffixes: Iterable[Any]) List[str][source]

Returns a list of fieldnames made by appending each suffix to the prefix.

Parameters
  • prefix – string prefix

  • suffixes – list of suffixes, which will be coerced to str

Returns

list of fieldnames, as above

static fieldnames_from_prefix(prefix: str, start: int, end: int) List[str][source]

Returns a list of field (column, attribute) names from a prefix. For example, fieldnames_from_prefix("q", 1, 5) produces ["q1", "q2", "q3", "q4", "q5"].

Parameters
  • prefix – string prefix

  • start – first value (inclusive)

  • end – last value (inclusive

Returns

list of fieldnames, as above

classmethod gen_all_subclasses() Generator[Type[camcops_server.cc_modules.cc_task.Task], None, None][source]

Generate all non-abstract SQLAlchemy ORM subclasses of Task – that is, all task classes.

We require that actual tasks are subclasses of both Task and camcops_server.cc_modules.cc_sqlalchemy.Base.

OLD WAY (ignore): this means we can (a) inherit from Task to make an abstract base class for actual tasks, as with PCL, HADS, HoNOS, etc.; and (b) not have those intermediate classes appear in the task list. Since all actual classes must be SQLAlchemy ORM objects inheriting from Base, that common inheritance is an excellent way to define them.

NEW WAY: things now inherit from Base/Task without necessarily being actual tasks; we discriminate using __abstract__ and/or __tablename__. See https://docs.sqlalchemy.org/en/latest/orm/inheritance.html#abstract-concrete-classes

classmethod gen_text_filter_columns() Generator[Tuple[str, sqlalchemy.sql.schema.Column], None, None][source]

Yields tuples of attrname, column, for columns that are suitable for text filtering.

get_adding_user_id() Optional[int][source]

Returns the user ID of the user who uploaded this task.

get_adding_user_username() str[source]

Returns the username of the user who uploaded this task.

get_all_summary_tables(req: CamcopsRequest) List[camcops_server.cc_modules.cc_summaryelement.ExtraSummaryTable][source]

Returns all camcops_server.cc_modules.cc_summaryelement.ExtraSummaryTable objects for this class, including any provided by subclasses, plus SNOMED CT codes if enabled.

get_atext(req: CamcopsRequest, attrname: str, answer_value: int) Optional[str][source]

Returns the text associated with a particular answer to a question. The default implementation is a guess.

Parameters
get_blob_fields() List[str][source]

Returns field (column) names for all BLOB fields in this class.

get_clinical_text(req: CamcopsRequest) Optional[List[CtvInfo]][source]

Tasks that provide clinical text information should override this to provide a list of camcops_server.cc_modules.cc_ctvinfo.CtvInfo objects.

Return None (default) for a task that doesn’t provide clinical text, or [] for one that does in general but has no information for this particular instance, or a list of camcops_server.cc_modules.cc_ctvinfo.CtvInfo objects.

get_clinician_fhir_telecom_other(req: CamcopsRequest) str[source]

May be overridden by TaskHasClinicianMixin; q.v.

get_clinician_name() str[source]

May be overridden by TaskHasClinicianMixin; q.v.

get_creation_datetime() Optional[pendulum.datetime.DateTime][source]

Creation datetime, or None.

get_creation_datetime_utc() Optional[pendulum.datetime.DateTime][source]

Creation datetime in UTC, or None.

get_creation_datetime_utc_tz_unaware() Optional[datetime.datetime][source]

Creation time as a datetime.datetime object on UTC with no timezone (i.e. an “offset-naive” datetime), or None.

classmethod get_ddl(dialect_name: str = 'mysql') str[source]

Returns DDL for the primary and any ancillary tables.

get_extra_summary_tables(req: CamcopsRequest) List[camcops_server.cc_modules.cc_summaryelement.ExtraSummaryTable][source]

Override if you wish to create extra summary tables, not just add summary columns to task/ancillary tables.

Return a list of camcops_server.cc_modules.cc_summaryelement.ExtraSummaryTable objects.

classmethod get_extrastring_taskname() str[source]

Get the taskname used as the top-level key for this task’s extra strings (loaded by the server from XML files). By default, this is the task’s primary tablename, but tasks may override that via extrastring_taskname.

get_fhir_bundle(req: CamcopsRequest, recipient: ExportRecipient, skip_docs_if_other_content: bool = False) fhirclient.models.bundle.Bundle[source]

Get a single FHIR Bundle with all entries. See get_fhir_bundle_entries().

get_fhir_bundle_entries(req: CamcopsRequest, recipient: ExportRecipient, skip_docs_if_other_content: bool = False) List[Dict][source]

Get all FHIR bundle entries. This is the “top-level” function to provide all FHIR information for the task. That information includes:

  • the Patient, if applicable;

  • the Questionnaire (task) itself;

  • multiple QuestionnaireResponse entries for the specific answers from this task instance.

If the task refuses to support FHIR, raises FhirExportException.

Parameters
get_fhir_extra_bundle_entries(req: CamcopsRequest, recipient: ExportRecipient) List[Dict][source]

Return a list of extra FHIR bundle entries, if relevant. (SNOMED-CT codes are done automatically; don’t repeat those.)

get_fhir_questionnaire(req: CamcopsRequest) List[camcops_server.cc_modules.cc_fhir.FHIRAnsweredQuestion][source]

Return FHIR information about a questionnaire: both about the task in the abstract (the questions) and the answers for this specific instance.

May be overridden.

classmethod get_fieldnames() List[str][source]

Returns all field (column) names for this task’s primary table.

get_hl7_data_segments(req: CamcopsRequest, recipient_def: ExportRecipient) List[hl7.containers.Segment][source]

Returns a list of HL7 data segments.

These will be:

  • observation request (OBR) segment

  • observation result (OBX) segment

  • any extra ones offered by the task

get_hl7_extra_data_segments(recipient_def: ExportRecipient) List[hl7.containers.Segment][source]

Return a list of any extra HL7 data segments. (See get_hl7_data_segments(), which calls this function.)

May be overridden.

get_html(req: CamcopsRequest, anonymise: bool = False) str[source]

Returns HTML representing the task, for our HTML view.

Parameters
get_is_complete_td_pair(req: CamcopsRequest) str[source]

HTML to indicate whether task is complete or not, and to make it very obvious visually when it isn’t.

get_is_complete_tr(req: CamcopsRequest) str[source]

HTML table row to indicate whether task is complete or not, and to make it very obvious visually when it isn’t.

get_manually_erasing_user_username() str[source]

Returns the username of the user who erased this task manually on the server.

get_patient_address() str[source]

Get the patient’s address, or “”.

get_patient_dob() Optional[pendulum.date.Date][source]

Get the patient’s DOB, or None.

get_patient_dob_first11chars() Optional[str][source]

Gets the patient’s date of birth in an 11-character human-readable short format. For example: 29 Dec 1999.

get_patient_forename() str[source]

Get the patient’s forename, in upper case, or “”.

get_patient_hl7_pid_segment(req: CamcopsRequest, recipient_def: ExportRecipient) Union[hl7.containers.Segment, str][source]

Get an HL7 PID segment for the patient, or “”.

get_patient_idnum_object(which_idnum: int) Optional[PatientIdNum][source]

Get the patient’s camcops_server.cc_modules.cc_patientidnum.PatientIdNum for the specified ID number type (which_idnum), or None.

get_patient_idnum_objects() List[PatientIdNum][source]

Gets all camcops_server.cc_modules.cc_patientidnum.PatientIdNum objects for the patient.

get_patient_idnum_value(which_idnum: int) Optional[int][source]

Get the patient’s ID number value for the specified ID number type (which_idnum), or None.

get_patient_server_pk() Optional[int][source]

Get the server PK of the patient, or None.

get_patient_sex() str[source]

Get the patient’s sex, or “”.

get_patient_surname() str[source]

Get the patient’s surname, in upper case, or “”.

get_pdf(req: CamcopsRequest, anonymise: bool = False) bytes[source]

Returns a PDF representing the task.

Parameters
get_pdf_html(req: CamcopsRequest, anonymise: bool = False) str[source]

Gets the HTML used to make the PDF (slightly different from the HTML used for the HTML view).

get_preserving_user_username() str[source]

Returns the username of the user who “preserved” this task (marking it to be saved on the server and then deleting it from the client).

get_qtext(req: CamcopsRequest, attrname: str) Optional[str][source]

Returns the text associated with a particular question. The default implementation is a guess.

Parameters
get_removing_user_username() str[source]

Returns the username of the user who deleted this task (by removing it on the client and re-uploading).

get_rio_metadata(req: CamcopsRequest, which_idnum: int, uploading_user_id: str, document_type: str) str[source]

Returns metadata for the task that Servelec’s RiO electronic patient record may want.

Parameters
  • req – a camcops_server.cc_modules.cc_request.CamcopsRequest

  • which_idnum – which CamCOPS ID number type corresponds to the RiO client ID?

  • uploading_user_id – RiO user ID (string) of the user who will be recorded as uploading this information; see below

  • document_type – a string indicating the RiO-defined document type (this is system-specific); see below

Returns

a newline-terminated single line of CSV values; see below

Called by camcops_server.cc_modules.cc_exportmodels.ExportedTaskFileGroup.export_task().

From Servelec (Lee Meredith) to Rudolf Cardinal, 2014-12-04:

Batch Document Upload

The RiO batch document upload function can be used to upload
documents in bulk automatically.  RiO includes a Batch Upload
windows service which monitors a designated folder for new files.
Each file which is scanned must be placed in the designated folder
along with a meta-data file which describes the document.  So
essentially if a document had been scanned in and was called
‘ThisIsANewReferralLetterForAPatient.pdf’ then there would also
need to be a meta file in the same folder called
‘ThisIsANewReferralLetterForAPatient.metadata’.  The contents of
the meta file would need to include the following:

    Field Order; Field Name; Description; Data Mandatory (Y/N);
    Format

    1; ClientID; RiO Client ID which identifies the patient in RiO
    against which the document will be uploaded.; Y; 15
    Alphanumeric Characters

    2; UserID; User ID of the uploaded document, this is any user
    defined within the RiO system and can be a single system user
    called ‘AutomaticDocumentUploadUser’ for example.; Y; 10
    Alphanumeric Characters

        [NB example longer than that!]

    3; DocumentType; The RiO defined document type eg: APT; Y; 80
    Alphanumeric Characters

    4; Title; The title of the document; N; 40 Alphanumeric
    Characters

    5; Description; The document description.; N; 500 Alphanumeric
    Characters

    6; Author; The author of the document; N; 80 Alphanumeric
    Characters

    7; DocumentDate; The date of the document; N; dd/MM/yyyy HH:mm

    8; FinalRevision; The revision values are 0 Draft or 1 Final,
    this is defaulted to 1 which is Final revision.; N; 0 or 1

As an example, this is what would be needed in a meta file:

    “1000001”,”TRUST1”,”APT”,”A title”, “A description of the
        document”, “An author”,”01/12/2012 09:45”,”1”

(on one line)

Clarification, from Lee Meredith to Rudolf Cardinal, 2015-02-18:

get_seconds_from_creation_to_first_finish() Optional[float][source]

Time in seconds from creation time to first finish (i.e. first exit if the first exit was a finish rather than an abort), or None.

get_snomed_codes(req: CamcopsRequest) List[SnomedExpression][source]

Returns all SNOMED-CT codes for this task.

Parameters

req – the camcops_server.cc_modules.cc_request.CamcopsRequest

Returns

a list of camcops_server.cc_modules.cc_snomed.SnomedExpression objects

get_spreadsheet_pages(req: CamcopsRequest) List[SpreadsheetPage][source]

Returns information used for the basic research dump in (e.g.) TSV format.

get_spreadsheet_schema_elements(req: CamcopsRequest) Set[camcops_server.cc_modules.cc_dataclasses.SummarySchemaInfo][source]

Returns schema information used for spreadsheets – more than just the database columns, and in the same format as the spreadsheets.

get_standard_clinician_comments_block(req: CamcopsRequest, comments: str) str[source]

HTML DIV for clinician’s comments.

get_task_html(req: CamcopsRequest) str[source]

HTML for the main task content.

Must be overridden by derived classes.

classmethod get_text_filter_columns() List[sqlalchemy.sql.schema.Column][source]

Cached function to return a list of SQLAlchemy Column objects suitable for text filtering.

get_trackers(req: CamcopsRequest) List[TrackerInfo][source]

Tasks that provide quantitative information for tracking over time should override this and return a list of camcops_server.cc_modules.cc_trackerhelpers.TrackerInfo objects, one per tracker.

The information is read by camcops_server.cc_modules.cc_tracker.Tracker.get_all_plots_for_one_task_html().

Time information will be retrieved using get_creation_datetime().

get_twocol_bool_row(req: CamcopsRequest, fieldname: str, label: str = None) str[source]

HTML table row, two columns, with Boolean Y/N formatter for value.

Parameters
Returns

two-column HTML table row (label, value)

get_twocol_bool_row_present_absent(req: CamcopsRequest, fieldname: str, label: str = None) str[source]

HTML table row, two columns, with Boolean present/absent formatter for value.

Parameters
Returns

two-column HTML table row (label, value)

get_twocol_bool_row_true_false(req: CamcopsRequest, fieldname: str, label: str = None) str[source]

HTML table row, two columns, with Boolean true/false formatter for value.

Parameters
Returns

two-column HTML table row (label, value)

static get_twocol_picture_row(blob: Optional[camcops_server.cc_modules.cc_blob.Blob], label: str) str[source]

HTML table row, two columns, with PNG on right.

Parameters
Returns

two-column HTML table row (label, picture)

get_twocol_string_row(fieldname: str, label: Optional[str] = None) str[source]

HTML table row, two columns, with web-safing of value.

Parameters
  • fieldname – field (attribute) name; the value will be retrieved from this attribute

  • label – descriptive label

Returns

two-column HTML table row (label, value)

get_twocol_val_row(fieldname: str, default: Optional[str] = None, label: Optional[str] = None) str[source]

HTML table row, two columns, without web-safing of value.

Parameters
  • fieldname – field (attribute) name; the value will be retrieved from this attribute

  • default – default to show if the value is None

  • label – descriptive label

Returns

two-column HTML table row (label, value)

get_values(fields: List[str]) List[source]

Get list of object’s values from list of field names.

get_xml(req: CamcopsRequest, options: camcops_server.cc_modules.cc_simpleobjects.TaskExportOptions = None, indent_spaces: int = 4, eol: str = '\n') str[source]

Returns XML describing the task.

Parameters
Returns

an XML UTF-8 document representing the task.

get_xml_root(req: CamcopsRequest, options: camcops_server.cc_modules.cc_simpleobjects.TaskExportOptions) camcops_server.cc_modules.cc_xml.XmlElement[source]

Returns an XML tree. The return value is the root camcops_server.cc_modules.cc_xml.XmlElement.

Override to include other tables, or to deal with BLOBs, if the default methods are insufficient.

Parameters
classmethod help_url() str[source]

Returns the URL for task-specific online help.

By default, this is based on the tablename – e.g. phq9, giving phq9.html in the documentation (from phq9.rst in the source). However, some tasks override this – which they may do by writing

info_filename_stem = "XXX"

In the C++ code, compare infoFilenameStem() for individual tasks and urlconst::taskDocUrl() overall.

The online help is presently only in English.

is_complete() bool[source]

Is the task instance complete?

Must be overridden.

is_erased() bool[source]

Has the task been manually erased? See manually_erase().

is_female() bool[source]

Is the patient female?

is_field_not_none(field: str) bool[source]

Is the field not None?

is_male() bool[source]

Is the patient male?

is_preserved() bool[source]

Is the task preserved and erased from the tablet?

is_respondent_complete() bool[source]

Is the respondent information complete?

May be overridden by TaskHasRespondentMixin.

static longname(req: CamcopsRequest) str[source]

Long name (in the relevant language).

static make_options_from_numbers(first: int, last: int) Dict[int, str][source]

Creates a simple dictionary mapping numbers to string versions of those numbers. Usually for subsequent (more interesting) processing!

Parameters
  • first – first value

  • last – last value

Returns

dict

classmethod make_options_from_xstrings(req: CamcopsRequest, prefix: str, first: int, last: int, suffix: str = '') Dict[int, str][source]

Creates a lookup dictionary from xstrings.

Parameters
Returns

Each entry maps value to an xstring named <PREFIX><VALUE><SUFFIX>.

Return type

dict

manually_erase(req: CamcopsRequest) None[source]

Manually erases a task (including sub-tables). Also erases linked non-current records. This WIPES THE CONTENTS but LEAVES THE RECORD AS A PLACEHOLDER.

Audits the erasure. Propagates erase through to the HL7 log, so those records will be re-sent. WRITES TO DATABASE.

mean_fields(fields: List[str], ignorevalues: Optional[List[Optional[Union[int, float]]]] = None) Optional[Union[int, float]][source]

Return the mean of the values stored in all specified fields (skipping any whose value is in ignorevalues, which defaults to [None]). Returns None on error.

static mean_values(values: List[Any], ignorevalues: Optional[List[Optional[Union[int, float]]]] = None) Optional[Union[int, float]][source]

Return the mean of the values provided (skipping any whose value is in ignorevalues, which defaults to [None]). Returns None on error.

n_fields_none(fields: List[str]) int[source]

How many of the specified fields are None?

n_fields_not_none(fields: List[str]) int[source]

How many of the specified fields are not None?

property patient: Optional[Patient]

Returns the camcops_server.cc_modules.cc_patient.Patient for this task.

Overridden by TaskHasPatientMixin.

standard_task_summary_fields() List[camcops_server.cc_modules.cc_summaryelement.SummaryElement][source]

Returns summary fields/values provided by all tasks.

suggested_pdf_filename(req: CamcopsRequest, anonymise: bool = False) str[source]

Suggested filename for the PDF copy (for downloads).

Parameters
sum_fields(fields: List[str], ignorevalues: Optional[List[Optional[Union[int, float]]]] = None) Optional[Union[int, float]][source]

Sum values stored in all specified fields (skipping any whose value is in ignorevalues, which defaults to [None]). Returns None on error.

static sum_values(values: List[Optional[Union[int, float]]], ignorevalues: Optional[List[Optional[Union[int, float]]]] = None) Optional[Union[int, float]][source]

Sum the values provided (skipping any whose value is in ignorevalues, which defaults to [None]). Returns None on error.

title_for_html(req: CamcopsRequest, anonymise: bool = False) str[source]

Returns the plain text used for the HTML <title> block (by task.mako), and also for the PDF title for PDF exports.

Should be plain text only.

Parameters
was_forcibly_preserved() bool[source]

Was this task forcibly preserved?

write_pdf_to_disk(req: CamcopsRequest, filename: str) None[source]

Writes the PDF to disk, using filename.

classmethod wxstring(req: CamcopsRequest, name: str, defaultvalue: str = None, provide_default_if_none: bool = True) str[source]

Return a web-safe version of an extra string for this task.

Parameters
  • reqcamcops_server.cc_modules.cc_request.CamcopsRequest

  • name – name (second-level key) of the string, within the set of this task’s extra strings

  • defaultvalue – default to return if the string is not found

  • provide_default_if_none – if True and default is None, return a helpful missing-string message in the style “string x.y not found”

classmethod xstring(req: CamcopsRequest, name: str, defaultvalue: str = None, provide_default_if_none: bool = True) str[source]

Return a raw (not necessarily web-safe) version of an extra string for this task.

Parameters
  • reqcamcops_server.cc_modules.cc_request.CamcopsRequest

  • name – name (second-level key) of the string, within the set of this task’s extra strings

  • defaultvalue – default to return if the string is not found

  • provide_default_if_none – if True and default is None, return a helpful missing-string message in the style “string x.y not found”

class camcops_server.cc_modules.cc_task.TaskHasClinicianMixin[source]

Mixin to add clinician columns and override clinician-related methods.

Must be to the LEFT of Task in the class’s base class list, i.e. must have higher precedence than Task in the method resolution order.

get_clinician_fhir_telecom_other(req: CamcopsRequest) str[source]

Return a mishmash of information that doesn’t fit neatly into a FHIR Practitioner object, but people might actually want to know.

get_clinician_name() str[source]

Returns the clinician’s name.

class camcops_server.cc_modules.cc_task.TaskHasPatientMixin[source]

Mixin for tasks that have a patient (aren’t anonymous).

class camcops_server.cc_modules.cc_task.TaskHasRespondentMixin[source]

Mixin to add respondent columns and override respondent-related methods.

A respondent is someone who isn’t the patient and isn’t a clinician, such as a family member or carer.

Must be to the LEFT of Task in the class’s base class list, i.e. must have higher precedence than Task in the method resolution order.

Notes:

  • If you don’t use @declared_attr, the comment property on columns doesn’t work.

is_respondent_complete() bool[source]

Do we have sufficient information about the respondent? (That means: name, relationship to the patient.)

camcops_server.cc_modules.cc_task.all_task_classes() List[Type[camcops_server.cc_modules.cc_task.Task]][source]

Returns all task base table names.

camcops_server.cc_modules.cc_task.all_task_tablenames() List[str][source]

Returns all task base table names.

camcops_server.cc_modules.cc_task.all_task_tables_with_min_client_version() Dict[str, semantic_version.base.Version][source]

Across all tasks, return a mapping from each of their tables to the minimum client version.

Used by camcops_server.cc_modules.client_api.all_tables_with_min_client_version().

camcops_server.cc_modules.cc_task.get_from_dict(d: Dict, key: Any, default: Any = '[invalid_value]') Any[source]

Returns a value from a dictionary. This is not a very complex function… all it really does in practice is provide a default for default.

Parameters
  • d – the dictionary

  • key – the key

  • default – value to return if none is provided

camcops_server.cc_modules.cc_task.tablename_to_task_class_dict() Dict[str, Type[camcops_server.cc_modules.cc_task.Task]][source]

Returns a mapping from task base tablenames to task classes.