function rc() { $captcha = get_option('cforms_captcha_def'); $min = prep($captcha['c1'], 4); $max = prep($captcha['c2'], 5); $src = prep($captcha['ac'], 'abcdefghijkmnpqrstuvwxyz23456789'); $srclen = strlen($src) - 1; $length = mt_rand($min, $max); $Code = ''; for ($i = 0; $i < $length; $i++) { $Code .= substr($src, mt_rand(0, $srclen), 1); } return $Code; }
function prep(DirectoryIterator $dir) { global $xml; global $FILES; foreach ($dir as $f) { if (!$f->isDot()) { if ($f->isDir()) { $d = "{$f->getPath()}/{$f->getFilename()}"; file_put_contents("{$d}.metadata.properties.xml", $xml); prep(new DirectoryIterator($d)); } else { if ($f->getExtension() != 'xml') { fwrite($FILES, $f->getPath() . '/' . $f->getFilename() . "|\n"); } } } } }
function leyka_do_donations_export() { if (empty($_GET['leyka-donations-export-csv-excel'])) { return; } // Just in case that export will require some time: ini_set('max_execution_time', 99999); set_time_limit(99999); ob_start(); $meta_query = array('relation' => 'AND'); if (!empty($_GET['campaign'])) { $meta_query[] = array('key' => 'leyka_campaign_id', 'value' => (int) $_GET['campaign']); } if (!empty($_GET['payment_type'])) { $meta_query[] = array('key' => 'leyka_payment_type', 'value' => $_GET['payment_type']); } if (!empty($_GET['gateway_pm'])) { if (strpos($_GET['gateway_pm'], 'gateway__') !== false) { $meta_query[] = array('key' => 'leyka_gateway', 'value' => str_replace('gateway__', '', $_GET['gateway_pm'])); } elseif (strpos($_GET['gateway_pm'], 'pm__') !== false) { $meta_query[] = array('key' => 'leyka_payment_method', 'value' => str_replace('pm__', '', $_GET['gateway_pm'])); } } $args = array('post_type' => Leyka_Donation_Management::$post_type, 'post_status' => isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys(leyka()->get_donation_statuses())) ? $_GET['post_status'] : 'any', 'm' => $_GET['month-year'], 'meta_query' => $meta_query, 'posts_per_page' => 200); $donations = new WP_Query(apply_filters('leyka_donations_export_query_args', $args)); $total_pages = $donations->found_posts / 200; $total_pages = $total_pages - (int) $total_pages > 0 ? (int) $total_pages + 1 : $total_pages; $posts_page = $total_pages > 0 ? 1 : 0; $donations = $donations->get_posts(); require_once LEYKA_PLUGIN_DIR . 'inc/excel-writer/SimpleExcel.php'; $excel = new SimpleExcel('csv'); $domain = str_replace(array('http:', 'https:'), '', home_url()); function prep($text) { return '"' . str_replace(array(';', '"'), array('', ''), $text) . '"'; } if (isset($_GET['export-tech'])) { // Technical export mode column headings $excel->writer->addRow(array('hash', 'Domain', 'Org_name', 'Timestamp', 'Date', 'Email_hash', 'Donor_name hash', 'Sum', 'Currency', 'Gateway_pm', 'Donation_status', 'Campaign_title', 'Campaign_URL', 'Payment_title', 'Target_sum', 'Campaign_target_state', 'Campaign_is_finished')); } else { // Normal export mode column headings $excel->writer->addRow(array(apply_filters('leyka_donations_export_headers', array('ID', 'Имя донора', 'Email', 'Тип платежа', 'Способ платежа', 'Сумма', 'Дата пожертвования', 'Статус', 'Кампания')))); } while ($posts_page && $posts_page <= $total_pages) { // Main loop too fill the export file foreach ($donations as $donation) { $donation = new Leyka_Donation($donation); $campaign = new Leyka_Campaign($donation->campaign_id); if (isset($_GET['export-tech'])) { $excel->writer->addRow(array(prep(wp_hash($domain . $donation->date_timestamp . $donation->sum . $donation->id)), prep($domain), prep(leyka_options()->opt('org_full_name')), prep($donation->date_timestamp), prep(date(get_option('date_format') . ', H:i', $donation->date_timestamp)), prep(wp_hash($donation->donor_email)), prep(wp_hash($donation->donor_name)), prep((int) $donation->sum), prep($donation->currency), $donation->payment_type == 'correction' ? prep($donation->pm_id) : prep($donation->gateway_label . '-' . $donation->pm_id), prep($donation->status), prep($campaign->title), prep($campaign->url), prep($campaign->payment_title), prep((int) $campaign->target), prep($campaign->target_state), prep((int) $campaign->is_finished))); } else { $excel->writer->addRow(apply_filters('leyka_donations_export_line', array($donation->id, $donation->donor_name, $donation->donor_email, $donation->payment_type_label, $donation->payment_method_label, $donation->sum . ' ' . $donation->currency_label, $donation->date, $donation->status_label, $campaign->title))); } } $posts_page++; $args['paged'] = $posts_page; $donations = get_posts(apply_filters('leyka_donations_export_query_args', $args)); wp_cache_flush(); } if (isset($_GET['export-tech'])) { $excel->writer->setDelimiter(';'); ob_clean(); header('Content-type: application/vnd.ms-excel'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Pragma: no-cache'); header('Content-Disposition: attachment; filename="donations-tech-' . $domain . '-' . date('d.m.Y-H.i.s') . '.csv"'); die(iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=;\n" . $excel->writer->saveString())); // ob_clean(); // // header('Content-type: application/vnd.ms-excel'); // header('Content-Transfer-Encoding: binary'); // header('Expires: 0'); // header('Pragma: no-cache'); // header('Content-Disposition: attachment; filename="donations-tech-'.$domain.'-'.date('d.m.Y-H.i.s').'.csv"'); // // die("sep=;\n".implode("\r\n", $file_lines)); } else { $excel->writer->setDelimiter(','); ob_clean(); header('Content-type: application/vnd.ms-excel'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Pragma: no-cache'); header('Content-Disposition: attachment; filename="donations-' . date('d.m.Y-H.i.s') . '.csv"'); die(iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=,\n" . $excel->writer->saveString())); } }
$res = mq($q); $proj_list = array(array("id" => "0", "name" => "--")); while ($info = mysql_fetch_array($res)) { $proj_list[] = array("id" => $info['id'], "name" => $info['name_ru']); } $smarty->assign("projects", $proj_list); // saving filter state if (isset($_POST['search_button'])) { // if (!empty($_POST['f_name'])) { $_SESSION['f_name'] = prep($_POST['f_name']); // } // if ($_POST['f_type'] != '0') { $_SESSION['f_type'] = prep($_POST['f_type']); // } // if ($_POST['f_proj'] != '0') { $_SESSION['f_proj'] = prep($_POST['f_proj']); // } } else { if (isset($_POST['clear_button'])) { $_SESSION['f_name'] = ''; $_SESSION['f_type'] = '0'; $_SESSION['f_proj'] = '0'; } } $smarty->assign("selected_page_name", $_SESSION['f_name']); $smarty->assign("selected_page_type", $_SESSION['f_type']); $smarty->assign("selected_project", $_SESSION['f_proj']); // applying filter conditions $filter_conditions = ""; $undef_filter_conditions = ""; if (!empty($_SESSION['f_name'])) {
} else { $abspath = '../../../'; } if (file_exists($abspath . 'wp-load.php')) { require_once $abspath . 'wp-load.php'; } else { require_once $abspath . 'wp-config.php'; } $cformsSettings = get_option('cforms_settings'); ### ### reset captcha image ### if (isset($_POST['captcha'])) { $cap = $cformsSettings['global']['cforms_captcha_def']; $c1 = prep($cap['c1'], '3'); $c2 = prep($cap['c2'], '5'); $ac = prep(urlencode($cap['ac']), urlencode('abcdefghijkmnpqrstuvwxyz23456789')); $i = prep($cap['i'], ''); $h = prep($cap['h'], 25); $w = prep($cap['w'], 115); $c = prep($cap['c'], '000066'); $l = prep($cap['l'], '000066'); $f = prep($cap['f'], 'font4.ttf'); $a1 = prep($cap['a1'], -12); $a2 = prep($cap['a2'], 12); $f1 = prep($cap['f1'], 17); $f2 = prep($cap['f2'], 19); $bg = prep($cap['bg'], '1.gif'); $captcha_uri = "&c1={$c1}&c2={$c2}&ac={$ac}&i={$i}&w={$w}&h={$h}&c={$c}&l={$l}&f={$f}&a1={$a1}&a2={$a2}&f1={$f1}&f2={$f2}&b={$bg}"; echo $cformsSettings['global']['cforms_root'] . '/cforms-captcha.php?ts=' . $no . str_replace('&', '&', $captcha_uri); }
public static function storeExportFile($original_filename, $file_content, $archiveFile = false, $dateShiftDates = false) { global $edoc_storage_option; ## Create the stored name of the file as it wll be stored in the file system $stored_name = date('YmdHis') . "_pid" . PROJECT_ID . "_" . generateRandomHash(6) . getFileExt($original_filename, true); $file_extension = getFileExt($original_filename); $mime_type = strtolower($file_extension) == 'csv' ? 'application/csv' : 'application/octet-stream'; // If file is UTF-8 encoded, then add BOM // Do NOT use addBOMtoUTF8() on Stata syntax file (.do) because BOM causes issues in syntax file if (strtolower($file_extension) != 'do') { $file_content = addBOMtoUTF8($file_content); } // If Gzip enabled, then gzip the file and append filename with .gz extension list($file_content, $stored_name, $gzipped) = gzip_encode_file($file_content, $stored_name); // Get file size in bytes $docs_size = strlen($file_content); // Add file to file system if ($edoc_storage_option == '0') { // Store locally $fp = fopen(EDOC_PATH . $stored_name, 'w'); if ($fp !== false && fwrite($fp, $file_content) !== false) { // Close connection fclose($fp); } else { // Send error response return false; } // Add file to S3 } elseif ($edoc_storage_option == '2') { global $amazon_s3_key, $amazon_s3_secret, $amazon_s3_bucket; $s3 = new S3($amazon_s3_key, $amazon_s3_secret, SSL); if (!$s3->putObject($file_content, $amazon_s3_bucket, $stored_name, S3::ACL_PUBLIC_READ_WRITE)) { // Send error response return false; } } else { // Store using WebDAV require_once APP_PATH_CLASSES . "WebdavClient.php"; require APP_PATH_WEBTOOLS . 'webdav/webdav_connection.php'; $wdc = new WebdavClient(); $wdc->set_server($webdav_hostname); $wdc->set_port($webdav_port); $wdc->set_ssl($webdav_ssl); $wdc->set_user($webdav_username); $wdc->set_pass($webdav_password); $wdc->set_protocol(1); // use HTTP/1.1 $wdc->set_debug(false); // enable debugging? if (!$wdc->open()) { // Send error response return false; } if (substr($webdav_path, -1) != '/') { $webdav_path .= '/'; } $http_status = $wdc->put($webdav_path . $stored_name, $file_content); $wdc->close(); } ## Add file info to edocs_metadata table // If not archiving file in File Repository, then set to be deleted in 1 hour $delete_time = $archiveFile ? "" : NOW; // Add to table $sql = "insert into redcap_edocs_metadata (stored_name, mime_type, doc_name, doc_size, file_extension, project_id, \n\t\t\t\tstored_date, delete_date, gzipped) values ('" . prep($stored_name) . "', '{$mime_type}', '" . prep($original_filename) . "', \n\t\t\t\t'" . prep($docs_size) . "', '" . prep($file_extension) . "', " . PROJECT_ID . ", '" . NOW . "', " . checkNull($delete_time) . ", {$gzipped})"; if (!db_query($sql)) { // Send error response return false; } // Get edoc_id $edoc_id = db_insert_id(); ## Add to doc_to_edoc table // Set flag if data is date shifted $dateShiftFlag = $dateShiftDates ? "DATE_SHIFT" : ""; // Set "comment" in docs table if (strtolower($file_extension) == 'csv') { $docs_comment = "Data export file created by " . USERID . " on " . date("Y-m-d-H-i-s"); } else { if ($file_extension == 'sps') { $stats_package_name = 'Spss'; } elseif ($file_extension == 'do') { $stats_package_name = 'Stata'; } else { $stats_package_name = camelCase($file_extension); } $docs_comment = "{$stats_package_name} syntax file created by " . USERID . " on " . date("Y-m-d-H-i-s"); } // Archive in redcap_docs table $sql = "INSERT INTO redcap_docs (project_id, docs_name, docs_file, docs_date, docs_size, docs_comment, docs_type, \n\t\t\t\tdocs_rights, export_file, temp) VALUES (" . PROJECT_ID . ", '" . prep($original_filename) . "', NULL, '" . TODAY . "', \n\t\t\t\t'{$docs_size}', '" . prep($docs_comment) . "', '{$mime_type}', " . checkNull($dateShiftFlag) . ", 1, \n\t\t\t\t" . checkNull($archiveFile ? "0" : "1") . ")"; if (db_query($sql)) { $docs_id = db_insert_id(); // Add to redcap_docs_to_edocs also $sql = "insert into redcap_docs_to_edocs (docs_id, doc_id) values ({$docs_id}, {$edoc_id})"; db_query($sql); } else { // Could not store in table, so remove from edocs_metadata also db_query("delete from redcap_edocs_metadata where doc_id = {$edoc_id}"); return false; } // Return successful response of docs_id from redcap_docs table return $docs_id; }
print "\t\t\t</select>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td valign='top' style='font-size:11px;color:#666;padding-left:10px;'>\n\t\t\t\t\t\t\t{$lang['calendar_popup_24']} {$table_pk_label}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr></table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>"; } print "<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td valign='top'>\n\t\t\t\t\t<br><br>\n\t\t\t\t\t<input type='submit' value='{$lang['calendar_popup_25']}' onclick=\"\n\t\t\t\t\t\tif (document.getElementById('notes').value.length < 1) {\n\t\t\t\t\t\t\talert('{$lang['calendar_popup_26']}');\n\t\t\t\t\t\t\treturn false;\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\">\n\t\t\t\t\t<br><br>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t</form>"; /** * DISPLAY CONFIRMATION THAT NEW CALENDAR EVENT WAS CREATED */ } elseif (!isset($_GET['cal_id']) && !empty($_POST)) { //If an existing record was selected, make sure record doesn't already exist in a DAG. If so, add its group_id to calendar event. if ($_POST['idnumber'] != "") { $group_id = db_result(db_query("select value from redcap_data where project_id = {$project_id} and record = '{$_POST['idnumber']}' and field_name = '__GROUPID__' limit 1"), 0); //If did not select a record, check if user is in DAG. } elseif ($user_rights['group_id'] != "") { $group_id = $user_rights['group_id']; } //Add event to calendar $sql = "insert into redcap_events_calendar (project_id, group_id, record, event_date, event_time, notes) values " . "({$project_id}, " . checkNull($group_id) . ", " . checkNull($_POST['idnumber']) . ", '{$_POST['event_date']}', " . checkNull($_POST['event_time']) . ", '" . prep($_POST['notes']) . "')"; //Success if (db_query($sql)) { //Logging log_event($sql, "redcap_events_calendar", "MANAGE", $new_cal_id, calLogChange(db_insert_id()), "Create calendar event"); //Show confirmation print "<div style='color:green;padding:30px 0 0 15px;margin-bottom:10px;font-weight:bold;font-size:16px;'>\n\t\t\t\t\t<img src='" . APP_PATH_IMAGES . "tick.png'>{$lang['calendar_popup_27']}<br><br><br>\n\t\t\t\t</div>"; //Render javascript to refresh calendar underneath and close pop-up print "<script type='text/javascript'>\n\t\t\t\twindow.opener.location.reload();\n\t\t\t\tsetTimeout(function(){self.close();},2500);\n\t\t\t\t</script>"; //Query failed } else { print "<p><b>{$lang['global_01']}{$lang['colon']}</b> {$lang['calendar_popup_28']}</p>"; if (SUPER_USER) { print db_error() . "<br>QUERY:<br>{$sql}"; } }
/** * we don't want to duplicate queries * if the result is excluded or has a query history, ignore it */ if (!($result['exclude'] || count($history) > 0)) { if ($debug) { show_var($history, 'HISTORY', 'red'); } $dr_status = 'OPEN'; $non_rule = null; $response_requested = '1'; $response = NULL; $drw_log = "Open data query"; // Insert new or update existing $sql = "insert into redcap_data_quality_status (rule_id, non_rule, project_id, record, event_id, field_name, query_status, assigned_user_id) values (" . checkNull($rule_id) . ", " . checkNull($non_rule) . ", " . PROJECT_ID . ", '" . prep($result['record']) . "', {$result['event_id']}, " . checkNull($field) . ", " . checkNull($dr_status) . ", " . checkNull($user['ui_id']) . ") on duplicate key update query_status = " . checkNull($dr_status) . ", status_id = LAST_INSERT_ID(status_id)"; if ($debug) { show_var($sql, 'INSERT STATUS', 'red'); } if (true) { //if (db_query($sql)) { // Get cleaner_id $status_id = db_insert_id(); // Get current user's ui_id $userInitiator = User::getUserInfo(USERID); // Add new row to data_resolution_log $sql = "insert into redcap_data_quality_resolutions (status_id, ts, user_id, response_requested, response, comment, current_query_status, upload_doc_id) values ($status_id, '" . NOW . "', " . checkNull($userInitiator['ui_id']) . ",
require "../system/incl.php"; $table = "page_type"; $errors = array(); $edit = false; $weights = array(); for ($i = 1; $i < 21; $weights[] = $i++) { } $smarty->assign("weights", $weights); // if submit button was pressed if (isset($_POST['sent'])) { $id = prep($_POST['id']); $name_ru = $_POST['name_ru']; $name_en = $_POST['name_en']; $weight = prep($_POST['weight']); $color = prep($_POST['color']); // validation if (empty($name_ru) || empty($name_en)) { $errors[] = "Название не может быть пустым!"; } if (count($errors) > 0) { if ($id > 0) { $edit = true; } $data['id'] = $_POST['id']; $data['weight'] = $_POST['weight']; $data['color'] = $_POST['color']; $data['name_ru'] = str_replace("\\'", "'", $_POST['name_ru']); $data['name_en'] = str_replace("\\'", "'", $_POST['name_en']); $smarty->assign("data", $data); $smarty->assign("errors", $errors);
$dq->executeRule($rule_id); // $results_table = $dq->displayResultsTable($rule_info); // print $results_table[2]; // print $results_table[1]; /** * cycle through rule results */ $rule_results = $dq->getLogicCheckResults(); foreach ($rule_results AS $results) { foreach ($results AS $result) { $dag_prefix = substr(get_single_field($result['record'], $project_id, $Proj->firstEventId, 'dm_usubjid', ''), 0, 3); $dag_result = db_query("SELECT group_name FROM redcap_data_access_groups WHERE project_id = '$project_id' AND LEFT(group_name, 3) = '$dag_prefix'"); if ($dag_result) { $dag_name = db_result($dag_result, 0, 'group_name'); $dag_name = prep($dag_name); } /** * if the result is excluded ignore it */ if ($result['exclude'] != 1) { $today = date('Y-m-d'); $redcap_event_name = $Proj->getUniqueEventNames($result['event_id']); $check_table = array(); $check_table_result = db_query("SELECT * FROM _target_notifications WHERE project_id = '$project_id' AND record = '{$result['record']}' AND redcap_event_name = '$redcap_event_name' AND redcap_data_access_group = '$dag_name' AND form_name = '$destination_form' AND type = 'rule' AND type_id = '$rule_id' AND action_date = '$today'"); if ($check_table_result) { $check_table = db_fetch_assoc($check_table_result); } else { error_log(db_error()); } if (count($check_table) == 0) {
/** * Delete entity * * @param array $item * * @return bool */ function flat_delete(array &$item) : bool { $attrs = $item['_entity']['attr']; $stmt = prep('DELETE FROM %s WHERE %s = :id', $item['_entity']['tab'], $attrs['id']['col']); $stmt->bindValue(':id', $item['_old']['id'], db_type($attrs['id'], $item['_old']['id'])); $stmt->execute(); return true; }
/** * @param $sql * @param $table * @param $event * @param $record * @param $display * @param string $descrip * @param string $change_reason * @param $userid * @return bool|mysqli_result * * This function should only be used when required, to impersonate another user for the purpose of ensuring data integrity. * One example of this purpose is to replicate Survey respondent input so survey functionality is maintained. */ function target_proxy_log_event($sql, $table, $event, $record, $display, $descrip = "", $change_reason = "", $userid = "") { global $user_firstactivity, $rc_connection; // Pages that do not have authentication that should have USERID set to [non-user] $nonAuthPages = array("_cron/cirrhosis_reporting.php", "_cron/push-hcvrna-monitoring.php", "_cron/push_durations.php", "_cron/push_durations_to_repo.php", "_cron/push_svr_actual_to_pivot.php", "push_svr_actual_to_pivot.php", "_cron/update_daa.php"); // Log the event in the redcap_log_event table $ts = str_replace(array("-", ":", " "), array("", "", ""), NOW); $page = (defined("PAGE") ? PAGE : ""); $ip = (isset($userid) && $userid != "[Survey respondent]") ? "" : getIpAddress(); // Don't log IP for survey respondents $event = strtoupper($event); $event_id = (isset($_GET['event_id']) && is_numeric($_GET['event_id'])) ? $_GET['event_id'] : "NULL"; $project_id = defined("PROJECT_ID") ? PROJECT_ID : 0; // Query $sql = "INSERT INTO redcap_log_event (project_id, ts, user, ip, page, event, object_type, sql_log, pk, event_id, data_values, description, change_reason) VALUES ($project_id, $ts, '" . prep($userid) . "', " . checkNull($ip) . ", '$page', '$event', '$table', " . checkNull($sql) . ", " . checkNull($record) . ", $event_id, " . checkNull($display) . ", " . checkNull($descrip) . ", " . checkNull($change_reason) . ")"; $q = db_query($sql, $rc_connection); // FIRST/LAST ACTIVITY TIMESTAMP: Set timestamp of last activity (and first, if applicable) if (defined("USERID") && strpos(USERID, "[") === false) { // SET FIRST ACTIVITY TIMESTAMP: If this is the user's first activity to be logged in the log_event table, then log the time in the user_information table $sql_firstact = ""; if ((!isset($user_firstactivity) || (isset($user_firstactivity) && empty($user_firstactivity)))) { $sql_firstact = ", user_firstactivity = '" . NOW . "'"; } // SET LAST ACTIVITY TIMESTAMP $sql = "update redcap_user_information set user_lastactivity = '" . NOW . "' $sql_firstact where username = '******' limit 1"; db_query($sql, $rc_connection); } // Return true/false success for logged event return $q; }
$dr_status = 'OPEN'; if (!$send_to_field) { $non_rule = NULL; unset($field); } else { $non_rule = 1; unset($rule_id); } $response_requested = '1'; $response = NULL; $drw_log = "Open data query"; // Insert new or update existing $status_sql = "insert into redcap_data_quality_status (rule_id, non_rule, project_id, record, event_id, field_name, query_status, assigned_user_id) values (" . checkNull($rule_id) . ", " . checkNull($non_rule) . ", " . PROJECT_ID . ", '" . prep($result['record']) . "', {$result['event_id']}, " . checkNull($field) . ", " . checkNull($dr_status) . ", " . $assigned_user_id . ") on duplicate key update query_status = " . checkNull($dr_status) . ", status_id = LAST_INSERT_ID(status_id)"; if (!$debug) { if (db_query($status_sql)) { // Get cleaner_id $status_id = db_insert_id(); // Get current user's ui_id $userInitiator = User::getUserInfo(USERID); // Add new row to data_resolution_log $sql = "insert into redcap_data_quality_resolutions (status_id, ts, user_id, response_requested, response, comment, current_query_status, upload_doc_id) values ($status_id, '" . NOW . "', " . checkNull($userInitiator['ui_id']) . ", " . checkNull($response_requested) . ", " . checkNull($response) . ", " . checkNull($rule_info['name']) . ", " . checkNull($dr_status) . ", " . checkNull($_POST['upload_doc_id']) . ")"; if (db_query($sql)) { // Success, so return content via JSON to redisplay with new changes made $res_id = db_insert_id();
print "<div class='red' style='margin:10px 0;width:640px;'><img src='" . APP_PATH_IMAGES . "exclamation.png'> " . RCView::escape($table_pk_label) . " <b>{$_GET['id']}</b> {$lang['data_entry_08']}<br/><b>{$lang['data_entry_13']} " . RCView::escape($table_pk_label) . " {$lang['data_entry_15']}</b></div>"; } } /*************************************************************** ** EVENT-FORM GRID ***************************************************************/ ## Query to get all Form Status values for all forms across all time-points. Put all into array for later retrieval. // Prefill $grid_form_status array with blank defaults $grid_form_status = array(); foreach ($Proj->eventsForms as $this_event_id => $these_forms) { foreach ($these_forms as $this_form) { $grid_form_status[$this_event_id][$this_form][1] = ''; } } // Get form statuses $qsql = "select distinct d.event_id, m.form_name, if(d2.value is null, '0', d2.value) as value, d2.instance\n\t\t\tfrom (redcap_data d, redcap_metadata m) left join redcap_data d2\n\t\t\ton d2.project_id = m.project_id and d2.record = d.record and d2.event_id = d.event_id\n\t\t\tand d2.field_name = concat(m.form_name, '_complete')\n\t\t\twhere d.project_id = {$project_id} and d.project_id = m.project_id and d.record = '" . prep($id) . "' and m.element_type != 'calc'\n\t\t\tand d.field_name = m.field_name and m.form_name in (" . prep_implode(array_keys($Proj->forms)) . ") and m.field_name != '{$Proj->table_pk}'"; $q = db_query($qsql); $has_repeated_events = false; while ($row = db_fetch_array($q)) { if ($row['instance'] == '') { $row['instance'] = '1'; } else { $has_repeated_events = true; } //Put time-point and form name as array keys with form status as value $grid_form_status[$row['event_id']][$row['form_name']][$row['instance']] = $row['value']; } // Create an array to count the max instances per event $instance_count = array(); // If has repeated events, then loop through all events/forms and sort them by instance if ($has_repeated_events) {
$min_font_size = prep($_REQUEST['f1'], 17); $max_font_size = prep($_REQUEST['f2'], 19); $min_angle = prep($_REQUEST['a1'], -12); $max_angle = prep($_REQUEST['a2'], 12); $col_txt_type = 4; $col = prep($_REQUEST['c'], '000066'); $col_txt_r = hexdec(substr($col, 0, 2)); $col_txt_g = hexdec(substr($col, 2, 2)); $col_txt_b = hexdec(substr($col, 4, 2)); $border = prep($_REQUEST['l'], '000066'); $border_r = hexdec(substr($border, 0, 2)); $border_g = hexdec(substr($border, 2, 2)); $border_b = hexdec(substr($border, 4, 2)); $char_padding = 2; $output_type = 'png'; $no = prep($_REQUEST['ts'], ''); ### captcha random code $srclen = strlen($src) - 1; $length = mt_rand($min, $max); $turing = ''; for ($i = 0; $i < $length; $i++) { $turing .= substr($src, mt_rand(0, $srclen), 1); } $tu = $_REQUEST['i'] == 'i' ? strtolower($turing) : $turing; setcookie('turing_string_' . $no, $_REQUEST['i'] . '+' . md5($tu), time() + 60 * 60 * 5, "/"); if ($fontUsed == 1) { $fontno = mt_rand(1, 34); $font = $fonts_dir . '/font' . $fontno . '.ttf'; } else { $font = $font_url; }
/** * Created by HCV-TARGET. * User: kbergqui * Date: 2/25/14 * Time: 9:02 AM */ function create_download_all($Proj, $lang, $project_id, $app_name, $app_title, $super_user, $userid, $headers, $headers_labels, $data_csv, $data_csv_labels, $field_names, $is_child=false, $chkd_flds, $table_pk, $longitudinal, $exportDags=false, $exportSurveyFields=false) { $dagEnum = ''; $do_remove_identifiers = false; $do_date_shift = false; // Retrieve project data (raw & labels) and headers in CSV format //list ($headers, $headers_labels, $data_csv, $data_csv_labels, $field_names) // = fetchDataCsv($chkd_flds, $parent_chkd_flds, false, $do_hash, $do_remove_identifiers, $useStandardCodes, $useStandardCodeDataConversion, $standardId, $standardCodeLookup, $useFieldNames, $exportDags, $exportSurveyFields, $exportSurveyFields); // Log the event //log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_flds) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Export data"); ############################################################ ## PREPARE SYNTAX FILES FOR STATS PACKAGES # Initializing the syntax file strings $spss_string = "FILE HANDLE data1 NAME='data_place_holder_name' LRECL=90000.\n"; $spss_string .= "DATA LIST FREE" . "\n\t"; $spss_string .= "FILE = data1\n\t/"; $sas_string = "DATA " . $app_name . ";\nINPUT "; $sas_format_string = "data redcap;\n\tset redcap;\n"; $stata_string = "clear\n\n"; $R_string = "#Clear existing data and graphics\nrm(list=ls())\n"; $R_string .= "graphics.off()\n"; $R_string .= "#Load Hmisc library\nlibrary(Hmisc)\n"; $R_label_string = "#Setting Labels\n"; $R_units_string = "\n#Setting Units\n"; $R_factors_string = "\n\n#Setting Factors(will create new variable for factors)"; $R_levels_string = ""; $value_labels_spss = "VALUE LABELS "; // Get relevant metadata to use for syntax files $syntaxfile_sql = "SELECT field_name, element_validation_type, element_enum, element_type, element_label, field_units FROM redcap_metadata where project_id = $project_id and field_name in ($chkd_flds) order by field_order"; // Array that is prepended to $field_names array if fields need to be added, such as redcap_event_name or survey timestamp $field_names_prepend = array(); $prev_form = ""; $prev_field = ""; // Loop through all fields that were exported $q = db_query($syntaxfile_sql); while ($row = db_fetch_assoc($q)) { // Create object for each field we loop through $ob = new stdClass(); foreach ($row as $col => $val) { $col = strtoupper($col); $ob->$col = $val; } // Set values for this loop $this_form = $Proj->metadata[$ob->FIELD_NAME]['form_name']; // If surveys exist, as timestamp and identifier fields if ($exportSurveyFields && $prev_form != $this_form && $ob->FIELD_NAME != $table_pk && isset($Proj->forms[$this_form]['survey_id'])) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'text'; $ob2->FIELD_NAME = $this_form . '_timestamp'; $ob2->ELEMENT_LABEL = 'Survey Timestamp'; $ob2->ELEMENT_ENUM = ''; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; } if ($ob->ELEMENT_TYPE != 'checkbox') { // For non-checkboxes, add to $meta_array $meta_array[$ob->FIELD_NAME] = (Object)$ob; } else { // For checkboxes, loop through each choice to add to $meta_array $orig_fieldname = $ob->FIELD_NAME; $orig_fieldlabel = $ob->ELEMENT_LABEL; $orig_elementenum = $ob->ELEMENT_ENUM; foreach (parseEnum($orig_elementenum) as $this_value => $this_label) { unset($ob); // $ob = $meta_set->FetchObject(); $ob = new stdClass(); // If coded value is not numeric, then format to work correct in variable name (no spaces, caps, etc) if (!is_numeric($this_value)) { $this_value = preg_replace("/[^a-z0-9]/", "", strtolower($this_value)); } // Convert each checkbox choice to a advcheckbox field (because advcheckbox has equivalent processing we need) // Append triple underscore + coded value $ob->FIELD_NAME = $orig_fieldname . '___' . $this_value; $ob->ELEMENT_ENUM = "0, Unchecked \\n 1, Checked"; $ob->ELEMENT_TYPE = "advcheckbox"; $ob->ELEMENT_LABEL = "$orig_fieldlabel (choice=" . str_replace(array("'", "\""), array("", ""), $this_label) . ")"; $meta_array[$ob->FIELD_NAME] = (Object)$ob; } } if ($ob->FIELD_NAME == $table_pk) { // If project has multiple Events (i.e. Longitudinal), add new column for Event name if ($longitudinal) { // Put unique event names and labels into array to convert to enum format $evtEnumArray = array(); $evtLabels = array(); foreach ($Proj->eventInfo as $event_id => $attr) { $evtLabels[$event_id] = label_decode($attr['name_ext']); } foreach ($evtLabels as $event_id => $event_label) { $evtEnumArray[] = $Proj->getUniqueEventNames($event_id) . ", " . label_decode($event_label); } $evtEnum = implode(" \\n ", $evtEnumArray); // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'select'; $ob2->FIELD_NAME = 'redcap_event_name'; $ob2->ELEMENT_LABEL = 'Event Name'; $ob2->ELEMENT_ENUM = $evtEnum; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; // Add pseudo-field to array $field_names_prepend[] = $ob2->FIELD_NAME; } // If project has DAGs, add new column for group name if ($exportDags) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'select'; $ob2->FIELD_NAME = 'redcap_data_access_group'; $ob2->ELEMENT_LABEL = 'Data Access Group'; $ob2->ELEMENT_ENUM = $dagEnum; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; // Add pseudo-field to array $field_names_prepend[] = $ob2->FIELD_NAME; } // Add survey identifier (unless we've set it to remove all identifiers - treat survey identifier same as field identifier) if ($exportSurveyFields && !$do_remove_identifiers) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'text'; $ob2->FIELD_NAME = 'redcap_survey_identifier'; $ob2->ELEMENT_LABEL = 'Survey Identifier'; $ob2->ELEMENT_ENUM = ''; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; // Add pseudo-field to array $field_names_prepend[] = $ob2->FIELD_NAME; } // If surveys exist, as timestamp and identifier fields if ($exportSurveyFields && $prev_form != $this_form && isset($Proj->forms[$this_form]['survey_id'])) { // Alter $meta_array $ob2 = new stdClass(); $ob2->ELEMENT_TYPE = 'text'; $ob2->FIELD_NAME = $this_form . '_timestamp'; $ob2->ELEMENT_LABEL = 'Survey Timestamp'; $ob2->ELEMENT_ENUM = ''; $ob2->FIELD_UNITS = ''; $ob2->ELEMENT_VALIDATION_TYPE = ''; $meta_array[$ob2->FIELD_NAME] = (Object)$ob2; } } // Set values for next loop $prev_form = $this_form; $prev_field = $ob->FIELD_NAME; } // Now reset field_names array $field_names = array_keys($meta_array); // $spss_data_type_array = ""; $spss_format_dates = ""; $spss_variable_label = "VARIABLE LABEL "; $spss_variable_level = array(); $sas_label_section = "\ndata redcap;\n\tset redcap;\n"; $sas_value_label = "proc format;\n"; $sas_input = "input\n"; $sas_informat = ""; $sas_format = ""; $stata_insheet = "insheet "; $stata_var_label = ""; $stata_inf_label = ""; $stata_value_label = ""; $stata_date_format = ""; $first_label = true; $large_name_counter = 0; $large_name = false; // Use arrays for string replacement $orig = array("'", "\"", "\r\n", "\r", "\n", "<", "<="); $repl = array("", "", " ", " ", " ", "<", "< ="); //print_array($meta_array);print_array($field_names);exit; // Loop through all metadata fields for ($x = 0; $x <= count($field_names) + 1; $x++) { if (($x % 5) == 0 && $x != 0) { $spss_string .= "\n\t"; } $large_name = false; // Set field object for this loop $ob = $meta_array[$field_names[$x]]; // Remove any . or - in the field name (as a result of checkbox raw values containing . or -) // $ob->FIELD_NAME = str_replace(array("-", "."), array("_", "_"), (string)$ob->FIELD_NAME); // Convert "sql" field types to "select" field types so that their Select Choices come out correctly in the syntax files. /** * override for autocomplete plugin code starts here * add autocomplete type to this check */ if ($ob->ELEMENT_TYPE == "sql" || $ob->ELEMENT_TYPE == "autocomplete") /** * end override for autocomplete plugin code */ { // Change to select $ob->ELEMENT_TYPE = "select"; // Now populate it's choices by running the query $ob->ELEMENT_ENUM = getSqlFieldEnum($ob->ELEMENT_ENUM); } elseif ($ob->ELEMENT_TYPE == "yesno") { $ob->ELEMENT_ENUM = YN_ENUM; } elseif ($ob->ELEMENT_TYPE == "truefalse") { $ob->ELEMENT_ENUM = TF_ENUM; } //Remove any offending characters from label $ob->ELEMENT_LABEL = str_replace($orig, $repl, label_decode(html_entity_decode($ob->ELEMENT_LABEL, ENT_QUOTES))); if ($field_names[$x] != "") { if (strlen($field_names[$x]) >= 31) { $short_name = substr($field_names[$x], 0, 20) . "_v_" . $large_name_counter; $sas_label_section .= "\tlabel " . $short_name . "='" . $ob->ELEMENT_LABEL . "';\n"; $stata_var_label .= "label variable " . $short_name . ' "' . $ob->ELEMENT_LABEL . '"' . "\n"; $stata_insheet .= $short_name . " "; $large_name_counter++; $large_name = true; } if (!$large_name) { $sas_label_section .= "\tlabel " . $field_names[$x] . "='" . $ob->ELEMENT_LABEL . "';\n"; $stata_var_label .= "label variable " . $field_names[$x] . ' "' . $ob->ELEMENT_LABEL . '"' . "\n"; $stata_insheet .= $field_names[$x] . " "; } $spss_variable_label .= $field_names[$x] . " '" . $ob->ELEMENT_LABEL . "'\n\t/"; $R_label_string .= "\nlabel(data$" . $field_names[$x] . ")=" . '"' . $ob->ELEMENT_LABEL . '"'; if (($ob->FIELD_UNITS != Null) || ($ob->FIELD_UNITS != "")) { $R_units_string .= "\nunits(data$" . $field_names[$x] . ")=" . '"' . $ob->FIELD_UNITS . '"'; } } # Checking for single element enum (i.e. if it is coded with a number or letter) $single_element_enum = true; if (substr_count(((string)$ob->ELEMENT_ENUM), ",") > 0) { $single_element_enum = false; } # Select value labels are created if (($ob->ELEMENT_TYPE == "yesno" || $ob->ELEMENT_TYPE == "truefalse" || $ob->ELEMENT_TYPE == "select" || $ob->ELEMENT_TYPE == "advcheckbox" || $ob->ELEMENT_TYPE == "radio") && !preg_match("/\+\+SQL\+\+/", (string)$ob->ELEMENT_ENUM)) { //Remove any apostrophes from the Choice Labels $ob->ELEMENT_ENUM = str_replace($orig, $repl, label_decode($ob->ELEMENT_ENUM)); //Place $ in front of SAS value if using non-numeric coded values for dropdowns/radios $sas_val_enum_num = ""; //default $numericChoices = true; foreach (array_keys(parseEnum($ob->ELEMENT_ENUM)) as $key) { if (!is_numeric($key)) { // If at least one key is not numeric, then stop looping because we have all we need. $sas_val_enum_num = "$"; $numericChoices = false; break; } } if ($first_label) { if (!$single_element_enum) { $value_labels_spss .= "\n" . (string)$ob->FIELD_NAME . " "; } $R_factors_string .= "\ndata$" . (string)$ob->FIELD_NAME . ".factor = factor(data$" . (string)$ob->FIELD_NAME . ",levels=c("; $R_levels_string .= "\nlevels(data$" . (string)$ob->FIELD_NAME . ".factor)=c("; $first_label = false; if (!$large_name && !$single_element_enum) { $sas_value_label .= "\tvalue $sas_val_enum_num" . (string)$ob->FIELD_NAME . "_ "; $sas_format_string .= "\n\tformat " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_.;\n"; if ($numericChoices) { $stata_inf_label .= "\nlabel values " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_\n"; $stata_value_label = "label define " . (string)$ob->FIELD_NAME . "_ "; } } else if ($large_name && !$single_element_enum) { $sas_value_label .= "\tvalue $sas_val_enum_num" . $short_name . "_ "; $sas_format_string .= "\n\tformat " . $short_name . " " . $short_name . "_.;\n"; if ($numericChoices) { $stata_value_label .= "label define " . $short_name . "_ "; $stata_inf_label .= "\nlabel values " . $short_name . " " . $short_name . "_\n"; } } } else if (!$first_label) { if (!$single_element_enum) { $value_labels_spss .= "\n/" . (string)$ob->FIELD_NAME . " "; if (!$large_name) { $sas_value_label .= "\n\tvalue $sas_val_enum_num" . (string)$ob->FIELD_NAME . "_ "; $sas_format_string .= "\tformat " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_.;\n"; if ($numericChoices) { $stata_value_label .= "\nlabel define " . (string)$ob->FIELD_NAME . "_ "; $stata_inf_label .= "label values " . (string)$ob->FIELD_NAME . " " . (string)$ob->FIELD_NAME . "_\n"; } } } $R_factors_string .= "data$" . (string)$ob->FIELD_NAME . ".factor = factor(data$" . (string)$ob->FIELD_NAME . ",levels=c("; $R_levels_string .= "levels(data$" . (string)$ob->FIELD_NAME . ".factor)=c("; if ($large_name && !$single_element_enum) { $sas_value_label .= "\n\tvalue $sas_val_enum_num" . $short_name . "_ "; $sas_format_string .= "\tformat " . $short_name . " " . $short_name . "_.;\n"; if ($numericChoices) { $stata_value_label .= "\nlabel define " . $short_name . "_ "; //LS inserted this line 24-Feb-2012 $stata_inf_label .= "label values " . $short_name . " " . $short_name . "_\n"; } } } $first_new_line_explode_array = explode("\\n", (string)$ob->ELEMENT_ENUM); // Loop through multiple choice options $select_is_text = false; $select_determining_array = array(); for ($counter = 0; $counter < count($first_new_line_explode_array); $counter++) { if (!$single_element_enum) { // SAS: Add line break after 2 multiple choice options if (($counter % 2) == 0 && $counter != 0) { $sas_value_label .= "\n\t\t"; $value_labels_spss .= "\n\t"; } $second_comma_explode = explode(",", $first_new_line_explode_array[$counter], 2); $value_labels_spss .= "'" . trim($second_comma_explode[0]) . "' "; $value_labels_spss .= "'" . trim($second_comma_explode[1]) . "' "; if (!is_numeric(trim($second_comma_explode[0])) && is_numeric(substr(trim($second_comma_explode[0]), 0, 1))) { // if enum raw value is not a number BUT begins with a number, add quotes around it for SAS only (parsing issue) $sas_value_label .= "'" . trim($second_comma_explode[0]) . "'="; } else { $sas_value_label .= trim($second_comma_explode[0]) . "="; } $sas_value_label .= "'" . trim($second_comma_explode[1]) . "' "; if ($numericChoices) { $stata_value_label .= trim($second_comma_explode[0]) . " "; $stata_value_label .= "\"" . trim($second_comma_explode[1]) . "\" "; } $select_determining_array[] = $second_comma_explode[0]; $R_factors_string .= '"' . trim($second_comma_explode[0]) . '",'; $R_levels_string .= '"' . trim($second_comma_explode[1]) . '",'; } else { $select_determining_array[] = $second_comma_explode[0]; $R_factors_string .= '"' . trim($first_new_line_explode_array[$counter]) . '",'; $R_levels_string .= '"' . trim($first_new_line_explode_array[$counter]) . '",'; } } $R_factors_string = rtrim($R_factors_string, ","); $R_factors_string .= "))\n"; //pharris 09/28/05 $R_levels_string = rtrim($R_levels_string, ","); $R_levels_string .= ")\n"; if (!$single_element_enum) { $sas_value_label = rtrim($sas_value_label, " "); $sas_value_label .= ";"; } if (!$single_element_enum) { foreach ($select_determining_array as $value) { if (preg_match("/([A-Za-z])/", $value)) { $select_is_text = true; } } } else { foreach ($first_new_line_explode_array as $value) { if (preg_match("/([A-Za-z])/", $value)) { $select_is_text = true; } } } } else if (preg_match("/\+\+SQL\+\+/", (string)$ob->ELEMENT_ENUM)) { $select_is_text = true; } ################################################################################ ################################################################################ # If the ELEMENT_VALIDATION_TYPE is a float the data is define as a Number if ($ob->ELEMENT_VALIDATION_TYPE == "float" || $ob->ELEMENT_TYPE == "calc") { $spss_string .= $ob->FIELD_NAME . " (F8.2) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " best32. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " best12. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " best32. ;\n"; $sas_format .= "\tformat " . $short_name . " best12. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } // $spss_data_type_array[$x] = "NUMBER"; $spss_variable_level[] = $ob->FIELD_NAME . " (SCALE)"; } elseif ($ob->ELEMENT_TYPE == "slider" || $ob->ELEMENT_VALIDATION_TYPE == "int") { $spss_string .= $ob->FIELD_NAME . " (F8) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " best32. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " best12. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " best32. ;\n"; $sas_format .= "\tformat " . $short_name . " best12. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } // $spss_data_type_array[$x] = "NUMBER"; $spss_variable_level[] = $ob->FIELD_NAME . " (SCALE)"; # If the ELEMENT_VALIDATION_TYPE is a DATE a treat the data as a date } elseif ($ob->ELEMENT_VALIDATION_TYPE == "date" || $ob->ELEMENT_VALIDATION_TYPE == "date_ymd" || $ob->ELEMENT_VALIDATION_TYPE == "date_mdy" || $ob->ELEMENT_VALIDATION_TYPE == "date_dmy") { $spss_string .= $ob->FIELD_NAME . " (SDATE10) "; $spss_format_dates .= "FORMATS " . $ob->FIELD_NAME . "(ADATE10).\n"; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " yymmdd10. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " yymmdd10. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; $stata_date_format .= "\ntostring " . $ob->FIELD_NAME . ", replace"; $stata_date_format .= "\ngen _date_ = date(" . $ob->FIELD_NAME . ",\"YMD\")\n"; $stata_date_format .= "drop " . $ob->FIELD_NAME . "\n"; $stata_date_format .= "rename _date_ " . $ob->FIELD_NAME . "\n"; $stata_date_format .= "format " . $ob->FIELD_NAME . " %dM_d,_CY\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " yymmdd10. ;\n"; $sas_format .= "\tformat " . $short_name . " yymmdd10. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; $stata_date_format .= "\ntostring " . $short_name . ", replace"; $stata_date_format .= "\ngen _date_ = date(" . $short_name . ",\"YMD\")\n"; $stata_date_format .= "drop " . $short_name . "\n"; $stata_date_format .= "rename _date_ " . $short_name . "\n"; $stata_date_format .= "format " . $short_name . " %dM_d,_CY\n"; } # If the ELEMENT_VALIDATION_TYPE is TIME (military) } elseif ($ob->ELEMENT_VALIDATION_TYPE == "time") { $spss_string .= $ob->FIELD_NAME . " (A500) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " time5. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " time5. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " time5. ;\n"; $sas_format .= "\tformat " . $short_name . " time5. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } # If the ELEMENT_VALIDATION_TYPE is DATETIME or DATETIME_SECONDS // } elseif (substr($ob->ELEMENT_VALIDATION_TYPE, 0, 8) == "datetime") { # If the object type is select then the variable $select_is_text is checked to # see if it is a TEXT or a NUMBER and treated accordanly. } elseif ($ob->ELEMENT_TYPE == "yesno" || $ob->ELEMENT_TYPE == "truefalse" || $ob->ELEMENT_TYPE == "select" || $ob->ELEMENT_TYPE == "advcheckbox" || $ob->ELEMENT_TYPE == "radio") { if ($select_is_text) { $temp_trim = rtrim("varchar(500)", ")"); # Divides the string to get the number of caracters $temp_explode_number = explode("(", $temp_trim); $spss_string .= $ob->FIELD_NAME . " (A" . $temp_explode_number[1] . ") "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . " \$\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_format .= "\tformat " . $short_name . " \$" . $temp_explode_number[1] . ". ;\n"; $sas_input .= "\t\t" . $short_name . " \$\n"; } // $spss_data_type_array[$x] = "TEXT"; } else { $spss_string .= $ob->FIELD_NAME . " (F3) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " best32. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " best12. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . "\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " best32. ;\n"; $sas_format .= "\tformat " . $short_name . " best12. ;\n"; $sas_input .= "\t\t" . $short_name . "\n"; } // $spss_data_type_array[$x] = "NUMBER"; } # If the object type is text a treat the data like a text and look for the length # that is specified in the database } elseif ($ob->ELEMENT_TYPE == "text" || $ob->ELEMENT_TYPE == "calc" || $ob->ELEMENT_TYPE == "file") { $spss_string .= $ob->FIELD_NAME . " (A500) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " \$500. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " \$500. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . " \$\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " \$500. ;\n"; $sas_format .= "\tformat " . $short_name . " \$500. ;\n"; $sas_input .= "\t\t" . $short_name . " \$\n"; } # If the object type is textarea a treat the data like a text and specify a large # string size. } elseif ($ob->ELEMENT_TYPE == "textarea") { $spss_string .= $ob->FIELD_NAME . " (A30000) "; if (!$large_name) { $sas_informat .= "\tinformat " . $ob->FIELD_NAME . " \$5000. ;\n"; $sas_format .= "\tformat " . $ob->FIELD_NAME . " \$5000. ;\n"; $sas_input .= "\t\t" . $ob->FIELD_NAME . " \$\n"; } elseif ($large_name) { $sas_informat .= "\tinformat " . $short_name . " \$5000. ;\n"; $sas_format .= "\tformat " . $short_name . " \$5000. ;\n"; $sas_input .= "\t\t" . $short_name . " \$\n"; } // $spss_data_type_array[$x] = "TEXT"; } } // File names $today = date("Y-m-d_Hi"); $projTitleShort = substr(str_replace(" ", "", ucwords(preg_replace("/[^a-zA-Z0-9 ]/", "", html_entity_decode($app_title, ENT_QUOTES)))), 0, 20); $data_file_name = $projTitleShort . "_DATA_NOHDRS_" . $today . ".csv"; $data_file_name_WH = $projTitleShort . "_DATA_" . $today . ".csv"; $data_file_name_labels = $projTitleShort . "_DATA_LABELS_" . $today . ".csv"; $export_sps_file_name = $projTitleShort . "_SPSS_" . $today . ".sps"; $export_sas_file_name = $projTitleShort . "_SAS_" . $today . ".sas"; $export_R_file_name = $projTitleShort . "_R_" . $today . ".r"; $export_stata_file_name = $projTitleShort . "_STATA_" . $today . ".do"; //Finish up syntax files $spss_string = rtrim($spss_string); $spss_string .= ".\n"; $spss_string .= "\nVARIABLE LEVEL " . implode("\n\t/", $spss_variable_level) . ".\n"; $spss_string .= "\n" . substr_replace($spss_variable_label, ".", -3) . "\n\n"; $spss_string .= rtrim($value_labels_spss); $spss_string .= ".\n\n$spss_format_dates\nSET LOCALE=en_us.\nEXECUTE.\n"; $spss_string = str_replace("data_place_holder_name", $data_file_name, $spss_string); $sas_read_string .= "%macro removeOldFile(bye); %if %sysfunc(exist(&bye.)) %then %do; proc delete data=&bye.; run; " . "%end; %mend removeOldFile; %removeOldFile(work.redcap); data REDCAP; "; // Suggested change by Ray Balise //$sas_read_string .= "proc delete data=REDCAP;\nrun;\n\ndata REDCAP;"; // Added to prevent deleting all temp files //$sas_read_string .= "proc delete data=_ALL_;\nrun;\n\ndata REDCAP;"; $sas_read_string .= "%let _EFIERR_ = 0; "; $sas_read_string .= "infile '" . $data_file_name . "'"; $sas_read_string .= " delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=1 ; "; $sas_read_string .= "\n" . $sas_informat; $sas_read_string .= "\n" . $sas_format; $sas_read_string .= "\n" . $sas_input; $sas_read_string .= ";\n"; $sas_read_string .= "if _ERROR_ then call symput('_EFIERR_',\"1\");\n"; $sas_read_string .= "run;\n\nproc contents;run;\n\n"; $sas_read_string .= $sas_label_section . "\trun;\n"; $sas_value_label .= "\n\trun;\n"; $sas_format_string .= "\trun;\n"; $sas_read_string .= "\n" . $sas_value_label; $sas_read_string .= "\n" . $sas_format_string; $sas_read_string .= "\nproc contents data=redcap;"; $sas_read_string .= "\nproc print data=redcap;"; $sas_read_string .= "\nrun;\nquit;"; $stata_order = "order " . substr($stata_insheet, 8); $stata_insheet .= "using " . "\"" . $data_file_name . "\", nonames"; $stata_string .= $stata_insheet . "\n\n"; $stata_string .= "label data " . "\"" . $data_file_name . "\"" . "\n\n"; $stata_string .= $stata_value_label . "\n"; $stata_string .= $stata_inf_label . "\n\n"; $stata_string .= $stata_date_format . "\n"; $stata_string .= $stata_var_label . "\n"; $stata_string .= $stata_order . "\n"; $stata_string .= "set more off\ndescribe\n"; $R_string .= "#Read Data\ndata=read.csv('" . $data_file_name_WH . "')\n"; $R_string .= $R_label_string; $R_string .= $R_units_string; $R_string .= $R_factors_string; $R_string .= $R_levels_string; $today = date("Y-m-d-H-i-s"); $docs_comment = $docs_comment_WH = "Data export file created by $userid on $today"; $spss_docs_comment = "Spss syntax file created by $userid on $today"; $sas_docs_comment = "Sas syntax file created by $userid on $today"; $stata_docs_comment = "Stata syntax file created by $userid on $today"; $R_docs_comment = "R syntax file created by $userid on $today"; $data = prep($data); ######################################### // Replace any MS Word chacters in the data $data_csv = replaceMSchars($data_csv); $data_csv_labels = replaceMSchars($data_csv_labels); //Add comment in last field if these are date shifted $doc_rights = $do_date_shift ? "'DATE_SHIFT'" : "NULL"; // Set flag for checking if error occurs during saving of files to docs table $is_export_error = false; ### Creates the STATA syntax file $stata_string = strip_tags($stata_string); // Do NOT use addBOMtoUTF8() on Stata because BOM causes issues in syntax file $docs_size = strlen($stata_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_stata_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $stata_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $stata_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_stata_file_name, $stata_string, $stata_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the R syntax file $R_string = addBOMtoUTF8(strip_tags($R_string)); $docs_size = strlen($R_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_R_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $R_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $r_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_R_file_name, $R_string, $r_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the SAS syntax file $sas_read_string = addBOMtoUTF8(strip_tags($sas_read_string)); $docs_size = strlen($sas_read_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_sas_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $sas_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $sas_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_sas_file_name, $sas_read_string, $sas_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the data comma separeted value file WITHOUT headers $data_csv_temp = addBOMtoUTF8($data_csv); $docs_size = strlen($data_csv_temp); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment . "','application/csv',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $data_wo_hdr_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($data_file_name, $data_csv_temp, $data_wo_hdr_doc_id, $docs_size)) { $is_export_error = true; } } unset($data_csv_temp); ### Creates the data comma separeted value file WITH header $data_csv = addBOMtoUTF8($headers . $data_csv); $docs_size = strlen($data_csv); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name_WH . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment_WH . "','application/csv',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $data_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($data_file_name_WH, $data_csv, $data_doc_id, $docs_size)) { $is_export_error = true; } } unset($data_csv); ### Creates the SPSS syntax file $spss_string = addBOMtoUTF8(strip_tags($spss_string)); $docs_size = strlen($spss_string); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $export_sps_file_name . "', NULL, '" . TODAY . "','$docs_size','" . $spss_docs_comment . "','application/octet-stream',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $spss_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($export_sps_file_name, $spss_string, $spss_doc_id, $docs_size)) { $is_export_error = true; } } ### Creates the data comma separeted value file WITH LABELS $data_csv_labels = addBOMtoUTF8($headers_labels . $data_csv_labels); $docs_size = strlen($data_csv_labels); $export_sql = "INSERT INTO redcap_docs (project_id,docs_name,docs_file,docs_date,docs_size,docs_comment,docs_type,docs_rights,export_file) " . "VALUES ($project_id, '" . $data_file_name_labels . "', NULL, '" . TODAY . "','$docs_size','" . $docs_comment . "','application/csv',$doc_rights,1)"; if (!db_query($export_sql)) { $is_export_error = true; } else { // Get insert id $data_labels_doc_id = db_insert_id(); // Store the file in the file system if (!DataExport::storeExportFile($data_file_name_labels, $data_csv_labels, $data_labels_doc_id, $docs_size)) { $is_export_error = true; } } ######################################### //Catch the error if the CSV data file is too large for MySQL to handle if ($is_export_error) { include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_go.png'> {$lang['app_03']}"); print "<div class='red' style='margin:20px 0;'><img src='" . APP_PATH_IMAGES . "exclamation.png'> <b>{$lang['global_01']}:</b><br/>{$lang['data_export_tool_62']}"; if ($super_user) { if ($edoc_storage_option == '1') { print $lang['data_export_tool_136']; } elseif ($edoc_storage_option == '0') { print $lang['data_export_tool_135'] . " (<b>" . EDOC_PATH . "</b>)" . $lang['period']; } else { print $lang['data_export_tool_135'] . " " . $lang['period']; } print " " . $lang['data_export_tool_137']; } else { print "{$lang['data_export_tool_64']} <a href='mailto:$project_contact_email' style='font-family:Verdana;'>$project_contact_name</a> {$lang['data_export_tool_65']}"; } print "</div>"; renderPrevPageLink(PAGE); include APP_PATH_DOCROOT . 'ProjectGeneral/footer.php'; exit; } //Catch the error if there were data conversion problems if ($is_data_conversion_error) { include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_go.png'> {$lang['app_03']}"); print "<div class='red' style='margin:20px 0;'><img src='" . APP_PATH_IMAGES . "exclamation.png'> <b>{$lang['global_01']}:</b><br/>{$lang['data_export_tool_62']}"; if ($super_user) { print $lang['data_export_tool_63']; } else { print "{$lang['data_export_tool_64']} <a href='mailto:$project_contact_email' style='font-family:Verdana;'>$project_contact_name</a> {$lang['data_export_tool_65']}"; } print $is_data_conversion_error_msg; print "</div>"; renderPrevPageLink(PAGE); include APP_PATH_DOCROOT . 'ProjectGeneral/footer.php'; exit; } // Header include APP_PATH_DOCROOT . 'ProjectGeneral/header.php'; renderPageTitle("<img src='" . APP_PATH_IMAGES . "application_go.png'> {$lang['app_03']}"); print "<div style='text-align:center;padding-top:10px;max-width:700px;'> <span class='darkgreen' style='padding:8px 80px;'> <img src='" . APP_PATH_IMAGES . "tick.png' class='imgfix'> {$lang['data_export_tool_05']} </span> </div> <p><br>{$lang['data_export_tool_06']}<br><br>"; // Button back to previous page $prevPage = (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : PAGE_FULL . "?pid=$project_id"; print "<button class='jqbutton' onclick=\"window.location.href='$prevPage';\"> <img src='" . APP_PATH_IMAGES . "arrow_left.png' class='imgfix'> {$lang['config_functions_40']} </button>"; //Set the CSV icon to date-shifted look if the data in these files were date shifted if ($do_date_shift) { $csv_img = "download_csvdata_ds.gif"; $csvexcel_img = "download_csvexcel_raw_ds.gif"; $csvexcellabels_img = "download_csvexcel_labels_ds.gif"; } else { $csv_img = "download_csvdata.gif"; $csvexcel_img = "download_csvexcel_raw.gif"; $csvexcellabels_img = "download_csvexcel_labels.gif"; } // If Send-It is not enabled for Data Export and File Repository, then hide the link to utilize Send-It $sendItLinkDisplay = ($sendit_enabled == '1' || $sendit_enabled == '3') ? "" : "display:none;"; //Table header print "<div style='max-width:700px;'>"; print "<table style='border: 1px solid #DODODO; border-collapse: collapse; width: 100%'> <tr class='grp2'> <td colspan='2' style='font-family:Verdana;font-size:12px;text-align:right;'> </td> <td style='font-family:Verdana;font-size:12px;text-align:center;'> {$lang['docs_58']}<br>{$lang['data_export_tool_51']} </td> </tr>"; //Excel print '<tr class="odd"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'excelicon.gif" title="' . $lang['data_export_tool_15'] . '" alt="' . $lang['data_export_tool_15'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_15'] . '</b><br> ' . $lang['data_export_tool_118'] . '<br><br> <i>' . $lang['global_02'] . ': ' . $lang['data_export_tool_17'] . '</i> </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_labels_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csvexcellabels_img . '" title="' . $lang['data_export_tool_60'] . '" alt="' . $lang['data_export_tool_60'] . '"></a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csvexcel_img . '" title="' . $lang['data_export_tool_60'] . '" alt="' . $lang['data_export_tool_60'] . '"></a> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\'$("#sendit_' . $data_doc_id . '").toggle("blind",{},"fast");\'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $data_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_labels_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_120'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_119'] . '</a> </div> </div> </div> </td> </tr>'; //SPSS print '<tr class="even noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'spsslogo_small.png" title="' . $lang['data_export_tool_07'] . '" alt="' . $lang['data_export_tool_07'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_07'] . '</b><br />' . $lang['global_24'] . $lang['colon'] . " " . $lang['data_export_tool_08'] . '<br> <a href="javascript:;" style="text-decoration:underline;font-size:11px;" onclick=\'$("#spss_detail").toggle("fade");\'>' . $lang['data_export_tool_08b'] . '</a> <div style="display:none;border-top:1px solid #aaa;margin-top:5px;padding-top:3px;" id="spss_detail"> <b>' . $lang['data_export_tool_01'] . '</b><br>' . $lang['data_export_tool_08c'] . ' <font color="green">/folder/subfolder/</font> (e.g., /Users/administrator/documents/)<br><br>' . $lang['data_export_tool_08d'] . ' <br><font color=green>FILE HANDLE data1 NAME=\'DATA.CSV\' LRECL=90000.</font><br><br>' . $lang['data_export_tool_08e'] . '<br> <font color=green>FILE HANDLE data1 NAME=\'<font color=red>/folder/subfolder/</font>DATA.CSV\' LRECL=90000.</font><br><br>' . $lang['data_export_tool_08f'] . ' </div> </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $spss_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_spss.gif" title="' . $lang['data_export_tool_68'] . '" alt="' . $lang['data_export_tool_68'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_wo_hdr_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="padding-left:11px;text-align:left;"> <a href="' . APP_PATH_WEBROOT . 'DataExport/spss_pathway_mapper.php?pid=' . $project_id . '" ><img src="' . APP_PATH_IMAGES . 'download_pathway_mapper.gif" title="' . $lang['data_export_tool_70'] . '" alt="' . $lang['data_export_tool_70'] . '"></a> </div> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $spss_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $spss_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $spss_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_wo_hdr_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; //SAS print '<tr class="odd noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'saslogo_small.png" title="' . $lang['data_export_tool_11'] . '" alt="' . $lang['data_export_tool_11'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_11'] . '</b><br />' . $lang['global_24'] . $lang['colon'] . " " . $lang['data_export_tool_130'] . '<br> <a href="javascript:;" style="text-decoration:underline;font-size:11px;" onclick=\'$("#sas_detail").toggle("fade");\'>' . $lang['data_export_tool_08b'] . '</a> <div style="display:none;border-top:1px solid #aaa;margin-top:5px;padding-top:3px;" id="sas_detail"> <b>' . $lang['data_export_tool_131'] . '</b><br>' . $lang['data_export_tool_132'] . ' <font color="green">/folder/subfolder/</font> (e.g., /Users/administrator/documents/)<br><br>' . $lang['data_export_tool_133'] . ' <br>... <font color=green>infile \'DATA.CSV\' delimiter = \',\' MISSOVER DSD lrecl=32767 firstobs=1 ;</font><br><br>' . $lang['data_export_tool_08e'] . '<br> ... <font color=green>infile \'<font color=red>/folder/subfolder/</font>DATA.CSV\' delimiter = \',\' MISSOVER DSD lrecl=32767 firstobs=1 ;</font><br><br>' . $lang['data_export_tool_134'] . ' </div> </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $sas_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_sas.gif" title="' . $lang['data_export_tool_74'] . '" alt="' . $lang['data_export_tool_74'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_wo_hdr_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="padding-left:11px;text-align:left;"> <a href="' . APP_PATH_WEBROOT . 'DataExport/sas_pathway_mapper.php?pid=' . $project_id . '" ><img src="' . APP_PATH_IMAGES . 'download_pathway_mapper.gif"></a> </div> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $sas_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $sas_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $sas_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_wo_hdr_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; //R print '<tr class="even noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'rlogo_small.png" title="' . $lang['data_export_tool_09'] . '" alt="' . $lang['data_export_tool_09'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;" valign="top"> <b>' . $lang['data_export_tool_09'] . '</b><br />' . $lang['data_export_tool_10'] . ' </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $r_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_r.gif" title="' . $lang['data_export_tool_75'] . '" alt="' . $lang['data_export_tool_75'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_doc_id . '&exporttype=R"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $r_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $r_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $r_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; //STATA print '<tr class="odd noncsv"> <td valign="top" style="text-align:center;width:60px;padding-top:10px;border:0px;border-bottom:1px solid #D0D0D0;border-left:1px solid #D0D0D0;"> <img src="' . APP_PATH_IMAGES . 'statalogo_small.png" title="' . $lang['data_export_tool_13'] . '" alt="' . $lang['data_export_tool_13'] . '" /> </td> <td style="font-family:Verdana;font-size:11px;padding:10px;border-bottom:1px solid #D0D0D0;" valign="top"> <b>' . $lang['data_export_tool_13'] . '</b><br />' . $lang['data_export_tool_14'] . ' </td> <td valign="top" style="text-align:right;width:100px;padding-top:10px;border-bottom:1px solid #D0D0D0;"> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $stata_doc_id . '"> <img src="' . APP_PATH_IMAGES . 'download_stata.gif" title="' . $lang['data_export_tool_76'] . '" alt="' . $lang['data_export_tool_76'] . '"> </a> <a href="' . APP_PATH_WEBROOT . 'FileRepository/file_download.php?pid=' . $project_id . '&id=' . $data_wo_hdr_doc_id . '"> <img src="' . APP_PATH_IMAGES . $csv_img . '" title="' . $lang['data_export_tool_69'] . '" alt="' . $lang['data_export_tool_69'] . '"></a> <div style="text-align:left;padding:5px 0 1px;' . $sendItLinkDisplay . '"> <div style="line-height:5px;"> <img src="' . APP_PATH_IMAGES . 'mail_small.png" style="position: relative; top: 5px;"><a href="javascript:;" style="color:#666;font-size:10px;text-decoration:underline;" onclick=\' $("#sendit_' . $stata_doc_id . '").toggle("blind",{},"fast"); \'>' . $lang['data_export_tool_66'] . '</a> </div> <div id="sendit_' . $stata_doc_id . '" style="display:none;padding:4px 0 4px 6px;"> <div> • <a href="javascript:;" onclick="popupSendIt(' . $stata_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_71'] . '</a> </div> <div> • <a href="javascript:;" onclick="popupSendIt(' . $data_wo_hdr_doc_id . ',2);" style="font-size:10px;">' . $lang['data_export_tool_72'] . '</a> </div> </div> </div> </td> </tr>'; print '</table>'; print '</div><br><br><br><br>'; }
function check_existing_user($ldap_user) { if (User::getUserInfo($ldap_user['uid']) == false && !empty($ldap_user['mail'])) { global $allow_create_db_default; $sql = "\n\t\t\tinsert into redcap_user_information \n\t\t\t\t(username, user_email, user_firstname, user_lastname, user_creation, allow_create_db) \n\t\t\tvalues ('" . prep($ldap_user['uid']) . "', \n\t\t\t\t'" . prep($ldap_user['mail']) . "', \n\t\t\t\t'" . prep($ldap_user['sudisplaynamefirst']) . "', \n\t\t\t\t'" . prep($ldap_user['sudisplaynamelast']) . " (added via userrights)', \n\t\t\t\tNOW(), \n\t\t\t\t{$allow_create_db_default})"; $q = db_query($sql); if ($q) { log_event($sql, "redcap_user_information", "MANAGE", $ldap_user['uid'], "username = '******'uid']}'", "Update user info"); } return false; } else { return true; } }
*/ code_bodsys($project_id, $subject_id, $event_id, $event['dcv_aedecod'], $event['dcv_aebodsys'], 'dcv_aebodsys', $debug, $recode_soc); /** * HVN_AEBODSYS */ code_bodsys($project_id, $subject_id, $event_id, $event['hvn_aedecod'], $event['hvn_aebodsys'], 'hvn_aebodsys', $debug, $recode_soc); /** * EOT_AEBODSYS */ code_bodsys($project_id, $subject_id, $event_id, $event['eot_aedecod'], $event['eot_aebodsys'], 'eot_aebodsys', $debug, $recode_soc); /** * CM_CMDECOD */ if (isset($event['cm_cmtrt']) && $event['cm_cmtrt'] != '') { $med = array(); $med_result = db_query("SELECT DISTINCT drug_name FROM _whodrug_mp_us WHERE drug_name = '" . prep($event['cm_cmtrt']) . "'"); if ($med_result) { $med = db_fetch_assoc($med_result); if ($event['cm_cmdecod'] == '' && isset($med['drug_name']) && $med['drug_name'] != '') { update_field_compare($subject_id, $project_id, $event_id, $med['drug_name'], $event['cm_cmdecod'], 'cm_cmdecod', $debug); } } } else { update_field_compare($subject_id, $project_id, $event_id, '', $event['cm_cmdecod'], 'cm_cmdecod', $debug); } /** * cm_suppcm_mktstat * PRESCRIPTION or OTC */ if (isset($event['cm_cmdecod']) && $event['cm_cmdecod'] != '') { update_field_compare($subject_id, $project_id, $event_id, get_conmed_mktg_status($event['cm_cmdecod']), $event['cm_suppcm_mktstat'], 'cm_suppcm_mktstat', $debug);
function leyka_do_donations_export() { if (empty($_GET['leyka-donations-export-csv-excel'])) { return; } ob_start(); $meta_query = array('relation' => 'AND'); if (!empty($_GET['campaign'])) { $meta_query[] = array('key' => 'leyka_campaign_id', 'value' => (int) $_GET['campaign']); } if (!empty($_GET['payment_type'])) { $meta_query[] = array('key' => 'leyka_payment_type', 'value' => $_GET['payment_type']); } if (!empty($_GET['gateway_pm'])) { if (strpos($_GET['gateway_pm'], 'gateway__') !== false) { $meta_query[] = array('key' => 'leyka_gateway', 'value' => str_replace('gateway__', '', $_GET['gateway_pm'])); } elseif (strpos($_GET['gateway_pm'], 'pm__') !== false) { $meta_query[] = array('key' => 'leyka_payment_method', 'value' => str_replace('pm__', '', $_GET['gateway_pm'])); } } $args = array('post_type' => Leyka_Donation_Management::$post_type, 'post_status' => isset($_GET['post_status']) && in_array($_GET['post_status'], array_keys(leyka()->get_donation_statuses())) ? $_GET['post_status'] : 'any', 'm' => $_GET['month-year'], 'meta_query' => $meta_query, 'nopaging' => true); $donations = get_posts(apply_filters('leyka_donations_export_query_args', $args)); if (isset($_GET['export-tech'])) { function prep($text) { return '"' . str_replace(array(';', '"'), array('', ''), $text) . '"'; } $file_lines = array(array('hash', 'Domain', 'Org_name', 'Timestamp', 'Date', 'Email_hash', 'Donor_name hash', 'Sum', 'Currency', 'Gateway_pm', 'Donation_status', 'Campaign_title', 'Campaign_URL', 'Payment_title', 'Target_sum', 'Campaign_target_state', 'Campaign_is_finished')); for ($i = 0; $i < count($file_lines[0]); $i++) { $file_lines[0][$i] = prep($file_lines[0][$i]); } $domain = str_replace(array('http:', 'https:'), '', home_url()); foreach ($donations as $donation) { $donation = new Leyka_Donation($donation); $campaign = new Leyka_Campaign($donation->campaign_id); $donation_fields = array(prep(wp_hash($domain . $donation->date_timestamp . $donation->sum . $donation->id)), prep($domain), prep(leyka_options()->opt('org_full_name')), prep($donation->date_timestamp), prep(date(get_option('date_format') . ', H:i', $donation->date_timestamp)), prep(wp_hash($donation->donor_email)), prep(wp_hash($donation->donor_name)), prep((int) $donation->sum), prep($donation->currency), $donation->payment_type == 'correction' ? prep($donation->pm_id) : prep($donation->gateway_label . '-' . $donation->pm_id), prep($donation->status), prep($campaign->title), prep($campaign->url), prep($campaign->payment_title), prep((int) $campaign->target), prep($campaign->target_state), prep((int) $campaign->is_finished)); $file_lines[] = $donation_fields; } for ($i = 0; $i < count($file_lines); $i++) { $file_lines[$i] = implode(';', $file_lines[$i]); } ob_clean(); header('Content-type: application/vnd.ms-excel'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Pragma: no-cache'); header('Content-Disposition: attachment; filename="donations-tech-' . $domain . '-' . date('d.m.Y-H.i.s') . '.csv"'); die("sep=;\n" . implode("\r\n", $file_lines)); } else { $file_lines = array(apply_filters('leyka_donations_export_headers', array('ID', 'Имя донора', 'Email', 'Тип платежа', 'Способ платежа', 'Сумма', 'Дата пожертвования', 'Статус', 'Кампания'))); foreach ($donations as $donation) { $donation = new Leyka_Donation($donation); $campaign = new Leyka_Campaign($donation->campaign_id); $donation_fields = apply_filters('leyka_donations_export_line', array($donation->id, $donation->donor_name, $donation->donor_email, $donation->payment_type_label, $donation->payment_method_label, $donation->sum . ' ' . $donation->currency_label, $donation->date, $donation->status_label, $campaign->title)); $file_lines[] = $donation_fields; } require_once LEYKA_PLUGIN_DIR . 'inc/excel-writer/SimpleExcel.php'; $excel = new SimpleExcel('csv'); $excel->writer->setData($file_lines); $excel->writer->setDelimiter(','); ob_clean(); header('Content-type: application/vnd.ms-excel'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Pragma: no-cache'); header('Content-Disposition: attachment; filename="donations-' . date('d.m.Y-H.i.s') . '.csv"'); // Do iconv so Excel could open it: die(iconv('UTF-8', apply_filters('leyka_donations_export_content_charset', 'windows-1251'), "sep=,\n" . $excel->writer->saveString())); } }
/** * @param $record * @param $event_id * @param $group_id * @param $debug */ function schedule_surveys($record, $event_id, $group_id, $debug) { global $Proj, $project_id, $user_rights, $table_pk; /** * if the user is in a DAG */ if ($user_rights['group_id'] != "") { /** * does this record exist? */ $q = db_query("SELECT 1 from redcap_data WHERE project_id = $project_id AND record = '$record' LIMIT 1"); if (db_num_rows($q) > 0) { /** * is the record in this users DAG? */ $q = db_query("SELECT 1 from redcap_data WHERE project_id = $project_id AND record = '$record' AND field_name = '__GROUPID__' AND value = '{$user_rights['group_id']}' LIMIT 1"); if (db_num_rows($q) < 1) { /** * record is not in Users DAG! */ REDCap::logEvent('Scheduled record is not in users DAG', '', '', $record, $event_id, $project_id); exit; } } } /** * check to see if the subject has an existing schedule on an existing arm */ $sub = "SELECT DISTINCT e.arm_id from redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id"; $sched_arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = $project_id AND arm_id IN (" . pre_query($sub) . ")"); if ($sched_arm_result) { $trt = Treatment::getTrtInfo($record); if ($debug) { error_log(print_r($trt, true)); } $tx_start_date = $trt['rfxstdtc']; $rand_date = $trt['rand_date']; $dates = array(); $arm_num = db_result($sched_arm_result, 0, 'arm_num'); if (isset($arm_num) && $arm_num != '') { // subject has an existing schedule. keep existing event_id > arm structure if ($arm_num != '1') { // make sure we don't put anything in the first arm $q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = $arm_num order by m.day_offset, m.descrip"); if ($q) { while ($row = db_fetch_assoc($q)) { // if we have no $arm_num, this will be empty /** * get the event date ($rand_date for baseline and $tx_start_date + day_offset) */ $row['day_offset'] = $arm_num != $trt['timing_arm_num'] ? $trt['timing_offsets'][$row['descrip']] : $row['day_offset']; if (in_array($row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year'))) { $this_event_date = isset($rand_date) && $rand_date != '' ? add_date($rand_date, $row['day_offset']) : null; } else { $this_event_date = isset($tx_start_date) && $tx_start_date != '' ? add_date($tx_start_date, $row['day_offset']) : null; } $dates[$row['event_id']] = $this_event_date; } db_free_result($q); } } else { REDCap::logEvent('Scheduling attempted in invalid arm', '', '', $record, $event_id, $project_id); } } else { // subject's schedule is new. put dates into event_ids for this arm $arm_result = db_query("SELECT arm_num FROM redcap_events_arms WHERE project_id = '$project_id' AND arm_name = '{$trt['arm']}'"); if ($arm_result) { $arm_num = db_result($arm_result, 0, 'arm_num'); if ($arm_num != '1') { $q = db_query("SELECT * from redcap_events_metadata m, redcap_events_arms a WHERE a.project_id = $project_id AND a.arm_id = m.arm_id AND a.arm_num = $arm_num order by m.day_offset, m.descrip"); if ($q) { while ($row = db_fetch_assoc($q)) { // if we have no $arm_num, this will be empty /** * get the event date ($rand_date for baseline and $tx_start_date + day_offset) */ if (in_array($row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year'))) { $this_event_date = isset($rand_date) && $rand_date != '' ? add_date($rand_date, $row['day_offset']) : null; } else { $this_event_date = isset($tx_start_date) && $tx_start_date != '' ? add_date($tx_start_date, $row['day_offset']) : null; } $dates[$row['event_id']] = $this_event_date; } db_free_result($q); } } else { REDCap::logEvent('Scheduling attempted in invalid arm', '', '', $record, $event_id, $project_id); } db_free_result($arm_result); } } if ($debug) { error_log(print_r($dates, true)); } if (!empty($dates)) { /** * do we have an existing schedule? */ $sql = "SELECT c.event_date, c.baseline_date, e.* FROM redcap_events_calendar c, redcap_events_metadata e WHERE c.project_id = $project_id AND c.record = '$record' AND c.event_id = e.event_id AND e.arm_id IN (" . pre_query($sub) . ")"; $sched_result = db_query($sql); if ($sched_result) { $sql_all = array(); $sql_errors = array(); if (db_num_rows($sched_result) > 0) { while ($sched_row = db_fetch_assoc($sched_result)) { $base_date = in_array($sched_row['descrip'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc']; /** * if the scheduled date is in the $dates array, we don't care about it, so ignore it and remove from $dates * if we have an existing schedule and the dates have changed, update the schedule and remove from $dates * if the base date has changed, update it and the schedule * whatever is left will be new dates, insert into schedule */ if ($dates[$sched_row['event_id']] == $sched_row['event_date']) { unset($dates[$sched_row['event_id']]); } if (isset($dates[$sched_row['event_id']]) && $dates[$sched_row['event_id']] != '' && $sched_row['event_date'] != $dates[$sched_row['event_id']]) { // the date has changed. update the date. $sql = "UPDATE redcap_events_calendar SET event_date = '{$dates[$sched_row['event_id']]}' WHERE record = '$record' AND project_id = '$project_id' AND group_id = '$group_id' AND event_id = '{$sched_row['event_id']}' AND event_date = '{$sched_row['event_date']}'"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; log_event($sql, "redcap_events_calendar", "MANAGE", $record, $sched_row['event_id'], "Update calendar event"); } else { $sql_errors[] = $sql; } } else { error_log($sql); } unset($dates[$sched_row['event_id']]); } if ($base_date != $sched_row['baseline_date']) { // the base_date has changed. this will only occur if the treatment start date or randomization date are changed in the study. $sql = "UPDATE redcap_events_calendar SET baseline_date = '" . prep($base_date) . "' WHERE record = '$record' AND project_id = '$project_id' AND group_id = '$group_id' AND event_id = '{$sched_row['event_id']}' AND baseline_date = '{$sched_row['baseline_date']}'"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; log_event($sql, "redcap_events_calendar", "MANAGE", $record, $sched_row['event_id'], "Update calendar event"); } else { $sql_errors[] = $sql; } } else { error_log($sql); } unset($dates[$sched_row['event_id']]); } } foreach ($dates AS $date_event_id => $date) { //Loop through dates and add them to the schedule $base_date = in_array($Proj->eventInfo[$date_event_id]['name'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc']; if (isset($date) && $date != "") { //Add to table $sql = "INSERT INTO redcap_events_calendar (record, project_id, group_id, event_id, event_date, event_time, event_status, baseline_date) VALUES ('$record', $project_id, " . checkNull($group_id) . ", '" . prep($date_event_id) . "', '" . prep($date) . "', '" . null . "', 0, '$base_date')"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; } else { $sql_errors[] = $sql; } } else { error_log($sql); } } else { REDCap::logEvent('Schedule start date is not a valid date', '', '', $record, $event_id, $project_id); } } log_event(implode(";\n", $sql_all), "redcap_events_calendar", "MANAGE", $_GET['idnumber'], "$table_pk = '$record'", "Perform scheduling"); } else { foreach ($dates AS $date_event_id => $date) { //Loop through dates and add them to the schedule $base_date = in_array($Proj->eventInfo[$date_event_id]['name'], array('Baseline', 'EOT+1Year', 'EOT+3Year')) ? $trt['rand_date'] : $trt['rfxstdtc']; if (isset($date) && $date != "") { //Add to table $sql = "INSERT INTO redcap_events_calendar (record, project_id, group_id, event_id, event_date, event_time, event_status, baseline_date) VALUES ('$record', $project_id, " . checkNull($group_id) . ", '" . prep($date_event_id) . "', '" . prep($date) . "', '" . null . "', 0, '$base_date')"; if (!$debug) { if (db_query($sql)) { $sql_all[] = $sql; } else { $sql_errors[] = $sql; } } else { error_log($sql); } } else { REDCap::logEvent('Schedule start date is not a valid date', '', '', $record, $event_id, $project_id); } } log_event(implode(";\n", $sql_all), "redcap_events_calendar", "MANAGE", $_GET['idnumber'], "$table_pk = '$record'", "Perform scheduling"); } } db_free_result($sched_result); } db_free_result($sched_arm_result); } }
function test1() { $X = null; prep(Ent::createLoader(1, 2, 3, 4)); }
//For lock/unlock records and e-signatures, show locks by any forms that are locked (if a record is pulled up on data entry page) if (PAGE == "DataEntry/index.php" && isset($fetched)) { $entry_num = isset($entry_num) ? $entry_num : ""; // Lock records $sql = "select form_name, timestamp from redcap_locking_data where project_id = $project_id and event_id = {$_GET['event_id']} and record = '" . prep($fetched.$entry_num). "'"; $q = db_query($sql); while ($row = db_fetch_array($q)) { $locked_forms[$row['form_name']] = " <img id='formlock-{$row['form_name']}' src='".APP_PATH_IMAGES."lock_small.png' title='".cleanHtml($lang['bottom_59'])." " . DateTimeRC::format_ts_from_ymd($row['timestamp']) . "'>"; } // E-signatures $sql = "select form_name, timestamp from redcap_esignatures where project_id = $project_id and event_id = {$_GET['event_id']} and record = '" . prep($fetched.$entry_num). "'"; $q = db_query($sql); while ($row = db_fetch_array($q)) { $this_esignts = " <img id='formesign-{$row['form_name']}' src='".APP_PATH_IMAGES."tick_shield_small.png' title='" . cleanHtml($lang['data_entry_224'] . " " . DateTimeRC::format_ts_from_ymd($row['timestamp'])) . "'>"; if (isset($locked_forms[$row['form_name']])) { $locked_forms[$row['form_name']] .= $this_esignts; } else { $locked_forms[$row['form_name']] = $this_esignts; } } } ## Render the form list for this project list ($form_count,$formString) = renderFormMenuList($this_app_name,$fetched,$locked_forms,$hidden_edit,$entry_num,$visit_forms); $dataEntry .= $formString;
$timer['start_main'] = microtime(true); /** * Main loop */ foreach ($vals_array as $subj_usubjid => $subj_val_array) { //d($subj_val_array); $seq = 1; $constants['USUBJID'] = $constants['STUDYID'] . '-' . $subj_usubjid; foreach ($subj_val_array AS $subj_array) { if ($subj_array['aeterm'] != '') { /** * Get MedDRA terms and codes */ $aeterm = $subj_array['aeterm']; $meddra = array(); $meddra_result = db_query($meddra_query . " WHERE llt.aellt = '" . prep($subj_array['aedecod']) . "'"); if ($meddra_result) { $meddra = db_fetch_assoc($meddra_result); db_free_result($meddra_result); } $query[] = '(' . fix_null($constants['STUDYID']) . ',' . fix_null($constants['DOMAIN']) . ',' . fix_null($constants['USUBJID']) . ',' . fix_null($seq) . ',' . fix_null($subj_array['aeterm']) . ',' . fix_null($subj_array['aemodify']) . ',' . fix_null($meddra['aellt']) . ',' . fix_null($meddra['aelltcd']) . ',' . fix_null($subj_array['aedecod']) . ',' . fix_null($meddra['aeptcd']) . ',' .
require "../system/incl.php"; $table = "category"; $errors = array(); $edit = false; $weights = array(); for ($i = 1; $i < 21; $weights[] = $i++) { } $smarty->assign("weights", $weights); if (isset($_POST['save'])) { $id = prep($_POST['id']); $name_ru = prep($_POST['name_ru']); $name_en = prep($_POST['name_en']); $menuname_ru = prep($_POST['menuname_ru']); $menuname_en = prep($_POST['menuname_en']); $weight = prep($_POST['weight']); // validation if (empty($name_ru) || empty($name_en)) { $errors[] = "Название не может быть пустым!"; } if (count($errors) > 0) { if ($id > 0) { $edit = true; } $data['id'] = $_POST['id']; $data['weight'] = $_POST['weight']; $data['name_ru'] = str_replace("\\'", "'", $_POST['name_ru']); $data['name_en'] = str_replace("\\'", "'", $_POST['name_en']); $data['menuname_ru'] = str_replace("\\'", "'", $_POST['menuname_ru']); $data['menuname_en'] = str_replace("\\'", "'", $_POST['menuname_en']); $smarty->assign("data", $data);
echo db_error() . "<br />" . $delete_query; } } else { echo "<div class='red'>ALL values for this field are hidden. DELETE value: {$empty_row['value']}.</div>"; show_var($history, "{$empty_row['record']}, {$empty_row['event_id']}, {$empty_row['field_name']}", 'red'); show_var($delete_query); } } else { /** * All are not hidden. If the most recent value shown is not THIS VALUE, then delete the row */ $mutable_history = $history; $most_recent_event = array_pop($mutable_history); if (($most_recent_event['value'] != $empty_row['value']) || $most_recent_event['value'] == '') { $rows_deleted++; $delete_query = "DELETE FROM redcap_data WHERE record = '{$empty_row['record']}' AND project_id = '$project_id' AND event_id = '{$empty_row['event_id']}' AND field_name = '{$empty_row['field_name']}' AND value = '" . prep($empty_row['value']) . "' LIMIT 1"; if (!$debug) { if (db_query($delete_query)) { target_log_event($delete_query, 'redcap_data', 'delete', $empty_row['record'], "{$empty_row['field_name']} = '{$empty_row['value']}'", 'Delete hidden blank value', '', $project_id, $empty_row['event_id']); } else { error_log("SQL DELETE FAILED: " . db_error() . ': ' . $delete_query); echo db_error() . "<br />" . $delete_query; } } else { echo "<div class='red'>NON-MATCHING value is shown. THIS value ({$empty_row['value']}) is hidden. DELETE row.</div>"; show_var($history, "{$empty_row['record']}, {$empty_row['event_id']}, {$empty_row['field_name']}", 'red'); show_var($most_recent_event['value'], 'MOST RECENT', 'red'); show_var($delete_query); } } else { /**
//Edit the visit status case "edit_status": $sql = "update redcap_events_calendar set event_status = '" . prep($_GET['event_status']) . "' where cal_id = {$_GET['cal_id']}"; $q = db_query($sql); if (!$q) { exit("<b>{$lang['global_01']}!</b>"); } else { $msg = $msg_saved_status; //LOGGING log_event($sql, "redcap_events_calendar", "MANAGE", $_GET['cal_id'], calLogChange($_GET['cal_id']), "Edit calendar event"); } break; //Edit notes //Edit notes case "edit_notes": $sql = "update redcap_events_calendar set notes = '" . prep($_POST['notes']) . "' where cal_id = {$_POST['cal_id']}"; if (db_query($sql)) { //LOGGING log_event($sql, "redcap_events_calendar", "MANAGE", $_POST['cal_id'], calLogChange($_POST['cal_id']), "Edit calendar event"); } exit; break; } } //DATE Field if ($_GET['view'] == "date") { print "<div id='change_date' style='display:block;'>\n\t\t\t\t<b>" . DateTimeRC::format_ts_from_ymd($event_date) . " (" . DateTimeRC::getDay($event_date) . ")</b> "; // Dont' allow user to change date here if tied to an Event (need to change on Scheduling page where it might affect other scheduled dates) if ($row['event_id'] == "") { print "<a href='javascript:;' style='text-decoration:underline;font-size:11px;' onclick=\"\$('#change_date').css({'display':'none'});\$('#save_date').css({'display':'block'});\">{$lang['calendar_popup_ajax_03']}</a>"; }
/** * @param $record * @param $redcap_event_name * @param $instrument * @param $debug */ public static function code_terms($record, $redcap_event_name, $instrument, $debug) { global $Proj, $project_id, $tx_fragment_labels; $this_event_id = $Proj->getEventIdUsingUniqueEventName($redcap_event_name); switch ($instrument) { case 'ae_coding': $recode_llt = false; $recode_pt = true; $recode_soc = true; $prefix = 'ae'; /** * AE_AEMODIFY */ $fields = array("ae_aeterm", "ae_oth_aeterm", "ae_aemodify"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['ae_aeterm']), fix_case($data[$record][$this_event_id]['ae_oth_aeterm']), $data[$record][$this_event_id]['ae_aemodify'], 'ae_aemodify', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded AE_AEMODIFY {$data[$record][$this_event_id]['ae_aemodify']}: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aeterm']} - {$data[$record][$this_event_id]['ae_oth_aeterm']}"); } /** * PREFIX_AEDECOD * uses $tx_prefixes preset array */ $fields = array($prefix . "_aemodify", $prefix . "_aedecod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aemodify"], $data[$record][$this_event_id][$prefix . "_aedecod"], $prefix . "_aedecod", $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_AEDECOD {$data[$record][$this_event_id][$prefix . '_aedecod']}: subject=$record, event=$this_event_id for AEMODIFY {$data[$record][$this_event_id][$prefix . '_aemodify']}"); } /** * PREFIX_AEBODSYS * uses $tx_prefixes preset array */ $fields = array($prefix . "_aedecod", $prefix . "_aebodsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aedecod"], $data[$record][$this_event_id][$prefix . "_aebodsys"], $prefix . "_aebodsys", $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id][$prefix . "_aedecod"]}"); } unset($data); break; /** * ADVERSE EVENTS * ACTION: auto-code AE */ case 'adverse_events': $recode_llt = true; $recode_pt = true; $recode_soc = true; /** * AE_AEDECOD */ $fields = array("ae_aeterm", "ae_oth_aeterm", "ae_aemodify"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['ae_aeterm']), fix_case($data[$record][$this_event_id]['ae_oth_aeterm']), $data[$record][$this_event_id]['ae_aemodify'], 'ae_aemodify', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded AE_AEMODIFY {$data[$record][$this_event_id]['ae_aemodify']}: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aeterm']} - {$data[$record][$this_event_id]['ae_oth_aeterm']}"); } /** * AE_AEDECOD */ $fields = array("ae_aemodify", "ae_aedecod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['ae_aemodify']), $data[$record][$this_event_id]['ae_aedecod'], 'ae_aedecod', $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded AE_AEDECOD {$data[$record][$this_event_id]['ae_aedecod']}: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aemodify']}"); } /** * AE_AEBODSYS */ $fields = array("ae_aedecod", "ae_aebodsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['ae_aedecod'], $data[$record][$this_event_id]['ae_aebodsys'], 'ae_aebodsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aedecod']}"); } unset($data); break; /** * MEDICAL HISTORY * ACTION: auto-code MH */ case 'key_medical_history': $recode_llt = false; $recode_pt = true; $recode_soc = true; $mh_prefixes = array('othpsy', 'othca'); /** * MH_MHMODIFY */ foreach ($mh_prefixes AS $prefix) { $fields = array($prefix . "_oth_mhterm", $prefix . "_mhmodify"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id][$prefix . "_oth_mhterm"]), '', $data[$record][$this_event_id][$prefix . "_mhmodify"], $prefix . "_mhmodify", $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHMODIFY {$data[$record][$this_event_id][$prefix . "_mhmodify"]}: subject=$record, event=$this_event_id for MH {$data[$record][$this_event_id][$prefix . "_oth_mhterm"]}"); } /** * PREFIX_MHDECOD * uses $mh_prefixes preset array */ $fields = array($prefix . "_mhmodify", $prefix . "_mhdecod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhmodify"], $data[$record][$this_event_id][$prefix . "_mhdecod"], $prefix . "_mhdecod", $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHDECOD {$data[$record][$this_event_id][$prefix . '_mhdecod']}: subject=$record, event=$this_event_id for MHMODIFY {$data[$record][$this_event_id][$prefix . '_mhmodify']}"); } /** * PREFIX_mhBODSYS * uses $mh_prefixes preset array */ $fields = array($prefix . "_mhdecod", $prefix . "_mhbodsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhdecod"], $data[$record][$this_event_id][$prefix . "_mhbodsys"], $prefix . "_mhbodsys", $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHBODSYS {$data[$record][$this_event_id][$prefix . "_mhbodsys"]}: subject=$record, event=$this_event_id for MHDECOD {$data[$record][$this_event_id][$prefix . "_mhdecod"]}"); } } unset($data); break; /** * EOT */ case 'early_discontinuation_eot': $recode_llt = true; $recode_pt = true; $recode_soc = true; /** * EOT_AEDECOD */ $data = REDCap::getData('array', $record, array("eot_suppds_ncmpae", "eot_oth_suppds_ncmpae", "eot_aemodify", "eot_dsterm"), $this_event_id); $ptdata = REDCap::getData('array', $record, array("eot_aemodify", "eot_aedecod"), $this_event_id); $soc_data = REDCap::getData('array', $record, array("eot_aedecod", "eot_aebodsys"), $this_event_id); foreach ($data[$record][$this_event_id] AS $event) { if ($event['eot_dsterm'] == 'ADVERSE_EVENT') { code_llt($project_id, $record, $this_event_id, fix_case($event['eot_suppds_ncmpae']), fix_case($event['eot_oth_suppds_ncmpae']), $event['eot_aemodify'], 'eot_aemodify', $debug, $recode_llt); if ($debug) { error_log("INFO (TESTING EOT): Coded EOT_AEMODIFY {$event['eot_aemodify']}: subject=$record, event=$this_event_id for AE {$event['eot_suppds_ncmpae']} - {$event['eot_oth_suppds_ncmpae']}"); } /** * AE_AEDECOD */ foreach ($ptdata[$record][$this_event_id] AS $ptevent) { code_pt($project_id, $record, $this_event_id, fix_case($ptevent['eot_aemodify']), $ptevent['eot_aedecod'], 'eot_aedecod', $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded EOT_AEDECOD {$ptevent['eot_aedecod']}: subject=$record, event=$this_event_id for AEMODIFY {$ptevent['eot_aemodify']}"); } } /** * EOT_AEBODSYS */ foreach ($soc_data[$record][$this_event_id] AS $soc_event) { code_bodsys($project_id, $record, $this_event_id, $soc_event['eot_aedecod'], $soc_event['eot_aebodsys'], 'eot_aebodsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$soc_event['eot_aedecod']}"); } } } } unset($data); unset($ptdata); unset($soc_data); break; /** * TX stop AEs */ case 'ribavirin_administration': case 'harvoni_administration': case 'ombitasvir_paritaprevir': case 'dasabuvir': case 'zepatier_administration': $recode_llt = true; $recode_pt = true; $recode_soc = true; $tx_prefix = array_search(substr($instrument, 0, strpos($instrument, '_')), $tx_fragment_labels); /** * AE_AEMODIFY */ $fields = array($tx_prefix . '_suppcm_cmncmpae', $tx_prefix . '_oth_suppcm_cmncmpae', $tx_prefix . '_aemodify'); $data = REDCap::getData('array', $record, $fields, $this_event_id); foreach ($data[$record][$this_event_id] AS $event) { code_llt($project_id, $record, $this_event_id, fix_case($event[$tx_prefix . '_suppcm_cmncmpae']), fix_case($event[$tx_prefix . '_oth_suppcm_cmncmpae']), $event[$tx_prefix . '_aemodify'], $tx_prefix . '_aemodify', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded AE_AEMODIFY {$event[$tx_prefix . '_aemodify']}: subject=$record, event=$this_event_id for AE {$event[$tx_prefix . '_suppcm_cmncmpae']} - {$event[$tx_prefix . '_oth_suppcm_cmncmpae']}"); } } /** * AE_AEDECOD */ $fields = array($tx_prefix . '_aemodify', $tx_prefix . "_aedecod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); foreach ($data[$record][$this_event_id] AS $event) { code_pt($project_id, $record, $this_event_id, fix_case($event[$tx_prefix . '_aemodify']), $event[$tx_prefix . '_aedecod'], $tx_prefix . '_aedecod', $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded AE_AEDECOD {$event[$tx_prefix . '_aedecod']}: subject=$record, event=$this_event_id for AE {$event[$tx_prefix . '_aemodify']}"); } } /** * AE_AEBODSYS */ $fields = array($tx_prefix . '_aedecod', $tx_prefix . '_aebodsys'); $data = REDCap::getData('array', $record, $fields, $this_event_id); foreach ($data[$record][$this_event_id] AS $event) { code_bodsys($project_id, $record, $this_event_id, $event[$tx_prefix . '_aedecod'], $event[$tx_prefix . '_aebodsys'], $tx_prefix . '_aebodsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$event[$tx_prefix . '_aedecod']}"); } } unset($data); break; /** * CONMEDS * ACTION: auto-code CONMEDS */ case 'conmeds': /** * CM_CMDECOD */ $recode_cm = true; $recode_llt = true; $recode_pt = true; $recode_soc = true; $recode_atc = true; $fields = array("cm_cmtrt", "cm_cmdecod", "cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_cm($project_id, $record, $this_event_id, $data[$record][$this_event_id], $debug, $recode_cm); /** * cm_suppcm_mktstat * PRESCRIPTION or OTC */ $fields = array("cm_cmdecod", "cm_suppcm_mktstat"); $data = REDCap::getData('array', $record, $fields, $this_event_id); foreach ($data as $subject_id => $subject) { foreach ($subject as $event_id => $event) { if (isset($event['cm_cmdecod']) && $event['cm_cmdecod'] != '') { update_field_compare($subject_id, $project_id, $event_id, get_conmed_mktg_status($event['cm_cmdecod']), $event['cm_suppcm_mktstat'], 'cm_suppcm_mktstat', $debug); if ($debug) { error_log("DEBUG: $subject_id Marketing Status = " . get_conmed_mktg_status($event['cm_cmdecod'])); } } } } /** * CM_SUPPCM_INDCOD */ $fields = array("cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcmodf"); $data = REDCap::getData('array', $record, $fields, $this_event_id); /** * re-code all nutritional support to nutritional supplement */ if ($data[$record][$this_event_id]['cm_oth_cmindc'] == 'Nutritional support') { $data[$record][$this_event_id]['cm_oth_cmindc'] = 'Nutritional supplement'; } code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['cm_cmindc']), fix_case($data[$record][$this_event_id]['cm_oth_cmindc']), $data[$record][$this_event_id]['cm_suppcm_indcmodf'], 'cm_suppcm_indcmodf', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded INDC LLT: {} subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_cmindc']}"); } /** * CM_SUPPCM_INDCOD */ $fields = array("cm_suppcm_indcmodf", "cm_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcmodf'], $data[$record][$this_event_id]['cm_suppcm_indcod'], 'cm_suppcm_indcod', $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded INDC PT: subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_suppcm_indcod']}"); } /** * CM_SUPPCM_INDCSYS */ $fields = array("cm_suppcm_indcod", "cm_suppcm_indcsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcod'], $data[$record][$this_event_id]['cm_suppcm_indcsys'], 'cm_suppcm_indcsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['cm_suppcm_indcod']}"); } /** * CM_SUPPCM_ATCNAME * CM_SUPPCM_ATC2NAME */ $fields = array("cm_cmdecod", "cm_suppcm_atcname", "cm_suppcm_atc2name"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_atc($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_cmdecod'], $data[$record][$this_event_id]['cm_suppcm_atcname'], $data[$record][$this_event_id]['cm_suppcm_atc2name'], $debug, $recode_atc); if ($debug) { error_log("DEBUG: Coded ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['cm_cmdecod']}"); } break; case 'transfusions': $recode_cm = true; $recode_llt = true; $recode_soc = true; $recode_atc = true; /** * XFSN_CMDECOD */ $fields = array("xfsn_cmtrt", "xfsn_cmdecod", "xfsn_cmindc", "xfsn_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_cm($project_id, $record, $this_event_id, $data[$record][$this_event_id], $debug, $recode_cm); /** * XFSN_SUPPCM_INDCOD */ $fields = array("xfsn_cmindc", "xfsn_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['xfsn_cmindc']), fix_case($data[$record][$this_event_id]['xfsn_oth_cmindc']), $data[$record][$this_event_id]['xfsn_suppcm_indcod'], 'xfsn_suppcm_indcod', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded XFSN INDC: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}"); } /** * XFSN_SUPPCM_INDCSYS */ $fields = array("xfsn_suppcm_indcod", "xfsn_suppcm_indcsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_suppcm_indcod'], $data[$record][$this_event_id]['xfsn_suppcm_indcsys'], 'xfsn_suppcm_indcsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded XFSN INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['xfsn_suppcm_indcod']}"); } /** * XFSN_SUPPCM_ATCNAME * XFSN_SUPPCM_ATC2NAME */ $fields = array("xfsn_cmdecod", "xfsn_suppcm_atcname", "xfsn_suppcm_atc2name"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_atc_xfsn($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_cmdecod'], $data[$record][$this_event_id]['xfsn_suppcm_atcname'], $data[$record][$this_event_id]['xfsn_suppcm_atc2name'], $debug, $recode_atc); if ($debug) { error_log("DEBUG: Coded XFSN ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}"); } unset($data); break; case 'mh_coding': $recode_llt = false; $recode_pt = true; $recode_soc = true; $mh_prefixes = array('othpsy', 'othca'); /** * MH_MHMODIFY */ foreach ($mh_prefixes AS $prefix) { $fields = array($prefix . "_oth_mhterm", $prefix . "_mhmodify"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id][$prefix . "_oth_mhterm"]), '', $data[$record][$this_event_id][$prefix . "_mhmodify"], $prefix . "_mhmodify", $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHMODIFY {$data[$record][$this_event_id][$prefix . "_mhmodify"]}: subject=$record, event=$this_event_id for MH {$data[$record][$this_event_id][$prefix . "_oth_mhterm"]}"); } /** * PREFIX_MHDECOD * uses $mh_prefixes preset array */ $fields = array($prefix . "_mhmodify", $prefix . "_mhdecod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhmodify"], $data[$record][$this_event_id][$prefix . "_mhdecod"], $prefix . "_mhdecod", $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHDECOD {$data[$record][$this_event_id][$prefix . '_mhdecod']}: subject=$record, event=$this_event_id for MHMODIFY {$data[$record][$this_event_id][$prefix . '_mhmodify']}"); } /** * PREFIX_mhBODSYS * uses $mh_prefixes preset array */ $fields = array($prefix . "_mhdecod", $prefix . "_mhbodsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhdecod"], $data[$record][$this_event_id][$prefix . "_mhbodsys"], $prefix . "_mhbodsys", $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHBODSYS {$data[$record][$this_event_id][$prefix . "_mhbodsys"]}: subject=$record, event=$this_event_id for MHDECOD {$data[$record][$this_event_id][$prefix . "_mhdecod"]}"); } } unset($data); break; case 'cm_coding': $recode_llt = false; $recode_pt = true; $recode_soc = true; $recode_atc = false; $recode_cm = true; /** * CM_CMDECOD */ $fields = array("cm_cmtrt", "cm_cmdecod", "cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_cm($project_id, $record, $this_event_id, $data[$record][$this_event_id], $debug, $recode_cm); if ($debug) { error_log("DEBUG: Coded CONMED: subject=$record, event=$this_event_id for CMTRT {$data[$record][$this_event_id]['cm_cmtrt']}"); } /** * cm_suppcm_mktstat * PRESCRIPTION or OTC */ $fields = array("cm_cmdecod", "cm_suppcm_mktstat"); $data = REDCap::getData('array', $record, $fields, $this_event_id); foreach ($data as $subject_id => $subject) { foreach ($subject as $event_id => $event) { if (isset($event['cm_cmdecod']) && $event['cm_cmdecod'] != '') { update_field_compare($subject_id, $project_id, $event_id, get_conmed_mktg_status($event['cm_cmdecod']), $event['cm_suppcm_mktstat'], 'cm_suppcm_mktstat', $debug); if ($debug) { error_log("DEBUG: $subject_id Marketing Status = " . get_conmed_mktg_status($event['cm_cmdecod'])); } } } } /** * CM_SUPPCM_INDCOD */ $fields = array("cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcmodf"); $data = REDCap::getData('array', $record, $fields, $this_event_id); /** * re-code all nutritional support to nutritional supplement */ if ($data[$record][$this_event_id]['cm_oth_cmindc'] == 'Nutritional support') { $data[$record][$this_event_id]['cm_oth_cmindc'] = 'Nutritional supplement'; } code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['cm_cmindc']), fix_case($data[$record][$this_event_id]['cm_oth_cmindc']), $data[$record][$this_event_id]['cm_suppcm_indcmodf'], 'cm_suppcm_indcmodf', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded INDC LLT: {} subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_cmindc']}"); } /** * CM_SUPPCM_INDCOD */ $fields = array("cm_suppcm_indcmodf", "cm_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcmodf'], $data[$record][$this_event_id]['cm_suppcm_indcod'], 'cm_suppcm_indcod', $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded INDC PT: subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_suppcm_indcod']}"); } /** * CM_SUPPCM_INDCSYS */ $fields = array("cm_suppcm_indcod", "cm_suppcm_indcsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcod'], $data[$record][$this_event_id]['cm_suppcm_indcsys'], 'cm_suppcm_indcsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['cm_suppcm_indcod']}"); } /** * CM_SUPPCM_ATCNAME * CM_SUPPCM_ATC2NAME */ $fields = array("cm_cmdecod", "cm_suppcm_atcname", "cm_suppcm_atc2name"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_atc_soc($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_cmdecod'], $data[$record][$this_event_id]['cm_suppcm_atcname'], $data[$record][$this_event_id]['cm_suppcm_atc2name'], $debug, $recode_atc); if ($debug) { error_log("DEBUG: Coded ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['cm_cmdecod']}"); } /** * XFSN_CMDECOD */ $fields = array("xfsn_cmtrt", "xfsn_cmdecod", "xfsn_cmindc", "xfsn_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); foreach ($data AS $subject_id => $subject) { foreach ($subject AS $event_id => $event) { if (isset($event['xfsn_cmtrt']) && $event['xfsn_cmtrt'] != '') { $med = array(); $med_result = db_query("SELECT DISTINCT drug_coded FROM _target_xfsn_coding WHERE drug_name = '" . prep($event['xfsn_cmtrt']) . "'"); if ($med_result) { $med = db_fetch_assoc($med_result); if (isset($med['drug_coded']) && $med['drug_coded'] != '') { update_field_compare($subject_id, $project_id, $event_id, $med['drug_coded'], $event['xfsn_cmdecod'], 'xfsn_cmdecod', $debug); } } if ($debug) { error_log("DEBUG: Coded Transfusion: subject=$subject_id, event=$event_id for CMTRT {$event['xfsn_cmtrt']}"); } } else { update_field_compare($subject_id, $project_id, $event_id, '', $event['xfsn_cmdecod'], 'xfsn_cmdecod', $debug); } } } /** * XFSN_SUPPCM_INDCOD */ $fields = array("xfsn_cmindc", "xfsn_suppcm_indcod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['xfsn_cmindc']), fix_case($data[$record][$this_event_id]['xfsn_oth_cmindc']), $data[$record][$this_event_id]['xfsn_suppcm_indcod'], 'xfsn_suppcm_indcod', $debug, $recode_llt); if ($debug) { error_log("DEBUG: Coded XFSN INDC: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}"); } /** * XFSN_SUPPCM_INDCSYS */ $fields = array("xfsn_suppcm_indcod", "xfsn_suppcm_indcsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_suppcm_indcod'], $data[$record][$this_event_id]['xfsn_suppcm_indcsys'], 'xfsn_suppcm_indcsys', $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded XFSN INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['xfsn_suppcm_indcod']}"); } /** * XFSN_SUPPCM_ATCNAME * XFSN_SUPPCM_ATC2NAME */ $fields = array("xfsn_cmdecod", "xfsn_suppcm_atcname", "xfsn_suppcm_atc2name"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_atc_xfsn($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_cmdecod'], $data[$record][$this_event_id]['xfsn_suppcm_atcname'], $data[$record][$this_event_id]['xfsn_suppcm_atc2name'], $debug, $recode_atc); if ($debug) { error_log("DEBUG: Coded XFSN ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}"); } unset($data); break; case 'ex_coding': $recode_pt = true; $recode_soc = true; $prefix = 'eot'; /** * PREFIX_AEDECOD * uses $tx_prefixes preset array */ $fields = array($prefix . "_aemodify", $prefix . "_aedecod"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aemodify"], $data[$record][$this_event_id][$prefix . "_aedecod"], $prefix . "_aedecod", $debug, $recode_pt); if ($debug) { error_log("DEBUG: Coded " . strtoupper($prefix) . "_AEDECOD {$data[$record][$this_event_id][$prefix . '_aedecod']}: subject=$record, event=$this_event_id for AEMODIFY {$data[$record][$this_event_id][$prefix . '_aemodify']}"); } /** * PREFIX_AEBODSYS * uses $tx_prefixes preset array */ $fields = array($prefix . "_aedecod", $prefix . "_aebodsys"); $data = REDCap::getData('array', $record, $fields, $this_event_id); code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aedecod"], $data[$record][$this_event_id][$prefix . "_aebodsys"], $prefix . "_aebodsys", $debug, $recode_soc); if ($debug) { error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id][$prefix . "_aedecod"]}"); } unset($data); break; default: break; } }
public function updateDetUrl($an) { global $data_entry_trigger_url; // Create a DET URL: $base = 'https://' . $_SERVER['SERVER_NAME']; $parse_url = parse_url($_SERVER['PHP_SELF']); $path = dirname($parse_url['path']); $data_entry_trigger_url = $base . $path . '/?an=' . $an; $sql = "update redcap_projects set data_entry_trigger_url = '" . prep($data_entry_trigger_url) . "' where project_id = " . PROJECT_ID . " LIMIT 1;"; $q = db_query($sql); // echo "$sql"; }
function get_captcha_uri() { global $cformsSettings; $cap = $cformsSettings['global']['cforms_captcha_def']; $c1 = prep($cap['c1'], '3'); $c2 = prep($cap['c2'], '5'); $ac = prep(urlencode($cap['ac']), urlencode('abcdefghijkmnpqrstuvwxyz23456789')); $i = prep($cap['i'], ''); $h = prep($cap['h'], 25); $w = prep($cap['w'], 115); $c = prep($cap['c'], '000066'); $l = prep($cap['l'], '000066'); $f = prep($cap['f'], 'font4.ttf'); $a1 = prep($cap['a1'], -12); $a2 = prep($cap['a2'], 12); $f1 = prep($cap['f1'], 17); $f2 = prep($cap['f2'], 19); $bg = prep($cap['bg'], '1.gif'); return "&c1={$c1}&c2={$c2}&ac={$ac}&i={$i}&w={$w}&h={$h}&c={$c}&l={$l}&f={$f}&a1={$a1}&a2={$a2}&f1={$f1}&f2={$f2}&b={$bg}"; }
public static function checkRecordNameCaseSensitive($record) { global $table_pk; // Make sure record is a string $record = "{$record}"; // Query to get back-end record name $sql = "select trim(record) from redcap_data where project_id = " . PROJECT_ID . " and field_name = '{$table_pk}' \n\t\t\t\tand record = '" . prep($record) . "' limit 1"; $q = db_query($sql); if (db_num_rows($q) > 0) { $backEndRecordName = "" . db_result($q, 0); if ($backEndRecordName != "" && $backEndRecordName !== $record) { // They don't match, return the back-end value. return $backEndRecordName; } } // Return same value submitted. Trim it, just in case. return trim($record); }