Versions Compared

Key

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

...

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"
          }
        }
      }
    },

Show/Hide custom field – Using Regex Matching

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

Example code

...

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.
lived
core_size_
name
mm",
      "caption" : "
Lived Name
Core Size (mm)",
      "type" : "text",
  
"optional":
 
"true",
   "showIf"
: { "op": "AND", "rules": [ {
 : "!!specimen.extensionDetail.attrsMap.core_size_mm",
      "
field
showInOverviewIf" : "
cpr.ppid
useShowIf"
,

      
"
op
optional" : 
".search('^J') !=", // Modify the regex in single quote as per requirement. "value": "-1" } ] } }

Show/Hide Custom field based on CP site

Expand

#1. When CP SiteName is an Amol site, then only it will show the custom field 'Live Nucleated Count (MCells)'.

Code:

Code Block
{
        "name": "specimen.extensionDetail.attrsMap.post_processing_nucleated_count",
        "caption": "Live Nucleated Count (MCells)",
        "type": "text",
        "attr": "post_processing_nucleated_count",
        "optional": true,
        "showIf": {
          "op": "NOT",
          "rules": [
            {
              "field": "cp.siteName",
              "op": "!=",
              "value": "'Amol site'"
            }
          ]
        },
        "showInOverviewIf": "useShowIf"
      }

Screenshot:

image-20241018-150140.pngImage Removed

#2. When CP SiteName is not Amol site, then not show the custom field 'Live Nucleated Count (MCells)'.

Code:

Code Block
{
        "name": "specimen.extensionDetail.attrsMap.post_processing_nucleated_count",
        "caption": "Live Nucleated Count (MCells)",
        "type": "text",
        "attr": "post_processing_nucleated_count",
        "optional": true,
        "showIf": {
          "op": "NOT",
          "rules": [
            {
              "field": "cp.siteName",
              "op": "==",
     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": [
      {
        "
value
field": "
'Amol site'"
cpr.ppid",
        "op": ".search('^J') !=", 
}
 // Modify the regex in single quote as per requirement. 
]

        
},
"value": "-1"
      }
"showInOverviewIf":
 
"useShowIf"
   ]
  }
}

Screenshot:

image-20241018-150035.pngImage Removed

Example JSON

Download