VIATEUR-AI commited on
Commit
5b7d3da
·
verified ·
1 Parent(s): 4250942

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +73 -0
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # =========================
4
+ # DATABASE YA HOSPITALS MU RWANDA (with GPS + specialty)
5
+ # =========================
6
+ hospitals_data = [
7
+ {"name": "King Faisal Hospital", "province": "Kigali City", "district": "Gasabo", "sector": "Kacyiru",
8
+ "contact": "+250788123200", "email": "info@kingfaisalhosp.rw", "gps": "-1.949,30.089", "specialty": ["General","Maternity","Surgery"]},
9
+ {"name": "CHUK", "province": "Kigali City", "district": "Nyarugenge", "sector": "Nyarugenge",
10
+ "contact": "", "email": "", "gps": "-1.950,30.058", "specialty": ["General","Pediatrics","Emergency"]},
11
+ {"name": "Gahini District Hospital", "province": "Eastern Province", "district": "Kayonza", "sector": "Gahini",
12
+ "contact": "0781403761", "email": "gahini.hospital@moh.gov.rw", "gps": "-2.019,30.576", "specialty": ["General","Orthopedic"]},
13
+ {"name": "Rwinkwavu District Hospital", "province": "Eastern Province", "district": "Kayonza", "sector": "Rwinkwavu",
14
+ "contact": "0788358810", "email": "rwinkwavu.hospital@moh.gov.rw", "gps": "-2.151,30.565", "specialty": ["General","Maternity"]},
15
+ {"name": "CHUB (Butare University Teaching Hospital)", "province": "Southern Province", "district": "Huye", "sector": "Ngoma",
16
+ "contact": "", "email": "", "gps": "-2.590,29.739", "specialty": ["General","Pediatrics","Surgery"]},
17
+ {"name": "Shyira Hospital", "province": "Western Province", "district": "Nyamasheke", "sector": "Bushenge",
18
+ "contact": "", "email": "", "gps": "-2.482,29.155", "specialty": ["General","Maternity"]},
19
+ {"name": "Butaro Hospital", "province": "Northern Province", "district": "Burera", "sector": "Butaro",
20
+ "contact": "", "email": "", "gps": "-1.641,29.893", "specialty": ["General","Oncology","Pediatrics"]}
21
+ # Ongeraho hospitals zose wifuza, GPS na specialty
22
+ ]
23
+
24
+ # =========================
25
+ # FUNCTION YO GUSUBIZA IBIBAZO
26
+ # =========================
27
+ def healthcare_ai(query, province="", district="", specialty=""):
28
+ """
29
+ Ushobora kwandika symptom, province, district cyangwa specialty.
30
+ AI izasubiza ibitaro bihuye n'aho uri cyangwa specialty wifuza.
31
+ """
32
+ results = hospitals_data
33
+
34
+ # Filter ku province niba yatanzwe
35
+ if province:
36
+ results = [h for h in results if h["province"].lower() == province.lower()]
37
+ # Filter ku district niba yatanzwe
38
+ if district:
39
+ results = [h for h in results if h["district"].lower() == district.lower()]
40
+ # Filter ku specialty niba yatanzwe
41
+ if specialty:
42
+ results = [h for h in results if specialty.lower() in [s.lower() for s in h["specialty"]]]
43
+ # Filter ku query keyword (hospital name / symptom keyword)
44
+ if query:
45
+ results = [h for h in results if query.lower() in h["name"].lower() or query.lower() in h["district"].lower() or query.lower() in h["sector"].lower()]
46
+
47
+ if not results:
48
+ return "Ntibitaro bibonetse. Ongera ugerageze keyword, province, district cyangwa specialty."
49
+
50
+ # Format response
51
+ response = "🏥 Ibitaro biboneka:\n\n"
52
+ for h in results:
53
+ response += f"🏥 {h['name']}\n📍 Intara: {h['province']}\n📍 Akarere: {h['district']}\n📍 Umurenge: {h['sector']}\n📞 Contact: {h['contact'] if h['contact'] else 'N/A'}\n📧 Email: {h['email'] if h['email'] else 'N/A'}\n🌐 GPS: {h['gps']}\n⭐ Specialty: {', '.join(h['specialty'])}\n\n"
54
+
55
+ return response
56
+
57
+ # =========================
58
+ # GRADIO INTERFACE
59
+ # =========================
60
+ iface = gr.Interface(
61
+ fn=healthcare_ai,
62
+ inputs=[
63
+ gr.Textbox(label="Andika symptom, hospital name, district cyangwa province", placeholder="Urugero: Kigali, Gahini, CHUK..."),
64
+ gr.Dropdown(label="Province (optional)", choices=[""] + [h["province"] for h in hospitals_data], type="value"),
65
+ gr.Textbox(label="District (optional)", placeholder="Akarere niba ushaka"),
66
+ gr.Dropdown(label="Specialty (optional)", choices=[""] + ["General","Maternity","Pediatrics","Surgery","Orthopedic","Psychiatric","Oncology"], type="value")
67
+ ],
68
+ outputs="text",
69
+ title="Rwanda Healthcare AI – GPS + Specialty",
70
+ description="Shaka ibitaro mu Rwanda. Ushobora kwandika symptom, hospital name, province, district, cyangwa specialty, AI ikagusubiza ibitaro bihuye n'ibyo ukeneye."
71
+ )
72
+
73
+ iface.launch()