HH/apps/px_sources/migrations/0003_populate_px_sources.py
2026-01-15 14:31:58 +03:00

151 lines
5.2 KiB
Python

"""
Populate PXSource table with default complaint sources.
This migration creates PXSource records for the previously hardcoded
ComplaintSource enum values and other common feedback sources.
"""
from django.db import migrations
def create_px_sources(apps, schema_editor):
"""Create default PXSource records"""
PXSource = apps.get_model('px_sources', 'PXSource')
# Create complaint sources
sources = [
{
'code': 'PATIENT',
'name_en': 'Patient',
'name_ar': 'مريض',
'description_en': 'Direct patient feedback',
'description_ar': 'ملاحظات مباشرة من المريض',
'source_type': 'complaint',
'order': 1,
},
{
'code': 'FAMILY',
'name_en': 'Family Member',
'name_ar': 'عضو العائلة',
'description_en': 'Feedback from family members',
'description_ar': 'ملاحظات من أعضاء العائلة',
'source_type': 'complaint',
'order': 2,
},
{
'code': 'STAFF',
'name_en': 'Staff Report',
'name_ar': 'تقرير الموظف',
'description_en': 'Report from hospital staff',
'description_ar': 'تقرير من موظفي المستشفى',
'source_type': 'complaint',
'order': 3,
},
{
'code': 'SURVEY',
'name_en': 'Survey',
'name_ar': 'استبيان',
'description_en': 'Patient survey response',
'description_ar': 'رد على استبيان المريض',
'source_type': 'both',
'order': 4,
},
{
'code': 'SOCIAL_MEDIA',
'name_en': 'Social Media',
'name_ar': 'وسائل التواصل الاجتماعي',
'description_en': 'Feedback from social media platforms',
'description_ar': 'ملاحظات من وسائل التواصل الاجتماعي',
'source_type': 'both',
'order': 5,
},
{
'code': 'CALL_CENTER',
'name_en': 'Call Center',
'name_ar': 'مركز الاتصال',
'description_en': 'Call center interaction',
'description_ar': 'تفاعل من مركز الاتصال',
'source_type': 'both',
'order': 6,
},
{
'code': 'MOH',
'name_en': 'Ministry of Health',
'name_ar': 'وزارة الصحة',
'description_en': 'Report from Ministry of Health',
'description_ar': 'تقرير من وزارة الصحة',
'source_type': 'complaint',
'order': 7,
},
{
'code': 'CHI',
'name_en': 'Council of Health Insurance',
'name_ar': 'مجلس الضمان الصحي',
'description_en': 'Report from Council of Health Insurance',
'description_ar': 'تقرير من مجلس الضمان الصحي',
'source_type': 'complaint',
'order': 8,
},
{
'code': 'OTHER',
'name_en': 'Other',
'name_ar': 'أخرى',
'description_en': 'Other sources',
'description_ar': 'مصادر أخرى',
'source_type': 'both',
'order': 9,
},
{
'code': 'WEB',
'name_en': 'Web Portal',
'name_ar': 'البوابة الإلكترونية',
'description_en': 'Feedback from web portal',
'description_ar': 'ملاحظات من البوابة الإلكترونية',
'source_type': 'inquiry',
'order': 10,
},
{
'code': 'MOBILE',
'name_en': 'Mobile App',
'name_ar': 'تطبيق الجوال',
'description_en': 'Feedback from mobile app',
'description_ar': 'ملاحظات من تطبيق الجوال',
'source_type': 'inquiry',
'order': 11,
},
{
'code': 'KIOSK',
'name_en': 'Kiosk',
'name_ar': 'كيوسك',
'description_en': 'Feedback from kiosk terminal',
'description_ar': 'ملاحظات من الكيوسك',
'source_type': 'inquiry',
'order': 12,
},
{
'code': 'EMAIL',
'name_en': 'Email',
'name_ar': 'البريد الإلكتروني',
'description_en': 'Feedback via email',
'description_ar': 'ملاحظات عبر البريد الإلكتروني',
'source_type': 'inquiry',
'order': 13,
},
]
for source_data in sources:
PXSource.objects.get_or_create(
code=source_data['code'],
defaults=source_data
)
class Migration(migrations.Migration):
dependencies = [
('px_sources', '0002_remove_pxsource_color_code_and_more'),
('complaints', '0004_alter_complaint_source'),
('feedback', '0003_alter_feedback_source'),
]
operations = [
migrations.RunPython(create_px_sources),
]