# `BloodPressure`

A blood pressure reading: `120/80 mmHg`.

Use it for a person's reading. For any other pressure, use [`Pressure`](/docs/types/type-pressure.md).

## Shape

| Field | Type | Required? |
|---|---|---|
| `systolic` | [`Pressure`](/docs/types/type-pressure.md) | Yes |
| `diastolic` | [`Pressure`](/docs/types/type-pressure.md) | Yes |

Its parts keep these rules, and a value that breaks one fails with the rule's name:

- `diastolic_below_systolic`: diastolic < systolic

## Example

```jadpo
BloodPressure {
    systolic: 120mmHg
    diastolic: 80mmHg
}
```

## Good to know

- `diastolic` must be below `systolic`.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it, so sort by one of its parts instead.
- A field that holds one counts as personal data (`health`), so you don't mark it yourself.

## In JSON

An object of its parts, in a request, a response or `json.write`:

```json
{"systolic":{"value":"15998.686","unit":"Pa"},"diastolic":{"value":"10665.791","unit":"Pa"}}
{"systolic":{"value":"19331.746","unit":"Pa"},"diastolic":{"value":"12265.66","unit":"Pa"}}
{"systolic":{"value":"16000","unit":"Pa"},"diastolic":{"value":"10700","unit":"Pa"}}
```

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`BloodPressure` is in the group Health, and has been in Jadpo since 0.1.0.

### Text form

It has no single text form, so `text.from` and `text.parse` don't take it.

### How it is stored

It is stored in 2 columns, each named for the field, `_` and its suffix. This is `{"systolic":{"value":"19331.746","unit":"Pa"},"diastolic":{"value":"12265.66","unit":"Pa"}}`:

| Column | Type | Holds |
|---|---|---|
| `<field>_systolic` | `numeric(38, 3)` | `19331.746` |
| `<field>_diastolic` | `numeric(38, 3)` | `12265.66` |

### How it is shown to people

`text.format(value, locale:)` shows it to people in their locale. A call may also give `unit:`.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `{"systolic":{"value":"120","unit":"mmHg"},"diastolic":{"value":"80","unit":"mmHg"}}` | `120/80 mmHg` |
| `{"systolic":{"value":"145","unit":"mmHg"},"diastolic":{"value":"92","unit":"mmHg"}}` | `145/92 mmHg` |
| `{"systolic":{"value":"16","unit":"kPa"},"diastolic":{"value":"10.7","unit":"kPa"}}` | `120/80 mmHg` |

### Operations

It also takes `text.format`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
