452 lines
18 KiB
Python
452 lines
18 KiB
Python
"""
|
|
Django forms for psychology app.
|
|
"""
|
|
|
|
from django import forms
|
|
from django.utils.translation import gettext_lazy as _
|
|
from crispy_forms.helper import FormHelper
|
|
from crispy_forms.layout import Layout, Fieldset, Row, Column, Submit, HTML
|
|
|
|
from .models import (
|
|
PsychologyConsultation,
|
|
PsychologyAssessment,
|
|
PsychologySession,
|
|
PsychologyGoal,
|
|
PsychologyProgressReport,
|
|
)
|
|
|
|
|
|
class PsychologyConsultationForm(forms.ModelForm):
|
|
"""Form for creating/editing psychology consultations."""
|
|
|
|
class Meta:
|
|
model = PsychologyConsultation
|
|
fields = [
|
|
'patient', 'tenant', 'consultation_date', 'provider', 'appointment',
|
|
'referral_reason', 'referral_source', 'presenting_problem',
|
|
'family_history', 'medical_history', 'developmental_history',
|
|
'educational_history', 'social_history',
|
|
'appearance', 'behavior', 'mood', 'affect', 'speech',
|
|
'thought_process', 'thought_content', 'perception',
|
|
'cognition', 'insight', 'judgment',
|
|
'suicide_risk', 'homicide_risk', 'risk_assessment_notes',
|
|
'clinical_impressions', 'provisional_diagnosis',
|
|
'treatment_goals', 'treatment_approach', 'recommendations',
|
|
'frequency_duration', 'referrals_needed',
|
|
]
|
|
widgets = {
|
|
'consultation_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'presenting_problem': forms.Textarea(attrs={'rows': 4}),
|
|
'family_history': forms.Textarea(attrs={'rows': 3}),
|
|
'medical_history': forms.Textarea(attrs={'rows': 3}),
|
|
'developmental_history': forms.Textarea(attrs={'rows': 3}),
|
|
'educational_history': forms.Textarea(attrs={'rows': 3}),
|
|
'social_history': forms.Textarea(attrs={'rows': 3}),
|
|
'appearance': forms.Textarea(attrs={'rows': 2}),
|
|
'behavior': forms.Textarea(attrs={'rows': 2}),
|
|
'speech': forms.Textarea(attrs={'rows': 2}),
|
|
'thought_process': forms.Textarea(attrs={'rows': 2}),
|
|
'thought_content': forms.Textarea(attrs={'rows': 2}),
|
|
'perception': forms.Textarea(attrs={'rows': 2}),
|
|
'cognition': forms.Textarea(attrs={'rows': 2}),
|
|
'risk_assessment_notes': forms.Textarea(attrs={'rows': 3}),
|
|
'clinical_impressions': forms.Textarea(attrs={'rows': 4}),
|
|
'provisional_diagnosis': forms.Textarea(attrs={'rows': 3}),
|
|
'treatment_goals': forms.Textarea(attrs={'rows': 4}),
|
|
'treatment_approach': forms.Textarea(attrs={'rows': 3}),
|
|
'recommendations': forms.Textarea(attrs={'rows': 4}),
|
|
'referrals_needed': forms.Textarea(attrs={'rows': 2}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Patient & Provider Information'),
|
|
Row(
|
|
Column('patient', css_class='col-md-4'),
|
|
Column('tenant', css_class='col-md-4'),
|
|
Column('consultation_date', css_class='col-md-4'),
|
|
),
|
|
Row(
|
|
Column('provider', css_class='col-md-6'),
|
|
Column('appointment', css_class='col-md-6'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Referral Information'),
|
|
Row(
|
|
Column('referral_reason', css_class='col-md-6'),
|
|
Column('referral_source', css_class='col-md-6'),
|
|
),
|
|
'presenting_problem',
|
|
),
|
|
Fieldset(
|
|
_('Background Information'),
|
|
'family_history',
|
|
'medical_history',
|
|
'developmental_history',
|
|
'educational_history',
|
|
'social_history',
|
|
),
|
|
Fieldset(
|
|
_('Mental Status Examination'),
|
|
Row(
|
|
Column('appearance', css_class='col-md-6'),
|
|
Column('behavior', css_class='col-md-6'),
|
|
),
|
|
Row(
|
|
Column('mood', css_class='col-md-6'),
|
|
Column('affect', css_class='col-md-6'),
|
|
),
|
|
'speech',
|
|
Row(
|
|
Column('thought_process', css_class='col-md-6'),
|
|
Column('thought_content', css_class='col-md-6'),
|
|
),
|
|
Row(
|
|
Column('perception', css_class='col-md-6'),
|
|
Column('cognition', css_class='col-md-6'),
|
|
),
|
|
Row(
|
|
Column('insight', css_class='col-md-6'),
|
|
Column('judgment', css_class='col-md-6'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Risk Assessment'),
|
|
Row(
|
|
Column('suicide_risk', css_class='col-md-6'),
|
|
Column('homicide_risk', css_class='col-md-6'),
|
|
),
|
|
'risk_assessment_notes',
|
|
),
|
|
Fieldset(
|
|
_('Clinical Impressions & Diagnosis'),
|
|
'clinical_impressions',
|
|
'provisional_diagnosis',
|
|
),
|
|
Fieldset(
|
|
_('Treatment Plan'),
|
|
'treatment_goals',
|
|
'treatment_approach',
|
|
'recommendations',
|
|
Row(
|
|
Column('frequency_duration', css_class='col-md-6'),
|
|
Column('referrals_needed', css_class='col-md-6'),
|
|
),
|
|
),
|
|
Submit('submit', _('Save Consultation'), css_class='btn btn-primary'),
|
|
)
|
|
|
|
|
|
class PsychologyAssessmentForm(forms.ModelForm):
|
|
"""Form for creating/editing psychology assessments."""
|
|
|
|
class Meta:
|
|
model = PsychologyAssessment
|
|
fields = [
|
|
'patient', 'tenant', 'assessment_date', 'provider', 'appointment',
|
|
'assessment_type', 'reason_for_assessment',
|
|
'relevant_history', 'current_medications',
|
|
'tests_administered', 'behavioral_observations', 'test_validity',
|
|
'cognitive_functioning', 'emotional_functioning',
|
|
'behavioral_functioning', 'social_functioning', 'adaptive_functioning',
|
|
'strengths', 'weaknesses',
|
|
'diagnostic_impressions', 'dsm5_diagnosis',
|
|
'recommendations', 'treatment_recommendations',
|
|
'educational_recommendations', 'follow_up_recommendations',
|
|
]
|
|
widgets = {
|
|
'assessment_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'reason_for_assessment': forms.Textarea(attrs={'rows': 3}),
|
|
'relevant_history': forms.Textarea(attrs={'rows': 3}),
|
|
'current_medications': forms.Textarea(attrs={'rows': 2}),
|
|
'tests_administered': forms.Textarea(attrs={'rows': 4, 'placeholder': 'Enter as JSON array'}),
|
|
'behavioral_observations': forms.Textarea(attrs={'rows': 3}),
|
|
'test_validity': forms.Textarea(attrs={'rows': 2}),
|
|
'cognitive_functioning': forms.Textarea(attrs={'rows': 3}),
|
|
'emotional_functioning': forms.Textarea(attrs={'rows': 3}),
|
|
'behavioral_functioning': forms.Textarea(attrs={'rows': 3}),
|
|
'social_functioning': forms.Textarea(attrs={'rows': 3}),
|
|
'adaptive_functioning': forms.Textarea(attrs={'rows': 3}),
|
|
'strengths': forms.Textarea(attrs={'rows': 3}),
|
|
'weaknesses': forms.Textarea(attrs={'rows': 3}),
|
|
'diagnostic_impressions': forms.Textarea(attrs={'rows': 4}),
|
|
'dsm5_diagnosis': forms.Textarea(attrs={'rows': 3}),
|
|
'recommendations': forms.Textarea(attrs={'rows': 4}),
|
|
'treatment_recommendations': forms.Textarea(attrs={'rows': 3}),
|
|
'educational_recommendations': forms.Textarea(attrs={'rows': 3}),
|
|
'follow_up_recommendations': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Patient & Provider Information'),
|
|
Row(
|
|
Column('patient', css_class='col-md-4'),
|
|
Column('tenant', css_class='col-md-4'),
|
|
Column('assessment_date', css_class='col-md-4'),
|
|
),
|
|
Row(
|
|
Column('provider', css_class='col-md-6'),
|
|
Column('appointment', css_class='col-md-6'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Assessment Details'),
|
|
'assessment_type',
|
|
'reason_for_assessment',
|
|
'relevant_history',
|
|
'current_medications',
|
|
),
|
|
Fieldset(
|
|
_('Tests & Observations'),
|
|
'tests_administered',
|
|
'behavioral_observations',
|
|
'test_validity',
|
|
),
|
|
Fieldset(
|
|
_('Results Summary'),
|
|
'cognitive_functioning',
|
|
'emotional_functioning',
|
|
'behavioral_functioning',
|
|
'social_functioning',
|
|
'adaptive_functioning',
|
|
),
|
|
Fieldset(
|
|
_('Strengths & Weaknesses'),
|
|
Row(
|
|
Column('strengths', css_class='col-md-6'),
|
|
Column('weaknesses', css_class='col-md-6'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Diagnosis'),
|
|
'diagnostic_impressions',
|
|
'dsm5_diagnosis',
|
|
),
|
|
Fieldset(
|
|
_('Recommendations'),
|
|
'recommendations',
|
|
'treatment_recommendations',
|
|
'educational_recommendations',
|
|
'follow_up_recommendations',
|
|
),
|
|
Submit('submit', _('Save Assessment'), css_class='btn btn-primary'),
|
|
)
|
|
|
|
|
|
class PsychologySessionForm(forms.ModelForm):
|
|
"""Form for creating/editing psychology sessions."""
|
|
|
|
class Meta:
|
|
model = PsychologySession
|
|
fields = [
|
|
'patient', 'tenant', 'session_number', 'session_date', 'provider', 'appointment',
|
|
'session_type', 'therapy_modality', 'duration_minutes',
|
|
'presenting_issues', 'interventions_used', 'client_response',
|
|
'progress_toward_goals', 'behavioral_observations', 'mood_affect',
|
|
'current_risk_level', 'risk_notes',
|
|
'homework_assigned', 'plan_for_next_session',
|
|
'clinical_notes',
|
|
]
|
|
widgets = {
|
|
'session_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'presenting_issues': forms.Textarea(attrs={'rows': 3}),
|
|
'interventions_used': forms.Textarea(attrs={'rows': 3}),
|
|
'client_response': forms.Textarea(attrs={'rows': 3}),
|
|
'progress_toward_goals': forms.Textarea(attrs={'rows': 3}),
|
|
'behavioral_observations': forms.Textarea(attrs={'rows': 3}),
|
|
'risk_notes': forms.Textarea(attrs={'rows': 2}),
|
|
'homework_assigned': forms.Textarea(attrs={'rows': 3}),
|
|
'plan_for_next_session': forms.Textarea(attrs={'rows': 3}),
|
|
'clinical_notes': forms.Textarea(attrs={'rows': 4}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Patient & Provider Information'),
|
|
Row(
|
|
Column('patient', css_class='col-md-4'),
|
|
Column('tenant', css_class='col-md-4'),
|
|
Column('session_number', css_class='col-md-4'),
|
|
),
|
|
Row(
|
|
Column('session_date', css_class='col-md-4'),
|
|
Column('provider', css_class='col-md-4'),
|
|
Column('appointment', css_class='col-md-4'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Session Details'),
|
|
Row(
|
|
Column('session_type', css_class='col-md-4'),
|
|
Column('therapy_modality', css_class='col-md-4'),
|
|
Column('duration_minutes', css_class='col-md-4'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Session Content'),
|
|
'presenting_issues',
|
|
'interventions_used',
|
|
'client_response',
|
|
),
|
|
Fieldset(
|
|
_('Progress Notes'),
|
|
'progress_toward_goals',
|
|
'behavioral_observations',
|
|
'mood_affect',
|
|
),
|
|
Fieldset(
|
|
_('Risk Assessment'),
|
|
Row(
|
|
Column('current_risk_level', css_class='col-md-6'),
|
|
Column('risk_notes', css_class='col-md-6'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Homework & Plan'),
|
|
'homework_assigned',
|
|
'plan_for_next_session',
|
|
),
|
|
Fieldset(
|
|
_('Clinical Notes'),
|
|
'clinical_notes',
|
|
),
|
|
Submit('submit', _('Save Session'), css_class='btn btn-primary'),
|
|
)
|
|
|
|
|
|
class PsychologyGoalForm(forms.ModelForm):
|
|
"""Form for creating/editing psychology goals."""
|
|
|
|
class Meta:
|
|
model = PsychologyGoal
|
|
fields = [
|
|
'patient', 'consultation',
|
|
'goal_description', 'target_date', 'status',
|
|
'progress_percentage', 'progress_notes', 'achieved_date',
|
|
]
|
|
widgets = {
|
|
'target_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'achieved_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'goal_description': forms.Textarea(attrs={'rows': 3}),
|
|
'progress_notes': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Goal Information'),
|
|
Row(
|
|
Column('patient', css_class='col-md-6'),
|
|
Column('consultation', css_class='col-md-6'),
|
|
),
|
|
'goal_description',
|
|
),
|
|
Fieldset(
|
|
_('Progress Tracking'),
|
|
Row(
|
|
Column('status', css_class='col-md-4'),
|
|
Column('progress_percentage', css_class='col-md-4'),
|
|
Column('target_date', css_class='col-md-4'),
|
|
),
|
|
Row(
|
|
Column('achieved_date', css_class='col-md-6'),
|
|
Column(HTML(''), css_class='col-md-6'),
|
|
),
|
|
'progress_notes',
|
|
),
|
|
Submit('submit', _('Save Goal'), css_class='btn btn-primary'),
|
|
)
|
|
|
|
|
|
class PsychologyProgressReportForm(forms.ModelForm):
|
|
"""Form for creating/editing psychology progress reports."""
|
|
|
|
class Meta:
|
|
model = PsychologyProgressReport
|
|
fields = [
|
|
'patient', 'tenant', 'report_date', 'provider',
|
|
'treatment_start_date', 'sessions_scheduled', 'sessions_attended',
|
|
'presenting_problems_summary', 'treatment_provided',
|
|
'goals_progress', 'overall_progress',
|
|
'current_functioning', 'current_symptoms',
|
|
'recommendations', 'continue_treatment', 'discharge_plan',
|
|
'prognosis',
|
|
]
|
|
widgets = {
|
|
'report_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'treatment_start_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'presenting_problems_summary': forms.Textarea(attrs={'rows': 3}),
|
|
'treatment_provided': forms.Textarea(attrs={'rows': 3}),
|
|
'goals_progress': forms.Textarea(attrs={'rows': 4}),
|
|
'overall_progress': forms.Textarea(attrs={'rows': 4}),
|
|
'current_functioning': forms.Textarea(attrs={'rows': 3}),
|
|
'current_symptoms': forms.Textarea(attrs={'rows': 3}),
|
|
'recommendations': forms.Textarea(attrs={'rows': 4}),
|
|
'discharge_plan': forms.Textarea(attrs={'rows': 3}),
|
|
'prognosis': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.helper = FormHelper()
|
|
self.helper.form_method = 'post'
|
|
self.helper.layout = Layout(
|
|
Fieldset(
|
|
_('Patient & Provider Information'),
|
|
Row(
|
|
Column('patient', css_class='col-md-4'),
|
|
Column('tenant', css_class='col-md-4'),
|
|
Column('report_date', css_class='col-md-4'),
|
|
),
|
|
'provider',
|
|
),
|
|
Fieldset(
|
|
_('Treatment Summary'),
|
|
Row(
|
|
Column('treatment_start_date', css_class='col-md-4'),
|
|
Column('sessions_scheduled', css_class='col-md-4'),
|
|
Column('sessions_attended', css_class='col-md-4'),
|
|
),
|
|
),
|
|
Fieldset(
|
|
_('Progress Summary'),
|
|
'presenting_problems_summary',
|
|
'treatment_provided',
|
|
'goals_progress',
|
|
'overall_progress',
|
|
),
|
|
Fieldset(
|
|
_('Current Status'),
|
|
'current_functioning',
|
|
'current_symptoms',
|
|
),
|
|
Fieldset(
|
|
_('Recommendations & Plan'),
|
|
'recommendations',
|
|
Row(
|
|
Column('continue_treatment', css_class='col-md-6'),
|
|
Column(HTML(''), css_class='col-md-6'),
|
|
),
|
|
'discharge_plan',
|
|
'prognosis',
|
|
),
|
|
Submit('submit', _('Save Progress Report'), css_class='btn btn-primary'),
|
|
)
|