Import Lab Req Form
Imports Lab Req Forms into the DNA Insights admin dashboard, one PDF at a time, from explicit paths supplied by the user.
Invocation
import-lab-recform <path1.pdf> [<path2.pdf> ...]
- At least one PDF path is required.
- Paths may be absolute or relative (resolve relative paths against the current working directory).
Output Language
All user-facing output of this skill is in English — regardless of the chat/conversation language. This includes: queue reports, every step report, confirmation-gate prompts, result lines, the final report, and the generated HTML report. Do not localize these.
Workflow Overview
Phase 0: Validate supplied paths + ask for Dashboard URL + detect type from PDF content
↓
For each PDF, in the order supplied:
Setup: create `<recform-slug>/screenshots/` in the primary working dir NOW
(slug from the ReqForm Description) so every step's screenshot is written
straight into it — see `references/reporting.md`. No images outside the folder.
↓
Pre-check: Does Medical Specialty exist?
↓ No → Workflow 01: Create Medical Specialty
↓ Yes → skip
Workflow 02: Create Req Form (no Sync CSV yet)
↓
Workflow 03: Flatten PDF via Ghostscript → Upload to dashboard
↓
Workflow 04: Create Form.io order services form (full-read PDF via Claude
Read tool → classify fields + business rules → confirm field list → build JSON → paste into
builder → user checks → Save → open → verify panel→parameters wiring via
verify-formio-panel-params → screenshot Preview Form → link
schema URL into ReqForm metadata → export req-form mapping CSV via
convert-order-service-json-to-csv → Sync CSV on the ReqForm)
↓
Workflow 05 — import-key-to-pdf: Fill AnnotsJSON in medicalpdf admin
(fetch current AnnotsJSON from dashboard → read full PDF → build ICD10 panel
mapping → apply via icd10-panel-fill → paste updated JSON back → Save)
↓
Workflow 06: Final confirm + build per-recform HTML report
(screenshots per step → <recform-slug>/report-<slug>.html)
↓
🔒 CONFIRM GATE: report this recform's result, then ASK the user to
confirm before continuing. Only move to the next requested recform
AFTER the user confirms.
↓
Next PDF → repeat until queue empty
Per recform: capture a screenshot at each step and produce one self-contained
<recform-slug>/folder (withscreenshots/+report-<recform-slug>.html) — finish it before the next PDF. Seereferences/reporting.md.Screenshots go straight into the folder. Create
<recform-slug>/screenshots/first, thenbrowser_take_screenshot(filename="<recform-slug>/screenshots/<NN>-<step>.png"). Never leave report images in the project root or.playwright-mcp/.
Reference Files
Load these as needed:
references/playwright-mcp-setup.md— Browser automation via Playwright MCP (login + tool mapping)references/content-detection-rules.md— Detect Test Type + Lab from PDF contentreferences/abbreviation-map.md— Form Title → Short Code + Lab normalizationreferences/metadata-template.json— Metadata JSON for Medical Specialtyreferences/order-services-formio-template.json— Annotated Form.io schema skeleton for Workflow 04references/field-taxonomy.md— Workflow 04: classify reqform fields (EMR-prepopulated / provider-input / fixed), business rules, the 3 fixed fields, ICD-10 routing mapreferences/reporting.md— Per-recform folder, screenshots, and HTML reportreferences/error-handling.md— Error cases and responsesscripts/detect-recform-type.py— Helper that extracts title + lab hints from a PDFscripts/build-report.py— Builds the self-contained per-recform HTML report~/.claude/skills/convert-order-service-json-to-csv/scripts/convert.py— Converts the saved Form.io schema JSON to the DNAi req-form mapping CSV (called at end of W04)verify-formio-panel-paramsskill — Verifies the Form.io Test Panel → Test Parameters → aggregator copy wiring (static key/mapping check + live Preview submission check); called from W04 step 8a after Saveextract-recform-icd10-panelsskill — Turns the requisition PDF into the panel → ICD-10 JSON (relevant_diagnosis_condition: PRIMARY required / SECONDARY optional / CROSS-PANEL per panel). Run it BEFORE W05 and feed its JSON toicd10-panel-fillinstead of hand-typing the mapping. Requisition PDFs are flattened (no text layer), so it renders at 300 DPI and reads the strips — do not read codes off a page-scale render.verify-recform-icd10-importskill — Runs AFTER W05: diffs the saved AnnotsJSON against that panel/ICD JSON and reports unfilled entries, codes the form prints but nobody imported, codes under the wrong panel, extras and count mismatches. Treat a non-zero exit as a W05 failure and fix the mapping before the confirmation gate.
Browser Automation
All browser steps (navigate / click / type / upload / read URL) run through the
Playwright MCP server (playwright). See references/playwright-mcp-setup.md
for the config, the one-time login, and the tool mapping. Use a single
persistent browser context for the whole run. Take a browser_take_screenshot
at each step for the report (see references/reporting.md).
Workflow Files
Follow each in order per PDF:
workflows/01-create-specialty.md— Section 0: Create Medical Specialtyworkflows/02-create-reqform.md— Section 1: Create Req Formworkflows/03-flatten-upload.md— Section 2: Flatten PDF + Uploadworkflows/04-create-order-services-form.md— Section 4: Create Form.io order services formworkflows/05-import-key-to-pdf.md— Section 5: Fill AnnotsJSON in medicalpdf adminworkflows/06-final-confirm-and-report.md— Section 6: Final confirm + per-recform HTML report
Phase 0 — Validate Inputs
Check arguments were supplied.
- If no PDF path was given → report
❌ No PDF path supplied. Usage: import-lab-recform <path1.pdf> [<path2.pdf> ...]and STOP.
- If no PDF path was given → report
Validate EVERY supplied path before processing any of them. For each path, check that:
- the file exists, AND
- it ends with
.pdf(case-insensitive). - If any path is missing or not a PDF → report each invalid path like
❌ Invalid path: <path> (not found / not a PDF)and STOP. Do not process a partial queue.
Ask the user for the Dashboard base URL (used in all workflows):
What is the dashboard base URL to use? (e.g. https://dev-dashboard.dnainsights.ai)- Store the answer as
<DASHBOARD_URL>and substitute it everywhere the workflows reference<DASHBOARD_URL>. Strip any trailing/. - Also derive the environment tag
<ENV>from the URL (used in Workflow 04): host containsdev/staging→[DEV], otherwise →[PROD]. - Wait for the answer before continuing.
- Store the answer as
Ensure the browser is ready (Playwright MCP). Follow the first-run login in
references/playwright-mcp-setup.md: confirm theplaywrightMCP is available, then make sure both<DASHBOARD_URL>/admin/andhttps://docs.google.comare logged in (ask the user to log in once in the opened window if needed). The persistent profile keeps the session for later.Load
references/content-detection-rules.md, then for each PDF detect its Test Type + Lab by reading the PDF content (runscripts/detect-recform-type.pyand map the result viareferences/abbreviation-map.md). Do NOT rely on the filename.Report the full queue with detected values (Test Type, Lab, Short Code, derived names) and the chosen
<DASHBOARD_URL>before starting. This is the processing queue, in the order supplied. If any detection is uncertain, show it and ask the user to confirm/correct before proceeding.
Per-Recform Confirmation Gate
After completing all workflows for one PDF (including Workflow 05, which builds
the <recform-slug>/ folder + HTML report):
- Report that recform's result line (see Final Report Format) and the path to
<recform-slug>/report-<recform-slug>.html. - Ask the user:
✅ Done with <filename>.pdf. Continue to the next recform? (yes / stop) - Only proceed to the next PDF AFTER the user confirms. If the user says stop → end the run and print the final report for what was processed so far.
Final Report Format
After all PDFs processed (or the user stops):
✅ Immunodeficiency Panel - Amedix Inc.pdf → S0 skipped | S1 ✅ | Sync ✅ | S2 ✅ | S3 ✅
✅ CGX rec_Amedix.pdf → S0 ✅ (CGX-2026 created) | S1 ✅ | Sync ✅ | S2 ✅ | S3 ✅
❌ SomePDF.pdf → Failed at S1 (reason: ...)
Total: X success, Y failed
(S3 = Workflow 04 order services form. Mark S3 ⏸ if the user deferred the
form review without saving.)