87 lines
2.8 KiB
Python
87 lines
2.8 KiB
Python
#!/usr/bin/env python
|
|
"""
|
|
Check survey questions for satisfaction options.
|
|
This script examines Inpatient, Outpatient, and Appointment surveys
|
|
to see if they have satisfaction questions with the required options.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import django
|
|
|
|
# Setup Django
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'PX360.settings')
|
|
django.setup()
|
|
|
|
from apps.surveys.models import SurveyTemplate, SurveyQuestion
|
|
|
|
print("=" * 70)
|
|
print("CHECKING SATISFACTION SURVEYS AND QUESTIONS")
|
|
print("=" * 70)
|
|
|
|
# Target surveys
|
|
target_surveys = SurveyTemplate.objects.filter(
|
|
name__icontains='inpatient'
|
|
) | SurveyTemplate.objects.filter(
|
|
name__icontains='outpatient'
|
|
) | SurveyTemplate.objects.filter(
|
|
name__icontains='appointment'
|
|
)
|
|
|
|
print(f"\nFound {target_surveys.count()} target surveys")
|
|
|
|
# Required satisfaction options
|
|
SATISFACTION_OPTIONS = [
|
|
'Very Unsatisfied',
|
|
'Poor',
|
|
'Neutral',
|
|
'Good',
|
|
'Very Satisfied'
|
|
]
|
|
|
|
for survey in target_surveys:
|
|
print(f"\n{'=' * 70}")
|
|
print(f"SURVEY: {survey.name}")
|
|
print(f"{'=' * 70}")
|
|
|
|
questions = survey.questions.all().order_by('order')
|
|
|
|
if not questions.exists():
|
|
print(" No questions found!")
|
|
continue
|
|
|
|
for question in questions:
|
|
print(f"\n Q{question.order}: {question.text}")
|
|
print(f" Type: {question.question_type}")
|
|
print(f" Required: {question.is_required}")
|
|
|
|
if question.question_type == 'multiple_choice' and question.choices_json:
|
|
print(f" Options ({len(question.choices_json)}):")
|
|
for i, choice in enumerate(question.choices_json):
|
|
label = choice.get('label', 'N/A')
|
|
label_ar = choice.get('label_ar', 'N/A')
|
|
value = choice.get('value', 'N/A')
|
|
print(f" {i+1}. {label} ({label_ar}) - Value: {value}")
|
|
|
|
# Check if all required options exist
|
|
existing_options = [choice.get('label', '') for choice in question.choices_json]
|
|
missing_options = [opt for opt in SATISFACTION_OPTIONS if opt not in existing_options]
|
|
|
|
if missing_options:
|
|
print(f" ⚠️ MISSING OPTIONS: {', '.join(missing_options)}")
|
|
else:
|
|
print(f" ✓ All required satisfaction options present")
|
|
elif question.question_type in ['rating', 'likert', 'nps']:
|
|
print(f" Rating scale question")
|
|
else:
|
|
print(f" Text/input question")
|
|
|
|
print("\n" + "=" * 70)
|
|
print("ANALYSIS COMPLETE")
|
|
print("=" * 70)
|
|
print("\nRequired satisfaction options:")
|
|
for opt in SATISFACTION_OPTIONS:
|
|
print(f" - {opt}")
|
|
print("\nNote: These should be added as multiple-choice type questions")
|
|
print(" with checkboxes for single or multiple selections.")
|
|
print("=" * 70) |