# 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 = [
        ('organizations', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='QIProjectTask',
            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)),
                ('title', models.CharField(max_length=500)),
                ('description', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('completed_date', models.DateField(blank=True, null=True)),
                ('order', models.IntegerField(default=0)),
            ],
            options={
                'ordering': ['project', 'order'],
            },
        ),
        migrations.CreateModel(
            name='FOCUSPhase',
            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)),
                ('phase', models.CharField(choices=[('find', 'Find'), ('organize', 'Organize'), ('clarify', 'Clarify'), ('understand', 'Understand'), ('select', 'Select')], max_length=15)),
                ('title', models.CharField(blank=True, max_length=300)),
                ('description', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('completed_date', models.DateField(blank=True, null=True)),
                ('findings', models.TextField(blank=True)),
                ('order', models.IntegerField(default=0)),
                ('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='owned_focus_phases', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['project', 'order'],
            },
        ),
        migrations.CreateModel(
            name='PDCAPhase',
            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)),
                ('phase', models.CharField(choices=[('plan', 'Plan'), ('do', 'Do'), ('check', 'Check'), ('act', 'Act')], max_length=10)),
                ('title', models.CharField(blank=True, max_length=300)),
                ('description', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='pending', max_length=20)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('completed_date', models.DateField(blank=True, null=True)),
                ('findings', models.TextField(blank=True)),
                ('order', models.IntegerField(default=0)),
                ('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='owned_pdca_phases', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['project', 'order'],
            },
        ),
        migrations.CreateModel(
            name='QIProject',
            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)),
                ('name', models.CharField(max_length=200)),
                ('name_ar', models.CharField(blank=True, max_length=200)),
                ('description', models.TextField()),
                ('is_template', models.BooleanField(db_index=True, default=False, help_text='If True, this is a reusable template, not an active project')),
                ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], db_index=True, default='pending', max_length=20)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('target_completion_date', models.DateField(blank=True, db_index=True, null=True)),
                ('actual_completion_date', models.DateField(blank=True, null=True)),
                ('outcome_description', models.TextField(blank=True)),
                ('success_metrics', models.JSONField(blank=True, default=dict, help_text='Success metrics and results')),
                ('focus_enabled', models.BooleanField(default=True, help_text='Whether to use FOCUS methodology alongside PDCA')),
                ('metadata', models.JSONField(blank=True, default=dict)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_qi_projects', to=settings.AUTH_USER_MODEL)),
                ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='qi_projects', to='organizations.department')),
                ('hospital', models.ForeignKey(blank=True, help_text='Null for global templates available to all hospitals', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='qi_projects', to='organizations.hospital')),
                ('project_lead', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='led_projects', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
    ]
