} $include = $trial->checkPageLogin($page); switch ($include) { case 'usersett': $user = $trial->getUser(); if (!$user->checkPassword($_POST["{$page}-password"][0])) { $_SESSION['error'] = 'You must enter your current password to change your details.'; header("Location:index.php?page=usersett"); exit; } else { if ($user->checkDuplicate($_POST["{$page}-email"])) { $_SESSION['error'] = "A user has already been registered with this email address."; header("Location:index.php?page=usersett"); exit; } else { $trial->addUserInput($_POST, $user); // Add data to user object if (!isset($_SESSION['inputErr'])) { // If no errors, report success $user->saveToDB(); // Save it to the database $_SESSION['message'] = 'Your details have been successfully updated.'; header("Location:index.php"); exit; } } } header("Location:index.php?page={$include}"); exit; break; case 'register':
$trial->addRecord(); $data = $trial->record->getData($page); if ($trial->user->isRegional() && $_POST['core-centre_id'] != $trial->user->getCentre()) { $_SESSION['error'] = 'You are not authorised to enter records for other centres.'; $complete = false; } elseif (!isset($_SESSION['newTrialID']) || $_POST['core-trialid'] != $_SESSION['newTrialID']) { $_SESSION['error'] = "Please use the " . Config::get('idName') . " as generated for you, this will prevent ID collisions."; $complete = false; } else { $centre = new Centre($_POST['core-centre_id']); if ($centre->isLocked()) { $_SESSION['error'] = 'This centre is locked for any data entry.'; $complete = false; } else { // $_POST['core-trialid'] = substr_replace($_POST['core-trialid'], str_pad($_POST['core-centre_id'],3,'0',0), 0, 3); $complete = $trial->addUserInput($_POST, $data); if ($trial->record->checkDuplicate()) { $_SESSION['error'] = "A patient has already been entered from that centre with that " . Config::get('idName') . "."; $complete = false; } } } $trial->user->linkRecord($trial->record->saveToDB()); unset($_SESSION['newTrialID']); if ($complete) { $trial->setStudyGroup(); $trial->record->saveToDB(); $sGName = $trial->record->getData('core')->get('studygroup') ? 'CPAP Study' : 'Control'; $message = "<h3>You have successfully randomised a patient to the {$sGName} group.</h3>"; $email = $trial->generateRandomisationEmail(); $sent = $trial->sendEmail($email);
} $_SESSION['message'] = "The record has been marked as complete. Thank you."; header("Location:{$return}"); exit; } elseif ($trial->record->isPreSigned() && $signed) { $trial->record->unPreSignRecord(); header("Location:dataentry.php?page=signpt"); exit; } else { header("Location:dataentry.php?page=signpt"); exit; } } else { if ($page === 'discontinue') { unset($_SESSION['inputErr']); $complete = $trial->addUserInput($_POST); if ($complete) { $trial->record->signRecord(); $comment = 'Patient record discontinued'; $trial->record->set('comment', $comment); $trial->record->saveToDB(); $_SESSION['message'] = "This patient has now been withdrawn from the study. Their record is now no longer editable."; header("Location:index.php"); exit; } else { $_SESSION['error'] = "You must complete the form to discontinue a patient from the trial. Please try again."; header("Location:index.php"); exit; } } else { if ($page === 'adverseevent') {
$comment = 'Incomplete record'; $trial->record->set('comment', $comment); $trial->record->saveToDB(); } $_SESSION['message'] = "The record has been marked as complete. Thank you."; header("Location:{$return}"); exit; } elseif ($trial->record->isPreSigned() && $signed) { $trial->record->unPreSignRecord(); header("Location:dataentry.php?page=signpt"); exit; } else { header("Location:dataentry.php?page=signpt"); exit; } } else { $complete = $trial->addUserInput($_POST); if ($page == 'core' && $trial->record->checkDuplicate()) { $_SESSION['error'] = "{$trial->record->getID()} - A patient has already been entered from that centre with that " . Config::get('idName') . "."; $complete = false; } else { $trial->record->saveToDB(); } if ($complete) { $newPage = $trial->getNextPage(); } else { $newPage = $page; } header("Location:dataentry.php?page={$newPage}"); exit; }