203 lines
17 KiB
Python
203 lines
17 KiB
Python
# Generated by Django 5.2.3 on 2025-11-11 09:06
|
|
|
|
import django.core.validators
|
|
import django.db.models.deletion
|
|
import simple_history.models
|
|
import uuid
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('appointments', '0003_add_no_show_tracking'),
|
|
('core', '0010_documentationdelaytracker'),
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='HistoricalSession',
|
|
fields=[
|
|
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, verbose_name='ID')),
|
|
('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Created At')),
|
|
('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Updated At')),
|
|
('session_number', models.CharField(db_index=True, editable=False, max_length=20, verbose_name='Session Number')),
|
|
('session_type', models.CharField(choices=[('INDIVIDUAL', 'Individual Session'), ('GROUP', 'Group Session')], default='INDIVIDUAL', max_length=20, verbose_name='Session Type')),
|
|
('max_capacity', models.PositiveIntegerField(default=1, help_text='Maximum number of patients (1-20)', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(20)], verbose_name='Maximum Capacity')),
|
|
('service_type', models.CharField(max_length=200, verbose_name='Service Type')),
|
|
('scheduled_date', models.DateField(verbose_name='Scheduled Date')),
|
|
('scheduled_time', models.TimeField(verbose_name='Scheduled Time')),
|
|
('duration', models.PositiveIntegerField(default=30, help_text='Duration in minutes', verbose_name='Duration')),
|
|
('status', models.CharField(choices=[('SCHEDULED', 'Scheduled'), ('IN_PROGRESS', 'In Progress'), ('COMPLETED', 'Completed'), ('CANCELLED', 'Cancelled')], default='SCHEDULED', max_length=20, verbose_name='Status')),
|
|
('start_at', models.DateTimeField(blank=True, null=True, verbose_name='Start Time')),
|
|
('end_at', models.DateTimeField(blank=True, null=True, verbose_name='End Time')),
|
|
('group_notes', models.TextField(blank=True, help_text='Shared notes for the entire session', verbose_name='Group Notes')),
|
|
('cancel_reason', models.TextField(blank=True, verbose_name='Cancellation Reason')),
|
|
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
|
('history_date', models.DateTimeField(db_index=True)),
|
|
('history_change_reason', models.CharField(max_length=100, null=True)),
|
|
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
|
('cancelled_by', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Cancelled By')),
|
|
('clinic', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='core.clinic', verbose_name='Clinic')),
|
|
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
|
('provider', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='appointments.provider', verbose_name='Provider')),
|
|
('room', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='appointments.room', verbose_name='Room')),
|
|
('tenant', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='core.tenant', verbose_name='Tenant')),
|
|
],
|
|
options={
|
|
'verbose_name': 'historical Session',
|
|
'verbose_name_plural': 'historical Sessions',
|
|
'ordering': ('-history_date', '-history_id'),
|
|
'get_latest_by': ('history_date', 'history_id'),
|
|
},
|
|
bases=(simple_history.models.HistoricalChanges, models.Model),
|
|
),
|
|
migrations.CreateModel(
|
|
name='Session',
|
|
fields=[
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
|
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
|
|
('session_number', models.CharField(editable=False, max_length=20, unique=True, verbose_name='Session Number')),
|
|
('session_type', models.CharField(choices=[('INDIVIDUAL', 'Individual Session'), ('GROUP', 'Group Session')], default='INDIVIDUAL', max_length=20, verbose_name='Session Type')),
|
|
('max_capacity', models.PositiveIntegerField(default=1, help_text='Maximum number of patients (1-20)', validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(20)], verbose_name='Maximum Capacity')),
|
|
('service_type', models.CharField(max_length=200, verbose_name='Service Type')),
|
|
('scheduled_date', models.DateField(verbose_name='Scheduled Date')),
|
|
('scheduled_time', models.TimeField(verbose_name='Scheduled Time')),
|
|
('duration', models.PositiveIntegerField(default=30, help_text='Duration in minutes', verbose_name='Duration')),
|
|
('status', models.CharField(choices=[('SCHEDULED', 'Scheduled'), ('IN_PROGRESS', 'In Progress'), ('COMPLETED', 'Completed'), ('CANCELLED', 'Cancelled')], default='SCHEDULED', max_length=20, verbose_name='Status')),
|
|
('start_at', models.DateTimeField(blank=True, null=True, verbose_name='Start Time')),
|
|
('end_at', models.DateTimeField(blank=True, null=True, verbose_name='End Time')),
|
|
('group_notes', models.TextField(blank=True, help_text='Shared notes for the entire session', verbose_name='Group Notes')),
|
|
('cancel_reason', models.TextField(blank=True, verbose_name='Cancellation Reason')),
|
|
('cancelled_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='cancelled_sessions', to=settings.AUTH_USER_MODEL, verbose_name='Cancelled By')),
|
|
('clinic', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sessions', to='core.clinic', verbose_name='Clinic')),
|
|
('provider', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sessions', to='appointments.provider', verbose_name='Provider')),
|
|
('room', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sessions', to='appointments.room', verbose_name='Room')),
|
|
('tenant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_related', to='core.tenant', verbose_name='Tenant')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Session',
|
|
'verbose_name_plural': 'Sessions',
|
|
'ordering': ['-scheduled_date', '-scheduled_time'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='HistoricalSessionParticipant',
|
|
fields=[
|
|
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, verbose_name='ID')),
|
|
('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Created At')),
|
|
('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Updated At')),
|
|
('appointment_number', models.CharField(db_index=True, editable=False, max_length=20, verbose_name='Appointment Number')),
|
|
('status', models.CharField(choices=[('BOOKED', 'Booked'), ('CONFIRMED', 'Confirmed'), ('CANCELLED', 'Cancelled'), ('NO_SHOW', 'No Show'), ('ARRIVED', 'Arrived'), ('ATTENDED', 'Attended')], default='BOOKED', max_length=20, verbose_name='Status')),
|
|
('confirmation_sent_at', models.DateTimeField(blank=True, null=True, verbose_name='Confirmation Sent At')),
|
|
('arrival_at', models.DateTimeField(blank=True, null=True, verbose_name='Arrival Time')),
|
|
('attended_at', models.DateTimeField(blank=True, null=True, verbose_name='Attended At')),
|
|
('individual_notes', models.TextField(blank=True, help_text='Notes specific to this patient', verbose_name='Individual Notes')),
|
|
('finance_cleared', models.BooleanField(default=False, verbose_name='Finance Cleared')),
|
|
('consent_verified', models.BooleanField(default=False, verbose_name='Consent Verified')),
|
|
('cancel_reason', models.TextField(blank=True, verbose_name='Cancellation Reason')),
|
|
('no_show_reason', models.CharField(blank=True, choices=[('PATIENT_FORGOT', 'Patient Forgot'), ('PATIENT_SICK', 'Patient Sick'), ('TRANSPORTATION', 'Transportation Issue'), ('EMERGENCY', 'Emergency'), ('NO_CONTACT', 'Could Not Contact'), ('LATE_CANCELLATION', 'Late Cancellation'), ('OTHER', 'Other')], max_length=30, verbose_name='No-Show Reason')),
|
|
('no_show_notes', models.TextField(blank=True, help_text='Additional details about the no-show', verbose_name='No-Show Notes')),
|
|
('history_id', models.AutoField(primary_key=True, serialize=False)),
|
|
('history_date', models.DateTimeField(db_index=True)),
|
|
('history_change_reason', models.CharField(max_length=100, null=True)),
|
|
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
|
|
('cancelled_by', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Cancelled By')),
|
|
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
|
|
('patient', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='core.patient', verbose_name='Patient')),
|
|
('session', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='appointments.session', verbose_name='Session')),
|
|
],
|
|
options={
|
|
'verbose_name': 'historical Session Participant',
|
|
'verbose_name_plural': 'historical Session Participants',
|
|
'ordering': ('-history_date', '-history_id'),
|
|
'get_latest_by': ('history_date', 'history_id'),
|
|
},
|
|
bases=(simple_history.models.HistoricalChanges, models.Model),
|
|
),
|
|
migrations.AddField(
|
|
model_name='appointment',
|
|
name='session',
|
|
field=models.ForeignKey(blank=True, help_text='Link to session model for group session support', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='legacy_appointments', to='appointments.session', verbose_name='Session'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='historicalappointment',
|
|
name='session',
|
|
field=models.ForeignKey(blank=True, db_constraint=False, help_text='Link to session model for group session support', null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='appointments.session', verbose_name='Session'),
|
|
),
|
|
migrations.CreateModel(
|
|
name='SessionParticipant',
|
|
fields=[
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
|
|
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
|
|
('appointment_number', models.CharField(editable=False, max_length=20, unique=True, verbose_name='Appointment Number')),
|
|
('status', models.CharField(choices=[('BOOKED', 'Booked'), ('CONFIRMED', 'Confirmed'), ('CANCELLED', 'Cancelled'), ('NO_SHOW', 'No Show'), ('ARRIVED', 'Arrived'), ('ATTENDED', 'Attended')], default='BOOKED', max_length=20, verbose_name='Status')),
|
|
('confirmation_sent_at', models.DateTimeField(blank=True, null=True, verbose_name='Confirmation Sent At')),
|
|
('arrival_at', models.DateTimeField(blank=True, null=True, verbose_name='Arrival Time')),
|
|
('attended_at', models.DateTimeField(blank=True, null=True, verbose_name='Attended At')),
|
|
('individual_notes', models.TextField(blank=True, help_text='Notes specific to this patient', verbose_name='Individual Notes')),
|
|
('finance_cleared', models.BooleanField(default=False, verbose_name='Finance Cleared')),
|
|
('consent_verified', models.BooleanField(default=False, verbose_name='Consent Verified')),
|
|
('cancel_reason', models.TextField(blank=True, verbose_name='Cancellation Reason')),
|
|
('no_show_reason', models.CharField(blank=True, choices=[('PATIENT_FORGOT', 'Patient Forgot'), ('PATIENT_SICK', 'Patient Sick'), ('TRANSPORTATION', 'Transportation Issue'), ('EMERGENCY', 'Emergency'), ('NO_CONTACT', 'Could Not Contact'), ('LATE_CANCELLATION', 'Late Cancellation'), ('OTHER', 'Other')], max_length=30, verbose_name='No-Show Reason')),
|
|
('no_show_notes', models.TextField(blank=True, help_text='Additional details about the no-show', verbose_name='No-Show Notes')),
|
|
('cancelled_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='cancelled_participations', to=settings.AUTH_USER_MODEL, verbose_name='Cancelled By')),
|
|
('patient', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='session_participations', to='core.patient', verbose_name='Patient')),
|
|
('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='participants', to='appointments.session', verbose_name='Session')),
|
|
],
|
|
options={
|
|
'verbose_name': 'Session Participant',
|
|
'verbose_name_plural': 'Session Participants',
|
|
'ordering': ['created_at'],
|
|
},
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='session',
|
|
index=models.Index(fields=['session_number'], name='appointment_session_67a242_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='session',
|
|
index=models.Index(fields=['provider', 'scheduled_date'], name='appointment_provide_41e3aa_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='session',
|
|
index=models.Index(fields=['clinic', 'scheduled_date'], name='appointment_clinic__b7b4c5_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='session',
|
|
index=models.Index(fields=['status', 'scheduled_date'], name='appointment_status_ee4e4f_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='session',
|
|
index=models.Index(fields=['tenant', 'scheduled_date'], name='appointment_tenant__934d61_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='session',
|
|
index=models.Index(fields=['session_type', 'scheduled_date'], name='appointment_session_f0fdd6_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='sessionparticipant',
|
|
index=models.Index(fields=['appointment_number'], name='appointment_appoint_79a745_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='sessionparticipant',
|
|
index=models.Index(fields=['session', 'status'], name='appointment_session_af4cdb_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='sessionparticipant',
|
|
index=models.Index(fields=['patient', 'status'], name='appointment_patient_369712_idx'),
|
|
),
|
|
migrations.AddIndex(
|
|
model_name='sessionparticipant',
|
|
index=models.Index(fields=['status'], name='appointment_status_052db2_idx'),
|
|
),
|
|
migrations.AlterUniqueTogether(
|
|
name='sessionparticipant',
|
|
unique_together={('session', 'patient')},
|
|
),
|
|
]
|