Skip to content

Instantly share code, notes, and snippets.

View 123andy's full-sized avatar

Andy Martin 123andy

  • Stanford University
  • Stanford, CA
View GitHub Profile
@123andy
123andy / gist:ade63284496877e1ad40eb5f03265ad2
Last active November 17, 2022 00:50
A Plugin for Gzipping old Edocs for local EDOC storage on REDCap
<?php
/**
This is a plugin that was used to gzip old edocs that were created prior to when REDCap introduced Gzip.
Which was with version 6 in 2014! So, if you've only been REDCapping for a while, then this might not
have that much importance. If, like us, you've got an old instance with lots of old files, this could save
you some substantial disk space
Compressing old .csv, .r, .xls, .sas exports can free up about 90% of their previous storage space.
@123andy
123andy / migrateLogEventTable
Created May 4, 2022 18:31
A MySql procedure to help migrate log entries from one table to another in REDCap
create
definer = andy123@`10.130.0.0/255.255.0.0` procedure migrateLogEventTable(IN pid int, IN source_table varchar(255),
IN target_table varchar(255))
p1:BEGIN
set @pid = pid;
set @source_table = source_table;
set @target_table = target_table;
-- MAKE SURE WE ARENT MOVING TO SAME TABLE!
@123andy
123andy / example.php
Created March 17, 2022 21:38
Example template for a context token
function getContextToken (
$project_id = null,
$record = null,
$event_id = null,
$module_prefix = self::_PREFIX,
$custom = [],
$duration_valid_in_mins = 5
) {
// refactor to allow passing parameters in an array as a single argument as well
@123andy
123andy / ideas.sql
Created June 24, 2020 17:57
Ideas for a REDCapDataQuery class to convert queries to SQL
-- main
set @PID = 19184;
set @EID = 115110;
set @F1 = 'rsp_prt_portal_email';
set @F2 = 'rsp_prt_portal_phone';
set @F3 = 'rsp_prt_portal_url';
set @F4 = 'rsp_prt_start_date';
set @F5 = 'rsp_prt_disable_email';
set @F6 = 'rsp_prt_disable_sms';
@123andy
123andy / RepeatingForms
Created April 17, 2020 17:18
A helper object for working with repeating forms in REDCap - this is a WIP...
<?php
class RepeatingForms
{
// Metadata
private $Proj;
private $pid;
private $is_longitudinal;
private $data_dictionary;
private $fields;
private $events_enabled = array(); // Array of event_ids where the instrument is enabled
@123andy
123andy / records.php
Last active April 15, 2020 17:11
Record Exists and reserveNewRecordId
<?php
class Record
{
/**
* DETERMINE IF A RECORD RESERVED (private method)
* See if a record is reserved in the new_record_cache table
*
* @param $project_id
@123andy
123andy / fix bad commit
Created March 19, 2020 21:15
Dealing with a corrupt redcap builder issue
We have seen cases where an EM repo ends up nesting the entire REDCap web repo inside of it recursively. You often get /webauth/webauth/webuath runaways.
determine the hash for the last 'good' commit.
git checkout dev
git log -5 // determine last good commit
git reset --hard HASH
git push -f origin dev
Then repeat for master and prod if it ended up there...
@123andy
123andy / update_pull.php
Last active February 3, 2020 18:57
A script to update any cloned modules in your local REDCap development server
<?php
/*
* This script is intended to help you keep your many cloned external modules current...
* To run, place this in your redcap root folder and from the command line run
*
* php update_pull.php
*
* Note that nothing will be automatically done unless you pass in a true argument as in
*
@123andy
123andy / config.js
Created April 30, 2019 17:00
converting format of js...
// Create a javascript object to hold all of our config features
var SummarizeConfig = {
init: function(params) {
// Make true
this.isDev = true;
// We need to delay a little bit for the rest of the config to finish loading
setTimeout(function() {
SummarizeConfig.configAjax.call(SummarizeConfig,'pages/ConfigAjax')
@123andy
123andy / ActionTagHelper.php
Last active March 22, 2021 13:40
Custom Action Tag to convert "Andy's Hook Framework" things into External Modules
<?php
namespace Stanford\Utility;
use \REDCap as REDCap;
/**
* Class ActionTagHelper
*
* A class for helping to parse custom action tags
*/
class ActionTagHelper