-
Notifications
You must be signed in to change notification settings - Fork 0
/
doctor.sol
75 lines (46 loc) · 1.8 KB
/
doctor.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
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Medical records
* @dev Store & retreive Doctor details
*/
contract Doctor {
mapping(uint256 => doctor) doctorlist;
struct doctor{
string doctor_name;
string doctor_specialisation;
uint256 doctor_ph_no;
string doctor_address;
}
doctor d;
address owner;
constructor() public {
owner = 0xE6005Cc724c2d44F0aF23d663017a7E375DD7F35; //Address of Hospital
}
// modifier to give access only to hospital
modifier isOwner() {
require(msg.sender == owner, "Access is not allowed");
_;
}
/**
* @dev Store doctor details
* @param doctor_id doctor id
* @param _doctor_name name of doctor
* @param _doctor_specialisation specialisation of doctor
* @param _doctor_ph_no doctor phone number
*/
function store_doctor_details(uint16 doctor_id,string memory _doctor_name,string memory _doctor_specialisation,uint256 _doctor_ph_no,string memory _doctor_address)public isOwner {
d.doctor_name = _doctor_name;
d.doctor_specialisation = _doctor_specialisation;
d.doctor_ph_no = _doctor_ph_no;
d.doctor_address = _doctor_address;
doctorlist[doctor_id] = d;
}
/**
* @dev Retreive doctor details
* @param doctor_id doctor id
* */
function retreive_doctor_details(uint16 doctor_id) public view returns (string memory,string memory,uint256,string memory){
doctor memory d = doctorlist[doctor_id];
return (d.doctor_name,d.doctor_specialisation,d.doctor_ph_no,d.doctor_address);
}
}