# `BloodPressure`

A blood pressure (LOINC 85354-9): its systolic and diastolic `Pressure`s, the diastolic below the systolic. Shown `120/80 mmHg`. Health data.

[Health](types.md#health); not ordered; since Jadpo 0.1.0.

## Make one

Build one from its fields, `BloodPressure { systolic: ...  diastolic: ... }`.

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

- `diastolic_below_systolic`: `diastolic < systolic`

## Fields

| Field | Type |
|---|---|
| `systolic` | [`Pressure`](type-pressure.md) |
| `diastolic` | [`Pressure`](type-pressure.md) |

## Text, JSON and storage

It has no single text form, so `text.from` and `text.parse` don't take it. JSON sends an object of its parts.

| 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"}}` |

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

## 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 has the contract's own operations: `text.format`, `json.read`, `json.write` and `==`. It isn't ordered, so `<` and sorting don't take it. [Every standard type meets one contract](../topics/every-standard-type-meets-one-contract.md) says how they work.
