예제 #1
0
파일: addcore.php 프로젝트: uhtoff/eCRF
    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);
    $email = $trial->generateCentralRandomisationEmail();
    if ($email) {
        $trial->sendEmail($email);
    }
    if ($sent) {
        $message .= "<p>Please note down their trial ID ({$data->trialid}) and group assignment, you should have received an email with this information.</p>";
    } else {
        $message .= "<p>Please note down their trial ID ({$data->trialid}) and group assignment, there has been an error in sending emails, so please ensure you record this.</p>";
    }
    if ($sGName == 'Control') {