icgc-argo / argo-dictionary

Development of the ARGO Data Dictionary
https://docs.icgc-argo.org/dictionary
GNU Affero General Public License v3.0
2 stars 1 forks source link

Allow a clinical exceptions on fields "percent_tumour_cells" and "percent_tumour_cells_measurement_method" #418

Closed lindaxiang closed 1 year ago

lindaxiang commented 1 year ago

Since "percent_tumour_cells" is of "Number" type, we can't implement a clinical exception using the Clinical Exception API. Instead we'll need to create a validation script that permits "percent_tumour_cells" to be empty if = "percent_tumour_cells_measurement_method" is submitted as "Not applicable"

Similar solution as what we did for the "chemotherapy_drug_dose" field (https://github.com/icgc-argo/argo-dictionary/issues/409)

lindaxiang commented 1 year ago

Proposed solution (Thanks to @hknahal suggestions):

  1. Create validation script for "percent_tumour_cells":

  2. in this script $field is the submitted value for the "percent_tumour_cells" field and $name is the actual field name ("percent_tumour_cells")

  3. Code:

    // Check for when "percent_tumour_cells_measurement_method" has a clinical exception value of "not applicable"
    if ($row.percent_tumour_cells_measurement_method && $row.percent_tumour_cells_measurement_method != null && !(checkforEmpty($row.percent_tumour_cells_measurement_method)) && $row.percent_tumour_cells_measurement_method.trim().toLowerCase() === 'not applicable') {
      if ($field && $field != null && !(checkforEmpty($field))) {
          result = {
            valid: false,
            message: `The '${$name}' field cannot be submitted when 'percent_tumour_cells_measurement_method' = 'Not applicable'`
          };
        }
      }