File size: 33,228 Bytes
8af460e
 
 
 
 
 
 
 
 
41d34fe
 
bdd79d5
41d34fe
 
 
 
 
 
 
 
 
 
 
 
b91ee01
41d34fe
 
b91ee01
41d34fe
 
 
8af460e
b91ee01
 
8af460e
 
 
 
 
 
 
 
 
 
 
 
1771c99
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41d34fe
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9e3240
8af460e
 
 
 
 
 
e9e3240
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b45b638
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
b45b638
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04921e1
8af460e
b45b638
8af460e
 
 
 
 
 
 
 
 
d002e7a
8af460e
b45b638
8af460e
 
 
 
 
e9e3240
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9e3240
8af460e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
from streamlit_option_menu import option_menu
import random
from streamlit_echarts import st_pyecharts
from streamlit_echarts import st_echarts
from pyecharts.charts import Bar
from pyecharts.charts import Pie
from pyecharts import options as opts
import requests

ACCESS_TOKEN = "sl.u.AFthKXj6h47zwLFIL7K_Pmj2a1WrN1H4XPY1vU7j_Umw9O52HqXTZ1ksOkYLdOeFgG3-OhFXRmmVCAuqNCrB2jTaLwhZfqMn-2l7T7DFmzZiVjKqdWt6Rhm5NFKewKocXLnEBVlRDaDmD3scjsyPY6rSxKaAI3pHPB7G9w3aKlwQzfCEbyf3LMqBgawcopqzFOlbzdQqgUAfTgTGfQ47TSavObixEvVc2vzK1k7ZxO7O0I-ivIhnrrDv6r53sGFQ2UDqS_Nyv-f032lvkXwa-FH5-3GwGQajbTDnxOzpt9KWvQ5pJCuXvb865DX8rONOmZ_jyqgkY5O8TsjkVwXWRDUwWgQ5hMjJbS42FWMnDfI9htvZQ6fm8vEM1GTBSp6m_JyYtZUsSlGMZynheJUt6EMxvspsd2woFz5NZN3w5EOM81wwNJdwg1hcB4p8vzJbecxetyz2NFiYMl-N6cV_WBIY35h6pdZGrIfcUYBBNaK5muT4bz2CjY4vXYo0TgkF14UyaWd3J44IDHKeIvT8nroeOks3VvTohjuAMtgNm6QfxN7AB1B0E75ipnurholM8I7zfLNejFgMzI2FcSGigDr7ovPKCj2x9ocwJSzJTNv7gbOI0Ot-1UQKCozKilo4HCR28cWjMqlcQ8cMFNwsc2pz7lbKhf9eEj6mn2r6vGnHVfXqjtbyXWn7Pj9V2n6CQD25DmabsR8JNboiafDH2mJHDSidvF_eF3bsPdkMQBARkPVHLDCNHasUErBTxeQgvUTdufcxfldlcMPFDUT7t3i0rPEohlwtUL8cyDk8SyTGzOVNUCwr9XI7YkkNkYV3_HUesJPf6P6R8EkqoiUC4wtkcFK9EJTQ8ZX5P9iGDNPpGt1k3FidfSdagRikJHCwqw4h2ffL68dcOZAmpXE3e-kNY5DUcr1_XuUxlS7ypQ1Q_oFNjj5r2C_qMU5ISNv-bWTKenNe7m2OLNGCeOaUANSpUFW1z61VI98nGUArRwdtni-cMWiyke1ZAk-0JS_0zkxjfXXM5dwFCvRix18HH39ARXJu3L3nYYdpH17EX7aA8IjVq3kMrQ5CBqk7G-ZbCVuEzsRFxgpYHtdsw1ex8m6al--g726r5h-9XnJgx0cdDKIBeRt8FQvAvp3ULWzuMHiL8cebClWCAc0nPv9skRyM39WvwSJuMF3S6c8QCBNKm3HEqiAL3HEdqRWsZIbCsx9rc8KVShHDANbkkf34fg4NzHNHfwYGvKN2fokWK7EnuEjn5LJ07x5iE8shnbFCSxBfKpk_tAfGlX-UuWg8cPbPJ2aP6MbTiKtWVkFI_vTkDGDEX_Ax9ToJbCpR8ieW7FLupSwdsHVHmvMio9EjW6jpvx-EENq6e8X1TImBDv8Q6H7-LkBZYbJ56iddzA0ItJqrNbhT5ygWZvrUL1oLgjwkgcwDd45bF2SLp_nDICj5eQ"
FILE_PATH = "/data2.xlsx"  # Chemin du fichier dans Dropbox

# Fonction pour télécharger le fichier Dropbox
def download_file_from_dropbox():
    headers = {
        "Authorization": f"Bearer {ACCESS_TOKEN}",
        "Dropbox-API-Arg": f'{{"path": "{FILE_PATH}"}}'
    }
    url = "https://content.dropboxapi.com/2/files/download"
    response = requests.post(url, headers=headers, stream=True)
    
    if response.status_code == 200:
        with open("data2.xlsx", "wb") as file:
            for chunk in response.iter_content(chunk_size=8192):
                file.write(chunk)
        return "data2.xlsx"
    else:
        st.error(f"Erreur de téléchargement Dropbox : {response.status_code}")
        return None



region_district = {
                "ADAMAOUA" : ["Bankim","Banyo","Belel","Dang","Djohong","Meiganga","Ngaoundal","Ngaoundere Rural","Ngaoundere Urbain","Tibati","Tignere"],
                "CENTRE" : ["Akonolinga","Awae","Ayos","Bafia","Biyem Assi","Cite Verte","Djoungolo","Ebebda","Efoulan","Elig Mfomo","Eseka","Esse","Evodoula","Mbalmayo","Mbandjock","Mbankomo","Mfou","Monatele","Mvog-Ada","Nanga Eboko","Ndikinimeki","Ngog Mapubi","Ngoumou","Nkolbisson","Nkolndongo","Ntui","Obala","Odza","Okola","Sa'a","Soa","Yoko"],
                "EST": ["Abong Mbang","Batouri","Belabo","Bertoua","Betare Oya","Doume","Garoua Boulai","Kette","Lomie","Mbang","Messamena","Moloundou","Ndelele","Nguelemendouka","Yokadouma"],
                "EXTREME NORD" : ["Bogo","Bourha","Fotokol","Gazawa","Goulfey","Guere","Guidiguis","Hina","Kaele","Kar Hay","Kolofata","Kousseri","Koza","Mada","Maga","Makary","Maroua 1","Maroua 2","Maroua 3","Meri","Mindif","Mogode","Mokolo","Mora","Moulvoudaye","Moutourwa","Mozogo","Pette","Roua","Tokombere","Vele","Waza","Yagoua"],
                "LITTORAL": ["Abo","Bangue","Boko","Bonassama","Cite Des Palmiers","Deido","Dibombari","Edea","Japoma","Logbaba","Loum","Manjo","Manoka","Mbanga","Melong","Ndom","New Bell","Ngambe","Njombe Penja","Nkondjock","Nkongsamba","Nylon","Pouma","Yabassi"],
                "NORD" : ["Bibemi","Figuil","Garoua I","Garoua II","Gaschiga","Golombe","Guider","Lagdo","Mayo Oulo","Ngong","Pitoa","Poli","Rey Bouba","Tchollire","Touboro"],
                "NORD OUEST" : ["Ako","Bafut","Bali","Bamenda","Bamenda 3","Batibo","Benakuma","Fundong","Kumbo East","Kumbo West","Mbengwi","Misaje","Ndop","Ndu","Njikwa","Nkambe","Nwa","Oku","Santa","Tubah","Wum"],
                "OUEST" : ["Bafang","Baham","Bamendjou","Bandja","Bandjoun","Bangangte","Bangourain","Batcham","Dschang","Foumban","Foumbot","Galim","Kekem","Kouoptamo","Malantouen","Massangam","Mbouda","Mifi","Penka Michel","Santchou"],
                "SUD" : ["Ambam","Djoum","Ebolowa","Kribi","Kye ossi","Lolodorf","Meyomessala","Mintom","Mvangan","Niete","Olamze","Sangmelima","Zoetele"],
                "SUD OUEST": ["Akwaya","Bakassi","Bamusso","Bangem","Buea","Ekondo Titi","Eyumodjock","Fontem","Konye","Kumba North","Kumba South","Limbe","Mamfe","Mbonge","Mundemba","Muyuka","Nguti","Tiko","Toko","Tombel","Wabane"]
}
liste_vaccin = ['YELLOW FEVER', 'Penta', 'VPO', 'VPI', 'nOPV2', 'TD','Mosquirix', 'PCV13', 'MEASLES', 'BCG', 'Janssen', 'Rota', 'MENINGO', 'HPV', 'Mencevax', 'Hepatite B']
liste_signe_symptome = {

    "code" : [    10022044,10001497,10002198,10002034,10002424,10061093,10002847,10002855,10003553,10049535,10069633,10060800,10006482,10005169,10005177,10019211,10002199,10011042,10010741,
                  10012373,10039906,10039083,10011703,10047555,10012174,10040844,10038687,10012735,10033371,10022086,10008479,10000081,10003239,10028411,10000084,10013968,10014625,10000087,
                  10015150,10041232,10042772,10028372,10016256,10037660,10033775,10008531,10025197,10018762,10019465,10018910,10039424,10020642,10020772,10071552,10021097,10023126,10022075,
                  10061218,10022437,10024264,10020937,10068319,10021089,10028813,10029864,10030095,10070774,10052139,10016029,10030302,10076569,10016062,10033799,10034037,10061428,10024855,
                  10017577,10061461,10005191,10042128,10011469,10037087,10052140,10052904,10037844,10020751,10058605,10080283,10030071,10039101,10022061,10030041,10055798,10040047,10015727,
                  10041349,10042241,10011878,10043071,10043089,10069381,10011224,10027327,10053425,10046735,10069555,10047340,10047513,100475132,10047700],

    "symptome" : ["Abcès au point d'injection", "Agitation", "Anaphylaxie", "Anémie", "Angioedème (généralisé ou localisé)", "Anomalies des nerfs crâniens", "Anurie",
                  "Anxiété", "Asthme", "Autres", "Baisse ou absence du contact visuel", "Bouffées de chaleur", "Bronchospame", "Cécité", "Cécité corticale",
                  "Céphalées", "Choc anaphylactique", "Clignement", "Conjonctivite", "Conscience altérée", "Convulsions", "Coryza", "Cyanose", "Déficit du champ visuel",
                  "Déshydratation", "Desquamation", "Détresse respiratoire", "Diarrhée", "Douleur", "Douleur au point d'injection", "Douleur thoracique", "Douleurs abdominales",
                  "Douleurs articulaires", "Douleurs musculaires", "Douleurs pelviennes", "Dyspnée", "Encéphalopathie", "Epigastralgie", "Erythème","Eternuement","Evanouissement/Syncope",
                  "Faiblesse motrice", "Fatigue / Prostration", "Fièvre", "Fourmillements", "Frissons", "Ganglion", "Geignement", "Hémiparésie", "Hémolyse", "Hypersalivation / hypersialorrhée",
                  "Hypersudation / Hyperhidrose", "Hypertension", "Hyporéactivité", "Hypotension", "Ictère", "Induration au point d'injection", "Inflammation", "Insomnie",
                  "Léthargie", "Lourdeur des membres", "Maux de gorge", "Modification des réflexes tendineux (hypo / hyper asymetrie)", "Nausée", "Nystagmus cérébelleux",
                  "Œdème", "Œdème des voies respiratoires hautes (lèvres, gorge, palais ou larynx)", "Œdème des yeux", "Œdème facial", "Oligurie", "Ophtalmoparésie", "Paralysie faciale",
                  "Paralysie flasque aiguë", "Parotidite", "Perte d'appétit (anorexie)", "Perte de connaissance", "Perte de l'équilibre", "Perturbations de la fonction érectile",
                  "Phlyctènes", "Plaies buccales", "Pleurs persistentes (> 3 heures)", "Prurit", "Prurit occulaire", "Raideur nucale", "Rash", "Réaction allergique", "Réflexe de moue succion",
                  "Refus de téter","Révulsion oculaire","Rhume", "Rougeur au point d'injection", "Rougeur des yeux", "Saignement (hémorrhagie)", "Sepsis", "Signes de Babinski", "Somnolence", "Stridor", "Surdité",
                  "Tachycardie, palpitations", "Tachypnée", "Temps de remplissage capillaire > 3s", "Toux", "Troubles du cycle menstruel", "Tuméfaction au point d'injection",
                  "Urticaire", "Utilisation excessive des muscles respiratoires accessoires", "Vertige", "Vision floue", "Voix rauque", "Vomissements"]
}

# Initialization
if 'data' not in st.session_state:
    st.session_state['data'] = None

if 'data_file_2' not in st.session_state:
    st.session_state['data_file_2'] = None

if 'data_2' not in st.session_state:
    st.session_state['data_2'] = None

if 'dataframe_mappi_region' not in st.session_state:
    st.session_state['dataframe_mappi_region'] = None

if st.session_state['data'] is None:
    st.warning("Veuillez entrer les données")
else :
    data = st.session_state['data']
    nav_bar1 = option_menu(None,
                       ["District silencieux", "Repartition des MAPPI"],
                        icons=['file-earmark-bar-graph-fill'],
                        menu_icon="cast",
                        default_index=0,
                        orientation="horizontal")


    ## gestion des districts silencieux
    if nav_bar1 == "District silencieux":
        region = []
        district = []
        col1, col2, col3 = st.columns([2,5,1])
        # creation du csv des district silencieux
        with col1 :
            for i in list(region_district.keys()):
                for k in region_district[f"{i}"] :
                    if data[data["admininfo/district"] == f"{k}".upper()].shape[0] == 0 :
                        region.append(i)
                        district.append(k)
            district_silencieux = {
                "Region" : region,
                "District": district
            }
            district_silencieux = pd.DataFrame(district_silencieux)
            st.write(district_silencieux)
            st.write("Nombre de district silencieux : ", district_silencieux.shape[0])
            st.write("Nombre de district present : ", len(list(data["admininfo/district"].unique())))

        # graphe de visualisation des district silencieux
        with col2:
            region_counts = district_silencieux.Region.value_counts().to_dict()
            regions = list(region_counts.keys())
            counts = list(region_counts.values())
            # Création du graphique
            # bar chart
            district_silencieux_bar = (
                Bar()
                .add_xaxis(regions)
                .add_yaxis("Nombre d'apparitions", counts)
                .set_global_opts(title_opts=opts.TitleOpts(title="Distribution des Régions"))
            )
            # Affichage avec Streamlit
            st_pyecharts(district_silencieux_bar, height="470px")

        with col3:
            # liste des district par region
            seleteur_1 = st.selectbox("Liste des district silencieux par region", options = list(district_silencieux["Region"].unique()))
            _ = []
            for i in list(district_silencieux.District[district_silencieux.Region == f"{seleteur_1}"]):
                _.append(i)
            st.write(_)

        st.write("___")

        col1, col2 = st.columns([1,4])
        with col2:
            # Création du pie chart complet (sans donut)
            district_silencieux_pie = (
                Pie()
                .add("", [list(z) for z in zip(regions, counts)])
                .set_global_opts(title_opts=opts.TitleOpts(title=""))
                .set_series_opts(
                    label_opts=opts.LabelOpts(formatter = "{b}: ({d}%)",
                                            position = "inside",  # Met le texte à l'intérieur du camembert
                                            font_size = 12,
                                            rotate = "radial")  # Affichage des pourcentages
                )
            )
            st_pyecharts(district_silencieux_pie, height="590px")
        with col1:
            # Taux de district silencieux par region
            st.subheader("Taux d'abstention par region")
            _ = []
            for i in list(region_district.keys()): # liste des regions
                # nombre de district de la region
                nbr_region_district = len(region_district[f"{i}"])
                # nombre de district silencieux de la region
                nbr_silenc_region_district = (district_silencieux[district_silencieux.Region == f"{i}"].shape[0])
                _.append((nbr_silenc_region_district/nbr_region_district)*100)

            taux_de_district_silencieux = {
                "region" : list(region_district.keys()),
                "taux de district silencieux" : [f"{round(k,2)}%" for k in _]
            }
            taux_de_district_silencieux = pd.DataFrame(taux_de_district_silencieux)
            st.dataframe(taux_de_district_silencieux, use_container_width = False)
        expander_2 = st.expander("District silentieux ", expanded=True)
        with expander_2:
            if st.session_state['data_file_2'] is None:
                data_file_2 = download_file_from_dropbox()
                st.session_state['data_file_2'] = data_file_2
            else:
                data_file_2 = st.session_state['data_file_2']

            if data_file_2:
                data_2 = pd.read_excel(data_file_2, engine="openpyxl")
                data_2['q6_district'] = data_2['q6_district'].str.replace('_', ' ')
                data_2['q6_district'] = data_2['q6_district'].str.replace('-', ' ')
                # determiner les district silencieux
                region_2 = []
                district_2 = []
                col1, col2, col3 = st.columns([2,5,1])
                # creation du csv des district silencieux
                with col1 :
                    for i in list(region_district.keys()):
                        for k in region_district[f"{i}"] :
                            if data_2[data_2["q6_district"] == f"{k}"].shape[0] == 0 :
                                region_2.append(i)
                                district_2.append(k)
                    district_silencieux_2 = {
                        "Region" : region_2,
                        "District": district_2
                    }
                col1, col2 = st.columns([5,9])
                with col1:
                    district_silencieux_2 = pd.DataFrame(district_silencieux_2)
                    st.write(district_silencieux_2)
                    st.write("Nombre de district silencieux : ", district_silencieux_2.shape[0])
                    st.write()
                with col2:
                    region_2_counts = district_silencieux_2.Region.value_counts().to_dict()
                    regions_2 = list(region_2_counts.keys())
                    counts_2 = list(region_2_counts.values())
                    district_silencieux_2_bar = (
                        Bar()
                        .add_xaxis(regions_2)
                        .add_yaxis("Nombre d'apparitions", counts_2)
                    )
                    # Affichage avec Streamlit
                    st_pyecharts(district_silencieux_2_bar, height="370px")
        
        st.write("___")
        if data_file_2:      
            expander_3 = st.expander("District silencieux absolue",expanded=True)
            with expander_3:
                st.header("Synthese")
                col1, col2 = st.columns([5,9])
                with col1:
                    df_common = district_silencieux.merge(district_silencieux_2, how='inner')
                    st.write(df_common)
                    st.write("Nombre de district silencieux : ", df_common.shape[0])
                    st.write()
                with col2:
                    region_2_counts = df_common .Region.value_counts().to_dict()
                    regions_2 = list(region_2_counts.keys())
                    counts_2 = list(region_2_counts.values())
                    district_silencieux_2_bar = (
                        Bar()
                        .add_xaxis(regions_2)
                        .add_yaxis("Nombre d'apparitions", counts_2)
                    )
                    # Affichage avec Streamlit
                    st_pyecharts(district_silencieux_2_bar, height="370px")


    if nav_bar1 == "Repartition des MAPPI":
        nav_bar2 = option_menu(None,
                            ["Carte" ,"Par region", "Par semaine épidémiologique", "Par vaccin"],
                                icons=['file-earmark-bar-graph-fill','file-earmark-bar-graph-fill', 'file-earmark-bar-graph-fill', 'file-earmark-bar-graph-fill'],
                                menu_icon="cast",
                                default_index=1,
                                orientation="horizontal")

        if nav_bar2 == "Par region" :
            expander_1 = st.expander("database Mappi par region", expanded=False)
            with expander_1:

                nbr_mappi_region = []

                for i in list(region_district.keys()):
                    x = data[data["admininfo/states"] == f"{i}"]
                    filtered_df = x[x['type_Vaccin'].isin(liste_vaccin)]
                    nbr_mappi_region.append(filtered_df.shape[0])

                # filtrage MAPPI grave
                filtered_df = data[data['type_Vaccin'].isin(liste_vaccin)] # filtrage du jeu de donnees
                # compter le nombre de mappi grave par region
                mappi_grave = []
                for i in list(region_district.keys()):
                    temp = filtered_df[filtered_df["admininfo/states"] == f"{i}"]
                    mappi_grave.append(temp[temp["seriousness/serious"] == 1.0].shape[0])
                # deduire le nombre de MAPPI non grave
                mappi_non_grave = []
                for i in range(0,10):
                    mappi_non_grave.append(nbr_mappi_region[i] - mappi_grave[i])

                # nombre de deces
                nbr_deces = []
                for i in list(region_district.keys()):
                    temp = filtered_df[filtered_df["admininfo/states"] == f"{i}"]
                    nbr_deces.append(temp[temp["seriousness/seriousnessdeath"] == 1.0].shape[0])

                dataframe_mappi_region = {
                        "region": list(region_district.keys()),
                        "Nombre de MAPPI" : nbr_mappi_region,
                        "Nombre de MAPPI non grave": mappi_non_grave,
                        "Nombre de MAPPI grave": mappi_grave,
                        "Nombre de deces" : nbr_deces
                    }
                dataframe_mappi_region = pd.DataFrame(dataframe_mappi_region)
                st.session_state['dataframe_mappi_region'] = dataframe_mappi_region

                st.dataframe(dataframe_mappi_region, use_container_width = True)
                col = st.columns(4)
                with col[0]:
                    st.write("Nombre totale de MAPPI : ", sum(nbr_mappi_region))
                with col[1]:
                    st.write("Nombre totale de MAPPI grave: ", sum(mappi_grave))
                with col[2]:
                    st.write("Nombre totale de MAPPI non grave: ", sum(mappi_non_grave))
                with col[3]:
                    st.write("Nombre de deces", sum(nbr_deces))
            st.write("___")

            col1, col2 = st.columns([4,1])
            with col2:
                # filtre
                form_1 = st.form("Filtre")
                with form_1:
                    seleteur_2 = st.multiselect("choisisez la/les regions", options=list(region_district.keys()))
                    btn_1 = st.form_submit_button("Appliquer", use_container_width=True)
                    btn_2 = st.form_submit_button("Reinitialiser", use_container_width=True)

            if btn_2:
                btn_1 = False

            with col1:
                if btn_1 and len(seleteur_2) > 0:
                    _1_ = []
                    _2_ = []
                    _3_ = []

                    for i in seleteur_2:
                        _1_.append(mappi_non_grave[list(region_district.keys()).index(i)])
                        _2_.append(mappi_grave[list(region_district.keys()).index(i)])
                        _3_.append(nbr_deces[list(region_district.keys()).index(i)])

                    district_silencieux_bar = (
                            Bar()
                            .add_xaxis(seleteur_2)
                            .add_yaxis("MAPPI NON GRAVE", _1_, itemstyle_opts=opts.ItemStyleOpts(color="#0F52BA"))
                            .add_yaxis("MAPPI GRAVE", _2_, itemstyle_opts=opts.ItemStyleOpts(color="#FF4B4B"))
                            .add_yaxis("Deces", _3_, itemstyle_opts=opts.ItemStyleOpts(color="#FFA62B"))
                            .set_global_opts(title_opts=opts.TitleOpts(title="Distribution des Régions"))
                        )
                        # Affichage avec Streamlit
                    st_pyecharts(district_silencieux_bar, height="470px")

                else:
                    district_silencieux_bar = (
                            Bar()
                            .add_xaxis(list(region_district.keys()))
                            .add_yaxis("MAPPI NON GRAVE", mappi_non_grave, itemstyle_opts=opts.ItemStyleOpts(color="#0F52BA"))
                            .add_yaxis("MAPPI GRAVE", mappi_grave, itemstyle_opts=opts.ItemStyleOpts(color="#FF4B4B"))
                            .add_yaxis("Deces", nbr_deces, itemstyle_opts=opts.ItemStyleOpts(color="#FFA62B"))
                            .set_global_opts(title_opts=opts.TitleOpts(title="Distribution des Régions"))
                        )
                        # Affichage avec Streamlit
                    st_pyecharts(district_silencieux_bar, height="470px")

        elif nav_bar2 == "Par semaine épidémiologique" :

            # filtrage MAPPI grave
            filtered_df = data[data['type_Vaccin'].isin(liste_vaccin)] # filtrage du jeu de donnees
            # liste des semaines vaccinales
            semaine_epidemiologique = list(filtered_df["Semaine_Epid"].unique())
            semaine_epidemiologique.sort()

            selecteur_3 = st.selectbox("Choisissez le type de vacin", options = liste_vaccin)
            # repartition des MAAPI par semaines vaccinal
            _ = []
            for i in semaine_epidemiologique:
                temp = filtered_df[(filtered_df["Semaine_Epid"] == f"{i}") & (filtered_df["type_Vaccin"] == selecteur_3)]
                _.append(temp.shape[0])
            # evolution des mappi par semaine vaccinal
            MAPPI_semaine_vaccinal_bar = (
                    Bar()
                    .add_xaxis(semaine_epidemiologique)
                    .add_yaxis("Nombre d'apparitions", _)
                    .set_global_opts(title_opts=opts.TitleOpts(title="Nombre de MAPPI par semaines épidémiologique"))
            )
            st_pyecharts(MAPPI_semaine_vaccinal_bar, width="100%", height="600px")

        elif nav_bar2 == "Par vaccin":
            selecteur_5 = st.selectbox("Choisir le Vaccin", options=liste_vaccin, index=0)
            col = st.columns(2)
            with col[0]:
                # filtre par sex:
                filtre_sex = st.toggle("Sexe")
            with col[1]:
                # filtre par tranche d'age
                list_tranche_dage = list(dict(data.Tranche_Age.value_counts()).keys())
                filtre_tranche_age = st.toggle("Tranche d'Age")


            # filtre des donnees selon les vaccin
            filtered_df = data[data['type_Vaccin'].isin(liste_vaccin)]
            # filtre selon le vaccin choisis
            filtered_df_2 = filtered_df[filtered_df["type_Vaccin"] == selecteur_5]
            # compte du nombre de MAPPI
            nbr_mappi = filtered_df_2.shape[0]
            # determination du nombre de mappi grave
            nbr_mappi_grave = filtered_df_2[filtered_df_2["seriousness/serious"] == 1.0].shape[0]
            # determination du nombre de mappi non grave
            nbr_mappi_non_grave = nbr_mappi - nbr_mappi_grave
            col = st.columns(3)
            with col[0]:
                st.write(f"Nombre de MAPPI : {nbr_mappi}")
            with col[1]:
                st.write(f"Nombre de mappi grave : {nbr_mappi_grave}")
            with col[2]:
                st.write(f"Nombre de mappi non grave : {nbr_mappi_non_grave}")
            st.write("___")

            if filtre_sex == True and filtre_tranche_age == False:
                ## filtre du nombre de mappi grave par sexe
                filtered_df_3 = filtered_df_2[filtered_df_2["seriousness/serious"] == 1.0]
                mappi_grave_homme = filtered_df_3[filtered_df_3["Sexe"] == "Masculin"].shape[0]
                mappi_grave_femme = filtered_df_3[filtered_df_3["Sexe"] != "Masculin"].shape[0]
                ## filtre mappi non grave par sexe
                filtered_df_3 = filtered_df_2[filtered_df_2["seriousness/serious"] == 2.0]
                mappi_non_grave_homme = filtered_df_3[filtered_df_3["Sexe"] == "Masculin"].shape[0]
                mappi_non_grave_femme = filtered_df_3[filtered_df_3["Sexe"] != "Masculin"].shape[0]
                col = st.columns(2)
                with col[0]:
                    st.subheader("HOMME")
                    ## graphe
                    Nbr_mappi_type_vaccin_homme = (
                        Bar()
                        .add_xaxis([selecteur_5])  # X-axis avec le vaccin sélectionné
                        .add_yaxis("Nombre de MAPPI non grave (HOMME)", [mappi_non_grave_homme])
                        .add_yaxis("Nombre de MAPPI grave (HOMME)", [mappi_grave_homme], itemstyle_opts=opts.ItemStyleOpts(color="#FF4B4B"))
                    )

                    # Affichage avec Streamlit
                    st_pyecharts(Nbr_mappi_type_vaccin_homme, height="470px")

                with col[1]:
                    st.subheader("FEMME")
                    Nbr_mappi_type_vaccin_femme = (
                        Bar()
                        .add_xaxis([selecteur_5])  # X-axis avec le vaccin sélectionné
                        .add_yaxis("Nombre de MAPPI non grave (FEMME)", [mappi_non_grave_femme])
                        .add_yaxis("Nombre de MAPPI grave (FEMME)", [mappi_grave_femme], itemstyle_opts=opts.ItemStyleOpts(color="#FF4B4B"))
                    )

                    # Affichage avec Streamlit
                    st_pyecharts(Nbr_mappi_type_vaccin_femme, height="470px")

            elif filtre_sex == False and filtre_tranche_age == True:
                _0_1_grave = []
                _1_5_grave = []
                _5_15_grave = []
                _15_18_grave = []
                _18_25_grave = []
                _25_35_grave = []
                _35_45_grave = []
                _45_55_grave = []
                _55_65_grave = []
                _65etPlus_grave = []

                _0_1_non_grave = []
                _1_5_non_grave = []
                _5_15_non_grave = []
                _15_18_non_grave = []
                _18_25_non_grave = []
                _25_35_non_grave = []
                _35_45_non_grave = []
                _45_55_non_grave = []
                _55_65_non_grave = []
                _65etPlus_non_grave = []

                filtered_df_3 = filtered_df_2[filtered_df_2["seriousness/serious"] == 1.0]
                filtered_df_4 = filtered_df_2[filtered_df_2["seriousness/serious"] == 2.0]
                for i in list_tranche_dage:
                    _ = filtered_df_3[filtered_df_3.Tranche_Age == f"{i}"].shape[0]

                    if i == '[0-1[':
                        _0_1_grave.append(_)
                    elif i == '[01-05[':
                        _1_5_grave.append(_)
                    elif i == '[05-15[':
                        _5_15_grave.append(_)
                    elif i == '[15-18[':
                        _15_18_grave.append(_)
                    elif i == '[18-25[':
                        _18_25_grave.append(_)
                    elif i == '[25-35[':
                        _25_35_grave.append(_)
                    elif i == '[35-45[':
                        _35_45_grave.append(_)
                    elif i == '[45-55[':
                        _45_55_grave.append(_)
                    elif i == '[55-65[':
                        _55_65_grave.append(_)
                    elif i == '65etPlus':
                        _65etPlus_grave.append(_)

                for i in list_tranche_dage:
                    _ = filtered_df_4[filtered_df_4.Tranche_Age == f"{i}"].shape[0]

                    if i == '[0-1[':
                        _0_1_non_grave.append(_)
                    elif i == '[01-05[':
                        _1_5_non_grave.append(_)
                    elif i == '[05-15[':
                        _5_15_non_grave.append(_)
                    elif i == '[15-18[':
                        _15_18_non_grave.append(_)
                    elif i == '[18-25[':
                        _18_25_non_grave.append(_)
                    elif i == '[25-35[':
                        _25_35_non_grave.append(_)
                    elif i == '[35-45[':
                        _35_45_non_grave.append(_)
                    elif i == '[45-55[':
                        _45_55_non_grave.append(_)
                    elif i == '[55-65[':
                        _55_65_non_grave.append(_)
                    elif i == '65etPlus':
                        _65etPlus_non_grave.append(_)

                # afficher la figure
                col = st.columns(2)
                with col[1]:
                    st.subheader("Mappi Grave")
                    Nbr_mappi_tranche_age_grave = (
                        Bar()
                        .add_xaxis([selecteur_5])
                        .add_yaxis("[0-1[", _0_1_grave)
                        .add_yaxis("[1-5[", _1_5_grave)
                        .add_yaxis("[5-15[", _5_15_grave)
                        .add_yaxis("[12-18[", _15_18_grave)
                        .add_yaxis("[18-25[", _18_25_grave)
                        .add_yaxis("[25-35[", _25_35_grave)
                        .add_yaxis("[35-45[", _35_45_grave)
                        .add_yaxis("[45-55[", _45_55_grave)
                        .add_yaxis("[55-65[", _55_65_grave)
                        .add_yaxis("65etPlus", _65etPlus_grave)
                    )
                    # Affichage avec Streamlit
                    st_pyecharts(Nbr_mappi_tranche_age_grave, height="470px")
                with col[0]:
                    st.subheader("Mappi non Grave")
                    Nbr_mappi_tranche_age_non_grave = (
                        Bar()
                        .add_xaxis([selecteur_5])  # Doit être une liste
                        .add_yaxis("[0-1[", _0_1_non_grave)
                        .add_yaxis("[1-5[", _1_5_non_grave)
                        .add_yaxis("[5-15[", _5_15_non_grave)
                        .add_yaxis("[12-18[", _15_18_non_grave)
                        .add_yaxis("[18-25[", _18_25_non_grave)
                        .add_yaxis("[25-35[", _25_35_non_grave)
                        .add_yaxis("[35-45[", _35_45_non_grave)
                        .add_yaxis("[45-55[", _45_55_non_grave)
                        .add_yaxis("[55-65[", _55_65_non_grave)
                        .add_yaxis("65etPlus", _65etPlus_non_grave)
                    )
                    # Affichage avec Streamlit
                    st_pyecharts(Nbr_mappi_tranche_age_non_grave, height="470px")

            elif  filtre_sex == True and filtre_tranche_age == True:
                filtre_sex = False
            else:
                # Création du graphique
                Nbr_mappi_type_vaccin = (
                    Bar()
                    .add_xaxis([selecteur_5])  # Doit être une liste
                    .add_yaxis("Nombre de MAPPI non grave", [nbr_mappi_non_grave])
                    .add_yaxis("Nombre de MAPPI grave", [nbr_mappi_grave], itemstyle_opts=opts.ItemStyleOpts(color="#FF4B4B"))
                    .set_global_opts(title_opts=opts.TitleOpts(title="Distribution des MAPPI par Vaccin"))
                )

                # Affichage avec Streamlit
                st_pyecharts(Nbr_mappi_type_vaccin, height="470px")

        elif nav_bar2 == "Carte":
            latitude = []
            longitude = []
            selecteur_6 = st.selectbox("Choisir le Vaccin", options=liste_vaccin)
            # filtre par vaccin
            filtered_df = data[data['type_Vaccin'].isin(liste_vaccin)]
            # filtre sur le vaccin specifique
            filtered_df_2 = filtered_df[filtered_df['type_Vaccin'] == selecteur_6]

            st.map(filtered_df_2, latitude= "_gps_beginning_latitude", longitude= "_gps_beginning_longitude")