-
Notifications
You must be signed in to change notification settings - Fork 0
/
records.sol
223 lines (144 loc) · 6.78 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
pragma solidity >=0.4.22 <0.7.0;
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;
constructor() ERC721("AmritaMedicalCoin","AMC") public {
owner = 0x466147A21E54F6a7A22Cc86004ab5841C00bE41f; //Address of Doctor
}
// modifier to give access only to doctor
modifier isOwner() {
require(msg.sender == owner, "Access is not allowed");
_;
}
function namedecl() public view returns (string memory) {
//calling the Built-in function in ERC721
return name();
}
function symboldecl() public view returns (string memory) {
//calling the Built-in function in ERC721
return symbol();
}
function totalSupplycount() public view returns (uint256) {
//calling the Built-in function in ERC721
return totalSupply();
}
function medical_record(uint256 patient_id)public{
//Calling the Built-in function in ERC721
_mint(msg.sender,patient_id);
patientlist[patient_id] = p;
}
function previous_dates(uint256 patient_id,string memory _previous)public isOwner {
pr.previous = _previous;
prevdates[patient_id] = pr;
}
function get_previous_dates(uint256 patient_id)public view returns (string memory){
prev memory pr = prevdates[patient_id];
return (pr.previous);
}
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;
}
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);
}
function present_illness(uint256 patient_id,string memory _complaints,string memory _duration)public isOwner {
hi.complaints = _complaints;
hi.duration = _duration;
patienthistory[patient_id] = hi;
}
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);
}
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;
}
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);
}
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;
}
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);
}
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;
}
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);
}
}