Created
June 14, 2020 07:58
-
-
Save zaryab2000/8a198675e35d151b454a7b931c67874f to your computer and use it in GitHub Desktop.
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
//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; | |
patientList[_pid].insuranceAmount -= _amountRequired; | |
recepientDoctor.transfer(_amountRequired); | |
// Entire History of Withdrawal of Funds is stored on Blockchain | |
withdrawCount++; | |
withdrawHistoryList[withdrawCount] = withdrawHistory(_pid, patientList[_pid].doctorName,now,_amountRequired,patientList[_pid].name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment