# Generated by Django 6.0.1 on 2026-05-11 20:32

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('complaints', '0002_initial'),
        ('organizations', '0004_legacylocation_legacymainsection_and_more'),
        ('px_sources', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='complaint',
            name='source',
            field=models.ForeignKey(blank=True, help_text='Source of complaint', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='complaints', to='px_sources.pxsource'),
        ),
        migrations.AddField(
            model_name='complaint',
            name='staff',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaints', to='organizations.staff'),
        ),
        migrations.AddField(
            model_name='complaint',
            name='subsection',
            field=models.ForeignKey(blank=True, help_text='Subsection within the section', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='complaints', to='organizations.legacysubsection'),
        ),
        migrations.AddField(
            model_name='complaintadverseaction',
            name='complaint',
            field=models.ForeignKey(help_text='The complaint this adverse action is related to', on_delete=django.db.models.deletion.CASCADE, related_name='adverse_actions', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintadverseaction',
            name='investigated_by',
            field=models.ForeignKey(blank=True, help_text='User who investigated this adverse action', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investigated_adverse_actions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintadverseaction',
            name='involved_staff',
            field=models.ManyToManyField(blank=True, help_text='Staff members involved in the adverse action', related_name='adverse_actions_involved', to='organizations.staff'),
        ),
        migrations.AddField(
            model_name='complaintadverseaction',
            name='reported_by',
            field=models.ForeignKey(blank=True, help_text='User who reported this adverse action', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reported_adverse_actions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintadverseaction',
            name='resolved_by',
            field=models.ForeignKey(blank=True, help_text='User who resolved this adverse action', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='resolved_adverse_actions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintadverseactionattachment',
            name='adverse_action',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='complaints.complaintadverseaction'),
        ),
        migrations.AddField(
            model_name='complaintadverseactionattachment',
            name='uploaded_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='adverse_action_attachments', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintattachment',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintattachment',
            name='uploaded_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_attachments', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintcategory',
            name='hospitals',
            field=models.ManyToManyField(blank=True, help_text='Empty list = system-wide category. Add hospitals to share category.', related_name='complaint_categories', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='complaintcategory',
            name='parent',
            field=models.ForeignKey(blank=True, help_text='Parent category for hierarchical structure', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='subcategories', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='complaint',
            name='category',
            field=models.ForeignKey(blank=True, help_text='Level 2: Category', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='complaints', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='complaint',
            name='classification_obj',
            field=models.ForeignKey(blank=True, help_text='Level 4: Classification', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='complaints_classification', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='complaint',
            name='domain',
            field=models.ForeignKey(blank=True, help_text='Level 1: Domain', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='complaints_domain', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='complaint',
            name='subcategory_obj',
            field=models.ForeignKey(blank=True, help_text='Level 3: Subcategory', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='complaints_subcategory', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='complaintcommunication',
            name='complaint',
            field=models.ForeignKey(help_text='Related complaint', on_delete=django.db.models.deletion.CASCADE, related_name='communications', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintcommunication',
            name='created_by',
            field=models.ForeignKey(help_text='User who logged this communication', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_communications', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintexplanation',
            name='accepted_by',
            field=models.ForeignKey(blank=True, help_text='User who reviewed and marked the explanation', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reviewed_explanations', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintexplanation',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='explanations', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintexplanation',
            name='escalated_to_manager',
            field=models.ForeignKey(blank=True, help_text="Escalated to this explanation (manager's explanation request)", null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='escalated_from_staff', to='complaints.complaintexplanation'),
        ),
        migrations.AddField(
            model_name='complaintexplanation',
            name='requested_by',
            field=models.ForeignKey(blank=True, help_text='User who requested the explanation', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='requested_complaint_explanations', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintexplanation',
            name='staff',
            field=models.ForeignKey(blank=True, help_text='Staff member who submitted the explanation', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_explanations', to='organizations.staff'),
        ),
        migrations.AddField(
            model_name='complaintinvolveddepartment',
            name='added_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='added_department_involvements', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintinvolveddepartment',
            name='assigned_to',
            field=models.ForeignKey(blank=True, help_text='User assigned from this department to handle the complaint', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='department_assigned_complaints', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintinvolveddepartment',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='involved_departments', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintinvolveddepartment',
            name='department',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaint_involvements', to='organizations.department'),
        ),
        migrations.AddField(
            model_name='complaintinvolvedstaff',
            name='added_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='added_staff_involvements', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintinvolvedstaff',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='involved_staff', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintinvolvedstaff',
            name='staff',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaint_involvements', to='organizations.staff'),
        ),
        migrations.AddField(
            model_name='complaintmeeting',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='meetings', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintmeeting',
            name='created_by',
            field=models.ForeignKey(blank=True, help_text='User who created this meeting record', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_meetings', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintprinteraction',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pr_interactions', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintprinteraction',
            name='created_by',
            field=models.ForeignKey(blank=True, help_text='User who created this PR interaction record', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_pr_interactions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintprinteraction',
            name='pr_staff',
            field=models.ForeignKey(blank=True, help_text='PR staff member who made the contact', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='pr_interactions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='complaintslaconfig',
            name='hospital',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaint_sla_configs', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='complaintslaconfig',
            name='source',
            field=models.ForeignKey(blank=True, help_text='Complaint source (MOH, CHI, Patient, etc.). Empty = severity/priority-based config', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_sla_configs', to='px_sources.pxsource'),
        ),
        migrations.AddField(
            model_name='complainttemplate',
            name='auto_assign_department',
            field=models.ForeignKey(blank=True, help_text='Auto-assign to this department when template is used', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='template_assignments', to='organizations.department'),
        ),
        migrations.AddField(
            model_name='complainttemplate',
            name='category',
            field=models.ForeignKey(blank=True, help_text='Default category for this template', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='templates', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='complainttemplate',
            name='hospital',
            field=models.ForeignKey(help_text='Hospital this template belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='complaint_templates', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='complaintthreshold',
            name='hospital',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaint_thresholds', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='complaintupdate',
            name='complaint',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='updates', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='complaintupdate',
            name='created_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_updates', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='escalationrule',
            name='escalate_to_user',
            field=models.ForeignKey(blank=True, help_text="Specific user if escalate_to_role is 'specific_user'", null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='escalation_target_rules', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='escalationrule',
            name='hospital',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='escalation_rules', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='explanationattachment',
            name='explanation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='complaints.complaintexplanation'),
        ),
        migrations.AddField(
            model_name='explanationslaconfig',
            name='hospital',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='explanation_sla_configs', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='governmentticket',
            name='assigned_to',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_government_tickets', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='governmentticket',
            name='complaint',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='government_ticket', to='complaints.complaint'),
        ),
        migrations.AddField(
            model_name='governmentticket',
            name='location',
            field=models.ForeignKey(blank=True, help_text='Location (e.g., Riyadh, Jeddah)', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='government_tickets', to='organizations.legacylocation'),
        ),
        migrations.AddField(
            model_name='governmentticket',
            name='main_section',
            field=models.ForeignKey(blank=True, help_text='Section/Department', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='government_tickets', to='organizations.legacymainsection'),
        ),
        migrations.AddField(
            model_name='governmentticket',
            name='source',
            field=models.ForeignKey(help_text='Government source (MOH, CCHI, etc.)', limit_choices_to={'is_active': True, 'source_type': 'government'}, on_delete=django.db.models.deletion.PROTECT, related_name='government_tickets', to='px_sources.pxsource'),
        ),
        migrations.AddField(
            model_name='governmentticket',
            name='subsection',
            field=models.ForeignKey(blank=True, help_text='Subsection within the section', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='government_tickets', to='organizations.legacysubsection'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='assigned_to',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_inquiries', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='contacted_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_contacted', to=settings.AUTH_USER_MODEL, verbose_name='Contacted By'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='contacted_nr_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_contacted_nr', to=settings.AUTH_USER_MODEL, verbose_name='Contacted NR By'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='created_by',
            field=models.ForeignKey(blank=True, help_text='User who created this inquiry (SourceUser or Patient)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_inquiries', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='deleted_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='deleted_%(class)s_set', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='department',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries', to='organizations.department'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='department_responded_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='department_inquiry_responses', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='dept_response_accepted_by',
            field=models.ForeignKey(blank=True, help_text='User who reviewed the department response', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reviewed_inquiry_dept_responses', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='follow_up_completed_by',
            field=models.ForeignKey(blank=True, help_text='User who completed the follow-up call', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='completed_inquiry_followups', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='hospital',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inquiries', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='location',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries', to='organizations.legacylocation'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='main_section',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries', to='organizations.legacymainsection'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='outgoing_department',
            field=models.ForeignKey(blank=True, help_text='Department that was contacted for this inquiry', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='outgoing_inquiries', to='organizations.department'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='patient',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='inquiries', to='organizations.patient'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='responded_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='responded_inquiries', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='source',
            field=models.ForeignKey(blank=True, help_text='Source of inquiry', null=True, on_delete=django.db.models.deletion.PROTECT, related_name='inquiries', to='px_sources.pxsource'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='subsection',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries', to='organizations.legacysubsection'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='taxonomy_category',
            field=models.ForeignKey(blank=True, help_text='Level 2: Category', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries_category', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='taxonomy_classification',
            field=models.ForeignKey(blank=True, help_text='Level 4: Classification', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries_classification', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='taxonomy_domain',
            field=models.ForeignKey(blank=True, help_text='Level 1: Domain', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries_domain', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='taxonomy_subcategory',
            field=models.ForeignKey(blank=True, help_text='Level 3: Subcategory', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries_subcategory', to='complaints.complaintcategory'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='transferred_by',
            field=models.ForeignKey(blank=True, help_text='User who transferred the inquiry', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transferred_inquiries', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='transferred_to_department',
            field=models.ForeignKey(blank=True, help_text='Department the inquiry was transferred to', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='transferred_inquiries', to='organizations.department'),
        ),
        migrations.AddField(
            model_name='inquiry',
            name='under_process_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_under_process', to=settings.AUTH_USER_MODEL, verbose_name='Under Process By'),
        ),
        migrations.AddField(
            model_name='inquiryattachment',
            name='inquiry',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='complaints.inquiry'),
        ),
        migrations.AddField(
            model_name='inquiryattachment',
            name='uploaded_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_attachments', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiryexplanation',
            name='inquiry',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='explanations', to='complaints.inquiry'),
        ),
        migrations.AddField(
            model_name='inquiryexplanation',
            name='requested_by',
            field=models.ForeignKey(blank=True, help_text='User who requested the response', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='requested_inquiry_explanations', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiryexplanation',
            name='staff',
            field=models.ForeignKey(blank=True, help_text='Staff member who submitted the response', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_explanations', to='organizations.staff'),
        ),
        migrations.AddField(
            model_name='inquiryexplanationattachment',
            name='explanation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='complaints.inquiryexplanation'),
        ),
        migrations.AddField(
            model_name='inquiryslaconfig',
            name='hospital',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inquiry_sla_configs', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='inquiryslaconfig',
            name='source',
            field=models.ForeignKey(blank=True, help_text='Inquiry source (MOH, CHI, Patient, etc.). Empty = default config', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_sla_configs', to='px_sources.pxsource'),
        ),
        migrations.AddField(
            model_name='inquiryupdate',
            name='created_by',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiry_updates', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='inquiryupdate',
            name='inquiry',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='updates', to='complaints.inquiry'),
        ),
        migrations.AddField(
            model_name='oncalladmin',
            name='admin_user',
            field=models.ForeignKey(help_text='User who is on-call (PX Admin, PX Coordinator, or Hospital Admin)', on_delete=django.db.models.deletion.CASCADE, related_name='on_call_schedules', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='oncalladminschedule',
            name='hospital',
            field=models.ForeignKey(blank=True, help_text='Hospital scope. Leave empty for system-wide configuration.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='on_call_schedules', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='oncalladmin',
            name='schedule',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='on_call_admins', to='complaints.oncalladminschedule'),
        ),
        migrations.AddField(
            model_name='patientcomplaintsession',
            name='created_by',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_sessions', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='patientcomplaintsession',
            name='patient',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaint_sessions', to='organizations.patient'),
        ),
        migrations.AddIndex(
            model_name='complaintadverseaction',
            index=models.Index(fields=['complaint', '-incident_date'], name='complaints__complai_e2164d_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintadverseaction',
            index=models.Index(fields=['action_type', 'severity'], name='complaints__action__502a3c_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintadverseaction',
            index=models.Index(fields=['status', '-created_at'], name='complaints__status_d0a04c_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintcategory',
            index=models.Index(fields=['code'], name='complaints__code_8e9bbe_idx'),
        ),
        migrations.AddIndex(
            model_name='complaint',
            index=models.Index(fields=['status', '-created_at'], name='complaints__status_f077e8_idx'),
        ),
        migrations.AddIndex(
            model_name='complaint',
            index=models.Index(fields=['hospital', 'status', '-created_at'], name='complaints__hospita_cf53df_idx'),
        ),
        migrations.AddIndex(
            model_name='complaint',
            index=models.Index(fields=['assigned_to', 'status', '-created_at'], name='complaints__assigne_68a48b_idx'),
        ),
        migrations.AddIndex(
            model_name='complaint',
            index=models.Index(fields=['department', 'status', '-created_at'], name='complaints__departm_fd6d45_idx'),
        ),
        migrations.AddIndex(
            model_name='complaint',
            index=models.Index(fields=['is_overdue', 'status'], name='complaints__is_over_3d3554_idx'),
        ),
        migrations.AddIndex(
            model_name='complaint',
            index=models.Index(fields=['due_at', 'status'], name='complaints__due_at_836821_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintcommunication',
            index=models.Index(fields=['complaint', '-created_at'], name='complaints__complai_ae1be5_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintcommunication',
            index=models.Index(fields=['communication_type'], name='complaints__communi_fffa08_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintcommunication',
            index=models.Index(fields=['requires_followup', 'followup_date'], name='complaints__require_6cd08c_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintexplanation',
            index=models.Index(fields=['complaint', '-created_at'], name='complaints__complai_b20e58_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintexplanation',
            index=models.Index(fields=['token', 'is_used'], name='complaints__token_f8f9b7_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintinvolveddepartment',
            index=models.Index(fields=['complaint', 'role'], name='complaints__complai_169f99_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintinvolveddepartment',
            index=models.Index(fields=['department', 'response_submitted'], name='complaints__departm_07d2e5_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintinvolveddepartment',
            index=models.Index(fields=['department', 'forwarded_at'], name='complaints__departm_4d974e_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='complaintinvolveddepartment',
            unique_together={('complaint', 'department')},
        ),
        migrations.AddIndex(
            model_name='complaintinvolvedstaff',
            index=models.Index(fields=['complaint', 'role'], name='complaints__complai_383082_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintinvolvedstaff',
            index=models.Index(fields=['staff', 'explanation_received'], name='complaints__staff_i_222e56_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='complaintinvolvedstaff',
            unique_together={('complaint', 'staff')},
        ),
        migrations.AddIndex(
            model_name='complaintmeeting',
            index=models.Index(fields=['complaint', '-meeting_date'], name='complaints__complai_e0d679_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintprinteraction',
            index=models.Index(fields=['complaint', '-contact_date'], name='complaints__complai_740a3c_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintslaconfig',
            index=models.Index(fields=['hospital', 'is_active'], name='complaints__hospita_bdf8a5_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintslaconfig',
            index=models.Index(fields=['hospital', 'source', 'is_active'], name='complaints__hospita_072d9d_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='complaintslaconfig',
            unique_together={('hospital', 'source', 'severity', 'priority')},
        ),
        migrations.AddIndex(
            model_name='complainttemplate',
            index=models.Index(fields=['hospital', 'is_active'], name='complaints__hospita_9e42d3_idx'),
        ),
        migrations.AddIndex(
            model_name='complainttemplate',
            index=models.Index(fields=['-usage_count'], name='complaints__usage_c_8dccb2_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='complainttemplate',
            unique_together={('hospital', 'name')},
        ),
        migrations.AddIndex(
            model_name='complaintthreshold',
            index=models.Index(fields=['hospital', 'is_active'], name='complaints__hospita_b8efc9_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintthreshold',
            index=models.Index(fields=['threshold_type', 'is_active'], name='complaints__thresho_719969_idx'),
        ),
        migrations.AddIndex(
            model_name='complaintupdate',
            index=models.Index(fields=['complaint', '-created_at'], name='complaints__complai_f3684e_idx'),
        ),
        migrations.AddIndex(
            model_name='escalationrule',
            index=models.Index(fields=['hospital', 'is_active'], name='complaints__hospita_3c8bac_idx'),
        ),
        migrations.AddIndex(
            model_name='explanationslaconfig',
            index=models.Index(fields=['hospital', 'is_active'], name='complaints__hospita_fe4ec5_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiry',
            index=models.Index(fields=['status', '-created_at'], name='complaints__status_3d0678_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiry',
            index=models.Index(fields=['hospital', 'status', '-created_at'], name='complaints__hospita_8643ee_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiry',
            index=models.Index(fields=['assigned_to', 'status', '-created_at'], name='complaints__assigne_a54ba2_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiryexplanation',
            index=models.Index(fields=['inquiry', '-created_at'], name='complaints__inquiry_5f2017_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiryexplanation',
            index=models.Index(fields=['token', 'is_used'], name='complaints__token_61e029_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiryslaconfig',
            index=models.Index(fields=['hospital', 'is_active'], name='complaints__hospita_ef59ee_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiryslaconfig',
            index=models.Index(fields=['hospital', 'source', 'is_active'], name='complaints__hospita_1b1d4c_idx'),
        ),
        migrations.AddIndex(
            model_name='inquiryupdate',
            index=models.Index(fields=['inquiry', '-created_at'], name='complaints__inquiry_551c37_idx'),
        ),
        migrations.AddConstraint(
            model_name='oncalladminschedule',
            constraint=models.UniqueConstraint(condition=models.Q(('hospital__isnull', False)), fields=('hospital',), name='unique_oncall_per_hospital'),
        ),
        migrations.AddConstraint(
            model_name='oncalladminschedule',
            constraint=models.UniqueConstraint(condition=models.Q(('hospital__isnull', True)), fields=('hospital',), name='unique_system_wide_oncall'),
        ),
        migrations.AlterUniqueTogether(
            name='oncalladmin',
            unique_together={('schedule', 'admin_user')},
        ),
        migrations.AddIndex(
            model_name='patientcomplaintsession',
            index=models.Index(fields=['patient', 'is_active'], name='complaints__patient_07c7de_idx'),
        ),
    ]
