Pharmacy sig management platform: permutation engine, time-travel action log, structured review queue, and AI clinical validation.
A pharmacy owner and his team were spending several hours every week manually reviewing sigs in spreadsheets with no standardization, no audit trail, and nothing to catch clinical errors before sigs entered production use. The same instruction existed under dozens of slightly different names with no way to see they were duplicates.
Next.js App Router + tRPC (end-to-end typed API) + Prisma + PostgreSQL
Manual review queue: parsed/approved/skipped tabs, reviewer claim-locking (prevents two people editing the same sig simultaneously), timed undo drawer that reverses actions server-side
Action log: every field change, approval, skip, and return writes an Action record with a full diffwho changed what, from what value, to what value, and when. Viewable inline per sig and on a dedicated history page
Permutation engine: a canonical hash is computed from each sig's structured field values (not its name). Sigs that share a hash are grouped into a Permutationthe deduplicated canonical form. Makes 'how many ways are we writing this instruction?' a searchable dashboard instead of an unanswerable question
Upstream Vite/React preprocessing tool for Epic EHR CSV exportsparses free-text ENTERED_SIG fields against clinical dictionaries (frequency codes, route codes, dose units), assigns a confidence score per mapping, surfaces low-confidence cases for manual correction before they enter the review queue
Multi-step sig support: tapering dose schedules modeled as ordered stages; field values across steps stored as pipe-delimited strings (e.g. 'Once Daily|Twice Daily'); reviewers confirm which fields were inferred vs explicitly stated before approval
AI validation layer (BAML typed LLM function signatures): ValidateSigBatch for batch post-approval safety checks, AnalyzeUnapprovedSig for pre-approval deep analysis, conversational Q&A on validation results with real-time streaming
Role system: Admin / Normal / Junior / Onboardingnew users land on a waiting page until approved by an admin. NextAuth + OTP passwordless auth, Playwright E2E tests, Sentry error monitoring, GitHub Actions daily DB backups
Parsing messy free-text EHR sigs ('0.1 mg q6h PRN HTN' and '0.1 mg every 6 hours if needed for high blood pressure' mean the same thing) into normalized structured fields without losing clinical intent
Modeling multi-step sigs where each stage has independent field valuesand preserving the full sequence in a single DB record without losing per-step granularity
Designing the permutation hash so it captures semantic equivalence across different surface representations, not just exact string matches
Building claim-locking that handles concurrent reviewers without deadlocks or a reviewer silently overwriting another's work
Integrating AI validation as a safety net that flags issues without blocking the pharmacist's workflow or creating alert fatigue
Replaced hours of weekly manual sig review with a structured, audited queue. Pharmacists work claims, not spreadsheets
Every action in the system is logged with a field-level diff: any change can be traced back to who made it, when, and what it replaced. Full time-travel audit trail
Permutation engine automatically surfaces sig duplicates. A searchable view of every canonical instruction and all its variant names
Upstream preprocessing handles new healthcare facility data automatically: new sigs are discovered, parsed, and pushed to the review queue without manual data entry
AI validation catches critical/warning/info-level clinical issues before sigs are used in production, with conversational follow-up for pharmacist review



