File size: 34,854 Bytes
a7c6900
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Relatório de Produção Aprovada - CAPS</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .fade-in {
            animation: fadeIn 0.5s ease-in-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .chart-container {
            transition: all 0.3s ease;
        }
        .chart-container:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .data-table {
            max-height: 400px;
            overflow-y: auto;
        }
        .data-table::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        .data-table::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 10px;
        }
        .data-table::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 10px;
        }
        .data-table::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
        .highlight {
            background-color: #f0f9ff;
        }
    </style>
</head>
<body class="bg-gray-50">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="bg-blue-700 text-white rounded-xl shadow-lg p-6 mb-8 fade-in">
            <div class="flex flex-col md:flex-row justify-between items-start md:items-center">
                <div>
                    <h1 class="text-2xl md:text-3xl font-bold mb-2">RELATÓRIO DE PRODUÇÃO APROVADA</h1>
                    <h2 class="text-xl md:text-2xl font-semibold mb-4">Períodos: Agosto, Setembro, Outubro e Novembro de 2023 e 2024</h2>
                    <p class="text-blue-100">Data de geração: 22/04/2025</p>
                </div>
                <div class="mt-4 md:mt-0 bg-white text-blue-700 px-4 py-2 rounded-lg shadow">
                    <p class="font-bold">FONTE: SIASUS</p>
                </div>
            </div>
        </header>

        <!-- Summary Cards -->
        <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
            <div class="bg-white rounded-xl shadow-md p-6 fade-in hover:shadow-lg transition-shadow">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 font-medium">Total 2023</p>
                        <p class="text-3xl font-bold text-blue-600">5,279</p>
                    </div>
                    <div class="bg-blue-100 p-3 rounded-full">
                        <i class="fas fa-calendar-alt text-blue-600 text-xl"></i>
                    </div>
                </div>
                <div class="mt-4">
                    <p class="text-sm text-gray-500">Procedimentos realizados</p>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md p-6 fade-in hover:shadow-lg transition-shadow">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 font-medium">Total 2024</p>
                        <p class="text-3xl font-bold text-green-600">11,628</p>
                    </div>
                    <div class="bg-green-100 p-3 rounded-full">
                        <i class="fas fa-chart-line text-green-600 text-xl"></i>
                    </div>
                </div>
                <div class="mt-4">
                    <p class="text-sm text-gray-500">Procedimentos realizados (+120%)</p>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md p-6 fade-in hover:shadow-lg transition-shadow">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-gray-500 font-medium">Unidades</p>
                        <p class="text-3xl font-bold text-purple-600">2</p>
                    </div>
                    <div class="bg-purple-100 p-3 rounded-full">
                        <i class="fas fa-hospital text-purple-600 text-xl"></i>
                    </div>
                </div>
                <div class="mt-4">
                    <p class="text-sm text-gray-500">CAPS analisados</p>
                </div>
            </div>
        </div>

        <!-- Unit Selector -->
        <div class="mb-8">
            <div class="bg-white rounded-xl shadow-md p-6 fade-in">
                <h3 class="text-lg font-semibold mb-4 text-gray-700">Selecione as unidades para comparação</h3>
                <div class="flex flex-wrap gap-4">
                    <button id="all-units" class="px-4 py-2 bg-blue-600 text-white rounded-lg shadow hover:bg-blue-700 transition-colors">
                        Todas as unidades
                    </button>
                    <button id="unit-1953" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg shadow hover:bg-gray-300 transition-colors">
                        US 318 CAPS CPTRA
                    </button>
                    <button id="unit-28657" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-lg shadow hover:bg-gray-300 transition-colors">
                        US 277 CAPS ESPERANÇA
                    </button>
                </div>
            </div>
        </div>

        <!-- Main Charts -->
        <div class="grid grid-cols-1 lg:grid-cols-2 gap-8 mb-8">
            <!-- Monthly Comparison Chart -->
            <div class="bg-white rounded-xl shadow-md p-6 fade-in chart-container">
                <h3 class="text-lg font-semibold mb-4 text-gray-700">Comparativo Mensal de Procedimentos</h3>
                <div class="h-80">
                    <canvas id="monthlyComparisonChart"></canvas>
                </div>
            </div>

            <!-- Unit Distribution Chart -->
            <div class="bg-white rounded-xl shadow-md p-6 fade-in chart-container">
                <h3 class="text-lg font-semibold mb-4 text-gray-700">Distribuição por Unidade</h3>
                <div class="h-80">
                    <canvas id="unitDistributionChart"></canvas>
                </div>
            </div>
        </div>

        <!-- Yearly Growth Chart -->
        <div class="bg-white rounded-xl shadow-md p-6 mb-8 fade-in chart-container">
            <h3 class="text-lg font-semibold mb-4 text-gray-700">Crescimento Anual</h3>
            <div class="h-96">
                <canvas id="yearlyGrowthChart"></canvas>
            </div>
        </div>

        <!-- Procedure Details -->
        <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8 fade-in">
            <div class="p-6 border-b border-gray-200">
                <h3 class="text-lg font-semibold text-gray-700">Detalhamento de Procedimentos</h3>
                <p class="text-sm text-gray-500">Comparativo entre unidades e anos</p>
            </div>
            <div class="p-4 data-table">
                <table class="min-w-full divide-y divide-gray-200">
                    <thead class="bg-gray-50">
                        <tr>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Procedimento</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Unidade</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Set/23</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Out/23</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nov/23</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Set/24</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Out/24</th>
                            <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nov/24</th>
                        </tr>
                    </thead>
                    <tbody class="bg-white divide-y divide-gray-200">
                        <!-- Row for ACOLHIMENTO DIURNO -->
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ACOLHIMENTO DIURNO</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 318 CAPS CPTRA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">154</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">198</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">95</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">393</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">369</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">373</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ACOLHIMENTO DIURNO</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 277 CAPS ESPERANÇA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">9</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">11</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">13</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">12</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">117</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">218</td>
                        </tr>
                        
                        <!-- Row for ATENDIMENTO INDIVIDUAL -->
                        <tr class="bg-gray-50 hover:bg-gray-100">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ATENDIMENTO INDIVIDUAL</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 318 CAPS CPTRA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">466</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">407</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">289</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">666</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">563</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">489</td>
                        </tr>
                        <tr class="bg-gray-50 hover:bg-gray-100">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ATENDIMENTO INDIVIDUAL</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 277 CAPS ESPERANÇA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">219</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">212</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">275</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">160</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">92</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">202</td>
                        </tr>
                        
                        <!-- Row for ATENDIMENTO EM GRUPO -->
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ATENDIMENTO EM GRUPO</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 318 CAPS CPTRA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">474</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">548</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">531</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">1,046</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">827</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">655</td>
                        </tr>
                        <tr class="hover:bg-gray-50">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ATENDIMENTO EM GRUPO</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 277 CAPS ESPERANÇA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">339</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">302</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">386</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">250</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">679</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">766</td>
                        </tr>
                        
                        <!-- Row for ATENCAO AS SITUACOES DE CRISE -->
                        <tr class="bg-gray-50 hover:bg-gray-100">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ATENÇÃO ÀS SITUAÇÕES DE CRISE</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 318 CAPS CPTRA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">349</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">338</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">254</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">802</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">798</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">684</td>
                        </tr>
                        <tr class="bg-gray-50 hover:bg-gray-100">
                            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">ATENÇÃO ÀS SITUAÇÕES DE CRISE</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">US 277 CAPS ESPERANÇA</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">12</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">16</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">30</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">11</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">16</td>
                            <td class="px-6 py-4 whitespace-nowrap text-sm text-blue-600 font-semibold">17</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

        <!-- Top Procedures -->
        <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
            <!-- Top Procedures 2023 -->
            <div class="bg-white rounded-xl shadow-md p-6 fade-in chart-container">
                <h3 class="text-lg font-semibold mb-4 text-gray-700">Top 5 Procedimentos 2023</h3>
                <div class="h-80">
                    <canvas id="topProcedures2023Chart"></canvas>
                </div>
            </div>

            <!-- Top Procedures 2024 -->
            <div class="bg-white rounded-xl shadow-md p-6 fade-in chart-container">
                <h3 class="text-lg font-semibold mb-4 text-gray-700">Top 5 Procedimentos 2024</h3>
                <div class="h-80">
                    <canvas id="topProcedures2024Chart"></canvas>
                </div>
            </div>
        </div>

        <!-- Footer -->
        <footer class="bg-gray-100 rounded-xl p-6 text-center text-gray-600 text-sm">
            <p>Relatório gerado automaticamente pelo sistema SIASUS em 22/04/2025</p>
            <p class="mt-2">Secretaria Municipal de Saúde - Gerência de Saúde Mental</p>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Monthly Comparison Chart
            const monthlyCtx = document.getElementById('monthlyComparisonChart').getContext('2d');
            const monthlyComparisonChart = new Chart(monthlyCtx, {
                type: 'bar',
                data: {
                    labels: ['Set/23', 'Out/23', 'Nov/23', 'Set/24', 'Out/24', 'Nov/24'],
                    datasets: [
                        {
                            label: 'US 318 CAPS CPTRA',
                            data: [2405, 2802, 1988, 4553, 3836, 3407],
                            backgroundColor: 'rgba(59, 130, 246, 0.7)',
                            borderColor: 'rgba(59, 130, 246, 1)',
                            borderWidth: 1
                        },
                        {
                            label: 'US 277 CAPS ESPERANÇA',
                            data: [984, 893, 1130, 721, 1132, 2706],
                            backgroundColor: 'rgba(124, 58, 237, 0.7)',
                            borderColor: 'rgba(124, 58, 237, 1)',
                            borderWidth: 1
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        y: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: 'Quantidade de Procedimentos'
                            }
                        },
                        x: {
                            title: {
                                display: true,
                                text: 'Mês/Ano'
                            }
                        }
                    },
                    plugins: {
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return context.dataset.label + ': ' + context.raw.toLocaleString();
                                }
                            }
                        },
                        legend: {
                            position: 'top',
                        }
                    }
                }
            });

            // Unit Distribution Chart
            const unitCtx = document.getElementById('unitDistributionChart').getContext('2d');
            const unitDistributionChart = new Chart(unitCtx, {
                type: 'doughnut',
                data: {
                    labels: ['US 318 CAPS CPTRA', 'US 277 CAPS ESPERANÇA'],
                    datasets: [{
                        data: [17045, 7566],
                        backgroundColor: [
                            'rgba(59, 130, 246, 0.7)',
                            'rgba(124, 58, 237, 0.7)'
                        ],
                        borderColor: [
                            'rgba(59, 130, 246, 1)',
                            'rgba(124, 58, 237, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            position: 'right',
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    const label = context.label || '';
                                    const value = context.raw || 0;
                                    const total = context.dataset.data.reduce((a, b) => a + b, 0);
                                    const percentage = Math.round((value / total) * 100);
                                    return `${label}: ${value.toLocaleString()} (${percentage}%)`;
                                }
                            }
                        }
                    }
                }
            });

            // Yearly Growth Chart
            const yearlyCtx = document.getElementById('yearlyGrowthChart').getContext('2d');
            const yearlyGrowthChart = new Chart(yearlyCtx, {
                type: 'line',
                data: {
                    labels: ['Set', 'Out', 'Nov'],
                    datasets: [
                        {
                            label: '2023 - US 318 CAPS CPTRA',
                            data: [2405, 2802, 1988],
                            borderColor: 'rgba(59, 130, 246, 0.5)',
                            backgroundColor: 'rgba(59, 130, 246, 0.1)',
                            borderWidth: 2,
                            tension: 0.3,
                            fill: true
                        },
                        {
                            label: '2024 - US 318 CAPS CPTRA',
                            data: [4553, 3836, 3407],
                            borderColor: 'rgba(59, 130, 246, 1)',
                            backgroundColor: 'rgba(59, 130, 246, 0.2)',
                            borderWidth: 3,
                            tension: 0.3,
                            fill: true
                        },
                        {
                            label: '2023 - US 277 CAPS ESPERANÇA',
                            data: [984, 893, 1130],
                            borderColor: 'rgba(124, 58, 237, 0.5)',
                            backgroundColor: 'rgba(124, 58, 237, 0.1)',
                            borderWidth: 2,
                            tension: 0.3,
                            fill: true
                        },
                        {
                            label: '2024 - US 277 CAPS ESPERANÇA',
                            data: [721, 1132, 2706],
                            borderColor: 'rgba(124, 58, 237, 1)',
                            backgroundColor: 'rgba(124, 58, 237, 0.2)',
                            borderWidth: 3,
                            tension: 0.3,
                            fill: true
                        }
                    ]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    scales: {
                        y: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: 'Quantidade de Procedimentos'
                            }
                        },
                        x: {
                            title: {
                                display: true,
                                text: 'Mês'
                            }
                        }
                    },
                    plugins: {
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return context.dataset.label + ': ' + context.raw.toLocaleString();
                                }
                            }
                        },
                        legend: {
                            position: 'top',
                        }
                    }
                }
            });

            // Top Procedures 2023 Chart
            const top2023Ctx = document.getElementById('topProcedures2023Chart').getContext('2d');
            const topProcedures2023Chart = new Chart(top2023Ctx, {
                type: 'bar',
                data: {
                    labels: [
                        'ATEND. INDIVIDUAL (318)',
                        'ATEND. EM GRUPO (318)',
                        'ATENÇÃO CRISE (318)',
                        'PROMOÇÃO CONTRATUALIDADE (318)',
                        'PRÁTICAS EXPRESSIVAS (318)'
                    ],
                    datasets: [{
                        label: 'Procedimentos 2023',
                        data: [952, 1361, 641, 922, 584],
                        backgroundColor: [
                            'rgba(59, 130, 246, 0.7)',
                            'rgba(16, 185, 129, 0.7)',
                            'rgba(245, 158, 11, 0.7)',
                            'rgba(244, 63, 94, 0.7)',
                            'rgba(139, 92, 246, 0.7)'
                        ],
                        borderColor: [
                            'rgba(59, 130, 246, 1)',
                            'rgba(16, 185, 129, 1)',
                            'rgba(245, 158, 11, 1)',
                            'rgba(244, 63, 94, 1)',
                            'rgba(139, 92, 246, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    indexAxis: 'y',
                    scales: {
                        x: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: 'Quantidade'
                            }
                        }
                    },
                    plugins: {
                        legend: {
                            display: false
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return context.raw.toLocaleString() + ' procedimentos';
                                }
                            }
                        }
                    }
                }
            });

            // Top Procedures 2024 Chart
            const top2024Ctx = document.getElementById('topProcedures2024Chart').getContext('2d');
            const topProcedures2024Chart = new Chart(top2024Ctx, {
                type: 'bar',
                data: {
                    labels: [
                        'ATEND. EM GRUPO (318)',
                        'ATENÇÃO CRISE (318)',
                        'ATEND. INDIVIDUAL (318)',
                        'PROMOÇÃO CONTRATUALIDADE (318)',
                        'ATEND. EM GRUPO (277)'
                    ],
                    datasets: [{
                        label: 'Procedimentos 2024',
                        data: [2528, 2284, 1718, 1617, 1795],
                        backgroundColor: [
                            'rgba(16, 185, 129, 0.7)',
                            'rgba(245, 158, 11, 0.7)',
                            'rgba(59, 130, 246, 0.7)',
                            'rgba(244, 63, 94, 0.7)',
                            'rgba(139, 92, 246, 0.7)'
                        ],
                        borderColor: [
                            'rgba(16, 185, 129, 1)',
                            'rgba(245, 158, 11, 1)',
                            'rgba(59, 130, 246, 1)',
                            'rgba(244, 63, 94, 1)',
                            'rgba(139, 92, 246, 1)'
                        ],
                        borderWidth: 1
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    indexAxis: 'y',
                    scales: {
                        x: {
                            beginAtZero: true,
                            title: {
                                display: true,
                                text: 'Quantidade'
                            }
                        }
                    },
                    plugins: {
                        legend: {
                            display: false
                        },
                        tooltip: {
                            callbacks: {
                                label: function(context) {
                                    return context.raw.toLocaleString() + ' procedimentos';
                                }
                            }
                        }
                    }
                }
            });

            // Unit selector functionality
            const allUnitsBtn = document.getElementById('all-units');
            const unit1953Btn = document.getElementById('unit-1953');
            const unit28657Btn = document.getElementById('unit-28657');

            function updateCharts(show1953, show28657) {
                // Update monthly comparison chart
                monthlyComparisonChart.data.datasets[0].hidden = !show1953;
                monthlyComparisonChart.data.datasets[1].hidden = !show28657;
                monthlyComparisonChart.update();

                // Update yearly growth chart
                yearlyGrowthChart.data.datasets[0].hidden = !show1953;
                yearlyGrowthChart.data.datasets[1].hidden = !show1953;
                yearlyGrowthChart.data.datasets[2].hidden = !show28657;
                yearlyGrowthChart.data.datasets[3].hidden = !show28657;
                yearlyGrowthChart.update();

                // Update button styles
                if (show1953 && show28657) {
                    allUnitsBtn.classList.remove('bg-gray-200', 'text-gray-700');
                    allUnitsBtn.classList.add('bg-blue-600', 'text-white');
                    unit1953Btn.classList.remove('bg-blue-600', 'text-white');
                    unit1953Btn.classList.add('bg-gray-200', 'text-gray-700');
                    unit28657Btn.classList.remove('bg-blue-600', 'text-white');
                    unit28657Btn.classList.add('bg-gray-200', 'text-gray-700');
                } else if (show1953) {
                    allUnitsBtn.classList.remove('bg-blue-600', 'text-white');
                    allUnitsBtn.classList.add('bg-gray-200', 'text-gray-700');
                    unit1953Btn.classList.remove('bg-gray-200', 'text-gray-700');
                    unit1953Btn.classList.add('bg-blue-600', 'text-white');
                    unit28657Btn.classList.remove('bg-blue-600', 'text-white');
                    unit28657Btn.classList.add('bg-gray-200', 'text-gray-700');
                } else if (show28657) {
                    allUnitsBtn.classList.remove('bg-blue-600', 'text-white');
                    allUnitsBtn.classList.add('bg-gray-200', 'text-gray-700');
                    unit1953Btn.classList.remove('bg-blue-600', 'text-white');
                    unit1953Btn.classList.add('bg-gray-200', 'text-gray-700');
                    unit28657Btn.classList.remove('bg-gray-200', 'text-gray-700');
                    unit28657Btn.classList.add('bg-blue-600', 'text-white');
                }
            }

            allUnitsBtn.addEventListener('click', () => updateCharts(true, true));
            unit1953Btn.addEventListener('click', () => updateCharts(true, false));
            unit28657Btn.addEventListener('click', () => updateCharts(false, true));

            // Highlight rows on table hover
            const tableRows = document.querySelectorAll('tbody tr');
            tableRows.forEach(row => {
                row.addEventListener('mouseenter', () => {
                    const procedureName = row.querySelector('td:first-child').textContent.trim();
                    tableRows.forEach(r => {
                        if (r.querySelector('td:first-child').textContent.trim() === procedureName) {
                            r.classList.add('highlight');
                        }
                    });
                });
                
                row.addEventListener('mouseleave', () => {
                    tableRows.forEach(r => {
                        r.classList.remove('highlight');
                    });
                });
            });
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=saiane/caps" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>