# Generated by Django 3.2.9 on 2021-11-08 17:23

from django.conf import settings
import django.contrib.postgres.fields
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import mycarehub.common.models.base_models
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('common', '0003_auto_20211108_2023'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(default=django.utils.timezone.now)),
                ('created_by', models.UUIDField(blank=True, null=True)),
                ('updated', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_by', models.UUIDField(blank=True, null=True)),
                ('client_type', models.CharField(choices=[('PMTCT', 'PMTCT'), ('OTZ', 'OTZ'), ('OTZ_PLUS', 'OTZ Plus'), ('HVL', 'HVL'), ('OVC', 'OVC'), ('DREAMS', 'DREAMS'), ('HIGH_RISK', 'High Risk Clients'), ('SPOUSES', 'SPOUSES'), ('YOUTH', 'Youth')], max_length=64)),
                ('enrollment_date', models.DateTimeField(auto_now_add=True)),
                ('fhir_patient_id', models.TextField(blank=True, null=True, unique=True)),
                ('emr_health_record_id', models.TextField(blank=True, null=True, unique=True)),
                ('treatment_buddy', models.TextField(blank=True)),
                ('counselled', models.BooleanField(default=False)),
                ('languages', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, choices=[('en', 'English'), ('sw', 'Swahili')], max_length=150, null=True), blank=True, null=True, size=None)),
                ('addresses', models.ManyToManyField(related_name='client_addresses', to='common.Address')),
                ('chv', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='client_chvs', to=settings.AUTH_USER_MODEL)),
                ('contacts', models.ManyToManyField(related_name='client_contacts', to='common.Contact')),
                ('current_facility', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='common.facility')),
            ],
            options={
                'ordering': ('-updated', '-created'),
                'abstract': False,
            },
            managers=[
                ('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
            ],
        ),
        migrations.CreateModel(
            name='SecurityQuestion',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(default=django.utils.timezone.now)),
                ('created_by', models.UUIDField(blank=True, null=True)),
                ('updated', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_by', models.UUIDField(blank=True, null=True)),
                ('stem', models.TextField()),
                ('description', models.TextField()),
                ('sequence', models.IntegerField(default=0)),
                ('response_type', models.CharField(choices=[('TEXT', 'Text Response'), ('DATE', 'Date Response'), ('NUMBER', 'Number Response'), ('BOOLEAN', 'Boolean Response')], max_length=32)),
                ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_securityquestion_related', to='common.organisation')),
            ],
            options={
                'ordering': ('-updated', '-created'),
                'abstract': False,
            },
            managers=[
                ('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
            ],
        ),
        migrations.CreateModel(
            name='RelatedPerson',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(default=django.utils.timezone.now)),
                ('created_by', models.UUIDField(blank=True, null=True)),
                ('updated', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_by', models.UUIDField(blank=True, null=True)),
                ('first_name', models.TextField()),
                ('last_name', models.TextField()),
                ('other_name', models.TextField()),
                ('date_of_birth', models.DateField(blank=True, null=True)),
                ('gender', models.CharField(choices=[('MALE', 'Male'), ('FEMALE', 'Female')], max_length=16)),
                ('relationship_type', models.CharField(choices=[('SPOUSE', 'Spouse'), ('NEXT_OF_KIN', 'Next of kin'), ('CHILD', 'Child'), ('PARENT', 'Parent'), ('SIBLING', 'Sibling'), ('NEIGHBOUR', 'Neighbour'), ('OTHER', 'Other')], max_length=64)),
                ('addresses', models.ManyToManyField(related_name='related_person_addresses', to='common.Address')),
                ('contacts', models.ManyToManyField(related_name='related_person_contacts', to='common.Contact')),
                ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_relatedperson_related', to='common.organisation')),
            ],
            options={
                'ordering': ('-updated', '-created'),
                'abstract': False,
            },
            managers=[
                ('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
            ],
        ),
        migrations.CreateModel(
            name='Identifier',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(default=django.utils.timezone.now)),
                ('created_by', models.UUIDField(blank=True, null=True)),
                ('updated', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_by', models.UUIDField(blank=True, null=True)),
                ('identifier_type', models.CharField(choices=[('CCC', 'Comprehensive Care Clinic Number'), ('NATIONAL_ID', 'National ID Document'), ('BIRTH_CERTIFICATE', 'Birth Certificate'), ('PASSPORT', 'Passport'), ('UNIQUE', 'Unique Identifier')], max_length=64)),
                ('identifier_value', models.TextField()),
                ('identifier_use', models.CharField(choices=[('OFFICIAL', 'Official Identifier'), ('TEMPORARY', 'Temporary Identifier'), ('OLD', 'Old (retired) Identifier')], max_length=64)),
                ('description', models.TextField()),
                ('valid_from', models.DateTimeField(auto_now_add=True)),
                ('valid_to', models.DateTimeField(blank=True, null=True)),
                ('is_primary_identifier', models.BooleanField(default=False)),
                ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_identifier_related', to='common.organisation')),
            ],
            options={
                'ordering': ('-updated', '-created'),
                'abstract': False,
            },
            managers=[
                ('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
            ],
        ),
        migrations.CreateModel(
            name='ClientFacility',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(default=django.utils.timezone.now)),
                ('created_by', models.UUIDField(blank=True, null=True)),
                ('updated', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_by', models.UUIDField(blank=True, null=True)),
                ('assigned', models.DateTimeField()),
                ('transferred_out', models.DateTimeField(blank=True, null=True)),
                ('client', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clients.client')),
                ('facility', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='common.facility')),
                ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_clientfacility_related', to='common.organisation')),
            ],
            options={
                'ordering': ('-updated', '-created'),
                'abstract': False,
            },
            managers=[
                ('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
            ],
        ),
        migrations.AddField(
            model_name='client',
            name='identifiers',
            field=models.ManyToManyField(related_name='client_identifiers', to='clients.Identifier'),
        ),
        migrations.AddField(
            model_name='client',
            name='organisation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_client_related', to='common.organisation'),
        ),
        migrations.AddField(
            model_name='client',
            name='related_persons',
            field=models.ManyToManyField(related_name='client_related_persons', to='clients.RelatedPerson'),
        ),
        migrations.AddField(
            model_name='client',
            name='user',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='SecurityQuestionResponse',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('active', models.BooleanField(default=True)),
                ('created', models.DateTimeField(default=django.utils.timezone.now)),
                ('created_by', models.UUIDField(blank=True, null=True)),
                ('updated', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_by', models.UUIDField(blank=True, null=True)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('response', models.TextField()),
                ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='clients_securityquestionresponse_related', to='common.organisation')),
                ('question', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='clients.securityquestion')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'unique_together': {('user', 'question')},
            },
            managers=[
                ('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
            ],
        ),
    ]
