Last active
September 12, 2018 17:13
-
-
Save asselstine/6f0474e1fe0dda0539f5119022c10657 to your computer and use it in GitHub Desktop.
An example of a contract that uses the DoctorRegistry
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
import 'medcredits-solidity/DoctorRegistry.sol'; | |
contract CaseFactory { | |
uint8 constant DERMATOLOGY_CODE = 0x00001a83; | |
Case[] cases; | |
mapping (uint256 => address) public caseIndices; | |
DoctorRegistry doctorRegistry; | |
function CaseFactory(DoctorRegistry _doctorRegistry) { | |
doctorRegistry = _doctorRegistry; | |
} | |
modifier isQualified(address _doctor) { | |
return doctorRegistry.isQualified(_doctor, DERMATOLOGY_CODE, 'doctor is not qualified'); | |
_; | |
} | |
function createCase(address _patient, address _doctor) external isQualified(_doctor) returns (Case) { | |
Case case = new Case(_patient, _doctor); | |
uint256 index = cases.length; | |
cases.push(case); | |
caseIndices[index] = case; | |
return case; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs
returns(Case)
function createCase(address _doctor) external isQualified(_doctor) {