# Generated by Django 5.0.6 on 2026-11-02 07:03

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('Company', '0001_initial'),
        ('Employee', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='EmployeeInsurancePolicy',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, help_text='Who created this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, help_text='Who last updated this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('policy_number', models.CharField(max_length=100, unique=True)),
                ('insurer_name', models.CharField(max_length=255)),
                ('tpa_name', models.CharField(blank=True, max_length=255, null=True)),
                ('plan_name', models.CharField(blank=True, max_length=255, null=True)),
                ('policy_type', models.CharField(default='GROUP_HEALTH', max_length=50)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('ACTIVE', 'Active'), ('EXPIRED', 'Expired'), ('REJECTED', 'Rejected'), ('CANCELLED', 'Cancelled')], db_index=True, default='PENDING', max_length=20)),
                ('sum_insured', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('employee_monthly_premium', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('employer_monthly_premium', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('e_card', models.FileField(blank=True, null=True, upload_to='insurance/e_cards/')),
                ('policy_document', models.FileField(blank=True, null=True, upload_to='insurance/policies/')),
                ('coverage_summary', models.TextField(blank=True, null=True)),
                ('exclusions', models.TextField(blank=True, null=True)),
                ('waiting_period', models.TextField(blank=True, null=True)),
                ('co_payment', models.CharField(blank=True, max_length=100, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employee_insurance_policies', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='insurance_policies', to='Employee.employeedt')),
            ],
        ),
        migrations.CreateModel(
            name='EmployeeInsuranceDependent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, help_text='Who created this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, help_text='Who last updated this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('name', models.CharField(max_length=150)),
                ('relationship', models.CharField(choices=[('SPOUSE', 'Spouse'), ('CHILD', 'Child'), ('FATHER', 'Father'), ('MOTHER', 'Mother'), ('OTHER', 'Other')], max_length=20)),
                ('date_of_birth', models.DateField(blank=True, null=True)),
                ('gender', models.CharField(blank=True, max_length=30, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employee_insurance_dependents', to='Employee.employeedt')),
                ('policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employee_dependents', to='Insurance.employeeinsurancepolicy')),
            ],
        ),
        migrations.CreateModel(
            name='EmployeeInsuranceClaim',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, help_text='Who created this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, help_text='Who last updated this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('claim_number', models.CharField(max_length=50, unique=True)),
                ('claim_type', models.CharField(choices=[('CASHLESS', 'Cashless'), ('REIMBURSEMENT', 'Reimbursement')], max_length=20)),
                ('status', models.CharField(choices=[('SUBMITTED', 'Submitted'), ('UNDER_REVIEW', 'Under Review'), ('PREAUTH_PENDING', 'Pre-Authorization Pending'), ('PREAUTH_APPROVED', 'Pre-Authorization Approved'), ('PREAUTH_REJECTED', 'Pre-Authorization Rejected'), ('APPROVED', 'Approved'), ('PARTIALLY_APPROVED', 'Partially Approved'), ('REJECTED', 'Rejected'), ('SETTLED', 'Settled'), ('CANCELLED', 'Cancelled')], db_index=True, default='SUBMITTED', max_length=30)),
                ('hospital_name', models.CharField(blank=True, max_length=255, null=True)),
                ('hospital_city', models.CharField(blank=True, max_length=100, null=True)),
                ('admission_date', models.DateField(blank=True, null=True)),
                ('discharge_date', models.DateField(blank=True, null=True)),
                ('claimed_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('approved_amount', models.DecimalField(decimal_places=2, default=0, max_digits=12)),
                ('employee_description', models.TextField(blank=True, null=True)),
                ('rejection_reason', models.TextField(blank=True, null=True)),
                ('insurer_reference', models.CharField(blank=True, max_length=150, null=True)),
                ('submitted_at', models.DateTimeField(auto_now_add=True)),
                ('decision_at', models.DateTimeField(blank=True, null=True)),
                ('decided_by', models.CharField(blank=True, max_length=150, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employee_insurance_claims', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employee_insurance_claims', to='Employee.employeedt')),
                ('policy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='claims', to='Insurance.employeeinsurancepolicy')),
            ],
        ),
        migrations.CreateModel(
            name='InsuranceClaim',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=100)),
                ('updated_by', models.CharField(blank=True, max_length=100)),
                ('claim_id', models.CharField(max_length=100, unique=True)),
                ('patient_name', models.CharField(max_length=200)),
                ('relation', models.CharField(blank=True, default='Self', max_length=50)),
                ('claim_type', models.CharField(choices=[('Cashless', 'Cashless'), ('Reimbursement', 'Reimbursement')], max_length=30)),
                ('hospital_name', models.CharField(max_length=255)),
                ('city', models.CharField(max_length=100)),
                ('diagnosis', models.TextField(blank=True)),
                ('admission_date', models.DateField()),
                ('discharge_date', models.DateField()),
                ('claim_date', models.DateField()),
                ('claimed_amount', models.DecimalField(decimal_places=2, default=0, max_digits=14)),
                ('approved_amount', models.DecimalField(decimal_places=2, default=0, max_digits=14)),
                ('status', models.CharField(choices=[('Pending', 'Pending'), ('Approved', 'Approved'), ('Rejected', 'Rejected'), ('Settled', 'Settled')], default='Pending', max_length=30)),
                ('rejection_category', models.CharField(blank=True, max_length=100)),
                ('rejection_reason', models.TextField(blank=True)),
                ('tpa_ref', models.CharField(blank=True, max_length=150)),
                ('remarks', models.TextField(blank=True)),
                ('approved_at', models.DateTimeField(blank=True, null=True)),
                ('approved_by', models.CharField(blank=True, max_length=150)),
                ('rejected_at', models.DateTimeField(blank=True, null=True)),
                ('rejected_by', models.CharField(blank=True, max_length=150)),
                ('reopened_at', models.DateTimeField(blank=True, null=True)),
                ('reopened_by', models.CharField(blank=True, max_length=150)),
                ('settled_at', models.DateTimeField(blank=True, null=True)),
                ('settled_by', models.CharField(blank=True, max_length=150)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_records', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='legacy_insurance_claims', to='Employee.employeedt')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ClaimDocument',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, help_text='Who created this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, help_text='Who last updated this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('document_type', models.CharField(choices=[('Invoice', 'Invoice'), ('Discharge Summary', 'Discharge Summary'), ('Prescription', 'Prescription'), ('Other', 'Other')], default='Other', max_length=50)),
                ('file', models.FileField(upload_to='insurance/claims/%Y/%m/')),
                ('uploaded_at', models.DateTimeField(auto_now_add=True)),
                ('claim', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='Insurance.insuranceclaim')),
            ],
        ),
        migrations.CreateModel(
            name='InsuranceClaimDocument',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_by', models.CharField(blank=True, help_text='Who created this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('updated_by', models.CharField(blank=True, help_text='Who last updated this record (e.g. admin:<id> / employee:<id>)', max_length=150, null=True)),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('document_type', models.CharField(choices=[('BILL', 'Hospital Bill'), ('DISCHARGE', 'Discharge Summary'), ('PRESCRIPTION', 'Prescription'), ('REPORT', 'Medical Report'), ('ID', 'Identity Proof'), ('OTHER', 'Other')], max_length=30)),
                ('document_name', models.CharField(max_length=255)),
                ('file', models.FileField(upload_to='insurance/claims/')),
                ('uploaded_at', models.DateTimeField(auto_now_add=True)),
                ('claim', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='claim_documents', to='Insurance.employeeinsuranceclaim')),
            ],
        ),
        migrations.CreateModel(
            name='InsuranceDependent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=100)),
                ('updated_by', models.CharField(blank=True, max_length=100)),
                ('dependent_id', models.CharField(max_length=50, unique=True)),
                ('name', models.CharField(max_length=150)),
                ('relation', models.CharField(max_length=50)),
                ('gender', models.CharField(max_length=20)),
                ('dob', models.DateField(blank=True, null=True)),
                ('health_card_no', models.CharField(blank=True, max_length=100)),
                ('endorsement_status', models.CharField(default='Active', max_length=50)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_records', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='legacy_insurance_dependents', to='Employee.employeedt')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='InsurancePolicy',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=100)),
                ('updated_by', models.CharField(blank=True, max_length=100)),
                ('policy_id', models.CharField(max_length=50)),
                ('name', models.CharField(max_length=200)),
                ('provider', models.CharField(max_length=200)),
                ('policy_number', models.CharField(max_length=100)),
                ('policy_type', models.CharField(choices=[('GMC', 'Group Mediclaim'), ('GPA', 'Group Personal Accident'), ('GTL', 'Group Term Life'), ('TOP_UP', 'Voluntary Super Top-Up')], max_length=20)),
                ('sum_insured', models.DecimalField(decimal_places=2, max_digits=14)),
                ('coverage', models.CharField(blank=True, max_length=500)),
                ('eligible_dependents', models.CharField(blank=True, max_length=300)),
                ('co_pay_condition', models.CharField(blank=True, max_length=300)),
                ('room_rent_capping', models.CharField(blank=True, max_length=300)),
                ('maternity_cover', models.CharField(blank=True, max_length=300)),
                ('pre_post_hospitalization', models.CharField(blank=True, max_length=300)),
                ('tpa_name', models.CharField(blank=True, max_length=200)),
                ('tpa_helpline', models.CharField(blank=True, max_length=30)),
                ('start_date', models.DateField()),
                ('renewal_date', models.DateField()),
                ('status', models.CharField(choices=[('Active', 'Active'), ('Inactive', 'Inactive')], default='Active', max_length=20)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_records', to='Company.company_details')),
            ],
        ),
        migrations.AddField(
            model_name='insuranceclaim',
            name='policy',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='legacy_claims', to='Insurance.insurancepolicy'),
        ),
        migrations.CreateModel(
            name='EmployeeInsuranceEnrollment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=100)),
                ('updated_by', models.CharField(blank=True, max_length=100)),
                ('member_id', models.CharField(blank=True, max_length=100)),
                ('employee_monthly_premium', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('employer_monthly_premium', models.DecimalField(decimal_places=2, default=0, max_digits=10)),
                ('start_date', models.DateField(blank=True, null=True)),
                ('end_date', models.DateField(blank=True, null=True)),
                ('status', models.CharField(choices=[('Pending', 'Pending'), ('Active', 'Active'), ('Rejected', 'Rejected'), ('Inactive', 'Inactive')], default='Pending', max_length=20)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_records', to='Company.company_details')),
                ('employee', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='insurance_enrollments', to='Employee.employeedt')),
                ('policy', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='employee_enrollments', to='Insurance.insurancepolicy')),
            ],
        ),
        migrations.CreateModel(
            name='InsuranceTPA',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=100)),
                ('updated_by', models.CharField(blank=True, max_length=100)),
                ('name', models.CharField(max_length=200)),
                ('corporate_account', models.CharField(blank=True, max_length=200)),
                ('phone', models.CharField(blank=True, max_length=30)),
                ('email', models.EmailField(blank=True, max_length=254)),
                ('preauth_tat_hours', models.PositiveIntegerField(default=2)),
                ('settlement_ratio', models.DecimalField(decimal_places=2, default=0, max_digits=5)),
                ('is_active', models.BooleanField(default=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_records', to='Company.company_details')),
            ],
        ),
        migrations.CreateModel(
            name='NetworkHospital',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('id_version', models.PositiveIntegerField(default=1, help_text='Record version counter')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('created_by', models.CharField(blank=True, max_length=100)),
                ('updated_by', models.CharField(blank=True, max_length=100)),
                ('hospital_name', models.CharField(max_length=255)),
                ('address', models.CharField(blank=True, max_length=500, null=True)),
                ('city', models.CharField(max_length=100)),
                ('cashless_pre_auth', models.BooleanField(default=True)),
                ('direct_contact', models.CharField(blank=True, max_length=30, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_records', to='Company.company_details')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddConstraint(
            model_name='insurancepolicy',
            constraint=models.UniqueConstraint(fields=('company', 'policy_id'), name='unique_insurance_policy_company_id'),
        ),
        migrations.AddConstraint(
            model_name='insurancepolicy',
            constraint=models.UniqueConstraint(fields=('company', 'policy_number'), name='unique_insurance_policy_company_number'),
        ),
        migrations.AddConstraint(
            model_name='employeeinsuranceenrollment',
            constraint=models.UniqueConstraint(fields=('employee', 'policy'), name='unique_employee_insurance_enrollment'),
        ),
        migrations.AddConstraint(
            model_name='insurancetpa',
            constraint=models.UniqueConstraint(fields=('company', 'name'), name='unique_insurance_tpa_company_name'),
        ),
    ]
