/
Data Validation Examples
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Data Validation Examples

Participant

We can add edit checks on participant fields using the record type as ‘cpr’

Attribute Type

Description

Example JSON

Attribute Type

Description

Example JSON

Text

Patient first name, last name should not be null.

{ "records" : [ "cpr" ], "rules" : [ { "expr" : "#cpr.participant.firstName != null && #cpr.participant.lastName != null", "description" : "First name or last name should not be null" } ] },

Text

Allow only capital letters in the field first name

{ "records" : [ "cpr" ], "rules" : [ { "expr" : "#cpr.participant.firstName.matches(\"^[A-Z]+$\")", "description" : "Only capital letters allowed for Initials" } ] }

Numeric field

The participant’s age registered under the COVID protocol should be between 18-55

{ "records" : [ "cpr" ], "rules" : [ { "when" : "#cpr.participant.extensionDetail?.getAttrsMap()?.get('min_max_age') != null && !#cpr.participant.extensionDetail?.getAttrsMap()?.get('min_max_age').isEmpty()", "expr" : "T(java.lang.Integer).parseInt(#cpr.participant.extensionDetail?.getAttrsMap()?.get('min_max_age')) >= 18 && T(java.lang.Integer).parseInt(#cpr.participant.extensionDetail?.getAttrsMap()?.get('min_max_age')) <= 55", "description" : "Partiicpant's age should be between 18 and 55" } ] }

Text Custom Field

If the patient is ‘Dead’ then, specify the value ‘Cause of death.’

Dropdown

Only male participant registrations are allowed

Multi-select field

If Race is one of (White or Asian), then Ethnicity should be 'American.'

Dropdown and Muliselect

  1. If Registration Site='MCRI Repository', then Race values is one of 'White' or 'Asian'

  2. If the patient is ‘Alive’ then Ethnicity should be ‘African’ or 'American'

Custom Field

The email id of the participant should be of the form ‘example@something.com’

Custom Form Field

In the ‘Smoking History Form’ attached at the ‘Participant Forms’ level, if the value of ‘Have you ever smoked’ is ‘Yes’, the error ‘Smokers not allowed!’ should be thrown.

Custom Form Field

‘Male’ participants with the value of ‘Have you ever smoked?’ as ‘Yes’ are not allowed. Error ‘Male smokers not allowed!’ should be thrown.

Custom form Date Field