Got feedback or spotted a mistake?

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

Configure Fields Based on Multiple Operators

If you want to display a field based on multiple operators on add/edit pages, you can achieve that using AND/OR operators.

AND Operator

Example 1: Display visit custom field based on conditions

The visit custom field (Visit Details) is displayed on add/edit page only when the below conditions are true:

  1. The 'visit site' has to be 'JSON Testing'.

  2. The event label should be 'Baseline' or 'Pre-Surgery'.

{ "name" : "visit.extensionDetail.attrsMap.ST2", "caption" : "Visit Details", "type" : "text", "optional" : true, "showInOverviewIf" : "useShowIf", "showIf" : { "op" : "AND", "rules" : [ { "field" : "visit.site", "op" : "==", "value" : "'JSON Testing'" }, { "field" : "visit.eventLabel", "op" : ".search('Baseline|Pre-Surgery') != ", "value" : "-1" } ] } }

The overview screen will look like this:

Example 2: Display ethnicity field based on conditions

In this code, the 'Ethnicity' participant field is displayed on add/edit page based on the below conditions:

  1. The 'Gender' has to be 'Unknown'.

  2. The 'Race' should be 'White'.

{ "name": "cpr.participant.ethnicities", "caption": "Ethnicity", "type": "pvs", "attr": "ethnicity", "optional": true, "multiple": true, "showIf": { "op": "And", "rules": [ { "field": "cpr.participant.races", "op": "==", "value": "'White'" }, { "field": "cpr.participant.gender", "op": "==", "value": "'Unknown'" } ] }, "showInOverviewIf": "useShowIf" }

OR Operator

Example: Display death date field based on conditions

In this code, the 'Death Date' participant field is displayed on add/edit page based on the below conditions:

  1. The ‘Vital Status' has to be 'Dead’ OR 'Unspecified'.

{ "name": "cpr.participant.deathDate", "caption": "Death Date", "type": "date", "optional": true, "showIf": { "op": "OR", "rules": [ { "field": "cpr.participant.vitalStatus", "op": "==", "value": "'Dead'" }, { "field": "cpr.participant.vitalStatus", "op": "==", "value": "'Unspecified'" } ] }, "showInOverviewIf": "useShowIf" }

Example JSON

Download

Got feedback or spotted a mistake?

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