85 lines
4.0 KiB
Markdown
85 lines
4.0 KiB
Markdown
# Physician Reference Fixes
|
|
|
|
## Summary
|
|
Fixed all references to use the correct model (`organizations.Staff`) instead of incorrect `Physician` model references.
|
|
|
|
## Root Cause
|
|
The system uses `organizations.Staff` model for physicians, not a separate `Physician` model. Several templates and code were incorrectly trying to access a `physician` attribute on `PhysicianMonthlyRating` and `PatientJourneyStageInstance` objects, when the actual field is `staff`.
|
|
|
|
## Files Fixed
|
|
|
|
### 1. Journeys Module
|
|
**File:** `apps/journeys/ui_views.py`
|
|
- Changed `prefetch_related()` parameter from `'stage_instances__physician'` to `'stage_instances__staff'` in two places
|
|
- Line 40 (journey_instance_list view) and Line 149 (journey_instance_detail view)
|
|
- This was the source of the original AttributeError: "Cannot find 'physician' on PatientJourneyStageInstance object"
|
|
|
|
**File:** `apps/journeys/serializers.py`
|
|
- Changed `PatientJourneyStageInstanceSerializer` field from `physician` to `staff`
|
|
- Changed `physician_name` method to `staff_name`
|
|
- Updated fields list to use `staff` and `staff_name` instead of `physician` and `physician_name`
|
|
- The `PatientJourneyStageInstance` model has a `staff` field, not `physician`
|
|
|
|
### 2. Appreciation Module
|
|
**File:** `apps/appreciation/views.py`
|
|
- Changed all `Physician.objects` references to `Staff.objects`
|
|
- Updated queryset filters and filters context to use Staff model
|
|
|
|
**File:** `apps/appreciation/serializers.py`
|
|
- Changed model reference from `Physician` to `Staff`
|
|
- Updated all field references from `physician` to `staff`
|
|
|
|
### 3. Dashboard Module
|
|
**File:** `templates/dashboard/command_center.html`
|
|
- Changed `rating.physician.*` references to `rating.staff.*`
|
|
- The `PhysicianMonthlyRating` model has a `staff` field, not `physician`
|
|
|
|
### 4. Physicians Templates
|
|
**File:** `templates/physicians/ratings_list.html`
|
|
- Changed all `rating.physician.*` references to `rating.staff.*`
|
|
|
|
**File:** `templates/physicians/specialization_overview.html`
|
|
- Changed all `rating.physician.*` references to `rating.staff.*`
|
|
|
|
**File:** `templates/physicians/department_overview.html`
|
|
- Changed all `rating.physician.*` references to `rating.staff.*`
|
|
|
|
### 5. Physicians App (Verified - No Changes Needed)
|
|
The physicians app is already correctly implemented:
|
|
- `apps/physicians/models.py` - `PhysicianMonthlyRating.staff` field correctly points to `organizations.Staff`
|
|
- `apps/physicians/views.py` - All code correctly uses `staff` field when querying `PhysicianMonthlyRating`
|
|
- `apps/physicians/serializers.py` - All serializers correctly reference `staff` field
|
|
- `apps/physicians/ui_views.py` - All views correctly use `staff` field
|
|
- `templates/physicians/*.html` - All templates correctly access physician attributes through `physician.*` where `physician` is a Staff object
|
|
|
|
The variable name `physician` is used correctly in templates as it represents a `Staff` object passed from views, not a separate `Physician` model.
|
|
|
|
## Model Structure
|
|
|
|
### organizations.Staff
|
|
- This is the actual physician model
|
|
- Contains fields like: `first_name`, `last_name`, `license_number`, `specialization`, `department`, `hospital`
|
|
|
|
### physicians.PhysicianMonthlyRating
|
|
- Contains monthly aggregated ratings for physicians
|
|
- Has a `staff` field (ForeignKey to `organizations.Staff`), NOT `physician`
|
|
- This was the source of most template errors
|
|
|
|
### journeys.PatientJourneyStageInstance
|
|
- Contains stage instances in patient journeys
|
|
- Has a `staff` field (ForeignKey to `organizations.Staff`), NOT `physician`
|
|
- This was the source of the serializer error
|
|
|
|
## Verification
|
|
|
|
All imports were verified to be correct:
|
|
- `PhysicianMonthlyRating` imports are all correct
|
|
- No old `Physician` model imports exist
|
|
- Only one `physician_profile` reference found, which is a commented line
|
|
|
|
## Testing
|
|
The application should now work correctly without the following errors:
|
|
1. `AttributeError: Cannot find 'physician' on PatientJourneyStageInstance object`
|
|
2. Template rendering errors due to `rating.physician` not existing
|
|
3. All physician-related views should display correctly
|