# Generated by Django 6.0 on 2026-01-08 09:37 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', '0002_hospital_metadata'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='PXSource', 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)), ('code', models.CharField(db_index=True, help_text="Unique code for this source (e.g., 'PATIENT', 'FAMILY', 'STAFF')", max_length=50, unique=True)), ('name_en', models.CharField(help_text='Source name in English', max_length=200)), ('name_ar', models.CharField(blank=True, help_text='Source name in Arabic', max_length=200)), ('description_en', models.TextField(blank=True, help_text='Detailed description in English')), ('description_ar', models.TextField(blank=True, help_text='Detailed description in Arabic')), ('source_type', models.CharField(choices=[('complaint', 'Complaint'), ('inquiry', 'Inquiry'), ('both', 'Both Complaints and Inquiries')], db_index=True, default='both', help_text='Type of feedback this source applies to', max_length=20)), ('order', models.IntegerField(db_index=True, default=0, help_text='Display order (lower numbers appear first)')), ('is_active', models.BooleanField(db_index=True, default=True, help_text='Whether this source is active for selection')), ('icon_class', models.CharField(blank=True, help_text="CSS class for icon display (e.g., 'fas fa-user')", max_length=100)), ('color_code', models.CharField(blank=True, help_text="Color code for UI display (e.g., '#007bff')", max_length=20)), ('metadata', models.JSONField(blank=True, default=dict, help_text='Additional configuration or metadata')), ], options={ 'verbose_name': 'PX Source', 'verbose_name_plural': 'PX Sources', 'ordering': ['order', 'name_en'], 'indexes': [models.Index(fields=['is_active', 'source_type', 'order'], name='px_sources__is_acti_feb78d_idx'), models.Index(fields=['code'], name='px_sources__code_8ab80d_idx')], }, ), migrations.CreateModel( name='SourceUsage', 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)), ('object_id', models.UUIDField(help_text='ID of related object')), ('content_type', models.ForeignKey(help_text='Type of related object', on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')), ('hospital', models.ForeignKey(blank=True, help_text='Hospital where this source was used', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='source_usage_records', to='organizations.hospital')), ('source', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='usage_records', to='px_sources.pxsource')), ('user', models.ForeignKey(blank=True, help_text='User who selected this source', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='source_usage_records', to=settings.AUTH_USER_MODEL)), ], options={ 'verbose_name': 'Source Usage', 'verbose_name_plural': 'Source Usages', 'ordering': ['-created_at'], 'indexes': [models.Index(fields=['source', '-created_at'], name='px_sources__source__13a9ae_idx'), models.Index(fields=['content_type', 'object_id'], name='px_sources__content_30cb33_idx'), models.Index(fields=['hospital', '-created_at'], name='px_sources__hospita_a0479a_idx'), models.Index(fields=['created_at'], name='px_sources__created_8606b0_idx')], 'unique_together': {('content_type', 'object_id')}, }, ), ]