Marwan Alwali 263292f6be update
2025-11-04 00:50:06 +03:00

1478 lines
55 KiB
Python

# Generated by Django 5.2.7 on 2025-10-06 21:15
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 = [
("core", "0001_initial"),
("emr", "0001_initial"),
("inpatients", "0001_initial"),
("patients", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="OperatingRoom",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"room_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique room identifier",
unique=True,
),
),
(
"room_number",
models.CharField(help_text="Operating room number", max_length=20),
),
(
"room_name",
models.CharField(help_text="Operating room name", max_length=100),
),
(
"room_type",
models.CharField(
choices=[
("GENERAL", "General Surgery"),
("CARDIAC", "Cardiac Surgery"),
("NEURO", "Neurosurgery"),
("ORTHOPEDIC", "Orthopedic Surgery"),
("TRAUMA", "Trauma Surgery"),
("PEDIATRIC", "Pediatric Surgery"),
("OBSTETRIC", "Obstetric Surgery"),
("OPHTHALMOLOGY", "Ophthalmology"),
("ENT", "ENT Surgery"),
("UROLOGY", "Urology"),
("PLASTIC", "Plastic Surgery"),
("VASCULAR", "Vascular Surgery"),
("THORACIC", "Thoracic Surgery"),
("TRANSPLANT", "Transplant Surgery"),
("ROBOTIC", "Robotic Surgery"),
("HYBRID", "Hybrid OR"),
("AMBULATORY", "Ambulatory Surgery"),
("EMERGENCY", "Emergency Surgery"),
],
help_text="Operating room type",
max_length=30,
),
),
(
"status",
models.CharField(
choices=[
("AVAILABLE", "Available"),
("OCCUPIED", "Occupied"),
("CLEANING", "Cleaning"),
("MAINTENANCE", "Maintenance"),
("SETUP", "Setup"),
("TURNOVER", "Turnover"),
("OUT_OF_ORDER", "Out of Order"),
("CLOSED", "Closed"),
],
default="AVAILABLE",
help_text="Current room status",
max_length=20,
),
),
("floor_number", models.PositiveIntegerField(help_text="Floor number")),
(
"room_size",
models.FloatField(
blank=True, help_text="Room size in square meters", null=True
),
),
(
"ceiling_height",
models.FloatField(
blank=True, help_text="Ceiling height in meters", null=True
),
),
(
"temperature_min",
models.FloatField(
default=18.0, help_text="Minimum temperature in Celsius"
),
),
(
"temperature_max",
models.FloatField(
default=26.0, help_text="Maximum temperature in Celsius"
),
),
(
"humidity_min",
models.FloatField(
default=30.0, help_text="Minimum humidity percentage"
),
),
(
"humidity_max",
models.FloatField(
default=60.0, help_text="Maximum humidity percentage"
),
),
(
"air_changes_per_hour",
models.PositiveIntegerField(
default=20, help_text="Air changes per hour"
),
),
(
"positive_pressure",
models.BooleanField(
default=True, help_text="Positive pressure room"
),
),
(
"equipment_list",
models.JSONField(
default=list, help_text="Available equipment list"
),
),
(
"special_features",
models.JSONField(
default=list, help_text="Special features and capabilities"
),
),
(
"has_c_arm",
models.BooleanField(
default=False, help_text="C-arm fluoroscopy available"
),
),
(
"has_ct",
models.BooleanField(
default=False, help_text="Intraoperative CT available"
),
),
(
"has_mri",
models.BooleanField(
default=False, help_text="Intraoperative MRI available"
),
),
(
"has_ultrasound",
models.BooleanField(
default=False, help_text="Ultrasound available"
),
),
(
"has_neuromonitoring",
models.BooleanField(
default=False, help_text="Neuromonitoring available"
),
),
(
"supports_robotic",
models.BooleanField(
default=False, help_text="Robotic surgery capable"
),
),
(
"supports_laparoscopic",
models.BooleanField(
default=True, help_text="Laparoscopic surgery capable"
),
),
(
"supports_microscopy",
models.BooleanField(
default=False, help_text="Surgical microscopy available"
),
),
(
"supports_laser",
models.BooleanField(
default=False, help_text="Laser surgery capable"
),
),
(
"max_case_duration",
models.PositiveIntegerField(
default=480, help_text="Maximum case duration in minutes"
),
),
(
"turnover_time",
models.PositiveIntegerField(
default=30, help_text="Standard turnover time in minutes"
),
),
(
"cleaning_time",
models.PositiveIntegerField(
default=45, help_text="Deep cleaning time in minutes"
),
),
(
"required_nurses",
models.PositiveIntegerField(
default=2, help_text="Required number of nurses"
),
),
(
"required_techs",
models.PositiveIntegerField(
default=1, help_text="Required number of technicians"
),
),
(
"is_active",
models.BooleanField(
default=True,
help_text="Room is active and available for scheduling",
),
),
(
"accepts_emergency",
models.BooleanField(
default=True, help_text="Accepts emergency cases"
),
),
(
"building",
models.CharField(
blank=True,
help_text="Building name or identifier",
max_length=50,
null=True,
),
),
(
"wing",
models.CharField(
blank=True,
help_text="Wing or section",
max_length=50,
null=True,
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"created_by",
models.ForeignKey(
blank=True,
help_text="User who created the room",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_operating_rooms",
to=settings.AUTH_USER_MODEL,
),
),
(
"tenant",
models.ForeignKey(
help_text="Organization tenant",
on_delete=django.db.models.deletion.CASCADE,
related_name="operating_rooms",
to="core.tenant",
),
),
],
options={
"verbose_name": "Operating Room",
"verbose_name_plural": "Operating Rooms",
"db_table": "operating_theatre_operating_room",
"ordering": ["room_number"],
},
),
migrations.CreateModel(
name="ORBlock",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"block_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique block identifier",
unique=True,
),
),
("date", models.DateField(help_text="Block date")),
("start_time", models.TimeField(help_text="Block start time")),
("end_time", models.TimeField(help_text="Block end time")),
(
"block_type",
models.CharField(
choices=[
("SCHEDULED", "Scheduled Block"),
("EMERGENCY", "Emergency Block"),
("MAINTENANCE", "Maintenance Block"),
("CLEANING", "Deep Cleaning"),
("RESERVED", "Reserved"),
("BLOCKED", "Blocked"),
],
default="SCHEDULED",
help_text="Block type",
max_length=20,
),
),
(
"service",
models.CharField(
choices=[
("GENERAL", "General Surgery"),
("CARDIAC", "Cardiac Surgery"),
("NEURO", "Neurosurgery"),
("ORTHOPEDIC", "Orthopedic Surgery"),
("TRAUMA", "Trauma Surgery"),
("PEDIATRIC", "Pediatric Surgery"),
("OBSTETRIC", "Obstetric Surgery"),
("OPHTHALMOLOGY", "Ophthalmology"),
("ENT", "ENT Surgery"),
("UROLOGY", "Urology"),
("PLASTIC", "Plastic Surgery"),
("VASCULAR", "Vascular Surgery"),
("THORACIC", "Thoracic Surgery"),
("TRANSPLANT", "Transplant Surgery"),
],
help_text="Surgical service",
max_length=30,
),
),
(
"status",
models.CharField(
choices=[
("SCHEDULED", "Scheduled"),
("ACTIVE", "Active"),
("COMPLETED", "Completed"),
("CANCELLED", "Cancelled"),
("DELAYED", "Delayed"),
],
default="SCHEDULED",
help_text="Block status",
max_length=20,
),
),
(
"allocated_minutes",
models.PositiveIntegerField(help_text="Total allocated minutes"),
),
(
"used_minutes",
models.PositiveIntegerField(
default=0, help_text="Minutes actually used"
),
),
(
"special_equipment",
models.JSONField(
default=list, help_text="Special equipment requirements"
),
),
(
"special_setup",
models.TextField(
blank=True, help_text="Special setup requirements", null=True
),
),
(
"notes",
models.TextField(
blank=True, help_text="Block notes and comments", null=True
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"assistant_surgeons",
models.ManyToManyField(
blank=True,
help_text="Assistant surgeons",
related_name="assistant_or_blocks",
to=settings.AUTH_USER_MODEL,
),
),
(
"created_by",
models.ForeignKey(
blank=True,
help_text="User who created the block",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_or_blocks",
to=settings.AUTH_USER_MODEL,
),
),
(
"operating_room",
models.ForeignKey(
help_text="Operating room",
on_delete=django.db.models.deletion.CASCADE,
related_name="or_blocks",
to="operating_theatre.operatingroom",
),
),
(
"primary_surgeon",
models.ForeignKey(
help_text="Primary surgeon assigned to block",
on_delete=django.db.models.deletion.CASCADE,
related_name="primary_or_blocks",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "OR Block",
"verbose_name_plural": "OR Blocks",
"db_table": "operating_theatre_or_block",
"ordering": ["date", "start_time"],
},
),
migrations.CreateModel(
name="SurgicalCase",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"case_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique case identifier",
unique=True,
),
),
(
"case_number",
models.CharField(
help_text="Surgical case number", max_length=20, unique=True
),
),
(
"primary_procedure",
models.CharField(
help_text="Primary surgical procedure", max_length=200
),
),
(
"secondary_procedures",
models.JSONField(default=list, help_text="Secondary procedures"),
),
(
"procedure_codes",
models.JSONField(default=list, help_text="CPT procedure codes"),
),
(
"case_type",
models.CharField(
choices=[
("ELECTIVE", "Elective"),
("URGENT", "Urgent"),
("EMERGENCY", "Emergency"),
("TRAUMA", "Trauma"),
("TRANSPLANT", "Transplant"),
],
default="ELECTIVE",
help_text="Case type",
max_length=20,
),
),
(
"approach",
models.CharField(
choices=[
("OPEN", "Open"),
("LAPAROSCOPIC", "Laparoscopic"),
("ROBOTIC", "Robotic"),
("ENDOSCOPIC", "Endoscopic"),
("PERCUTANEOUS", "Percutaneous"),
("HYBRID", "Hybrid"),
],
help_text="Surgical approach",
max_length=20,
),
),
(
"anesthesia_type",
models.CharField(
choices=[
("GENERAL", "General"),
("REGIONAL", "Regional"),
("LOCAL", "Local"),
("SEDATION", "Sedation"),
("SPINAL", "Spinal"),
("EPIDURAL", "Epidural"),
("COMBINED", "Combined"),
],
help_text="Anesthesia type",
max_length=20,
),
),
(
"scheduled_start",
models.DateTimeField(help_text="Scheduled start time"),
),
(
"estimated_duration",
models.PositiveIntegerField(
help_text="Estimated duration in minutes"
),
),
(
"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
),
),
(
"status",
models.CharField(
choices=[
("SCHEDULED", "Scheduled"),
("CONFIRMED", "Confirmed"),
("PREP", "Pre-operative Prep"),
("DELAYED", "Delayed"),
("IN_PROGRESS", "In Progress"),
("COMPLETED", "Completed"),
("CANCELLED", "Cancelled"),
("POSTPONED", "Postponed"),
],
default="SCHEDULED",
help_text="Case status",
max_length=20,
),
),
(
"diagnosis",
models.CharField(help_text="Primary diagnosis", max_length=200),
),
(
"diagnosis_codes",
models.JSONField(default=list, help_text="ICD-10 diagnosis codes"),
),
(
"clinical_notes",
models.TextField(
blank=True, help_text="Clinical notes and history", null=True
),
),
(
"special_equipment",
models.JSONField(
default=list, help_text="Special equipment requirements"
),
),
(
"blood_products",
models.JSONField(
default=list, help_text="Blood product requirements"
),
),
(
"implants",
models.JSONField(default=list, help_text="Implant requirements"),
),
(
"patient_position",
models.CharField(
blank=True,
choices=[
("SUPINE", "Supine"),
("PRONE", "Prone"),
("LATERAL", "Lateral"),
("LITHOTOMY", "Lithotomy"),
("TRENDELENBURG", "Trendelenburg"),
("REVERSE_TREND", "Reverse Trendelenburg"),
("SITTING", "Sitting"),
("JACKKNIFE", "Jackknife"),
],
help_text="Patient positioning",
max_length=20,
null=True,
),
),
(
"complications",
models.JSONField(
default=list, help_text="Intraoperative complications"
),
),
(
"estimated_blood_loss",
models.PositiveIntegerField(
blank=True, help_text="Estimated blood loss in mL", null=True
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"admission",
models.ForeignKey(
blank=True,
help_text="Related admission",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="surgical_cases",
to="inpatients.admission",
),
),
(
"anesthesiologist",
models.ForeignKey(
blank=True,
help_text="Anesthesiologist",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="anesthesia_cases",
to=settings.AUTH_USER_MODEL,
),
),
(
"assistant_surgeons",
models.ManyToManyField(
blank=True,
help_text="Assistant surgeons",
related_name="assistant_surgical_cases",
to=settings.AUTH_USER_MODEL,
),
),
(
"circulating_nurse",
models.ForeignKey(
blank=True,
help_text="Circulating nurse",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="circulating_cases",
to=settings.AUTH_USER_MODEL,
),
),
(
"created_by",
models.ForeignKey(
blank=True,
help_text="User who created the case",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_surgical_cases",
to=settings.AUTH_USER_MODEL,
),
),
(
"encounter",
models.ForeignKey(
blank=True,
help_text="Related encounter",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="surgical_cases",
to="emr.encounter",
),
),
(
"or_block",
models.ForeignKey(
help_text="OR block assignment",
on_delete=django.db.models.deletion.CASCADE,
related_name="surgical_cases",
to="operating_theatre.orblock",
),
),
(
"patient",
models.ForeignKey(
help_text="Patient",
on_delete=django.db.models.deletion.CASCADE,
related_name="surgical_cases",
to="patients.patientprofile",
),
),
(
"primary_surgeon",
models.ForeignKey(
help_text="Primary surgeon",
on_delete=django.db.models.deletion.CASCADE,
related_name="primary_surgical_cases",
to=settings.AUTH_USER_MODEL,
),
),
(
"scrub_nurse",
models.ForeignKey(
blank=True,
help_text="Scrub nurse",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="scrub_cases",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"verbose_name": "Surgical Case",
"verbose_name_plural": "Surgical Cases",
"db_table": "operating_theatre_surgical_case",
"ordering": ["scheduled_start"],
},
),
migrations.CreateModel(
name="EquipmentUsage",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"usage_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique usage identifier",
unique=True,
),
),
(
"equipment_name",
models.CharField(help_text="Equipment name", max_length=100),
),
(
"equipment_type",
models.CharField(
choices=[
("SURGICAL_INSTRUMENT", "Surgical Instrument"),
("MONITORING_DEVICE", "Monitoring Device"),
("ANESTHESIA_MACHINE", "Anesthesia Machine"),
("VENTILATOR", "Ventilator"),
("ELECTROCAUTERY", "Electrocautery"),
("LASER", "Laser"),
("MICROSCOPE", "Microscope"),
("C_ARM", "C-Arm"),
("ULTRASOUND", "Ultrasound"),
("ROBOT", "Surgical Robot"),
("IMPLANT", "Implant"),
("DISPOSABLE", "Disposable"),
("OTHER", "Other"),
],
help_text="Equipment type",
max_length=50,
),
),
(
"manufacturer",
models.CharField(
blank=True,
help_text="Equipment manufacturer",
max_length=100,
null=True,
),
),
(
"model",
models.CharField(
blank=True,
help_text="Equipment model",
max_length=100,
null=True,
),
),
(
"serial_number",
models.CharField(
blank=True,
help_text="Equipment serial number",
max_length=100,
null=True,
),
),
(
"quantity_used",
models.PositiveIntegerField(default=1, help_text="Quantity used"),
),
(
"unit_of_measure",
models.CharField(
choices=[
("EACH", "Each"),
("SET", "Set"),
("PACK", "Pack"),
("BOX", "Box"),
("UNIT", "Unit"),
("PIECE", "Piece"),
],
default="EACH",
help_text="Unit of measure",
max_length=20,
),
),
(
"start_time",
models.DateTimeField(
blank=True, help_text="Equipment usage start time", null=True
),
),
(
"end_time",
models.DateTimeField(
blank=True, help_text="Equipment usage end time", null=True
),
),
(
"unit_cost",
models.DecimalField(
blank=True,
decimal_places=2,
help_text="Unit cost",
max_digits=10,
null=True,
),
),
(
"total_cost",
models.DecimalField(
blank=True,
decimal_places=2,
help_text="Total cost",
max_digits=10,
null=True,
),
),
(
"lot_number",
models.CharField(
blank=True,
help_text="Lot or batch number",
max_length=50,
null=True,
),
),
(
"expiration_date",
models.DateField(
blank=True, help_text="Expiration date", null=True
),
),
(
"sterilization_date",
models.DateField(
blank=True, help_text="Sterilization date", null=True
),
),
(
"notes",
models.TextField(
blank=True, help_text="Usage notes and comments", null=True
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"recorded_by",
models.ForeignKey(
blank=True,
help_text="Staff member who recorded usage",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="recorded_equipment_usage",
to=settings.AUTH_USER_MODEL,
),
),
(
"surgical_case",
models.ForeignKey(
help_text="Related surgical case",
on_delete=django.db.models.deletion.CASCADE,
related_name="equipment_usage",
to="operating_theatre.surgicalcase",
),
),
],
options={
"verbose_name": "Equipment Usage",
"verbose_name_plural": "Equipment Usage",
"db_table": "operating_theatre_equipment_usage",
"ordering": ["-created_at"],
},
),
migrations.CreateModel(
name="SurgicalNoteTemplate",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"template_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique template identifier",
unique=True,
),
),
("name", models.CharField(help_text="Template name", max_length=100)),
(
"description",
models.TextField(
blank=True, help_text="Template description", null=True
),
),
(
"procedure_type",
models.CharField(
blank=True,
help_text="Applicable procedure type",
max_length=100,
null=True,
),
),
(
"specialty",
models.CharField(
choices=[
("ALL", "All Specialties"),
("GENERAL", "General Surgery"),
("CARDIAC", "Cardiac Surgery"),
("NEURO", "Neurosurgery"),
("ORTHOPEDIC", "Orthopedic Surgery"),
("TRAUMA", "Trauma Surgery"),
("PEDIATRIC", "Pediatric Surgery"),
("OBSTETRIC", "Obstetric Surgery"),
("OPHTHALMOLOGY", "Ophthalmology"),
("ENT", "ENT Surgery"),
("UROLOGY", "Urology"),
("PLASTIC", "Plastic Surgery"),
("VASCULAR", "Vascular Surgery"),
("THORACIC", "Thoracic Surgery"),
("TRANSPLANT", "Transplant Surgery"),
],
default="ALL",
help_text="Applicable specialty",
max_length=30,
),
),
(
"preoperative_diagnosis_template",
models.TextField(
blank=True,
help_text="Preoperative diagnosis template",
null=True,
),
),
(
"planned_procedure_template",
models.TextField(
blank=True, help_text="Planned procedure template", null=True
),
),
(
"indication_template",
models.TextField(
blank=True, help_text="Indication template", null=True
),
),
(
"procedure_performed_template",
models.TextField(
blank=True, help_text="Procedure performed template", null=True
),
),
(
"surgical_approach_template",
models.TextField(
blank=True, help_text="Surgical approach template", null=True
),
),
(
"findings_template",
models.TextField(
blank=True, help_text="Findings template", null=True
),
),
(
"technique_template",
models.TextField(
blank=True, help_text="Technique template", null=True
),
),
(
"postoperative_diagnosis_template",
models.TextField(
blank=True,
help_text="Postoperative diagnosis template",
null=True,
),
),
(
"complications_template",
models.TextField(
blank=True, help_text="Complications template", null=True
),
),
(
"specimens_template",
models.TextField(
blank=True, help_text="Specimens template", null=True
),
),
(
"implants_template",
models.TextField(
blank=True, help_text="Implants template", null=True
),
),
(
"closure_template",
models.TextField(
blank=True, help_text="Closure template", null=True
),
),
(
"postop_instructions_template",
models.TextField(
blank=True,
help_text="Postoperative instructions template",
null=True,
),
),
(
"is_active",
models.BooleanField(default=True, help_text="Template is active"),
),
(
"is_default",
models.BooleanField(
default=False, help_text="Default template for specialty"
),
),
(
"usage_count",
models.PositiveIntegerField(
default=0, help_text="Number of times template has been used"
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"created_by",
models.ForeignKey(
blank=True,
help_text="User who created the template",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="created_surgical_note_templates",
to=settings.AUTH_USER_MODEL,
),
),
(
"tenant",
models.ForeignKey(
help_text="Organization tenant",
on_delete=django.db.models.deletion.CASCADE,
related_name="surgical_note_templates",
to="core.tenant",
),
),
],
options={
"verbose_name": "Surgical Note Template",
"verbose_name_plural": "Surgical Note Templates",
"db_table": "operating_theatre_surgical_note_template",
"ordering": ["specialty", "name"],
},
),
migrations.CreateModel(
name="SurgicalNote",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"note_id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
help_text="Unique note identifier",
unique=True,
),
),
(
"preoperative_diagnosis",
models.TextField(help_text="Preoperative diagnosis"),
),
(
"planned_procedure",
models.TextField(help_text="Planned surgical procedure"),
),
("indication", models.TextField(help_text="Indication for surgery")),
(
"procedure_performed",
models.TextField(help_text="Actual procedure performed"),
),
(
"surgical_approach",
models.TextField(help_text="Surgical approach and technique"),
),
("findings", models.TextField(help_text="Intraoperative findings")),
(
"technique",
models.TextField(help_text="Detailed surgical technique"),
),
(
"postoperative_diagnosis",
models.TextField(help_text="Postoperative diagnosis"),
),
(
"condition",
models.CharField(
choices=[
("STABLE", "Stable"),
("CRITICAL", "Critical"),
("GUARDED", "Guarded"),
("FAIR", "Fair"),
("GOOD", "Good"),
("EXCELLENT", "Excellent"),
],
help_text="Patient condition post-surgery",
max_length=20,
),
),
(
"disposition",
models.CharField(
choices=[
("RECOVERY", "Recovery Room"),
("ICU", "Intensive Care Unit"),
("WARD", "Ward"),
("DISCHARGE", "Discharge"),
("MORGUE", "Morgue"),
],
help_text="Patient disposition",
max_length=30,
),
),
(
"complications",
models.TextField(
blank=True, help_text="Intraoperative complications", null=True
),
),
(
"estimated_blood_loss",
models.PositiveIntegerField(
blank=True, help_text="Estimated blood loss in mL", null=True
),
),
(
"blood_transfusion",
models.TextField(
blank=True, help_text="Blood transfusion details", null=True
),
),
(
"specimens",
models.TextField(
blank=True, help_text="Specimens sent to pathology", null=True
),
),
(
"implants",
models.TextField(
blank=True, help_text="Implants and devices used", null=True
),
),
(
"drains",
models.TextField(
blank=True, help_text="Drains and tubes placed", null=True
),
),
(
"closure",
models.TextField(
blank=True, help_text="Wound closure technique", null=True
),
),
(
"postop_instructions",
models.TextField(
blank=True, help_text="Postoperative instructions", null=True
),
),
(
"follow_up",
models.TextField(
blank=True, help_text="Follow-up instructions", null=True
),
),
(
"status",
models.CharField(
choices=[
("DRAFT", "Draft"),
("COMPLETED", "Completed"),
("SIGNED", "Signed"),
("AMENDED", "Amended"),
],
default="DRAFT",
help_text="Note status",
max_length=20,
),
),
(
"signed_datetime",
models.DateTimeField(
blank=True, help_text="Date and time note was signed", null=True
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"surgeon",
models.ForeignKey(
help_text="Operating surgeon",
on_delete=django.db.models.deletion.CASCADE,
related_name="surgeon_surgical_notes",
to=settings.AUTH_USER_MODEL,
),
),
(
"surgical_case",
models.OneToOneField(
help_text="Related surgical case",
on_delete=django.db.models.deletion.CASCADE,
related_name="surgical_notes",
to="operating_theatre.surgicalcase",
),
),
(
"template_used",
models.ForeignKey(
blank=True,
help_text="Template used for note",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="surgical_notes",
to="operating_theatre.surgicalnotetemplate",
),
),
],
options={
"verbose_name": "Surgical Note",
"verbose_name_plural": "Surgical Notes",
"db_table": "operating_theatre_surgical_note",
"ordering": ["-created_at"],
},
),
migrations.AddIndex(
model_name="operatingroom",
index=models.Index(
fields=["tenant", "is_active"], name="operating_t_tenant__9540d2_idx"
),
),
migrations.AddIndex(
model_name="operatingroom",
index=models.Index(
fields=["room_type", "status"], name="operating_t_room_ty_30b0fb_idx"
),
),
migrations.AddIndex(
model_name="operatingroom",
index=models.Index(
fields=["floor_number"], name="operating_t_floor_n_c78887_idx"
),
),
migrations.AddIndex(
model_name="operatingroom",
index=models.Index(
fields=["accepts_emergency"], name="operating_t_accepts_ae727d_idx"
),
),
migrations.AlterUniqueTogether(
name="operatingroom",
unique_together={("tenant", "room_number")},
),
migrations.AddIndex(
model_name="orblock",
index=models.Index(
fields=["operating_room", "date"], name="operating_t_operati_da9d71_idx"
),
),
migrations.AddIndex(
model_name="orblock",
index=models.Index(
fields=["primary_surgeon", "date"],
name="operating_t_primary_09a931_idx",
),
),
migrations.AddIndex(
model_name="orblock",
index=models.Index(
fields=["service", "date"], name="operating_t_service_967798_idx"
),
),
migrations.AddIndex(
model_name="orblock",
index=models.Index(fields=["status"], name="operating_t_status_22bca2_idx"),
),
migrations.AddIndex(
model_name="surgicalcase",
index=models.Index(
fields=["or_block", "status"], name="operating_t_or_bloc_a6a886_idx"
),
),
migrations.AddIndex(
model_name="surgicalcase",
index=models.Index(
fields=["patient", "scheduled_start"],
name="operating_t_patient_6883ad_idx",
),
),
migrations.AddIndex(
model_name="surgicalcase",
index=models.Index(
fields=["primary_surgeon", "scheduled_start"],
name="operating_t_primary_f29519_idx",
),
),
migrations.AddIndex(
model_name="surgicalcase",
index=models.Index(
fields=["case_type", "status"], name="operating_t_case_ty_a2818b_idx"
),
),
migrations.AddIndex(
model_name="surgicalcase",
index=models.Index(
fields=["scheduled_start"], name="operating_t_schedul_f64a16_idx"
),
),
migrations.AddIndex(
model_name="surgicalcase",
index=models.Index(
fields=["case_number"], name="operating_t_case_nu_3ad6ad_idx"
),
),
migrations.AddIndex(
model_name="equipmentusage",
index=models.Index(
fields=["surgical_case"], name="operating_t_surgica_d7a286_idx"
),
),
migrations.AddIndex(
model_name="equipmentusage",
index=models.Index(
fields=["equipment_type"], name="operating_t_equipme_f8d073_idx"
),
),
migrations.AddIndex(
model_name="equipmentusage",
index=models.Index(
fields=["equipment_name"], name="operating_t_equipme_53875c_idx"
),
),
migrations.AddIndex(
model_name="equipmentusage",
index=models.Index(
fields=["recorded_by"], name="operating_t_recorde_6afb73_idx"
),
),
migrations.AddIndex(
model_name="surgicalnotetemplate",
index=models.Index(
fields=["tenant", "is_active"], name="operating_t_tenant__c9e347_idx"
),
),
migrations.AddIndex(
model_name="surgicalnotetemplate",
index=models.Index(
fields=["specialty"], name="operating_t_special_1bf3a9_idx"
),
),
migrations.AddIndex(
model_name="surgicalnotetemplate",
index=models.Index(
fields=["is_default"], name="operating_t_is_defa_101b13_idx"
),
),
migrations.AlterUniqueTogether(
name="surgicalnotetemplate",
unique_together={("tenant", "name")},
),
migrations.AddIndex(
model_name="surgicalnote",
index=models.Index(
fields=["surgical_case"], name="operating_t_surgica_888e50_idx"
),
),
migrations.AddIndex(
model_name="surgicalnote",
index=models.Index(
fields=["surgeon"], name="operating_t_surgeon_7abc83_idx"
),
),
migrations.AddIndex(
model_name="surgicalnote",
index=models.Index(fields=["status"], name="operating_t_status_9ec1e2_idx"),
),
migrations.AddIndex(
model_name="surgicalnote",
index=models.Index(
fields=["signed_datetime"], name="operating_t_signed__60df2f_idx"
),
),
]