Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

Zaryab zaryab2000

🏡
Working from home
View GitHub Profile
View Medical_Insurance_on_Ethereum_Blockchain
function doctorSign(address _pid) public{
require(doctorList[msg.sender]);
patientList[_pid].doctorSignature = true;
patientList[_pid].doctorAddress = msg.sender;
patientList[_pid].doctorName = doctorDetailList[msg.sender].docName;
}
View Medical Insurance
contract HealthCareStore is Ownable{
uint public pidCount;
uint public withdrawCount;
uint public doctorCount;
uint public donorCount;
}
View Medical Insurance
struct Patient{
uint256 time;
uint256 insuranceAmount;
uint256 donatedAmount;
string name;
string disease;
string doctorName;
string ipfsHash;
address doctorAddress;
View Medical_Insurance_on_Ethereum_Blockchain
pragma solidity ^0.6.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
contract HealthCareStore is Ownable{
uint public pidCount;
uint public withdrawCount;
uint public doctorCount;
uint public donorCount;
View Medical_Insurance_on_Ethereum_Blockchain
mapping( address => bool) public doctorList;
mapping(address => uint256) public donorList;
mapping(uint => address) public pidList;
mapping(address => Patient) public patientList;
mapping(address => Doctor) public doctorDetailList;
mapping(uint => donationHistory) public donationHistoryList;
mapping(uint => withdrawHistory) public withdrawHistoryList;
View Medical_Insurance_on_Ethereum_Blockchain
//Function to add a New Patient
function setPatientData(string memory _name, string memory _disease,string memory _ipfsHash) public payable onlyOwner{
//GENERATING a UNIQUE ID for Patient
address pid = address(bytes20(keccak256(abi.encodePacked(msg.sender,now))));
patientList[pid] = Patient(now,0,0,_name,_disease,' ',_ipfsHash,0x0000000000000000000000000000000000000000,pid,true,false);
// Adding Insurance Amount
patientList[pid].insuranceAmount = msg.value;
View Medical_Insurance_on_Ethereum_Blockchain
// Add a New DOCTOR
function setDoctor(address _docAddress,string memory _name, string memory _spec) public onlyOwner{
require(!doctorList[_docAddress]);
doctorList[_docAddress] = true;
doctorDetailList[_docAddress].docAdress = _docAddress;
doctorDetailList[_docAddress].docName = _name;
doctorDetailList[_docAddress].docSpecialization = _spec;
doctorCount++;
docAddressList[doctorCount] = _docAddress;
}
View gist:8a198675e35d151b454a7b931c67874f
//Withdrawing Funds from Patient
function withdrawInsurance(address _pid, uint256 _amountRequired) public{
// Checkpoints Before execution
require(doctorList[msg.sender]);
require(patientList[_pid].doctorAddress == msg.sender);
require(patientList[_pid].insuranceAmount >= _amountRequired);
// If all Conditions are satisfied, Funds are transferred to the assigned doctor
address payable recepientDoctor = msg.sender;
View Medical_Insurance_on_Ethereum_Blockchain
//DONATING FUNDS TO PATIENTS
function donateAmount(address _pid) public payable{
require((msg.sender).balance >= msg.value);
patientList[_pid].donatedAmount = msg.value;
donorList[msg.sender] = msg.value;
donorCount++;
donationHistoryList[donorCount] = donationHistory(_pid, msg.sender,now,msg.value,patientList[_pid].name);
}
View ERC721 interface
pragma solidity ^0.6.2;
import "../../introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);