Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Contact Us
  • Home
  • CDMS
  • Castor CDMS Calculations Manual
  • General calculation templates

AI prompt templates

Here you will find a list of prompt examples for our AI calculation helper!

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • CDMS
    Castor CDMS Manual Castor CDMS Calculations Manual Frequently Asked Questions Articles for Data Managers Castor CDMS Compliance Release Documents
  • eConsent
    Castor eConsent Manual Castor eConsent Compliance Release Documents
  • SMS
    Castor SMS Manual Castor SMS Compliance Release Documents
  • Castor Connect
    Castor Connect Compliance Release Documents Castor Connect Manual Castor Connect - Participant Quick Start Guide
  • Helpdesk
    News Other Resources Castor products knowledge resources
  • Status page
  • Completing a Study
+ More

Table of Contents

Introduction: Tips and tricks: Complete Prompt examples Example 1: Calculate BMI Example 2: Calculate BMI with different units Example 3: Check variable values Example 4: Calculate a score from 15 questions. Example 5: Date verifications for AEs Example 6: Check if a number is in a range Example 7: See if a certain checkbox is checked

Introduction:

Use these prompts with our new AI calculation helper! 

Tips and tricks:

  • Be specific! Specify the name and type of your fields if you can, e.g. “…for v1_pat_weight (number) ….” or “…. for pat_gender (radiobutton) …."
  • Explain what you are trying to do like you are writing to a human!
  • The max input length is set to 200 characters, for safety reasons.
  • Mention in case you expect one or multiple variables to be empty.
  • In Castor, checkboxes are stored as “2;4;5”, for example:
    • 'Pick colors you like' [x] Red=1, [] Blue=2, [x] Green=3, would be '1;3'
    • If you have non-incremental or non-numeric values for you option groups, please help the AI by specifying them: 
      • For example: “Check if NYC is checked in check_cities ([N=NYC, M=Madrid, A=Amsterdam])”
    • The AI will generate example input for you to test with.

 

Complete Prompt examples

Example 1: Calculate BMI 

Prompt: "Calculate BMI using v1_weight and v1_height"

JavaScript Code:

//Here is the JavaScript snippet that calculates BMI using v1_weight and v1_height:

// Initialize the variables

var v1_weight = "{v1_weight}";

var v1_height = "{v1_height}";


// Convert the variables to numbers

var weight = parseFloat(v1_weight);

var height = parseFloat(v1_height);


// Check if the variables are numbers

if (isNaN(weight) || isNaN(height)) {

 ("ERROR");

} else {

 // Calculate BMI

 var BMI = weight / Math.pow(height, 2);

 (BMI.toString());

}

This script first initializes the variables v1_weight and v1_height with the template tags. It then converts these variables to numbers. If either of the variables is not a number, it logs "ERROR". Otherwise, it calculates the BMI using the formula weight / height^2 and logs the result.

 

Example 2: Calculate BMI with different units

Prompt: "Calculate BMI based on height (in inches) and weight (in stones)"

JavaScript Code:

// Initialize the variables

var heightInInches = "{height_in_inches}";

var weightInStones = "{weight_in_stones}";


// Convert height from inches to meters

var heightInMeters = heightInInches * 0.0254;


// Convert weight from stones to kilograms

var weightInKilograms = weightInStones * 6.35029;


// Calculate BMI

var bmi = weightInKilograms / (heightInMeters * heightInMeters);


// Output the result

(bmi.toString());

 

Example 3:  Check variable values

Prompt: "if AEENDAT is not null and AEOUT = 3 then return 1, else return 0"

JavaScript Code:

// Initialize the variables

var AEENDAT = "{AEENDAT}";

var AEOUT = "{AEOUT}";


// Check if AEENDAT is not null and AEOUT equals 3

if (AEENDAT !== "null" \u0026\u0026 AEOUT === "3") {

 ("1");

} else {

 ("0");

}


Example 4: Calculate a score from 15 questions.

Prompt: "calculate the score of 14 questions named with the prefix "C15PAL" and then numbers from 1 to 14. The score is calculated as the mean of the responses."

JavaScript Code:



// Initialize the variables with template tags

var C15PAL1 = "{C15PAL1}";

var C15PAL2 = "{C15PAL2}";

var C15PAL3 = "{C15PAL3}";

var C15PAL4 = "{C15PAL4}";

var C15PAL5 = "{C15PAL5}";

var C15PAL6 = "{C15PAL6}";

var C15PAL7 = "{C15PAL7}";

var C15PAL8 = "{C15PAL8}";

var C15PAL9 = "{C15PAL9}";

var C15PAL10 = "{C15PAL10}";

var C15PAL11 = "{C15PAL11}";

var C15PAL12 = "{C15PAL12}";

var C15PAL13 = "{C15PAL13}";

var C15PAL14 = "{C15PAL14}";


// Convert the variables to numbers

C15PAL1 = Number(C15PAL1);

C15PAL2 = Number(C15PAL2);

C15PAL3 = Number(C15PAL3);

C15PAL4 = Number(C15PAL4);

C15PAL5 = Number(C15PAL5);

C15PAL6 = Number(C15PAL6);

C15PAL7 = Number(C15PAL7);

C15PAL8 = Number(C15PAL8);

C15PAL9 = Number(C15PAL9);

C15PAL10 = Number(C15PAL10);

C15PAL11 = Number(C15PAL11);

C15PAL12 = Number(C15PAL12);

C15PAL13 = Number(C15PAL13);

C15PAL14 = Number(C15PAL14);


// Calculate the mean of the responses

var mean = (C15PAL1 + C15PAL2 + C15PAL3 + C15PAL4 + C15PAL5 + C15PAL6 + C15PAL7 + C15PAL8 + C15PAL9 + C15PAL10 + C15PAL11 + C15PAL12 + C15PAL13 + C15PAL14) / 14;


// Output the result

(mean.toString());


Example 5: Date verifications for AEs

Prompt: "check if the AE start date, variable name aestdt, is after the AE end date, variabel name aeedt. IF so, return an error."

JavaScript Code:


// Initialize the variables

var aestdt = "{aestdt}";

var aeedt = "{aeedt}";


// Use moment.js to convert the dates to a valid format

var startDate = moment(aestdt, 'DD-MM-YYYY');

var endDate = moment(aeedt, 'DD-MM-YYYY');


// Check if the start date is after the end date

if (startDate.isAfter(endDate)) {

 ("ERROR");

} else {

 ("TRUE");

}

 

Example 6: Check if a number is in a range

Prompt: "check if a weight field is between 10 and 100"

JavaScript Code:



// Initialize the weight variable

let weight = "{weight}";


// Convert the weight to a number

let weightNumber = Number(weight);


// Check if the weight is between 10 and 100

if (weightNumber >= 10 \u0026\u0026 weightNumber \u003C= 100) {

 ("TRUE");

} else {

 ("FALSE");

}

 

Example 7: See if a certain checkbox is checked

Prompt: "For a checkbox field fav_color with three options: yellow, green, blue, see if green is checked and if anything is checked. If blue is checked, return "BLUE!", if anything is checked return "CHECK"."

JavaScript Code:


// Initialize the variable for the task

var fav_color = "{fav_color}"; //[fav_color=0;1;0]


// Split the string to convert it to an array

var color_array = fav_color.split(";");


// Check if green is checked (second position in the array)

if (color_array[1] === "1") {

    ("TRUE");

} else {

    ("FALSE");

}


// Check if anything is checked

if (color_array.includes("1")) {

    ("CHECK");

}


// Check if blue is checked (third position in the array)

if (color_array[2] === "1") {

    ("BLUE!");

}
prompts artificial intelligence

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Check if the 'upload file' field is empty or not in EDC/CDMS
  • Calculate the average in EDC/CDMS
  • Calculating with numbers in grids in EDC/CDMS
  • Validate capital letters in a text field in EDC/CDMS
ISO 27001
FDA - 21 CFR part 11
ICH GCP compliant
HIPAA compliant
CDISC
ISO 9001
gdpr compliant

Products & Industries

  • Electronic Data Capture (EDC)
  • ePRO
  • eConsent
  • Decentralized Clinical Trials (DCT)
  • Clinical Data Management
  • Medical Device & Diagnostics
  • Biotech & Pharma
  • CROs
  • Academic Research

Resources

  • Thought Leadership
  • Blog
  • Castor Academy
  • Knowledge Base

 

Company

  • About Us
  • Careers
  • News
  • Contact Support
  • Contact Us

Legal & Compliance

  • Terms of Use
  • Privacy & Cookie Statement
  • Responsible Disclosure Policy
  • Good Clinical Practice (GCP)
  • ISO Compliance Certificates
  • GDPR & HIPAA Compliance
  • Security Statement

© 2022, Castor. All Rights Reserved.

Follow us on social media


Knowledge Base Software powered by Helpjuice

Definition by Author

0
0
Expand