-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhospital.sol
76 lines (44 loc) · 1.73 KB
/
hospital.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
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Hospital Registration
* @dev Store & retreive Hospital details
*/
contract Hospital {
mapping(uint256 => hospital) hospitallist;
struct hospital{
string hospital_name;
string hospital_address;
string hospital_spec;
}
hospital h;
address owner;
constructor() public {
owner = msg.sender;
}
// modifier to give access only to hospital
modifier isOwner() {
require(msg.sender == owner, "Access is not allowed");
_;
}
/**
* @dev Store hospital details
* @param hospital_id hospital registration id
* @param _hospital_name name of hospital
* @param _hospital_spec hospital specialisation
* @param _hospital_address hospital address
* */
function store_doctor_details(uint256 hospital_id,string memory _hospital_name,string memory _hospital_address,string memory _hospital_spec)public isOwner {
h.hospital_name = _hospital_name;
h.hospital_address = _hospital_address;
h.hospital_spec = _hospital_spec;
hospitallist[hospital_id] = h;
}
/**
* @dev Retreive hospital details
* @param hospital_id hospital registration id
* */
function retreive_hospital_details(uint256 hospital_id) public view returns (string memory,string memory,string memory){
hospital memory h = hospitallist[hospital_id];
return (h.hospital_name,h.hospital_address,h.hospital_spec);
}
}