Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Introduction

You can set fields to show or hide based on values selected in another field using a custom configuration. 

Note

The rules added for skip logic is are only reflected on add/edit pages. The overview page is a superset of all fields described in the data dictionary.

Below are some examples of how this feature can be used.

...

Examples

Show custom field

...

based on the value of another custom field

Show the field 'Relation To Proband' only if the value of field 'Proband' is equal to 'No'.

Expand

Example code
title
Example
Code Block
{
          "name": "cpr.participant.extensionDetail.attrsMap.DD15",
          "caption": "Relation To Proband",
          "type": "dropdown",
          "optional": true,
          "showIf": {
            "op": "AND",
            "rules": [
              {
                "field": "cpr.participant.extensionDetail.attrsMap.RB10",
                "op": "==",
                "value": "'No'"
              }
            ]
          },
          "listSource": {
            "apiUrl": "forms/permissible-values",
            "selectProp": "value",
            "displayProp": "value",
            "queryParams": {
              "dynamic": {},
              "static": {
                "formName": "kMCParticipantExtension",
                "controlName": "DD15"
              }
            }
          }
        }

Screenshot when the field is hidden:

Image RemovedImage Added

Screenshot when the field is shown:

Image Removed

Example 2

...

Image Added

Show custom field only on create aliquots page

Display the custom field 'Storage tube'

...

field

...

while creating the

...

aliquots

...

Expand

Example code
Example
title
Code Block
{
          "name": "specimen.extensionDetail.attrsMap.ST3",
          "caption": "Storage tube",
          "type": "text",
          "optional": "true",
          "showIf": {
              "op": "AND",
              "rules": [
                {
                  "field": "specimen.lineage",
                  "op": "==",
                  "value": "'Aliquot'"
                }
              ]
            }
        }

...

Show custom field when the visit date is greater than specified date

Show the 'COVID-19 Test Date'

...

custom field only when the visit date is after

...

23 January 2020

...

.

Expand

Example code
Code Block
title
languagejsExample code
{
      "name" : "visit.extensionDetail.attrsMap.DP13",
      "caption" : "COVID-19 Test Date",
      "type" : "date",
      "dateOnly" : true,
      "optional" : true,
      "showIf" : {
        "op" : "AND",
        "rules" : [ {
          "field" : "visit.visitDate",
          "op" : ">=",
          "value" : "1579717800000"
        } ]
      },
      "showInOverviewIf" : "useShowIf"
    }

Info

"1579717800000" is the number of milliseconds elapsed since Unix time Epoch on 23/01/2020 at 00:00:00 hrs UTC.

The number can be obtained from the sites like https://currentmillis.com/.

Example 4

...

Show custom field based on specimen lineage and type

Display 'Upload image'

...

custom field when

...

the specimen

...

lineage is 'New'

...

and the specimen type is 'Whole Blood'.

Expand

Example code
Example
title
Code Block
 {
   "name" : "specimen.extensionDetail.attrsMap.FU2upload_image",
   "caption" : "Upload image",

  "type" : "file",

  "optional" : true,
   "showInOverviewIf" : "useShowIf",

  "showIf" : {

          "op" : "AND",
           "rules" : [ {
             "field": "specimen.lineage",
             "op": "==",
             "value": "'New'"
           },
          {
             "field" : "Specimenspecimen.type",
             "op" : "==",
             "value" : "'Whole Blood'"
         } ]

      }

},

The field looks like the below on the specimen overview page:

Image Added

Show/Hide custom field based on specimen lineage and multiple type condition

Made Method field shows only if the Lineage=Aliquot and Type is RNA or DNA

Example code
Code Block
{
      "name" : "specimen.extensionDetail.attrsMap.made_method",
      "caption" : "Made Method",
      "type" : "dropdown",
      "showInOverviewIf": "useShowIf",
        "showIf": {
          "op": "AND",
          "rules": [
            {
              "field": "specimen.lineage",
              "op": "==",
              "value": "'Aliquot'"
            },
            {
              "field" : "specimen.type",
              "op" : ".search('RNA|DNA')!=",
              "value" : "-1"
        }
          ]
        },
      "optional" : true,
      "listSource" : {
        "apiUrl" : "forms/permissible-values",
        "selectProp" : "value",
        "displayProp" : "value",
        "queryParams" : {
          "dynamic" : { },
          "static" : {
            "formName" : "epidemiology_specimen_custom_form",
            "controlName" : "made_method"
          }
        }
      }
    },

Hide Custom Field For Newer Data Entry

Once legacy data is added, the custom field may become unnecessary for new entries, but should remain visible for existing records with values.

Expand
titleExpand...
Example Code
Code Block
{
      "name" : "specimen.extensionDetail.attrsMap.core_size_mm",
      "caption" : "Core Size (mm)",
      "type" : "text",
      "showIf" : "!!specimen.extensionDetail.attrsMap.core_size_mm",
      "showInOverviewIf" : "useShowIf"
      "optional" : true,
}

Displays the "Core Size (mm)" field in the edit and overview page only if it has a value.

Explaination: Uses the double negation (!!) to check whether core_size_mm has a true value.
If core_size_mm is empty, null, or undefined, this condition will evaluate to false, preventing the field from displaying in edit and overview page.

Show/Hide custom field – Using Regex Matching

Show the 'Lived Name' custom field only when the PPID starts with 'J'.

Example code
Code Block
{
  "name": "cpr.participant.extensionDetail.attrsMap.lived_name",
  "caption": "Lived Name",
  "type": "text",
  "optional": "true",
  "showIf": {
    "op": "AND",
    "rules":
Image Removed
 [
      {
        "field": "cpr.ppid",
        "op": ".search('^J') !=",  // Modify the regex in single quote as per requirement. 
        "value": "-1"
      }
    ]
  }
}

Example JSON

Download