-
Notifications
You must be signed in to change notification settings - Fork 0
/
find_doctor.html
128 lines (122 loc) · 6.3 KB
/
find_doctor.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
<!DOCTYPE html>
<html>
<head>
<title>FindDoctorPage</title>
<link rel="stylesheet" href="css\style9.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="split left">
<div class="userimg" >
<img src="other\avatar.png" style="width: 45%; height:60% ;padding: 15px; background-size: cover; border-radius: 110px;">
</div>
<div class="navbar">
<button class="btn" onclick="window.location.href='home.html'">About Me</button>
<button class="btn" onclick="window.location.href='prescription.html'">Past Prescriptions</button>
<button class="btn" onclick="window.location.href='testing.html'">Past testing</button>
<button class="btn" onclick="window.location.href='operation.html'">Past operations</button>
<button class="btn" onclick="window.location.href='review.html'">Past reviews</button>
<button class="btn" style="background-color: white;"onclick="window.location.href='find_doctor.html'">Find a new doctor</button>
<button class="btn" onclick="window.location.href='rate.html'">Rate it</button>
<button class="btn" onclick="window.location.href='recommenddoctor.html'">Recommend doctor</button>
</div>
</div>
<div class="split right" id="adddoctor">
<!-- <div class="doctor_card">
<div class="leftcard">
<div class="pic">
<img src="other\avatar.png" style="width:80%; padding-left:20% ;">
</div>
<div class="stars">
<span class="fa fa-star checked" style="font-size:20px ;"></span>
<span class="fa fa-star checked" style="font-size:20px ;"></span>
<span class="fa fa-star checked" style="font-size: 20px;"></span>
<span class="fa fa-star" style="font-size:20px ;"></span>
<span class="fa fa-star" style="font-size:20px ;"></span>
</div>
<div >
<button class="bookbtn">Book appointment</button>
<input type="text" name="popup" class="hide">
</div>
</div>
<div class="details">
<div>Name</div>
<div>Age</div>
<div>Gender</div>
<div>Hospital</div>
<div>Specialization</div>
<div>charges</div>
</div>
</div> -->
</div>
<script type="text/javascript" src="js\bookapointment.js"></script>
<script>
cnt=0;
let imgsrc='other\\avatar.png';
var myHeaders = new Headers();
// myHeaders.append("Authorization", `Token ${JSON.parse(localStorage.getItem('token'))}`);
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("http://localhost:8000/doctor/", requestOptions)
.then((response) => response.text())
.then((result) => {
let data = JSON.parse(result)
console.log(data);
data.forEach((elem) => {
console.log(elem);
const e1 = document.createElement('div');
let cnt=0;
let rates=["","","","",""];
let avg=(elem.availability_rating+elem.collaboration_rating+elem.communication_rating+elem.treatment_rating)/4;
console.log(avg/2);
for(i=1;i<=5;i++){
if(i<=avg){
rates[i-1]="checked";
}
}
e1.innerHTML=`
<div class="doctor_card">
<div class="leftcard">
<div class="pic">
<img src=${imgsrc} style="width:80%; padding-left:20% ;">
</div>
<div class="stars">
<span class="fa fa-star ${rates[0]}" style="font-size:20px ;"></span>
<span class="fa fa-star ${rates[1]}" style="font-size:20px ;"></span>
<span class="fa fa-star ${rates[2]}" style="font-size: 20px;"></span>
<span class="fa fa-star ${rates[3]}" style="font-size:20px ;"></span>
<span class="fa fa-star ${rates[4]}" style="font-size:20px ;"></span>
</div>
<div>
<button class="bookbtn" onclick="bookappoint(this,this.nextElementSibling,${elem.id})">Book appointment</button>
<input type="text" name="popup" class="hide" placeholder="Enter in yyyy-mm-dd format">
</div>
</div>
<div class="details">
<div>Name: ${elem.name}</div>
<div>Age: ${elem.age}</div>
<div>Gender: ${elem.gender}</div>
<div>Hospital: ${elem.hospital.name}</div>
<div>Specialization: ${elem.specialization}</div>
<div>Consultation fees: ${elem.consultation_charges}</div>
</div>
</div>
`
console.log(e1);
document.getElementById("adddoctor").appendChild(e1);
console.log(document.getElementById('adddoctor'));
cnt+=1;
});
const e2=document.createElement('div');
e2.innerHTML=`<div style="position:relative;top:100% ;height: 30px"></div>`;
document.getElementById("adddoctor").appendChild(e2);
})
.catch((error) => {
console.log(error)
});
</script>
</body>
</html>