frictionlessdata / frictionless-py

Data management framework for Python that provides functionality to describe, extract, validate, and transform tabular data
https://framework.frictionlessdata.io
MIT License
710 stars 148 forks source link

Validating Combinations of Fields in CSV Files #1667

Open megin1989 opened 4 months ago

megin1989 commented 4 months ago

Overview

How can I perform Validating Combinations of Fields?

Example: Validate that all combinations of the ENCOUNTER_CLASS_CODE and ENCOUNTER_CLASS_CODE_DESCRIPTION fields in the primary CSV file exactly match the data given in the validation file. The check should ensure that each pair of ENCOUNTER_CLASS_CODE and ENCOUNTER_CLASS_CODE_DESCRIPTION in the primary CSV exists in the validation.json file using enum fields.

{
  "name": "ENCOUNTER_CLASS_CODE",
  "type": "string",
  "constraints": {
    "required": true,
    "enum": [
      "amb",
      "emer",
      "fld",
      "hh",
      "imp",
      "acute",
      "nonac",
      "obsenc",
      "prenc",
      "ss",
      "vr"
    ]
  }
},
{
  "name": "ENCOUNTER_CLASS_CODE_DESCRIPTION",
  "type": "string",
  "constraints": {
    "enum": [
      "ambulatory",
      "emergency",
      "field",
      "home health",
      "inpatient encounter",
      "inpatient acute",
      "inpatient non-acute",
      "observation encounter",
      "pre-admission",
      "short stay",
      "virtual"
    ]
  }
}
megin1989 commented 14 hours ago

If the ENCOUNTER_CLASS_CODE value is 'amb', the ENCOUNTER_CLASS_CODE_DESCRIPTION value should be 'ambulatory'. is it possible? Please help.