Spaces:
Sleeping
Sleeping
File size: 33,511 Bytes
3d8815a 85ea5e3 3d8815a 85ea5e3 3d8815a 85ea5e3 3d8815a 85ea5e3 3d8815a 85ea5e3 3d8815a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Healthcare Scheduling RL Environment</title>
<meta name="description" content="Interactive RL environment for healthcare appointment scheduling β OpenEnv compatible." />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet" />
<style>
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #0b0e17;
--surface: rgba(255,255,255,0.04);
--surface-hover: rgba(255,255,255,0.08);
--border: rgba(255,255,255,0.08);
--text: #e2e8f0;
--text-dim: #94a3b8;
--accent: #6366f1;
--accent-glow: rgba(99,102,241,0.35);
--green: #22c55e;
--green-glow: rgba(34,197,94,0.25);
--amber: #f59e0b;
--amber-glow: rgba(245,158,11,0.25);
--red: #ef4444;
--red-glow: rgba(239,68,68,0.2);
--cyan: #06b6d4;
--radius: 16px;
--radius-sm: 10px;
}
body {
font-family: 'Inter', -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
overflow-x: hidden;
}
/* Animated gradient orbs in background */
body::before, body::after {
content: '';
position: fixed;
border-radius: 50%;
filter: blur(120px);
opacity: 0.3;
pointer-events: none;
z-index: 0;
}
body::before {
width: 600px; height: 600px;
background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
top: -200px; left: -100px;
animation: float1 20s ease-in-out infinite;
}
body::after {
width: 500px; height: 500px;
background: radial-gradient(circle, var(--cyan) 0%, transparent 70%);
bottom: -150px; right: -100px;
animation: float2 25s ease-in-out infinite;
}
@keyframes float1 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(80px,60px)} }
@keyframes float2 { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-60px,-80px)} }
.container {
max-width: 1280px;
margin: 0 auto;
padding: 24px 20px;
position: relative;
z-index: 1;
}
/* HEADER */
header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 32px;
flex-wrap: wrap;
gap: 16px;
}
.logo {
display: flex;
align-items: center;
gap: 14px;
}
.logo-icon {
width: 48px; height: 48px;
background: linear-gradient(135deg, var(--accent), var(--cyan));
border-radius: 14px;
display: grid; place-items: center;
font-size: 24px;
box-shadow: 0 4px 20px var(--accent-glow);
}
.logo h1 {
font-size: 1.35rem;
font-weight: 700;
background: linear-gradient(135deg, #fff 30%, var(--cyan));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.logo span {
display: block;
font-size: 0.75rem;
font-weight: 400;
color: var(--text-dim);
-webkit-text-fill-color: var(--text-dim);
}
.header-badges {
display: flex; gap: 8px; flex-wrap: wrap;
}
.badge {
padding: 6px 14px;
border-radius: 999px;
font-size: 0.7rem;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
}
.badge-accent { background: var(--accent-glow); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.3); }
.badge-green { background: var(--green-glow); color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
/* STATS ROW */
.stats-row {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
margin-bottom: 28px;
}
.stat-card {
background: var(--surface);
backdrop-filter: blur(20px);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 20px 22px;
transition: all 0.3s ease;
}
.stat-card:hover { background: var(--surface-hover); transform: translateY(-2px); }
.stat-label {
font-size: 0.72rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 1px;
color: var(--text-dim);
margin-bottom: 8px;
}
.stat-value {
font-size: 1.8rem;
font-weight: 800;
}
.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-value.cyan { color: var(--cyan); }
/* CONTROL BAR */
.control-bar {
display: flex;
gap: 10px;
margin-bottom: 28px;
flex-wrap: wrap;
}
.btn {
display: inline-flex; align-items: center; gap: 8px;
padding: 12px 24px;
border: none;
border-radius: var(--radius-sm);
font-family: inherit;
font-size: 0.85rem;
font-weight: 600;
cursor: pointer;
transition: all 0.25s ease;
position: relative;
overflow: hidden;
}
.btn::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
opacity: 0;
transition: opacity 0.25s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }
.btn-primary {
background: linear-gradient(135deg, var(--accent), #818cf8);
color: #fff;
box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-success {
background: linear-gradient(135deg, #059669, var(--green));
color: #fff;
box-shadow: 0 4px 20px var(--green-glow);
}
.btn-amber {
background: linear-gradient(135deg, #d97706, var(--amber));
color: #fff;
box-shadow: 0 4px 20px var(--amber-glow);
}
.btn-ghost {
background: var(--surface);
color: var(--text);
border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); }
.btn:disabled {
opacity: 0.45;
cursor: not-allowed;
pointer-events: none;
}
/* GRID LAYOUT */
.main-grid {
display: grid;
grid-template-columns: 1fr 380px;
gap: 20px;
}
@media (max-width: 960px) {
.main-grid { grid-template-columns: 1fr; }
}
/* PANELS */
.panel {
background: var(--surface);
backdrop-filter: blur(20px);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
transition: all 0.3s ease;
}
.panel:hover { border-color: rgba(255,255,255,0.12); }
.panel-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18px 22px;
border-bottom: 1px solid var(--border);
}
.panel-title {
font-size: 0.95rem;
font-weight: 700;
display: flex; align-items: center; gap: 10px;
}
.panel-body { padding: 20px 22px; }
/* DOCTORS GRID */
.doctors-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 14px;
}
@media (max-width: 700px) {
.doctors-grid { grid-template-columns: 1fr; }
}
.doctor-card {
background: rgba(255,255,255,0.03);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 16px;
transition: all 0.3s ease;
}
.doctor-card:hover { background: rgba(255,255,255,0.06); transform: translateY(-2px); }
.doctor-name {
font-size: 0.88rem;
font-weight: 700;
margin-bottom: 4px;
display: flex; align-items: center; gap: 8px;
}
.doctor-specialty {
font-size: 0.72rem;
color: var(--text-dim);
margin-bottom: 14px;
}
.slots-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
}
.slot {
aspect-ratio: 1;
border-radius: 8px;
display: grid;
place-items: center;
font-size: 0.68rem;
font-weight: 700;
cursor: pointer;
transition: all 0.25s ease;
border: 1px solid transparent;
position: relative;
}
.slot.available {
background: var(--green-glow);
color: var(--green);
border-color: rgba(34,197,94,0.2);
}
.slot.available:hover {
background: rgba(34,197,94,0.4);
transform: scale(1.1);
box-shadow: 0 0 12px var(--green-glow);
}
.slot.booked {
background: var(--red-glow);
color: var(--red);
border-color: rgba(239,68,68,0.2);
}
.slot-label {
font-size: 0.6rem; color: var(--text-dim);
text-align: center;
margin-top: 6px;
}
.slot-times {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 6px;
margin-top: 4px;
}
/* SIDEBAR */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
/* ACTION FORM */
.action-form { display: flex; flex-direction: column; gap: 14px; }
.form-group label {
display: block;
font-size: 0.72rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.8px;
color: var(--text-dim);
margin-bottom: 6px;
}
.form-group select, .form-group input {
width: 100%;
padding: 10px 14px;
background: rgba(255,255,255,0.05);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
color: var(--text);
font-family: inherit;
font-size: 0.85rem;
outline: none;
transition: border-color 0.25s;
}
.form-group select:focus, .form-group input:focus {
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group select option { background: #1e1e2e; }
/* PATIENTS LIST */
.patients-list {
display: flex;
flex-direction: column;
gap: 8px;
max-height: 360px;
overflow-y: auto;
}
.patients-list::-webkit-scrollbar { width: 4px; }
.patients-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.patient-row {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px;
background: rgba(255,255,255,0.02);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
transition: all 0.25s ease;
cursor: pointer;
}
.patient-row:hover { background: rgba(255,255,255,0.06); }
.patient-row.selected {
border-color: var(--accent);
background: var(--accent-glow);
}
.patient-avatar {
width: 34px; height: 34px;
border-radius: 50%;
display: grid; place-items: center;
font-size: 0.75rem;
font-weight: 700;
flex-shrink: 0;
}
.priority-high .patient-avatar { background: var(--red-glow); color: var(--red); }
.priority-medium .patient-avatar { background: var(--amber-glow); color: var(--amber); }
.priority-low .patient-avatar { background: var(--green-glow); color: var(--green); }
.patient-info { flex: 1; min-width: 0; }
.patient-name {
font-size: 0.8rem;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.patient-meta {
font-size: 0.68rem;
color: var(--text-dim);
}
.patient-status {
padding: 3px 10px;
border-radius: 999px;
font-size: 0.62rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.status-waiting { background: var(--amber-glow); color: var(--amber); }
.status-booked { background: var(--green-glow); color: var(--green); }
.status-cancelled { background: var(--red-glow); color: var(--red); }
/* SCORES */
.scores-grid { display: flex; flex-direction: column; gap: 12px; }
.score-row {
display: flex;
align-items: center;
gap: 14px;
}
.score-label {
font-size: 0.78rem;
font-weight: 600;
min-width: 70px;
}
.score-bar-bg {
flex: 1;
height: 10px;
background: rgba(255,255,255,0.06);
border-radius: 999px;
overflow: hidden;
}
.score-bar-fill {
height: 100%;
border-radius: 999px;
transition: width 0.6s cubic-bezier(0.22,1,0.36,1);
}
.score-bar-fill.t1 { background: linear-gradient(90deg, var(--green), #34d399); }
.score-bar-fill.t2 { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.score-bar-fill.t3 { background: linear-gradient(90deg, var(--accent), #818cf8); }
.score-value {
font-size: 0.82rem;
font-weight: 800;
min-width: 42px;
text-align: right;
}
/* LOG */
.log-area {
max-height: 200px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 4px;
}
.log-area::-webkit-scrollbar { width: 4px; }
.log-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.log-entry {
font-size: 0.72rem;
padding: 6px 10px;
border-radius: 6px;
background: rgba(255,255,255,0.02);
color: var(--text-dim);
font-family: 'SF Mono', 'Cascadia Code', monospace;
animation: fadeIn 0.3s ease;
}
.log-entry.success { color: var(--green); }
.log-entry.error { color: var(--red); }
.log-entry.info { color: var(--cyan); }
@keyframes fadeIn {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
/* TOAST */
.toast-container {
position: fixed;
bottom: 24px;
right: 24px;
z-index: 1000;
display: flex;
flex-direction: column;
gap: 8px;
}
.toast {
padding: 14px 20px;
border-radius: var(--radius-sm);
font-size: 0.82rem;
font-weight: 500;
backdrop-filter: blur(20px);
animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
max-width: 360px;
}
.toast.success { background: rgba(34,197,94,0.2); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.toast.error { background: rgba(239,68,68,0.2); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.toast.info { background: rgba(6,182,212,0.2); border: 1px solid rgba(6,182,212,0.3); color: #67e8f9; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { transform: translateY(10px); opacity: 0; } }
/* Pulse animation for live indicator */
.pulse {
width: 8px; height: 8px;
background: var(--green);
border-radius: 50%;
animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
0%,100% { box-shadow: 0 0 0 0 var(--green-glow); }
50% { box-shadow: 0 0 0 8px transparent; }
}
.step-counter-inline {
font-size: 0.75rem;
color: var(--text-dim);
display: flex; align-items: center; gap: 6px;
}
/* Footer */
footer {
margin-top: 40px;
text-align: center;
padding: 20px;
font-size: 0.72rem;
color: var(--text-dim);
border-top: 1px solid var(--border);
}
footer a {
color: var(--accent);
text-decoration: none;
}
footer a:hover { text-decoration: underline; }
</style>
</head>
<body>
<div class="container">
<!-- HEADER -->
<header>
<div class="logo">
<div class="logo-icon">π₯</div>
<div>
<h1>Healthcare Scheduling RL</h1>
<span>OpenEnv Interactive Environment</span>
</div>
</div>
<div class="header-badges">
<div class="badge badge-accent">OpenEnv 1.0</div>
<div class="badge badge-green" style="display:flex;align-items:center;gap:6px;">
<div class="pulse"></div> Live
</div>
</div>
</header>
<!-- STATS ROW -->
<div class="stats-row">
<div class="stat-card">
<div class="stat-label">Patients Waiting</div>
<div class="stat-value amber" id="stat-waiting">β</div>
</div>
<div class="stat-card">
<div class="stat-label">Patients Booked</div>
<div class="stat-value green" id="stat-booked">β</div>
</div>
<div class="stat-card">
<div class="stat-label">Available Slots</div>
<div class="stat-value cyan" id="stat-slots">β</div>
</div>
<div class="stat-card">
<div class="stat-label">Current Step</div>
<div class="stat-value accent" id="stat-step">β</div>
</div>
</div>
<!-- CONTROLS -->
<div class="control-bar">
<button class="btn btn-primary" id="btn-reset" onclick="resetEnv()">π Reset Environment</button>
<button class="btn btn-success" id="btn-baseline" onclick="runBaseline()">π€ Run Baseline Agent</button>
<button class="btn btn-amber" id="btn-grade" onclick="getGrades()">π Grade Tasks</button>
<button class="btn btn-ghost" onclick="window.open('/docs','_blank')">π API Docs</button>
<div style="flex:1"></div>
<div class="step-counter-inline">
<span>Episode:</span>
<strong id="episode-status">Not started</strong>
</div>
</div>
<!-- MAIN LAYOUT -->
<div class="main-grid">
<!-- LEFT: Doctors + Log -->
<div style="display:flex;flex-direction:column;gap:20px;">
<!-- DOCTOR SLOTS -->
<div class="panel">
<div class="panel-header">
<div class="panel-title">π¨ββοΈ Doctor Availability</div>
</div>
<div class="panel-body">
<div class="doctors-grid" id="doctors-grid">
<div style="color:var(--text-dim);font-size:0.85rem;">Click <b>Reset</b> to start an episode</div>
</div>
</div>
</div>
<!-- TASK SCORES -->
<div class="panel">
<div class="panel-header">
<div class="panel-title">π― Task Scores</div>
</div>
<div class="panel-body">
<div class="scores-grid" id="scores-grid">
<div class="score-row">
<span class="score-label" style="color:var(--green)">Task 1</span>
<div class="score-bar-bg"><div class="score-bar-fill t1" id="bar-t1" style="width:0%"></div></div>
<span class="score-value" id="score-t1">β</span>
</div>
<div class="score-row">
<span class="score-label" style="color:var(--amber)">Task 2</span>
<div class="score-bar-bg"><div class="score-bar-fill t2" id="bar-t2" style="width:0%"></div></div>
<span class="score-value" id="score-t2">β</span>
</div>
<div class="score-row">
<span class="score-label" style="color:var(--accent)">Task 3</span>
<div class="score-bar-bg"><div class="score-bar-fill t3" id="bar-t3" style="width:0%"></div></div>
<span class="score-value" id="score-t3">β</span>
</div>
</div>
</div>
</div>
<!-- ACTION LOG -->
<div class="panel">
<div class="panel-header">
<div class="panel-title">π Action Log</div>
<button class="btn btn-ghost" style="padding:6px 12px;font-size:0.72rem;" onclick="clearLog()">Clear</button>
</div>
<div class="panel-body">
<div class="log-area" id="log-area">
<div class="log-entry info">System ready. Click Reset to begin.</div>
</div>
</div>
</div>
</div>
<!-- RIGHT SIDEBAR -->
<div class="sidebar">
<!-- ACTION FORM -->
<div class="panel">
<div class="panel-header">
<div class="panel-title">β‘ Take Action</div>
</div>
<div class="panel-body">
<div class="action-form">
<div class="form-group">
<label>Action Type</label>
<select id="action-type">
<option value="book">π
Book Appointment</option>
<option value="reschedule">π Reschedule</option>
<option value="cancel">β Cancel</option>
<option value="waitlist">β³ Waitlist</option>
</select>
</div>
<div class="form-group">
<label>Patient ID</label>
<select id="action-patient"></select>
</div>
<div class="form-group" id="doctor-group">
<label>Doctor ID</label>
<select id="action-doctor"></select>
</div>
<div class="form-group" id="slot-group">
<label>Slot ID</label>
<select id="action-slot">
<option value="0">Slot 0 (9:00 AM)</option>
<option value="1">Slot 1 (9:30 AM)</option>
<option value="2">Slot 2 (10:00 AM)</option>
<option value="3">Slot 3 (10:30 AM)</option>
<option value="4">Slot 4 (2:00 PM)</option>
<option value="5">Slot 5 (2:30 PM)</option>
<option value="6">Slot 6 (3:00 PM)</option>
<option value="7">Slot 7 (3:30 PM)</option>
</select>
</div>
<button class="btn btn-primary" style="width:100%;justify-content:center;" id="btn-step" onclick="stepEnv()" disabled>
π Execute Action
</button>
</div>
</div>
</div>
<!-- PATIENTS -->
<div class="panel">
<div class="panel-header">
<div class="panel-title">π§βπ€βπ§ Patients</div>
<span style="font-size:0.7rem;color:var(--text-dim);" id="patient-count">0 total</span>
</div>
<div class="panel-body">
<div class="patients-list" id="patients-list">
<div style="color:var(--text-dim);font-size:0.82rem;">No data yet</div>
</div>
</div>
</div>
</div>
</div>
<footer>
Built with β€οΈ for the <a href="https://openenv.org">OpenEnv</a> Hackathon —
Healthcare Appointment Scheduling RL Environment —
<a href="/docs">API Docs</a> • <a href="/redoc">ReDoc</a>
</footer>
</div>
<div class="toast-container" id="toast-container"></div>
<script>
const API = ''; // same origin
const DOCTOR_NAMES = ['Dr. Patel', 'Dr. Sharma', 'Dr. Gupta', 'Dr. Reddy', 'Dr. Kumar'];
const DOCTOR_SPECS = ['General Medicine', 'Cardiology', 'Orthopedics', 'Pediatrics', 'Dermatology'];
const SLOT_TIMES = ['9:00 AM', '9:30 AM', '10:00 AM', '10:30 AM', '2:00 PM', '2:30 PM', '3:00 PM', '3:30 PM'];
const PRIORITY_LABELS = { 1: 'High', 2: 'Medium', 3: 'Low' };
const PRIORITY_CLASSES = { 1: 'priority-high', 2: 'priority-medium', 3: 'priority-low' };
let envState = null;
let isDone = false;
// Toast
function showToast(msg, type = 'info') {
const tc = document.getElementById('toast-container');
const t = document.createElement('div');
t.className = `toast ${type}`;
t.textContent = msg;
tc.appendChild(t);
setTimeout(() => t.remove(), 3000);
}
// Log
function addLog(msg, type = '') {
const area = document.getElementById('log-area');
const entry = document.createElement('div');
entry.className = `log-entry ${type}`;
const time = new Date().toLocaleTimeString();
entry.textContent = `[${time}] ${msg}`;
area.appendChild(entry);
area.scrollTop = area.scrollHeight;
}
function clearLog() {
document.getElementById('log-area').innerHTML = '';
}
// Update UI
function updateUI(obs) {
if (!obs) return;
envState = obs;
// Stats
let waiting = 0, booked = 0, totalSlots = 0;
const patients = obs.patients || {};
Object.values(patients).forEach(p => {
if (p.status === 'waiting') waiting++;
if (p.status === 'booked') booked++;
});
const doctorSlots = obs.doctor_slots || {};
Object.values(doctorSlots).forEach(slots => {
slots.forEach(s => { if (s) totalSlots++; });
});
document.getElementById('stat-waiting').textContent = waiting;
document.getElementById('stat-booked').textContent = booked;
document.getElementById('stat-slots').textContent = totalSlots;
document.getElementById('stat-step').textContent = obs.current_step || 0;
document.getElementById('episode-status').textContent = isDone ? 'β
Done' : `Step ${obs.current_step || 0}`;
document.getElementById('btn-step').disabled = isDone;
// Doctors
const dg = document.getElementById('doctors-grid');
dg.innerHTML = '';
Object.entries(doctorSlots).forEach(([did, slots]) => {
const idx = parseInt(did);
const card = document.createElement('div');
card.className = 'doctor-card';
card.innerHTML = `
<div class="doctor-name">
<span style="font-size:1.2rem;">π¨ββοΈ</span>
${DOCTOR_NAMES[idx] || 'Doctor ' + did}
</div>
<div class="doctor-specialty">${DOCTOR_SPECS[idx] || 'Specialist'}</div>
<div class="slots-grid">
${slots.map((avail, si) => `
<div class="slot ${avail ? 'available' : 'booked'}"
title="${avail ? 'Available' : 'Booked'} β ${SLOT_TIMES[si]}"
onclick="${avail && !isDone ? `quickBook(${did}, ${si})` : ''}">
${si}
</div>
`).join('')}
</div>
<div class="slot-times">
${SLOT_TIMES.map(t => `<div class="slot-label">${t.replace(':00 ','')}</div>`).join('')}
</div>
`;
dg.appendChild(card);
});
// Patients
const pl = document.getElementById('patients-list');
pl.innerHTML = '';
const sorted = Object.values(patients).sort((a, b) => a.priority - b.priority);
sorted.forEach(p => {
const pid = p.id !== undefined ? p.id : '?';
const row = document.createElement('div');
row.className = `patient-row ${PRIORITY_CLASSES[p.priority] || ''}`;
row.onclick = () => {
document.getElementById('action-patient').value = pid;
document.querySelectorAll('.patient-row').forEach(r => r.classList.remove('selected'));
row.classList.add('selected');
};
const statusClass = p.status === 'booked' ? 'status-booked' : p.status === 'cancelled' ? 'status-cancelled' : 'status-waiting';
let meta = `Priority: ${PRIORITY_LABELS[p.priority] || p.priority} β’ Prefers: ${DOCTOR_NAMES[p.preferred_doctor] || 'Dr ' + p.preferred_doctor}`;
if (p.status === 'booked') {
meta += ` β’ Booked: ${DOCTOR_NAMES[p.booked_doctor] || 'Dr ' + p.booked_doctor} @ ${SLOT_TIMES[p.booked_slot] || 'Slot ' + p.booked_slot}`;
}
row.innerHTML = `
<div class="patient-avatar">P${pid}</div>
<div class="patient-info">
<div class="patient-name">Patient ${pid}</div>
<div class="patient-meta">${meta}</div>
</div>
<div class="patient-status ${statusClass}">${p.status}</div>
`;
pl.appendChild(row);
});
document.getElementById('patient-count').textContent = `${Object.keys(patients).length} total`;
// Patient dropdown
const patientSelect = document.getElementById('action-patient');
const currentVal = patientSelect.value;
patientSelect.innerHTML = '';
sorted.forEach(p => {
const opt = document.createElement('option');
opt.value = p.id;
opt.textContent = `Patient ${p.id} (${PRIORITY_LABELS[p.priority] || ''} β ${p.status})`;
patientSelect.appendChild(opt);
});
if (currentVal && patientSelect.querySelector(`option[value="${currentVal}"]`)) {
patientSelect.value = currentVal;
}
// Doctor dropdown
const doctorSelect = document.getElementById('action-doctor');
doctorSelect.innerHTML = '';
Object.keys(doctorSlots).forEach(did => {
const opt = document.createElement('option');
opt.value = did;
opt.textContent = `${DOCTOR_NAMES[parseInt(did)] || 'Doctor ' + did} (ID: ${did})`;
doctorSelect.appendChild(opt);
});
}
function updateScores(scores) {
if (!scores) return;
const t1 = scores.task_1 || 0, t2 = scores.task_2 || 0, t3 = scores.task_3 || 0;
document.getElementById('score-t1').textContent = (t1 * 100).toFixed(0) + '%';
document.getElementById('score-t2').textContent = (t2 * 100).toFixed(0) + '%';
document.getElementById('score-t3').textContent = (t3 * 100).toFixed(0) + '%';
document.getElementById('bar-t1').style.width = (t1 * 100) + '%';
document.getElementById('bar-t2').style.width = (t2 * 100) + '%';
document.getElementById('bar-t3').style.width = (t3 * 100) + '%';
}
// Show/hide doctor & slot fields based on action type
document.getElementById('action-type').addEventListener('change', function() {
const t = this.value;
document.getElementById('doctor-group').style.display = (t === 'cancel' || t === 'waitlist') ? 'none' : 'block';
document.getElementById('slot-group').style.display = (t === 'cancel' || t === 'waitlist') ? 'none' : 'block';
});
// Quick book from slot click
function quickBook(doctorId, slotId) {
document.getElementById('action-type').value = 'book';
document.getElementById('action-doctor').value = doctorId;
document.getElementById('action-slot').value = slotId;
document.getElementById('action-type').dispatchEvent(new Event('change'));
showToast(`Selected: ${DOCTOR_NAMES[doctorId]} @ ${SLOT_TIMES[slotId]}`, 'info');
}
// API Calls
async function resetEnv() {
try {
addLog('Resetting environment...', 'info');
const res = await fetch(API + '/reset', { method: 'POST' });
const data = await res.json();
isDone = false;
updateUI(data.observation);
document.getElementById('btn-step').disabled = false;
// Reset scores
['t1','t2','t3'].forEach(t => {
document.getElementById('score-' + t).textContent = 'β';
document.getElementById('bar-' + t).style.width = '0%';
});
addLog('Environment reset. Episode started!', 'success');
showToast('Environment reset successfully', 'success');
} catch (e) {
addLog('Reset failed: ' + e.message, 'error');
showToast('Reset failed', 'error');
}
}
async function stepEnv() {
const type = document.getElementById('action-type').value;
const patient_id = parseInt(document.getElementById('action-patient').value);
const doctor_id = parseInt(document.getElementById('action-doctor').value);
const slot_id = parseInt(document.getElementById('action-slot').value);
const body = { type, patient_id };
if (type === 'book' || type === 'reschedule') {
body.doctor_id = doctor_id;
body.slot_id = slot_id;
}
try {
addLog(`Action: ${type} | Patient ${patient_id}${body.doctor_id !== undefined ? ' β Dr ' + doctor_id + ' Slot ' + slot_id : ''}`, 'info');
const res = await fetch(API + '/step', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
const data = await res.json();
isDone = data.done;
updateUI(data.observation);
const reward = data.reward;
const infoStr = data.info.status || data.info.error || JSON.stringify(data.info);
if (reward >= 0) {
addLog(`β
Result: ${infoStr} | Reward: +${reward.toFixed(2)}`, 'success');
showToast(`Action succeeded! Reward: +${reward.toFixed(2)}`, 'success');
} else {
addLog(`β Result: ${infoStr} | Reward: ${reward.toFixed(2)}`, 'error');
showToast(`Action failed: ${infoStr}`, 'error');
}
if (isDone) {
addLog('π Episode finished!', 'info');
showToast('Episode complete! Check grades.', 'info');
getGrades();
}
} catch (e) {
addLog('Step failed: ' + e.message, 'error');
showToast('Step failed', 'error');
}
}
async function getGrades() {
try {
addLog('Fetching task grades...', 'info');
const res = await fetch(API + '/grader');
const data = await res.json();
updateScores(data.task_scores);
addLog(`Grades β T1: ${(data.task_scores.task_1*100).toFixed(0)}% | T2: ${(data.task_scores.task_2*100).toFixed(0)}% | T3: ${(data.task_scores.task_3*100).toFixed(0)}%`, 'success');
showToast('Grades updated', 'success');
} catch (e) {
addLog('Grading failed: ' + e.message, 'error');
showToast('Grading failed', 'error');
}
}
async function runBaseline() {
try {
addLog('Running baseline agent...', 'info');
showToast('Running baseline agent...', 'info');
const res = await fetch(API + '/baseline');
const data = await res.json();
isDone = true;
// Fetch latest state
const stateRes = await fetch(API + '/state');
const stateData = await stateRes.json();
updateUI(stateData.state);
updateScores(data.task_scores);
addLog(`Baseline done β T1: ${(data.task_scores.task_1*100).toFixed(0)}% | T2: ${(data.task_scores.task_2*100).toFixed(0)}% | T3: ${(data.task_scores.task_3*100).toFixed(0)}%`, 'success');
showToast('Baseline agent finished!', 'success');
document.getElementById('episode-status').textContent = 'β
Done (Baseline)';
document.getElementById('btn-step').disabled = true;
} catch (e) {
addLog('Baseline failed: ' + e.message, 'error');
showToast('Baseline failed', 'error');
}
}
</script>
</body>
</html>
|