# The data model

What the fields mean, and the rules behind them. Agents and developers can rely on these definitions; they don't change within `/v1`.

## Entries

An entry (an *absence*) is a player who is currently unavailable for his club, as at least one source reports it. Every entry has an `id` that stays the same while it's open, and a `player.id` that stays the same across entries.

An entry closes when the player is dressed for a game of his club again (`closed_reason: returned`), when no source lists him any more (`cleared`), or when he's dressed for another club (`moved`: a loan to another National League club, a transfer). Closed entries no longer appear in the current lists; [`/v1/changes`](/api/reference#get-v1-changes) shows that they closed.

[`/v1/changes`](/api/reference#get-v1-changes) also lists updates (`kind: updated`) when they are news: a new `type`, a new reason, or a new suspension length (`suspension.games`, `was`, and `eligible_from`, the first game the player may play again). A reworded return estimate is not news and isn't listed; the entry itself always has the latest wording.

Clubs' medical reports list everyone the club says is out. When a club drops a player but another source still lists him (usually SIHF's lineup sheet of his team's last game), the entry stays open with `off_club_report` set: since when, and the club's page. Its `return` is then the club's last estimate, from before it dropped him; the site shows "Off the club's medical report since …" instead. `/v1/changes` lists the drop as an update with `changed: ["club_report"]` and `club_report.listed: false`, and `listed: true` when the club lists him again. The entry closes as usual, once he's dressed for a game (`returned`) or no source lists him (`cleared`).

When a club's game preview or news says a player it lists as out plays a named upcoming game ("Martschini vor Comeback"), his entry gets `expected_back`: the game (`starts_at`, `home`, the `opponent`'s slug) and the article (`url`, `said_on`). It's the club's stated plan, read by a language model and checked against the article, not a fact: the entry stays open until he's dressed, and `expected_back` is null again once that game has started.

## `type`

| Value | Meaning |
|---|---|
| `injury` | Injured |
| `illness` | Ill |
| `suspension` | Suspended (league discipline) |
| `loan` | With the farm team or another club (`category: loan`) |
| `national_team` | Away with a national team |
| `personal` | Personal reasons |
| `healthy_scratch` | Fit, but left out of the last game (`category: scratch`) |
| `import_limit` | A foreign player left out because six were already dressed (`category: scratch`) |
| `unknown` | Unavailable, reason not known |

## `category`

Not every entry is an absence. `category` says how an entry counts:

| `category` | Types | Counted in `Team.out` |
|---|---|---|
| `out` | injury, illness, suspension, national team, personal, unknown | yes |
| `scratch` | healthy scratch, import limit: fit, left out by the coach | no |
| `loan` | loan: with the farm team or another club, a roster decision | no |

Lists return `category=out` by default, as the site counts; ask for `category=all`, `scratch`, `loan`, or several (`out,loan`).

## `confidence`

How the information is known, from strongest to weakest:

| Value | Source |
|---|---|
| `official` | The club itself: its medical report or its news |
| `league` | The National League (discipline) or the Swiss Ice Hockey Federation (lineup sheets) |
| `media` | A media report, checked by a person before it's shown |
| `inferred` | Only that a regular has been missing from the lineups; the reason is unknown |

When several sources report the same player, the entry shows the strongest one's details, and `sources` lists them all.

## Reasons

`reason_text` is the reason **as the source published it, in its language** ("Oberkörperverletzung", "bas du corps", "knee"). sidelined.ch adds no medical details, diagnoses or guesses of its own. `body_region` (`upper_body`, `lower_body`, `head`) is only set when the source names it. Inferred entries have no reason.

## `since` and `since_kind`

| `since_kind` | `since` is |
|---|---|
| `reported` | A date the source published (injury or report date) |
| `article` | The date of the news article that reported it |
| `first_seen` | When sidelined.ch first saw the entry (sources without dates) |
| `lineup` | The first game the player missed |

## `return`

The expected return: the source's wording and sidelined.ch's reading of it. **An estimate, not a club statement.**

| `return.kind` | Reading | `min` / `max` |
|---|---|---|
| `day_to_day` | Day-to-day | today and a week later |
| `week_to_week` | Week-to-week | one to four weeks from now |
| `duration` | "6 weeks", "2–3 Wochen", "several months" | the window from the report date |
| `calendar` | "mid-November", "fin octobre" | that part of the month |
| `games` | A suspension for a number of games | the date of the first game he may play again (he misses the ones before it) |
| `season` | Out for the season | both the end of the season |
| `unknown` | "unbestimmt", "à déterminer" | both `null` |

`return.text` keeps the source's original words, and `return.text_by` is `source`. The one exception: for league suspensions the league states the number of games, and `text` is our summary of it ("für 3 Spiele gesperrt", "vorsorglich für 1 Spiel gesperrt"), with `text_by` set to `sidelined`. Don't quote that as the league's words.

## `sources`

Every entry lists where it comes from: `kind`, a readable `label` and the `url` of the page or document (the club's report, the article, the lineup sheet). Lineup data has no URL.

## Freshness

Club pages are read every 30 minutes, news every 1 to 4 hours, SIHF's lineups and lineup sheets around each game. `Team.checked_at` says when the club's own sources were last read successfully.

`Team.next_game` is the club's next National League game from the league's schedule (today's, until it's over): `starts_at` in Swiss local time with its offset, `home`, and the `opponent`. Cup and Champions Hockey League games aren't in it. `null` when nothing is scheduled.
