# Generated by Django 3.2.3 on 2021-05-24 14:38

import _socket
from django.conf import settings
import django.core.validators
from django.db import migrations, models
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_utils.date
import simple_history.models
import uuid


class Migration(migrations.Migration):

    dependencies = [
        ("sites", "0002_alter_domain_unique"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("inte_screening", "0016_alter_dailyclosinglogrevised_options"),
    ]

    operations = [
        migrations.CreateModel(
            name="HistoricalDailyClosingLogRevised",
            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.",
                    ),
                ),
                (
                    "log_date",
                    models.DateField(
                        default=edc_utils.date.get_utcnow, verbose_name="Clinic date"
                    ),
                ),
                (
                    "clinic_services",
                    models.CharField(
                        choices=[
                            (
                                "integrated",
                                "Integrated care day (HIV, Diabetes, Hypertension)",
                            ),
                            ("ncd", "NCD day (Diabetes + Hypertension)"),
                            ("HIV", "HIV only day"),
                            ("diabetes", "Diabetes only day"),
                            ("hypertension", "Hypertension only day"),
                        ],
                        max_length=25,
                        verbose_name="Which services are being offered at the clinic today?",
                    ),
                ),
                (
                    "attended",
                    models.IntegerField(
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name="Total number of patients who attended the clinic today",
                    ),
                ),
                (
                    "selection_method",
                    models.CharField(
                        choices=[
                            ("random_sampling", "Random sampling"),
                            ("systematic", "Systematically selected"),
                            ("sequential", "Sequentially selected"),
                            ("purposively_selected", "Purposively selected"),
                        ],
                        max_length=25,
                        null=True,
                        verbose_name="How were patients selected to be approached?",
                    ),
                ),
                (
                    "approached",
                    models.IntegerField(
                        null=True,
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name="Of those who attended, how many were approached by the study team",
                    ),
                ),
                (
                    "agreed_to_screen",
                    models.IntegerField(
                        null=True,
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name="Of those approached, how many agreed to be screened",
                    ),
                ),
                (
                    "clinic_start_time",
                    models.TimeField(
                        help_text="Use 24HRS format. For example 17:00",
                        null=True,
                        verbose_name="Clinic start time",
                    ),
                ),
                (
                    "clinic_end_time",
                    models.TimeField(
                        help_text="Use 24HRS format. For example 17:00",
                        null=True,
                        verbose_name="Clinic End time",
                    ),
                ),
                (
                    "comment",
                    models.TextField(
                        blank=True, null=True, verbose_name="Additional Comments"
                    ),
                ),
                (
                    "history_id",
                    models.UUIDField(
                        default=uuid.uuid4, editable=False, primary_key=True, serialize=False
                    ),
                ),
                ("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,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="sites.site",
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Daily Closing Log (post-enrollment)",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
