---
title: "service_direction"
description: "Structured details of a complex direction for an ordered or requested service."
---

Structured details of a complex direction for an ordered or requested service.

**Purpose.** To record structured details of a complex direction for an ordered or requested service.

## Source

| Model | Leg | Role |
|---|---|---|
| `openEHR-EHR-CLUSTER.service_direction.v1` | openEHR | defines this table |

## Columns

| Column | Type | Null | Description | Source |
|---|---|---|---|---|
| `id` | `uuid primary key` | no | Primary key. | — |
| `direction_sequence` | `integer` | yes | Direction sequence | `/items[at0001]` |
| `direction_description` | `text` | yes | Direction description | `/items[at0002]` |
| `direction_duration_coded_text`<br />`direction_duration_coded_text_code`<br />`direction_duration_coded_text_system`<br />`direction_duration_coded_text_valueset_id`<br />`direction_duration_duration` | coded text<br />`text`, `text`, `text`, `text`, `interval` | yes | Direction duration | `/items[at0007]` |
| `total_amount_count`<br />`total_amount_duration` | integer, interval<br />`integer`, `interval` | yes | Total amount | `/items[at0011]` |

## Constraints

```sql
check (direction_sequence is null or direction_sequence >= 1)
check ((direction_duration_coded_text_code is null and direction_duration_coded_text_system is null and direction_duration_coded_text_valueset_id is null) or (direction_duration_coded_text is not null and direction_duration_coded_text_code is not null and direction_duration_coded_text_system is not null and direction_duration_coded_text_valueset_id is not null))
check (num_nonnulls(direction_duration_coded_text, direction_duration_duration) <= 1)
check (total_amount_count is null or total_amount_count >= 1)
check (num_nonnulls(total_amount_count, total_amount_duration) <= 1)
```

## References

| Columns | Target | On delete |
|---|---|---|
| `direction_duration_coded_text_valueset_id, direction_duration_coded_text_code, direction_duration_coded_text_system, direction_duration_coded_text` | [`valueset_code`](/docs/tables/valueset_code) | restrict |

## Referenced by

- [`service_direction_activity`](/docs/tables/service_direction_activity) via `service_direction_id`
- [`service_direction_repetition_timing`](/docs/tables/service_direction_repetition_timing) via `service_direction_id`
- [`service_request_complex_timing`](/docs/tables/service_request_complex_timing) via `service_direction_id`

## Child tables

3 tables hang off `service_direction`, one row per repetition.

### `service_direction_activity`

Child table — one row per repetition, deleted with its parent.

| Column | Type | Null | Description | Source |
|---|---|---|---|---|
| `id` | `uuid primary key` | no | Primary key. | — |
| `service_direction_id` | `uuid` → [`service_direction`](/docs/tables/service_direction) | no | — | — |
| `position` | `integer` | no | Order of this row within its parent, from zero. | — |
| `activity_sequence` | `integer` | yes | Activity sequence | `/items[at0003]/items[at0004]` |
| `amount_count`<br />`amount_duration` | integer, interval<br />`integer`, `interval` | yes | Amount | `/items[at0003]/items[at0005]` |

#### Constraints

```sql
check (activity_sequence is null or activity_sequence >= 1)
check (amount_count is null or amount_count >= 1)
check (num_nonnulls(amount_count, amount_duration) <= 1)
```

#### Unique

- `service_direction_id, position`

#### References

| Columns | Target | On delete |
|---|---|---|
| `service_direction_id` | [`service_direction`](/docs/tables/service_direction) | cascade |

### Referenced by

- [`service_direction_activity_intraday_timing`](/docs/tables/service_direction_activity_intraday_timing) via `service_direction_activity_id`

### `service_direction_activity_intraday_timing`

Child table — one row per repetition, deleted with its parent.

| Column | Type | Null | Description | Source |
|---|---|---|---|---|
| `id` | `uuid primary key` | no | Primary key. | — |
| `service_direction_activity_id` | `uuid` → [`service_direction_activity`](/docs/tables/service_direction_activity) | no | — | — |
| `position` | `integer` | no | Order of this row within its parent, from zero. | — |
| `timing_daily_id` | `uuid` | no | Intraday timing | `/items[at0003]/items[at0006]` |

#### Unique

- `service_direction_activity_id, position`
- `service_direction_activity_id, timing_daily_id`

#### References

| Columns | Target | On delete |
|---|---|---|
| `service_direction_activity_id` | [`service_direction_activity`](/docs/tables/service_direction_activity) | cascade |
| `timing_daily_id` | [`timing_daily`](/docs/tables/timing_daily) | no action |

#### Indexes

- `service_direction_activity_intraday_timing_timing_daily_id_idx` on `timing_daily_id`

### `service_direction_repetition_timing`

Child table — one row per repetition, deleted with its parent.

| Column | Type | Null | Description | Source |
|---|---|---|---|---|
| `id` | `uuid primary key` | no | Primary key. | — |
| `service_direction_id` | `uuid` → [`service_direction`](/docs/tables/service_direction) | no | — | — |
| `position` | `integer` | no | Order of this row within its parent, from zero. | — |
| `timing_nondaily_id` | `uuid` | no | Repetition timing | `/items[at0010]` |

#### Unique

- `service_direction_id, position`
- `service_direction_id, timing_nondaily_id`

#### References

| Columns | Target | On delete |
|---|---|---|
| `service_direction_id` | [`service_direction`](/docs/tables/service_direction) | cascade |
| `timing_nondaily_id` | [`timing_nondaily`](/docs/tables/timing_nondaily) | no action |

#### Indexes

- `service_direction_repetition_timing_timing_nondaily_id_idx` on `timing_nondaily_id`

## Value sets

| Value set | Codes |
|---|---|
| `org.openehr::openEHR-EHR-CLUSTER.service_direction.v1/direction_duration` | 1 |

