mirror of
https://github.com/temetro/temetro.git
synced 2026-08-25 18:07:44 +00:00
feat: edit parsed records before importing
The import preview only showed counts + skipped-row errors with no way to fix anything. Now every parsed record is editable before import: - backend: shared validatePatientImport() (used by the previewImport tool) + POST /api/ai/import/validate for dry-run re-validation; the import preview payload now carries the original records (and the source record on each invalid row) so the UI can edit them. - frontend: the import card gets a "Review & edit" dialog listing every record with a ready / needs-fixing badge; opening one reuses the full PatientFormDialog in a new non-persisting review mode (editable file number) and re-validates on save, so skipped rows can be fixed and included. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
saveAiConfig,
|
||||
toAiConfig,
|
||||
} from "../services/ai/config.js";
|
||||
import { validatePatientImport } from "../services/ai/import.js";
|
||||
import { getPolicy, savePolicy } from "../services/ai/policy.js";
|
||||
import * as patients from "../services/patients.js";
|
||||
|
||||
@@ -189,3 +190,27 @@ aiRouter.post(
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// --- Migration import re-validation (dry run) -------------------------------
|
||||
// Powers the "review & edit before import" UI: the client edits parsed records
|
||||
// and calls this to refresh which are ready vs. need fixing. Writes nothing.
|
||||
aiRouter.post(
|
||||
"/import/validate",
|
||||
requireAuth,
|
||||
requireOrg,
|
||||
requirePermission({ patient: ["write"] }),
|
||||
async (req, res, next) => {
|
||||
try {
|
||||
const records = (req.body as { records?: unknown[] }).records;
|
||||
if (!Array.isArray(records)) {
|
||||
throw new HttpError(400, "records must be an array.");
|
||||
}
|
||||
if (records.length > 500) {
|
||||
throw new HttpError(400, "Too many records (max 500).");
|
||||
}
|
||||
res.json(validatePatientImport(records));
|
||||
} catch (err) {
|
||||
next(err);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user