-
Notifications
You must be signed in to change notification settings - Fork 0
/
doctor.html
192 lines (175 loc) · 5.63 KB
/
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
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
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body class="background">
<p><a href="hospital.html">
<button type="submit" class="hidden" style='margin-right:16px'>Hospital Registration</button></a><a href="patient.html">
<button type="submit" class="hidden" style='margin-right:16px'>Patient 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>
<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://goerli.infura.io/v3/0x903b71963A43AaDBC78CCA43d137Ba52dBF866a6"));
}
// Non-DApp browsers
else {
console.log('Non-Ethereum browser detected. Please install MetaMask');
}
});
var abi = [
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "doctor_id",
"type": "uint16"
}
],
"name": "retreive_doctor_details",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "string",
"name": "",
"type": "string"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint16",
"name": "doctor_id",
"type": "uint16"
},
{
"internalType": "string",
"name": "_doctor_name",
"type": "string"
},
{
"internalType": "string",
"name": "_doctor_specialisation",
"type": "string"
},
{
"internalType": "uint256",
"name": "_doctor_ph_no",
"type": "uint256"
},
{
"internalType": "string",
"name": "_doctor_address",
"type": "string"
}
],
"name": "store_doctor_details",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
var contractaddress = '0x466147A21E54F6a7A22Cc86004ab5841C00bE41f';
function add_details() {
var myContract = new web3.eth.Contract(abi,contractaddress, {from: account, gasPrice: '5000000', gas: '500000'});
var ds1 = document.getElementById("spec").value;
var ds2 = document.getElementById("pno").value;
var ds3 = document.getElementById("addr").value;
var tname = document.getElementById("name1").value;
var id = document.getElementById("id1").value;
var result = myContract.methods.store_doctor_details(id,tname,ds1,ds2,ds3).send(function (err, result) {
if (err) { console.log(err); }
});
}
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_doctor_details(idd).call(function (err, result) {
if (err) { console.log(err); }
if (result) {
document.getElementById("get_name").innerHTML = result[0];
document.getElementById("get_spec").innerHTML = result[1];
document.getElementById("get_pno").innerHTML = result[2];
document.getElementById("get_addr").innerHTML = result[3];
}
});
}
</script>
<div class="heading">
<h1>Doctor Registration</h1>
<h2>Register Doctor</h2>
</div>
<div class="form-main">
<form class="entries">
<table style="width:25%">
<tr>
<td>Enter Doctor Id: </td>
<td><input type="text" id="id1" name="id1"></td>
</tr>
<tr>
<td> Doctor Name: </td>
<td><input type="text" id="name1" name="name1"></td>
</tr>
<tr>
<td>Doctor Specification: </td>
<td><input type="text" id="spec" name="spec"></td>
</tr>
<tr>
<td>Doctor Phone Number: </td>
<td><input type="text" id="pno" name="pno"></td>
</tr>
<tr>
<td>Doctor Address: </td>
<td><input type="text" id="addr" name="addr"></td>
</tr>
<tr>
<td><input class="btn" type="button" onclick="add_details()" value="Register"></td>
</tr>
</table>
</form>
</div>
<div class="last-heading">
<h3>To get details of a doctor <a href="doctor_details.html">Click Here</a></h3>
</div>
</body>
</html>