anujkum0x commited on
Commit
011591f
·
verified ·
1 Parent(s): df24d27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -38
app.py CHANGED
@@ -441,57 +441,70 @@ def nurse_scheduling_app(
441
 
442
  # Create Gradio interface
443
  def create_interface():
444
- with gr.Blocks(title="Advanced Nurse Scheduling System") as demo:
445
- gr.Markdown("# Advanced Nurse Scheduling System")
446
 
447
  with gr.Row():
448
  with gr.Column():
449
- csv_file = gr.File(label="Upload Demand Data CSV")
 
 
 
 
 
 
 
450
 
451
- with gr.Group(label="Clinic Parameters"):
452
- clinic_start = gr.Textbox(label="Clinic Start Time (HH:MM)", value="08:00")
453
- clinic_end = gr.Textbox(label="Clinic End Time (HH:MM)", value="20:00")
454
- cycle_duration = gr.Number(label="Cycle Duration (hours)", value=5)
455
-
456
- with gr.Group(label="Staff Constraints"):
457
- beds_per_staff = gr.Slider(label="Beds Per Staff", minimum=1, maximum=10, value=3, step=1)
458
- max_shift_duration = gr.Slider(label="Maximum Shift Duration (hours)", minimum=4, maximum=12, value=12, step=1)
459
- handover_overlap = gr.Slider(label="Handover Overlap (minutes)", minimum=0, maximum=60, value=30, step=5)
460
- max_monthly_hours = gr.Slider(label="Maximum Monthly Hours", minimum=100, maximum=300, value=234, step=1)
461
-
462
- submit_btn = gr.Button("Generate Schedule")
 
 
463
 
464
  with gr.Column():
465
- summary_output = gr.Markdown(label="Summary")
466
- gantt_output = gr.Plot(label="Gantt Chart")
467
- schedule_output = gr.Dataframe(label="Schedule")
468
- csv_output = gr.File(label="Download Schedule CSV")
 
 
 
 
 
 
469
 
470
- submit_btn.click(
 
471
  fn=nurse_scheduling_app,
472
  inputs=[
473
- csv_file,
474
- beds_per_staff,
475
- max_shift_duration,
476
- handover_overlap,
477
- max_monthly_hours,
478
  clinic_start,
479
  clinic_end,
480
- cycle_duration
 
481
  ],
482
- outputs=[
483
- summary_output,
484
- gantt_output,
485
- schedule_output,
486
- csv_output
487
- ]
488
  )
489
-
490
- return demo
491
 
492
- # Create and launch the interface
493
- interface = create_interface()
494
 
495
- # For local testing
496
  if __name__ == "__main__":
497
- interface.launch()
 
 
441
 
442
  # Create Gradio interface
443
  def create_interface():
444
+ with gr.Blocks() as interface:
445
+ gr.Markdown("# Staff Scheduling Optimizer")
446
 
447
  with gr.Row():
448
  with gr.Column():
449
+ # Left panel for inputs
450
+ gr.Markdown("### Clinic Parameters") # Use Markdown instead of Group label
451
+ with gr.Group(): # Group without label
452
+ csv_input = gr.File(label="Upload CSV")
453
+ beds_per_staff = gr.Number(label="Beds per Staff", value=3)
454
+ max_hours_per_staff = gr.Number(label="Maximum monthly hours", value=160)
455
+ hours_per_cycle = gr.Number(label="Hours per Cycle", value=4)
456
+ rest_days_per_week = gr.Number(label="Rest Days per Week", value=2)
457
 
458
+ gr.Markdown("### Time Parameters") # Use Markdown for section headers
459
+ with gr.Group():
460
+ clinic_start = gr.Dropdown(
461
+ label="Clinic Start Hour",
462
+ choices=am_pm_times,
463
+ value="08:00 AM"
464
+ )
465
+ clinic_end = gr.Dropdown(
466
+ label="Clinic End Hour",
467
+ choices=am_pm_times,
468
+ value="08:00 PM"
469
+ )
470
+ overlap_time = gr.Number(label="Overlap Time", value=0)
471
+ max_start_time_change = gr.Number(label="Max Start Time Change", value=2)
472
 
473
  with gr.Column():
474
+ # Right panel for outputs
475
+ with gr.Tabs():
476
+ with gr.TabItem("Schedule"):
477
+ schedule_output = gr.Dataframe()
478
+ with gr.TabItem("Visualization"):
479
+ gantt_chart = gr.Plot()
480
+ with gr.TabItem("Statistics"):
481
+ stats_output = gr.Markdown()
482
+
483
+ optimize_btn = gr.Button("Optimize Schedule", variant="primary")
484
 
485
+ # Connect the button to your optimization function
486
+ optimize_btn.click(
487
  fn=nurse_scheduling_app,
488
  inputs=[
489
+ csv_input,
490
+ beds_per_staff,
491
+ max_hours_per_staff,
492
+ hours_per_cycle,
493
+ rest_days_per_week,
494
  clinic_start,
495
  clinic_end,
496
+ overlap_time,
497
+ max_start_time_change
498
  ],
499
+ outputs=[schedule_output, gantt_chart, stats_output]
 
 
 
 
 
500
  )
501
+
502
+ return interface
503
 
504
+ # Define your time options
505
+ am_pm_times = [f"{i:02d}:00 AM" for i in range(1, 13)] + [f"{i:02d}:00 PM" for i in range(1, 13)]
506
 
507
+ # Launch the interface
508
  if __name__ == "__main__":
509
+ interface = create_interface()
510
+ interface.launch(share=True)