6.9 KiB
6.9 KiB
Post-Discharge Survey Implementation
Overview
This implementation replaces the per-stage survey system with a comprehensive post-discharge survey that merges questions from all completed stages into a single survey sent after patient discharge.
Changes Made
1. Model Changes
PatientJourneyTemplate Model
- Added:
send_post_discharge_survey: Boolean field to enable/disable post-discharge surveyspost_discharge_survey_delay_hours: Integer field for delay after discharge (in hours)
PatientJourneyStageTemplate Model
- Removed:
auto_send_survey: No longer auto-send surveys at each stagesurvey_delay_hours: No longer needed for individual stage surveys
- Retained:
survey_template: Still linked for collecting questions to merge
2. Task Changes
process_inbound_event (apps/integrations/tasks.py)
- New Logic:
- Detects
patient_dischargedevent code - Checks if journey template has
send_post_discharge_survey=True - Schedules
create_post_discharge_surveytask with configured delay
- Detects
- Removed:
- No longer triggers surveys at individual stage completion
create_post_discharge_survey (apps/surveys/tasks.py)
- New Task:
- Fetches all completed stages for the journey
- Collects survey templates from each completed stage
- Creates a comprehensive survey template on-the-fly
- Merges questions from all stages with section headers
- Sends the comprehensive survey to the patient
3. Admin Changes
PatientJourneyStageTemplateInline
- Removed:
auto_send_surveyfrom inline fields
- Retained:
survey_templatefor question configuration
PatientJourneyStageTemplateAdmin
- Removed:
auto_send_surveyfrom list_display, list_filter, fieldsetssurvey_delay_hoursfrom fieldsets
PatientJourneyTemplateAdmin
- Added:
- New "Post-Discharge Survey" fieldset with:
send_post_discharge_surveypost_discharge_survey_delay_hours
- New "Post-Discharge Survey" fieldset with:
How It Works
Workflow
-
Patient Journey Starts:
- Patient goes through various stages (admission, treatment, etc.)
- Each stage has a
survey_templateconfigured with questions - No surveys are sent at this point
-
Patient Discharges:
- System receives
patient_dischargedevent viaprocess_inbound_event - If
send_post_discharge_survey=Trueon journey template:- Schedules
create_post_discharge_surveytask after configured delay
- Schedules
- System receives
-
Comprehensive Survey Created:
- Task collects all completed stages
- Creates new survey template with merged questions
- Questions organized with section headers for each stage
- Survey sent to patient via SMS/WhatsApp/Email
-
Patient Responds:
- Patient completes the comprehensive survey
- System calculates score and processes feedback
- Negative scores trigger PX Actions (existing functionality)
Survey Structure
The post-discharge survey includes:
Post-Discharge Survey - [Patient Name] - [Encounter ID]
--- Stage 1 Name ---
[Question 1 from Stage 1]
[Question 2 from Stage 1]
...
--- Stage 2 Name ---
[Question 1 from Stage 2]
[Question 2 from Stage 2]
...
--- Stage 3 Name ---
[Question 1 from Stage 3]
[Question 2 from Stage 3]
...
Configuration
Enabling Post-Discharge Surveys
- Go to Admin → Patient Journey Templates
- Select or create a journey template
- In "Post-Discharge Survey" section:
- Check "Send post-discharge survey"
- Set "Post-discharge survey delay (hours)" (default: 24)
Setting Stage Questions
- Go to Patient Journey Templates → Edit Template
- For each stage in "Journey stage templates" section:
- Select a
Survey template(contains questions) - These questions will be merged into the post-discharge survey
- Select a
Benefits
- Reduced Survey Fatigue: One comprehensive survey instead of multiple surveys
- Better Patient Experience: Patients not overwhelmed with frequent surveys
- Complete Picture: Captures feedback for entire hospital stay
- Flexible Configuration: Easy to enable/disable per journey template
- Contextual Organization: Questions grouped by stage for clarity
Migration Details
Migration File: apps/journeys/migrations/0003_remove_patientjourneystagetemplate_auto_send_survey_and_more.py
Changes:
- Remove
auto_send_surveyfromPatientJourneyStageTemplate - Remove
survey_delay_hoursfromPatientJourneyStageTemplate - Add
send_post_discharge_surveytoPatientJourneyTemplate - Add
post_discharge_survey_delay_hourstoPatientJourneyTemplate - Make
survey_templatenullable onPatientJourneyStageTemplate
Task Parameters
create_post_discharge_survey
Parameters:
journey_instance_id: UUID of the PatientJourneyInstance
Returns:
{
'status': 'sent' | 'skipped' | 'error',
'survey_instance_id': str,
'survey_template_id': str,
'notification_log_id': str,
'stages_included': int,
'total_questions': int,
'reason': str # if skipped/error
}
Skip Conditions:
- No completed stages in journey
- No survey templates found for completed stages
Audit Events
The implementation creates audit logs for:
post_discharge_survey_sent: When comprehensive survey is created and sent
Metadata includes:
survey_template: Name of comprehensive surveyjourney_instance: Journey instance IDencounter_id: Patient encounter IDstages_included: Number of stages mergedtotal_questions: Total questions in surveychannel: Delivery channel (sms/whatsapp/email)
Future Enhancements
Potential improvements:
- Add per-stage question filtering (optional stages)
- Allow custom question ordering
- Add conditional questions based on stage outcomes
- Implement survey reminders for post-discharge surveys
- Add analytics comparing pre/post implementation metrics
Testing Checklist
- Verify journey template has post-discharge survey enabled
- Create journey with multiple stages, each with survey templates
- Complete all stages
- Send
patient_dischargedevent - Verify task is scheduled with correct delay
- Verify comprehensive survey is created
- Verify all stage questions are merged with section headers
- Verify survey is sent to patient
- Test patient survey completion
- Verify score calculation works correctly
- Verify negative survey triggers PX Action
Rollback Plan
If needed, rollback steps:
- Disable
send_post_discharge_surveyon all journey templates - Revert migration:
python manage.py migrate journeys 0002 - Manually restore
auto_send_surveyandsurvey_delay_hoursfields if needed - Update
process_inbound_eventto restore stage survey logic