Skip to content

Instantly share code, notes, and snippets.

@asselstine
Created September 6, 2018 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asselstine/e6abd9c192228fab30f2e45b790f78f0 to your computer and use it in GitHub Desktop.
Save asselstine/e6abd9c192228fab30f2e45b790f78f0 to your computer and use it in GitHub Desktop.
Some snippets showing the case challenging code for arbitration
contract ChallengeManager is Ownable, Initializable {
using RegistryLookup for Registry;
Registry registry;
event ChallengeDoctorSet(address indexed _case, address indexed _patient, address indexed _challengingDoctor, bytes doctorEncryptedKey);
event ChallengingDoctorCleared(address indexed _case, address indexed _patient, address indexed _diagnosingDoctor);
event CaseChallenged(address indexed _case, address indexed _patient, address indexed _challengingDoctor);
event ChallengedCaseClosed(address indexed _case, address indexed _patient, address indexed _diagnosingDoctor, address _challengingDoctor);
event CaseDiagnosesDiffer(address indexed _case, address indexed _patient, address indexed _challengingDoctor);
event CaseDiagnosisConfirmed(address indexed _case, address indexed _patient, address indexed _challengingDoctor);
function challengeWithDoctor(address _caseAddress, address _doctor, bytes _doctorEncryptedKey)
external
onlyCaseLifecycleManager
{
Case _case = Case(_caseAddress);
_case.setStatus(Case.CaseStatus.Challenging);
setChallengingDoctor(_case, _doctor, _doctorEncryptedKey);
registry.caseScheduleManager().touchUpdatedAt(_caseAddress);
emit CaseChallenged(_caseAddress, _case.patient(), _doctor);
}
function setChallengingDoctor(Case _case, address _doctor, bytes _doctorEncryptedKey) internal {
_case.setChallengingDoctor(_doctor);
_case.setDoctorEncryptedCaseKeys(_doctor, _doctorEncryptedKey);
registry.caseManager().addDoctorToDoctorCases(_doctor, _case);
registry.caseStatusManager().addOpenCase(_doctor, _case);
emit ChallengeDoctorSet(_case, _case.patient(), _doctor, _doctorEncryptedKey);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment