-
Notifications
You must be signed in to change notification settings - Fork 0
/
hospital.html
276 lines (264 loc) · 9.25 KB
/
hospital.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
<html>
<head>
<title>Hospital Registration</title>
<link rel="icon" href="blockchain.png" type="image/icon type">
<link rel="stylesheet" href="./Style/hospital.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<!-- SideBar -->
<div id="fadeout" class="fadeout_block"></div>
<!-- <div class="background"></div> -->
<p id="upperbar" style="background-color: #212529; padding: 1rem; margin: 0rem;">
<button id="side-barbutton" class="btn" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseWidthExample" aria-expanded="false" aria-controls="collapseWidthExample">
<i class="fa-solid fa-bars fa-xl" style="color: #4a73ba;"></i>
</button>
</p>
<div id="wholeBody">
<div class="collapse collapse-horizontal" id="collapseWidthExample" style="height: 102vh;">
<div class="d-flex flex-column flex-shrink-0 p-3 text-bg-dark card-body" style="width: 400px; height: 92%;">
<a href="./hospital.html"
class="d-flex align-items-center mb-3 mb-md-0 me-md-auto text-white text-decoration-none">
<svg class="bi pe-none me-2" width="40" height="32">
<use xlink:href="#bootstrap"></use>
</svg>
<span class="fs-4">Secured Health Data</span>
</a>
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item">
<a href="doctor.html" class="nav-link text-white" aria-current="page">
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#home"></use>
</svg>
Doctor Registration
</a>
</li>
<li>
<a href="patient.html" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#speedometer2"></use>
</svg>
Patient Registration
</a>
</li>
<li>
<a href="./record.html" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#grid"></use>
</svg>
Make Medical Record
</a>
</li>
<li>
<a href="./patient_examine.html" class="nav-link text-white">
<svg class="bi pe-none me-2" width="16" height="16">
<use xlink:href="#people-circle"></use>
</svg>
Patient Examine
</a>
</li>
</ul>
<hr>
<div class="dropdown">
<a href="#" class="d-flex align-items-center text-white text-decoration-none dropdown-toggle"
data-bs-toggle="dropdown" aria-expanded="false">
<strong>More Features</strong>
</a>
<ul class="dropdown-menu dropdown-menu-dark text-small shadow">
<li><a class="dropdown-item" href="./hospital_details.html">Hospital's Details</a></li>
<li><a class="dropdown-item" href="./doctor_details.html">Doctor's Details</a></li>
<li><a class="dropdown-item" href="./patient_details.html">Patient's Detail</a></li>
<li><a class="dropdown-item" href="./examine_details.html">Examine Detail</a></li>
<li><a class="dropdown-item" href="./record_details.html">Record Detail</a></li>
</ul>
</div>
</div>
</div>
</div>
<!-- Other Work -->
<h1 id="main_heading">Hospital Registration</h1>
<script src="https://cdn.jsdelivr.net/npm/web3@1.2.8/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": "hospital_id",
"type": "uint256"
}
],
"name": "retreive_hospital_details",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "hospital_id",
"type": "uint256"
},
{
"internalType": "string",
"name": "_hospital_name",
"type": "string"
},
{
"internalType": "string",
"name": "_hospital_address",
"type": "string"
},
{
"internalType": "string",
"name": "_hospital_spec",
"type": "string"
}
],
"name": "store_doctor_details",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
var contractaddress = "0x10F33c2Bc172C3431175b468601105b6Eb2d85d6";
function add_details() {
var myContract = new web3.eth.Contract(abi, contractaddress, {
from: account,
gasPrice: "5000000",
gas: "500000",
});
var ds1 = document.getElementById("addr").value;
var ds2 = document.getElementById("spec").value;
var tname = document.getElementById("name1").value;
var id = document.getElementById("id1").value;
var result = myContract.methods
.store_doctor_details(id, tname, ds1, ds2)
.send(function (err, result) {
if (err) {
console.log(err);
}
if (result!==NULL) {
document.getElementById("result").innerHTML = result;
}
});
}
function show_details() {
var myContract = new web3.eth.Contract(abi, contractaddress, {
from: account,
gasPrice: "5000000",
gas: "500000",
});
var idd = document.getElementById("tid").value;
var result = myContract.methods
.retreive_hospital_details(idd)
.call(function (err, result) {
if (err) {
console.log(err);
}
if (result) {
document.getElementById("get_name").innerHTML = result[0];
document.getElementById("get_addr").innerHTML = result[1];
document.getElementById("get_spec").innerHTML = result[2];
}
});
}
function del_details() {
var myContract = new web3.eth.Contract(abi, contractaddress, {
from: account,
gasPrice: "5000000",
gas: "500000",
});
var bid = document.getElementById("bid1").value;
var result = myContract.methods
.burnMyToken(bid)
.send(function (err, result) {
if (err) {
console.log(err);
}
});
}
</script>
<div id="formblock">
<form>
<table style="width: 100%">
<tr>
<td>Enter Hospital Id:</td>
<td><input type="text" id="id1" name="id1" /></td>
</tr>
<tr>
<td>Hospital Name:</td>
<td><input type="text" id="name1" name="name1" /></td>
</tr>
<tr>
<td>Hospital Address:</td>
<td><input type="text" id="addr" name="addr" /></td>
</tr>
<tr>
<td>Hospital Specification:</td>
<td><input type="text" id="spec" name="spec" /></td>
</tr>
</table>
<input type="button" onclick="add_details()" class="btn btn-primary btn-ghost" value="Register"
style="margin-left: 20%; margin-top: 40px;" />
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"
integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js"
integrity="sha384-cuYeSxntonz0PPNlHhBs68uyIAVpIIOZZ5JqeqvYYIcEL727kskC66kF92t6Xl2V"
crossorigin="anonymous"></script>
<script src="https://kit.fontawesome.com/24c1065ad6.js" crossorigin="anonymous"></script>
<script src="./Javascript/fadeout.js"></script>
</body>
</html>