# Generated by Django 2.2.9 on 2020-12-01 15:17

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Request',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('description', models.TextField(blank=True)),
                ('favorite', models.BooleanField(default=False)),
                ('data_type_of_query', models.CharField(choices=[('PATIENT', 'FHIR Patient'), ('ENCOUNTER', 'FHIR Encounter')], default='PATIENT', max_length=9)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_requests', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='RequestQuerySnapshot',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('serialized_query', models.TextField(default='{}')),
                ('refresh_every_seconds', models.BigIntegerField(default=0)),
                ('refresh_create_cohort', models.BooleanField(default=False)),
                ('is_active_branch', models.BooleanField(default=True)),
                ('saved', models.BooleanField(default=False)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_request_query_snapshots', to=settings.AUTH_USER_MODEL)),
                ('previous_snapshot', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='next_snapshots', to='explorations.RequestQuerySnapshot')),
                ('request', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='query_snapshots', to='explorations.Request')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='DatedMeasure',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('fhir_datetime', models.DateTimeField()),
                ('measure', models.BigIntegerField()),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_request_query_results', to=settings.AUTH_USER_MODEL)),
                ('request', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorations.Request')),
                ('request_query_snapshot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorations.RequestQuerySnapshot')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='CohortResult',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('description', models.TextField(blank=True)),
                ('favorite', models.BooleanField(default=False)),
                ('fhir_group_id', models.CharField(blank=True, max_length=64)),
                ('request_job_id', models.TextField(blank=True)),
                ('request_job_status', models.CharField(choices=[('pending', 'pending'), ('started', 'started'), ('cancelled', 'cancelled'), ('finished', 'finished')], default='pending', max_length=10)),
                ('type', models.CharField(choices=[('IMPORT_I2B2', 'Previous cohorts imported from i2b2.'), ('MY_ORGANIZATIONS', 'Organizations in which I work (care sites with pseudo-anonymised reading rights).'), ('MY_PATIENTS', 'Patients that passed by all my organizations (care sites with nominative reading rights).'), ('MY_COHORTS', 'Cohorts I created in Cohort360')], default='MY_COHORTS', max_length=20)),
                ('dated_measure', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cohort', to='explorations.DatedMeasure')),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_cohorts', to=settings.AUTH_USER_MODEL)),
                ('request', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='request_cohorts', to='explorations.Request')),
                ('request_query_snapshot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorations.RequestQuerySnapshot')),
            ],
            options={
                'unique_together': {('owner', 'fhir_group_id', 'type')},
            },
        ),
    ]

# Generated by Django 2.2.9 on 2020-12-01 15:17

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Request',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('description', models.TextField(blank=True)),
                ('favorite', models.BooleanField(default=False)),
                ('data_type_of_query', models.CharField(choices=[('PATIENT', 'FHIR Patient'), ('ENCOUNTER', 'FHIR Encounter')], default='PATIENT', max_length=9)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_requests', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='RequestQuerySnapshot',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('serialized_query', models.TextField(default='{}')),
                ('refresh_every_seconds', models.BigIntegerField(default=0)),
                ('refresh_create_cohort', models.BooleanField(default=False)),
                ('is_active_branch', models.BooleanField(default=True)),
                ('saved', models.BooleanField(default=False)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_request_query_snapshots', to=settings.AUTH_USER_MODEL)),
                ('previous_snapshot', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='next_snapshots', to='explorations.RequestQuerySnapshot')),
                ('request', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='query_snapshots', to='explorations.Request')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='DatedMeasure',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('fhir_datetime', models.DateTimeField()),
                ('measure', models.BigIntegerField()),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_request_query_results', to=settings.AUTH_USER_MODEL)),
                ('request', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorations.Request')),
                ('request_query_snapshot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorations.RequestQuerySnapshot')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='CohortResult',
            fields=[
                ('uuid', models.UUIDField(auto_created=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('modified_at', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=50)),
                ('description', models.TextField(blank=True)),
                ('favorite', models.BooleanField(default=False)),
                ('fhir_group_id', models.CharField(blank=True, max_length=64)),
                ('request_job_id', models.TextField(blank=True)),
                ('request_job_status', models.CharField(choices=[('pending', 'pending'), ('started', 'started'), ('cancelled', 'cancelled'), ('finished', 'finished')], default='pending', max_length=10)),
                ('type', models.CharField(choices=[('IMPORT_I2B2', 'Previous cohorts imported from i2b2.'), ('MY_ORGANIZATIONS', 'Organizations in which I work (care sites with pseudo-anonymised reading rights).'), ('MY_PATIENTS', 'Patients that passed by all my organizations (care sites with nominative reading rights).'), ('MY_COHORTS', 'Cohorts I created in Cohort360')], default='MY_COHORTS', max_length=20)),
                ('dated_measure', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='cohort', to='explorations.DatedMeasure')),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_cohorts', to=settings.AUTH_USER_MODEL)),
                ('request', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='request_cohorts', to='explorations.Request')),
                ('request_query_snapshot', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='explorations.RequestQuerySnapshot')),
            ],
            options={
                'unique_together': {('owner', 'fhir_group_id', 'type')},
            },
        ),
    ]

# Generated by Django 2.2.9 on 2020-12-01 15:17