66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
# Generated migration to add missing fields to Observation model
|
|
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
('organizations', '0001_initial'), # Need hospital and department models
|
|
('observations', '0001_initial'),
|
|
]
|
|
|
|
operations = [
|
|
# Add hospital field (required for tenant isolation)
|
|
# Initially nullable, will be made required in next migration
|
|
migrations.AddField(
|
|
model_name='observation',
|
|
name='hospital',
|
|
field=models.ForeignKey(
|
|
null=True,
|
|
blank=True,
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name='observations',
|
|
to='organizations.hospital'
|
|
),
|
|
),
|
|
|
|
# Add staff field (optional, for AI-matching like complaints)
|
|
migrations.AddField(
|
|
model_name='observation',
|
|
name='staff',
|
|
field=models.ForeignKey(
|
|
blank=True,
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name='observations',
|
|
to='organizations.staff'
|
|
),
|
|
),
|
|
|
|
# Add source field (to track how observation was submitted)
|
|
migrations.AddField(
|
|
model_name='observation',
|
|
name='source',
|
|
field=models.CharField(
|
|
blank=True,
|
|
choices=[
|
|
('staff_portal', 'Staff Portal'),
|
|
('web_form', 'Web Form'),
|
|
('mobile_app', 'Mobile App'),
|
|
('email', 'Email'),
|
|
('call_center', 'Call Center'),
|
|
('other', 'Other'),
|
|
],
|
|
default='staff_portal',
|
|
max_length=50
|
|
),
|
|
),
|
|
|
|
# Add indexes for hospital filtering
|
|
migrations.AddIndex(
|
|
model_name='observation',
|
|
index=models.Index(fields=['hospital', 'status', '-created_at'], name='obs_hospital_status_idx'),
|
|
),
|
|
]
|