# GetShiftPattern

## Overview

getShiftPattern retrieves a single ShiftPattern by id, including its embedded `segments`. It is the lookup behind pattern detail/edit views and behind Shift creation flows that instantiate a pattern.

## Business Rules

- Accepts a `shiftPatternId` as input
- Returns the pattern record (`code`, `name`, `kind`) plus its ordered embedded `segments` (by `sequence`)
- A pattern always has at least one segment, so the segment list is never empty for an existing pattern
- Reference/master data: not effective-dated, so there is exactly one current record per id

## Process Flow

```mermaid
flowchart TD
    A[Receive shiftPatternId] --> B[Look up ShiftPattern by id]
    B --> C{Found?}
    C -->|No| D[Return error: SHIFT_PATTERN_NOT_FOUND]
    C -->|Yes| E[Return embedded segments ordered by sequence]
    E --> F[Return pattern with segments]
```

## External Dependencies

None — segments are embedded directly in the ShiftPattern (ADR-022).

## Error Scenarios

- **SHIFT_PATTERN_NOT_FOUND**: no ShiftPattern exists for the given id

## Test Cases

- returns the ShiftPattern for a given id
- returns segments ordered by sequence
- returns a single segment for a 日勤/早番/遅番/夜勤/宿直 pattern
- returns two or more segments for a 中抜け pattern
- throws SHIFT_PATTERN_NOT_FOUND for an unknown id
