Got feedback or spotted a mistake?

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

Hide/Set Default Value to Specimen Fields

Introduction

Using 'showIf' and 'showInOverviewIf' conditions, you can hide specific fields either from all specimens pages or from parent/child pages. You can also hide or show fields based on some other field's value.

Using ' "defaultValue": "<value>" ' field, you can set the default value to any specimen field.

Hide Fields From All Pages

It is possible to hide a few specimen-level fields from the UI using the SDE. The fields like the anatomic site, pathology status, and laterality can be hidden from the add/edit and overview pages by removing them from the dictionary. These fields are defaulted to 'Not Specified' on the backend.

Below are the sample JSONs attached and steps to configure the JSON:

URLhttp://<host>:<port>/openspecimen/rest/ng/collection-protocols/{id}/workflows
MethodPUT
Requestapplication/json

Hide Fields on Parent/Child Specimen Pages

Example 1: The quantity for the parent specimen is not recorded since they are processed and stored as aliquots. The quantity field will not be displayed for specimens with lineage: 'New' (parent) on the unplanned specimens' add/edit/overview pages.

Quantity
{
  "name": "specimen.initialQty",
  "caption": "Initial Quantity",
  "showInOverviewIf": "useShowIf",      //Hides field from overview pages as well if the showif conditions are not met
  "type": "specimen-quantity",
  "specimen": "specimen",
  "optional": true,
  "showIf": {
    "op": "AND",
    "rules": [
      {
        "field": "specimen.lineage",
        "op": "!=",
        "value": "'New'"
      }
    ]
  }
}, {
  "name": "specimen.availableQty",
  "caption": "Available Quantity",
  "showInOverviewIf": "useShowIf",
  "type": "specimen-quantity",
  "specimen": "specimen",
  "optional": true,
  "showIf": {
    "op": "AND",
    "rules": [
      {
        "field": "specimen.lineage",
        "op": "!=",
        "value": "'New'"
      }
    ]
  }
}

Screenshot for the parent specimen's overview and edit page, where the fields for quantity are hidden.

Both the fields will be displayed for the child specimens (lineage: derived/aliquot).


Example 2Display specimen type field only on child pages and not on primary specimen page.

Example code
{
"name": "specimen.type",
"caption": "Specimen Type",
"showInOverviewIf": "specimen.lineage != 'New'",
"type": "specimen-type",
"specimen": "specimen",
"optional": true
}

Specimen field not displayed on parent specimen page:

Specimen field displayed on child specimen page:

Hide/Set Default Value to Mandatory Fields

#1. You can provide the default values for any mandatory fields like specimen type, anatomic site by adding "defaultValue": "<value>" as below:

  1. Add the below-mentioned code block in the dictionary.

  2. In the below example, we have set the default value 'Abdomen, NOS' for the anatomic site. Also,  hide the 'Anatomical Site' field from the aliquot overview page using the "showInOverviewIf": "useShowIf" function.

Anatomic site
{
  "name" : "specimen.anatomicSite",
  "caption" : "Anatomical Site",
  "type" : "pvs",
  "attr" : "anatomic_site",
  "optional" : true,
  "showInOverviewIf": "useShowIf",
  "defaultValue" : "Abdomen, NOS",
  "showOnlyLeafValues" : true,
  "showIf" : {
    "op" : "AND",
    "rules" : [ {
      "field" : "specimen.lineage",
      "op" : "!=",
      "value" : "'Aliquot'"
    } ]
  }
}

#2. Set Type field defaulted as "Plasma" and hide it from the data entry page by adding the false condition in ShowIf.

Type
{
      "name" : "specimen.type",
      "caption" : "Type",
      "defaultValue" : "Plasma",
      "type" : "specimen-type",
      "attr" : "specimen_type",
      "specimen" : "specimen",
      "optional" : false,
      "showIf" : {
        "op" : "AND",
        "rules" : [ {
          "field" : "specimen.lineage",
          "op" : "!=",
          "value" : "'Aliquot'"
        }, {
          "field" : "specimen.type",
          "op" : "!=",
          "value" : "'Plasma'"
        } ]
      }
},

#3. Set Anatomic Site field defaulted as "Plasma" and hide it from the data entry page by adding the false condition in ShowIf.

Anatomic Site
{
      "name" : "specimen.anatomicSite",
      "caption" : "Anatomical Site",
      "type" : "pvs",
      "attr" : "anatomic_site",
      "optional" : true,
      "defaultValue" : "Abdomen, NOS",
      "showIf" : {
        "op" : "AND",
        "rules" : [ {
          "field" : "specimen.lineage",
          "op" : "!=",
          "value" : "'Aliquot'"
        },
        {
          "field" : "specimen.anatomicSite",
          "op" : "!=",
          "value" : "'Abdomen, NOS'"
        } 
         ]
      }
    },

Example JSON

Download

Got feedback or spotted a mistake?

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