All checks were successful
Build and Push Docker Image / build (push) Successful in 1m5s
212 lines
17 KiB
Python
212 lines
17 KiB
Python
# Generated by Django 6.0.1 on 2026-05-11 20:32
|
|
|
|
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 = [
|
|
('contenttypes', '0002_remove_content_type_name'),
|
|
('organizations', '0001_initial'),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='NotificationTemplate',
|
|
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)),
|
|
('name', models.CharField(max_length=200, unique=True)),
|
|
('description', models.TextField(blank=True)),
|
|
('template_type', models.CharField(choices=[('survey_invitation', 'Survey Invitation'), ('survey_reminder', 'Survey Reminder'), ('complaint_acknowledgment', 'Complaint Acknowledgment'), ('complaint_update', 'Complaint Update'), ('action_assignment', 'Action Assignment'), ('sla_reminder', 'SLA Reminder'), ('sla_breach', 'SLA Breach'), ('onboarding_invitation', 'Onboarding Invitation'), ('onboarding_reminder', 'Onboarding Reminder'), ('onboarding_completion', 'Onboarding Completion')], db_index=True, max_length=50)),
|
|
('sms_template', models.TextField(blank=True, help_text='SMS template with {{variables}}')),
|
|
('sms_template_ar', models.TextField(blank=True)),
|
|
('whatsapp_template', models.TextField(blank=True, help_text='WhatsApp template with {{variables}}')),
|
|
('whatsapp_template_ar', models.TextField(blank=True)),
|
|
('email_subject', models.CharField(blank=True, max_length=500)),
|
|
('email_subject_ar', models.CharField(blank=True, max_length=500)),
|
|
('email_template', models.TextField(blank=True, help_text='Email HTML template with {{variables}}')),
|
|
('email_template_ar', models.TextField(blank=True)),
|
|
('is_active', models.BooleanField(default=True)),
|
|
],
|
|
options={
|
|
'ordering': ['name'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='HospitalNotificationSettings',
|
|
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)),
|
|
('complaint_acknowledgment_email', models.BooleanField(default=True, help_text='Send email when complaint is acknowledged')),
|
|
('complaint_acknowledgment_sms', models.BooleanField(default=False, help_text='Send SMS when complaint is acknowledged')),
|
|
('complaint_acknowledgment_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when complaint is acknowledged')),
|
|
('complaint_assigned_email', models.BooleanField(default=True, help_text='Send email when complaint is assigned')),
|
|
('complaint_assigned_sms', models.BooleanField(default=False, help_text='Send SMS when complaint is assigned')),
|
|
('complaint_assigned_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when complaint is assigned')),
|
|
('complaint_status_changed_email', models.BooleanField(default=True, help_text='Send email when complaint status changes')),
|
|
('complaint_status_changed_sms', models.BooleanField(default=False, help_text='Send SMS when complaint status changes')),
|
|
('complaint_status_changed_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when complaint status changes')),
|
|
('complaint_resolved_email', models.BooleanField(default=True, help_text='Send email when complaint is resolved')),
|
|
('complaint_resolved_sms', models.BooleanField(default=False, help_text='Send SMS when complaint is resolved')),
|
|
('complaint_resolved_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when complaint is resolved')),
|
|
('complaint_closed_email', models.BooleanField(default=True, help_text='Send email when complaint is closed')),
|
|
('complaint_closed_sms', models.BooleanField(default=False, help_text='Send SMS when complaint is closed')),
|
|
('complaint_closed_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when complaint is closed')),
|
|
('explanation_requested_email', models.BooleanField(default=True, help_text='Send email when complaint is sent to department')),
|
|
('explanation_requested_sms', models.BooleanField(default=False, help_text='Send SMS when explanation is requested from staff')),
|
|
('explanation_requested_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when explanation is requested from staff')),
|
|
('explanation_reminder_email', models.BooleanField(default=True, help_text='Send email reminder at 24h before SLA expires')),
|
|
('explanation_reminder_sms', models.BooleanField(default=False, help_text='Send SMS reminder at 24h before SLA expires')),
|
|
('explanation_reminder_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp reminder at 24h before SLA expires')),
|
|
('explanation_overdue_email', models.BooleanField(default=True, help_text='Send email when explanation is overdue (escalation)')),
|
|
('explanation_overdue_sms', models.BooleanField(default=False, help_text='Send SMS when explanation is overdue (escalation)')),
|
|
('explanation_overdue_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when explanation is overdue (escalation)')),
|
|
('explanation_received_email', models.BooleanField(default=True, help_text='Send email when staff submits explanation')),
|
|
('explanation_received_sms', models.BooleanField(default=False, help_text='Send SMS when staff submits explanation')),
|
|
('explanation_received_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when staff submits explanation')),
|
|
('explanation_manager_cc', models.BooleanField(default=False, help_text='CC manager when explanation is requested from staff')),
|
|
('survey_invitation_email', models.BooleanField(default=True, help_text='Send email survey invitation to patient')),
|
|
('survey_invitation_sms', models.BooleanField(default=True, help_text='Send SMS survey invitation to patient')),
|
|
('survey_invitation_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp survey invitation to patient')),
|
|
('survey_reminder_email', models.BooleanField(default=True, help_text='Send email survey reminder')),
|
|
('survey_reminder_sms', models.BooleanField(default=True, help_text='Send SMS survey reminder')),
|
|
('survey_reminder_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp survey reminder')),
|
|
('survey_completed_email', models.BooleanField(default=True, help_text='Send email when patient completes survey')),
|
|
('survey_completed_sms', models.BooleanField(default=False, help_text='Send SMS when patient completes survey')),
|
|
('action_assigned_email', models.BooleanField(default=True, help_text='Send email when action is assigned')),
|
|
('action_assigned_sms', models.BooleanField(default=False, help_text='Send SMS when action is assigned')),
|
|
('action_assigned_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when action is assigned')),
|
|
('action_due_soon_email', models.BooleanField(default=True, help_text='Send email when action is due soon')),
|
|
('action_due_soon_sms', models.BooleanField(default=False, help_text='Send SMS when action is due soon')),
|
|
('action_overdue_email', models.BooleanField(default=True, help_text='Send email when action is overdue')),
|
|
('action_overdue_sms', models.BooleanField(default=False, help_text='Send SMS when action is overdue')),
|
|
('sla_reminder_email', models.BooleanField(default=True, help_text='Send email SLA reminder')),
|
|
('sla_reminder_sms', models.BooleanField(default=False, help_text='Send SMS SLA reminder')),
|
|
('sla_breach_email', models.BooleanField(default=True, help_text='Send email when SLA is breached')),
|
|
('sla_breach_sms', models.BooleanField(default=False, help_text='Send SMS when SLA is breached')),
|
|
('sla_breach_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp when SLA is breached')),
|
|
('onboarding_invitation_email', models.BooleanField(default=True, help_text='Send email invitation to new provisional users')),
|
|
('onboarding_invitation_sms', models.BooleanField(default=False, help_text='Send SMS invitation to new provisional users')),
|
|
('onboarding_invitation_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp invitation to new provisional users')),
|
|
('onboarding_reminder_email', models.BooleanField(default=True, help_text='Send email reminder to complete onboarding')),
|
|
('onboarding_reminder_sms', models.BooleanField(default=False, help_text='Send SMS reminder to complete onboarding')),
|
|
('onboarding_reminder_whatsapp', models.BooleanField(default=False, help_text='Send WhatsApp reminder to complete onboarding')),
|
|
('onboarding_completion_email', models.BooleanField(default=True, help_text='Send email notification to admins when user completes onboarding')),
|
|
('onboarding_completion_sms', models.BooleanField(default=False, help_text='Send SMS notification to admins when user completes onboarding')),
|
|
('notifications_enabled', models.BooleanField(default=True, help_text='Master switch to enable/disable all notifications')),
|
|
('quiet_hours_enabled', models.BooleanField(default=False, help_text='Enable quiet hours (no SMS/WhatsApp during these hours)')),
|
|
('quiet_hours_start', models.TimeField(default='22:00', help_text='Start of quiet hours (e.g., 22:00 for 10 PM)')),
|
|
('quiet_hours_end', models.TimeField(default='08:00', help_text='End of quiet hours (e.g., 08:00 for 8 AM)')),
|
|
('retry_failed_notifications', models.BooleanField(default=True, help_text='Automatically retry failed notifications')),
|
|
('max_retries', models.IntegerField(default=3, help_text='Maximum number of retry attempts')),
|
|
('hospital', models.OneToOneField(help_text='Hospital these settings apply to', on_delete=django.db.models.deletion.CASCADE, related_name='notification_settings', to='organizations.hospital')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Hospital Notification Settings',
|
|
'verbose_name_plural': 'Hospital Notification Settings',
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='NotificationLog',
|
|
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)),
|
|
('channel', models.CharField(choices=[('sms', 'SMS'), ('whatsapp', 'WhatsApp'), ('email', 'Email'), ('push', 'Push Notification')], db_index=True, max_length=20)),
|
|
('recipient', models.CharField(help_text='Phone number or email address', max_length=200)),
|
|
('subject', models.CharField(blank=True, max_length=500)),
|
|
('message', models.TextField()),
|
|
('object_id', models.UUIDField(blank=True, null=True)),
|
|
('status', models.CharField(choices=[('pending', 'Pending'), ('sending', 'Sending'), ('sent', 'Sent'), ('delivered', 'Delivered'), ('failed', 'Failed'), ('bounced', 'Bounced')], db_index=True, default='pending', max_length=20)),
|
|
('sent_at', models.DateTimeField(blank=True, null=True)),
|
|
('delivered_at', models.DateTimeField(blank=True, null=True)),
|
|
('provider', models.CharField(blank=True, help_text='SMS/Email provider used', max_length=50)),
|
|
('provider_message_id', models.CharField(blank=True, help_text='Message ID from provider', max_length=200)),
|
|
('provider_response', models.JSONField(blank=True, default=dict, help_text='Full response from provider')),
|
|
('error', models.TextField(blank=True)),
|
|
('retry_count', models.IntegerField(default=0)),
|
|
('metadata', models.JSONField(blank=True, default=dict, help_text='Additional metadata (campaign, template, etc.)')),
|
|
('content_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='contenttypes.contenttype')),
|
|
],
|
|
options={
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='NotificationSettingsLog',
|
|
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)),
|
|
('field_name', models.CharField(max_length=100)),
|
|
('old_value', models.BooleanField(null=True)),
|
|
('new_value', models.BooleanField(null=True)),
|
|
('changed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
|
|
('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notification_settings_logs', to='organizations.hospital')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Notification Settings Change Log',
|
|
'verbose_name_plural': 'Notification Settings Change Logs',
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='UserNotification',
|
|
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)),
|
|
('title', models.CharField(max_length=200)),
|
|
('title_ar', models.CharField(blank=True, max_length=200)),
|
|
('message', models.TextField()),
|
|
('message_ar', models.TextField(blank=True)),
|
|
('notification_type', models.CharField(max_length=50)),
|
|
('object_id', models.UUIDField(blank=True, null=True)),
|
|
('action_url', models.CharField(blank=True, max_length=500)),
|
|
('is_read', models.BooleanField(default=False)),
|
|
('read_at', models.DateTimeField(blank=True, null=True)),
|
|
('is_dismissed', models.BooleanField(default=False)),
|
|
('dismissed_at', models.DateTimeField(blank=True, null=True)),
|
|
('content_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
|
|
('email_log', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='user_notification', to='notifications.notificationlog')),
|
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notifications', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'ordering': ['-created_at'],
|
|
},
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='notificationlog',
|
|
index=models.Index(fields=['channel', 'status', '-created_at'], name='notificatio_channel_b100a4_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='notificationlog',
|
|
index=models.Index(fields=['recipient', '-created_at'], name='notificatio_recipie_d4670c_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='notificationlog',
|
|
index=models.Index(fields=['content_type', 'object_id'], name='notificatio_content_bc6e15_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='usernotification',
|
|
index=models.Index(fields=['user', 'is_dismissed', '-created_at'], name='notificatio_user_id_092141_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='usernotification',
|
|
index=models.Index(fields=['user', 'is_read', '-created_at'], name='notificatio_user_id_bf9fcb_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='usernotification',
|
|
index=models.Index(fields=['created_at'], name='notificatio_created_edf100_idx'),
|
|
),
|
|
]
|