Created
October 14, 2018 14:37
-
-
Save akinhwan/9fa9606da63b33c4193e95d3287ec8c9 to your computer and use it in GitHub Desktop.
Pill Smart Contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.17; | |
contract Dispense { | |
address public manager; | |
address[] public rfid; | |
uint public minimumContribution; | |
address[] public serialTransactionNo; | |
mapping(uint => Prescription) prescriptions; | |
uint drperscribe = 60 seconds; | |
uint lastUpdated; | |
struct Prescription { | |
bool rxstarted; | |
uint timeStamp; | |
} | |
event bottleEvent(uint rfid, uint occur); | |
modifier onlyRfid() { | |
require(msg.sender == manager); | |
_; | |
} | |
function returnpres(uint id) view public returns (bool, uint) { | |
return (prescriptions[id].rxstarted, prescriptions[id].timeStamp); | |
} | |
function pushtobc(uint minimum) public { | |
manager = msg.sender; | |
minimumContribution = minimum; | |
} | |
function gethashes() public view returns (address[]) { | |
return serialTransactionNo; | |
} | |
function takerx(uint id) public { | |
prescriptions[id].rxstarted = true; | |
prescriptions[id].timeStamp = now; | |
emit bottleEvent(id, 1); | |
} | |
function compromisedBottle(uint id) public { | |
prescriptions[id].rxstarted = true; | |
prescriptions[id].timeStamp = now; | |
emit bottleEvent(id, 2); | |
} | |
function drtimehaspassed() public view returns (bool) { | |
return (now >= (lastUpdated + 60 seconds)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment