# Generated by Django 6.0.2 on 2026-03-02 05:00

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='CohortDefinition',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('description', models.TextField(blank=True)),
                ('criteria', models.JSONField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('patient_count', models.IntegerField(null=True)),
                ('encounter_count', models.IntegerField(null=True)),
            ],
        ),
        migrations.CreateModel(
            name='SavedQuery',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('description', models.TextField(blank=True)),
                ('query_definition', models.JSONField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('result_count', models.IntegerField(null=True)),
            ],
            options={
                'verbose_name_plural': 'Saved queries',
            },
        ),
        migrations.CreateModel(
            name='CohortMember',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('patient_id', models.IntegerField()),
                ('encounter_id', models.IntegerField(blank=True, null=True)),
                ('group_label', models.CharField(blank=True, max_length=50)),
                ('cohort', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='research.cohortdefinition')),
            ],
            options={
                'unique_together': {('cohort', 'patient_id', 'encounter_id')},
            },
        ),
    ]
