Dtypes Findings Migration (Incremental, Endoreg-Safe)¶
Last updated: 2026-03-09 Owner: reporting/backend
Scope¶
Migrate findings read/write flows to a dtypes-driven API surface under /base_api/** without breaking existing /api/** endoreg_db behavior.
Current-State Inventory¶
Uses dtypes today¶
/base_api/examinations/{examination_id}/findings/read path useslx_dtypesloader with module defaultlx_knowledge_base./base_api/findings/{finding_id}/classifications/read path uses dtypes lookup constraints./base_api/classifications/{classification_id}/choices/read path available./base_api/patient-findings/**write/read API includes dtypes validation (finding allowed for exam, classification/choice consistency).Frontend
findingsApisupports backend mode flagVITE_FINDINGS_BACKEND(endoreg,dtypes_read,dtypes).
Uses endoreg_db today¶
/api/**remains production default and unchanged.Patient finding persistence is still on endoreg_db tables (
PatientFinding,PatientFindingClassification) for/base_api/patient-findings/**.Default frontend mode is
VITE_FINDINGS_BACKEND=endoreg.Report save flows still submit to
/api/patient-examination-reports/save-submission/.
Phased Checklist¶
Phase 0: Stabilize current findings flow (no behavior break)¶
[x] Remove duplicate findings reactive reload triggers in
FindingsDetailandAddableFindingsDetail.[x] Normalize findings network calls through a single service layer (
findingsApi) for edited components/stores.[x] Keep endoreg-safe create contract: create finding first, then dedicated classifications update route.
[x] Add structured error parsing (
required-finding,duplicate-finding,invalid-choice,invalid-finding).Acceptance criteria:
No repeated watcher-trigger loops for single finding render.
400 errors surface actionable code/message.
Phase 1: Frontend findings API abstraction¶
[x] Add
frontend/src/api/findingsApi.ts+.js.[x] Add
VITE_FINDINGS_BACKENDenv typing.[x] Route
patientFindingStoreandexaminationStorethroughfindingsApi.[x] Route findings reads in
AddableFindingsDetail,FindingsDetail,Report.vue,ReportEditorPage.vuethroughfindingsApi.Acceptance criteria:
Component/store layer remains camelCase-compatible.
Backend switching does not require component-level endpoint changes.
Phase 2: dtypes read endpoints (parallel, non-breaking)¶
[x]
GET /base_api/examinations/{examination_id}/findings/[x]
GET /base_api/findings/{finding_id}/classifications/[x]
GET /base_api/classifications/{classification_id}/choices/[x] Compatibility-oriented payload shape preserved (
id,name,required,choices, legacy fields where needed).Acceptance criteria:
Frontend can run in
dtypes_readmode without/apifindings reads.
Phase 3: dtypes write endpoints (endoreg-safe persistence)¶
[x]
GET /base_api/patient-findings/?patient_examination=...[x]
POST /base_api/patient-findings/[x]
PATCH /base_api/patient-findings/{id}/[x]
DELETE /base_api/patient-findings/{id}/[x]
POST /base_api/patient-findings/{id}/classifications/[x] Validation rules enforced before persistence.
[x] Persistence remains endoreg_db tables for compatibility.
Acceptance criteria:
/api/**remains fully operational with no contract regression.
Phase 4: Cutover governance¶
[x] Track migration in this document.
[ ] Parity test suite green in CI for all findings endpoints/modes.
[ ] Soak window complete (no regressions in configured period).
[ ] Flip default
VITE_FINDINGS_BACKENDfromendoregto agreed dtypes mode.
Compatibility Matrix¶
Endpoint / Area |
Read/Write Source |
Persistence |
Rollout Status |
|---|---|---|---|
|
endoreg_db |
endoreg_db |
Stable (default path) |
|
endoreg_db |
endoreg_db |
Stable (default path) |
|
endoreg_db |
endoreg_db |
Stable (default path) |
|
dtypes KB |
n/a |
Implemented |
|
dtypes KB + db mapping |
n/a |
Implemented |
|
dtypes KB + db mapping |
n/a |
Implemented |
|
dtypes-validated API |
endoreg_db tables |
Implemented |
Frontend findings integration |
|
n/a |
Implemented (default |
Decision Log¶
Date |
Decision |
Rationale |
Owner |
|---|---|---|---|
2026-03-09 |
Keep |
Avoid production regressions during migration. |
reporting/backend |
2026-03-09 |
Use |
Enables incremental rollout and targeted testing. |
frontend |
2026-03-09 |
Validate with dtypes but persist patient findings in existing endoreg tables for now. |
Reduces schema/data migration risk while gaining validation parity. |
backend |
2026-03-09 |
Keep explicit create-then-classification flow for endoreg-safe mode. |
Matches existing behavior and prevents nested-write ambiguity. |
frontend/backend |
2026-03-09 |
Pin pytest CI settings to a deterministic findings module ( |
Avoids environment-dependent |
backend |
Progress Log¶
Date |
Reference |
Status |
Notes |
|---|---|---|---|
2026-03-09 |
Working tree changes in |
Completed |
Added |
2026-03-09 |
Working tree changes in |
Completed |
Fixed pytest execution path for backend contract tests; |
2026-03-09 |
Working tree changes in |
Completed |
Added unified service layer and backend mode switch. |
2026-03-09 |
Working tree changes in findings components/stores/reporting views |
Completed |
Removed duplicate reload triggers and migrated key calls to |
2026-03-09 |
Frontend validation ( |
Completed |
Type-check and targeted migration tests pass locally. |
Cutover Gate¶
Default can move from endoreg only when all are true:
Contract tests pass for
/base_apiread/write findings endpoints.Frontend mode tests pass for
endoreg,dtypes_read, anddtypes.End-to-end create/update/delete/classification flows pass in staging.
No agreed regression during soak period.