# default

## Definition

In a config modifier schema, use `default` to specify a value to return if any of the previous keywords result in a non-existent value. This value can be a primitive value or an object.

> **Definition of existence**
>
> We define <u>existence</u> of a value based on some rules. Specifically, these evaluations are defined as <u>does not exist</u>:
>
> - `undefined`
> - `null`
> - `''`
> - `[]`
> - `NaN`
>
> We specifically treat some Falsy ([learn about Falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)) values as <u>exists</u>:
>
> - `false`
> - `0`
> - `' '` (empty string but padded with a space)

## 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 could set a default value for a specific value if it doesn’t exist in the input. 

For example, if `SCH.25.1` is missing from the `initialPayload` (an HL7v2 message in the scenario below), you can set the  `Visit.Status` property to a `default` value of  “Scheduled” in the `Scheduling` data model message.

**Example: Default input**

```json
  {
    "SCH": {
      "2": {
        "1": "123456",
        "2": "HST"
      },
      "3": "1",
      "7": {
        "1": "",
        "2": "**Comment Notes here***"
      },
      "9": "0001",
      "10": {
        "1": "s"
      },
      "11": [
        {
          "1": {
            "1": ""
          },
          "2": {
            "1": ""
          },
          "3": "",
          "4": {
            "1": "20250924111500"
          },
          "5": {
            "1": "20250924121500"
          }
        }
      ],
      "16": [
        {
          "1": "",
          "2": {
            "1": "Mouse"
          },
          "3": "Mickey"
        }
      ],
      "20": [
        {
          "1": "",
          "2": {
            "1": "Mouse, Mickey"
          }
        }
      ]
    },
  }
```

**Example: Default selector**

```json
$.Visit.Status
```

**Example: Config modifier with default keyword**

```yaml
use: initialPayload
get: SCH.25.1
default: Scheduled
```

**Example: Default output**

```json
{
  "Visit": {
      ...
      "Status": "Scheduled",
      ...
  }
}
```
