Enables or disables Kint, can globally enforce the rendering mode. If called without parameters, returns the
current mode.
public static enabled ( mixed $forceMode = null ) : mixed | ||
$forceMode | mixed | null or void - return current mode false - disable (no output) true - enable and detect cli automatically Kint::MODE_* - enable and force selected mode disregarding detection and function shorthand (s()/d()), note that you can still override this with the "~" modifier |
return | mixed | previously set value if a new one is passed |
protected function setUpKint() { if (class_exists('Kint')) { Kint::$cliDetection = true; Kint::$maxLevels = 10; Kint::$theme = 'aante-light'; Kint::$displayCalledFrom = true; Kint::enabled(Kint::MODE_RICH); } }
/** * {@inheritDoc} */ public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); \Kint::enabled($config['enabled']); \Kint::$maxLevels = $config['nesting_depth']; \Kint::$maxStrLength = $config['string_length']; $container->setParameter('cg_kint.enabled', $config['enabled']); $container->setParameter('cg_kint.nesting_depth', $config['nesting_depth']); $container->setParameter('cg_kint.string_length', $config['string_length']); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('services.xml'); }
/** * Returns a lite debug string of passed on variables * * @return string */ function debugLite() { if (!Kint::enabled()) { return ''; } else { ob_start(); $argv = func_get_args(); echo '<pre>'; foreach ($argv as $k => $v) { $k && (print "\n\n"); echo s($v); } echo '</pre>' . "\n"; return ob_get_clean(); } }
/** * Application constructor. * * @param object $loader The autoloader instance. * @param array $config The custom configuration of the application. * @param string $appPath The application absolute path. * @param array $classesMap The custom classes map of the application. */ public function __construct($loader, array $config = [], $appPath = null, array $classesMap = []) { # Utilities $this->utilities = new Utilities($this); # Register start time $this->utilities->registerStartTime(); # Store application path $this->utilities->setApplicationPath($appPath); # Store classes map $this['class'] = $this->utilities->setClassesMap($classesMap); # Call container constructor parent::__construct($this->utilities->setConfiguration($config)); # Register core services providers $this->register(new FilesystemServiceProvider()); $this->register(new FinderServiceProvider()); $this->register(new HttpServiceProvider()); $this->register(new LoggerServiceProvider()); $this->register(new MessagesServiceProvider()); $this->register(new RouterServiceProvider()); $this->register(new SupportServiceProvider()); $this->register(new TemplatingServiceProvider()); $this->register(new TriggersServiceProvider()); # Enables the portablity layer and configures PHP for UTF-8 Utf8Bootup::initAll(); # Redirects to an UTF-8 encoded URL if it's not already the case Utf8Bootup::filterRequestUri(); # Normalizes HTTP inputs to UTF-8 NFC Utf8Bootup::filterRequestInputs(); # Print errors in debug mode if ($this['debug']) { $whoops = new WhoopsRun(); $whoops->pushHandler(new WhoopsHandler()); $whoops->register(); } else { ErrorHandler::register($this['phpLogger']); } # Only enable Kint in debug mode \Kint::enabled($this['debug']); }
$timer = array(); $timer['start'] = microtime(true); /** * includes * adjust dirname depth as needed */ $base_path = dirname(dirname(dirname(__FILE__))); require_once $base_path . "/redcap_connect.php"; require_once $base_path . '/plugins/includes/functions.php'; require_once APP_PATH_DOCROOT . '/ProjectGeneral/header.php'; /** * restricted use */ $allowed_pids = array('38'); REDCap::allowProjects($allowed_pids); Kint::enabled($enable_kint); /** * project metadata */ global $Proj; $first_event_id = $Proj->firstEventId; $plugin_title = "Derive stuff"; /** * plugin title */ echo "<h3>$plugin_title</h3>"; /** * MAIN */ if ($debug) { $timer['main_start'] = microtime(true);
public static function init() { self::$_enableColors = Kint::$cliColors && (DIRECTORY_SEPARATOR === '/' || getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON'); return Kint::enabled() === Kint::MODE_PLAIN ? '<style>.-kint i{color:#d00;font-style:normal}.-kint u{color:#030;text-decoration:none;font-weight:bold}</style>' : ''; }
/** * Dump information about variables, accepts any number of parameters, supports modifiers: * * clean up any output before kint and place the dump at the top of page: * - Kint::dump() * ***** * expand all nodes on display: * ! Kint::dump() * ***** * dump variables disregarding their depth: * + Kint::dump() * ***** * return output instead of displaying it (also disables ajax/cli detection): * @ Kint::dump() * ***** * disable ajax and cli auto-detection and just output as requested (plain/rich): * ~ Kint::dump() * * Modifiers are supported by all dump wrapper functions, including Kint::trace(). Space is optional. * * * You can also use the following shorthand to display debug_backtrace(): * Kint::dump( 1 ); * * Passing the result from debug_backtrace() to kint::dump() as a single parameter will display it as trace too: * $trace = debug_backtrace( true ); * Kint::dump( $trace ); * Or simply: * Kint::dump( debug_backtrace() ); * * * @param mixed $data * * @return void|string */ public static function dump($data = null) { if (!Kint::enabled()) { return ''; } # find caller information list($names, $modifiers, $callee, $previousCaller, $miniTrace) = self::_getPassedNames(defined('DEBUG_BACKTRACE_IGNORE_ARGS') ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) : debug_backtrace()); # process modifiers: @, +, !, ~ and - if (strpos($modifiers, '-') !== false) { self::$_firstRun = true; while (ob_get_level()) { ob_end_clean(); } } if (strpos($modifiers, '!') !== false) { $expandedByDefaultOldValue = self::$expandedByDefault; self::$expandedByDefault = true; } if (strpos($modifiers, '+') !== false) { $maxLevelsOldValue = self::$maxLevels; self::$maxLevels = false; } if (strpos($modifiers, '@') !== false) { $firstRunOldValue = self::$_firstRun; self::$_firstRun = true; } # disable mode detection if (strpos($modifiers, '@') !== false || strpos($modifiers, '~') === false) { $modeOldValue = self::$mode; $isAjaxOldValue = self::$_isAjax; if (self::$_detected === 'ajax') { self::$_isAjax = true; } elseif (self::$_detected === 'cli' && self::$cliDetection) { # cli detection is checked here as you can toggle the feature for individual dumps self::$mode = self::$cliColors ? 'cli' : 'whitespace'; } } $decoratorsMap = array('cli' => 'Kint_Decorators_Cli', 'plain' => 'Kint_Decorators_Plain', 'rich' => 'Kint_Decorators_Rich', 'whitespace' => 'Kint_Decorators_Whitespace'); $decorator = $decoratorsMap[self::$mode]; $output = $decorator::wrapStart($callee); $trace = false; if ($names === array(null) && func_num_args() === 1 && $data === 1) { $trace = debug_backtrace(true); # Kint::dump(1) shorthand } elseif (func_num_args() === 1 && is_array($data)) { $trace = $data; # test if the single parameter is result of debug_backtrace() } $trace and $trace = self::_parseTrace($trace); if ($trace) { $output .= $decorator::decorateTrace($trace); } else { $data = func_num_args() === 0 ? array("[[no arguments passed]]") : func_get_args(); foreach ($data as $k => $argument) { kintParser::reset(); $output .= $decorator::decorate(kintParser::factory($argument, $names[$k])); } } $output .= $decorator::wrapEnd($callee, $miniTrace, $previousCaller); if (strpos($modifiers, '~') === false) { self::$mode = $modeOldValue; } if (strpos($modifiers, '!') !== false) { self::$expandedByDefault = $expandedByDefaultOldValue; } if (strpos($modifiers, '+') !== false) { self::$maxLevels = $maxLevelsOldValue; } if (strpos($modifiers, '@') !== false) { self::$_firstRun = $firstRunOldValue; return $output; } if (self::$_isAjax) { $data = rawurlencode($output); $chunks = array(); while (strlen($data) > 4096) { $chunks[] = substr($data, 0, 4096); $data = substr($data, 4096); } $chunks[] = $data; for ($i = 0, $c = count($chunks); $i < $c; $i++) { $index = self::$_headerNo++; $name = 'kint' . ($index > 0 ? "-{$index}" : ''); header("{$name}: {$chunks[$i]}"); } if (strpos($modifiers, '~') === false) { self::$_isAjax = $isAjaxOldValue; } return ''; } echo $output; return ''; }
<?php //-------------------------------------------------------------- // Examples: Quandl API //-------------------------------------------------------------- require "./vendor/autoload.php"; if (file_exists(__DIR__ . '/.env')) { $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); } Kint::enabled(true); $api_key = getenv('QUANDL_API_KEY'); $symbol = "GOOG/NASDAQ_AAPL"; // Modify this call to check different samples $data = example1($api_key, $symbol); d($data); // Example 1: Hello Quandl function example1($api_key, $symbol) { $quandl = new Royopa\Quandl\Quandl(); return $quandl->getSymbol($symbol); } // Example 2: API Key + JSON function example2($api_key, $symbol) { $quandl = new Royopa\Quandl\Quandl($api_key); $quandl->format = "json"; return $quandl->getSymbol($symbol); } // Example 3: Date Range + Last URL function example3($api_key, $symbol)
/** * @param $record * @param $debug */ public static function set_treatment_exp($record, $debug) { global $Proj, $project_id; $trt_exp_array = array('gen2_mhoccur', 'pegifn_mhoccur', 'triple_mhoccur', 'nopegifn_mhoccur', 'dm_suppdm_trtexp'); $enable_kint = $debug && (isset($record) && $record != '') ? true : false; Kint::enabled($enable_kint); $baseline_event_id = $Proj->firstEventId; $data = REDCap::getData('array', $record, $trt_exp_array, $baseline_event_id); if ($debug) { error_log(print_r($data, TRUE)); } foreach ($data AS $subject_id => $subject) { /** * Are you experienced? */ $experienced = false; foreach ($subject AS $event_id => $event) { if ($event['simsof_mhoccur'] == 'Y' || $event['simsofrbv_mhoccur'] == 'Y' || $event['pegifn_mhoccur'] == 'Y' || $event['triple_mhoccur'] == 'Y' || $event['nopegifn_mhoccur'] == 'Y') { $experienced = true; } } $trt_exp = $experienced ? 'Y' : 'N'; update_field_compare($subject_id, $project_id, $baseline_event_id, $trt_exp, $subject[$baseline_event_id]['dm_suppdm_trtexp'], 'dm_suppdm_trtexp', $debug); } }
/** * Dump information about a variable * * @param mixed $data * @return void|string */ public static function dump($data) { if (!Kint::enabled()) { return; } // decide what action to take based on parameter count if (func_num_args() === 0) { // todo if no arguments were provided, dump the whole environment // self::env(); // todo return; } // find caller information $prevCaller = array(); $trace = debug_backtrace(); while ($callee = array_pop($trace)) { if (strtolower($callee['function']) === 'd' || strtolower($callee['function']) === 'dd' || isset($callee['class']) && strtolower($callee['class']) === strtolower(__CLASS__)) { break; } else { $prevCaller = $callee; } } list($names, $modifier) = self::_getPassedNames($callee, ''); // catches @, + and - switch ($modifier) { case '-': self::$_firstRun = TRUE; ob_clean(); break; case '+': $prevLevels = self::$maxLevels; self::$maxLevels = 0; break; } $ret = self::_css() . self::_wrapStart($callee); foreach (func_get_args() as $k => $argument) { $dump = self::_dump($argument); list($class, $plus) = self::_collapsed(); $ret .= "<dl><dt{$class}>{$plus}" . (!empty($names[$k]) ? "<dfn>{$names[$k]}</dfn> " : "") . "{$dump}</dl>"; } $ret .= self::_wrapEnd($callee, $prevCaller); self::$_firstRun = FALSE; if ($modifier === '+') { self::$maxLevels = $prevLevels; } if ($modifier === '@') { self::$_firstRun = TRUE; return $ret; } ob_start('kint_debug_globals'); echo $ret; ob_end_flush(); }
/** * @see s() * * [!!!] IMPORTANT: execution will halt after call to this function * * @return string */ function sd() { if (!Kint::enabled()) { return ''; } Kint::enabled(PHP_SAPI === 'cli' ? Kint::MODE_WHITESPACE : Kint::MODE_PLAIN); call_user_func_array(array('Kint', 'dump'), func_get_args()); die; }
/** * Dumps/Echo out array data with print_r or var_dump if xdebug installed * * Will check if xdebug is installed and if so will use standard var_dump, * otherwise will use print_r inside <pre> tags to give formatted output. * * @since 1.1.9 * * @param $field_data */ function dump_array($field_data) { if (!$field_data) { _e('No field data found!', 'wp-job-manager-field-editor'); return; } require_once WPJM_FIELD_EDITOR_PLUGIN_DIR . "/includes/kint/Kint.class.php"; Kint::enabled(TRUE); Kint::dump($field_data); Kint::enabled(FALSE); }
/** * @param $record * @param $debug */ public static function set_hcvrna_outcome($record, $debug) { global $Proj, $project_id, $ie_criteria_labels; $enable_kint = $debug && (isset($record) && $record != '') ? true : false; Kint::enabled($enable_kint); $baseline_event_id = $Proj->firstEventId; $fieldsets = array('abstracted' => array(array('date_field' => 'hcv_lbdtc'), array('value_field' => 'hcv_lbstresn'), array('detect_field' => 'hcv_supplb_hcvdtct')), 'imported' => array(array('date_field' => 'hcv_im_lbdtc'), array('value_field' => 'hcv_im_lbstresn'), array('detect_field' => 'hcv_im_supplb_hcvdtct'), array('trust' => 'hcv_im_nxtrust'))); $data = array(); $field_translate = array(); $reverse_translate = array(); foreach ($fieldsets as $formtype => $fieldset) { $filter_logic = $formtype == 'abstracted' ? "[hcv_lbdtc] != ''" : "[hcv_im_lbdtc] != '' AND [hcv_im_nxtrust] != 'N'"; $fields = array(); foreach ($fieldset as $field) { foreach ($field as $key => $value) { $fields[] = $value; $field_translate[$formtype][$key] = $value; $reverse_translate[$formtype][$value] = $key; } } $data[$formtype] = REDCap::getData('array', $record, $fields, null, null, false, false, false, $filter_logic); } /** * Main */ $ie_fields = array('ie_ietestcd'); $ie_data = REDCap::getData('array', $record, $ie_fields); $date_fields = array('dm_usubjid', 'dm_rfstdtc', 'dis_suppfa_txendt', 'eot_dsterm', 'dis_dsstdy', 'hcv_suppfa_fuelgbl', 'hcv_suppfa_nlgblrsn', 'hcv_suppfa_hcvout', 'hcv_suppfa_wk10rna', 'hcv_suppfa_lastbloq', 'dis_suppds_funcmprsn', 'hcv_suppfa_fudue', 'dm_suppdm_hcvt2id', 'dm_actarmcd', 'dm_suppdm_rtrtsdtc'); $date_data = REDCap::getData('array', $record, $date_fields, $baseline_event_id); foreach ($date_data as $subject_id => $subject) { $all_events = array(); $post_tx_dates = array(); $post_tx_bloq_dates = array(); $re_treat_candidate = false; $re_treat_dates = array(); foreach ($subject as $date_event_id => $date_event) { /** * HCV RNA Outcome */ $hcvrna_improved = false; $on_tx_scores = array(); $hcvrna_previous_score = ''; $post_tx_scores = array(); $post_tx_plus10w_scores = array(); $post_tx_plus10d_scores = array(); $last_hcvrna_bloq = false; $stop_date_plus_10w = null; $stop_date_plus_10d = null; $tx_stopped_10_wks_ago = false; $started_tx = false; $stopped_tx = false; $hcv_fu_eligible = true; $hcv_fu_ineligible_reason = array(); $lost_to_followup = false; $hcv_data_due = false; $tx_start_date = isset($date_event['dm_rfstdtc']) && $date_event['dm_rfstdtc'] != '' ? $date_event['dm_rfstdtc'] : null; $stop_date = isset($date_event['dis_suppfa_txendt']) && $date_event['dis_suppfa_txendt'] != '' ? $date_event['dis_suppfa_txendt'] : null; $dis_dsstdy = isset($date_event['dis_dsstdy']) && $date_event['dis_dsstdy'] != '' ? $date_event['dis_dsstdy'] : null; $eot_dsterm = isset($date_event['eot_dsterm']) && $date_event['eot_dsterm'] != '' ? $date_event['eot_dsterm'] : null; /** * look for this dm_usubjid in dm_suppdm_hcvt2id. This is a foreign key between TARGET 2 and TARGET 3 patients. * Get the start date of the TARGET 3 patient if dm_suppdm_hcvt2id is not empty. */ $t3_fk_result = db_query("SELECT record FROM redcap_data WHERE project_id = '{$project_id}' AND field_name = 'dm_suppdm_hcvt2id' AND value = '{$date_event['dm_usubjid']}'"); if ($t3_fk_result) { $t3_fk = db_fetch_assoc($t3_fk_result); $t3_start_date_value = get_single_field($t3_fk['record'], $project_id, $baseline_event_id, 'dm_rfstdtc', ''); } $t3_start_date = isset($t3_start_date_value) ? $t3_start_date_value : ''; /** * where are we in treatment? */ if (isset($tx_start_date)) { // started treatment $started_tx = true; /** * treatment must have started to stop */ if (isset($stop_date)) { // completed treatment $stopped_tx = true; $stop_date_plus_10d = add_date($stop_date, 10, 0, 0); $stop_date_plus_10w = add_date($stop_date, 64, 0, 0); if (date("Y-m-d") >= $stop_date_plus_10w && isset($stop_date_plus_10w)) { $tx_stopped_10_wks_ago = true; } } else { // not completed treatment $stopped_tx = false; $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = 'TX Not Completed'; } } else { // not started treatment $started_tx = false; $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = 'TX Not Started'; } /** * get fields for both abstracted (standardized) and imported HCV RNA forms */ foreach ($fieldsets as $formtype => $fieldset) { foreach ($data[$formtype][$subject_id] as $event_id => $event) { /** * standardize array keys */ foreach ($event as $event_key => $event_value) { unset($event[$event_key]); $event[array_search($event_key, $field_translate[$formtype])] = $event_value; } /** * merge into all_events array */ if ($event['date_field'] != '') { $all_events[$event['date_field']][] = $event; } } } ksort($all_events); /** * get outcomes */ foreach ($all_events as $event_date => $event_set) { foreach ($event_set as $event) { /** * if we have a date, and the HCV RNA isn't an 'untrusted blip'... * (blips are sudden, small increases in viral load following EOT) */ if (($event['value_field'] != '' || $event['detect_field'] != '') && ($event['date_field'] != '' && $t3_start_date == '' || $event['date_field'] != '' && $t3_start_date != '' && $event['date_field'] <= $t3_start_date)) { $is_bloq = in_array($event['detect_field'], array('BLOQ', 'NOT_SPECIFIED', 'DETECTED')) || $event['value_field'] == '0' ? true : false; $score = $is_bloq ? '0' : '1'; /** * if treatment has started, and $event['date_field'] is after start date (is baseline or later) */ if ($started_tx && $tx_start_date <= $event['date_field']) { /** * and is... */ if (!$stopped_tx || $stopped_tx && $event['date_field'] <= $stop_date) { // on treatment $on_tx_scores[] = $score; if ($score >= $hcvrna_previous_score) { $hcvrna_improved = false; } elseif ($score < $hcvrna_previous_score) { $hcvrna_improved = true; } $hcvrna_previous_score = $score; if ($eot_dsterm == 'LACK_OF_EFFICACY' && get_end_of_array($on_tx_scores) == '1') { $re_treat_candidate = true; } } else { // post-treatment /** * RE-TREAT handling * If this HCVRNA is quantifiable, add the date to an array * if this HCVRNA is bloq and we have quantified post-TX HCVRNA, it's a re-treat and we don't want it in $post_tx_scores */ if ($is_bloq && !in_array('1', $post_tx_scores) && !$re_treat_candidate) { $post_tx_bloq_dates[] = $event['date_field']; $post_tx_scores[] = $score; /** * capture scores that are after EOT plus 10 weeks */ if (isset($stop_date_plus_10w) && $event['date_field'] >= $stop_date_plus_10w) { $post_tx_plus10w_scores[] = $score; } /** * capture scores that are between EOT and EOT plus 10 days */ if (isset($stop_date_plus_10d) && $event['date_field'] <= $stop_date_plus_10d) { $post_tx_plus10d_scores[] = $score; } } if (!$is_bloq && !in_array('1', $post_tx_scores) && !$re_treat_candidate) { $post_tx_dates[] = $event['date_field']; $post_tx_scores[] = $score; /** * capture scores that are after EOT plus 10 weeks */ if (isset($stop_date_plus_10w) && $event['date_field'] >= $stop_date_plus_10w) { $post_tx_plus10w_scores[] = $score; } /** * capture scores that are between EOT and EOT plus 10 days */ if (isset($stop_date_plus_10d) && $event['date_field'] <= $stop_date_plus_10d) { $post_tx_plus10d_scores[] = $score; } } if ($is_bloq && in_array('1', $post_tx_scores)) { $re_treat_candidate = true; } } } } } } /** * we have all our score candidates */ $all_scores = array_merge($on_tx_scores, $post_tx_scores); $last_hcvrna_bloq = count($all_scores) > 0 && get_end_of_array($all_scores) == '0' ? true : false; /** * get candidates for re-treat cutoff date */ $re_treat_dates = array_diff(array_unique($post_tx_dates), array_unique($post_tx_bloq_dates)); /** * HCVRNA Followup Eligibility * subjects are ineligible for followup if: */ foreach ($ie_data[$subject_id] as $ie_event) { if ($ie_event['ie_ietestcd'] != '') { // failed i/e criteria $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = $ie_criteria_labels[$ie_event['ie_ietestcd']]; } } /** * disposition-related ineligibility */ if (in_array($date_event['eot_dsterm'], array('LOST_TO_FOLLOWUP', 'LACK_OF_EFFICACY'))) { // disposition is lost to followup $lost_to_followup = true; $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = fix_case($date_event['eot_dsterm']); } /** * Quantified HCVRNA after EOT */ if (count($post_tx_scores) > 1 && !$hcvrna_improved) { if (in_array('1', $post_tx_scores)) { // had quantified HCV RNA after EOT $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = 'Quantified post-TX HCVRNA'; } } else { if (in_array('1', $post_tx_scores)) { // had quantified HCV RNA after EOT $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = 'Quantified post-TX HCVRNA'; } } /** * lost to post-treatment follow up if not already LTFU */ $post_tx_followup_eligible = $date_event['dis_suppds_funcmprsn'] == 'LOST_TO_FOLLOWUP' ? false : true; if (!$lost_to_followup) { if (!$post_tx_followup_eligible) { $lost_to_followup = true; $hcv_fu_eligible = false; $hcv_fu_ineligible_reason[] = 'Lost to post-TX followup'; } } /** * derive outcome now as it's needed below */ $GLOBALS['started_tx'] = $started_tx; $GLOBALS['stopped_tx'] = $stopped_tx; $GLOBALS['post_tx_plus10w_scores'] = $post_tx_plus10w_scores; $GLOBALS['last_hcvrna_bloq'] = $last_hcvrna_bloq; $GLOBALS['lost_to_followup'] = $lost_to_followup; $GLOBALS['tx_stopped_10_wks_ago'] = $tx_stopped_10_wks_ago; $GLOBALS['hcv_fu_eligible'] = $hcv_fu_eligible; $GLOBALS['on_tx_scores'] = $on_tx_scores; $GLOBALS['post_tx_plus10d_scores'] = $post_tx_plus10d_scores; $GLOBALS['post_tx_scores'] = $post_tx_scores; $GLOBALS['eot_dsterm'] = $eot_dsterm; $outcome = self::get_outcome(); /** * IS FOLLOWUP DATA FOR THIS SUBJECT DUE? * if followup eligible and treatment duration greater than 4 weeks... */ if ($hcv_fu_eligible && $post_tx_followup_eligible && isset($dis_dsstdy) && $dis_dsstdy >= 29) { /** * AND today is TX stop date + 14 weeks ago, and no final outcome, data is due */ if (date("Y-m-d") >= add_date($stop_date, 98, 0, 0) && !in_array($outcome, array('SVR', 'VIRAL BREAKTHROUGH', 'RELAPSE', 'NON-RESPONDER', 'LOST TO FOLLOWUP'))) { $hcv_data_due = true; } } /** * if not followup eligible (and no TX stop - implied by ineligible)... */ if ((!$hcv_fu_eligible || !$post_tx_followup_eligible) && $started_tx && !$stopped_tx) { /** * is regimen SOF + RBV? */ $regimen = get_single_field($subject_id, $project_id, $baseline_event_id, 'dm_actarmcd', null); // $due_fields = array('sof_cmstdtc', 'rib_cmstdtc'); // $due_data = REDCap::getData('array', $subject_id, $due_fields); // $sof_rbv_regimen = false; // $sof = array(); // $rbv = array(); // foreach ($due_data[$subject_id] AS $event_id => $event) { // if ($event['sof_cmstdtc'] != '') { // $sof[] = true; // } // if ($event['rib_cmstdtc'] != '') { // $rbv[] = true; // } // } $sof_rbv_regimen = $regimen == 'SOF/RBV' ? true : false; /** * get genotype */ $genotype = get_single_field($subject_id, $project_id, $baseline_event_id, 'hcvgt_lborres', ''); /** * if regimen is SOF + RBV and Genotype 1 or 3 */ if ($sof_rbv_regimen && ($genotype == '1' || $genotype == '3')) { /** * AND if TX start is 168 days ago, data is due */ if (date("Y-m-d") >= add_date($tx_start_date, 168, 0, 0)) { $hcv_data_due = true; } /** * if regimen is SOF + RBV and Genotype 2 */ } elseif ($sof_rbv_regimen && $genotype == '2') { /** * if TX start is 84 days ago, data is due */ if (date("Y-m-d") >= add_date($tx_start_date, 84, 0, 0)) { $hcv_data_due = true; } /** * if any other regimen or genotype */ } else { /** * if TX start is 84 days ago, data is due */ if (date("Y-m-d") >= add_date($tx_start_date, 84, 0, 0)) { $hcv_data_due = true; } } } /** * get values */ $last_bloq = $last_hcvrna_bloq ? 'Y' : 'N'; $eligible = !$hcv_fu_eligible ? 'N' : 'Y'; $reason = implode('; ', array_unique($hcv_fu_ineligible_reason)); $data_due = $hcv_data_due ? 'Y' : 'N'; $wk10_rna = count($post_tx_plus10w_scores) > 0 ? 'Y' : 'N'; rsort($re_treat_dates); $re_treat_date = $re_treat_candidate ? get_end_of_array($re_treat_dates) : null; /** * debug */ d($all_scores); if ($started_tx) { d($tx_start_date); d($on_tx_scores); if ($stopped_tx) { d($stop_date); d($post_tx_scores); d($post_tx_plus10d_scores); d($post_tx_plus10w_scores); d($last_hcvrna_bloq); d($lost_to_followup); d($post_tx_followup_eligible); d($hcv_fu_eligible); d($post_tx_bloq_dates); d($post_tx_dates); d($t3_start_date); d($re_treat_candidate); d($re_treat_date); d($tx_stopped_10_wks_ago); d($hcv_data_due); d($outcome); } else { d('NO TX STOP'); } } else { d('NO TX START'); } /** * set overall hcvrna followup eligibility and reason if ineligible */ update_field_compare($subject_id, $project_id, $baseline_event_id, $eligible, $date_event['hcv_suppfa_fuelgbl'], 'hcv_suppfa_fuelgbl', $debug); update_field_compare($subject_id, $project_id, $baseline_event_id, $reason, $date_event['hcv_suppfa_nlgblrsn'], 'hcv_suppfa_nlgblrsn', $debug); /** * set follow up timing - is it due? */ update_field_compare($subject_id, $project_id, $baseline_event_id, $data_due, $date_event['hcv_suppfa_fudue'], 'hcv_suppfa_fudue', $debug); /** * set outcome */ update_field_compare($subject_id, $project_id, $baseline_event_id, $outcome, $date_event['hcv_suppfa_hcvout'], 'hcv_suppfa_hcvout', $debug); /** * set 10 HCV RNA? */ update_field_compare($subject_id, $project_id, $baseline_event_id, $wk10_rna, $date_event['hcv_suppfa_wk10rna'], 'hcv_suppfa_wk10rna', $debug); /** * set HCV RNA BLOQ? */ update_field_compare($subject_id, $project_id, $baseline_event_id, $last_bloq, $date_event['hcv_suppfa_lastbloq'], 'hcv_suppfa_lastbloq', $debug); /** * set re-treat window start date */ update_field_compare($subject_id, $project_id, $baseline_event_id, $re_treat_date, $date_event['dm_suppdm_rtrtsdtc'], 'dm_suppdm_rtrtsdtc', $debug); } } }
/** * @see j() * @see de() * * @return string */ function je() { if (!Kint::enabled()) { return ''; } $stash = Kint::settings(); Kint::$delayedMode = true; Kint::enabled(PHP_SAPI === 'cli' && Kint::$cliDetection === true ? Kint::MODE_CLI : Kint::MODE_JS); $out = call_user_func_array(array('kint\\Kint', 'dump'), func_get_args()); Kint::settings($stash); return $out; }
private static function _parse_string(&$variable, kintVariableData $variableData) { $variableData->type = 'string'; $encoding = self::_detectEncoding($variable); if ($encoding !== 'ASCII') { $variableData->type .= ' ' . $encoding; } if (Kint::enabled() !== Kint::MODE_RICH) { $variableData->value = '"' . self::escape($variable, $encoding) . '"'; return; } $variableData->size = self::_strlen($variable, $encoding); if (!self::$_placeFullStringInValue) { $strippedString = preg_replace('[\\s+]', ' ', $variable); if (Kint::$maxStrLength && $variableData->size > Kint::$maxStrLength) { // encode and truncate $variableData->value = '"' . self::escape(self::_substr($strippedString, 0, Kint::$maxStrLength, $encoding), $encoding) . ' …"'; $variableData->extendedValue = self::escape($variable, $encoding); return; } elseif ($variable !== $strippedString) { // omit no data from display $variableData->value = '"' . self::escape($variable, $encoding) . '"'; $variableData->extendedValue = self::escape($variable, $encoding); return; } } $variableData->value = '"' . self::escape($variable, $encoding) . '"'; }
/** * Dump information about a variable * * @param mixed $data,... * @access public * @static */ public static function dump() { if (!Kint::enabled()) { return; } // decide what action to take baset on parameter count if (func_num_args() === 0) { // todo if no arguments were provided, dump the whole environment // self::env(); // todo return; } // find caller information $prevCaller = array(); $trace = debug_backtrace(); while ($callee = array_pop($trace)) { if (strtolower($callee['function']) === 'd' || strtolower($callee['function']) === 'dd' || isset($callee['class']) && strtolower($callee['class']) === strtolower(__CLASS__)) { break; } else { $prevCaller = $callee; } } list($names, $modifier) = self::_getPassedNames($callee, ''); // catches !, + and - switch ($modifier) { case '-': self::$_firstRun = TRUE; ob_clean(); break; case '+': // todo revert after dumping self::$maxLevels = FALSE; break; } self::_css(); echo self::_wrapStart(); foreach (func_get_args() as $k => $argument) { $dump = self::_dump($argument); list($class, $plus) = self::_collapsed(); echo "<dl><dt{$class}>{$plus}" . (!empty($names[$k]) ? "<dfn>{$names[$k]}</dfn> " : "") . "{$dump}</dl>"; } echo self::_wrapEnd($callee, $prevCaller); self::$_firstRun = FALSE; //todo add ability to echo just prettily formatted code without html //if ( self::_isAjax() ) { // echo "\n\n" . strip_tags( $dump ); //} }
/** * @see s() * * [!!!] IMPORTANT: execution will halt after call to this function * * @return string */ function sd() { $enabled = Kint::enabled(); if (!$enabled) { return ''; } if ($enabled !== Kint::MODE_WHITESPACE) { Kint::enabled(PHP_SAPI === 'cli' ? Kint::MODE_WHITESPACE : Kint::MODE_PLAIN); } $params = func_get_args(); call_user_func_array(array('Kint', 'dump'), $params); die; }
/** * dump information about variables * * @param mixed $data * * @return void|string */ public static function dump($data = null) { if (!Kint::enabled()) { return; } # find caller information $trace = debug_backtrace(); list($names, $modifier, $callee, $previousCaller) = self::_getPassedNames($trace); if ($names === array(null) && func_num_args() === 1 && $data === 1) { $call = reset($trace); if (!isset($call['file']) && isset($call['class']) && $call['class'] === __CLASS__) { array_shift($trace); $call = reset($trace); } while (isset($call['file']) && $call['file'] === __FILE__) { array_shift($trace); $call = reset($trace); } self::trace($trace); return; } # process modifiers: @, + and - switch ($modifier) { case '-': self::$_firstRun = true; while (ob_get_level()) { ob_end_clean(); } break; case '!': self::$expandedByDefault = true; break; case '+': $maxLevelsOldValue = self::$maxLevels; self::$maxLevels = false; break; case '@': $firstRunOldValue = self::$_firstRun; self::$_firstRun = true; break; } $data = func_num_args() === 0 ? array("[[no arguments passed]]") : func_get_args(); $output = Kint_Decorators_Rich::_css(); $output .= Kint_Decorators_Rich::_wrapStart($callee); foreach ($data as $k => $argument) { $output .= self::_dump($argument, $names[$k]); } $output .= Kint_Decorators_Rich::_wrapEnd($callee, $previousCaller); self::$_firstRun = false; switch ($modifier) { case '+': self::$maxLevels = $maxLevelsOldValue; echo $output; break; case '@': self::$_firstRun = $firstRunOldValue; return $output; break; default: echo $output; break; } return ''; }
require $file; } } function AutoloadView($className) { $file = SITE_ROOT_DIR . 'views' . DIRECTORY_SEPARATOR . strtolower(str_replace('View', '', $className)) . '.php'; if (is_readable($file)) { require $file; } } function LoadConfig($config) { require_once SITE_ROOT_DIR . 'configs' . DIRECTORY_SEPARATOR . $config . '.php'; } function LoadLib($lib) { require LIB_DIR . $lib . DIRECTORY_SEPARATOR . $lib . '.php'; } function ErrorReporting() { ini_set('error_reporting', E_ALL); ini_set('display_errors', true); ini_set('html_errors', true); } LoadLib('Kint'); Kint::enabled(DEBUG); DEBUG && ErrorReporting(); spl_autoload_register('AutoloadClass'); spl_autoload_register('AutoloadModel'); spl_autoload_register('AutoloadController'); spl_autoload_register('AutoloadView');
* debug */ $debug = $_GET['debug'] ? (bool)$_GET['debug'] : false; /** * includes */ $base_path = dirname(dirname(dirname(__FILE__))); require_once $base_path . "/redcap_connect.php"; require_once $base_path . '/plugins/includes/functions.php'; require APP_PATH_CLASSES . "Message.php"; /** * restricted use */ $allowed_pids = array('38'); REDCap::allowProjects($allowed_pids); Kint::enabled($debug); /** * initialize variables */ $item_count = 0; $today = date('Y-m-d'); $rows = ''; /** * query target_email_actions for any actions that haven't yet been digested. * digest and send them */ $actions_result = db_query("SELECT DISTINCT * FROM target_email_actions WHERE (digest_date IS NULL OR digest_date = '') AND project_id = '$project_id' ORDER BY redcap_data_access_group ASC, abs(record) ASC"); if ($actions_result) { while ($actions_row = db_fetch_assoc($actions_result)) { $item_count++; foreach ($actions_row AS $key => $value) {
/** * @param $record * @param null $save_event_id * @param string $formtype 'abstracted', 'imported' or 'both' * @param $debug */ function set_apri($record, $save_event_id = null, $formtype = 'both', $debug) { /** * derives APRI for a single event if $save_event_id is set. Derives APRI for all events if $save_event_id = null */ global $Proj, $project_id; $chem_fields = array('chem_lbdtc', 'ast_lbstresn'); $cbc_fields = array('cbc_lbdtc', 'plat_lbstresn', 'apri_lbblfl', 'apri_lborres'); $chem_im_fields = array('chem_im_lbdtc', 'ast_im_lbstresn'); $cbc_im_fields = array('cbc_im_lbdtc', 'plat_im_lbstresn', 'apri_im_lbblfl', 'apri_im_lborres'); $enable_kint = $debug && (isset($record) && $record != '') ? true : false; Kint::enabled($enable_kint); $baseline_event_id = $Proj->firstEventId; $filter_logic = "[cbc_lbdtc] != ''"; switch ($formtype) { case 'both': $cbc_fields = array_merge($cbc_fields, $cbc_im_fields); $chem_fields = array_merge($chem_fields, $chem_im_fields); break; case 'imported': $cbc_fields = $cbc_im_fields; $chem_fields = $chem_im_fields; break; default: break; } $fields = array_merge($cbc_fields, array('plat_supplb_lbdtbl')); $save_event_id = isset($save_event_id) && $save_event_id != $baseline_event_id ? array($baseline_event_id, $save_event_id) : $save_event_id; /** * APRI */ $uln = 40; $cbc_data = REDCap::getData('array', $record, $fields, $save_event_id); $chem_data = REDCap::getData('array', $record, $chem_fields); if ($debug) { error_log(print_r($cbc_data, TRUE)); } foreach ($cbc_data AS $subject_id => $subject) { $plat_bl_date = $subject[$baseline_event_id]['plat_supplb_lbdtbl']; d($subject_id); $chem_events = array(); foreach ($subject AS $event_id => $event) { if ($formtype == 'imported' || $formtype == 'both') { $is_baseline = ''; $apri_score = ''; if ($event['cbc_im_lbdtc'] != '' && $event['plat_im_lbstresn'] != '' && is_numeric($event['plat_im_lbstresn'])) { foreach ($chem_data[$subject_id] AS $chem_event) { if ($chem_event['chem_im_lbdtc'] != '' && $chem_event['ast_im_lbstresn'] != '' && $chem_event['chem_im_lbdtc'] == $event['cbc_im_lbdtc'] && is_numeric($chem_event['ast_im_lbstresn'])) { if (isset($plat_bl_date) && $plat_bl_date != '' && $plat_bl_date == $chem_event['chem_im_lbdtc']) { $is_baseline = 'Y'; } $apri_score = (string)round(((($chem_event['ast_im_lbstresn'] / $uln) / $event['plat_im_lbstresn']) * 100), 2); } } } update_field_compare($subject_id, $project_id, $event_id, $apri_score, $event['apri_im_lborres'], 'apri_im_lborres', $debug); update_field_compare($subject_id, $project_id, $event_id, $is_baseline, $event['apri_im_lbblfl'], 'apri_im_lbblfl', $debug); } if ($formtype == 'abstracted' || $formtype == 'both') { $is_baseline = ''; $apri_score = ''; if ($event['cbc_lbdtc'] != '' && $event['plat_lbstresn'] != '' && is_numeric($event['plat_lbstresn'])) { foreach ($chem_data[$subject_id] AS $chem_event) { if ($chem_event['chem_lbdtc'] != '' && $chem_event['ast_lbstresn'] != '' && $chem_event['chem_lbdtc'] == $event['cbc_lbdtc'] && is_numeric($chem_event['ast_lbstresn'])) { if (isset($plat_bl_date) && $plat_bl_date != '' && $plat_bl_date == $chem_event['chem_lbdtc']) { $is_baseline = 'Y'; } $apri_score = (string)round(((($chem_event['ast_lbstresn'] / $uln) / $event['plat_lbstresn']) * 100), 2); } } } update_field_compare($subject_id, $project_id, $event_id, $apri_score, $event['apri_lborres'], 'apri_lborres', $debug); update_field_compare($subject_id, $project_id, $event_id, $is_baseline, $event['apri_lbblfl'], 'apri_lbblfl', $debug); } } } }