# Baltique OS 0.78.0 — Enterprise Integration Architecture

## Decyzja architektoniczna

Baltique OS 0.78.0 jest release integracyjnym. Nie dodaje kolejnej równoległej zakładki dla każdego problemu. Stabilizuje wspólne domeny, dane i reguły.

## Kanoniczne domeny

| Domena | Źródło prawdy | Moduły powiązane |
|---|---|---|
| Patient Case | baza danych | Pacjenci, ClinicFlow, CarePath |
| Operative Case | baza danych | Operative Path, GO/HOLD/NO-GO, OR Readiness |
| OR Day Plan | baza danych | TheatreFlow v2, OR Live, Digital Twin, Safe Auto-Apply |
| Staff Work | baza danych/eventy | OR Staff Automation, OR Staff Mobile, Push |
| Communication Thread | baza danych | Communication Hub, Parser e-mail/SMS, Portal |
| Document Instance | baza danych | Content Blocks, Rules Matrix, Document Assembly |
| Consent Evidence | baza danych | Consent Center, Consent Vault, Signed Archive |
| Inventory / Implants | baza danych | Magazyn, Implant Registry, Implant Passport |
| Governance | baza danych | Clinical Governance, Module Registry, Migration Ledger |

## Zasady 0.78.0

1. Runtime nie powinien tworzyć nowych schematów biznesowych poza wąską kompatybilnością. Docelowe zmiany schematu idą przez migracje i ledger.
2. Każdy moduł ma być opisany w Module Registry.
3. Moduły legacy pozostają dostępne wyłącznie jako kompatybilność i muszą mieć wskazany moduł zastępujący.
4. Digital Twin jest silnikiem optymalizacji dnia operacyjnego, nie wizualizacją.
5. Safe Auto-Apply nie działa w trybie pełnej automatyki bez preflightu, audytu i możliwości rollbacku.
6. Podpisany dokument jest snapshotem rekordu w bazie, a PDF jest eksportem.

## Naprawione rozjazdy

### Digital Twin

0.75 i 0.77 używały różnych nazw kolumn. 0.78.0 zapewnia kompatybilność przez utrzymywanie par:

- `simulation_date` / `scenario_date`
- `scenario_key` / `scenario_code`
- `delay_minutes` / `predicted_delay_minutes`
- `impact_json` / `expected_impact_json`

### OR Readiness

Indeks `readiness_date + operative_case_id + booking_id` nie zatrzymywał duplikatów przy `booking_id = NULL`. 0.78.0 dodaje `readiness_source_key`, usuwa starsze duplikaty i wymusza unikalność dnia po źródle.

### OR Mobile Push

0.78.0 obsługuje jednocześnie:

- model bezpieczny: `endpoint_hash`, `subscription_json`, `permission_status`;
- model runtime: `endpoint`, `p256dh`, `auth_secret`, `user_agent`.

### Signed Documents

0.78.0 normalizuje snapshot dokumentu:

- `snapshot_html`, `snapshot_sha256` jako model kanoniczny;
- `final_html`, `content_sha256` jako aliasy kompatybilności;
- `immutable_record = 1`;
- blokada dokumentu źródłowego w `operative_case_documents`.
