-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathehr.sol
More file actions
101 lines (81 loc) · 2.43 KB
/
Copy pathehr.sol
File metadata and controls
101 lines (81 loc) · 2.43 KB
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
pragma solidity ^0.4.25;
contract Record {
address public patientID;
address public requestorID;
address public doctorID;
constructor () public {
patientID = msg.sender;
}
string public messages;
string name = 'John Doe';
uint age = 17;
uint weight = 170;
uint height = 60;
string allergies = 'Nuts, Pollen';
string medicine = 'Singular, Allegra';
modifier onlyPatient {
if(patientID != msg.sender) {
revert();
} else {
_;
}
}
modifier onlyPatientorDoctor {
if((patientID == msg.sender) || (doctorID == msg.sender)) {
_;
} else {
revert();
}
}
modifier notPatient {
if(patientID == msg.sender) {
revert();
} else {
_;
}
}
function requestAccess() public notPatient {
messages = 'Access to records is being requested';
requestorID = msg.sender;
}
function allowAccess(bool access) public onlyPatientorDoctor {
if(access == true){
messages = 'Access to records is granted';
doctorID = requestorID;
} else {
messages = 'Access to records is denied';
}
}
function stopAccess() public onlyPatient {
messages = 'Access to records has been stopped';
doctorID = 0;
}
modifier onlyDoctor {
if(doctorID != msg.sender) {
revert();
} else {
_;
}
}
function viewRecord() public onlyPatientorDoctor view returns(string,uint,uint,uint,string,string) {
return (name, age, weight, height, allergies, medicine);
}
function updateName(string newName) public onlyDoctor returns(string) {
name = newName;
}
function updateAge(uint newAge) public onlyDoctor returns(uint) {
age = newAge;
}
function updateWeight(uint newWeight) public onlyDoctor returns(uint) {
weight = newWeight;
}
function updateHeight(uint newHeight) public onlyDoctor returns(uint) {
height = newHeight;
}
function updateAllergies(string newAllergies) public onlyDoctor returns(string) {
allergies = newAllergies;
}
function updateMedicine(string newMedicine) public onlyDoctor returns(string) {
medicine = newMedicine;
}
}