# Generated by Django 6.0.1 on 2026-05-11 20:32 import django.db.models.deletion import uuid from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ('complaints', '0001_initial'), ('organizations', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='ComplaintRequest', fields=[ ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('patient_name', models.CharField(blank=True, help_text='Patient name', max_length=200)), ('file_number', models.CharField(blank=True, help_text='Patient file number', max_length=100)), ('incident_date', models.DateField(blank=True, help_text='Date of the incident', null=True)), ('phone_number', models.CharField(blank=True, help_text='Patient phone number', max_length=20)), ('filled', models.BooleanField(default=False, help_text='Whether the request was filled')), ('on_hold', models.BooleanField(default=False, help_text='Whether the request is on hold')), ('not_filled', models.BooleanField(default=False, help_text='Whether the request was not filled')), ('from_barcode', models.BooleanField(default=False, help_text='Whether the request came from barcode scanning')), ('filling_time_category', models.CharField(choices=[('same_time', 'Same Time'), ('within_6h', 'Within 6 Hours'), ('6_to_24h', '6 to 24 Hours'), ('after_1_day', 'After 1 Day'), ('not_mentioned', 'Time Not Mentioned')], default='not_mentioned', help_text='When the request was filled', max_length=20)), ('request_date', models.DateField(help_text='Date of the request')), ('request_time', models.TimeField(blank=True, help_text='Time of the request', null=True)), ('form_sent_at', models.DateTimeField(blank=True, help_text='When complaint form was sent to patient', null=True)), ('form_sent_time', models.TimeField(blank=True, help_text='Time when form was sent', null=True)), ('filled_at', models.DateTimeField(blank=True, help_text='When the request was filled', null=True)), ('filled_time', models.TimeField(blank=True, help_text='Time when request was filled', null=True)), ('reason_non_activation', models.CharField(blank=True, choices=[('converted_to_note', 'تم تحويلها ملاحظة (Converted to observation)'), ('issue_resolved_immediately', 'تم حل الاشكالية (Issue resolved immediately)'), ('not_meeting_conditions', 'غير مستوفية للشروط (Does not meet conditions)'), ('raised_via_cchi', 'تم رفع الشكوى عن طريق مجلس الضمان الصحي (Raised via CCHI)'), ('request_not_activated', 'لم يتم تفعيل طلب الشكوى (Request not activated)'), ('complainant_withdrew', 'بناء على طلب المشتكي (Per complainant request)'), ('complainant_retracted', 'المشتكي تنازل عن الشكوى (Complainant retracted)'), ('duplicate', 'مكررة (Duplicate)'), ('other', 'Other')], help_text='Reason complaint was not activated', max_length=50)), ('reason_non_activation_other', models.CharField(blank=True, help_text='Other reason details', max_length=200)), ('pr_observations', models.TextField(blank=True, help_text='PR team observations about this request')), ('notes', models.TextField(blank=True, help_text='Additional notes about the request')), ('complained_department', models.ForeignKey(blank=True, help_text='Department being complained about', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_requests', to='organizations.department')), ('complaint', models.ForeignKey(blank=True, help_text='Related complaint (if any)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_request_records', to='complaints.complaint')), ('hospital', models.ForeignKey(blank=True, help_text='Hospital where the request was made', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_requests', to='organizations.hospital')), ('staff', models.ForeignKey(help_text='Staff member who sent/filled the request', on_delete=django.db.models.deletion.CASCADE, related_name='complaint_requests_sent', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Complaint Request', 'verbose_name_plural': 'Complaint Requests', 'ordering': ['-request_date', '-created_at'], 'indexes': [models.Index(fields=['staff', 'request_date'], name='dashboard_c_staff_i_6d32eb_idx'), models.Index(fields=['filled', 'on_hold'], name='dashboard_c_filled_9bb46e_idx'), models.Index(fields=['request_date'], name='dashboard_c_request_f114d3_idx'), models.Index(fields=['hospital', 'request_date'], name='dashboard_c_hospita_def391_idx'), models.Index(fields=['reason_non_activation'], name='dashboard_c_reason__fe9deb_idx')], }, ), migrations.CreateModel( name='EscalatedComplaintLog', fields=[ ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('escalation_timing', models.CharField(choices=[('before_72h', 'Before 72 Hours'), ('exactly_72h', '72 Hours Exactly'), ('after_72h', 'After 72 Hours')], help_text='When the complaint was escalated relative to 72h SLA', max_length=20)), ('escalated_at', models.DateTimeField(help_text='When the complaint was escalated')), ('is_resolved', models.BooleanField(default=False, help_text='Whether the escalated complaint was resolved')), ('resolved_at', models.DateTimeField(blank=True, help_text='When the escalated complaint was resolved', null=True)), ('resolution_notes', models.TextField(blank=True, help_text='Notes about the resolution')), ('week_start_date', models.DateField(help_text='Start date of the week this escalation is recorded for')), ('complaint', models.ForeignKey(help_text='The escalated complaint', on_delete=django.db.models.deletion.CASCADE, related_name='escalation_logs', to='complaints.complaint')), ('staff', models.ForeignKey(help_text='Staff member who the complaint is assigned to', on_delete=django.db.models.deletion.CASCADE, related_name='escalated_complaints', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Escalated Complaint Log', 'verbose_name_plural': 'Escalated Complaint Logs', 'ordering': ['-escalated_at', '-created_at'], 'indexes': [models.Index(fields=['staff', 'week_start_date'], name='dashboard_e_staff_i_6fc418_idx'), models.Index(fields=['escalation_timing', 'is_resolved'], name='dashboard_e_escalat_06e4bf_idx'), models.Index(fields=['week_start_date'], name='dashboard_e_week_st_bf1d71_idx')], }, ), migrations.CreateModel( name='EvaluationNote', fields=[ ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('category', models.CharField(choices=[('non_medical', 'Non-Medical'), ('medical', 'Medical'), ('er', 'ER'), ('hospital', 'Hospital')], help_text='Note category', max_length=50)), ('sub_category', models.CharField(choices=[('it_app', 'IT - App'), ('lab', 'LAB'), ('doctors_managers_reception', 'Doctors/Managers/Reception'), ('hospital_general', 'Hospital'), ('medical_reports', 'Medical Reports'), ('doctors', 'Doctors'), ('other', 'Other')], help_text='Note sub-category', max_length=50)), ('count', models.IntegerField(default=1, help_text='Number of notes in this category')), ('note_date', models.DateField(help_text='Date the note was recorded')), ('description', models.TextField(blank=True, help_text='Optional description')), ('created_by', models.ForeignKey(blank=True, help_text='User who created this note entry', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='notes_created', to=settings.AUTH_USER_MODEL)), ('staff', models.ForeignKey(help_text='Staff member this note is for', on_delete=django.db.models.deletion.CASCADE, related_name='evaluation_notes', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Evaluation Note', 'verbose_name_plural': 'Evaluation Notes', 'ordering': ['-note_date', 'category', 'sub_category'], 'indexes': [models.Index(fields=['staff', 'note_date'], name='dashboard_e_staff_i_5cb15c_idx'), models.Index(fields=['category', 'sub_category'], name='dashboard_e_categor_1b7060_idx'), models.Index(fields=['note_date'], name='dashboard_e_note_da_51e000_idx')], }, ), migrations.CreateModel( name='InquiryDetail', fields=[ ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('inquiry_type', models.CharField(choices=[('contact_doctor', 'Contact the doctor'), ('sick_leave_reports', 'Sick-Leave - Medical Reports'), ('blood_test', 'Blood test result'), ('raise_complaint', 'Raise a Complaint'), ('app_problem', 'Problem with the app'), ('medication', 'Ask about medication'), ('insurance_status', 'Insurance request status'), ('general_question', 'General question'), ('other', 'Other')], help_text='Type of inquiry', max_length=50)), ('is_outgoing', models.BooleanField(default=False, help_text='Whether this is an outgoing inquiry')), ('response_time_category', models.CharField(blank=True, choices=[('24h', '24 Hours'), ('48h', '48 Hours'), ('72h', '72 Hours'), ('more_than_72h', 'More than 72 Hours')], help_text='Response time category', max_length=20)), ('inquiry_status', models.CharField(blank=True, choices=[('in_progress', 'تحت الإجراء (In Progress)'), ('contacted', 'تم التواصل (Contacted)'), ('contacted_no_response', 'تم التواصل ولم يتم الرد (Contacted No Response)')], help_text='Current status of the inquiry', max_length=50)), ('inquiry_date', models.DateField(help_text='Date of the inquiry')), ('notes', models.TextField(blank=True, help_text='Additional notes')), ('inquiry', models.OneToOneField(help_text='Related inquiry', on_delete=django.db.models.deletion.CASCADE, related_name='evaluation_detail', to='complaints.inquiry')), ('staff', models.ForeignKey(help_text='Staff member handling the inquiry', on_delete=django.db.models.deletion.CASCADE, related_name='inquiry_details', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Inquiry Detail', 'verbose_name_plural': 'Inquiry Details', 'ordering': ['-inquiry_date', '-created_at'], 'indexes': [models.Index(fields=['staff', 'inquiry_date'], name='dashboard_i_staff_i_cee374_idx'), models.Index(fields=['inquiry_type', 'is_outgoing'], name='dashboard_i_inquiry_5064f6_idx'), models.Index(fields=['inquiry_date'], name='dashboard_i_inquiry_4e47dd_idx')], }, ), migrations.CreateModel( name='ReportCompletion', fields=[ ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('report_type', models.CharField(choices=[('complaint_report', 'Complaint Report'), ('complaint_request_report', 'Complaint Request Report'), ('observation_report', 'Observation Report'), ('incoming_inquiries_report', 'Incoming Inquiries Report'), ('outgoing_inquiries_report', 'Outgoing Inquiries Report'), ('extension_report', 'Extension Report'), ('escalated_complaints_report', 'Escalated Complaints Report')], help_text='Type of report', max_length=50)), ('is_completed', models.BooleanField(default=False, help_text='Whether the report is completed')), ('completed_at', models.DateTimeField(blank=True, help_text='When the report was completed', null=True)), ('week_start_date', models.DateField(help_text='Start date of the week this report is for')), ('notes', models.TextField(blank=True, help_text='Notes about the report completion')), ('staff', models.ForeignKey(help_text='Staff member who should complete the report', on_delete=django.db.models.deletion.CASCADE, related_name='report_completions', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Report Completion', 'verbose_name_plural': 'Report Completions', 'ordering': ['-week_start_date', 'report_type'], 'indexes': [models.Index(fields=['staff', 'week_start_date'], name='dashboard_r_staff_i_e94140_idx'), models.Index(fields=['report_type', 'is_completed'], name='dashboard_r_report__6e699b_idx'), models.Index(fields=['week_start_date'], name='dashboard_r_week_st_8558ae_idx')], 'unique_together': {('staff', 'report_type', 'week_start_date')}, }, ), ]