module documentation

Defines the fields that can be used to query the patient records.

Basically, this defines what buttons, dropdowns, and checkboxes are displayed on the dashboard and to some extent also how they look. Here, we also define the ThreeWayToggle button that is used to select between three states: positive, negative, and unknown. The ThreeWayToggle button is used for selecting HPV status, nicotine abuse, LNL involvement and more.

Typically, when calling one of the dataexplorer.views functions, an instance of the DataexplorerForm is created with the user's permissions and the initial data from the DataexplorerForm.from_initial class method. This initial data is then used to display the dashboard. Then, the user applies filters to the data and submits the form by pressing the "Compute" button. The form is then validated and cleaned (form.is_valid()), also in the dataexplorer.views module.

Note: the DataexplorerForm is not strictly used as Django intends forms to be used. In Django's logic, a form just after creation is "unbound" and in that state expects user input (think of a login form with empty fields). However, in our dashboard, no fields are ever "empty". Even when you first load the dashboard, the ThreeWayToggle buttons are already set to a value (None). Therefore, we never have this "unbound" state of the form. Instead, we always work with bound and validated forms, either created from the initial defaults or from the user's input.

Class DataexplorerForm Form for querying the database.
Class EasySubsiteChoiceField Simple subclass that provides a convenience method to create subsite fields.
Class ThreeWayToggle Field to choose one of three options: True, None and False.
Class ThreeWayToggleWidget Widget that renders the three-way toggle button.
Function format_dataset_choices Create a list of tuples for the dataset choices.
Function get_modality_choices Return the choices for the modality field.
Function trio_to_bool Transform -1, 0, and +1 to False, None and True respectively.
Type Variable T Undocumented
Variable checkbox_attrs Undocumented
Variable logger Undocumented
def format_dataset_choices(datasets: list[str]) -> list[tuple[str, str]]:

Create a list of tuples for the dataset choices.

def get_modality_choices() -> list[tuple[str, str]]:

Return the choices for the modality field.

def trio_to_bool(value: int | Any) -> bool | Any:

Transform -1, 0, and +1 to False, None and True respectively.

Any other values are simply passed through unchanged. This is used to map the values of the three-way toggle buttons to its boolean representation.

T =

Undocumented

Value
TypeVar('T',
        bound='DataexplorerForm')
checkbox_attrs: dict[str, str] =

Undocumented

logger =

Undocumented