# omit

## Definition

In a config modifier schema, use `omit` to conditionally remove or exclude a specific field or value from a processed payload. Although it’s the first keyword in order of execution, you should use it in the context of a conditional keyword like one of the following, then set `omit:true` to remove a field or value:

- `switch`
- `if`

## Order of execution

This keyword executes in the following order:  

1. **`omit`**
2. `constant`
3. `references`
4. `use`
5. `get`
6. Mutually exclusive keywords at this level:
   - `properties` 
   - `if` 
   - `concat` 
   - `switch` 
   - `pipe` 
   - `merge` 
   - `prefer` 
   - `items`
7. `default`
8. `plugin`

## Example

You can specify that a processed payload should omit an observation if its values match the terms you define.

**Example: Observations input from initial payload**

```json
"Observations": [
    {
      "AbnormalFlag": null,
      "Code": "93246-7",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "1",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "93247-5",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "1",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "NF1570400181",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "High Risk",
      "ValueType": "String"
    },
    {
      "AbnormalFlag": null,
      "Code": "93267-3",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "1",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "93269-9",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "0",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "NF1570400504",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "Putting my notes here",
      "ValueType": "String"
    }
  ]
```

**Example: Observations selector**

```json
$.Observations
```

**Example: Config modifier with omit keyword**

```yaml
items:
  switch:
    select:
      get: Code
    cases:
      - terms:
          - constant: NF1570400504
          - constant: NF1570400181
          - constant: 93374-7
        then:
          omit: true
    else:
      comment: pass observation through
```

If the observation values match the values defined in the schema, the `then` action executes (i.e., the observation is omitted from the processed payload). If the values don’t match, the `else` action executes (i.e., the payload passes through with the observation).

**Example: Observations output**

```json
"Observations": [
    {
      "AbnormalFlag": null,
      "Code": "93246-7",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "1",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "93247-5",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "1",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "93267-3",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "1",
      "ValueType": "Coded Entry"
    },
    {
      "AbnormalFlag": null,
      "Code": "93269-9",
      ...
      "Status": "Final",
      "Units": null,
      "Value": "0",
      "ValueType": "Coded Entry"
    }
  ],
```
