Got feedback or spotted a mistake?

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

Configure Anticipated/Pending Visits based on Participant Field

The anticipated/pending visits from the visit table are configurable based on specific values selected in one or more fields. These fields can be static or custom fields at the participant level.

Add the below-mentioned code block in the “visitsTab” section.

{ "name": "visitsTab", "data": { "occurred": [ { "field": "visit.name", "baseField": "visit.name", "width": "150px" }, { "field": "visit.visitDate", "baseField": "visit.visitDate", "width": "100px" } ], "anticipatedEvents": [ { "rule": "cpr.participant.gender == 'Female'", "events": ["S01" , "MFW","D01"] }, { "rule": "cpr.participant.gender == 'Male'", "events": ["S01" , "PFW"] } ] } }

After adding the above JSON, the visit table on the participant overview page would look like the screenshot added below:

Case 1: 'Gender' = 'Female'

Case 2: 'Gender' = 'Male'

Note:

  • The “rule” specifies the participant criteria: In this case, “cpr.participant.gender “ is the field and “Female” is the value of that field. So, based on gender, visits are hidden and shown in the visit table.

  • The “events” specifies the list of events (codes) to be displayed.

  • Every time, the first matching rule is used. When no rules match, all the events are displayed.

  • If the event code is not specified, it will always be displayed in the anticipated visit table.

For Multi-select Custom fields

Below code can be used to set up the show/hide events based on multi-select field.

{ "name" : "visitsTab", "view" : null, "ctrl" : null, "data" : { "anticipatedEvents" : { "matchType" : "all", "rules" : [ { "rule" : "cpr.participant.extensionDetail.attrsMap.marital_status_.indexOf('Married') > -1", "events" : [ "C1", "C2", "C3" ] }, { "rule" : "cpr.participant.extensionDetail.attrsMap.marital_status_.indexOf('Unmarried') > -1", "events" : [ "C1", "C3" ] }, { "rule" : "cpr.participant.extensionDetail.attrsMap.marital_status_.indexOf('Engaged') > -1", "events" : [ "C4", "C5" ] }, { "rule" : "cpr.participant.extensionDetail.attrsMap.marital_status_.indexOf('Widow') > -1", "events" : [ "C6", "C7", "C8", "C1" ] }, { "rule" : "*", "events" : [ "C9" ] } ] } } }

After adding the above JSON, the visit table on the participant overview page would look like the screenshot added below:

Case 1: 'Marital Status' = 'Married'

Case 2: 'Marital Status' = 'Married' & 'Engaged’

In both Case 1 and Case 2, Day 9 is showing up because C9 is specified as * in the code.

 

Got feedback or spotted a mistake?

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