public function calculateStatus(\Event $event)
{
$status = 0;
// need to reset to ensure we are getting the correct values for the elements
// after any edits that have taken place (edits taking place in the controller
// operate on different instances of the event elements from those cached in the manager)
// TODO: Would be good to fix the Controller so this was no longer the case.
$this->resetElementStore($event);
if ($this->isIssued($event)) {
$status |= self::$ISSUED;
}
if ($clerical = $this->getClericalElementForEvent($event)) {
$clerical->setScenario('finalise');
if ($clerical->validate()) {
$status |= self::$CLERICAL_COMPLETE;
}
}
if ($clinical = $this->getClinicalElementForEvent($event)) {
$clinical->setScenario('finalise');
if ($clinical->validate()) {
$status |= self::$CLINICAL_COMPLETE;
}
if ($clinical->isSigned()) {
$status |= self::$CONSULTANT_SIGNED;
}
}
if ($demographics = $this->getDemographicsElementForEvent($event)) {
$demographics->setScenario('finalise');
if ($demographics->validate()) {
$status |= self::$DEMOGRAPHICS_COMPLETE;
}
}
if ($signature = $this->getConsentSignatureElementForEvent($event)) {
if ($signature->checkSignature()) {
$status |= self::$CONSENTED;
}
}
$this->resetElementStore($event);
return $status;
}