Parent Epic
Part of #16 — [Epic] Databricks EHR Writeback — Delta Outbox + Canonical Prediction Model
Summary
Define the canonical ClinicalPrediction domain model and the Delta outbox table that stores it with processing semantics.
Tasks
Define ClinicalPrediction Pydantic model with fields: prediction_id, patient_id, encounter_id, prediction_code, values[] (label, value, unit), effective_datetime, model_id, model_version, metadata
Define PredictionValue Pydantic model for the values array (supports scalar and vector)
Define Delta outbox table schema — adds processing columns: status (pending/processing/completed/failed/dead_letter), locked_by, locked_at, retry_count, last_error, created_at, updated_at
Implement lease-based MERGE semantics: claim (pending → processing with lock), release (processing → completed/failed), expire stale locks
New module: src/ehr_writeback/outbox/ with models.py, outbox_store.py
Unit tests for model validation and outbox CRUD operations
Acceptance Criteria
Parent Epic
Part of #16 — [Epic] Databricks EHR Writeback — Delta Outbox + Canonical Prediction Model
Summary
Define the canonical
ClinicalPredictiondomain model and the Delta outbox table that stores it with processing semantics.Tasks
ClinicalPredictionPydantic model with fields:prediction_id,patient_id,encounter_id,prediction_code,values[](label, value, unit),effective_datetime,model_id,model_version,metadataPredictionValuePydantic model for the values array (supports scalar and vector)status(pending/processing/completed/failed/dead_letter),locked_by,locked_at,retry_count,last_error,created_at,updated_atsrc/ehr_writeback/outbox/withmodels.py,outbox_store.pyAcceptance Criteria
ClinicalPredictionmodel validates scalar (single value) and vector (multi-value) predictions