105 lines
4.0 KiB
Markdown
105 lines
4.0 KiB
Markdown
# OT Forms Field Mismatch Fixes
|
|
|
|
## Summary
|
|
Fixed multiple field name mismatches between `ot/models.py` and `ot/forms.py` that were causing Django FieldError exceptions.
|
|
|
|
## Date
|
|
October 13, 2025
|
|
|
|
## Issues Found and Fixed
|
|
|
|
### 1. OTConsultForm
|
|
**Issues:**
|
|
- Form used `reasons_for_referral` but model has `reasons`
|
|
- Form used `recommendation_type` but model has `recommendation`
|
|
- Form used `recommendations` but model has `recommendation_notes`
|
|
- Form used `behavior_descriptors` but model has `infant_behavior_descriptors` and `current_behavior_descriptors` (two separate fields)
|
|
|
|
**Fixes Applied:**
|
|
- ✅ Changed `reasons_for_referral` → `reasons` in Meta.fields
|
|
- ✅ Changed `recommendation_type` → `recommendation` in Meta.fields
|
|
- ✅ Changed `recommendations` → `recommendation_notes` in Meta.fields
|
|
- ✅ Split `behavior_descriptors` → `infant_behavior_descriptors` and `current_behavior_descriptors` in Meta.fields
|
|
- ✅ Updated widgets to include `recommendation_notes` instead of `recommendations`
|
|
- ✅ Updated HTML layout to use correct field names in textarea elements
|
|
- ✅ Updated Recommendations fieldset to use `recommendation` and `recommendation_notes`
|
|
|
|
### 2. OTSessionForm
|
|
**Issues:**
|
|
- Form included `session_time` field but model doesn't have this field (OTSession only has `session_date`)
|
|
|
|
**Fixes Applied:**
|
|
- ✅ Removed `session_time` from Meta.fields
|
|
- ✅ Removed `session_time` widget
|
|
- ✅ Updated layout to remove `session_time` column (changed from 3-column to 2-column layout)
|
|
|
|
### 3. OTTargetSkillForm
|
|
**Issues:**
|
|
- Form used `baseline_score` and `current_score` but model only has `score` field
|
|
- Form was missing `order` field that exists in model
|
|
|
|
**Fixes Applied:**
|
|
- ✅ Changed `baseline_score` and `current_score` → `score` in Meta.fields
|
|
- ✅ Added `order` field to Meta.fields with HiddenInput widget
|
|
- ✅ Updated clean() method to validate single `score` field instead of two separate fields
|
|
|
|
### 4. OTProgressReportForm
|
|
**Issues:**
|
|
- Form used `goals_achieved` but model has `goals_progress` (JSONField)
|
|
- Form was missing `sessions_scheduled` field
|
|
- Form was missing `continue_treatment` field
|
|
|
|
**Fixes Applied:**
|
|
- ✅ Changed `goals_achieved` → `goals_progress` in Meta.fields
|
|
- ✅ Added `sessions_scheduled` field to Meta.fields
|
|
- ✅ Added `continue_treatment` field to Meta.fields
|
|
- ✅ Removed `goals_achieved` widget
|
|
- ✅ Updated layout to include Session Summary fieldset with both scheduled and attended sessions
|
|
- ✅ Added HTML textarea for `goals_progress` JSONField with proper placeholder
|
|
- ✅ Added `continue_treatment` checkbox to Recommendations fieldset
|
|
|
|
## Model Field Reference
|
|
|
|
### OTConsult Model Fields:
|
|
- patient, appointment, consultation_date, provider
|
|
- reasons (JSONField)
|
|
- top_difficulty_areas (JSONField)
|
|
- developmental_motor_milestones (JSONField)
|
|
- self_help_skills (JSONField)
|
|
- feeding_participation (TextField)
|
|
- infant_behavior_descriptors (JSONField)
|
|
- current_behavior_descriptors (JSONField)
|
|
- recommendation (CharField with choices)
|
|
- recommendation_notes (TextField)
|
|
|
|
### OTSession Model Fields:
|
|
- patient, appointment, session_date, provider
|
|
- session_type, cooperative_level, distraction_tolerance
|
|
- activities_checklist (JSONField)
|
|
- observations, activities_performed, recommendations
|
|
|
|
### OTTargetSkill Model Fields:
|
|
- session, skill_name, score, notes, order
|
|
|
|
### OTProgressReport Model Fields:
|
|
- patient, report_date, provider
|
|
- sessions_scheduled, sessions_attended
|
|
- goals_progress (JSONField)
|
|
- overall_progress, recommendations, continue_treatment
|
|
|
|
## Testing Recommendations
|
|
|
|
1. Test OTConsultForm creation with all fields
|
|
2. Test OTSessionForm with target skills formset
|
|
3. Test OTTargetSkillForm score validation (0-10 range)
|
|
4. Test OTProgressReportForm with JSONField for goals_progress
|
|
5. Verify all form submissions work without FieldError exceptions
|
|
|
|
## Files Modified
|
|
- `ot/forms.py` - All form classes updated to match model fields
|
|
|
|
## Status
|
|
✅ All field mismatches resolved
|
|
✅ Forms now match model definitions exactly
|
|
✅ Ready for testing
|