root = Card([header, kpisRow, chartsRow, criticalSection, dischargeSection, orSection, suppliesSection, actionsRow], "card", "column", "l")
header = Card([titleBlock, datePicker], "clear", "row", "m", "center", "between")
titleBlock = Card([mainTitle, subtitle], "clear", "column", "xs")
mainTitle = Heading("Hospital Operations Command", "h2")
subtitle = TextContent("Real-time capacity, flow & safety snapshot", "small")
datePicker = DatePicker("view-date", "single", [], ["2024-01-15"])
kpisRow = Card([bedOccupancy, erWait, admissionsChart], "card", "row", "l", "stretch", "start", true)
bedOccupancy = Card([bedLabel, bedProgress], "sunk", "column", "s")
bedLabel = Heading("Bed Occupancy", "h4")
bedProgress = Progress(85, "340 of 400 beds occupied")
erWait = Card([erLabel, erCallout], "sunk", "column", "s")
erLabel = Heading("ER Wait Time", "h4")
erCallout = Callout("warning", "42 minutes", "Current average door-to-provider")
admissionsChart = Card([admLabel, admChart], "sunk", "column", "s")
admLabel = Heading("Admissions (14 days)", "h4")
admChart = AreaChart(admLabels, [admSeries], "natural", "Day", "Admissions")
admLabels = ["Jan 1", "Jan 2", "Jan 3", "Jan 4", "Jan 5", "Jan 6", "Jan 7", "Jan 8", "Jan 9", "Jan 10", "Jan 11", "Jan 12", "Jan 13", "Jan 14"]
admSeries = Series("Admissions", [28, 31, 25, 34, 29, 33, 30, 27, 35, 32, 28, 36, 31, 34])
chartsRow = Card([deptChart, staffTable], "card", "row", "l", "stretch", "start", true)
deptChart = Card([deptLabel, deptChartInner], "sunk", "column", "s")
deptLabel = Heading("Patients per Department", "h4")
deptChartInner = HorizontalBarChart(deptLabels, [deptSeries], "grouped", "Patients", "Department")
deptLabels = ["Emergency", "ICU", "Cardiology", "Orthopedics", "Oncology", "Pediatrics", "Surgery", "Neurology"]
deptSeries = Series("Current Census", [24, 18, 15, 12, 10, 8, 7, 6])
staffTable = Card([staffLabel, staffTableInner], "sunk", "column", "s")
staffLabel = Heading("Staff On Shift", "h4")
staffTableInner = Table([staffNameCol, staffRoleCol, staffShiftCol, staffStatusCol])
staffNameCol = Col("Name", ["Dr. Sarah Chen", "Dr. Marcus Webb", "RN Amanda Torres", "RN James Park", "RT Lisa Nguyen", "CNA Maria Santos", "PharmD Kevin Lee", "SW Rachel Kim"])
staffRoleCol = Col("Role", ["Attending EM", "Attending ICU", "Charge Nurse ER", "Charge Nurse ICU", "Respiratory Therapist", "Patient Care Tech", "Clinical Pharmacist", "Social Worker"])
staffShiftCol = Col("Shift", ["07:00-19:00", "07:00-19:00", "07:00-19:00", "19:00-07:00", "07:00-19:00", "19:00-07:00", "07:00-19:00", "09:00-17:00"])
staffStatusCol = Col("Status", ["Active", "Active", "Active", "On Break", "Active", "Active", "Active", "Available"])
criticalSection = Card([criticalLabel, criticalList], "card", "column", "m")
criticalLabel = Heading("Critical Patients Requiring Attention", "h3")
criticalList = ListBlock([crit1, crit2, crit3, crit4], "number")
crit1 = ListItem("Room 302 — STEMI", "Troponin 12.4, cath lab activated, ETA 8 min", [], "View")
crit2 = ListItem("Room 215 — Septic Shock", "Lactate 5.8, on norepi 0.15, central line placed", [], "View")
crit3 = ListItem("Room 418 — Status Asthmaticus", "pH 7.21, pCO2 68, BiPAP initiated, ICU consult", [], "View")
crit4 = ListItem("Room 109 — GI Bleed", "Hb 6.2, 2 units PRBC transfused, GI scope scheduled", [], "View")
dischargeSection = Card([dischargeLabel, dischargeList], "card", "column", "m")
dischargeLabel = Heading("Patients Ready for Discharge", "h3")
dischargeList = ListBlock([disc1, disc2, disc3, disc4, disc5], "number")
disc1 = ListItem("Room 304 — K. Johnson", "CHF exacerbation resolved, PO diuretics tolerated, home health arranged", [], "Discharge")
disc2 = ListItem("Room 221 — R. Patel", "Cellulitis improved, switch to PO antibiotics, follow-up scheduled", [], "Discharge")
disc3 = ListItem("Room 412 — M. Thompson", "Post-op day 3 lap chole, pain controlled, tolerating diet", [], "Discharge")
disc4 = ListItem("Room 105 — D. Williams", "Pneumonia clinically improved, CURB-65 0, oral abx prescribed", [], "Discharge")
disc5 = ListItem("Room 508 — S. Garcia", "Observation for syncope, workup negative, cardiology follow-up", [], "Discharge")
orSection = Card([orLabel, orTable], "card", "column", "m")
orLabel = Heading("Today's Operating Room Bookings", "h3")
orTable = Table([orTimeCol, orRoomCol, orProcedureCol, orSurgeonCol, orStatusCol])
orTimeCol = Col("Time", ["07:30-09:30", "08:00-10:00", "09:00-12:00", "10:30-12:30", "11:00-13:00", "13:00-15:00", "14:00-16:30", "15:30-17:30"])
orRoomCol = Col("Room", ["OR 1", "OR 2", "OR 3", "OR 1", "OR 4", "OR 2", "OR 3", "OR 1"])
orProcedureCol = Col("Procedure", ["Lap Cholecystectomy", "Total Knee Arthroplasty", "CABG x3", "Lap Appendectomy", "THA Revision", "ACL Reconstruction", "Craniotomy Tumor", "Lap Hernia Repair"])
orSurgeonCol = Col("Surgeon", ["Dr. Ahmed", "Dr. Brooks", "Dr. Chen", "Dr. Davis", "Dr. Evans", "Dr. Foster", "Dr. Grant", "Dr. Hayes"])
orStatusCol = Col("Status", ["In Progress", "Prepping", "Scheduled", "Scheduled", "Scheduled", "Scheduled", "Scheduled", "Scheduled"])
suppliesSection = Card([suppliesLabel, suppliesTable], "card", "column", "m")
suppliesLabel = Heading("Supplies Running Low", "h3")
suppliesTable = Table([supplyItemCol, supplyCurrentCol, supplyThresholdCol, supplyStatusCol])
supplyItemCol = Col("Item", ["0.9% NaCl 1L bags", "Heparin 5000U vials", "Epinephrine 1mg syringes", "N95 Masks (M)", "Blood Culture Bottles", "Foley Catheters 16Fr", "Central Line Kits", "Chest Tube Trays"])
supplyCurrentCol = Col("Current", [42, 18, 12, 156, 24, 8, 6, 4])
supplyThresholdCol = Col("Reorder Pt", [50, 25, 20, 200, 30, 15, 10, 8])
supplyStatusCol = Col("Status", [Tag("Low", null, "md", "warning"), Tag("Low", null, "md", "warning"), Tag("Critical", null, "md", "danger"), Tag("Low", null, "md", "warning"), Tag("Low", null, "md", "warning"), Tag("Critical", null, "md", "danger"), Tag("Critical", null, "md", "danger"), Tag("Critical", null, "md", "danger")])
actionsRow = Card([incidentBtn, transferBtn], "clear", "row", "l", "center", "center")
incidentBtn = DialogBlock("File Incident Report", "Incident Report", "Document a safety event, near miss, or quality concern", [incidentForm], "default")
incidentForm = Form("incident-report", incidentButtons, [incidentType, incidentLocation, incidentDesc, incidentSeverity])
incidentType = FormControl("Incident Type", incidentTypeSelect, "Select the category that best describes the event")
incidentTypeSelect = Select("incident_type", [incType1, incType2, incType3, incType4, incType5], "Choose type")
incType1 = SelectItem("medication", "Medication Error")
incType2 = SelectItem("fall", "Patient Fall")
incType3 = SelectItem("pressure_injury", "Pressure Injury")
incType4 = SelectItem("equipment", "Equipment Failure")
incType5 = SelectItem("other", "Other / Near Miss")
incidentLocation = FormControl("Location", incidentLocationInput, "Unit, room, or area where incident occurred")
incidentLocationInput = Input("location", "e.g., ICU Room 12, ER Bay 3")
incidentDesc = FormControl("Description", incidentDescArea, "Factual description of what happened")
incidentDescArea = TextArea("description", "Describe the event chronologically...", 4)
incidentSeverity = FormControl("Severity", incidentSeverityRadio, "Actual or potential harm level")
incidentSeverityRadio = RadioGroup("severity", [sev1, sev2, sev3, sev4], "none")
sev1 = RadioItem("None", "No harm reached patient", "none")
sev2 = RadioItem("Minor", "Minor harm, no treatment needed", "minor")
sev3 = RadioItem("Moderate", "Harm requiring treatment", "moderate")
sev4 = RadioItem("Severe", "Serious harm or death", "severe")
incidentButtons = Buttons([incidentSubmit, incidentCancel])
incidentSubmit = Button("Submit Report", null, "primary")
incidentCancel = Button("Cancel", null, "tertiary")
transferBtn = DialogBlock("Request Patient Transfer", "Patient Transfer Request", "Initiate an internal or external transfer for a patient", [transferForm], "default")
transferForm = Form("transfer-request", transferButtons, [transferPatient, transferFrom, transferTo, transferReason, transferUrgency])
transferPatient = FormControl("Patient", transferPatientInput, "Name and MRN")
transferPatientInput = Input("patient", "J. Smith (MRN 847291)")
transferFrom = FormControl("From Unit", transferFromSelect, "Current location")
transferFromSelect = Select("from_unit", [from1, from2, from3, from4, from5], "Select unit")
from1 = SelectItem("er", "Emergency Department")
from2 = SelectItem("icu", "ICU")
from3 = SelectItem("med_surg", "Med-Surg")
from4 = SelectItem("stepdown", "Step-Down")
from5 = SelectItem("other", "Other")
transferTo = FormControl("To Unit / Facility", transferToInput, "Destination unit or receiving facility")
transferToInput = Input("to_unit", "e.g., ICU Bed 4 or Mercy General Hospital")
transferReason = FormControl("Clinical Reason", transferReasonArea, "Medical justification for transfer")
transferReasonArea = TextArea("reason", "Clinical indication...", 3)
transferUrgency = FormControl("Urgency", transferUrgencyRadio, "Time sensitivity")
transferUrgencyRadio = RadioGroup("urgency", [urg1, urg2, urg3], "routine")
urg1 = RadioItem("Emergent", "Immediate — life/limb threat", "emergent")
urg2 = RadioItem("Urgent", "Within 1-2 hours", "urgent")
urg3 = RadioItem("Routine", "Next available bed/transport", "routine")
transferButtons = Buttons([transferSubmit, transferCancel])
transferSubmit = Button("Request Transfer", null, "primary")
transferCancel = Button("Cancel", null, "tertiary")