# Generated by Django 6.0.1 on 2026-06-10 20:48

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


def migrate_contacted_statuses(apps, schema_editor):
    Complaint = apps.get_model("complaints", "Complaint")
    Complaint.objects.filter(status="contacted").update(
        status="in_progress",
        patient_contact_status="contacted",
    )
    Complaint.objects.filter(status="contacted_no_response").update(
        status="in_progress",
        patient_contact_status="contacted_no_response",
    )


class Migration(migrations.Migration):

    dependencies = [
        ('complaints', '0016_champion_investigation'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='complaint',
            name='patient_contact_status',
            field=models.CharField(choices=[('not_contacted', 'Not Contacted'), ('contacted', 'Contacted'), ('contacted_no_response', 'Contacted, No Response')], db_index=True, default='not_contacted', help_text='Tracks whether the patient has been contacted regarding this complaint', max_length=30),
        ),
        migrations.AddField(
            model_name='complaint',
            name='patient_contact_status_at',
            field=models.DateTimeField(blank=True, help_text='When the patient contact status was last updated', null=True),
        ),
        migrations.AddField(
            model_name='complaint',
            name='patient_contact_status_by',
            field=models.ForeignKey(blank=True, help_text='User who last updated the patient contact status', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='patient_contact_updated_complaints', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterField(
            model_name='complaint',
            name='status',
            field=models.CharField(choices=[('open', 'Open'), ('in_progress', 'In Progress'), ('partially_resolved', 'Partially Resolved'), ('resolved', 'Resolved'), ('closed', 'Closed'), ('cancelled', 'Cancelled'), ('pending_external', 'Pending External'), ('ovr_pending', 'OVR Pending Approval')], db_index=True, default='open', max_length=25),
        ),
        migrations.RunPython(migrate_contacted_statuses, migrations.RunPython.noop),
    ]
