# Generated by Django 3.0.9 on 2020-10-21 19:18

import uuid

import _socket
import django.core.validators
import django.db.models.deletion
import django_audit_fields.fields.hostname_modification_field
import django_audit_fields.fields.userfield
import django_audit_fields.fields.uuid_auto_field
import django_audit_fields.models.audit_model_mixin
import django_revision.revision_field
import edc_model.models.fields.other_charfield
import edc_protocol.validators
import edc_sites.models
import edc_utils.date
import simple_history.models
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("edc_action_item", "0026_auto_20200729_2240"),
        ("sites", "0002_alter_domain_unique"),
        (
            "inte_prn",
            "0006_historicaloffschedulehiv_historicaloffschedulencd_offschedulehiv_offschedulencd",
        ),
    ]

    operations = [
        migrations.CreateModel(
            name="LossToFollowupHiv",
            fields=[],
            options={
                "proxy": True,
                "indexes": [],
                "constraints": [],
            },
            bases=("inte_prn.losstofollowup",),
            managers=[
                ("on_site", edc_sites.models.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="LossToFollowupNcd",
            fields=[],
            options={
                "proxy": True,
                "indexes": [],
                "constraints": [],
            },
            bases=("inte_prn.losstofollowup",),
            managers=[
                ("on_site", edc_sites.models.CurrentSiteManager()),
            ],
        ),
        migrations.AlterModelOptions(
            name="historicaloffschedulehiv",
            options={
                "get_latest_by": "history_date",
                "ordering": ("-history_date", "-history_id"),
                "verbose_name": "historical End of Study (HIV)",
            },
        ),
        migrations.AlterModelOptions(
            name="historicaloffschedulencd",
            options={
                "get_latest_by": "history_date",
                "ordering": ("-history_date", "-history_id"),
                "verbose_name": "historical End of Study (NCD)",
            },
        ),
        migrations.AlterModelOptions(
            name="offschedulehiv",
            options={
                "verbose_name": "End of Study (HIV)",
                "verbose_name_plural": "End of Study (HIV)",
            },
        ),
        migrations.AlterModelOptions(
            name="offschedulencd",
            options={
                "verbose_name": "End of Study (NCD)",
                "verbose_name_plural": "End of Study (NCD)",
            },
        ),
        migrations.AddField(
            model_name="endofstudy",
            name="schedule_name",
            field=models.CharField(default="-", editable=False, max_length=25),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="endofstudy",
            name="visit_schedule_name",
            field=models.CharField(
                default="-",
                editable=False,
                help_text='the name of the visit schedule used to find the "schedule"',
                max_length=25,
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicalendofstudy",
            name="schedule_name",
            field=models.CharField(default="-", editable=False, max_length=25),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicalendofstudy",
            name="visit_schedule_name",
            field=models.CharField(
                default="-",
                editable=False,
                help_text='the name of the visit schedule used to find the "schedule"',
                max_length=25,
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicallosstofollowup",
            name="schedule_name",
            field=models.CharField(default="-", editable=False, max_length=25),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicallosstofollowup",
            name="visit_schedule_name",
            field=models.CharField(
                default="-",
                editable=False,
                help_text='the name of the visit schedule used to find the "schedule"',
                max_length=25,
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicaloffschedulehiv",
            name="schedule_name",
            field=models.CharField(default="-", editable=False, max_length=25),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicaloffschedulehiv",
            name="visit_schedule_name",
            field=models.CharField(
                default="_",
                editable=False,
                help_text='the name of the visit schedule used to find the "schedule"',
                max_length=25,
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicaloffschedulencd",
            name="schedule_name",
            field=models.CharField(default="-", editable=False, max_length=25),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="historicaloffschedulencd",
            name="visit_schedule_name",
            field=models.CharField(
                default="-",
                editable=False,
                help_text='the name of the visit schedule used to find the "schedule"',
                max_length=25,
            ),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="losstofollowup",
            name="schedule_name",
            field=models.CharField(default="-", editable=False, max_length=25),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="losstofollowup",
            name="visit_schedule_name",
            field=models.CharField(
                default="-",
                editable=False,
                help_text='the name of the visit schedule used to find the "schedule"',
                max_length=25,
            ),
            preserve_default=False,
        ),
        migrations.CreateModel(
            name="HistoricalLossToFollowupNcd",
            fields=[
                (
                    "revision",
                    django_revision.revision_field.RevisionField(
                        blank=True,
                        editable=False,
                        help_text="System field. Git repository tag:branch:commit.",
                        max_length=75,
                        null=True,
                        verbose_name="Revision",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(
                        blank=True,
                        default=django_audit_fields.models.audit_model_mixin.utcnow,
                    ),
                ),
                (
                    "modified",
                    models.DateTimeField(
                        blank=True,
                        default=django_audit_fields.models.audit_model_mixin.utcnow,
                    ),
                ),
                (
                    "user_created",
                    django_audit_fields.fields.userfield.UserField(
                        blank=True,
                        help_text="Updated by admin.save_model",
                        max_length=50,
                        verbose_name="user created",
                    ),
                ),
                (
                    "user_modified",
                    django_audit_fields.fields.userfield.UserField(
                        blank=True,
                        help_text="Updated by admin.save_model",
                        max_length=50,
                        verbose_name="user modified",
                    ),
                ),
                (
                    "hostname_created",
                    models.CharField(
                        blank=True,
                        default=_socket.gethostname,
                        help_text="System field. (modified on create only)",
                        max_length=60,
                    ),
                ),
                (
                    "hostname_modified",
                    django_audit_fields.fields.hostname_modification_field.HostnameModificationField(
                        blank=True,
                        help_text="System field. (modified on every save)",
                        max_length=50,
                    ),
                ),
                ("device_created", models.CharField(blank=True, max_length=10)),
                ("device_modified", models.CharField(blank=True, max_length=10)),
                (
                    "id",
                    django_audit_fields.fields.uuid_auto_field.UUIDAutoField(
                        blank=True,
                        db_index=True,
                        editable=False,
                        help_text="System auto field. UUID primary key.",
                    ),
                ),
                ("subject_identifier", models.CharField(max_length=50)),
                ("tracking_identifier", models.CharField(db_index=True, max_length=30)),
                ("action_identifier", models.CharField(db_index=True, max_length=50)),
                (
                    "parent_action_identifier",
                    models.CharField(
                        help_text="action identifier that links to parent reference model instance.",
                        max_length=30,
                        null=True,
                    ),
                ),
                (
                    "related_action_identifier",
                    models.CharField(
                        help_text="action identifier that links to related reference model instance.",
                        max_length=30,
                        null=True,
                    ),
                ),
                ("action_item_reason", models.TextField(editable=False, null=True)),
                (
                    "history_id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "visit_schedule_name",
                    models.CharField(
                        editable=False,
                        help_text='the name of the visit schedule used to find the "schedule"',
                        max_length=25,
                    ),
                ),
                ("schedule_name", models.CharField(editable=False, max_length=25)),
                (
                    "report_datetime",
                    models.DateTimeField(
                        default=edc_utils.date.get_utcnow,
                        validators=[edc_protocol.validators.date_not_before_study_start],
                        verbose_name="Report Date and Time",
                    ),
                ),
                (
                    "last_seen_datetime",
                    models.DateField(
                        validators=[edc_protocol.validators.date_not_before_study_start],
                        verbose_name="Date participant last seen",
                    ),
                ),
                (
                    "number_consecutive_missed_visits",
                    models.IntegerField(
                        null=True, verbose_name="Number of consecutive visits missed"
                    ),
                ),
                (
                    "last_missed_visit_datetime",
                    models.DateField(
                        null=True,
                        verbose_name="Date of last missed visit report submitted",
                    ),
                ),
                (
                    "phone",
                    models.CharField(
                        choices=[("Yes", "Yes"), ("No", "No")],
                        max_length=15,
                        null=True,
                        verbose_name="Was contact by phone attempted",
                    ),
                ),
                (
                    "phone_attempts",
                    models.IntegerField(
                        default=0,
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name=(
                            "If YES, how many attempts were made to contact the participant by phone",
                        ),
                    ),
                ),
                (
                    "home_visited",
                    models.CharField(
                        choices=[("Yes", "Yes"), ("No", "No")],
                        max_length=15,
                        verbose_name="Was a home visit attempted",
                    ),
                ),
                (
                    "home_visit_detail",
                    models.TextField(
                        blank=True,
                        null=True,
                        verbose_name="If YES, provide any further details of the home visit",
                    ),
                ),
                (
                    "loss_category_other",
                    edc_model.models.fields.other_charfield.OtherCharField(
                        blank=True,
                        max_length=35,
                        null=True,
                        verbose_name="If other, please specify ...",
                    ),
                ),
                (
                    "comment",
                    models.TextField(
                        blank=True,
                        null=True,
                        verbose_name="If any, please give additional details of the circumstances that led to this decision.",
                    ),
                ),
                (
                    "loss_category",
                    models.CharField(
                        choices=[
                            ("unknown_address", "Changed to an unknown address"),
                            ("never_returned", "Did not return despite reminders"),
                            ("bad_contact_details", "Inaccurate contact details"),
                            ("OTHER", "Other"),
                        ],
                        max_length=25,
                        verbose_name="Category of loss to follow up",
                    ),
                ),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "action_item",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="edc_action_item.ActionItem",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "parent_action_item",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="edc_action_item.ActionItem",
                    ),
                ),
                (
                    "related_action_item",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="edc_action_item.ActionItem",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "historical loss to followup ncd",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalLossToFollowupHiv",
            fields=[
                (
                    "revision",
                    django_revision.revision_field.RevisionField(
                        blank=True,
                        editable=False,
                        help_text="System field. Git repository tag:branch:commit.",
                        max_length=75,
                        null=True,
                        verbose_name="Revision",
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(
                        blank=True,
                        default=django_audit_fields.models.audit_model_mixin.utcnow,
                    ),
                ),
                (
                    "modified",
                    models.DateTimeField(
                        blank=True,
                        default=django_audit_fields.models.audit_model_mixin.utcnow,
                    ),
                ),
                (
                    "user_created",
                    django_audit_fields.fields.userfield.UserField(
                        blank=True,
                        help_text="Updated by admin.save_model",
                        max_length=50,
                        verbose_name="user created",
                    ),
                ),
                (
                    "user_modified",
                    django_audit_fields.fields.userfield.UserField(
                        blank=True,
                        help_text="Updated by admin.save_model",
                        max_length=50,
                        verbose_name="user modified",
                    ),
                ),
                (
                    "hostname_created",
                    models.CharField(
                        blank=True,
                        default=_socket.gethostname,
                        help_text="System field. (modified on create only)",
                        max_length=60,
                    ),
                ),
                (
                    "hostname_modified",
                    django_audit_fields.fields.hostname_modification_field.HostnameModificationField(
                        blank=True,
                        help_text="System field. (modified on every save)",
                        max_length=50,
                    ),
                ),
                ("device_created", models.CharField(blank=True, max_length=10)),
                ("device_modified", models.CharField(blank=True, max_length=10)),
                (
                    "id",
                    django_audit_fields.fields.uuid_auto_field.UUIDAutoField(
                        blank=True,
                        db_index=True,
                        editable=False,
                        help_text="System auto field. UUID primary key.",
                    ),
                ),
                ("subject_identifier", models.CharField(max_length=50)),
                ("tracking_identifier", models.CharField(db_index=True, max_length=30)),
                ("action_identifier", models.CharField(db_index=True, max_length=50)),
                (
                    "parent_action_identifier",
                    models.CharField(
                        help_text="action identifier that links to parent reference model instance.",
                        max_length=30,
                        null=True,
                    ),
                ),
                (
                    "related_action_identifier",
                    models.CharField(
                        help_text="action identifier that links to related reference model instance.",
                        max_length=30,
                        null=True,
                    ),
                ),
                ("action_item_reason", models.TextField(editable=False, null=True)),
                (
                    "history_id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "visit_schedule_name",
                    models.CharField(
                        editable=False,
                        help_text='the name of the visit schedule used to find the "schedule"',
                        max_length=25,
                    ),
                ),
                ("schedule_name", models.CharField(editable=False, max_length=25)),
                (
                    "report_datetime",
                    models.DateTimeField(
                        default=edc_utils.date.get_utcnow,
                        validators=[edc_protocol.validators.date_not_before_study_start],
                        verbose_name="Report Date and Time",
                    ),
                ),
                (
                    "last_seen_datetime",
                    models.DateField(
                        validators=[edc_protocol.validators.date_not_before_study_start],
                        verbose_name="Date participant last seen",
                    ),
                ),
                (
                    "number_consecutive_missed_visits",
                    models.IntegerField(
                        null=True, verbose_name="Number of consecutive visits missed"
                    ),
                ),
                (
                    "last_missed_visit_datetime",
                    models.DateField(
                        null=True,
                        verbose_name="Date of last missed visit report submitted",
                    ),
                ),
                (
                    "phone",
                    models.CharField(
                        choices=[("Yes", "Yes"), ("No", "No")],
                        max_length=15,
                        null=True,
                        verbose_name="Was contact by phone attempted",
                    ),
                ),
                (
                    "phone_attempts",
                    models.IntegerField(
                        default=0,
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name=(
                            "If YES, how many attempts were made to contact the participant by phone",
                        ),
                    ),
                ),
                (
                    "home_visited",
                    models.CharField(
                        choices=[("Yes", "Yes"), ("No", "No")],
                        max_length=15,
                        verbose_name="Was a home visit attempted",
                    ),
                ),
                (
                    "home_visit_detail",
                    models.TextField(
                        blank=True,
                        null=True,
                        verbose_name="If YES, provide any further details of the home visit",
                    ),
                ),
                (
                    "loss_category_other",
                    edc_model.models.fields.other_charfield.OtherCharField(
                        blank=True,
                        max_length=35,
                        null=True,
                        verbose_name="If other, please specify ...",
                    ),
                ),
                (
                    "comment",
                    models.TextField(
                        blank=True,
                        null=True,
                        verbose_name="If any, please give additional details of the circumstances that led to this decision.",
                    ),
                ),
                (
                    "loss_category",
                    models.CharField(
                        choices=[
                            ("unknown_address", "Changed to an unknown address"),
                            ("never_returned", "Did not return despite reminders"),
                            ("bad_contact_details", "Inaccurate contact details"),
                            ("OTHER", "Other"),
                        ],
                        max_length=25,
                        verbose_name="Category of loss to follow up",
                    ),
                ),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "action_item",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="edc_action_item.ActionItem",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "parent_action_item",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="edc_action_item.ActionItem",
                    ),
                ),
                (
                    "related_action_item",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="edc_action_item.ActionItem",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "historical loss to followup hiv",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
