Versions Compared

Key

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

You can show the field fields based on the dropdown values contains for a specific string in it or is one of the values of the dropdown fieldstudy.

'Contains'

...

Condition

Example: Show the custom field 'Any complications' at the visit level only if the 'Clinical Diagnosis' field contains the word 'pregnancy' word. Below is the example code,.

Expand
titleClick here to expand
Code Block
languagejson
{
           "name" : "visit.extensionDetail.attrsMap.TA2",
           "caption" : "Any complications",
           "type" : "textarea",
           "optional" : true,
           "showIf" : {
             "op" : "AND",
             "rules" : [ {
               "field" : "visit.clinicalDiagnoses",
               "op" : ".join(',').indexOf('pregnancy')",
               "value" : "> -1"
             } ]
           },
           "showInOverviewIf": "useShowIf"
}

"op" : ".join(',').indexOf('pregnancy')":

...

means

...

show 'TA2' field when clinical diagnosis has 'pregnancy' word in the selected option.

...

Image Added

'Is one of the value'

...

Condition

Example 1: Suppose the case shows Shows the field 'Any complications' at the visit level if 'Clinical Diagnosis' has '10 weeks gestation of pregnancy' value. Below is the example code,in it.

Expand
titleClick here to expand
Code Block
languagejson
{
           "name" : "visit.extensionDetail.attrsMap.TA2",
           "caption" : "Any complications",
           "type" : "textarea",
           "optional" : true,
           "showIf" : {
             "op" : "AND",
             "rules" : [ {
               "field" : "visit.clinicalDiagnoses",
               "op" : ".indexOf('10 weeks gestation of pregnancy')",
               "value" : "> -1"
             } ]
           },
           "showInOverviewIf": "useShowIf"
  }

"op": ".indexOf('10 weeks gestation of pregnancy')":

...

means

...

show 'TA2' field when clinical diagnosis has '10 weeks gestation of pregnancy' value.

...

Image AddedImage Added

Example 2: Suppose you want to display fields on the nth step page when only specified specimen types are selected.

Expand
Code Block
languagejson
{
  "name" : "specimenCollection",
  "view" : null,
  "ctrl" : null,
  "data" : {
    "fieldGroups" : [ {
      "title" : "Processing Event for Frozen Samples",
      "criteria" : {
        "op" : "AND",
        "rules" : [ {
          "field" : "specimen.lineage",
          "op" : "==",
          "value" : "'Derived'"
        }, {
          "field" : "['Frozen Tissue', 'Frozen Tissue Slide', 'Frozen Tissue Block','Embedded in OCT', 'Swiss Role in OCT'].indexOf(specimen.type)",
          "op" : "!=",
          "value" : "-1"
        } ]
      },
      "fields" : [ {
        "name" : "specimen.label",
        "baseField" : "specimen.label",
        "type" : "span"
      }, {
        "name" : "specimen.type",
        "baseField" : "specimen.type",
        "type" : "span"
      }, {
        "name" : "specimen.createdOn",
        "baseField" : "specimen.createdOn",
        "caption" : "Processing Date and Time"
      } ]
    } ]
  }
}
Image Added

Example 3: Show field on overview and hide on the data entry page.

Expand
Code Block
languagejson
{
      "name" : "cpr.participant.extensionDetail.attrsMap.ST10",
      "caption" : "Kindred ID",
      "type" : "text",
      "showIf" : {
        "op" : "AND",
        "rules" : [ {
          "field" : "cpr.participant.extensionDetail.attrsMap.ST10",
          "op" : "==",
          "value" : "'xxx"
        } ]
      },
      "optional" : true
    }

Example 4: Show field on overview only if the value is present. (Check showinOverviewIf)

Expand
Code Block
languagejson
{
   "name" : "cpr.participant.extensionDetail.attrsMap.DP3",
   "caption" : "Estimated Date of Delivery",
   "showInOverviewIf" : "!!cpr.participant.extensionDetail.attrsMap.DP3",
   "type" : "date",
   "optional" : true
},

Example 5: Don’t show field on overview if the value present is “Not Specified“ or “Null“.

Expand
Code Block
{
      "name" : "visit.clinicalDiagnoses",
      "caption" : "Clinical Diagnoses",
      "type" : "pvs",
      "attr" : "clinical_diagnosis",
      "showInOverviewIf" : "!!visit.clinicalDiagnoses && visit.clinicalDiagnoses.length > 0 && (visit.clinicalDiagnoses.length != 1 || visit.clinicalDiagnoses[0] != 'Not Specified')",
      "optional" : true,
      "multiple" : true,
      "showIf" : {
        "op" : "AND",
        "rules" : [ {
          "field" : "visit.status",
          "op" : "!=",
          "value" : "'Missed Collection'"
        } ]
      }
    }

Example 6: Show the Birth Date field based on collection protocol name.

Expand
Code Block
{
      "name": "cpr.participant.birthDate",
      "caption": "Birth Date",
      "type": "date",
      "dateOnly": true,
      "optional": true,
      "showIf": {
        "rules": [
          {
            "field": "['(UAHS) [BW] Brain Health', 'AmolT1'].indexOf(cp.shortTitle)",
            "op": "!=",
            "value": "-1"
          }
        ]
      },
      "showInOverviewIf": "useShowIf"
    },

Screenshot 1: When CP name ((UAHS) [BW] Brain Health) is matched to the rule, then the field “Birth Date” is shown.

image-20240417-074449.pngImage Added

Screenshot 2: When CP name (Accreta Current) is not matched to the rule, then the field “Birth Date” is not shown or hide.

image-20240417-075833.pngImage Added

Example 7: Show custom field if the specimen type is ‘Fixed Tissue Block' or 'Fixed Tissue Slide’

Expand
Code Block
languagejson
{
      "name" : "specimen.extensionDetail.attrsMap.clinical_block_identifier",
      "caption" : "Clinical Block Identifier",
      "type" : "text",
      "optional" : true,
      "showInOverviewIf" : "useShowIf",
      "showIf" : {
        "op" : "OR",
        "rules" : [ {
          "field" : "specimen.type",
          "op" : "==",
          "value" : "'Fixed Tissue Block'"
        },
        {
          "field" : "specimen.type",
          "op" : "==",
          "value" : "'Fixed Tissue Slide'"
        } ]
      }
    } 

Example JSON

...

Download