# Generated by Django 2.2.11 on 2023-02-15 08:04

import uuid

import django.contrib.postgres.fields.jsonb
import django.db.models.deletion
from django.db import migrations, models

import care.utils.models.validators


class Migration(migrations.Migration):
    dependencies = [
        ("facility", "0335_auto_20230207_1914"),
        ("hcx", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="Claim",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "external_id",
                    models.UUIDField(db_index=True, default=uuid.uuid4, unique=True),
                ),
                (
                    "created_date",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "modified_date",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                ("deleted", models.BooleanField(db_index=True, default=False)),
                (
                    "procedures",
                    django.contrib.postgres.fields.jsonb.JSONField(
                        default=list,
                        validators=[
                            care.utils.models.validators.JSONFieldSchemaValidator(
                                {
                                    "$schema": "http://json-schema.org/draft-07/schema#",
                                    "items": [
                                        {
                                            "additionalProperties": False,
                                            "properties": {
                                                "id": {"type": "string"},
                                                "name": {"type": "string"},
                                                "price": {"type": "number"},
                                            },
                                            "required": ["id", "name", "price"],
                                            "type": "object",
                                        }
                                    ],
                                    "type": "array",
                                }
                            )
                        ],
                    ),
                ),
                ("total_claim_amount", models.FloatField(blank=True, null=True)),
                ("total_amount_approved", models.FloatField(blank=True, null=True)),
                (
                    "use",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("claim", "Claim"),
                            ("preauthorization", "Pre-Authorization"),
                            ("predetermination", "Pre-Determination"),
                        ],
                        default=None,
                        max_length=20,
                        null=True,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("active", "Active"),
                            ("cancelled", "Cancelled"),
                            ("draft", "Draft"),
                            ("entered-in-error", "Entered in Error"),
                        ],
                        default=None,
                        max_length=20,
                        null=True,
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("stat", "Immediate"),
                            ("normal", "Normal"),
                            ("deferred", "Deferred"),
                        ],
                        default="normal",
                        max_length=20,
                    ),
                ),
                (
                    "type",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("institutional", "Institutional"),
                            ("oral", "Oral"),
                            ("pharmacy", "Pharmacy"),
                            ("professional", "Professional"),
                            ("vision", "Vision"),
                        ],
                        default=None,
                        max_length=20,
                        null=True,
                    ),
                ),
                (
                    "outcome",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("queued", "Queued"),
                            ("complete", "Processing Complete"),
                            ("error", "Error"),
                            ("partial", "Partial Processing"),
                        ],
                        default=None,
                        max_length=20,
                        null=True,
                    ),
                ),
                ("error_text", models.TextField(blank=True, null=True)),
                (
                    "consultation",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="facility.PatientConsultation",
                    ),
                ),
                (
                    "policy",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="hcx.Policy"
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
    ]
