14.3.130. crate_anon.crateweb.research.forms
crate_anon/crateweb/research/forms.py
Copyright (C) 2015, University of Cambridge, Department of Psychiatry. Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
This file is part of CRATE.
CRATE 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.
CRATE 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 CRATE. If not, see <https://www.gnu.org/licenses/>.
Django forms for the research site.
- class crate_anon.crateweb.research.forms.AddHighlightForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]
Form to add/edit a
crate_anon.crateweb.research.models.Highlight
.- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.AddQueryForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]
Form to add or edit an SQL
crate_anon.crateweb.research.models.Query
.- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.BlankHighlightForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]
Unused? For
crate_anon.crateweb.research.models.Highlight
.- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.BlankQueryForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)[source]
Unused? For
crate_anon.crateweb.research.models.Query
.- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.ClinicianAllTextFromPidForm(*args, **kwargs)[source]
A slightly restricted form of
SQLHelperTextAnywhereForm
for clinicians.The clinician version always requires an ID (no “patient browsing”; that’s in the domain of research as it might yield patients that aren’t being cared for by this clinician).
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.DatabasePickerForm(*args, dbinfolist: List[SingleResearchDatabase], **kwargs)[source]
Form to choose a research database.
- __init__(*args, dbinfolist: List[SingleResearchDatabase], **kwargs) None [source]
- Parameters:
dbinfolist – list of all
crate_anon.crateweb.research.research_db_info.SingleResearchDatabase
.
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.FieldPickerInfo(value: str, description: str, type_: Type, permits_empty_id: bool)[source]
Describes a database field for when the user is asked to choose one via a web form.
- class crate_anon.crateweb.research.forms.ManualPeQueryForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]
Simple form for the “manual” section of the “Build Patient Explorer” page.
Allows the user to enter raw SQL.
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.PidLookupForm(*args, dbinfo: SingleResearchDatabase, **kwargs)[source]
Form to look up patient IDs from RIDs, MRIDs, and/or TRIDs.
For the RDBM.
- __init__(*args, dbinfo: SingleResearchDatabase, **kwargs) None [source]
- Parameters:
dbinfo – research database to look up descriptions from, as a
crate_anon.crateweb.research.research_db_info.SingleResearchDatabase
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.QueryBuilderForm(*args, **kwargs)[source]
Form to build an SQL query using a web interface.
Works hand in hand with
querybuilder.js
on the client side; q.v.- clean() None [source]
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.RidLookupForm(*args, dbinfo: SingleResearchDatabase, **kwargs)[source]
Form to look up RIDs from PIDs/MPIDs.
For clinicians: “get the RID for my patient”.
- __init__(*args, dbinfo: SingleResearchDatabase, **kwargs) None [source]
- Parameters:
dbinfo – research database to look up descriptions from, as a
crate_anon.crateweb.research.research_db_info.SingleResearchDatabase
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.SQLHelperDrugTypeForm(*args, drug_options: List[str] = (('antidepressant', 'antidepressant'), ('conventional_antidepressant', 'conventional_antidepressant'), ('ssri', 'ssri'), ('non_ssri_modern_antidepressant', 'non_ssri_modern_antidepressant'), ('tricyclic_antidepressant', 'tricyclic_antidepressant'), ('tetracyclic_and_related_antidepressant', 'tetracyclic_and_related_antidepressant'), ('monoamine_oxidase_inhibitor', 'monoamine_oxidase_inhibitor'), ('antipsychotic', 'antipsychotic'), ('first_generation_antipsychotic', 'first_generation_antipsychotic'), ('second_generation_antipsychotic', 'second_generation_antipsychotic'), ('stimulant', 'stimulant'), ('anticholinergic', 'anticholinergic'), ('benzodiazepine', 'benzodiazepine'), ('z_drug', 'z_drug'), ('non_benzodiazepine_anxiolytic', 'non_benzodiazepine_anxiolytic'), ('gaba_a_functional_agonist', 'gaba_a_functional_agonist'), ('gaba_b_functional_agonist', 'gaba_b_functional_agonist'), ('mood_stabilizer', 'mood_stabilizer'), ('antidiabetic', 'antidiabetic'), ('sulfonylurea', 'sulfonylurea'), ('biguanide', 'biguanide'), ('glifozin', 'glifozin'), ('glp1_agonist', 'glp1_agonist'), ('dpp4_inhibitor', 'dpp4_inhibitor'), ('meglitinide', 'meglitinide'), ('thiazolidinedione', 'thiazolidinedione'), ('cardiovascular', 'cardiovascular'), ('beta_blocker', 'beta_blocker'), ('ace_inhibitor', 'ace_inhibitor'), ('statin', 'statin'), ('respiratory', 'respiratory'), ('beta_agonist', 'beta_agonist'), ('gastrointestinal', 'gastrointestinal'), ('proton_pump_inhibitor', 'proton_pump_inhibitor'), ('nonsteroidal_anti_inflammatory', 'nonsteroidal_anti_inflammatory'), ('vitamin', 'vitamin')), **kwargs)[source]
Form for “find drug of a given type anywhere in a patient’s record”.
Same as ‘SQLHelperTextAnywhereForm’ except the user picks a drug type to search for instead of a string fragment.
- __init__(*args, drug_options: List[str] = (('antidepressant', 'antidepressant'), ('conventional_antidepressant', 'conventional_antidepressant'), ('ssri', 'ssri'), ('non_ssri_modern_antidepressant', 'non_ssri_modern_antidepressant'), ('tricyclic_antidepressant', 'tricyclic_antidepressant'), ('tetracyclic_and_related_antidepressant', 'tetracyclic_and_related_antidepressant'), ('monoamine_oxidase_inhibitor', 'monoamine_oxidase_inhibitor'), ('antipsychotic', 'antipsychotic'), ('first_generation_antipsychotic', 'first_generation_antipsychotic'), ('second_generation_antipsychotic', 'second_generation_antipsychotic'), ('stimulant', 'stimulant'), ('anticholinergic', 'anticholinergic'), ('benzodiazepine', 'benzodiazepine'), ('z_drug', 'z_drug'), ('non_benzodiazepine_anxiolytic', 'non_benzodiazepine_anxiolytic'), ('gaba_a_functional_agonist', 'gaba_a_functional_agonist'), ('gaba_b_functional_agonist', 'gaba_b_functional_agonist'), ('mood_stabilizer', 'mood_stabilizer'), ('antidiabetic', 'antidiabetic'), ('sulfonylurea', 'sulfonylurea'), ('biguanide', 'biguanide'), ('glifozin', 'glifozin'), ('glp1_agonist', 'glp1_agonist'), ('dpp4_inhibitor', 'dpp4_inhibitor'), ('meglitinide', 'meglitinide'), ('thiazolidinedione', 'thiazolidinedione'), ('cardiovascular', 'cardiovascular'), ('beta_blocker', 'beta_blocker'), ('ace_inhibitor', 'ace_inhibitor'), ('statin', 'statin'), ('respiratory', 'respiratory'), ('beta_agonist', 'beta_agonist'), ('gastrointestinal', 'gastrointestinal'), ('proton_pump_inhibitor', 'proton_pump_inhibitor'), ('nonsteroidal_anti_inflammatory', 'nonsteroidal_anti_inflammatory'), ('vitamin', 'vitamin')), **kwargs) None [source]
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.SQLHelperFindAnywhereForm(*args, fk_options: List[FieldPickerInfo], fk_label: str = 'Field name containing patient research ID', **kwargs)[source]
Base class for finding something anywhere in a patient’s record.
The user gets to pick
a field name (consistent across tables) representing a patient research ID (see
FieldPickerInfo
);a RID value
options to restrict which text fields are searched
an option to use full-text indexing where available
display options
The subclasses then choose what the user should search for.
- __init__(*args, fk_options: List[FieldPickerInfo], fk_label: str = 'Field name containing patient research ID', **kwargs) None [source]
- clean() Dict[str, Any] [source]
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- property media
Return all media required to render the widgets on this form.
- class crate_anon.crateweb.research.forms.SQLHelperTextAnywhereForm(*args, **kwargs)[source]
Form for “find text anywhere in a patient’s record”.
The user gets to pick
a field name (consistent across tables) representing a patient research ID (see
FieldPickerInfo
);a RID value
details of the text to search for
options to restrict which text fields are searched
an option to use full-text indexing where available
display options
This research-oriented form is then subclassed for clinicians; see
ClinicianAllTextFromPidForm
.- property media
Return all media required to render the widgets on this form.
- crate_anon.crateweb.research.forms.float_validator(text: str) str [source]
Takes text and returns a string version of a float version of it.
- Parameters:
text –
- Returns:
the same thing, usually
- Raises:
TypeError –