API Reference

This section provides comprehensive technical documentation for SATHI’s modules, automatically generated from code docstrings.

Patient Management

Patient Views

patientapp.views.prom_review(request, pk, print_mode=False)[source]

View for the PRO Review page that shows patient questionnaire responses. Supports global filtering for all sections of the page.

Parameters:
  • request – HTTP request

  • pk – Patient UUID

  • print_mode – If True, renders print-optimized template instead of interactive page

patientapp.views.prom_review_print(request, pk)[source]

Print-friendly view for PRO Review report with simplified summaries. Reuses the same data gathering logic as prom_review but renders a print-optimized template with natural language summaries.

patientapp.views.prom_review_construct_plot(request, pk, construct_id)[source]

HTMX endpoint for lazy-loading a single construct plot with current filters.

patientapp.views.prom_review_composite_plot(request, pk, composite_id)[source]

HTMX endpoint for lazy-loading a single composite construct plot with current filters.

patientapp.views.prom_review_item_plot(request, pk, item_id)[source]

HTMX endpoint for lazy-loading a single item plot with current filters.

HTMX endpoint for searching items in the item filter autocomplete.

patientapp.views.patient_portal(request)[source]

Patient portal view for patients to see their own data and questionnaire responses.

Note: This view does NOT require ‘patientapp.view_patient’ permission because: - Patients should not be given permission to view other patients - This view is restricted to the authenticated user’s own patient data only - Security is enforced by checking request.user.patient exists and matches

patientapp.views.patient_search_api(request)[source]

API endpoint for Select2 widget to search patients by name or ID. Returns decrypted patient data in Select2 format with pagination support. Accessible to users with Provider profile or view_patient permission. Optionally filters by questionnaire assignment if questionnaire_id is provided.

patientapp.views.patient_list(request)[source]
patientapp.views.patient_detail(request, pk)[source]
patientapp.views.diagnosis_list(request)[source]
patientapp.views.diagnosis_detail(request, pk)[source]
patientapp.views.treatment_list(request)[source]
patientapp.views.treatment_detail(request, pk)[source]
class patientapp.views.PatientCreateView(**kwargs)[source]

Bases: InstitutionFilterMixin, LoginRequiredMixin, PermissionRequiredMixin, CreateView

model

alias of Patient

form_class

alias of PatientForm

template_name = 'patientapp/patient_form.html'
success_url = '/en-gb/patientapp/patients/'
permission_required = 'patientapp.add_patient'
get_form(form_class=None)[source]

Customize the form to limit institution choices for providers.

form_valid(form)[source]

If the form is valid, save the associated model.

form_invalid(form)[source]

Handle form invalid - preserve submitted diagnosis blocks.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

class patientapp.views.PatientRestrictedUpdateView(**kwargs)[source]

Bases: InstitutionFilterMixin, LoginRequiredMixin, PermissionRequiredMixin, UpdateView

model

alias of Patient

form_class

alias of PatientRestrictedUpdateForm

template_name = 'patientapp/patient_restricted_update_form.html'
permission_required = 'patientapp.change_patient'
get_form(form_class=None)[source]

Customize the form to limit institution choices for providers.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.DiagnosisCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

model

alias of Diagnosis

form_class

alias of DiagnosisForm

template_name = 'patientapp/diagnosis_form.html'
permission_required = 'patientapp.add_diagnosis'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.DiagnosisUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

model

alias of Diagnosis

form_class

alias of DiagnosisForm

template_name = 'patientapp/diagnosis_form.html'
permission_required = 'patientapp.change_diagnosis'
get_object(queryset=None)[source]

Get the diagnosis and check patient access.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.DiagnosisListCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

View for adding new diagnosis types to the DiagnosisList.

model

alias of DiagnosisList

form_class

alias of DiagnosisListForm

template_name = 'patientapp/diagnosislist_form.html'
permission_required = 'patientapp.add_diagnosislist'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.TreatmentCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

model

alias of Treatment

form_class

alias of TreatmentForm

template_name = 'patientapp/treatment_form.html'
permission_required = 'patientapp.add_treatment'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.TreatmentUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

model

alias of Treatment

form_class

alias of TreatmentForm

template_name = 'patientapp/treatment_form.html'
permission_required = 'patientapp.change_treatment'
get_object(queryset=None)[source]

Get the treatment and check patient access.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.TreatmentTypeCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

model

alias of TreatmentType

fields = ['treatment_type']
template_name = 'patientapp/treatment_type_form.html'
permission_required = 'patientapp.add_treatmenttype'
get_template_names()[source]

Return a list of template names to be used for the request. May not be called if render_to_response() is overridden. Return a list containing template_name, if set on the value. Otherwise, return a list containing:

  • the contents of the template_name_field field on the object instance that the view is operating upon (if available)

  • <app_label>/<model_name><template_name_suffix>.html

get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class patientapp.views.TreatmentTypeUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

model

alias of TreatmentType

fields = ['treatment_type']
template_name = 'patientapp/treatment_type_form.html'
permission_required = 'patientapp.change_treatmenttype'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

patientapp.views.treatment_type_list(request)[source]
patientapp.views.diagnosis_block_partial(request)[source]

HTMX endpoint to return a new diagnosis-treatment block for the patient form. Requires add_diagnosis permission to add diagnosis blocks. Expects a ‘block_idx’ parameter to set the prefix for the form fields.

patientapp.views.get_patient_count()[source]

Get the total count of patients in the system. Returns an integer count.

patientapp.views.patient_project_create(request, patient_pk)[source]

Create a new patient-project assignment.

patientapp.views.patient_project_update(request, pk)[source]

Update an existing patient-project assignment.

patientapp.views.patient_project_delete(request, pk)[source]

Delete a patient-project assignment.

patientapp.views.project_list(request)[source]

List all projects (staff only).

patientapp.views.project_create(request)[source]

Create a new project (staff only).

patientapp.views.project_update(request, pk)[source]

Update an existing project (staff only).

patientapp.views.redcap_project_dashboard(request, pk)[source]

List all ProjectRedcapMappings for a given Project.

patientapp.views.redcap_mapping_create(request, pk)[source]

Create a new ProjectRedcapMapping for a Project.

patientapp.views.redcap_mapping_edit(request, pk, mapping_pk)[source]

Edit an existing ProjectRedcapMapping.

patientapp.views.redcap_mapping_delete(request, pk, mapping_pk)[source]

Delete a ProjectRedcapMapping configuration.

patientapp.views.redcap_id_fields(request, pk, mapping_pk)[source]

Select Study ID and Secondary ID fields from fetched REDCap metadata.

patientapp.views.redcap_wizard_page(request, pk, mapping_pk)[source]

Full-page wrapper for the REDCap setup wizard.

patientapp.views.redcap_setup_wizard(request, pk, mapping_pk)[source]

Multi-step modal wizard: fetch metadata → ID fields → form mappings.

patientapp.views.redcap_fetch_metadata(request, pk, mapping_pk)[source]

HTMX POST: call PyCap to fetch project metadata and store in redcap_project_info.

patientapp.views.redcap_form_mappings(request, pk, mapping_pk)[source]

List RedcapFormToQuestionnaireMapping entries for a ProjectRedcapMapping.

patientapp.views.redcap_form_mapping_create(request, pk, mapping_pk)[source]

Create a RedcapFormToQuestionnaireMapping.

patientapp.views.redcap_form_mapping_edit(request, pk, mapping_pk, fm_pk)[source]

Edit a RedcapFormToQuestionnaireMapping.

patientapp.views.redcap_form_mapping_delete(request, pk, mapping_pk, fm_pk)[source]

Delete a RedcapFormToQuestionnaireMapping.

patientapp.views.redcap_field_mappings(request, pk, mapping_pk, fm_pk)[source]

Create/edit RedcapFieldToItemMapping entries for a form mapping.

patientapp.views.redcap_patient_ids(request, pk, mapping_pk)[source]

Map patients in the project to their REDCap study IDs.

patientapp.views.redcap_patient_id_delete(request, pk, mapping_pk, patient_pk)[source]

Delete a REDCap study ID mapping for a specific patient.

patientapp.views.redcap_match_submissions(request, pk, mapping_pk, patient_pk)[source]

Per-patient submission → REDCap instance matching review and save.

patientapp.views.redcap_export(request, pk, mapping_pk)[source]

Trigger a CSV download or API export for the selected form mappings.

Patient Models

class patientapp.models.Institution(*args, **kwargs)[source]

Bases: Model

Institution model.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patient_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

provider_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class patientapp.models.Project(*args, **kwargs)[source]

Bases: Model

This model will store information about the project to which the patient will be assigned to. Patient may be assigned to one or multiple projects.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

project_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patientproject_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

projectredcapmapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class patientapp.models.GenderChoices(*values)[source]

Bases: TextChoices

MALE = 'Male'
FEMALE = 'Female'
TRANSGENDER = 'Transgender'
NON_BINARY = 'Non-binary'
PREFER_NOT_TO_SAY = 'Prefer not to say'
OTHER = 'Other'
class patientapp.models.Patient(*args, **kwargs)[source]

Bases: Model

Patient model.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

institution

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_of_registration

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

age

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

gender

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

preferred_language

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

diagnosis_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

get_gender_display(*, field=<django.db.models.fields.CharField: gender>)
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_preferred_language_display(*, field=<django.db.models.fields.CharField: preferred_language>)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
institution_id
objects = <django.db.models.manager.Manager object>
patientproject_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

patientquestionnaire_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

questionnairesubmission_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapdataexportlog_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapstudyidtopatientidmap_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

user_id
patientapp.models.update_user_language(sender, instance, **kwargs)[source]

Signal to update the user’s session language when their preferred language changes

class patientapp.models.PatientProject(*args, **kwargs)[source]

Bases: Model

PatientProject model to link patients to project using a many to many relationship. The table also stores the date the patient was assigned to the project as that will be used later on with questionnaire export to allow users to export the questionnaires which were answered by the patient during the period the patient was a part of the project.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

date_patient_enrolled_in_project

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_patient_exited_from_project

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patient_id
project_id
class patientapp.models.DiagnosisList(*args, **kwargs)[source]

Bases: Model

List of diagnosis for the system. This list will be referenced in the model for the Diagnosis.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

diagnosis

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

icd_11_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

diagnosis_list

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
class patientapp.models.Diagnosis(*args, **kwargs)[source]

Bases: Model

Diagnosis model.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

diagnosis

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

date_of_diagnosis

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

diagnosis_id
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patient_id
treatment_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class patientapp.models.TreatmentIntentChoices(*values)[source]

Bases: TextChoices

PREVENTIVE = 'Preventive'
CURATIVE = 'Curative'
PALLIATIVE = 'Palliative'
OTHER = 'Other'
class patientapp.models.TreatmentType(*args, **kwargs)[source]

Bases: Model

Treatment types model.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

treatment_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
treatment_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class patientapp.models.Treatment(*args, **kwargs)[source]

Bases: Model

Treatment model. Use this to specify the treatments delivered to the specific diagnosis. As patients may have multiple treatments over a period of time, this form allows us to capture treatments delivered synchronously. If treatments are delivered sequentially, then add another entry of the form for the diagnosis. This also allows for data to be updated longitudinally.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

diagnosis

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

treatment_type

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

treatment_intent

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_of_start_of_treatment

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

currently_ongoing_treatment

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_of_end_of_treatment

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

clean()[source]

Custom validation for Treatment model.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

diagnosis_id
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
get_treatment_intent_display(*, field=<django.db.models.fields.CharField: treatment_intent>)
objects = <django.db.models.manager.Manager object>
class patientapp.models.ExportTypeChoices(*values)[source]

Bases: TextChoices

MANUAL = 'manual'
AUTOMATIC = 'automatic'
class patientapp.models.ProjectRedcapMapping(*args, **kwargs)[source]

Bases: Model

This table will map a REDCap project to the a specific CHAVI PROM Project allowing data of patients in CHAVI PROM to be exported to REDCap. Users can configure this mapping in the admin panel. Using PyCap, the project information will be stored as a JSON mapping in the database table. The project information may be updated also at a later date.

project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

redcap_project_url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_project_token

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_project_token_allows_import

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_project_token_allows_export

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_project_info

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

date_redcap_project_info_updated

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_record_count

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

export_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_study_id_field

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_data_access_group_used

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_secondary_id_field

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_export_type_display(*, field=<django.db.models.fields.CharField: export_type>)
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
project_id
redcapformtoquestionnairemapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapstudyidtopatientidmap_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class patientapp.models.RedcapStudyIDtoPatientIDMap(*args, **kwargs)[source]

Bases: Model

This model will store the mapping for the patient ID in REDCap to the patient ID in CHAVI PROM. Note that the patient ID field is different from username and refers to the patient_id field in the Patient model. Note that the patient will be linked to a specific study not to a questionnaire.

project_redcap_mapping

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

redcap_study_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
patient_id
project_redcap_mapping_id
class patientapp.models.SubmissionDateFormatChoices(*values)[source]

Bases: TextChoices

These choices will be used to convert the submission date time to the correct format for the export. Note while the UI of REDCap allows several formats during export data is expected to be in three specific formats. If the DATE_YMD format is chosen then only date gets saved.

DATE_YMD = 'date_ymd'
DATETIME_YMD = 'datetime_ymd'
DATETIME_SECONDS_YMD = 'datetime_seconds_ymd'
class patientapp.models.RedcapFormToQuestionnaireMapping(*args, **kwargs)[source]

Bases: Model

This table will store the linkage between a REDCap form in a REDCap project and the questionnaire in CHAVI PROM. This linkage will be specfic to the project and therefore when when the project is modified this linkage will be revised. Special note about mapping date of submission. In some REDCap forms there may be date or date time field that will be used for tracking the submission date. Data for this field will need to be obtained from the date_submitted field in the QuestionnaireSubmission model. A single field in the form which is a date or date time field should be allowed to be mapped to this value. The system will automatically detect the date / date time fields and check the date type field. In REDCap, the validation value is to be obtained from the JSON key in the project infromation.

project_redcap_mapping

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

redcap_form_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_event_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_form_is_repeating

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_form_is_in_event

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_event_is_repeating

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_date_mapping_field

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

submission_date_field

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

submission_date_format

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=False, **kwargs)
get_submission_date_format_display(*, field=<django.db.models.fields.CharField: submission_date_format>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
project_redcap_mapping_id
questionnaire_id
redcapdataexportlog_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapfieldtoitemmapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapinstancetosubmissionmapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class patientapp.models.ResponseTransformChoices(*values)[source]

Bases: TextChoices

NONE = 'none'
TO_INT = 'to_int'
TO_FLOAT = 'to_float'
TO_FLOAT_2 = 'to_float_2'
ROUND_INT = 'round_int'
STRIP_ZEROS = 'strip_zeros'
class patientapp.models.RedcapFieldToItemMapping(*args, **kwargs)[source]

Bases: Model

This table will store information about the mapping of REDCap fields to the Questionnaire Items in the CHAVI PROM questionnaire. Note that this linkage allows us to specify linkage of the same item to the multiple fields in REDCap. The linkage to the questionnaire item will point to the specific Item through the foreign key Questionnaire -> QuestionnaireItem -> Item (see promapp.models) When the export process will run, then the value stored for the specific item in the QuestionnaireSubmission will be used to populate the REDCap field data. The relationship traversal will be Questionnaire -> PatientQuestionnaire -> QuestionnaireSubmission -> QuestionnaireItemResponse where the field called response value stores the actual value that will be stored in the REDCap data export. (See promapp.models)

redcap_form_to_questionnaire_mapping

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

redcap_field_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_item

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

response_transform

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=False, **kwargs)
get_response_transform_display(*, field=<django.db.models.fields.CharField: response_transform>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
questionnaire_item_id
redcap_form_to_questionnaire_mapping_id
class patientapp.models.ExportStatusChoices(*values)[source]

Bases: TextChoices

PENDING = 'pending'
COMPLETED = 'completed'
INCOMPLETE = 'incomplete'
FAILED = 'failed'
class patientapp.models.RedcapInstanceToSubmissionMapping(*args, **kwargs)[source]

Bases: Model

This model will store the mapping between questionnaire submission instances and the REDCap data that will be created when the data is exported to REDCap. This model will grant access to several sets of information through relationships already existing in the models 1. Questionnaire submission -> User -> Patient ID -> Mapped REDCap study ID 2. Redcap form to questionnaire mapping -> Redcap form name, redcap event type and most importantly the redcap_date_mapping field which will allow us to map the submissions to specific events in a longitudinal project automatically.

questionnaire_submission

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

redcap_form

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

data_access_group

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_patient_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_event_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_repeat_instance

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

redcap_repeat_event

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
questionnaire_submission_id
redcap_form_id
class patientapp.models.RedcapDataExportLog(*args, **kwargs)[source]

Bases: Model

This model will store the entries for all transactions for data updating using REDCap API when data export is enabled using automatic method.

redcap_form_to_questionnaire_mapping

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_exporting_data

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

export_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

datetime_export_start

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

datetime_export_completed

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

export_status

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

export_log

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_export_status_display(*, field=<django.db.models.fields.CharField: export_status>)
get_export_type_display(*, field=<django.db.models.fields.CharField: export_type>)
get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_modified_at(*, field=<django.db.models.fields.DateTimeField: modified_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
patient_id
redcap_form_to_questionnaire_mapping_id
user_exporting_data_id

Patient Forms

class patientapp.forms.DiagnosisTreatmentBlockForm(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, bound_field_class=None)[source]

Bases: Form

A single block containing one Diagnosis and one Treatment for initial patient registration. Multiple blocks can be added dynamically via HTMX.

clean()[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__’.

base_fields = {'block_prefix': <django.forms.fields.CharField object>, 'currently_ongoing_treatment': <django.forms.fields.BooleanField object>, 'date_of_diagnosis': <django.forms.fields.DateField object>, 'date_of_end_of_treatment': <django.forms.fields.DateField object>, 'date_of_start_of_treatment': <django.forms.fields.DateField object>, 'diagnosis': <django.forms.models.ModelChoiceField object>, 'treatment_intent': <django.forms.fields.ChoiceField object>, 'treatment_type': <django.forms.models.ModelMultipleChoiceField object>}
declared_fields = {'block_prefix': <django.forms.fields.CharField object>, 'currently_ongoing_treatment': <django.forms.fields.BooleanField object>, 'date_of_diagnosis': <django.forms.fields.DateField object>, 'date_of_end_of_treatment': <django.forms.fields.DateField object>, 'date_of_start_of_treatment': <django.forms.fields.DateField object>, 'diagnosis': <django.forms.models.ModelChoiceField object>, 'treatment_intent': <django.forms.fields.ChoiceField object>, 'treatment_type': <django.forms.models.ModelMultipleChoiceField object>}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.PatientForm(*args, **kwargs)[source]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of Patient

fields = ['patient_id', 'name', 'age', 'gender', 'institution', 'date_of_registration', 'preferred_language', 'username', 'email', 'password1', 'password2', 'groups']
widgets = {'age': <django.forms.widgets.NumberInput object>, 'date_of_registration': <django.forms.widgets.DateInput object>, 'password1': <django.forms.widgets.PasswordInput object>, 'password2': <django.forms.widgets.PasswordInput object>}
__init__(*args, **kwargs)[source]
clean_password2()[source]
clean_username()[source]
clean_email()[source]
clean()[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__’.

base_fields = {'age': <django.forms.fields.IntegerField object>, 'date_of_registration': <django.forms.fields.DateField object>, 'date_patient_enrolled_in_project': <django.forms.fields.DateField object>, 'date_patient_exited_from_project': <django.forms.fields.DateField object>, 'email': <django.forms.fields.EmailField object>, 'gender': <django.forms.fields.TypedChoiceField object>, 'groups': <django.forms.models.ModelMultipleChoiceField object>, 'institution': <django.forms.models.ModelChoiceField object>, 'name': <django.forms.fields.CharField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'patient_id': <django.forms.fields.CharField object>, 'preferred_language': <django.forms.fields.TypedChoiceField object>, 'project': <django.forms.models.ModelChoiceField object>, 'username': <django.forms.fields.CharField object>}
declared_fields = {'date_patient_enrolled_in_project': <django.forms.fields.DateField object>, 'date_patient_exited_from_project': <django.forms.fields.DateField object>, 'email': <django.forms.fields.EmailField object>, 'groups': <django.forms.models.ModelMultipleChoiceField object>, 'password1': <django.forms.fields.CharField object>, 'password2': <django.forms.fields.CharField object>, 'project': <django.forms.models.ModelChoiceField object>, 'username': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.DiagnosisListForm(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]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of DiagnosisList

fields = ['diagnosis', 'icd_11_code']
labels = {'diagnosis': 'Diagnosis Name', 'icd_11_code': 'ICD-11 Code'}
base_fields = {'diagnosis': <django.forms.fields.CharField object>, 'icd_11_code': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.DiagnosisForm(*args, **kwargs)[source]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of Diagnosis

fields = ['diagnosis', 'date_of_diagnosis']
widgets = {'date_of_diagnosis': <django.forms.widgets.DateInput object>}
__init__(*args, **kwargs)[source]
base_fields = {'date_of_diagnosis': <django.forms.fields.DateField object>, 'diagnosis': <django.forms.models.ModelChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.PatientRestrictedUpdateForm(*args, **kwargs)[source]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of Patient

fields = ['age', 'gender', 'institution', 'date_of_registration', 'preferred_language']
widgets = {'age': <django.forms.widgets.NumberInput object>, 'date_of_registration': <django.forms.widgets.DateInput object>}
__init__(*args, **kwargs)[source]
base_fields = {'age': <django.forms.fields.IntegerField object>, 'date_of_registration': <django.forms.fields.DateField object>, 'gender': <django.forms.fields.TypedChoiceField object>, 'institution': <django.forms.models.ModelChoiceField object>, 'preferred_language': <django.forms.fields.TypedChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.TreatmentForm(*args, **kwargs)[source]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of Treatment

fields = ['treatment_type', 'treatment_intent', 'date_of_start_of_treatment', 'currently_ongoing_treatment', 'date_of_end_of_treatment']
widgets = {'date_of_end_of_treatment': <django.forms.widgets.DateInput object>, 'date_of_start_of_treatment': <django.forms.widgets.DateInput object>}
__init__(*args, **kwargs)[source]
base_fields = {'currently_ongoing_treatment': <django.forms.fields.BooleanField object>, 'date_of_end_of_treatment': <django.forms.fields.DateField object>, 'date_of_start_of_treatment': <django.forms.fields.DateField object>, 'treatment_intent': <django.forms.fields.TypedChoiceField object>, 'treatment_type': <django.forms.models.ModelMultipleChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.ProjectForm(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]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of Project

fields = ['project_name']
labels = {'project_name': 'Project Name'}
widgets = {'project_name': <django.forms.widgets.TextInput object>}
base_fields = {'project_name': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.PatientProjectForm(*args, **kwargs)[source]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of PatientProject

fields = ['project', 'date_patient_enrolled_in_project', 'date_patient_exited_from_project']
labels = {'date_patient_enrolled_in_project': 'Date Enrolled', 'date_patient_exited_from_project': 'Date Exited', 'project': 'Project'}
widgets = {'date_patient_enrolled_in_project': <django.forms.widgets.DateInput object>, 'date_patient_exited_from_project': <django.forms.widgets.DateInput object>, 'project': <django.forms.widgets.Select object>}
__init__(*args, **kwargs)[source]
clean()[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__’.

base_fields = {'date_patient_enrolled_in_project': <django.forms.fields.DateField object>, 'date_patient_exited_from_project': <django.forms.fields.DateField object>, 'project': <django.forms.models.ModelChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.ProjectRedcapMappingForm(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]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of ProjectRedcapMapping

fields = ['redcap_project_url', 'redcap_project_token', 'redcap_project_token_allows_import', 'redcap_project_token_allows_export', 'export_type']
labels = {'export_type': 'Export Type', 'redcap_project_token_allows_export': 'Token allows export from REDCap', 'redcap_project_token_allows_import': 'Token allows import into REDCap', 'redcap_project_url': 'REDCap Project URL'}
widgets = {'export_type': <django.forms.widgets.Select object>, 'redcap_project_token_allows_export': <django.forms.widgets.CheckboxInput object>, 'redcap_project_token_allows_import': <django.forms.widgets.CheckboxInput object>, 'redcap_project_url': <django.forms.widgets.URLInput object>}
clean_redcap_project_token()[source]
base_fields = {'export_type': <django.forms.fields.TypedChoiceField object>, 'redcap_project_token': <django.forms.fields.CharField object>, 'redcap_project_token_allows_export': <django.forms.fields.BooleanField object>, 'redcap_project_token_allows_import': <django.forms.fields.BooleanField object>, 'redcap_project_url': <django.forms.fields.URLField object>}
declared_fields = {'redcap_project_token': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.RedcapIDFieldsForm(*args, **kwargs)[source]

Bases: ModelForm

__init__(*args, **kwargs)[source]
class Meta[source]

Bases: object

model

alias of ProjectRedcapMapping

fields = ['redcap_study_id_field', 'redcap_secondary_id_field']
base_fields = {'redcap_secondary_id_field': <django.forms.fields.CharField object>, 'redcap_study_id_field': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.RedcapFormToQuestionnaireMappingForm(*args, project_redcap_mapping=None, **kwargs)[source]

Bases: ModelForm

__init__(*args, project_redcap_mapping=None, **kwargs)[source]
clean()[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__’.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

class Meta[source]

Bases: object

model

alias of RedcapFormToQuestionnaireMapping

fields = ['redcap_form_name', 'redcap_event_name', 'redcap_form_is_repeating', 'redcap_form_is_in_event', 'redcap_event_is_repeating', 'redcap_date_mapping_field', 'questionnaire', 'submission_date_field']
labels = {'questionnaire': 'CHAVI PROM Questionnaire', 'redcap_event_is_repeating': 'Event is repeating', 'redcap_event_name': 'REDCap Event Name', 'redcap_form_is_in_event': 'Form is part of an event', 'redcap_form_is_repeating': 'Form is a repeating form'}
widgets = {'questionnaire': <django.forms.widgets.Select object>, 'redcap_event_is_repeating': <django.forms.widgets.CheckboxInput object>, 'redcap_event_name': <django.forms.widgets.TextInput object>, 'redcap_form_is_in_event': <django.forms.widgets.CheckboxInput object>, 'redcap_form_is_repeating': <django.forms.widgets.CheckboxInput object>}
base_fields = {'questionnaire': <django.forms.models.ModelChoiceField object>, 'redcap_date_mapping_field': <django.forms.fields.CharField object>, 'redcap_event_is_repeating': <django.forms.fields.BooleanField object>, 'redcap_event_name': <django.forms.fields.CharField object>, 'redcap_form_is_in_event': <django.forms.fields.BooleanField object>, 'redcap_form_is_repeating': <django.forms.fields.BooleanField object>, 'redcap_form_name': <django.forms.fields.CharField object>, 'submission_date_field': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.RedcapFieldToItemMappingForm(*args, project_redcap_mapping=None, form_mapping=None, **kwargs)[source]

Bases: ModelForm

__init__(*args, project_redcap_mapping=None, form_mapping=None, **kwargs)[source]
class Meta[source]

Bases: object

model

alias of RedcapFieldToItemMapping

fields = ['redcap_field_name', 'questionnaire_item']
labels = {'questionnaire_item': 'Questionnaire Item'}
widgets = {'questionnaire_item': <django.forms.widgets.Select object>}
base_fields = {'questionnaire_item': <django.forms.models.ModelChoiceField object>, 'redcap_field_name': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class patientapp.forms.RedcapStudyIDMapForm(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]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of RedcapStudyIDtoPatientIDMap

fields = ['redcap_study_id']
labels = {'redcap_study_id': 'REDCap Study ID'}
widgets = {'redcap_study_id': <django.forms.widgets.TextInput object>}
base_fields = {'redcap_study_id': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

Patient Utilities

patientapp.utils.get_patient_available_start_dates(patient)[source]

Get all available start dates for a patient.

Parameters:

patient – Patient instance

Returns:

List of tuples (reference_key, display_name, date_value)

Return type:

list

patientapp.utils.get_patient_start_date(patient, start_date_reference='date_of_registration')[source]

Get the start date for a patient based on the reference type.

Parameters:
  • patient – Patient instance

  • start_date_reference – Type of start date reference key

Returns:

The start date or None if not available

Return type:

datetime.date or None

patientapp.utils.calculate_time_interval_value(submission_date, start_date, interval_type='weeks')[source]

Calculate the time interval value from start date to submission date.

Parameters:
  • submission_date – datetime object of the submission

  • start_date – date object of the start reference

  • interval_type – Type of interval (‘seconds’, ‘minutes’, ‘hours’, ‘days’, ‘weeks’, ‘months’, ‘years’)

Returns:

The calculated interval value

Return type:

float

patientapp.utils.get_interval_label(interval_type)[source]

Get the display label for the interval type.

Parameters:

interval_type – Type of interval

Returns:

Display label for the interval

Return type:

str

patientapp.utils.filter_positive_intervals(historical_responses, start_date, time_interval='weeks')[source]

Filter historical responses to only include those with non-negative time intervals.

Parameters:
  • historical_responses – List of response objects with submission dates

  • start_date – The reference start date

  • time_interval – Time interval type for calculation

Returns:

Filtered responses with only non-negative intervals

Return type:

List

patientapp.utils.filter_positive_intervals_construct(historical_scores, start_date, time_interval='weeks')[source]

Filter historical construct scores to only include those with non-negative time intervals.

Parameters:
  • historical_scores – List of construct score objects with submission dates

  • start_date – The reference start date

  • time_interval – Time interval type for calculation

Returns:

Filtered scores with only non-negative intervals

Return type:

List

patientapp.utils.add_clinical_indicators_to_plot(p, selected_indicators, start_date, time_interval, x_min, x_max, y_max=None)[source]

Add diagnosis and treatment indicators to a Bokeh plot.

Parameters:
  • p – Bokeh plot figure

  • selected_indicators – List of indicator dictionaries with type, date, and label

  • start_date – Reference start date for time calculations

  • time_interval – Time interval type for calculations

  • x_min – X-axis range limits

  • x_max – X-axis range limits

  • y_max – Maximum Y value for positioning markers (optional)

patientapp.utils.calculate_percentage(value: Decimal | None, max_value: Decimal | None) float[source]

Calculate the percentage of a value relative to a maximum value.

Parameters:
  • value (Optional[Decimal]) – The current value

  • max_value (Optional[Decimal]) – The maximum possible value

Returns:

The percentage (0-100) or 0 if calculation fails

Return type:

float

class patientapp.utils.ConstructScoreData(construct: ConstructScale, current_score: Decimal | None, previous_score: Decimal | None, historical_scores: List[QuestionnaireConstructScore], patient=None, start_date_reference='date_of_registration', time_interval='weeks', aggregated_statistics=None, aggregation_metadata=None, aggregation_type='median_iqr', selected_indicators=None, generate_plot=True)[source]

Bases: object

__init__(construct: ConstructScale, current_score: Decimal | None, previous_score: Decimal | None, historical_scores: List[QuestionnaireConstructScore], patient=None, start_date_reference='date_of_registration', time_interval='weeks', aggregated_statistics=None, aggregation_metadata=None, aggregation_type='median_iqr', selected_indicators=None, generate_plot=True)[source]
is_clinically_significant() bool[source]

Check if this construct score is clinically significant for any reason

static is_important_construct(construct: ConstructScale, current_score: Decimal | None) bool[source]

Determine if a construct is important based on the comprehensive clinical significance rules. This method creates a temporary ConstructScoreData object to leverage the full significance logic.

class patientapp.utils.CompositeConstructScoreData(composite_construct_scale, current_score: Decimal | None, previous_score: Decimal | None, historical_scores: List, patient=None, start_date_reference='date_of_registration', time_interval='weeks', selected_indicators=None, generate_plot=True)[source]

Bases: object

Data class for composite construct scores with plotting capabilities.

__init__(composite_construct_scale, current_score: Decimal | None, previous_score: Decimal | None, historical_scores: List, patient=None, start_date_reference='date_of_registration', time_interval='weeks', selected_indicators=None, generate_plot=True)[source]
patientapp.utils.filter_positive_intervals_composite(scores, start_date, time_interval)[source]

Filter composite construct scores to only include those with non-negative time intervals.

patientapp.utils.create_item_response_plot(historical_responses: List[QuestionnaireItemResponse], item: Item, patient=None, start_date_reference='date_of_registration', time_interval='weeks', selected_indicators=None) str[source]

Create a Bokeh plot for item responses over time.

Parameters:
  • historical_responses (List[QuestionnaireItemResponse]) – List of historical responses

  • item (Item) – The item being plotted

  • patient – Patient instance for start date calculation

  • start_date_reference – Reference date type for time calculation

  • time_interval – Time interval type for x-axis

Returns:

HTML string containing the Bokeh plot components

Return type:

str

patientapp.utils.create_likert_response_plot(historical_responses: List[QuestionnaireItemResponse], item: Item, patient=None, start_date_reference='date_of_registration', time_interval='weeks', selected_indicators=None) str[source]

Create a Bokeh plot specifically for Likert responses.

Parameters:
  • historical_responses (List[QuestionnaireItemResponse]) – List of historical responses

  • item (Item) – The item being plotted

  • patient – Patient instance for start date calculation

  • start_date_reference – Reference date type for time calculation

  • time_interval – Time interval type for x-axis

Returns:

HTML string containing the Bokeh plot components

Return type:

str

patientapp.utils.create_numeric_response_plot(historical_responses: List[QuestionnaireItemResponse], item: Item, patient=None, start_date_reference='date_of_registration', time_interval='weeks', selected_indicators=None) str[source]

Create a Bokeh plot for numeric responses.

Parameters:
  • historical_responses (List[QuestionnaireItemResponse]) – List of historical responses

  • item (Item) – The item being plotted

  • patient – Patient instance for start date calculation

  • start_date_reference – Reference date type for time calculation

  • time_interval – Time interval type for x-axis

Returns:

HTML string containing the Bokeh plot components

Return type:

str

patientapp.utils.get_patient_start_date_for_aggregation(patient, start_date_reference='date_of_registration')[source]

Get the start date for a patient for aggregation purposes.

For aggregation, we use the same diagnosis/treatment type but allow different dates: - If start_date_reference is a specific diagnosis, use that same diagnosis type’s date - If start_date_reference is a specific treatment, use that same treatment type’s date - Otherwise use the exact reference

Parameters:
  • patient – Patient instance

  • start_date_reference – Type of start date reference key

Returns:

The start date or None if not available

Return type:

datetime.date or None

patientapp.utils.get_filtered_patients_for_aggregation(exclude_patient, patient_filter_gender=None, patient_filter_diagnosis=None, patient_filter_treatment=None, patient_filter_min_age=None, patient_filter_max_age=None)[source]

Get patients for aggregation based on filtering criteria, excluding the current patient.

Parameters:
  • exclude_patient – Patient instance to exclude from aggregation

  • patient_filter_gender – Gender filter (‘match’, specific gender, or None for all)

  • patient_filter_diagnosis – Diagnosis filter (‘match’, specific diagnosis ID, or None for all)

  • patient_filter_treatment – Treatment filter (‘match’, specific treatment type ID, or None for all)

  • patient_filter_min_age – Minimum age filter (integer or None)

  • patient_filter_max_age – Maximum age filter (integer or None)

Returns:

Filtered patients excluding the current patient

Return type:

QuerySet

Note

Adding New Filter Fields - To add a new filtering criterion, follow this pattern:

  1. Add Parameter: Add the new filter parameter to the function signature

  2. Add Documentation: Update this docstring with the new parameter description

  3. Implement Filter Logic: Add the filtering logic following existing patterns

  4. Update Callers: Update all places that call this function

  5. Update UI: Add the new filter to the frontend

Filter Types Supported:

  • ‘match’: Match the exclude_patient’s value for this field

  • Specific value: Filter to patients with this exact value

  • None/empty: No filtering applied for this field

  • Range values: For numeric fields (min/max parameters)

Important Notes:

  • All filters use AND logic (cumulative narrowing)

  • Use .distinct() for relationship-based filters to avoid duplicates

  • Optimize relationship queries using values_list() instead of loops

  • Consider database indexes for new filterable fields

patientapp.utils.aggregate_construct_scores_by_time_interval(construct, patients_queryset, start_date_reference, time_interval, max_time_interval_filter=None, reference_time_intervals=None)[source]

Aggregate construct scores from multiple patients by time intervals.

For each reference time interval from the index patient, find the most recent observation from other patients that is at or before each reference time point.

Parameters:
  • construct – ConstructScale instance

  • patients_queryset – QuerySet of patients to include in aggregation

  • start_date_reference – Reference date type for time calculation

  • time_interval – Time interval type for grouping

  • max_time_interval_filter – Optional maximum time interval (relative to start date) for filtering submissions

  • reference_time_intervals – List of reference time intervals from index patient

Returns:

(aggregated_data dict, metadata dict)

Return type:

tuple

patientapp.utils.calculate_aggregation_statistics(aggregated_data, aggregation_type='median_iqr')[source]

Calculate aggregation statistics for each time interval.

Parameters:
  • aggregated_data – Dict mapping time intervals to lists of values

  • aggregation_type – Type of aggregation to perform

Returns:

Statistics for each time interval

Return type:

dict

patientapp.utils.calculate_aggregation_metadata(aggregated_data, patients_queryset, construct_or_item)[source]

Calculate metadata about the aggregation including patient and response counts.

Parameters:
  • aggregated_data – Dict mapping time intervals to lists of values

  • patients_queryset – QuerySet of patients included in aggregation

  • construct_or_item – The construct or item being aggregated

Returns:

Metadata about the aggregation

Return type:

dict

patientapp.utils.get_plotting_log_file_path()[source]

Get the path to the plotting data log file.

patientapp.utils.clear_plotting_log()[source]

Clear the plotting data log file.

patientapp.utils.log_plotting_session_start(patient_name, constructs_count)[source]

Log the start of a new plotting session.

patientapp.utils.calculate_patient_age(patient, reference_date=None)[source]

Get the age of a patient.

Parameters:
  • patient – Patient instance

  • reference_date – Date to calculate age at (not used, kept for compatibility)

Returns:

Age in years, or None if age is not available

Return type:

int or None

patientapp.utils.get_user_institution(user)[source]

Get the institution for the current user if they are a provider. Returns None if the user is not a provider or has no institution.

patientapp.utils.is_provider_user(user)[source]

Check if the user is a provider (has a provider profile).

patientapp.utils.filter_patients_by_institution(queryset, user)[source]

Filter a Patient queryset based on the user’s institution. If the user is a provider, only return patients from their institution. If the user is not a provider, return all patients (assuming they have appropriate permissions).

patientapp.utils.check_patient_access(user, patient)[source]

Check if a user can access a specific patient. Returns True if access is allowed, False otherwise. Provider users can only access patients from their institution.

patientapp.utils.get_accessible_patient_or_404(user, pk)[source]

Get a patient by pk, ensuring the user has access to it. Raises 404 if patient doesn’t exist, PermissionDenied if no access.

class patientapp.utils.InstitutionFilterMixin[source]

Bases: object

Mixin for class-based views that automatically filters Patient querysets based on the user’s institution.

get_user_institution()[source]

Get the institution for the current user.

get_queryset()[source]

Filter the queryset based on user’s institution.

get_object(queryset=None)[source]

Get the object, ensuring the user has access to it. This method is called by DetailView, UpdateView, DeleteView, etc.

Patient Middleware

class patientapp.middleware.PatientLanguageMiddleware(get_response)[source]

Bases: object

Middleware to automatically switch the website language based on the patient’s preferred language. This middleware checks if the logged-in user is a patient and if they have a preferred language set. If so, it activates that language and redirects to the appropriate language URL if necessary.

__init__(get_response)[source]

PROM Management

PROM Views

class promapp.views.QuestionnaireListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

Questionnaire List View for displaying list of avaialble questionnaires.

model

alias of Questionnaire

template_name = 'promapp/questionnaire_list.html'
context_object_name = 'questionnaires'
ordering = ['-created_date']
permission_required = 'promapp.view_questionnaire'
paginate_by = 10
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.QuestionnaireDetailView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DetailView

Questionnaire Detail View for displaying details of a specific questionnaire.

model

alias of Questionnaire

template_name = 'promapp/questionnaire_detail.html'
context_object_name = 'questionnaire'
permission_required = 'promapp.view_questionnaire'
get_context_data(**kwargs)[source]

Insert the single object into the context dict.

class promapp.views.QuestionnaireCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

Questionnaire Create View for creating a new questionnaire.

model

alias of Questionnaire

form_class

alias of QuestionnaireForm

template_name = 'promapp/questionnaire_create.html'
success_url = '/en-gb/promapp/questionnaires/'
permission_required = 'promapp.add_questionnaire'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

class promapp.views.QuestionnaireUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

Questionnaire Update View for updating an existing questionnaire.

model

alias of Questionnaire

form_class

alias of QuestionnaireForm

template_name = 'promapp/questionnaire_update.html'
success_url = '/en-gb/promapp/questionnaires/'
permission_required = 'promapp.change_questionnaire'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

class promapp.views.ItemListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

Item List View for displaying list of available items.

model

alias of Item

template_name = 'promapp/item_list.html'
context_object_name = 'items'
permission_required = 'promapp.view_item'
paginate_by = 10
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.ItemCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

View to create items

model

alias of Item

form_class

alias of ItemForm

template_name = 'promapp/item_create.html'
success_url = '/en-gb/promapp/items/'
permission_required = 'promapp.add_item'
get_initial()[source]

Return the initial data to use for forms on this view.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

class promapp.views.ItemUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View to update items

model

alias of Item

form_class

alias of ItemForm

template_name = 'promapp/item_update.html'
success_url = '/en-gb/promapp/items/'
permission_required = 'promapp.change_item'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

promapp.views.get_response_fields(request)[source]

Get the response fields based on the selected response type

promapp.views.add_item_form(request)[source]

View to add a new item

promapp.views.create_likert_scale(request)[source]

View to create a new likert scale

promapp.views.create_construct_scale(request)[source]

Function-based view for creating construct scales

promapp.views.add_likert_option(request)[source]

Add a new empty row to the Likert scale formset.

promapp.views.remove_likert_option(request)[source]

Remove a row from the Likert scale formset.

class promapp.views.LikertScaleListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View to list all likert scales

model

alias of LikertScale

template_name = 'promapp/likert_scale_list.html'
context_object_name = 'likert_scales'
permission_required = 'promapp.view_likertscale'
paginate_by = 10
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
promapp.views.create_range_scale(request)[source]
class promapp.views.RangeScaleListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View to list all range scales

model

alias of RangeScale

template_name = 'promapp/range_scale_list.html'
context_object_name = 'range_scales'
permission_required = 'promapp.view_rangescale'
paginate_by = 10
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.ConstructScaleListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View to list all construct scales

model

alias of ConstructScale

template_name = 'promapp/construct_scale_list.html'
context_object_name = 'construct_scales'
permission_required = 'promapp.view_constructscale'
paginate_by = 25
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.QuestionnaireResponseView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin, DetailView

View for handling questionnaire responses. This view allows patients to respond to questionnaires assigned to them. Only accessible to users with a Patient profile AND required permissions.

model

alias of PatientQuestionnaire

template_name = 'promapp/questionnaire_response.html'
context_object_name = 'patient_questionnaire'
permission_required = ['promapp.view_patientquestionnaire', 'promapp.add_questionnaireitemresponse', 'promapp.add_questionnairesubmission']
test_func()[source]

Check if user has a Patient profile. This is checked AFTER permissions are verified.

get_queryset()[source]

Return the QuerySet that will be used to look up the object.

This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.

check_interval(patient_questionnaire)[source]
dispatch(request, *args, **kwargs)[source]
get_translated_items(questionnaire)[source]

Helper method to get questionnaire items with properly translated Likert options

get_context_data(**kwargs)[source]

Insert the single object into the context dict.

get_next_available_questionnaire(current_patient_questionnaire)[source]

Find the next available questionnaire that can be answered. Returns the PatientQuestionnaire object or None if no more questionnaires are available.

post(request, *args, **kwargs)[source]
class promapp.views.PatientQuestionnaireManagementView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DetailView

View for managing questionnaires assigned to a patient. This view allows staff to assign/unassign questionnaires to patients.

model

alias of Patient

template_name = 'promapp/patient_questionnaire_management.html'
context_object_name = 'patient'
permission_required = 'promapp.add_patientquestionnaire'
get_context_data(**kwargs)[source]

Insert the single object into the context dict.

post(request, *args, **kwargs)[source]
class promapp.views.PatientQuestionnaireListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing patients who have questionnaires assigned to them.

model

alias of Patient

template_name = 'promapp/patient_questionnaire_list.html'
context_object_name = 'patients'
permission_required = 'promapp.view_patientquestionnaire'
paginate_by = 25
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

class promapp.views.MyQuestionnaireListView(**kwargs)[source]

Bases: LoginRequiredMixin, ListView

View to list all questionnaires for the logged-in patient

model

alias of PatientQuestionnaire

template_name = 'promapp/my_questionnaire_list.html'
context_object_name = 'patient_questionnaires'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

promapp.views.global_schedule_calendar(request)[source]

Global view of all scheduled assessments across all patients. Uses same permission structure as patient_list. Respects institution-based access control.

class promapp.views.QuestionnaireItemRuleListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing rules associated with a questionnaire item.

model

alias of QuestionnaireItemRule

template_name = 'promapp/questionnaire_item_rules_list.html'
context_object_name = 'rules'
permission_required = 'promapp.view_questionnaireitemrule'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

class promapp.views.QuestionnaireItemRuleCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

View for creating a new rule for a questionnaire item.

model

alias of QuestionnaireItemRule

form_class

alias of QuestionnaireItemRuleForm

template_name = 'promapp/questionnaire_item_rule_form.html'
permission_required = 'promapp.add_questionnaireitemrule'
get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireItemRuleUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for updating an existing rule.

model

alias of QuestionnaireItemRule

form_class

alias of QuestionnaireItemRuleForm

template_name = 'promapp/questionnaire_item_rule_form.html'
permission_required = 'promapp.change_questionnaireitemrule'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireItemRuleDeleteView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DeleteView

View for deleting a rule.

model

alias of QuestionnaireItemRule

permission_required = 'promapp.delete_questionnaireitemrule'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireItemRuleGroupListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing rule groups associated with a questionnaire item.

model

alias of QuestionnaireItemRuleGroup

template_name = 'promapp/questionnaire_item_rule_groups_list.html'
context_object_name = 'rule_groups'
permission_required = 'promapp.view_questionnaireitemrulegroup'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

class promapp.views.QuestionnaireItemRuleGroupCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

View for creating a new rule group.

model

alias of QuestionnaireItemRuleGroup

form_class

alias of QuestionnaireItemRuleGroupForm

template_name = 'promapp/questionnaire_item_rule_group_form.html'
permission_required = 'promapp.add_questionnaireitemrulegroup'
get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

get_form(form_class=None)[source]

Return an instance of the form to be used in this view.

get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireItemRuleGroupUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for updating an existing rule group.

model

alias of QuestionnaireItemRuleGroup

form_class

alias of QuestionnaireItemRuleGroupForm

template_name = 'promapp/questionnaire_item_rule_group_form.html'
permission_required = 'promapp.change_questionnaireitemrulegroup'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireItemRuleGroupDeleteView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DeleteView

View for deleting a rule group.

model

alias of QuestionnaireItemRuleGroup

permission_required = 'promapp.delete_questionnaireitemrulegroup'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireExportListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing questionnaires available for export.

model

alias of Questionnaire

template_name = 'promapp/questionnaire_export_list.html'
context_object_name = 'questionnaires'
permission_required = 'promapp.view_questionnaire'
paginate_by = 10
get_queryset()[source]

Return only questionnaires that have submissions.

get_context_data(**kwargs)[source]

Get the context for this view.

class promapp.views.ProjectExportListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing projects available for export.

model

alias of Project

template_name = 'promapp/project_export_list.html'
context_object_name = 'projects'
permission_required = 'patientapp.view_project'
paginate_by = 25
get_queryset()[source]

Return only projects that have patients with questionnaire submissions.

get_context_data(**kwargs)[source]

Get the context for this view.

class promapp.views.ProjectQuestionnaireExportListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing questionnaires available for export for a specific project.

model

alias of Questionnaire

template_name = 'promapp/project_questionnaire_export_list.html'
context_object_name = 'questionnaires'
permission_required = 'promapp.view_questionnaire'
paginate_by = 25
get_queryset()[source]

Return only questionnaires that have submissions from patients in this project.

get_context_data(**kwargs)[source]

Get the context for this view.

class promapp.views.QuestionnaireExportPatientListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing patients who have submitted a specific questionnaire.

model

alias of Patient

template_name = 'promapp/questionnaire_export_patient_list.html'
context_object_name = 'patients'
permission_required = 'promapp.view_questionnaire'
paginate_by = 25
get_queryset()[source]

Return patients who have submitted the selected questionnaire.

get_context_data(**kwargs)[source]

Get the context for this view.

promapp.views.export_questionnaire_responses(request, questionnaire_id, patient_id=None)[source]

Function for exporting questionnaire responses to CSV.

promapp.views.validate_dependent_item(request)[source]

Validate the selected dependent item and return appropriate feedback.

promapp.views.validate_rule_operator(request)[source]

Validate the selected operator and return appropriate feedback.

promapp.views.validate_comparison_value(request)[source]

Validate the comparison value based on the dependent item’s response type.

promapp.views.validate_logical_operator(request)[source]

Validate the logical operator selection.

promapp.views.validate_rule_order(request)[source]

Validate the rule order.

promapp.views.validate_group_order(request)[source]

Validate the group order.

promapp.views.validate_rule_selection(request)[source]

Validate the selected rules for a rule group.

promapp.views.rule_summary(request, questionnaire_item_id)[source]

Return a summary of rules for a questionnaire item.

promapp.views.rule_group_summary(request, questionnaire_item_id)[source]

Return a summary of rule groups for a questionnaire item.

promapp.views.save_question_numbers(request, pk)[source]

View to handle saving question numbers via AJAX.

class promapp.views.QuestionnaireRulesView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DetailView

View for managing rules for a questionnaire.

model

alias of Questionnaire

template_name = 'promapp/questionnaire_rules.html'
context_object_name = 'questionnaire'
permission_required = 'promapp.add_questionnaire'
get_context_data(**kwargs)[source]

Insert the single object into the context dict.

promapp.views.evaluate_question_rules(request, questionnaire_item_id)[source]

View to evaluate rules for a questionnaire item. Returns JSON response indicating whether the question should be shown.

class promapp.views.ItemTranslationView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for managing translations of an Item.

model

alias of Item

form_class

alias of ItemTranslationForm

template_name = 'promapp/item_translation_form.html'
permission_required = 'promapp.add_item'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.ItemTranslationListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing items with translation links.

model

alias of Item

template_name = 'promapp/item_translation_list.html'
context_object_name = 'items'
permission_required = 'promapp.add_item'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.QuestionnaireTranslationView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for managing translations of a Questionnaire.

model

alias of Questionnaire

form_class

alias of QuestionnaireTranslationForm

template_name = 'promapp/questionnaire_translation_form.html'
permission_required = 'promapp.add_questionnaire'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.QuestionnaireTranslationListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing questionnaires with translation links.

model

alias of Questionnaire

template_name = 'promapp/questionnaire_translation_list.html'
context_object_name = 'questionnaires'
permission_required = 'promapp.add_questionnaire'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.LikertScaleResponseOptionTranslationView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for managing translations of a LikertScaleResponseOption.

model

alias of LikertScaleResponseOption

form_class

alias of LikertScaleResponseOptionTranslationForm

template_name = 'promapp/likert_scale_response_option_translation_form.html'
permission_required = 'promapp.add_likertscaleresponseoption'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.LikertScaleResponseOptionTranslationListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing LikertScaleResponseOptions with translation links.

model

alias of LikertScaleResponseOption

template_name = 'promapp/likert_scale_response_option_translation_list.html'
context_object_name = 'options'
permission_required = 'promapp.add_likertscaleresponseoption'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.RangeScaleTranslationView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for managing translations of a RangeScale.

model

alias of RangeScale

form_class

alias of RangeScaleTranslationForm

template_name = 'promapp/range_scale_translation_form.html'
permission_required = 'promapp.add_rangescale'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

get_form_kwargs()[source]

Return the keyword arguments for instantiating the form.

form_valid(form)[source]

If the form is valid, save the associated model.

get_success_url()[source]

Return the URL to redirect to after processing a valid form.

class promapp.views.RangeScaleTranslationListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing range scales with translation links.

model

alias of RangeScale

template_name = 'promapp/range_scale_translation_list.html'
context_object_name = 'range_scales'
permission_required = 'promapp.add_rangescale'
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
promapp.views.switch_language(request)[source]

View to switch the current language for translation.

class promapp.views.TranslationsDashboardView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, TemplateView

View for the translations dashboard.

template_name = 'promapp/translations_dashboard.html'
permission_required = 'promapp.add_questionnaire'
get_context_data(**kwargs)[source]
promapp.views.search_construct_scales(request)[source]

Search construct scales and return matching results as JSON.

class promapp.views.ConstructEquationView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for managing the equation of a construct scale.

model

alias of ConstructScale

form_class

alias of ConstructEquationForm

template_name = 'promapp/construct_equation_form.html'
permission_required = 'promapp.change_constructscale'
get_context_data(**kwargs)[source]

Insert the form into the context dict.

form_valid(form)[source]

If the form is valid, save the associated model.

form_invalid(form)[source]

If the form is invalid, render the invalid form.

class promapp.views.ConstructScaleUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for updating a construct scale.

model

alias of ConstructScale

form_class

alias of ConstructScaleForm

template_name = 'promapp/construct_scale_form.html'
permission_required = 'promapp.change_constructscale'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

form_valid(form)[source]

If the form is valid, save the associated model.

class promapp.views.ConstructScaleDeleteView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DeleteView

View for deleting a construct scale.

model

alias of ConstructScale

permission_required = 'promapp.delete_constructscale'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

delete(request, *args, **kwargs)[source]

Call the delete() method on the fetched object and then redirect to the success URL.

promapp.views.validate_equation(request)[source]

HTMX endpoint to validate an equation in real-time.

promapp.views.add_to_equation(request)[source]

HTMX endpoint to add a question reference to the equation.

class promapp.views.CompositeConstructScaleScoringListView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, ListView

View for listing composite construct scale scoring configurations.

model

alias of CompositeConstructScaleScoring

template_name = 'promapp/composite_construct_scale_scoring_list.html'
context_object_name = 'composite_scales'
permission_required = 'promapp.view_compositeconstructscalescoring'
paginate_by = 25
get_queryset()[source]

Return the list of items for this view.

The return value must be an iterable and may be an instance of QuerySet in which case QuerySet specific behavior will be enabled.

get_context_data(**kwargs)[source]

Get the context for this view.

get(request, *args, **kwargs)[source]
class promapp.views.CompositeConstructScaleScoringCreateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, CreateView

View for creating a new composite construct scale scoring configuration.

model

alias of CompositeConstructScaleScoring

form_class

alias of CompositeConstructScaleScoringForm

template_name = 'promapp/composite_construct_scale_scoring_form.html'
permission_required = 'promapp.add_compositeconstructscalescoring'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

form_valid(form)[source]

If the form is valid, save the associated model.

form_invalid(form)[source]

If the form is invalid, render the invalid form.

class promapp.views.CompositeConstructScaleScoringUpdateView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UpdateView

View for updating a composite construct scale scoring configuration.

model

alias of CompositeConstructScaleScoring

form_class

alias of CompositeConstructScaleScoringForm

template_name = 'promapp/composite_construct_scale_scoring_form.html'
permission_required = 'promapp.change_compositeconstructscalescoring'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

form_valid(form)[source]

If the form is valid, save the associated model.

form_invalid(form)[source]

If the form is invalid, render the invalid form.

class promapp.views.CompositeConstructScaleScoringDeleteView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, DeleteView

View for deleting a composite construct scale scoring configuration.

model

alias of CompositeConstructScaleScoring

permission_required = 'promapp.delete_compositeconstructscalescoring'
get_success_url()[source]

Return the URL to redirect to after processing a valid form.

delete(request, *args, **kwargs)[source]

Call the delete() method on the fetched object and then redirect to the success URL.

class promapp.views.QuestionnaireGuidanceView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, TemplateView

View for the redesigned questionnaire guidance page with step-by-step workflow. This page provides a clear 4-step process for creating questionnaires with visual workflow and direct links to creation forms.

template_name = 'promapp/questionnaire_guidance.html'
permission_required = 'promapp.add_questionnaire'
get_context_data(**kwargs)[source]
promapp.views.get_questionnaire_count()[source]

Get the total count of questionnaires in the system. Returns an integer count.

promapp.views.get_item_count()[source]

Get the total count of items (questions) in the system. Returns an integer count.

promapp.views.get_questionnaire_submission_count()[source]

Get the total count of questionnaire submissions (responses) in the system. Returns an integer count.

class promapp.views.StaffQuestionnaireResponseView(**kwargs)[source]

Bases: LoginRequiredMixin, PermissionRequiredMixin, UserPassesTestMixin, DetailView

View for staff to submit questionnaire responses on behalf of patients. Displays all questions on a single page with patient selection and custom submission date. Only accessible to users with a Provider profile AND required permissions.

model

alias of Questionnaire

template_name = 'promapp/staff_questionnaire_response.html'
context_object_name = 'questionnaire'
permission_required = ['promapp.view_questionnaire', 'promapp.add_questionnaireitemresponse', 'promapp.add_questionnairesubmission', 'patientapp.view_patient']
test_func()[source]

Check if user has a Provider profile. This is checked AFTER permissions are verified.

get_translated_items(questionnaire)[source]

Helper method to get questionnaire items with properly translated Likert options

get_context_data(**kwargs)[source]

Insert the single object into the context dict.

post(request, *args, **kwargs)[source]
promapp.views.generate_tts_preview(request)[source]

AJAX view to generate TTS preview using Sarvam AI. Returns base64 encoded audio for preview playback.

promapp.views.save_tts_to_item(request, item_id)[source]

AJAX view to generate TTS and save it to Item media field.

PROM Models

class promapp.models.DirectionChoices(*values)[source]

Bases: TextChoices

HIGHER_IS_BETTER = 'Higher is Better'
LOWER_IS_BETTER = 'Lower is Better'
MIDDLE_IS_BETTER = 'Middle is Better'
NO_DIRECTION = 'No Direction'
class promapp.models.ConstructScale(*args, **kwargs)[source]

Bases: Model

Construct Scale model. Construct Scale refers to the collection of items that are used to measure a construct.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

instrument_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

instrument_version

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

scale_equation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

minimum_number_of_items

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

scale_better_score_direction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

scale_threshold_score

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

scale_minimum_clinical_important_difference

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

scale_normative_score_mean

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

scale_normative_score_standard_deviation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_valid_items_with_numbers()[source]

Returns a list of valid items (Number, Likert, or Range) with their stored item numbers.

validate_scale_equation()[source]

Validates the scale equation using Lark grammar. Validation rules are in the file called equation_validation_rules.lark

clean()[source]

This method is called by Django’s form validation and model validation. It ensures the scale_equation is validated before saving.

save(*args, **kwargs)[source]

Override save to ensure validation is always performed

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

compositeconstructscalescoring_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
get_scale_better_score_direction_display(*, field=<django.db.models.fields.CharField: scale_better_score_direction>)
item_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
questionnaireconstructscore_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class promapp.models.ScoringTypeChoices(*values)[source]

Bases: TextChoices

AVERAGE = 'Average'
SUM = 'Sum'
MEDIAN = 'Median'
MODE = 'Mode'
MIN = 'Min'
MAX = 'Max'
class promapp.models.CompositeConstructScaleScoring(*args, **kwargs)[source]

Bases: Model

Composite Construct Scale Scoring model. This is used when construct scales are combined to form a score.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

composite_construct_scale_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

construct_scales

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

scoring_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

composite_construct_score_direction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

composite_construct_scale_threshold_score

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

composite_construct_scale_minimum_clinical_important_difference

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

composite_construct_scale_normative_score_mean

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

composite_construct_scale_normative_score_standard_deviation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_composite_construct_score_direction_display(*, field=<django.db.models.fields.CharField: composite_construct_score_direction>)
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
get_scoring_type_display(*, field=<django.db.models.fields.CharField: scoring_type>)
objects = <django.db.models.manager.Manager object>
questionnaireconstructscorecomposite_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class promapp.models.AICapabilitiesChoices(*values)[source]

Bases: TextChoices

TTS = 'Text To Speech'
STT = 'Speech To Text'
IMAGE_GENERATION = 'Image Generation'
VIDEO_GENERATION = 'Video Generation'
TEXT_GENERATION = 'Text Generation'
class promapp.models.AIAPIConfiguration(*args, **kwargs)[source]

Bases: Model

AI API configuration model. This is used to store the AI API configuration for providing AI augmented services using a REST API.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ai_provider

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

ai_capability

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

utility_function_path

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

api_url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

api_key_environment_variable_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

get_utility_function()[source]

Retrieve and return the utility function specified by utility_function_path.

Returns:

The utility function for making API calls

Return type:

callable

Raises:

ValueError – If the utility function cannot be loaded

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_ai_capability_display(*, field=<django.db.models.fields.CharField: ai_capability>)
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
class promapp.models.LikertScale(*args, **kwargs)[source]

Bases: Model

Likert scale type model. This is used to store the type of Likert Scale.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

likert_scale_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

VIRIDIS_COLORS = ['#440154', '#3b528b', '#21918c', '#5ec962', '#fde725']
get_viridis_colors(n_colors)[source]

Generate n colors from the viridis color palette. Returns a list of hex color codes.

interpolate_color(color1, color2, t)[source]

Interpolate between two hex colors. t is a float between 0 and 1.

get_text_color(bg_color)[source]

Determine if text should be light or dark based on background color brightness. Returns ‘#ffffff’ for dark backgrounds and ‘#000000’ for light backgrounds.

get_option_colors(better_direction='Higher is Better')[source]

Get colors for each option in the scale. Colors are assigned based on the better_direction: - For ‘Higher is Better’: lighter colors for higher values - For ‘Lower is Better’: lighter colors for lower values

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
item_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

likertscaleresponseoption_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

objects = <django.db.models.manager.Manager object>
class promapp.models.LikertScaleResponseOption(*args, **kwargs)[source]

Bases: TranslatableModel

Likert scale response options model. This is used to store the options for Likert Scale Responses. In this the translatable fields are option_text, and option_media.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

likert_scale

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

option_order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

option_emoji

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

option_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_media_type(media_file=None)[source]

Determine the media type based on file extension.

Parameters:

media_file – Optional media file object. If not provided, uses self.option_media

Returns:

‘audio’, ‘video’, ‘image’, or ‘other’

Return type:

str

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
likert_scale_id
option_media

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

option_text

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

class promapp.models.RangeScale(*args, **kwargs)[source]

Bases: TranslatableModel

Range scale model. This is used to store the range of values for a range scale.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

range_scale_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

max_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

min_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

increment

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

validate_increment()[source]
get_available_languages()[source]

Return a list of language codes for which translations exist.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
item_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

max_value_text

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

min_value_text

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

class promapp.models.ResponseTypeChoices(*values)[source]

Bases: TextChoices

TEXT = 'Text'
NUMBER = 'Number'
LIKERT = 'Likert'
RANGE = 'Range'
MEDIA = 'Media'
class promapp.models.Item(*args, **kwargs)[source]

Bases: TranslatableModel

Item model for storing questions in an instrument. Ensure full_clean() is called before saving in views and forms. Translatable field is name.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

construct_scale

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

abbreviated_item_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_number

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

response_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

likert_response

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

range_response

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

is_required

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_missing_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_better_score_direction

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_threshold_score

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_minimum_clinical_important_difference

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_normative_score_mean

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item_normative_score_standard_deviation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

discrimination_parameter

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

difficulty_parameter

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

pseudo_guessing_parameter

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_related_constructs()[source]
save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

delete(*args, **kwargs)[source]

Override delete to check if this item is referenced in any construct scale equations.

get_available_languages()[source]

Return a list of language codes for which translations exist.

is_referenced_in_equation(check_item_number=None)[source]

Check if this item (or a specific item number) is referenced in any of its construct scale equations.

Parameters:

check_item_number – If provided, check this specific item number instead of self.item_number

Returns:

bool, ‘equations’: list of equations, and ‘construct_names’: str

Return type:

dict with ‘is_referenced’

get_media_type(media_file=None)[source]

Determine the media type based on file extension.

Parameters:

media_file – Optional media file object. If not provided, uses self.media

Returns:

‘audio’, ‘video’, ‘image’, or ‘other’

Return type:

str

get_media_info()[source]

Get comprehensive media information for template use. Handles translatable media fields with proper fallback.

Returns:

Contains media_type, url, name, and has_media

Return type:

dict

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_item_better_score_direction_display(*, field=<django.db.models.fields.CharField: item_better_score_direction>)
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
get_response_type_display(*, field=<django.db.models.fields.CharField: response_type>)
likert_response_id
media

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

questionnaireitem_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

range_response_id
class promapp.models.Questionnaire(*args, **kwargs)[source]

Bases: TranslatableModel

Questionnaire model. This is used to store the questionnaire. Translatable field are name and description.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

translations

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

questionnaire_answer_interval

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_redirect

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_available_languages()[source]

Return a list of language codes for which translations exist.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

description

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

patientquestionnaire_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

questionnaire_redirect_id
questionnaireitem_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapformtoquestionnairemapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redirect_questionnaire

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class promapp.models.QuestionnaireItem(*args, **kwargs)[source]

Bases: Model

Questionnaire Item model. This is used to store the items for the questionnaire. There is a many to many relationship between Questionnaire and Item.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

question_number

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

item

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

dependent_rules

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
item_id
objects = <django.db.models.manager.Manager object>
questionnaire_id
questionnaireitemresponse_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapfieldtoitemmapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

rule_groups

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

visibility_rules

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class promapp.models.PatientQuestionnaire(*args, **kwargs)[source]

Bases: Model

Patient Questionnaire model. This is used to store the questionnaire available for a patient.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

questionnaire

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

display_questionnaire

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patient_id
questionnaire_id
questionnairepatientschedule_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

questionnairesubmission_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class promapp.models.QuestionnairePatientSchedule(*args, **kwargs)[source]

Bases: Model

This is a model to store information about the schedule of the assessment for a give questionnaire for a pateint.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient_questionnaire

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

date_assessment

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patient_questionnaire_id
class promapp.models.QuestionnaireSubmission(*args, **kwargs)[source]

Bases: Model

Questionnaire Submission model. This is used to store the submission of the questionnaire.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

patient

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

user_submitting_questionnaire

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

patient_questionnaire

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

submission_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_next_by_submission_date(*, field=<django.db.models.fields.DateTimeField: submission_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
get_previous_by_submission_date(*, field=<django.db.models.fields.DateTimeField: submission_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
patient_id
patient_questionnaire_id
questionnaireconstructscore_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

questionnaireconstructscorecomposite_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

questionnaireitemresponse_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

redcapinstancetosubmissionmapping_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

user_submitting_questionnaire_id
class promapp.models.QuestionnaireConstructScore(*args, **kwargs)[source]

Bases: Model

Questionnaire Construct Score model. This is used to store the score for the construct.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_submission

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

construct

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

score

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

items_answered

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

items_not_answered

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

calculation_log

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

construct_id
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
questionnaire_submission_id
class promapp.models.QuestionnaireConstructScoreComposite(*args, **kwargs)[source]

Bases: Model

Questionnaire Construct Score Composite model. This is used to store the composite score for the construct.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_submission

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

composite_construct_scale

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

score

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

calculation_log

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

composite_construct_scale_id
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
questionnaire_submission_id
class promapp.models.QuestionnaireItemResponse(*args, **kwargs)[source]

Bases: Model

Questionnaire Item Response model. This is used to store the responses for the questionnaire item.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_submission

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

questionnaire_item

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

response_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

response_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

response_media

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_next_by_response_date(*, field=<django.db.models.fields.DateTimeField: response_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
get_previous_by_response_date(*, field=<django.db.models.fields.DateTimeField: response_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
questionnaire_item_id
questionnaire_submission_id
class promapp.models.QuestionnaireItemRule(*args, **kwargs)[source]

Bases: Model

Questionnaire Item Rule model. This is used to store rules that determine when a questionnaire item should be visible.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_item

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

dependent_item

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

OPERATOR_CHOICES = [('EQUALS', 'Equals'), ('NOT_EQUALS', 'Not Equals'), ('GREATER_THAN', 'Greater Than'), ('LESS_THAN', 'Less Than'), ('GREATER_THAN_EQUALS', 'Greater Than or Equals'), ('LESS_THAN_EQUALS', 'Less Than or Equals'), ('CONTAINS', 'Contains'), ('NOT_CONTAINS', 'Does Not Contain')]
operator

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

comparison_value

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

LOGICAL_OPERATOR_CHOICES = [('AND', 'And'), ('OR', 'Or')]
logical_operator

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

rule_order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

dependent_item_id
get_logical_operator_display(*, field=<django.db.models.fields.CharField: logical_operator>)
get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_operator_display(*, field=<django.db.models.fields.CharField: operator>)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
questionnaire_item_id
rule_groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class promapp.models.QuestionnaireItemRuleGroup(*args, **kwargs)[source]

Bases: Model

Questionnaire Item Rule Group model. This is used to group related rules together.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

questionnaire_item

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

rules

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

group_order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

modified_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=True, **kwargs)
get_next_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=True, **kwargs)
get_previous_by_created_date(*, field=<django.db.models.fields.DateTimeField: created_date>, is_next=False, **kwargs)
get_previous_by_modified_date(*, field=<django.db.models.fields.DateTimeField: modified_date>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
questionnaire_item_id
promapp.models.validate_question_number_change(sender, instance, **kwargs)[source]
promapp.models.calculate_construct_scores(sender, instance, created, **kwargs)[source]

Signal handler that calculates construct scores when a questionnaire is submitted.

This function only registers the submission for later processing. The actual calculation happens after all responses are saved.

promapp.models.trigger_score_calculation_on_response(sender, instance, created, **kwargs)[source]

When a response is saved, check if we need to calculate scores. We’ll do this after a slight delay to allow all responses to be saved.

promapp.models.calculate_scores_for_submission(submission)[source]

Calculate construct scores for a completed questionnaire submission.

This function contains the actual calculation logic and can be called either automatically by the signal handler or manually.

promapp.models.calculate_composite_scores_for_submission(submission)[source]

Calculate composite construct scores for a questionnaire submission.

This function calculates composite scores based on CompositeConstructScaleScoring definitions. Only composite scales that have at least one component construct present in the current submission will be processed. Missing construct scores are treated as 0 for the computation.

class promapp.models.ItemTranslation(id, language_code, name, media, master)

Bases: TranslatedFieldsModel

exception DoesNotExist

Bases: TranslationDoesNotExist, DoesNotExist, DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_language_code_display(*, field=<parler.utils.compat.HideChoicesCharField: language_code>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

master

The mandatory Foreign key field to the shared model.

master_id
media

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class promapp.models.LikertScaleResponseOptionTranslation(id, language_code, option_text, option_media, master)

Bases: TranslatedFieldsModel

exception DoesNotExist

Bases: TranslationDoesNotExist, DoesNotExist, DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_language_code_display(*, field=<parler.utils.compat.HideChoicesCharField: language_code>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

master

The mandatory Foreign key field to the shared model.

master_id
objects = <django.db.models.manager.Manager object>
option_media

The descriptor for the file attribute on the model instance. Return a FieldFile when accessed so you can write code like:

>>> from myapp.models import MyModel
>>> instance = MyModel.objects.get(pk=1)
>>> instance.file.size

Assign a file object on assignment so you can do:

>>> with open('/path/to/hello.world') as f:
...     instance.file = File(f)
option_text

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class promapp.models.QuestionnaireTranslation(id, language_code, name, description, master)

Bases: TranslatedFieldsModel

exception DoesNotExist

Bases: TranslationDoesNotExist, DoesNotExist, DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

description

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_language_code_display(*, field=<parler.utils.compat.HideChoicesCharField: language_code>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

master

The mandatory Foreign key field to the shared model.

master_id
name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
class promapp.models.RangeScaleTranslation(id, language_code, min_value_text, max_value_text, master)

Bases: TranslatedFieldsModel

exception DoesNotExist

Bases: TranslationDoesNotExist, DoesNotExist, DoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_language_code_display(*, field=<parler.utils.compat.HideChoicesCharField: language_code>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

language_code

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

master

The mandatory Foreign key field to the shared model.

master_id
max_value_text

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

min_value_text

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>

PROM Forms

class promapp.forms.QuestionnaireForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

class Meta[source]

Bases: object

model

alias of Questionnaire

fields = ['name', 'description', 'questionnaire_answer_interval', 'questionnaire_order', 'questionnaire_redirect']
__init__(*args, **kwargs)[source]
clean_questionnaire_answer_interval()[source]

Clean the questionnaire answer interval field.

clean_questionnaire_order()[source]

Clean the questionnaire order field.

clean()[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__’.

base_fields = {'description': <django.forms.fields.CharField object>, 'interval_unit': <django.forms.fields.ChoiceField object>, 'name': <django.forms.fields.CharField object>, 'questionnaire_answer_interval': <django.forms.fields.IntegerField object>, 'questionnaire_order': <django.forms.fields.IntegerField object>, 'questionnaire_redirect': <django.forms.models.ModelChoiceField object>}
declared_fields = {'description': <django.forms.fields.CharField object>, 'interval_unit': <django.forms.fields.ChoiceField object>, 'name': <django.forms.fields.CharField object>, 'questionnaire_answer_interval': <django.forms.fields.IntegerField object>, 'questionnaire_order': <django.forms.fields.IntegerField object>, 'questionnaire_redirect': <django.forms.models.ModelChoiceField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.ItemSelectionForm(*args, **kwargs)[source]

Bases: Form

__init__(*args, **kwargs)[source]
base_fields = {'items': <django.forms.models.ModelMultipleChoiceField object>}
declared_fields = {'items': <django.forms.models.ModelMultipleChoiceField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.ItemForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

class Meta[source]

Bases: object

model

alias of Item

fields = ['construct_scale', 'name', 'abbreviated_item_id', 'media', 'response_type', 'likert_response', 'range_response', 'is_required', 'item_missing_value', 'item_better_score_direction', 'item_threshold_score', 'item_minimum_clinical_important_difference', 'item_normative_score_mean', 'item_normative_score_standard_deviation']
widgets = {'construct_scale': <django.forms.widgets.SelectMultiple object>, 'is_required': <django.forms.widgets.CheckboxInput object>, 'item_minimum_clinical_important_difference': <django.forms.widgets.NumberInput object>, 'item_missing_value': <django.forms.widgets.NumberInput object>, 'item_normative_score_mean': <django.forms.widgets.NumberInput object>, 'item_normative_score_standard_deviation': <django.forms.widgets.NumberInput object>, 'item_threshold_score': <django.forms.widgets.NumberInput object>, 'likert_response': <django.forms.widgets.Select object>, 'range_response': <django.forms.widgets.Select object>, 'response_type': <django.forms.widgets.Select object>}
__init__(*args, **kwargs)[source]
clean()[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__’.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

base_fields = {'abbreviated_item_id': <django.forms.fields.CharField object>, 'construct_scale': <django.forms.models.ModelMultipleChoiceField object>, 'is_required': <django.forms.fields.BooleanField object>, 'item_better_score_direction': <django.forms.fields.TypedChoiceField object>, 'item_minimum_clinical_important_difference': <django.forms.fields.DecimalField object>, 'item_missing_value': <django.forms.fields.DecimalField object>, 'item_normative_score_mean': <django.forms.fields.DecimalField object>, 'item_normative_score_standard_deviation': <django.forms.fields.DecimalField object>, 'item_threshold_score': <django.forms.fields.DecimalField object>, 'likert_response': <django.forms.models.ModelChoiceField object>, 'media': <django.forms.fields.FileField object>, 'name': <django.forms.fields.CharField object>, 'range_response': <django.forms.models.ModelChoiceField object>, 'response_type': <django.forms.fields.TypedChoiceField object>}
declared_fields = {'media': <django.forms.fields.FileField object>, 'name': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.ConstructScaleForm(*args, **kwargs)[source]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of ConstructScale

fields = ['name', 'instrument_name', 'instrument_version', 'scale_better_score_direction', 'scale_threshold_score', 'scale_minimum_clinical_important_difference', 'scale_normative_score_mean', 'scale_normative_score_standard_deviation']
widgets = {'scale_minimum_clinical_important_difference': <django.forms.widgets.NumberInput object>, 'scale_normative_score_mean': <django.forms.widgets.NumberInput object>, 'scale_normative_score_standard_deviation': <django.forms.widgets.NumberInput object>, 'scale_threshold_score': <django.forms.widgets.NumberInput object>}
__init__(*args, **kwargs)[source]
base_fields = {'instrument_name': <django.forms.fields.CharField object>, 'instrument_version': <django.forms.fields.CharField object>, 'name': <django.forms.fields.CharField object>, 'scale_better_score_direction': <django.forms.fields.TypedChoiceField object>, 'scale_minimum_clinical_important_difference': <django.forms.fields.DecimalField object>, 'scale_normative_score_mean': <django.forms.fields.DecimalField object>, 'scale_normative_score_standard_deviation': <django.forms.fields.DecimalField object>, 'scale_threshold_score': <django.forms.fields.DecimalField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class promapp.forms.LikertScaleForm(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]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of LikertScale

fields = ['likert_scale_name']
base_fields = {'likert_scale_name': <django.forms.fields.CharField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class promapp.forms.LikertScaleResponseOptionForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

class Meta[source]

Bases: object

model

alias of LikertScaleResponseOption

fields = ['option_order', 'option_text', 'option_value', 'option_emoji', 'option_media']
widgets = {'option_emoji': <django.forms.widgets.TextInput object>}
base_fields = {'option_emoji': <django.forms.fields.CharField object>, 'option_media': <django.forms.fields.FileField object>, 'option_order': <django.forms.fields.IntegerField object>, 'option_text': <django.forms.fields.CharField object>, 'option_value': <django.forms.fields.DecimalField object>}
declared_fields = {'option_media': <django.forms.fields.FileField object>, 'option_text': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.QuestionnaireItemForm(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]

Bases: ModelForm

class Meta[source]

Bases: object

model

alias of QuestionnaireItem

fields = ['questionnaire', 'item']
base_fields = {'item': <django.forms.models.ModelChoiceField object>, 'questionnaire': <django.forms.models.ModelChoiceField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class promapp.forms.RangeScaleForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

class Meta[source]

Bases: object

model

alias of RangeScale

fields = ['range_scale_name', 'min_value', 'max_value', 'increment', 'min_value_text', 'max_value_text']
widgets = {'increment': <django.forms.widgets.NumberInput object>, 'max_value': <django.forms.widgets.NumberInput object>, 'min_value': <django.forms.widgets.NumberInput object>}
__init__(*args, **kwargs)[source]
base_fields = {'increment': <django.forms.fields.DecimalField object>, 'max_value': <django.forms.fields.DecimalField object>, 'max_value_text': <django.forms.fields.CharField object>, 'min_value': <django.forms.fields.DecimalField object>, 'min_value_text': <django.forms.fields.CharField object>, 'range_scale_name': <django.forms.fields.CharField object>}
declared_fields = {'max_value_text': <django.forms.fields.CharField object>, 'min_value_text': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.QuestionnaireResponseForm(*args, **kwargs)[source]

Bases: Form

Form for handling questionnaire responses. This form is dynamically created based on the questionnaire items.

__init__(*args, **kwargs)[source]
clean()[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__’.

base_fields = {}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class promapp.forms.QuestionnaireItemRuleForm(*args, **kwargs)[source]

Bases: ModelForm

Form for creating and editing questionnaire item rules.

class Meta[source]

Bases: object

model

alias of QuestionnaireItemRule

fields = ['dependent_item', 'operator', 'comparison_value', 'logical_operator', 'rule_order']
widgets = {'comparison_value': <django.forms.widgets.TextInput object>, 'logical_operator': <django.forms.widgets.Select object>, 'operator': <django.forms.widgets.Select object>, 'rule_order': <django.forms.widgets.NumberInput object>}
__init__(*args, **kwargs)[source]
clean()[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__’.

base_fields = {'comparison_value': <django.forms.fields.CharField object>, 'dependent_item': <django.forms.models.ModelChoiceField object>, 'logical_operator': <django.forms.fields.TypedChoiceField object>, 'operator': <django.forms.fields.TypedChoiceField object>, 'rule_order': <django.forms.fields.IntegerField object>}
declared_fields = {}
property media

Return all media required to render the widgets on this form.

class promapp.forms.QuestionnaireItemRuleGroupForm(*args, **kwargs)[source]

Bases: ModelForm

Form for creating and editing questionnaire item rule groups.

class Meta[source]

Bases: object

model

alias of QuestionnaireItemRuleGroup

fields = ['group_order']
widgets = {'group_order': <django.forms.widgets.NumberInput object>}
__init__(*args, **kwargs)[source]
clean()[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__’.

save(commit=True)[source]

Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.

base_fields = {'group_order': <django.forms.fields.IntegerField object>, 'rules': <django.forms.models.ModelMultipleChoiceField object>}
declared_fields = {'rules': <django.forms.models.ModelMultipleChoiceField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.ItemTranslationForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

Form for translating Item model.

property media

Return all media required to render the widgets on this form.

class Meta[source]

Bases: object

model

alias of Item

fields = ['name', 'media']
clean()[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__’.

__init__(*args, **kwargs)[source]
base_fields = {'media': <django.forms.fields.FileField object>, 'name': <django.forms.fields.CharField object>}
declared_fields = {'media': <django.forms.fields.FileField object>, 'name': <django.forms.fields.CharField object>}
class promapp.forms.QuestionnaireTranslationForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

Form for translating Questionnaire model.

class Meta[source]

Bases: object

model

alias of Questionnaire

fields = ['name', 'description']
__init__(*args, **kwargs)[source]
base_fields = {'description': <django.forms.fields.CharField object>, 'name': <django.forms.fields.CharField object>}
declared_fields = {'description': <django.forms.fields.CharField object>, 'name': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.LikertScaleResponseOptionTranslationForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

Form for translating LikertScaleResponseOption model.

class Meta[source]

Bases: object

model

alias of LikertScaleResponseOption

fields = ['option_text', 'option_media']
__init__(*args, **kwargs)[source]
base_fields = {'option_media': <django.forms.fields.FileField object>, 'option_text': <django.forms.fields.CharField object>}
declared_fields = {'option_media': <django.forms.fields.FileField object>, 'option_text': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.RangeScaleTranslationForm(*args, **kwargs)[source]

Bases: TranslatableModelForm

Form for translating RangeScale model.

class Meta[source]

Bases: object

model

alias of RangeScale

fields = ['min_value_text', 'max_value_text']
__init__(*args, **kwargs)[source]
base_fields = {'max_value_text': <django.forms.fields.CharField object>, 'min_value_text': <django.forms.fields.CharField object>}
declared_fields = {'max_value_text': <django.forms.fields.CharField object>, 'min_value_text': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.TranslationSearchForm(*args, **kwargs)[source]

Bases: Form

Form for searching and filtering translation lists.

__init__(*args, **kwargs)[source]
base_fields = {'language_filter': <django.forms.fields.ChoiceField object>, 'search': <django.forms.fields.CharField object>}
declared_fields = {'language_filter': <django.forms.fields.ChoiceField object>, 'search': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.ConstructEquationForm(*args, **kwargs)[source]

Bases: ModelForm

Form for managing the equation of a construct scale.

class Meta[source]

Bases: object

model

alias of ConstructScale

fields = ['scale_equation']
__init__(*args, **kwargs)[source]
clean_scale_equation()[source]
base_fields = {'scale_equation': <django.forms.fields.CharField object>}
declared_fields = {'scale_equation': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.CompositeConstructScaleScoringForm(*args, **kwargs)[source]

Bases: ModelForm

Form for creating and editing composite construct scale scoring configurations.

class Meta[source]

Bases: object

model

alias of CompositeConstructScaleScoring

fields = ['composite_construct_scale_name', 'construct_scales', 'scoring_type', 'composite_construct_score_direction', 'composite_construct_scale_threshold_score', 'composite_construct_scale_minimum_clinical_important_difference', 'composite_construct_scale_normative_score_mean', 'composite_construct_scale_normative_score_standard_deviation']
widgets = {'composite_construct_scale_minimum_clinical_important_difference': <django.forms.widgets.TextInput object>, 'composite_construct_scale_name': <django.forms.widgets.TextInput object>, 'composite_construct_scale_normative_score_mean': <django.forms.widgets.TextInput object>, 'composite_construct_scale_normative_score_standard_deviation': <django.forms.widgets.TextInput object>, 'composite_construct_scale_threshold_score': <django.forms.widgets.TextInput object>, 'composite_construct_score_direction': <django.forms.widgets.Select object>, 'scoring_type': <django.forms.widgets.Select object>}
__init__(*args, **kwargs)[source]
clean_construct_scales()[source]
base_fields = {'composite_construct_scale_minimum_clinical_important_difference': <django.forms.fields.CharField object>, 'composite_construct_scale_name': <django.forms.fields.CharField object>, 'composite_construct_scale_normative_score_mean': <django.forms.fields.CharField object>, 'composite_construct_scale_normative_score_standard_deviation': <django.forms.fields.CharField object>, 'composite_construct_scale_threshold_score': <django.forms.fields.CharField object>, 'composite_construct_score_direction': <django.forms.fields.TypedChoiceField object>, 'construct_scales': <django.forms.models.ModelMultipleChoiceField object>, 'scoring_type': <django.forms.fields.TypedChoiceField object>}
declared_fields = {'construct_scales': <django.forms.models.ModelMultipleChoiceField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.StaffQuestionnaireResponseForm(*args, **kwargs)[source]

Bases: Form

Form for staff to submit questionnaire responses on behalf of patients. Includes patient selection and custom submission date.

__init__(*args, **kwargs)[source]
clean_patient()[source]
clean()[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__’.

base_fields = {'patient': <django.forms.fields.CharField object>, 'submission_date': <django.forms.fields.DateTimeField object>}
declared_fields = {'patient': <django.forms.fields.CharField object>, 'submission_date': <django.forms.fields.DateTimeField object>}
property media

Return all media required to render the widgets on this form.

class promapp.forms.AIAPIConfigurationForm(*args, **kwargs)[source]

Bases: ModelForm

Form for AIAPIConfiguration with dynamic utility function choices.

class Meta[source]

Bases: object

model

alias of AIAPIConfiguration

fields = ['ai_provider', 'ai_capability', 'utility_function_path', 'api_url', 'api_key_environment_variable_name']
__init__(*args, **kwargs)[source]
base_fields = {'ai_capability': <django.forms.fields.TypedChoiceField object>, 'ai_provider': <django.forms.fields.CharField object>, 'api_key_environment_variable_name': <django.forms.fields.CharField object>, 'api_url': <django.forms.fields.CharField object>, 'utility_function_path': <django.forms.fields.ChoiceField object>}
declared_fields = {'utility_function_path': <django.forms.fields.ChoiceField object>}
property media

Return all media required to render the widgets on this form.

Schedule Forms

class promapp.schedule_forms.QuestionnaireScheduleForm(patient, *args, **kwargs)[source]

Bases: Form

Form for scheduling questionnaires for a patient. Allows selecting multiple questionnaires and multiple dates.

__init__(patient, *args, **kwargs)[source]
clean_scheduled_dates()[source]

Validate that scheduled dates are provided and in correct format. Expected format: JSON array of ISO datetime strings

clean()[source]

Validate that selected dates respect questionnaire answer intervals.

save()[source]

Create schedule entries for selected questionnaires and dates. Returns the number of schedules created.

base_fields = {'questionnaires': <django.forms.fields.MultipleChoiceField object>, 'scheduled_dates': <django.forms.fields.CharField object>}
declared_fields = {'questionnaires': <django.forms.fields.MultipleChoiceField object>, 'scheduled_dates': <django.forms.fields.CharField object>}
property media

Return all media required to render the widgets on this form.

Equation Parser

class promapp.equation_parser.EquationValidator[source]

Bases: object

__init__()[source]
validate(equation)[source]

Validates an equation string using the Lark grammar. Returns True if valid, raises ValidationError if invalid.

class promapp.equation_parser.EquationTransformer(question_values=None, minimum_required_items=0)[source]

Bases: Transformer

Transformer to evaluate the equation. This can be used later to actually calculate the equation value.

__init__(question_values=None, minimum_required_items=0)[source]

Initialize transformer with optional question values dictionary and minimum required items. question_values should be a dict mapping question numbers to their values. minimum_required_items specifies the minimum number of non-None values required for a valid score.

transform(tree)[source]

Override transform to catch VisitError and convert to ValidationError

add(a, b)[source]
sub(a, b)[source]
mul(a, b)[source]
div(a, b)[source]
pow(a, b)[source]
neg(a)[source]
NUMBER(n)[source]
null(*args)[source]

Convert the null keyword to Python None

QUESTION_REF(q)[source]

Handle question references like {q1}, {q2}, etc. Returns the value from question_values if available, otherwise raises ValidationError.

func(args)[source]

Handle function calls. The first argument is the function name, the rest are the function arguments.

abs(x)[source]

Calculate absolute value, handling None values

count_available(*args)[source]

Count the number of non-None values in the arguments

validate_minimum_items(*args)[source]

Validate that we have enough non-None values to calculate a score

sum(*args)[source]

Sum only the non-None values, after validating minimum items

min(*args)[source]

Find minimum of non-None values, after validating minimum items

max(*args)[source]

Find maximum of non-None values, after validating minimum items

round(x, digits=0)[source]

Round a number, handling None values

sqrt(x)[source]

Calculate square root, handling None values

eq(left, right)[source]

Handle equality comparison, including None values

ne(left, right)[source]

Handle inequality comparison, including None values

gt(left, right)[source]

Handle greater than comparison, including None values

lt(left, right)[source]

Handle less than comparison, including None values

ge(left, right)[source]

Handle greater than or equal comparison, including None values

le(left, right)[source]

Handle less than or equal comparison, including None values

if_expr(condition, then_expr, else_clause)[source]
elif_expr(condition, then_expr, else_clause)[source]
else_expr(expr)[source]
and_op(a, b)[source]

Handle logical AND operation, including None values

or_op(a, b)[source]

Handle logical OR operation, including None values

xor_op(a, b)[source]

Handle logical XOR operation, including None values

statements(args)[source]

Handle multiple statements, return the last expression value

assignment(args)[source]

Handle variable assignment: VARNAME = expr

var_ref(args)[source]

Handle variable reference

start(expr)[source]

Translation Utilities

Template Tags

promapp.templatetags.prom_filters.get_item(dictionary, key)[source]

Get an item from a dictionary by key

promapp.templatetags.prom_filters.subtract(value, arg)[source]

Subtract arg from value

promapp.templatetags.prom_filters.abs_value(value)[source]

Return absolute value

promapp.templatetags.prom_filters.divide(value, arg)[source]

Divide value by arg

promapp.templatetags.prom_filters.get_latest_aggregated_stat(aggregated_statistics)[source]

Get the latest (most recent time interval) aggregated statistic

promapp.templatetags.prom_filters.get_clinical_status(score_data)[source]

Determine clinical status for a construct score. Returns: ‘concerning’, ‘favorable’, or ‘stable’

promapp.templatetags.prom_filters.generate_simplified_summary(score_data, item_responses_grouped=None)[source]

Generate a simplified, natural language summary for print reports.

Example output: “The neurological problems score is 33.3, which is stable since the last visit but significantly above the normal threshold of 9.0. Most people in the reference group score 0.0, meaning this patient scores much higher than typical. This elevated score needs clinical attention.”

promapp.templatetags.prom_filters.generate_simplified_summary_no_improved_items(score_data, item_responses_grouped=None)[source]

Generate a simplified summary that only includes worsened items, not improved items. Used for ‘Other Construct Scores’ section to reduce verbosity.

AI Utilities

Utility functions for discovering and managing AI utility functions

promapp.ai_utils.utils.discover_utility_functions()[source]

Discover all available utility functions in the ai_utils directory.

Returns:

List of tuples (function_path, display_name) for use in model choices

Return type:

list

promapp.ai_utils.utils.get_utility_function_choices()[source]

Get choices for the utility_function_path field.

Returns:

List of tuples (value, label) for Django field choices

Return type:

list

Text-to-Speech utility using Sarvam AI

This module provides the utility function for converting text to speech using the Sarvam AI SDK.

promapp.ai_utils.sarvamai_tts.sarvam_tts(text, language_code='en-IN', config=None)[source]

Convert text to speech using Sarvam AI SDK.

Parameters:
  • text (str) – The text to convert to speech

  • language_code (str) – Language code (e.g., ‘en-IN’, ‘hi-IN’, ‘ta-IN’)

  • config (AIAPIConfiguration, optional) – The configuration object containing API details

Returns:

Dictionary containing:
  • ’audio_data’: bytes - Decoded WAV audio data

  • ’request_id’: str - Request ID from Sarvam API (if available)

  • ’format’: str - Audio format (always ‘wav’)

Return type:

dict

Raises:

Provider Management

Provider Models

class providerapp.models.ProviderType(id, name, created_at, updated_at)[source]

Bases: Model

name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
provider_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_reverse_many_to_one_manager() defined below.

class providerapp.models.Provider(id, user, provider_type, institution, employee_id, account_expiry_date, created_at, updated_at)[source]

Bases: Model

user

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

provider_type

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

institution

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

employee_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

account_expiry_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated_at

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

exception NotUpdated

Bases: ObjectNotUpdated, DatabaseError

get_next_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=True, **kwargs)
get_next_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=True, **kwargs)
get_previous_by_created_at(*, field=<django.db.models.fields.DateTimeField: created_at>, is_next=False, **kwargs)
get_previous_by_updated_at(*, field=<django.db.models.fields.DateTimeField: updated_at>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

institution_id
objects = <django.db.models.manager.Manager object>
provider_type_id
user_id

Provider Views

Core Application

Core Views

class chaviprom.views.IndexView(**kwargs)[source]

Bases: TemplateView

Main index/home page view that displays system statistics.

template_name = 'index.html'
get_context_data(**kwargs)[source]

Context Processors

chaviprom.context_processors.language_fonts(request)[source]

Context processor that provides language-specific font information to all templates.

Adapter

class chaviprom.adapter.CustomAccountAdapter(request: HttpRequest | None = None)[source]

Bases: DefaultAccountAdapter

Custom adapter to handle IP detection for Django Allauth 65.14.2+

In version 65.14.2, Allauth changed IP detection to distrust X-Forwarded-For by default for security. This adapter ensures proper IP detection in both development (localhost) and production (behind reverse proxy) environments.

Production: Uses ALLAUTH_TRUSTED_CLIENT_IP_HEADER and ALLAUTH_TRUSTED_PROXY_COUNT Development: Falls back to REMOTE_ADDR when no proxy is configured

get_client_ip(request)[source]

Override IP detection to handle both local development and production.

For production with reverse proxy: Parent implementation uses ALLAUTH_TRUSTED_* settings For local development: Falls back to REMOTE_ADDR when parent returns None