HH/apps/journeys/migrations/0001_initial.py

101 lines
6.8 KiB
Python

<<<<<<< HEAD
# Generated by Django 6.0 on 2026-01-12 09:50
=======
# Generated by Django 6.0.1 on 2026-01-12 09:50
>>>>>>> 1f9d8a7 (update on the complaint sla and staff hierarchy)
import django.db.models.deletion
import uuid
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('integrations', '0001_initial'),
('organizations', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='PatientJourneyStageTemplate',
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)),
('code', models.CharField(help_text='Unique code for this stage (e.g., OPD_MD_CONSULT, LAB, RADIOLOGY)', max_length=50)),
('order', models.IntegerField(default=0, help_text='Order of this stage in the journey')),
('trigger_event_code', models.CharField(db_index=True, help_text='Event code that triggers completion of this stage (e.g., OPD_VISIT_COMPLETED)', max_length=100)),
('auto_send_survey', models.BooleanField(default=False, help_text='Automatically send survey when stage completes')),
('survey_delay_hours', models.IntegerField(default=0, help_text='Hours to wait before sending survey (0 = immediate)')),
('requires_physician', models.BooleanField(default=False, help_text='Does this stage require physician information?')),
('requires_department', models.BooleanField(default=False, help_text='Does this stage require department information?')),
('is_optional', models.BooleanField(default=False, help_text='Can this stage be skipped?')),
('is_active', models.BooleanField(default=True)),
('description', models.TextField(blank=True)),
],
options={
'ordering': ['journey_template', 'order'],
},
),
migrations.CreateModel(
name='PatientJourneyTemplate',
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)')),
('journey_type', models.CharField(choices=[('ems', 'EMS (Emergency Medical Services)'), ('inpatient', 'Inpatient'), ('opd', 'OPD (Outpatient Department)')], db_index=True, max_length=20)),
('description', models.TextField(blank=True)),
('is_active', models.BooleanField(db_index=True, default=True)),
('is_default', models.BooleanField(default=False, help_text='Default template for this journey type in this hospital')),
],
options={
'ordering': ['hospital', 'journey_type', 'name'],
},
),
migrations.CreateModel(
name='PatientJourneyInstance',
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(db_index=True, help_text='Unique encounter ID from HIS system', max_length=100, unique=True)),
('status', models.CharField(choices=[('active', 'Active'), ('inactive', 'Inactive'), ('pending', 'Pending'), ('completed', 'Completed'), ('cancelled', 'Cancelled')], db_index=True, default='active', max_length=20)),
('started_at', models.DateTimeField(auto_now_add=True)),
('completed_at', models.DateTimeField(blank=True, null=True)),
('metadata', models.JSONField(blank=True, default=dict, help_text='Additional metadata from HIS system')),
('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='journey_instances', to='organizations.department')),
('hospital', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='journey_instances', to='organizations.hospital')),
('patient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='journeys', to='organizations.patient')),
],
options={
'ordering': ['-started_at'],
},
),
migrations.CreateModel(
name='PatientJourneyStageInstance',
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)),
('status', models.CharField(choices=[('pending', 'Pending'), ('in_progress', 'In Progress'), ('completed', 'Completed'), ('skipped', 'Skipped'), ('cancelled', 'Cancelled')], db_index=True, default='pending', max_length=20)),
('completed_at', models.DateTimeField(blank=True, db_index=True, null=True)),
('survey_sent_at', models.DateTimeField(blank=True, null=True)),
('metadata', models.JSONField(blank=True, default=dict, help_text='Additional data from integration event')),
('completed_by_event', models.ForeignKey(blank=True, help_text='Integration event that completed this stage', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='completed_stages', to='integrations.inboundevent')),
('department', models.ForeignKey(blank=True, help_text='Department where this stage occurred', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='journey_stages', to='organizations.department')),
('journey_instance', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stage_instances', to='journeys.patientjourneyinstance')),
('staff', models.ForeignKey(blank=True, help_text='Staff member associated with this stage', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='journey_stages', to='organizations.staff')),
],
options={
'ordering': ['journey_instance', 'stage_template__order'],
},
),
]