# constant

## Definition

In a config modifier schema, use `constant` to specify that a certain value should always be returned in the processed payload. The value can be a primitive value or an object.

A `constant` keyword ends the processing for that specific field. Any other keywords at the same nesting level or below it are skipped.

## 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 define which value to return at a given selector based on certain conditions. 

**Example: Constant input from initial payload**

```json
{
  "MSH": {
    "1": "|",
    "10": 68625012079,
    "12": {
      "1": "2.3"
    },
    "2": "^~\\&",
    "3": {
      "1": "GENEDX"
    },
    "4": {
      "1": "GDXIP"
    },
    "6": {
      "1": "ZY292"
    },
    "7": {
      "1": "20250428211659"
    },
    "9": {
      "1": "ORU",
      "2": "R01"
    }
  },
  ...
}
```

**Example: Constant selector**

```json
$.MSH.4.1
```

**Example: Config modifier with constant keyword**

```yaml
if:
  operator: equals
  terms:
    - use: initialPayload
      get: MSH.6.1
    - constant: ZA310
  then:
    constant: GDXIP
  else:
    constant: GDXAMB
```

During processing, the request checks if `MSH.6.1` equals `ZA310` in the initial payload. If so, the `then` action executes, meaning that `MSH.4.1` is set to `GDXIP`. If `MSH.6.1` doesn’t equal `ZA310`, the `else` action executes, meaning that `MSH.4.1` is set to `GDXAMB`.

**Example: Constant output**

```json
{
  "MSH": {
    "1": "|",
    "10": 68625012079,
    "12": {
      "1": "2.3"
    },
    "2": "^~\\&",
    "3": {
      "1": "GENEDX"
    },
    "4": {
      "1": "GDXAMB"
    },
    "6": {
      "1": "ZY292"
    },
    "7": {
      "1": "20250428211659"
    },
    "9": {
      "1": "ORU",
      "2": "R01"
    }
  },
```
