-
Notifications
You must be signed in to change notification settings - Fork 0
/
doctor_test.html
260 lines (224 loc) · 8.64 KB
/
doctor_test.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
<!DOCTYPE html>
<html>
<head>
<title>DoctorPage</title>
<link rel="stylesheet" href="doctor_style.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='doctor_home.html'">
About Me
</button>
<button
class="btn"
onclick="window.location.href='doctor_prescription.html'"
>
Past Prescriptions
</button>
<button
class="btn"
onclick="window.location.href='doctor_operation.html'"
>
Past Operations
</button>
<button class="btn"style="background-color: white" onclick="window.location.href='doctor_test.html'">
Past Medical Tests
</button>
<button class="btn" onclick="window.location.href='doctor_approveapp.html'">Approve Appointments</button>
<!-- <button class="btn" onclick="window.location.href='find_doctor.html'">Find a new doctor</button> -->
</div>
</div>
<!-- <div class="search">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<form class="example" action="action_page.php">
<input type="text" placeholder="llEnter the Patient ID" name="search">
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</div> -->
<div class="split right">
<div>
<div>
<button class="addbtn" onclick="fun('myModaladdm','buttnaddm','closeaddm')"id="buttnaddm">Suggest Test</button>
</div>
</div>
<div class="search">
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<div class="example" >
<input type="text" id="patientid" placeholder="Enter the Patient ID" name="search" />
<button onclick="show()"><i class="fa fa-search"></i></button>
</div>
</div>
<!-- <div>
<div class="details">
<div style="text-align: center" class="opdate"><b>25 Oct 2022</b></div>
<br />
<div><b>Medical Test ID: </b>#12345</div>
<div><b>Recommended by: </b>Dr Sani</div>
<div><b>Reason: </b>Leg Fracture</div>
<div><b>Total Cost: </b>₹2000</div>
<div><b>Discount Cost: </b>₹1599</div>
</div>
</div> -->
<div id="myModaladdm" class="modal">
<div class="modal-content">
<span id="closeaddm">×</span>
<!-- form -->
<div class="form-style-5">
<fieldset>
<legend><span class="number">1</span>Enter the Patient ID</legend>
<input id="patienttid" type="text" name="field1" placeholder="Patient ID...">
</fieldset>
<fieldset>
<legend><span class="number">2</span>Name of the Test</legend>
<table id="tests">
<tr>
<th>Name</th>
<th>Recommendation</th>
<th>Cost</th>
</tr>
</table>
<br>
<label for="testname" > Name of Medicine
<input id="testname" type="text" >
</label>
<label for="recomm">Recommendation :</label>
<input id="recomm" type="text" >
<label for="cost" > Cost
<input id="cost" type="number" >
</label>
<button onclick="addtest()">Add test</button>
</fieldset>
<!-- <fieldset>
<legend><span class="number">4</span>Expected Duration</legend>
<input type="text" name="field1" placeholder="In number of weeks">
</fieldset> -->
<button onclick="submittest()"> Submit test </button>
<h3 id="error" style="color: red;"></h3>
<h3 id="message" style="color: green;"></h3>
</div>
</div>
</div>
</div>
<script src="js\doctor.js"></script>
<script>
//simialrly for test get all tests of this patient(by every doctor) and then iterate on every test
function show(){
let pid=document.getElementById("patientid").value;
console.log(pid);
var myHeaders = new Headers();
myHeaders.append("Authorization", `Token ${localStorage.getItem('token')}`);
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch(`http://localhost:8000/medicaltests/${pid}`, requestOptions)
.then(response => response.text())
.then((result) =>{
let data = JSON.parse(result)
console.log(data);
data.forEach((patient)=>{
console.log(patient)
//we need to display all the operations differently
patient.tests.forEach((test)=>{
console.log(test)
const e1=document.createElement('div');
e1.innerHTML=`<div class="details">
<div style="text-align: center" class="opdate"><b>25 Oct 2022</b></div>
<br />
<div><b>Patient ID:</b> ${patient.patient}</div>
<div><b>Doctor ID:</b> ${patient.doctor}</div>
<div><b>Test Name:</b> ${test.name}</div>
<div><b>Recommended by:</b>${test.recommendation}</div>
<div><b>Cost:</b> ${test.cost}</div>
</div>`;
document.getElementsByClassName("split right")[0].appendChild(e1);
})
})
})
.catch(error => console.log('error', error));
}
function addtest(){
console.log('adding test has been called')
let name = document.getElementById("testname").value
let cost = document.getElementById("cost").value
let reco = document.getElementById("recomm").value
let table = document.getElementById("tests");
var row = table.insertRow();
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2)
cell1.innerHTML = name
cell2.innerHTML = reco
cell3.innerHTML = cost
}
function submittest(){
let patientID = document.getElementById("patienttid").value
// console.log(patientID)
// console.log(symptoms)
// console.log(followup)
// console.log(days)
if(patientID == "" ){
document.getElementById("error").innerHTML = "Fields are Missing"
return ;
}
let testData = []
let table = document.getElementById("tests");
for (var i = 1, row; row = table.rows[i]; i++) {
//iterate through rows
//rows would be accessed using the "row" variable assigned in the for loop
let name = row.cells[0].innerHTML
let rec = row.cells[1].innerHTML
let cost = row.cells[2].innerHTML
testData.push({
name : name,
recommendation : rec,
cost : cost
})
}
console.log(testData);
var myHeaders = new Headers();
myHeaders.append("Authorization", `Token ${localStorage.getItem('token')}`);
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"tests":testData,
"patient": patientID
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://localhost:8000/medicaltests/", requestOptions)
.then(response => response.text())
.then((result) => {
console.log(result)
console.log('done')
})
.catch(error => console.log('error', error));
}
</script>
</body>
</html>