-
Notifications
You must be signed in to change notification settings - Fork 1
/
doctor_details.html
342 lines (298 loc) · 12.1 KB
/
doctor_details.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Doctor Details</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
background-image: url('images/booking.jpg');
background-repeat: repeat;
}
.container {
display: flex;
justify-content: space-between;
align-items: flex-start;
max-width: 800px;
margin-right: 100px;
margin: 50px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.doctor-details {
width: 45%;
}
.doctor-details img {
width: 200px;
border-radius: 50%;
margin-bottom: 20px;
}
.doctor-details h2 {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
.doctor-details p {
font-size: 16px;
margin-bottom: 10px;
color: #333; /* Set the color for regular text */
}
/* Styles for the Consultation Fee, Experience, and Availability */
.doctor-details .attribute-label {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-weight: bold;
font-size: 16px;
color: #111111; /* Set color for labels */
}
.doctor-details .attribute-value {
font-weight: normal;
color: #111111; /* Set color for values */
margin-bottom: 10px;
}
.appointment-details {
width: 45%;
}
.appointment-details h3 {
font-size: 20px;
margin-bottom: 10px;
}
.appointment-details label {
display: block;
margin-bottom: 8px;
}
.appointment-details input[type="text"] {
width: 100%;
padding: 8px;
margin-bottom: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
.book-now-button {
background-color: #673ab7;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
/* Popup container styles */
.popup-container {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
z-index: 1000;
}
.popup-container img {
width: 100px;
border-radius: 50%;
margin-bottom: 20px;
margin: 0 auto;
display: block;
}
/* Custom Alert Styles */
.custom-alert {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
justify-content: center;
align-items: center;
z-index: 999;
}
.custom-alert-content {
background-color: #f8d7da;
color: #721c24;
padding: 20px;
border-radius: 5px;
position: relative;
width: 300px;
}
.close-btn {
position: absolute;
top: 5px;
right: 10px;
font-size: 20px;
cursor: pointer;
}
</style>
</head>
<body>
<!-- Custom Alert Modal -->
<div id="customAlert" class="custom-alert">
<div class="custom-alert-content">
<span class="close-btn" onclick="closeCustomAlert()">×</span>
<p id="customAlertMessage"></p>
</div>
</div>
<div class="container">
<div class="doctor-details">
<img id="doctor-img" src="{imageUrl}" alt="Doctor Image">
<h2 id="doctor-name"></h2>
<p id="doctor-specialization" class="attribute-label">Specialization: <span
id="doctor-specialization-value" class="attribute-value"></span></p>
<div class="rating" id="doctor-rating">
<i class="fa fa-star"></i>
<span></span>
</div>
<p id="doctor-bio"></p>
<!-- Consultation Fee -->
<p class="attribute-label">Consultation Fee: <span id="doctor-consultation-fee" class="attribute-value"></span></p>
<!-- Experience -->
<p class="attribute-label">Experience: <span id="doctor-experience" class="attribute-value"></span></p>
<!-- Availability -->
<p class="attribute-label">Availability: <span id="doctor-availability"
class="attribute-value"></span></p>
</div>
<div class="appointment-details">
<h3>Choose your slot</h3>
<label for="appointment-date">Appointment Date:</label>
<input type="date" id="appointment-date" name="appointment-date" placeholder="Enter appointment date">
<label for="appointment-time">Appointment Time:</label>
<input type="time" id="appointment-time" name="appointment-time" placeholder="Enter appointment time">
<label for="remarks">Remarks:</label>
<input type="text" id="remarks" name="remarks" placeholder="Enter any remarks">
<label for="symptoms">Symptoms:</label>
<input type="text" id="symptoms" name="symptoms" placeholder="Enter symptoms">
<button class="book-now-button" onclick="bookAppointment()">Book Now</button>
</div>
</div>
<!-- Popup container -->
<div id="popup" class="popup-container">
<img src="images/check.gif" alt="Success Image">
<p>Appointment booked successfully! 🎉</p>
</div>
<script>
window.onload = function () {
// Extract doctor ID from the URL
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const doctorId = urlParams.get('id');
// Fetch doctor details using the doctor ID
fetch(`http://localhost:3000/doctor/${doctorId}`)
.then(response => {
if (response.ok) {
var docemail = response.DoctorEmail;
var imageUrl = "api/uploads/" + docemail + ".jpeg";
return response.json();
} else {
// Handle error response
throw new Error('Failed to fetch doctor details');
}
})
.then(doctorDetails => {
const docemail = doctorDetails.DoctorEmail;
const imageUrl = `api/uploads/${docemail}doctor.jpeg`;
// Set the doctor's image source
document.getElementById("doctor-img").src = imageUrl;// Replace with actual image property
document.getElementById("doctor-name").innerText = "Doctor Name: " + doctorDetails.DoctorName;
document.getElementById("doctor-specialization-value").innerText = doctorDetails.Specialization;
document.getElementById("doctor-consultation-fee").innerText = "₹ " + doctorDetails.ConsultationFee;
document.getElementById("doctor-experience").innerText = doctorDetails.Experience;
document.getElementById("doctor-availability").innerText = doctorDetails.Availability;
})
.catch(error => {
console.error('Error:', error);
// Handle error scenario, show error message or redirect to an error page
});
};
function bookAppointment() {
// Retrieve the patient details from session storage
var patientDetails = JSON.parse(sessionStorage.getItem('patientDetailss'));
// Check if patientDetails is not null and contains the patient ID
if (patientDetails && patientDetails.id) {
// Generate random 5-digit AppointmentId
const appointmentId = Math.floor(10000 + Math.random() * 90000);
// Retrieve PatientId from patientDetails
const patientId = patientDetails.id;
// Fetch other details from input fields
const appointmentDate = document.getElementById("appointment-date").value;
const appointmentTime = document.getElementById("appointment-time").value;
const currentDate = new Date();
if (new Date(appointmentDate) < currentDate) {
// Show custom alert
showCustomAlert("Appointment Date cannot be less than the current date");
return;
}
const remarks = document.getElementById("remarks").value;
const symptoms = document.getElementById("symptoms").value;
// Construct JSON object
const appointmentData = {
"AppointmentId": appointmentId,
"PatientId": patientId,
"AppointmentDate": appointmentDate,
"Symptoms": symptoms,
"AppointmentTime": appointmentTime,
"Remarks": remarks
};
// Send POST request to the server
fetch('http://localhost:3000/appointment/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(appointmentData)
})
.then(response => {
if (response.ok) {
// Show success popup
showPopup();
} else {
// Handle error response
throw new Error('Failed to book appointment');
}
})
.catch(error => {
console.error('Error:', error);
// Handle error scenario, show error message or retry option
});
}
}
function showPopup() {
// Display the popup container
const popup = document.getElementById("popup");
popup.style.display = "block";
// Close the popup after a delay (e.g., 3 seconds)
setTimeout(function () {
hidePopup();
}, 3000);
}
function hidePopup() {
// Hide the popup container
const popup = document.getElementById("popup");
popup.style.display = "none";
}
function showCustomAlert(message) {
// Display the custom alert modal
const customAlert = document.getElementById("customAlert");
const customAlertMessage = document.getElementById("customAlertMessage");
customAlertMessage.innerText = message;
customAlert.style.display = "flex";
// Close the custom alert after a delay (e.g., 3 seconds)
setTimeout(function () {
closeCustomAlert();
}, 3000);
}
function closeCustomAlert() {
// Hide the custom alert modal
const customAlert = document.getElementById("customAlert");
customAlert.style.display = "none";
}
</script>
</body>
</html>