-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_real_data.py
More file actions
152 lines (121 loc) Β· 5.79 KB
/
check_real_data.py
File metadata and controls
152 lines (121 loc) Β· 5.79 KB
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
#!/usr/bin/env python3
"""
Check real data from doctors and hospitals APIs
"""
import requests
import json
def show_doctors_data():
"""Show all doctors data from API"""
print("π¨ββοΈ DOCTORS DATA FROM API")
print("=" * 60)
url = "https://medeasy-backend-cgetg3arfvgfcjcq.westcentralus-01.azurewebsites.net/api/users/doctors"
try:
response = requests.get(url, timeout=10)
if response.status_code == 200:
data = response.json()
doctors = data.get('data', [])
print(f"Total doctors found: {len(doctors)}")
print()
for i, doctor in enumerate(doctors, 1):
print(f"Doctor {i}:")
print(f" Name: {doctor.get('name', 'N/A')}")
print(f" Specialization: {doctor.get('specialization', 'N/A')}")
print(f" Rating: {doctor.get('rating', 'N/A')}")
print(f" Experience: {doctor.get('experience', 'N/A')}")
print(f" Location: {doctor.get('location', 'N/A')}")
print(f" Phone: {doctor.get('phone', 'N/A')}")
print(f" Email: {doctor.get('email', 'N/A')}")
print(f" ID: {doctor.get('_id', 'N/A')}")
print()
else:
print(f"β Error: {response.status_code}")
except Exception as e:
print(f"β Error: {e}")
def show_hospitals_data():
"""Show all hospitals data from API"""
print("π₯ HOSPITALS DATA FROM API")
print("=" * 60)
url = "https://medeasy-backend-cgetg3arfvgfcjcq.westcentralus-01.azurewebsites.net/api/users/hospitals"
try:
response = requests.get(url, timeout=10)
if response.status_code == 200:
data = response.json()
hospitals = data.get('data', [])
print(f"Total hospitals found: {len(hospitals)}")
print()
for i, hospital in enumerate(hospitals, 1):
print(f"Hospital {i}:")
print(f" Name: {hospital.get('name', 'N/A')}")
print(f" City: {hospital.get('city', 'N/A')}")
print(f" Country: {hospital.get('country', 'N/A')}")
print(f" Rating: {hospital.get('rate', 'N/A')}")
print(f" Phone: {hospital.get('phone', 'N/A')}")
print(f" Established: {hospital.get('Established', 'N/A')}")
print(f" Address: {hospital.get('address', 'N/A')}")
print(f" ID: {hospital.get('_id', 'N/A')}")
print()
else:
print(f"β Error: {response.status_code}")
except Exception as e:
print(f"β Error: {e}")
def analyze_data_quality():
"""Analyze the quality of data from both APIs"""
print("π DATA QUALITY ANALYSIS")
print("=" * 60)
# Check doctors data quality
print("π¨ββοΈ DOCTORS DATA QUALITY:")
doctors_url = "https://medeasy-backend-cgetg3arfvgfcjcq.westcentralus-01.azurewebsites.net/api/users/doctors"
try:
response = requests.get(doctors_url, timeout=10)
if response.status_code == 200:
data = response.json()
doctors = data.get('data', [])
# Count missing fields
missing_name = sum(1 for d in doctors if not d.get('name'))
missing_spec = sum(1 for d in doctors if not d.get('specialization'))
missing_rating = sum(1 for d in doctors if not d.get('rating'))
missing_location = sum(1 for d in doctors if not d.get('location'))
print(f" Total doctors: {len(doctors)}")
print(f" Missing names: {missing_name}")
print(f" Missing specializations: {missing_spec}")
print(f" Missing ratings: {missing_rating}")
print(f" Missing locations: {missing_location}")
# Show specializations
specs = set(d.get('specialization', '') for d in doctors if d.get('specialization'))
print(f" Available specializations: {', '.join(specs)}")
except Exception as e:
print(f" β Error analyzing doctors data: {e}")
print()
# Check hospitals data quality
print("π₯ HOSPITALS DATA QUALITY:")
hospitals_url = "https://medeasy-backend-cgetg3arfvgfcjcq.westcentralus-01.azurewebsites.net/api/users/hospitals"
try:
response = requests.get(hospitals_url, timeout=10)
if response.status_code == 200:
data = response.json()
hospitals = data.get('data', [])
# Count missing fields
missing_name = sum(1 for h in hospitals if not h.get('name'))
missing_city = sum(1 for h in hospitals if not h.get('city'))
missing_country = sum(1 for h in hospitals if not h.get('country'))
missing_rating = sum(1 for h in hospitals if not h.get('rate'))
print(f" Total hospitals: {len(hospitals)}")
print(f" Missing names: {missing_name}")
print(f" Missing cities: {missing_city}")
print(f" Missing countries: {missing_country}")
print(f" Missing ratings: {missing_rating}")
# Show cities
cities = set(h.get('city', '') for h in hospitals if h.get('city'))
print(f" Available cities: {', '.join(cities)}")
except Exception as e:
print(f" β Error analyzing hospitals data: {e}")
if __name__ == "__main__":
print("π CHECKING REAL API DATA")
print("=" * 60)
# Show detailed data
show_doctors_data()
show_hospitals_data()
# Analyze data quality
analyze_data_quality()
print("\n" + "=" * 60)
print("β
API DATA CHECK COMPLETE")