我正在尝试通过从此链接中获取参考来编写医疗保健合同。当患者发送地址时,医生只能更新患者的详细信息。
文件:Patient.sol
pragma solidity ^0.4.21;
contract Patient {
string public name = "";
string public dateOfBirth;
mapping (address => uint) public balances;
function () payable{
balances[msg.sender] = 40;
}
function getContractAddress() public view returns(address) {
return address(this);
}
// ############### Get Functions Begin ######################
function getName() external view returns (string) {
return name; // First_Name Last_Name
}
function getDateOfBirth() external view returns (string) {
return dateOfBirth; // YYYYMMDD
}
}
文件:Doctor.sol
pragma solidity ^0.4.21;
import './Patient.sol';
contract Doctor{
// the address of the owner (the patient)
address public owner;
string public name;
string public dateOfBirth;
string public patient_problem;
modifier isOwnerPatient {
require(msg.sender == owner);
_;
}
// constructor that sets the owner to the address creating
// this smart contract
function Doctor() {
owner = msg.sender;
}
// allows physician to add an allergy
function AddProblem(string _allergie) public isOwnerPatient {
patient_problem = _allergie;
}
}
但是当我运行function AddProblem()
. Doctor contract
它不会进入循环内部。看来owner != msg.sender
. 我正在使用 remix IDE 并将患者的合同地址输入到医生At Address
输入区域。