58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Check satisfaction surveys for correct options
|
|
"""
|
|
import os
|
|
import django
|
|
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PX360.settings')
|
|
django.setup()
|
|
|
|
from apps.surveys.models import SurveyTemplate, SurveyQuestion
|
|
|
|
# Get the three satisfaction surveys
|
|
surveys = SurveyTemplate.objects.filter(
|
|
name__in=[
|
|
'Inpatient Satisfaction Survey',
|
|
'Outpatient Satisfaction Survey',
|
|
'Appointment Satisfaction Survey'
|
|
]
|
|
)
|
|
|
|
print('Checking satisfaction surveys in database...\n')
|
|
|
|
required_options = ['Very Unsatisfied', 'Poor', 'Neutral', 'Good', 'Very Satisfied']
|
|
|
|
for survey in surveys:
|
|
print(f'\n{"="*80}')
|
|
print(f'Survey: {survey.name}')
|
|
print(f'{"="*80}')
|
|
print(f'Questions: {survey.questions.count()}')
|
|
|
|
# Check if any question has satisfaction options
|
|
has_satisfaction = False
|
|
for question in survey.questions.filter(question_type='multiple_choice'):
|
|
if question.choices_json:
|
|
labels = [choice['label'] for choice in question.choices_json]
|
|
|
|
# Check if all required options are present
|
|
missing_options = [opt for opt in required_options if opt not in labels]
|
|
|
|
if missing_options:
|
|
print(f' ✗ Question "{question.text[:60]}..." is missing options:')
|
|
print(f' Missing: {missing_options}')
|
|
else:
|
|
has_satisfaction = True
|
|
print(f' ✓ Question "{question.text[:60]}..." has all 5 satisfaction options')
|
|
print(f' Options: {labels}')
|
|
break
|
|
|
|
if not has_satisfaction:
|
|
print(f' ⚠ No question with all 5 satisfaction options found')
|
|
|
|
print(f'\n{"="*80}')
|
|
print('SUMMARY')
|
|
print(f'{"="*80}')
|
|
print(f'\nRequired satisfaction options:')
|
|
for i, option in enumerate(required_options, 1):
|
|
print(f' {i}. {option}') |