-
Notifications
You must be signed in to change notification settings - Fork 0
/
records.sol
303 lines (231 loc) · 9.22 KB
/
records.sol
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
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Medical records
* @dev Store & retreive patient details in Medicalrecords
*/
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol";
contract Records is ERC721 {
mapping(uint256 => insurance) insurancelist;
mapping(uint256 => history) patienthistory;
mapping(uint256 => past) pasthistory;
mapping(uint256 => diag) diagnosis;
mapping(uint256 => treat) treatment;
mapping(uint256 => prev) prevdates;
mapping(uint256 => patient) patientlist;
struct patient{
uint256 patient_id;
}
patient p;
struct prev{
uint256 patient_id;
string previous;
}
prev pr;
struct insurance{
uint256 patient_id;
string applicable;
uint64 policy_no;
string insurer;
string policy_type;
string policy_limit;
}
insurance i;
struct history{
uint256 patient_id;
string complaints;
string duration;
}
history hi;
struct past{
uint256 patient_id;
string family_history;
string personal_history;
string drug_history;
}
past pa;
struct diag{
uint256 patient_id;
string diag_summary;
string prescription;
}
diag d;
struct treat{
string treatment;
string date_treatment;
uint256 doctor_id;
uint256 hospital_id;
string discharge;
string follow_up;
}
treat tr;
address owner;
/**
* @dev Create the Token by Passing the Name and Symbol to the ERC721 Constructor
*/
constructor() ERC721("AmritaMedicalCoin","AMC") public {
owner = 0x34d8bC94989BbE14BCfd98E0550201ba4970B776; //Address of Doctor
}
// modifier to give access only to doctor
modifier isOwner() {
require(msg.sender == owner, "Access is not allowed");
_;
}
/**
* @dev Function to display name of the token
*/
function namedecl() public view returns (string memory) {
//calling the Built-in function in ERC721
return name();
}
/**
* @dev Function to display symbol of the token
*/
function symboldecl() public view returns (string memory) {
//calling the Built-in function in ERC721
return symbol();
}
/**
* @dev Function to display total count of the token
*/
function totalSupplycount() public view returns (uint256) {
//calling the Built-in function in ERC721
return totalSupply();
}
/**
* @dev Function to mint token of medical record
* @param patient_id patient id
*/
function medical_record(uint256 patient_id)public{
//Calling the Built-in function in ERC721
_mint(msg.sender,patient_id);
patientlist[patient_id] = p;
}
/**
* @dev Store previous dates of records updated
* @param patient_id patient id
* @param _previous previous dates of records updated
*/
function previous_dates(uint256 patient_id,string memory _previous)public isOwner {
pr.previous = _previous;
prevdates[patient_id] = pr;
}
/**
* @dev Retreive previous dates of records updated
* @param patient_id patient id
* */
function get_previous_dates(uint256 patient_id)public view returns (string memory){
prev memory pr = prevdates[patient_id];
return (pr.previous);
}
/**
* @dev Store insurance details
* @param patient_id patient id
* @param _applicable is applicable or not
* @param _policy_no policy number
* @param _insurer name of insurer
* @param _policy_type type of policy
* @param _policy_limit limit of policy
*/
function insurance_details( uint256 patient_id,string memory _applicable,uint64 _policy_no,string memory _insurer,string memory _policy_type,string memory _policy_limit)public isOwner {
i.applicable = _applicable;
i.policy_no = _policy_no;
i.insurer = _insurer;
i.policy_type = _policy_type;
i.policy_limit = _policy_limit;
insurancelist[patient_id] = i;
}
/**
* @dev Retreive insurance details
* @param patient_id patient id
* */
function get_insurance(uint256 patient_id)public view returns (string memory,uint64,string memory,string memory,string memory){
insurance memory i = insurancelist[patient_id];
return (i.applicable, i.policy_no,i.insurer,i.policy_type,i.policy_limit);
}
/**
* @dev Store present illness details
* @param patient_id patient id
* @param _complaints complaints
* @param _duration duration of the complaint
*/
function present_illness(uint256 patient_id,string memory _complaints,string memory _duration)public isOwner {
hi.complaints = _complaints;
hi.duration = _duration;
patienthistory[patient_id] = hi;
}
/**
* @dev Retreive present illness details
* @param patient_id patient id
* */
function get_present_illness(uint256 patient_id)public view returns (string memory,string memory){
history memory hi = patienthistory[patient_id];
return (hi.complaints,hi.duration);
}
/**
* @dev Store past illness details
* @param patient_id patient id
* @param _family_history history of family illness
* @param _personal_history history of personal illness
* @param _drug_history history of drug usage
*/
function past_illness(uint256 patient_id,string memory _family_history,string memory _personal_history,string memory _drug_history)public isOwner {
pa.family_history = _family_history;
pa.personal_history = _personal_history;
pa.drug_history = _drug_history;
pasthistory[patient_id] = pa;
}
/**
* @dev Retreive past illness details
* @param patient_id patient id
* */
function get_past_illness(uint256 patient_id)public view returns (string memory,string memory,string memory){
past memory pa = pasthistory[patient_id];
return (pa.family_history,pa.personal_history,pa.drug_history);
}
/**
* @dev Store functional diagnosis details
* @param patient_id patient id
* @param _diag_summary summary of diagnosis
* @param _prescription prescription
*/
function func_diagnosis(uint256 patient_id,string memory _diag_summary,string memory _prescription)public isOwner {
d.diag_summary = _diag_summary;
d.prescription = _prescription;
diagnosis[patient_id] = d;
}
/**
* @dev Retreive functional diagnosis details
* @param patient_id patient id
* */
function get_func_diagnosis(uint256 patient_id)public view returns (string memory,string memory){
diag memory d = diagnosis[patient_id];
return ( d.diag_summary,d.prescription);
}
/**
* @dev Store treatment summary details
* @param patient_id patient patient id
* @param _treatment treatment
* @param _date_treatment date of treatment
* @param _doctor_id id of doctor treated
* @param _hospital_id id of hospital
* @param _discharge date of discharge
* @param _follow_up date for follow up
* */
function treatment_summary(uint256 patient_id,string memory _treatment,string memory _date_treatment,uint256 _doctor_id,uint256 _hospital_id,string memory _discharge,string memory _follow_up)public isOwner {
tr.treatment = _treatment;
tr.date_treatment = _date_treatment;
tr.doctor_id = _doctor_id;
tr.hospital_id = _hospital_id;
tr.discharge = _discharge;
tr.follow_up = _follow_up;
treatment[patient_id] = tr;
}
/**
* @dev Retreive treatment summary details
* @param patient_id patient id
* */
function get_treatment_summary(uint256 patient_id)public view returns (string memory,string memory,uint256,uint256,string memory,string memory){
treat memory tr = treatment[patient_id];
return (tr.treatment,tr.date_treatment,tr.doctor_id,tr.hospital_id,tr.discharge,tr.follow_up);
}
}