149 lines
10 KiB
Python
149 lines
10 KiB
Python
# Generated by Django 5.0.14 on 2025-12-14 10:56
|
|
|
|
import django.db.models.deletion
|
|
import uuid
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
initial = True
|
|
|
|
dependencies = [
|
|
('organizations', '0001_initial'),
|
|
('surveys', '0002_surveyquestion_surveyresponse_and_more'),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='Complaint',
|
|
fields=[
|
|
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
('encounter_id', models.CharField(blank=True, db_index=True, help_text='Related encounter ID if applicable', max_length=100)),
|
|
('title', models.CharField(max_length=500)),
|
|
('description', models.TextField()),
|
|
('category', models.CharField(choices=[('clinical_care', 'Clinical Care'), ('staff_behavior', 'Staff Behavior'), ('facility', 'Facility & Environment'), ('wait_time', 'Wait Time'), ('billing', 'Billing'), ('communication', 'Communication'), ('other', 'Other')], db_index=True, max_length=100)),
|
|
('subcategory', models.CharField(blank=True, max_length=100)),
|
|
('priority', models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('critical', 'Critical')], db_index=True, default='medium', max_length=20)),
|
|
('severity', models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('critical', 'Critical')], db_index=True, default='medium', max_length=20)),
|
|
('source', models.CharField(choices=[('patient', 'Patient'), ('family', 'Family Member'), ('staff', 'Staff'), ('survey', 'Survey'), ('social_media', 'Social Media'), ('call_center', 'Call Center'), ('moh', 'Ministry of Health'), ('chi', 'Council of Health Insurance'), ('other', 'Other')], db_index=True, default='patient', max_length=50)),
|
|
('status', models.CharField(choices=[('open', 'Open'), ('in_progress', 'In Progress'), ('resolved', 'Resolved'), ('closed', 'Closed'), ('cancelled', 'Cancelled')], db_index=True, default='open', max_length=20)),
|
|
('assigned_at', models.DateTimeField(blank=True, null=True)),
|
|
('due_at', models.DateTimeField(db_index=True, help_text='SLA deadline')),
|
|
('is_overdue', models.BooleanField(db_index=True, default=False)),
|
|
('reminder_sent_at', models.DateTimeField(blank=True, null=True)),
|
|
('escalated_at', models.DateTimeField(blank=True, null=True)),
|
|
('resolution', models.TextField(blank=True)),
|
|
('resolved_at', models.DateTimeField(blank=True, null=True)),
|
|
('closed_at', models.DateTimeField(blank=True, null=True)),
|
|
('resolution_survey_sent_at', models.DateTimeField(blank=True, null=True)),
|
|
('metadata', models.JSONField(blank=True, default=dict)),
|
|
('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_complaints', to=settings.AUTH_USER_MODEL)),
|
|
('closed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='closed_complaints', to=settings.AUTH_USER_MODEL)),
|
|
('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaints', to='organizations.department')),
|
|
('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaints', to='organizations.hospital')),
|
|
('patient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='complaints', to='organizations.patient')),
|
|
('physician', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaints', to='organizations.physician')),
|
|
('resolution_survey', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_resolution', to='surveys.surveyinstance')),
|
|
('resolved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='resolved_complaints', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='ComplaintAttachment',
|
|
fields=[
|
|
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
('file', models.FileField(upload_to='complaints/%Y/%m/%d/')),
|
|
('filename', models.CharField(max_length=500)),
|
|
('file_type', models.CharField(blank=True, max_length=100)),
|
|
('file_size', models.IntegerField(help_text='File size in bytes')),
|
|
('description', models.TextField(blank=True)),
|
|
('complaint', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='attachments', to='complaints.complaint')),
|
|
('uploaded_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_attachments', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='ComplaintUpdate',
|
|
fields=[
|
|
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
('update_type', models.CharField(choices=[('status_change', 'Status Change'), ('assignment', 'Assignment'), ('note', 'Note'), ('resolution', 'Resolution'), ('escalation', 'Escalation'), ('communication', 'Communication')], db_index=True, max_length=50)),
|
|
('message', models.TextField()),
|
|
('old_status', models.CharField(blank=True, max_length=20)),
|
|
('new_status', models.CharField(blank=True, max_length=20)),
|
|
('metadata', models.JSONField(blank=True, default=dict)),
|
|
('complaint', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='updates', to='complaints.complaint')),
|
|
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='complaint_updates', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='Inquiry',
|
|
fields=[
|
|
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
|
|
('updated_at', models.DateTimeField(auto_now=True)),
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
('contact_name', models.CharField(blank=True, max_length=200)),
|
|
('contact_phone', models.CharField(blank=True, max_length=20)),
|
|
('contact_email', models.EmailField(blank=True, max_length=254)),
|
|
('subject', models.CharField(max_length=500)),
|
|
('message', models.TextField()),
|
|
('category', models.CharField(choices=[('appointment', 'Appointment'), ('billing', 'Billing'), ('medical_records', 'Medical Records'), ('general', 'General Information'), ('other', 'Other')], max_length=100)),
|
|
('status', models.CharField(choices=[('open', 'Open'), ('in_progress', 'In Progress'), ('resolved', 'Resolved'), ('closed', 'Closed')], db_index=True, default='open', max_length=20)),
|
|
('response', models.TextField(blank=True)),
|
|
('responded_at', models.DateTimeField(blank=True, null=True)),
|
|
('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_inquiries', to=settings.AUTH_USER_MODEL)),
|
|
('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='inquiries', to='organizations.department')),
|
|
('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='inquiries', to='organizations.hospital')),
|
|
('patient', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='inquiries', to='organizations.patient')),
|
|
('responded_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='responded_inquiries', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'verbose_name_plural': 'Inquiries',
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='complaint',
|
|
index=models.Index(fields=['status', '-created_at'], name='complaints__status_f077e8_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='complaint',
|
|
index=models.Index(fields=['hospital', 'status', '-created_at'], name='complaints__hospita_cf53df_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='complaint',
|
|
index=models.Index(fields=['is_overdue', 'status'], name='complaints__is_over_3d3554_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='complaint',
|
|
index=models.Index(fields=['due_at', 'status'], name='complaints__due_at_836821_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='complaintupdate',
|
|
index=models.Index(fields=['complaint', '-created_at'], name='complaints__complai_f3684e_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='inquiry',
|
|
index=models.Index(fields=['status', '-created_at'], name='complaints__status_3d0678_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='inquiry',
|
|
index=models.Index(fields=['hospital', 'status'], name='complaints__hospita_b1573b_idx'),
|
|
),
|
|
]
|