# Generated by Django 6.0 on 2026-01-12 09:50 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 = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='Organization', 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)), ('name_ar', models.CharField(blank=True, max_length=200, verbose_name='Name (Arabic)')), ('code', models.CharField(db_index=True, max_length=50, unique=True)), ('phone', models.CharField(blank=True, max_length=20)), ('email', models.EmailField(blank=True, max_length=254)), ('address', models.TextField(blank=True)), ('city', models.CharField(blank=True, max_length=100)), ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], db_index=True, default='active', max_length=20)), ('logo', models.ImageField(blank=True, null=True, upload_to='organizations/logos/')), ('website', models.URLField(blank=True)), ('license_number', models.CharField(blank=True, max_length=100)), ], options={ 'verbose_name': 'Organization', 'verbose_name_plural': 'Organizations', 'ordering': ['name'], }, ), migrations.CreateModel( name='Hospital', 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)), ('name_ar', models.CharField(blank=True, max_length=200, verbose_name='Name (Arabic)')), ('code', models.CharField(db_index=True, max_length=50, unique=True)), ('address', models.TextField(blank=True)), ('city', models.CharField(blank=True, max_length=100)), ('phone', models.CharField(blank=True, max_length=20)), ('email', models.EmailField(blank=True, max_length=254)), ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], db_index=True, default='active', max_length=20)), ('license_number', models.CharField(blank=True, max_length=100)), ('capacity', models.IntegerField(blank=True, help_text='Bed capacity', null=True)), ('metadata', models.JSONField(blank=True, default=dict, help_text='Hospital configuration settings')), ('ceo', models.ForeignKey(blank=True, help_text='Chief Executive Officer', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hospitals_as_ceo', to=settings.AUTH_USER_MODEL, verbose_name='CEO')), ('cfo', models.ForeignKey(blank=True, help_text='Chief Financial Officer', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hospitals_as_cfo', to=settings.AUTH_USER_MODEL, verbose_name='CFO')), ('coo', models.ForeignKey(blank=True, help_text='Chief Operating Officer', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hospitals_as_coo', to=settings.AUTH_USER_MODEL, verbose_name='COO')), ('medical_director', models.ForeignKey(blank=True, help_text='Medical Director', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hospitals_as_medical_director', to=settings.AUTH_USER_MODEL, verbose_name='Medical Director')), ('organization', models.ForeignKey(blank=True, help_text='Parent organization (null for backward compatibility)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='hospitals', to='organizations.organization')), ], options={ 'verbose_name_plural': 'Hospitals', 'ordering': ['name'], }, ), migrations.CreateModel( name='Department', 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)), ('name_ar', models.CharField(blank=True, max_length=200, verbose_name='Name (Arabic)')), ('code', models.CharField(db_index=True, max_length=50)), ('phone', models.CharField(blank=True, max_length=20)), ('email', models.EmailField(blank=True, max_length=254)), ('location', models.CharField(blank=True, help_text='Building/Floor/Room', max_length=200)), ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], db_index=True, default='active', max_length=20)), ('manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='managed_departments', to=settings.AUTH_USER_MODEL)), ('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sub_departments', to='organizations.department')), ('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='departments', to='organizations.hospital')), ], options={ 'ordering': ['hospital', 'name'], 'unique_together': {('hospital', 'code')}, }, ), migrations.CreateModel( name='Patient', 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)), ('mrn', models.CharField(db_index=True, max_length=50, unique=True, verbose_name='Medical Record Number')), ('national_id', models.CharField(blank=True, db_index=True, max_length=50)), ('first_name', models.CharField(max_length=100)), ('last_name', models.CharField(max_length=100)), ('first_name_ar', models.CharField(blank=True, max_length=100)), ('last_name_ar', models.CharField(blank=True, max_length=100)), ('date_of_birth', models.DateField(blank=True, null=True)), ('gender', models.CharField(blank=True, choices=[('male', 'Male'), ('female', 'Female'), ('other', 'Other')], max_length=10)), ('phone', models.CharField(blank=True, max_length=20)), ('email', models.EmailField(blank=True, max_length=254)), ('address', models.TextField(blank=True)), ('city', models.CharField(blank=True, max_length=100)), ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], db_index=True, default='active', max_length=20)), ('primary_hospital', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='patients', to='organizations.hospital')), ], options={ 'ordering': ['last_name', 'first_name'], }, ), migrations.CreateModel( name='Staff', 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)), ('first_name', models.CharField(max_length=100)), ('last_name', models.CharField(max_length=100)), ('first_name_ar', models.CharField(blank=True, max_length=100)), ('last_name_ar', models.CharField(blank=True, max_length=100)), ('staff_type', models.CharField(choices=[('physician', 'Physician'), ('nurse', 'Nurse'), ('admin', 'Administrative'), ('other', 'Other')], max_length=20)), ('job_title', models.CharField(max_length=200)), ('license_number', models.CharField(blank=True, max_length=100, null=True, unique=True)), ('specialization', models.CharField(blank=True, max_length=200)), ('email', models.EmailField(blank=True, max_length=254)), ('employee_id', models.CharField(db_index=True, max_length=50, unique=True)), ('name', models.CharField(blank=True, max_length=300, verbose_name='Full Name (Original)')), ('country', models.CharField(blank=True, max_length=100, verbose_name='Country')), ('location', models.CharField(blank=True, max_length=200, verbose_name='Location')), ('gender', models.CharField(blank=True, choices=[('male', 'Male'), ('female', 'Female'), ('other', 'Other')], max_length=10)), ('department_name', models.CharField(blank=True, max_length=200, verbose_name='Department (Original)')), ('section', models.CharField(blank=True, max_length=200, verbose_name='Section')), ('subsection', models.CharField(blank=True, max_length=200, verbose_name='Subsection')), ('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], default='active', max_length=20)), ('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='staff', to='organizations.department')), ('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='staff', to='organizations.hospital')), ('report_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='direct_reports', to='organizations.staff', verbose_name='Reports To')), ('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='staff_profile', to=settings.AUTH_USER_MODEL)), ], options={ 'abstract': False, }, ), ]