# properties

## Definition

In a config modifier schema, use `properties` to define individual properties to construct an object in the processed payload. 

> **Exclusive keywords**
>
> If `properties`, `if`, `concat`,  `switch`, `pipe`, `merge`, `prefer`, or `items` are present at the same nesting level, only the first keyword listed will run. We recommend not listing these keywords together at the same nesting level. 

## 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

In this example, you have an HL7v2 RDE message that gets mapped to the Redox `Medication` data model, which doesn't include an `Order.ClinicalInfo` array. 

**Example: properties input**

```json
{
  ...
  "ORDER": [
    {
      ...
      "OBSERVATION": [
        {
          "OBX": {
            "1": "1",
            "2": "ST",
            "3": {
              "1": "12260968",
              "2": "Specify type of feeding"
            },
            "5": [
              "Infant Bolus"
            ]
          }
        }
      ]
    }
  ]
}
```

However, the destination system wants each `OBX` segment in the HL7v2 message to come through as a `ClinicalInfo` array under `Order`.

The following schema ensures the order remains unchanged. It creates a new `ClinicalInfo` array by iterating over the initial message’s `ORDER[0].OBSERVATION` array and `get`ting specific OBX components.

Each `ClinicalInfo` comprises the following optional properties:

- `Code`
- `Description`
- `Value`
- `Units`
- `Codeset`

These fields must be nested under the `ClinicalInfo` array property name.

**Example: Properties selector**

```json
$.Order
```

**Example: Config modifier with properties keyword**

```yaml
merge:
  - {}
  - properties:
      ClinicalInfo:
        use: initialPayload
        get: ORDER[0].OBSERVATION
        items:
          properties:
          # Note: If a targeted field (like OBX.6.1 for Units) is missing from the input payload,
          # the property is simply omitted from the resulting output object.
            Code:
              get: OBX.3.1
            Description:
              get: OBX.3.2
            Value:
              get: OBX.5[0]
            Units:
              get: OBX.6.1
            Codeset:
              get: OBX.2
```

Given that, the output would be: 

**Example: Properties output**

```json
{
  ...
  "Order": {
    "ClinicalInfo": [
      {
        "Code": "12260968",
        "Codeset": "ST",
        "Description": "Specify type of feeding",
        "Value": "Infant Bolus"
      }
    ],
    ...
  }
}
```
