Marwan Alwali 84c1fb798e update
2025-09-08 19:52:52 +03:00

1047 lines
39 KiB
Python

# Generated by Django 5.2.6 on 2025-09-08 07:28
import django.core.validators
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="AppointmentTemplate",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(help_text="Template name", max_length=200)),
(
"description",
models.TextField(
blank=True, help_text="Template description", null=True
),
),
(
"appointment_type",
models.CharField(
help_text="Default appointment type", max_length=50
),
),
(
"specialty",
models.CharField(help_text="Medical specialty", max_length=100),
),
(
"duration_minutes",
models.PositiveIntegerField(
help_text="Default duration in minutes"
),
),
(
"advance_booking_days",
models.PositiveIntegerField(
default=30, help_text="Maximum advance booking days"
),
),
(
"minimum_notice_hours",
models.PositiveIntegerField(
default=24, help_text="Minimum notice required in hours"
),
),
(
"insurance_verification_required",
models.BooleanField(
default=False, help_text="Insurance verification required"
),
),
(
"authorization_required",
models.BooleanField(
default=False, help_text="Prior authorization required"
),
),
(
"pre_appointment_instructions",
models.TextField(
blank=True,
help_text="Pre-appointment instructions for patient",
null=True,
),
),
(
"post_appointment_instructions",
models.TextField(
blank=True,
help_text="Post-appointment instructions template",
null=True,
),
),
(
"required_forms",
models.JSONField(
blank=True,
default=list,
help_text="Required forms for this appointment type",
),
),
(
"is_active",
models.BooleanField(default=True, help_text="Template is active"),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Appointment Template",
"verbose_name_plural": "Appointment Templates",
"db_table": "appointments_appointment_template",
"ordering": ["specialty", "name"],
},
),
migrations.CreateModel(
name="QueueEntry",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"entry_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique entry identifier",
unique=True,
),
),
(
"queue_position",
models.PositiveIntegerField(help_text="Position in queue"),
),
(
"priority_score",
models.FloatField(
default=1.0, help_text="Priority score for queue ordering"
),
),
(
"joined_at",
models.DateTimeField(
auto_now_add=True, help_text="Time patient joined queue"
),
),
(
"estimated_service_time",
models.DateTimeField(
blank=True, help_text="Estimated service time", null=True
),
),
(
"called_at",
models.DateTimeField(
blank=True, help_text="Time patient was called", null=True
),
),
(
"served_at",
models.DateTimeField(
blank=True, help_text="Time patient was served", null=True
),
),
(
"status",
models.CharField(
choices=[
("WAITING", "Waiting"),
("CALLED", "Called"),
("IN_SERVICE", "In Service"),
("COMPLETED", "Completed"),
("LEFT", "Left Queue"),
("NO_SHOW", "No Show"),
],
default="WAITING",
help_text="Queue entry status",
max_length=20,
),
),
(
"notification_sent",
models.BooleanField(
default=False, help_text="Notification sent to patient"
),
),
(
"notification_method",
models.CharField(
blank=True,
choices=[
("SMS", "SMS"),
("EMAIL", "Email"),
("PHONE", "Phone Call"),
("PAGER", "Pager"),
("APP", "Mobile App"),
],
help_text="Notification method used",
max_length=20,
null=True,
),
),
(
"notes",
models.TextField(
blank=True, help_text="Additional notes", null=True
),
),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Queue Entry",
"verbose_name_plural": "Queue Entries",
"db_table": "appointments_queue_entry",
"ordering": ["queue", "priority_score", "joined_at"],
},
),
migrations.CreateModel(
name="SlotAvailability",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"slot_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique slot identifier",
unique=True,
),
),
("date", models.DateField(help_text="Availability date")),
("start_time", models.TimeField(help_text="Slot start time")),
("end_time", models.TimeField(help_text="Slot end time")),
(
"duration_minutes",
models.PositiveIntegerField(help_text="Slot duration in minutes"),
),
(
"availability_type",
models.CharField(
choices=[
("REGULAR", "Regular Hours"),
("EXTENDED", "Extended Hours"),
("EMERGENCY", "Emergency"),
("ON_CALL", "On Call"),
("TELEMEDICINE", "Telemedicine Only"),
],
default="REGULAR",
help_text="Type of availability",
max_length=20,
),
),
(
"max_appointments",
models.PositiveIntegerField(
default=1, help_text="Maximum appointments for this slot"
),
),
(
"booked_appointments",
models.PositiveIntegerField(
default=0, help_text="Number of booked appointments"
),
),
(
"location",
models.CharField(help_text="Appointment location", max_length=200),
),
(
"room_number",
models.CharField(
blank=True, help_text="Room number", max_length=50, null=True
),
),
(
"specialty",
models.CharField(
help_text="Medical specialty for this slot", max_length=100
),
),
(
"appointment_types",
models.JSONField(
default=list,
help_text="Allowed appointment types for this slot",
),
),
(
"patient_restrictions",
models.JSONField(
blank=True,
default=dict,
help_text="Patient restrictions (age, gender, etc.)",
),
),
(
"insurance_restrictions",
models.JSONField(
blank=True, default=list, help_text="Accepted insurance types"
),
),
(
"supports_telemedicine",
models.BooleanField(
default=False,
help_text="Slot supports telemedicine appointments",
),
),
(
"telemedicine_only",
models.BooleanField(
default=False, help_text="Telemedicine only slot"
),
),
(
"is_active",
models.BooleanField(
default=True, help_text="Slot is active and bookable"
),
),
(
"is_blocked",
models.BooleanField(
default=False, help_text="Slot is temporarily blocked"
),
),
(
"block_reason",
models.CharField(
blank=True,
help_text="Reason for blocking slot",
max_length=200,
null=True,
),
),
(
"is_recurring",
models.BooleanField(
default=False, help_text="Slot is part of recurring pattern"
),
),
(
"recurrence_pattern",
models.JSONField(
blank=True,
default=dict,
help_text="Recurrence pattern configuration",
),
),
(
"recurrence_end_date",
models.DateField(
blank=True,
help_text="End date for recurring pattern",
null=True,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Slot Availability",
"verbose_name_plural": "Slot Availability",
"db_table": "appointments_slot_availability",
"ordering": ["date", "start_time"],
},
),
migrations.CreateModel(
name="TelemedicineSession",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"session_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique session identifier",
unique=True,
),
),
(
"platform",
models.CharField(
choices=[
("ZOOM", "Zoom"),
("TEAMS", "Microsoft Teams"),
("WEBEX", "Cisco Webex"),
("DOXY", "Doxy.me"),
("CUSTOM", "Custom Platform"),
("OTHER", "Other"),
],
help_text="Telemedicine platform",
max_length=50,
),
),
("meeting_url", models.URLField(help_text="Meeting URL")),
(
"meeting_id",
models.CharField(
help_text="Meeting ID or room number", max_length=100
),
),
(
"meeting_password",
models.CharField(
blank=True,
help_text="Meeting password",
max_length=100,
null=True,
),
),
(
"waiting_room_enabled",
models.BooleanField(default=True, help_text="Waiting room enabled"),
),
(
"recording_enabled",
models.BooleanField(
default=False, help_text="Session recording enabled"
),
),
(
"recording_consent",
models.BooleanField(
default=False, help_text="Patient consent for recording"
),
),
(
"encryption_enabled",
models.BooleanField(
default=True, help_text="End-to-end encryption enabled"
),
),
(
"password_required",
models.BooleanField(
default=True, help_text="Password required to join"
),
),
(
"status",
models.CharField(
choices=[
("SCHEDULED", "Scheduled"),
("READY", "Ready to Start"),
("IN_PROGRESS", "In Progress"),
("COMPLETED", "Completed"),
("CANCELLED", "Cancelled"),
("FAILED", "Failed"),
],
default="SCHEDULED",
help_text="Session status",
max_length=20,
),
),
(
"scheduled_start",
models.DateTimeField(help_text="Scheduled start time"),
),
("scheduled_end", models.DateTimeField(help_text="Scheduled end time")),
(
"actual_start",
models.DateTimeField(
blank=True, help_text="Actual start time", null=True
),
),
(
"actual_end",
models.DateTimeField(
blank=True, help_text="Actual end time", null=True
),
),
(
"provider_joined_at",
models.DateTimeField(
blank=True, help_text="Provider join time", null=True
),
),
(
"patient_joined_at",
models.DateTimeField(
blank=True, help_text="Patient join time", null=True
),
),
(
"connection_quality",
models.CharField(
blank=True,
choices=[
("EXCELLENT", "Excellent"),
("GOOD", "Good"),
("FAIR", "Fair"),
("POOR", "Poor"),
],
help_text="Connection quality",
max_length=20,
null=True,
),
),
(
"technical_issues",
models.TextField(
blank=True, help_text="Technical issues encountered", null=True
),
),
(
"recording_url",
models.URLField(blank=True, help_text="Recording URL", null=True),
),
(
"recording_duration_minutes",
models.PositiveIntegerField(
blank=True, help_text="Recording duration in minutes", null=True
),
),
(
"session_notes",
models.TextField(blank=True, help_text="Session notes", null=True),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Telemedicine Session",
"verbose_name_plural": "Telemedicine Sessions",
"db_table": "appointments_telemedicine_session",
"ordering": ["-scheduled_start"],
},
),
migrations.CreateModel(
name="WaitingQueue",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"queue_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique queue identifier",
unique=True,
),
),
("name", models.CharField(help_text="Queue name", max_length=200)),
(
"description",
models.TextField(
blank=True, help_text="Queue description", null=True
),
),
(
"queue_type",
models.CharField(
choices=[
("PROVIDER", "Provider Queue"),
("SPECIALTY", "Specialty Queue"),
("LOCATION", "Location Queue"),
("PROCEDURE", "Procedure Queue"),
("EMERGENCY", "Emergency Queue"),
],
help_text="Type of queue",
max_length=20,
),
),
(
"specialty",
models.CharField(
blank=True,
help_text="Medical specialty",
max_length=100,
null=True,
),
),
(
"location",
models.CharField(
blank=True,
help_text="Queue location",
max_length=200,
null=True,
),
),
(
"max_queue_size",
models.PositiveIntegerField(
default=50, help_text="Maximum queue size"
),
),
(
"average_service_time_minutes",
models.PositiveIntegerField(
default=30, help_text="Average service time in minutes"
),
),
(
"priority_weights",
models.JSONField(
default=dict, help_text="Priority weights for queue ordering"
),
),
(
"is_active",
models.BooleanField(default=True, help_text="Queue is active"),
),
(
"is_accepting_patients",
models.BooleanField(
default=True, help_text="Queue is accepting new patients"
),
),
(
"operating_hours",
models.JSONField(
default=dict, help_text="Queue operating hours by day"
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Waiting Queue",
"verbose_name_plural": "Waiting Queues",
"db_table": "appointments_waiting_queue",
"ordering": ["name"],
},
),
migrations.CreateModel(
name="AppointmentRequest",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"request_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique appointment request identifier",
unique=True,
),
),
(
"appointment_type",
models.CharField(
choices=[
("CONSULTATION", "Consultation"),
("FOLLOW_UP", "Follow-up"),
("PROCEDURE", "Procedure"),
("SURGERY", "Surgery"),
("DIAGNOSTIC", "Diagnostic"),
("THERAPY", "Therapy"),
("VACCINATION", "Vaccination"),
("SCREENING", "Screening"),
("EMERGENCY", "Emergency"),
("TELEMEDICINE", "Telemedicine"),
("OTHER", "Other"),
],
help_text="Type of appointment",
max_length=50,
),
),
(
"specialty",
models.CharField(
choices=[
("FAMILY_MEDICINE", "Family Medicine"),
("INTERNAL_MEDICINE", "Internal Medicine"),
("PEDIATRICS", "Pediatrics"),
("CARDIOLOGY", "Cardiology"),
("DERMATOLOGY", "Dermatology"),
("ENDOCRINOLOGY", "Endocrinology"),
("GASTROENTEROLOGY", "Gastroenterology"),
("NEUROLOGY", "Neurology"),
("ONCOLOGY", "Oncology"),
("ORTHOPEDICS", "Orthopedics"),
("PSYCHIATRY", "Psychiatry"),
("RADIOLOGY", "Radiology"),
("SURGERY", "Surgery"),
("UROLOGY", "Urology"),
("GYNECOLOGY", "Gynecology"),
("OPHTHALMOLOGY", "Ophthalmology"),
("ENT", "Ear, Nose & Throat"),
("EMERGENCY", "Emergency Medicine"),
("OTHER", "Other"),
],
help_text="Medical specialty",
max_length=100,
),
),
(
"preferred_date",
models.DateField(help_text="Patient preferred appointment date"),
),
(
"preferred_time",
models.TimeField(
blank=True,
help_text="Patient preferred appointment time",
null=True,
),
),
(
"duration_minutes",
models.PositiveIntegerField(
default=30,
help_text="Appointment duration in minutes",
validators=[
django.core.validators.MinValueValidator(15),
django.core.validators.MaxValueValidator(480),
],
),
),
(
"flexible_scheduling",
models.BooleanField(
default=True, help_text="Patient accepts alternative times"
),
),
(
"earliest_acceptable_date",
models.DateField(
blank=True,
help_text="Earliest acceptable appointment date",
null=True,
),
),
(
"latest_acceptable_date",
models.DateField(
blank=True,
help_text="Latest acceptable appointment date",
null=True,
),
),
(
"acceptable_times",
models.JSONField(
blank=True,
default=list,
help_text="Acceptable time slots (JSON array)",
),
),
(
"priority",
models.CharField(
choices=[
("ROUTINE", "Routine"),
("URGENT", "Urgent"),
("STAT", "STAT"),
("EMERGENCY", "Emergency"),
],
default="ROUTINE",
help_text="Appointment priority",
max_length=20,
),
),
(
"urgency_score",
models.PositiveIntegerField(
default=1,
help_text="Urgency score (1-10, 10 being most urgent)",
validators=[
django.core.validators.MinValueValidator(1),
django.core.validators.MaxValueValidator(10),
],
),
),
(
"chief_complaint",
models.TextField(
help_text="Patient chief complaint or reason for visit"
),
),
(
"clinical_notes",
models.TextField(
blank=True, help_text="Additional clinical notes", null=True
),
),
(
"referring_provider",
models.CharField(
blank=True,
help_text="Referring provider name",
max_length=200,
null=True,
),
),
(
"insurance_verified",
models.BooleanField(
default=False, help_text="Insurance coverage verified"
),
),
(
"authorization_required",
models.BooleanField(
default=False, help_text="Prior authorization required"
),
),
(
"authorization_number",
models.CharField(
blank=True,
help_text="Authorization number",
max_length=100,
null=True,
),
),
(
"status",
models.CharField(
choices=[
("PENDING", "Pending"),
("SCHEDULED", "Scheduled"),
("CONFIRMED", "Confirmed"),
("CHECKED_IN", "Checked In"),
("IN_PROGRESS", "In Progress"),
("COMPLETED", "Completed"),
("CANCELLED", "Cancelled"),
("NO_SHOW", "No Show"),
("RESCHEDULED", "Rescheduled"),
],
default="PENDING",
help_text="Appointment status",
max_length=20,
),
),
(
"scheduled_datetime",
models.DateTimeField(
blank=True,
help_text="Scheduled appointment date and time",
null=True,
),
),
(
"scheduled_end_datetime",
models.DateTimeField(
blank=True,
help_text="Scheduled appointment end time",
null=True,
),
),
(
"location",
models.CharField(
blank=True,
help_text="Appointment location",
max_length=200,
null=True,
),
),
(
"room_number",
models.CharField(
blank=True, help_text="Room number", max_length=50, null=True
),
),
(
"is_telemedicine",
models.BooleanField(
default=False, help_text="Telemedicine appointment"
),
),
(
"telemedicine_platform",
models.CharField(
blank=True,
choices=[
("ZOOM", "Zoom"),
("TEAMS", "Microsoft Teams"),
("WEBEX", "Cisco Webex"),
("DOXY", "Doxy.me"),
("CUSTOM", "Custom Platform"),
("OTHER", "Other"),
],
help_text="Telemedicine platform",
max_length=50,
null=True,
),
),
(
"meeting_url",
models.URLField(
blank=True, help_text="Telemedicine meeting URL", null=True
),
),
(
"meeting_id",
models.CharField(
blank=True,
help_text="Meeting ID or room number",
max_length=100,
null=True,
),
),
(
"meeting_password",
models.CharField(
blank=True,
help_text="Meeting password",
max_length=100,
null=True,
),
),
(
"checked_in_at",
models.DateTimeField(
blank=True, help_text="Patient check-in time", null=True
),
),
(
"completed_at",
models.DateTimeField(
blank=True, help_text="Appointment completion time", null=True
),
),
(
"actual_duration_minutes",
models.PositiveIntegerField(
blank=True, help_text="Actual appointment duration", null=True
),
),
(
"cancelled_at",
models.DateTimeField(
blank=True, help_text="Cancellation timestamp", null=True
),
),
(
"cancellation_reason",
models.TextField(
blank=True, help_text="Reason for cancellation", null=True
),
),
(
"reminder_preferences",
models.JSONField(
blank=True,
default=dict,
help_text="Reminder preferences (email, SMS, phone)",
),
),
(
"special_requirements",
models.TextField(
blank=True,
help_text="Special requirements or accommodations",
null=True,
),
),
(
"interpreter_needed",
models.BooleanField(
default=False, help_text="Interpreter services needed"
),
),
(
"interpreter_language",
models.CharField(
blank=True,
help_text="Required interpreter language",
max_length=50,
null=True,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"cancelled_by",
models.ForeignKey(
blank=True,
help_text="User who cancelled appointment",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="cancelled_appointments",
to=settings.AUTH_USER_MODEL,
),
),
(
"checked_in_by",
models.ForeignKey(
blank=True,
help_text="Staff member who checked in patient",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="checked_in_appointments",
to=settings.AUTH_USER_MODEL,
),
),
(
"created_by",
models.ForeignKey(
blank=True,
help_text="User who created the appointment request",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_appointments",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Appointment Request",
"verbose_name_plural": "Appointment Requests",
"db_table": "appointments_appointment_request",
"ordering": ["-created_at"],
},
),
]