-
Notifications
You must be signed in to change notification settings - Fork 0
/
patient.html
343 lines (315 loc) · 7.98 KB
/
patient.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
343
<html>
<head>
<title>Register Patient</title>
</head>
<body>
<p><a href="hospital.html"><button type="submit" class="hidden" style='margin-right:16px'>Hospital Registration</button></a><a href="doctor.html"><button type="submit" class="hidden" style='margin-right:16px'>Doctor Registration</button></a><a href="patient_details.html"><button type="submit" class="hidden" style='margin-right:16px'>View Patient Details</button></a><a href="record_details.html"><button type="submit" class="hidden" style='margin-right:16px'>View Medical Record</button></a><a href="examine_details.html"><button type="submit" class="hidden" style='margin-right:16px'>View Patient Examine details</button></a></p>
<h1>Patient Registration</h1>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.js"></script>
<script>
var account;
window.addEventListener('load', async () => {
if (typeof window.ethereum !== 'undefined') {
console.log("MetaMask is Available :) !");
}
// Modern DApp browsers
if (window.ethereum) {
window.web3 = new Web3(ethereum);
// To prevent the page reloading when the MetaMask network changes
ethereum.autoRefreshOnNetworkChange = false;
// To Capture the account details from MetaMask
const accounts = await ethereum.enable();
account = accounts[0];
}
// Legacy DApp browsers
else if (window.web3) {
//window.web3 = new Web3(web3.currentProvider);
window.web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/cbd9dc11b30147e9a2cc974be655ef7c"));
}
// Non-DApp browsers
else {
console.log('Non-Ethereum browser detected. Please install MetaMask');
}
});
var abi = [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "patient_id",
"type": "uint256"
}
],
"name": "retreive_attendant_details",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "patient_id",
"type": "uint256"
}
],
"name": "retreive_patient_details",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "patient_id",
"type": "uint256"
},
{
"internalType": "string",
"name": "_attendant_name",
"type": "string"
},
{
"internalType": "string",
"name": "_attendant_relation",
"type": "string"
},
{
"internalType": "uint256",
"name": "_attendant_phn_no",
"type": "uint256"
}
],
"name": "store_attendant_details",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "patient_id",
"type": "uint256"
},
{
"internalType": "string",
"name": "_patient_name",
"type": "string"
},
{
"internalType": "uint256",
"name": "_age",
"type": "uint256"
},
{
"internalType": "string",
"name": "_gender",
"type": "string"
},
{
"internalType": "string",
"name": "_height",
"type": "string"
},
{
"internalType": "uint256",
"name": "_weight",
"type": "uint256"
},
{
"internalType": "string",
"name": "_patient_address",
"type": "string"
},
{
"internalType": "uint256",
"name": "_phone_no",
"type": "uint256"
},
{
"internalType": "string",
"name": "_email_id",
"type": "string"
},
{
"internalType": "uint256",
"name": "_date",
"type": "uint256"
}
],
"name": "store_patient_details",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
var contractaddress = '0x9125Fd4Ee671F0B53F5b145efE6101A0B7Aa1bfB';
function add_details() {
var myContract = new web3.eth.Contract(abi,contractaddress, {from: account, gasPrice: '5000000', gas: '5000000'});
var ds1 = document.getElementById("age").value;
var ds2 = document.getElementById("gen").value;
var ds3 = document.getElementById("hght").value;
var ds4 = document.getElementById("weig").value;
var ds5 = document.getElementById("addr").value;
var ds6 = document.getElementById("pno").value;
var ds7 = document.getElementById("email").value;
var ds8 = document.getElementById("date").value;
var tname = document.getElementById("name1").value;
var id = document.getElementById("id1").value;
var ads1 = document.getElementById("rel").value;
var ads2 = document.getElementById("apno").value;
var aname = document.getElementById("aname1").value;
var aid = document.getElementById("id2").value;
var result = myContract.methods.store_patient_details(id,tname,ds1,ds2,ds3,ds4,ds5,ds6,ds7,ds8).send(function (err, result) {
if (err) { console.log(err); }
});
var result = myContract.methods.store_attendant_details(aid,aname,ads1,ads2).send(function (err, result) {
if (err) { console.log(err); }
});
}
</script>
<h2>Register Patient</h2>
<form>
<table style="width:25%">
<tr>
<td>Enter Patient Id:</td>
<td><input type="text" id="id1" name="id1"></td>
</tr>
<tr>
<td> Patient Name:</td>
<td><input type="text" id="name1" name="name1"></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" id="age" name="age"></td>
</tr>
<tr>
<td>Gender:</td>
<td><input type="text" id="gen" name="gen"></td>
</tr>
<tr>
<td>Height(in ft):</td>
<td><input type="text" id="hght" name="hght"></td>
</tr>
<tr>
<td>Weight(in kg):</td>
<td><input type="text" id="weig" name="weig"></td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" id="addr" name="addr"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" id="pno" name="pno"></td>
</tr>
<tr>
<td>Email Id:</td>
<td><input type="text" id="email" name="email"></td>
</tr>
<tr>
<td>Date:</td>
<td><input type="text" id="date" name="date"></td>
</tr>
</table>
</form>
<h2> Patient's Attendant Details</h2>
<form>
<table style="width:25%">
<tr>
<td>Enter Patient Id:</td>
<td><input type="text" id="id2" name="id2"></td>
</tr>
<tr>
<td> Attendant Name:</td>
<td><input type="text" id="aname1" name="aname1"></td>
</tr>
<tr>
<td>Attendant Relation:</td>
<td><input type="text" id="rel" name="rel"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" id="apno" name="apno"></td>
</tr>
</table>
</form>
<form>
<table style="width:25%">
<tr>
<td><input type="button" onclick="add_details()" value="Register"></td>
</tr>
</table>
</form>
<h3>To get details of a patient <a href="patient_details.html">Click Here</a></h3>
</body>
</html>