root = Card([header, commandBar, kpiRow, criticalCallout, admissionsSection, deptSection, staffingSection, dischargeSection, orSection, suppliesSection])
header = CardHeader("Hospital Operations Command", "St. Mary's Medical Center · Command View · May 14, 2025")
commandBar = Card([incidentDialog, transferDialog, dateDialog], "sunk", "row", "m")
kpiRow = Card([occupancyCard, erCard], "clear", "row", "m")
occupancyCard = Card([occHeading, occBar, occText], "sunk")
occHeading = Heading("Bed occupancy", "h3")
occBar = SingleStackedBarChart(["Occupied", "Available"], [342, 58])
occText = TextContent("342 of 400 beds occupied — 85.5%", "small")
erCard = Card([erHeading, erWait, erCallout], "sunk")
erHeading = Heading("Current ER wait", "h3")
erWait = TextContent("2h 15m", "large-heavy")
erCallout = Callout("warning", "Above target", "Target is 1h 30m. 42 patients in the waiting room.")
criticalCallout = Alert("Critical patients", "3 patients in critical condition — Room 214 (cardiac arrest, stabilized), Room 306 (neuro trauma), Room 118 (sepsis). Rapid response team at bedside.", "destructive")
admissionsSection = Card([admHeading, admChart], "sunk")
admHeading = Heading("Admissions — last 14 days", "h3")
admChart = AreaChart(["5/1", "5/2", "5/3", "5/4", "5/5", "5/6", "5/7", "5/8", "5/9", "5/10", "5/11", "5/12", "5/13", "5/14"], [admSeries], "natural", "Date", "Admissions")
admSeries = Series("Admissions", [31, 27, 34, 39, 36, 42, 38, 45, 41, 48, 44, 50, 47, 52])
deptSection = Card([deptHeading, deptChart], "sunk")
deptHeading = Heading("Patients per department", "h3")
deptChart = BarChart(["ER", "Cardiology", "Oncology", "Orthopedics", "Neurology", "Pediatrics", "Maternity", "ICU"], [deptSeries], "grouped", "Department", "Patients")
deptSeries = Series("Patients", [45, 38, 41, 27, 19, 33, 22, 18])
staffingSection = Card([staffHeading, staffTable], "sunk")
staffHeading = Heading("Staff on shift", "h3")
staffTable = Table([staffName, staffRole, staffDept, staffShift])
staffName = Col("Name", ["Dr. Lena Fischer", "Dr. Marcus Bell", "Dr. Amara Okafor", "Sofia Reyes, RN", "Daniel Kim, RN", "Dr. Priya Sharma", "Tom Bradley, RN", "Julia Santos"])
staffRole = Col("Role", ["Attending", "Attending", "Resident", "Staff Nurse", "OR Nurse", "Anesthesiologist", "Charge Nurse", "Lab Tech"])
staffDept = Col("Department", ["Emergency", "Cardiology", "Neurology", "ICU", "Operating Room", "Operating Room", "Emergency", "Pathology"])
staffShift = Col("Shift", ["Day", "Day", "Day", "Night", "Day", "Day", "Day", "Day"])
dischargeSection = Card([dischargeHeading, dischargeList], "sunk")
dischargeHeading = Heading("Ready for discharge", "h3")
dischargeList = ListBlock([dischargeItem1, dischargeItem2, dischargeItem3])
dischargeItem1 = ListItem("Margaret Osei", "Room 422 · approved · awaiting transport", null, "Notify")
dischargeItem2 = ListItem("James Whitfield", "Room 307 · family notified · papers ready", null, "Notify")
dischargeItem3 = ListItem("Priya Raman", "Room 215 · pickup at 15:00", null, "Notify")
orSection = Card([orHeading, orTable], "sunk")
orHeading = Heading("Today's OR bookings", "h3")
orTable = Table([orTime, orRoom, orProcedure, orSurgeon, orStatus])
orTime = Col("Time", ["07:30", "09:00", "11:30", "13:00", "15:30"])
orRoom = Col("Room", ["OR-1", "OR-2", "OR-1", "OR-3", "OR-2"])
orProcedure = Col("Procedure", ["Total knee replacement", "Laparoscopic cholecystectomy", "CABG", "Emergency C-section", "Lumbar spinal fusion"])
orSurgeon = Col("Surgeon", ["Dr. N. Haddad", "Dr. E. Lindqvist", "Dr. N. Haddad", "Dr. F. Nwosu", "Dr. R. Osei"])
orStatus = Col("Status", ["Scheduled", "Scheduled", "In prep", "Scheduled", "Scheduled"])
suppliesSection = Card([suppliesHeading, suppliesTable], "sunk")
suppliesHeading = Heading("Supplies running low", "h3")
suppliesTable = Table([supplyItem, supplyStock, supplyReorder])
supplyItem = Col("Item", ["N95 masks", "IV saline 500 mL", "Platelets (O+)", "Doxycycline 100 mg", "Surgical gloves — M"])
supplyStock = Col("Current stock", ["40 boxes", "18 cases", "6 units", "120 doses", "25 boxes"])
supplyReorder = Col("Reorder at", ["50", "25", "10", "150", "30"])
incidentDialog = DialogBlock("File incident", "Report an incident", "This report goes to the risk & safety team for review.", [incidentForm], "outline")
incidentForm = Form("incident-report", incidentButtons, [incidentTypeField, incidentSeverityField, incidentDetailField])
incidentTypeField = FormControl("Incident type", incidentTypeSelect)
incidentTypeSelect = Select("type", [incType1, incType2, incType3, incType4, incType5], "Select a type")
incType1 = SelectItem("medication", "Medication error")
incType2 = SelectItem("fall", "Patient fall")
incType3 = SelectItem("equipment", "Equipment failure")
incType4 = SelectItem("safety", "Patient safety")
incType5 = SelectItem("staff", "Staff injury")
incidentSeverityField = FormControl("Severity", incidentSeverityRadio)
incidentSeverityRadio = RadioGroup("severity", [sevLow, sevMod, sevHigh, sevCrit], "moderate")
sevLow = RadioItem("Low", "No harm, monitor", "low")
sevMod = RadioItem("Moderate", "Extra monitoring required", "moderate")
sevHigh = RadioItem("Severe", "Immediate intervention", "severe")
sevCrit = RadioItem("Critical", "Life-threatening", "critical")
incidentDetailField = FormControl("Description", incidentDetailArea, "Include location, people involved, and what happened.")
incidentDetailArea = TextArea("details", "Describe the incident…", 4)
incidentButtons = Buttons([incidentSubmit, incidentCancel])
incidentSubmit = Button("Submit report", null, "primary")
incidentCancel = Button("Cancel", null, "tertiary")
transferDialog = DialogBlock("Request transfer", "Patient transfer request", "The bed coordinator is notified immediately on submit.", [transferForm], "outline")
transferForm = Form("transfer-request", transferButtons, [transferPatientField, transferFromField, transferToField, transferReasonField, transferUrgencyField])
transferPatientField = FormControl("Patient", transferPatientSelect)
transferPatientSelect = Select("patient", [pat1, pat2, pat3], "Select patient")
pat1 = SelectItem("4821", "Patient 4821 · Room 422 · General med")
pat2 = SelectItem("3912", "Patient 3912 · Room 307 · Cardiology")
pat3 = SelectItem("5588", "Patient 5588 · Room 215 · Orthopedics")
transferFromField = FormControl("From unit", transferFromSelect)
transferFromSelect = Select("from_unit", [from1, from2, from3], "Select unit")
from1 = SelectItem("general", "General medicine")
from2 = SelectItem("cardio", "Cardiology")
from3 = SelectItem("ortho", "Orthopedics")
transferToField = FormControl("To unit", transferToSelect)
transferToSelect = Select("to_unit", [to1, to2, to3, to4], "Select destination")
to1 = SelectItem("icu", "ICU")
to2 = SelectItem("stepdown", "Step-down")
to3 = SelectItem("cardio", "Cardiology")
to4 = SelectItem("rehab", "Rehab")
transferReasonField = FormControl("Reason", transferReasonInput)
transferReasonInput = Input("reason", "e.g. needs ICU monitoring")
transferUrgencyField = FormControl("Urgency", transferUrgencyRadio)
transferUrgencyRadio = RadioGroup("urgency", [urgRoutine, urgUrgent, urgEmerg], "urgent")
urgRoutine = RadioItem("Routine", "Within 24 hours", "routine")
urgUrgent = RadioItem("Urgent", "Within 2 hours", "urgent")
urgEmerg = RadioItem("Emergency", "Immediately", "emergency")
transferButtons = Buttons([transferSubmit, transferCancel])
transferSubmit = Button("Submit request", null, "primary")
transferCancel = Button("Cancel", null, "tertiary")
dateDialog = DialogBlock("View another day", "Look at another day", "Select a date to load that day's operations view.", [dateForm], "outline")
dateForm = Form("view-date", dateButtons, [dateField])
dateField = FormControl("Date", dateInput, "Shows the command view for the selected date.")
dateInput = DatePicker("view_date")
dateButtons = Buttons([dateSubmit, dateCancel])
dateSubmit = Button("View day", null, "primary")
dateCancel = Button("Cancel", null, "tertiary")