Calculations and Branching Logic By J Kevan Essmyer Acknowledgements: J. Phil Miller (WUSM...
Transcript of Calculations and Branching Logic By J Kevan Essmyer Acknowledgements: J. Phil Miller (WUSM...
Calculations and Branching Logic
By J Kevan Essmyer
Acknowledgements:J. Phil Miller (WUSM Biostatistics)
Paul Harris (Vanderbilt CTSA)Jack Baty (WUSM REDCap Admin)
Yu Tao (WUSM REDCap Admin)
Overview
• REDCap Overview
• Calculations• Branching Logic• Expanded Data Validation Types• Data Quality Module• External Links functionality• Data Search Tool
Development “Try it” and
Production “Study Data” Servers
• http://www.biostat.wustl.edu/redcap – REDCap User Request forms – REDCap Project Request forms (IRB #)– Sidedoor security certificate (External Access)
• Both servers are WUSM HIPAA compliant web-based data capture systems
• REDCap Policy: Study data should only be collected on the Production server
Project Creation Flow Chart
Create Project –Project Name, Longitudinal or Cross-Sectional/ Survey
Excel SpreadsheetOr
Online Form Designer
Data EntryForms
Add Users and
Set User Rights
Test
Forms
Move to Production Status and start Data Collection
Define Study Events
(Longitudinal)
add Schedule (optional)
Recent Changes
• Hardware– Improved Dedicated MySQL Database server
• Software (REDCap 4.8.x)– Data Query Module– New data validation types– Search Tool– External Links
File Server
Host Server
WEB Server
Uploaded Files
Installation Files
WEB Server
WU Campus
Sidedoor Server
https://redcapsurvey.wustl.edu...
REDCap Survey
Data Entry /Admin
Data Entry /Admin
MySQL Server
MySQL Slave Server
Data
Sync
Biostatistics Secure Domain
Authenticated Access
Public HTTPS Access
Calculations• Variable Referrence: [event_id][variable name]
– Event Id obtained from events grid
• Logic Statement: (if(expression),True Result,False Result)
• Simple– [weight]*10000/([height]*[height])
• Complex• Calculating the Mean of groups with null valid range includes zero
The following equation will calculate the Mean of a list of variables –
( (if(Math.abs([A])>0,[A],0)) +(if(Math.abs([B])>0,[B],0))+(if(Math.abs([C])>0,[C],0)) )/( (if(Math.abs([A])>0,1,if([A]=0,1,0))+if(Math.abs([B])>0,1,if([B]=0,1,0))+if(Math.abs([C])>0,1,if([C]=0,1,0)) )
Built in Functions
"y" years 1 year = 365.2425 days
"M" months 1 month = 30.44 days
"d" days
"h" hours
"m" minutes
"s" seconds
"ymd" Y-M-D (default)
"mdy" M-D-Y
"dmy" D-M-Y
Type of calculation Notes / examples
round(number,decimal places) Round
roundup(number,decimal places) Round Up
rounddown(number,decimal places) Round Down
sqrt(number) Square Root
(number)^(exponent) Exponents
abs(number) Absolute Value
min(number,number,...) Minimum
max(number,number,...) Maximum
mean(number,number,...) Mean
median(number,number,...) Median
sum(number,number,...) Sum
stdev(number,number,...) Standard Deviation
datediff([date1], [date2], "units", "dateformat", returnSignedValue)
datediff([dob],[date_enrolled],"d")
datediff([dob],"05-31-2007","h","mdy",true)
Units
Date Formats
DATEDIFF F(x)
Javascript Math Library• Math.abs(a) // the absolute value of a • Math.acos(a) // arc cosine of a • Math.asin(a) // arc sine of a • Math.atan(a) // arc tangent of a • Math.atan2(a,b) // arc tangent of a/b • Math.ceil(a) // integer closest to a and not less than a • Math.cos(a) // cosine of a • Math.exp(a) // exponent of a (Math.E to the power a) • Math.floor(a) // integer closest to a, not greater than a • Math.log(a) // log of a base e • Math.max(a,b) // the maximum of a and b • Math.min(a,b) // the minimum of a and b • Math.pow(a,b) // a to the power b • Math.random() // pseudorandom number 0 to 1 • Math.round(a) // integer closest to a • Math.sin(a) // sine of a • Math.sqrt(a) // square root of a • Math.tan(a) // tangent of a
http://www.javascripter.net/faq/mathfunc.htm
Pitfalls of Calculations• Changes made to equations after the start of data collection
– Correct new calculated value will display on page load– Each form must be individually submitted to re-apply calculation
• Calculations should be considered a tool not data.– Calculation should be reapplied during data analysis.
• Multiple calculations on a form.– Order of execution is determined by the alphabetical ordering of it’s
associated variable/field name.• Calculation 1 [weight_met] =[weight]*.45359237• Calculation 2 [BMI]=[weight_met]/([height]^2)
• !!!Calculation 2 will occur before calculation 1– Calculate BMI in one step (Best Solution)or– Rename variable to change order (only other option)
Branching Logic
• Exposes form question if logic expression is true
– [Event Id][Variable Name] = "0"
• Checkboxes Format– [Event Id][variablename(code)]
• To check the value of the checkboxes: • '1' = checked • '0' = unchecked
– [race(2)] = "1"
[sex] = "0" display question if sex = female; Female is coded as 0, Female
[sex] = "0" and [given_birth] = "1" display question if sex = female and given birth = yes; Yes is codesd as 1, Yes
([height] >= 170 or [weight] < 65) and [sex] = "1" display question if (height is greater than or equal to 170 OR weight is less than 65) AND sex = male; Male is coded as 1, Male
[last_name] <> "" display question if last name is not null (aka if last name field is empty)
Online Designer
Branching Logic
• Calculation with in branching logic– [kwdays] > (10+1)
• Prevent deletion of – With existing logic
• (other logic statements) or <>"“
– Stand alone• <>""
Branching logic warning about hiding existing data
Can be a dangerous situation and is best avoided.
Expanded Field Validation Types
Data Quality Module (data queries)
Results
Data Quality Module (data queries)
External Links
• Embed hyperlinks in the REDCap project menu.– Websites, Other REDCap Projects, web tools
Data Search Tool
“?!!?”
User Rights
Branching
Logic
Scheduling
API
Data Dictionary
Data
Validation
REDCap Lifelines
• Built-in tutorial videos• Built-in Frequently Asked Question (FAQ)
guide• Demonstration Databases (Some Online, more
to come)• WUSM Biostat REDCap Email Help Queue– [[email protected]]– Monitored by 4 to 5 Administrators
REDCap Email Support
REDCap Goals
• Easy to use• Metadata Driven • Adaptable Features• Data entry validation• Self service tool
Questions?