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

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('journeys', '0001_initial'),
        ('organizations', '0001_initial'),
        ('surveys', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='patientjourneystagetemplate',
            name='survey_template',
            field=models.ForeignKey(blank=True, help_text='Survey template containing questions for this stage (merged into post-discharge survey)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='journey_stages', to='surveys.surveytemplate'),
        ),
        migrations.AddField(
            model_name='patientjourneystageinstance',
            name='stage_template',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='instances', to='journeys.patientjourneystagetemplate'),
        ),
        migrations.AddField(
            model_name='patientjourneytemplate',
            name='hospital',
            field=models.ForeignKey(help_text='Hospital this template belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='journey_templates', to='organizations.hospital'),
        ),
        migrations.AddField(
            model_name='patientjourneystagetemplate',
            name='journey_template',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stages', to='journeys.patientjourneytemplate'),
        ),
        migrations.AddField(
            model_name='patientjourneyinstance',
            name='journey_template',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='instances', to='journeys.patientjourneytemplate'),
        ),
        migrations.AddIndex(
            model_name='patientjourneystageinstance',
            index=models.Index(fields=['journey_instance', 'status'], name='journeys_pa_journey_dc3289_idx'),
        ),
        migrations.AddIndex(
            model_name='patientjourneystageinstance',
            index=models.Index(fields=['status', 'completed_at'], name='journeys_pa_status_563c5f_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='patientjourneystageinstance',
            unique_together={('journey_instance', 'stage_template')},
        ),
        migrations.AddIndex(
            model_name='patientjourneytemplate',
            index=models.Index(fields=['hospital', 'journey_type', 'is_active'], name='journeys_pa_hospita_3b6b47_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='patientjourneytemplate',
            unique_together={('hospital', 'journey_type', 'name')},
        ),
        migrations.AddIndex(
            model_name='patientjourneystagetemplate',
            index=models.Index(fields=['journey_template', 'order'], name='journeys_pa_journey_ded883_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='patientjourneystagetemplate',
            unique_together={('journey_template', 'code')},
        ),
        migrations.AddIndex(
            model_name='patientjourneyinstance',
            index=models.Index(fields=['patient', '-started_at'], name='journeys_pa_patient_174f56_idx'),
        ),
        migrations.AddIndex(
            model_name='patientjourneyinstance',
            index=models.Index(fields=['hospital', 'status', '-started_at'], name='journeys_pa_hospita_724af9_idx'),
        ),
    ]
