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.
- patientapp.views.prom_review_item_search(request, pk)[source]¶
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.
- class patientapp.views.PatientCreateView(**kwargs)[source]¶
Bases:
InstitutionFilterMixin,LoginRequiredMixin,PermissionRequiredMixin,CreateView- form_class¶
alias of
PatientForm
- template_name = 'patientapp/patient_form.html'¶
- success_url = '/en-gb/patientapp/patients/'¶
- permission_required = 'patientapp.add_patient'¶
- class patientapp.views.PatientRestrictedUpdateView(**kwargs)[source]¶
Bases:
InstitutionFilterMixin,LoginRequiredMixin,PermissionRequiredMixin,UpdateView- form_class¶
alias of
PatientRestrictedUpdateForm
- template_name = 'patientapp/patient_restricted_update_form.html'¶
- permission_required = 'patientapp.change_patient'¶
- class patientapp.views.DiagnosisCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateView- form_class¶
alias of
DiagnosisForm
- template_name = 'patientapp/diagnosis_form.html'¶
- permission_required = 'patientapp.add_diagnosis'¶
- class patientapp.views.DiagnosisUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateView- form_class¶
alias of
DiagnosisForm
- template_name = 'patientapp/diagnosis_form.html'¶
- permission_required = 'patientapp.change_diagnosis'¶
- class patientapp.views.DiagnosisListCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateViewView 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'¶
- class patientapp.views.TreatmentCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateView- form_class¶
alias of
TreatmentForm
- template_name = 'patientapp/treatment_form.html'¶
- permission_required = 'patientapp.add_treatment'¶
- class patientapp.views.TreatmentUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateView- form_class¶
alias of
TreatmentForm
- template_name = 'patientapp/treatment_form.html'¶
- permission_required = 'patientapp.change_treatment'¶
- 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_fieldfield on the object instance that the view is operating upon (if available)<app_label>/<model_name><template_name_suffix>.html
- 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'¶
- 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.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.
Patient Models¶
- class patientapp.models.Institution(*args, **kwargs)[source]¶
Bases:
ModelInstitution 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelThis 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelPatient 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.parentis aForwardManyToOneDescriptorinstance.
- 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.placeis aForwardOneToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelPatientProject 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelList 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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelDiagnosis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelTreatment 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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:
ModelTreatment 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.parentis aForwardManyToOneDescriptorinstance.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.
- 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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
TextChoicesThese 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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
FormA 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- 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>}¶
- 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- fields = ['diagnosis', 'date_of_diagnosis']¶
- widgets = {'date_of_diagnosis': <django.forms.widgets.DateInput object>}¶
- 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- fields = ['age', 'gender', 'institution', 'date_of_registration', 'preferred_language']¶
- widgets = {'age': <django.forms.widgets.NumberInput object>, 'date_of_registration': <django.forms.widgets.DateInput object>}¶
- 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- 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>}¶
- 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- 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>}¶
- 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>}¶
- 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- 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- 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- 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:
- 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:
- 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:
- 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:
- 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]¶
- 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:
objectData class for composite construct scores with plotting capabilities.
- 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:
- 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:
- 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:
- 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:
Add Parameter: Add the new filter parameter to the function signature
Add Documentation: Update this docstring with the new parameter description
Implement Filter Logic: Add the filtering logic following existing patterns
Update Callers: Update all places that call this function
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:
- 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:
- 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:
- 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.
Patient Middleware¶
- class patientapp.middleware.PatientLanguageMiddleware(get_response)[source]¶
Bases:
objectMiddleware 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.
PROM Management¶
PROM Views¶
- class promapp.views.QuestionnaireListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewQuestionnaire 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¶
- class promapp.views.QuestionnaireDetailView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,DetailViewQuestionnaire 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'¶
- class promapp.views.QuestionnaireCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateViewQuestionnaire 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'¶
- class promapp.views.QuestionnaireUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewQuestionnaire 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'¶
- class promapp.views.ItemListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewItem 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¶
- class promapp.views.ItemCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateViewView to create items
- model¶
alias of
Item
- template_name = 'promapp/item_create.html'¶
- success_url = '/en-gb/promapp/items/'¶
- permission_required = 'promapp.add_item'¶
- class promapp.views.ItemUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView to update items
- model¶
alias of
Item
- template_name = 'promapp/item_update.html'¶
- success_url = '/en-gb/promapp/items/'¶
- permission_required = 'promapp.change_item'¶
- promapp.views.get_response_fields(request)[source]¶
Get the response fields based on the selected response type
- promapp.views.create_construct_scale(request)[source]¶
Function-based view for creating construct scales
- class promapp.views.LikertScaleListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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¶
- class promapp.views.RangeScaleListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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¶
- class promapp.views.ConstructScaleListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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¶
- class promapp.views.QuestionnaireResponseView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UserPassesTestMixin,DetailViewView 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.
- get_translated_items(questionnaire)[source]¶
Helper method to get questionnaire items with properly translated Likert options
- class promapp.views.PatientQuestionnaireManagementView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,DetailViewView for managing questionnaires assigned to a patient. This view allows staff to assign/unassign questionnaires to patients.
- template_name = 'promapp/patient_questionnaire_management.html'¶
- context_object_name = 'patient'¶
- permission_required = 'promapp.add_patientquestionnaire'¶
- class promapp.views.PatientQuestionnaireListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView for listing patients who have questionnaires assigned to them.
- template_name = 'promapp/patient_questionnaire_list.html'¶
- context_object_name = 'patients'¶
- permission_required = 'promapp.view_patientquestionnaire'¶
- paginate_by = 25¶
- class promapp.views.MyQuestionnaireListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,ListViewView 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'¶
- 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,ListViewView 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'¶
- class promapp.views.QuestionnaireItemRuleCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateViewView 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'¶
- class promapp.views.QuestionnaireItemRuleUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView 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'¶
- class promapp.views.QuestionnaireItemRuleDeleteView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,DeleteViewView for deleting a rule.
- model¶
alias of
QuestionnaireItemRule
- permission_required = 'promapp.delete_questionnaireitemrule'¶
- class promapp.views.QuestionnaireItemRuleGroupListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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'¶
- class promapp.views.QuestionnaireItemRuleGroupCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateViewView 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'¶
- class promapp.views.QuestionnaireItemRuleGroupUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView 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'¶
- class promapp.views.QuestionnaireItemRuleGroupDeleteView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,DeleteViewView for deleting a rule group.
- model¶
alias of
QuestionnaireItemRuleGroup
- permission_required = 'promapp.delete_questionnaireitemrulegroup'¶
- class promapp.views.QuestionnaireExportListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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¶
- class promapp.views.ProjectExportListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView for listing projects available for export.
- template_name = 'promapp/project_export_list.html'¶
- context_object_name = 'projects'¶
- permission_required = 'patientapp.view_project'¶
- paginate_by = 25¶
- class promapp.views.ProjectQuestionnaireExportListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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¶
- class promapp.views.QuestionnaireExportPatientListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView for listing patients who have submitted a specific questionnaire.
- template_name = 'promapp/questionnaire_export_patient_list.html'¶
- context_object_name = 'patients'¶
- permission_required = 'promapp.view_questionnaire'¶
- paginate_by = 25¶
- 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_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,DetailViewView 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'¶
- 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,UpdateViewView 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'¶
- class promapp.views.ItemTranslationListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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'¶
- class promapp.views.QuestionnaireTranslationView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView 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'¶
- class promapp.views.QuestionnaireTranslationListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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'¶
- class promapp.views.LikertScaleResponseOptionTranslationView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView for managing translations of a LikertScaleResponseOption.
- model¶
alias of
LikertScaleResponseOption
- form_class¶
- template_name = 'promapp/likert_scale_response_option_translation_form.html'¶
- permission_required = 'promapp.add_likertscaleresponseoption'¶
- class promapp.views.LikertScaleResponseOptionTranslationListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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'¶
- class promapp.views.RangeScaleTranslationView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView 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'¶
- class promapp.views.RangeScaleTranslationListView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,ListViewView 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'¶
- promapp.views.switch_language(request)[source]¶
View to switch the current language for translation.
- class promapp.views.TranslationsDashboardView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,TemplateViewView for the translations dashboard.
- template_name = 'promapp/translations_dashboard.html'¶
- permission_required = 'promapp.add_questionnaire'¶
- 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,UpdateViewView 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'¶
- class promapp.views.ConstructScaleUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView 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'¶
- class promapp.views.ConstructScaleDeleteView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,DeleteViewView for deleting a construct scale.
- model¶
alias of
ConstructScale
- permission_required = 'promapp.delete_constructscale'¶
- 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,ListViewView 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¶
- class promapp.views.CompositeConstructScaleScoringCreateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,CreateViewView 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'¶
- class promapp.views.CompositeConstructScaleScoringUpdateView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,UpdateViewView 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'¶
- class promapp.views.CompositeConstructScaleScoringDeleteView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,DeleteViewView for deleting a composite construct scale scoring configuration.
- model¶
alias of
CompositeConstructScaleScoring
- permission_required = 'promapp.delete_compositeconstructscalescoring'¶
- class promapp.views.QuestionnaireGuidanceView(**kwargs)[source]¶
Bases:
LoginRequiredMixin,PermissionRequiredMixin,TemplateViewView 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'¶
- 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,DetailViewView 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.
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:
ModelConstruct 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelComposite 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelAI 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:
ModelLikert 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
TranslatableModelLikert 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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:
- 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:
TranslatableModelRange 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
TranslatableModelItem 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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.childrenis aReverseManyToOneDescriptorinstance.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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
- 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:
- 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.childrenis aReverseManyToOneDescriptorinstance.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:
TranslatableModelQuestionnaire 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.childrenis aReverseManyToOneDescriptorinstance.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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelPatient 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelThis 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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.childrenis aReverseManyToOneDescriptorinstance.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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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:
ModelQuestionnaire 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.parentis aForwardManyToOneDescriptorinstance.
- 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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.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']¶
- 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- 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>}¶
- 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>}¶
- 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- 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>}¶
- 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:
FormForm for handling questionnaire responses. This form is dynamically created based on the questionnaire items.
- 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:
ModelFormForm 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>}¶
- 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:
ModelFormForm 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>}¶
- 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:
TranslatableModelFormForm for translating Item model.
- property media¶
Return all media required to render the widgets on this form.
- 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 = {'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:
TranslatableModelFormForm for translating Questionnaire model.
- 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:
TranslatableModelFormForm for translating LikertScaleResponseOption model.
- class Meta[source]¶
Bases:
object- model¶
alias of
LikertScaleResponseOption
- fields = ['option_text', 'option_media']¶
- 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:
TranslatableModelFormForm for translating RangeScale model.
- class Meta[source]¶
Bases:
object- model¶
alias of
RangeScale
- fields = ['min_value_text', 'max_value_text']¶
- 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:
FormForm for searching and filtering translation lists.
- 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:
ModelFormForm for managing the equation of a construct scale.
- 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:
ModelFormForm 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>}¶
- 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:
FormForm for staff to submit questionnaire responses on behalf of patients. Includes patient selection and custom submission date.
- 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:
ModelFormForm 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']¶
- 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:
FormForm for scheduling questionnaires for a patient. Allows selecting multiple questionnaires and multiple dates.
- clean_scheduled_dates()[source]¶
Validate that scheduled dates are provided and in correct format. Expected format: JSON array of ISO datetime strings
- 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.EquationTransformer(question_values=None, minimum_required_items=0)[source]¶
Bases:
TransformerTransformer 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.
- 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.
Translation Utilities¶
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:
- 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:
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:
- 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:
- Raises:
ValueError – If configuration is invalid or text is empty
Exception – If API call fails
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.childrenis aReverseManyToOneDescriptorinstance.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.placeis aForwardOneToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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.parentis aForwardManyToOneDescriptorinstance.
- 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¶
Context Processors¶
Adapter¶
- class chaviprom.adapter.CustomAccountAdapter(request: HttpRequest | None = None)[source]¶
Bases:
DefaultAccountAdapterCustom 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