## Patterns

### Assistant review: prepare, review, approve

The most important pattern in Parea. It is how "Parea bereitet vor, Ihr Team gibt frei" looks. The markup is in Components, Assistant.

1. **Prepared.** Assistant output appears in a `pa-assistant` block (lilac tint and border) with the label "Von Parea vorbereitet" and the Parea mark. In a list it is a row with a `pa-badge--assistant` "Entwurf".
2. **Sourced.** Every draft names what it was made from ("Aus der Aufnahme vom 12.01.2027, 09:34", "Auf Basis Ihrer Praxisinformationen") in `pa-assistant-source`, with a link to the source where one exists ("Aufnahme öffnen").
3. **Reviewed.** The person reads, edits or discards. A passage the assistant is unsure about is wrapped in `pa-assistant-mark` and explained in a `pa-assistant-note` directly under its paragraph ("Bitte prüfen: Dosierung nicht eindeutig verstanden."), linked with `aria-describedby`. No percentages, no confidence scores.
4. **Approved.** One explicit action by a named person with the right role, on a button that names the object and the outcome: "Befund freigeben", "Antwort senden". Under the actions, one line says who is acting: "Sie geben als Dr. Jana Höfler frei." Only Behandler approve medical documents.
5. **Settled.** The same box stays where it is and loses the lilac (`data-state="approved"`). A `pa-approved` line replaces the label: "Freigegeben von Dr. Jana Höfler, 12.01.2027, 10:02". Below the document a short "Verlauf" lists what happened, newest first: who approved, who edited, when Parea prepared it.

Buttons and their names:

| Where | Button | What it does |
| --- | --- | --- |
| A list row or a summary | the row itself, or "Entwurf prüfen" | Opens the draft. Approves nothing. |
| The draft, fully visible | "Befund freigeben", "Antwort senden" | Approves at once. Primary. |
| The draft | "Bearbeiten" | Switches to editing. Secondary. |
| The draft | "Verwerfen" | Opens a confirmation. Ghost. |

Editing:

- "Bearbeiten" replaces the text with fields in the same box: one `pa-textarea` per section, each with `data-assistant` until the person changes it.
- While editing, the actions are "Änderungen speichern" (primary) and "Abbrechen". Approve and discard come back after saving. A draft with unsaved changes cannot be approved.
- Unsaved changes are announced with a `pa-badge pa-badge--warning pa-badge--pending` "Ungespeicherte Änderungen" in a `role="status"` region. Leaving with unsaved changes asks once in a dialog: "Änderungen verwerfen?", "Weiter bearbeiten", "Änderungen verwerfen".
- A flagged passage keeps its note until the person edits that passage.

Discarding:

- "Verwerfen" opens a dialog: "Entwurf verwerfen?", "Der Entwurf wird gelöscht. Die Aufnahme bleibt erhalten.", "Entwurf behalten", "Entwurf verwerfen".
- Afterwards a `pa-alert--neutral` stands in place of the draft: "Entwurf verworfen."

Rules:

- Nothing prepared by the assistant is sent to a patient, written to a record or acted on without step 4. There is no auto-send and no "alle freigeben" for medical content.
- Approve, edit and discard appear together whenever a draft is shown and not being edited. Discard is never hidden in a menu.
- Before sending anything to a patient, confirm the patient's name, the full email address and the approved document on one screen.
- If a patient talks to an automated assistant, say so in the first message, in plain words: "Ich bin der digitale Assistent der Ordination am Park."
- The assistant never states a diagnosis or a medical decision as its own. Drafts attribute what they say: "Die Patientin berichtet", "laut Gespräch". Keep the practice's own section names for a report.
- Do not use sparkle icons, gradients or glow for AI. The mark and Flieder are the whole signal.

### Patient flow: one thing per page

Booking, intake forms, consent and follow-up all use the same structure. The frame markup is in Components, Patient frame.

- `data-audience="patient"` and `data-theme="light"` on `<html>`, `pa-patient-frame` on `<body>`, content in `pa-page--patient`.
- One question or one decision per step. The heading (`h1`) is the question. A summary and a result are statements.
- Above the heading: `pa-back` "Zurück" (not on the first step, not on the result) and, for flows of three or more steps, `pa-progress` with "Schritt 2 von 6". Questions and the summary are counted, the result is not. The bar is `aria-hidden="true"`, the words carry it.
- Answer with `pa-choice` cards, `pa-slot` buttons or one to four fields. Then one `pa-button pa-button--lg` "Weiter" inside `pa-actions`.
- Below the action, earlier answers stay visible under the heading "Ihre bisherigen Angaben": a `pa-card` with `pa-facts` and "Ändern" per row.
- The last step before submitting shows every answer once (`pa-facts`), says who sees the data and how long it is kept (`pa-alert--neutral`), and has the action with its real name ("Termin buchen").
- "Ändern" goes to that step. "Weiter" there returns to the summary. If the change makes later answers invalid (a new day needs a new time), those are asked again.
- Never lose what the person entered: not on back, not on error, not on reload. Keep the answers in `sessionStorage` for the length of the flow and clear them after submitting. Never keep patient data in `localStorage`.
- End with `pa-result`: what happened, what happens next, then the facts, then at most one action, which is secondary ("Zum Kalender hinzufügen"). The task is done, so nothing is primary.
- The practice's phone number is in the header of every step as a `tel:` link (`pa-patient-phone`).
- Say how long things take and how long data is kept, in plain numbers: "Die Buchung dauert etwa 2 Minuten.", "Die Ordination speichert Ihre Angaben 12 Monate."
- The footer holds the practice's name and address, "Impressum", "Datenschutz", and the line "Online-Terminbuchung mit Parea Agenda" as text.

Booking steps, each only when needed:

| Step | Heading | Answer |
| --- | --- | --- |
| Standort (more than one) | Wo möchten Sie hinkommen? | Choices with name and address |
| Besuch (if the practice asks) | Waren Sie schon bei uns? | Two choices |
| Terminart (more than one) | Welchen Termin brauchen Sie? | Choices with duration and billing ("30 Minuten, Kasse") |
| Tag | Welcher Tag passt Ihnen? | Choices for the next six days with free times, then a secondary button "Spätere Tage anzeigen" |
| Uhrzeit | Welche Uhrzeit passt Ihnen? | Slots under Vormittag (before 12:00), Nachmittag (12:00 to 17:00), Abend (from 17:00) |
| Person | Wer kommt zum Termin? | Vorname, Nachname, Geburtsdatum |
| Kontakt | Wie erreichen wir Sie? | Telefonnummer, E-Mail-Adresse, optional reminder |
| Zusammenfassung | Ist alles richtig? | Facts, data note, "Termin buchen" |
| Result | Ihr Termin ist bestätigt | Facts, "Zum Kalender hinzufügen" |

- With Arc's `availability-picker`, day and time are one step with the heading "Wann passt es Ihnen?".
- After a slot is chosen, say it in words in a `role="status"` line: "Gewählt: Mittwoch, 13. Jänner 2027, 17:30 bis 18:00 Uhr."
- A device outside Austrian time gets the note "Alle Zeiten in österreichischer Ortszeit." under the slots. Compare the offset of `Europe/Vienna` with the device's for the chosen day.
- Whether a booking is confirmed at once depends on the practice. Confirmed: "Ihr Termin ist bestätigt", `pa-result-mark` with a check, badge "Bestätigt". Request: "Ihre Anfrage ist bei der Ordination", `pa-result-mark--pending` with a clock, badge "Angefragt", and when the answer will come.
- If the slot was taken in the meantime, return to the time step with the error "Dieser Termin ist leider nicht mehr frei. Bitte wählen Sie eine andere Zeit."
- Hold a slot only if the product really does, and then say for how long: "Wir halten diesen Termin 10 Minuten für Sie frei."
- "Zum Kalender hinzufügen" downloads an `.ics` file with the practice, address, time and phone number. No appointment type, no reason for the visit.
- A booking code is six characters without look-alikes (no O, 0, I, 1), grouped in threes and set in mono: `K7P-4QX`.

### Forms and validation

- Validate on submit, not while typing and not on blur. Keep every value.
- On error, show a `pa-error-summary` below the page heading and above the first field, move focus to it, and repeat each message at its field.

```html
<div class="pa-error-summary" role="alert" tabindex="-1">
  <h2 class="pa-error-summary-title">Bitte prüfen Sie Ihre Angaben</h2>
  <ul>
    <li><a href="#geburtsdatum">Geben Sie Ihr Geburtsdatum ein, zum Beispiel 14.03.1958.</a></li>
  </ul>
</div>
```

- A field error is a `pa-error` under the field (see Field). A choice or slot group gets its `pa-error` under the group, the `fieldset` points to it with `aria-describedby`, and the summary link focuses the first option. Copy: "Wählen Sie eine Terminart aus.", "Wählen Sie einen Tag aus.", "Wählen Sie eine Uhrzeit aus."
- A group error clears when the person chooses. Field errors clear on the next submit.
- Error text says how to fix it and never blames: "Geben Sie Ihr Geburtsdatum ein, zum Beispiel 14.03.1958." Not "Ungültige Eingabe".
- Ask only for what the next step needs. Explain why for anything sensitive ("Die Ordination braucht sie für Rückfragen").
- Date of birth: one typed field, `inputmode="numeric"`, `autocomplete="bday"`, `pa-input--w10`, hint "Zum Beispiel 14.03.1958. Die Punkte können Sie weglassen." Accept 14.03.1958, 14031958 and 14.3.1958. Not a calendar picker. For a date that cannot be right: "Geben Sie ein Geburtsdatum in der Vergangenheit ein."
- Phone: `type="tel"`, `autocomplete="tel"`. Strip spaces, hyphens, slashes and brackets. It is only wrong with fewer than seven digits: "Geben Sie eine Telefonnummer wie +43 1 234 56 78 ein." Show it back as it was typed.
- In practice tools, editing happens in place, in a detail view or in a drawer, with "Speichern" and "Abbrechen".

### Identity and sensitive data

- The patient banner is pinned whenever a record is open, and shows the identifiers in full.
- Identifiers appear only where the task needs them: in the banner of an open record and in a search result that has to tell two people apart. Lists show names, not SV-Nummern. There are no half-masked numbers.
- Lists that others may see (a reception screen) offer a privacy switch in the view header: `pa-switch` "Namen kürzen", off by default, remembered on the device. It shortens names in lists and alerts to "Gruber, M." and never touches the banner of an open record.
- SV-Nummer is 10 digits shown as "1237 010180" in mono. Never derive or validate a date of birth from it.
- Emails, SMS and push notifications contain no clinical detail: not the reason for the visit, not a result. They say that something is ready and link to a protected page.
- A protected link needs a second factor the patient already has (an access code sent separately).
- Show who can see what, in words: "Nur Behandler können Befunde freigeben."
- Every operator or support access is announced: "Betreiberzugriff auf Ordination am Park. Jeder Zugriff wird im Audit-Log vermerkt."

### Theme switch

Practice tools offer the theme in the account menu or the settings: a `pa-segmented` with "Hell", "Dunkel" and "System", `aria-pressed` on the chosen one, in a group labelled "Darstellung". It sets `data-theme` on `<html>` and is remembered on the device. Patient pages ship `data-theme="light"` and have no switch.

### Sign-in

- Email plus a one-time code (`pa-code`) or a password. Allow paste and password managers. No puzzles.
- "Code anfordern", then "Prüfen Sie Ihr Postfach" with the address shown, "Neuen Code senden in 30 s", "Andere E-Mail-Adresse".
- Say how long the code is valid.

### States

Every region that loads data has four designed states: loading (`pa-skeleton`), empty (`pa-empty`), error (inline `pa-alert--danger` with "Erneut versuchen") and success shown in place. Conflicts are reported, not overwritten: "Der Eintrag wurde inzwischen geändert. Bitte laden Sie ihn neu."

Something that needs attention before a deadline (a request about to lapse) is an inline `pa-alert--warning` above the list it belongs to, with one action. Something that failed in the background (a recording that could not be processed) is a `pa-alert--danger` next to where its result would have appeared, with "Erneut versuchen".

### Destructive actions

Cancelling an appointment, removing access, deleting, discarding: the button opens a dialog whose title is the question, whose text is the consequence and whose buttons name both outcomes. If it can be undone, say so. If it notifies someone, say whom: "Die Person erhält eine Absage per E-Mail. Die Zeit wird wieder frei."

### Dates, numbers, names

Dates, times, numbers and money come from `Intl` with locale `de-AT` and time zone `Europe/Vienna`. Do not build them from parts by hand.

| Thing | Patient | Practice |
| --- | --- | --- |
| Date | Dienstag, 12. Jänner 2027 | Di., 12.01.2027 |
| Date in a short list | Dienstag, 12. Jänner | Di., 12.01. |
| Time | 09:30 Uhr | 09:30 |
| Range | 09:30 bis 10:00 Uhr | 09:30–10:00 |
| Date and time | Dienstag, 12. Jänner 2027, 09:30 Uhr | 12.01.2027, 09:30 |
| Relative | heute, morgen, in 3 Tagen | heute, morgen |
| Duration | 30 Minuten | 30 Min. |
| Money | € 80,00 and € 1.234,50 | € 80,00 |
| Number | 1 234,5 | 1 234,5 |
| Phone | +43 1 234 56 78 | +43 1 234 56 78 |
| Date of birth | 14. März 1958 | 14.03.1958 (68 Jahre) |
| Name | Maria Gruber, Frau Gruber | Gruber, Maria |

```js
const at = { timeZone: 'Europe/Vienna' };
const f = (options) => new Intl.DateTimeFormat('de-AT', { ...at, ...options });

f({ weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }).format(d); // Dienstag, 12. Jänner 2027
f({ weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric' }).format(d); // Di., 12.01.2027
f({ day: '2-digit', month: '2-digit', year: 'numeric' }).format(d); // 12.01.2027
f({ hour: '2-digit', minute: '2-digit' }).format(d); // 09:30
new Intl.NumberFormat('de-AT', { style: 'currency', currency: 'EUR' }).format(80); // € 80,00
new Intl.NumberFormat('de-AT', { style: 'unit', unit: 'minute', unitDisplay: 'long' }).format(30); // 30 Minuten
new Intl.RelativeTimeFormat('de-AT', { numeric: 'auto' }).format(1, 'day'); // morgen
new Intl.PluralRules('de-AT').select(1); // one: "1 Termin", other: "3 Termine"
new Intl.ListFormat('de-AT', { type: 'conjunction' }).format(['A', 'B', 'C']); // A, B und C
```

- "Uhr" and "bis" are words you put around the output of `Intl`: `${time} Uhr`, `${from} bis ${to} Uhr`. The practice range joins two times with an en dash.
- Three things are assembled by hand because `Intl` has no format for them: the SV-Nummer (four digits, a space, six digits), the age after a date of birth ("(68 Jahre)"), and phone numbers, which are shown as stored.
- January is "Jänner", and `de-AT` produces it. Write numerals for all numbers. For patients prefer "1 von 7" over percentages.
- The year is shown in confirmations, records and anything that is kept. A list of the coming days leaves it out.

### Email and SMS

- One message, one purpose, one action. Subject says what happened: "Ihr Termin ist bestätigt".
- Sender name is the practice. Parea signs off in the footer.
- White card on `--background`, logo or name of the practice, heading, two sentences, the facts, one button, then phone and "Termin verwalten".
- Plain text version always. No clinical detail. Buttons are real links that also appear as text.
- SMS: under 160 characters, practice name first, date and time, one short link.
