Skip to content

feat: add Common Lab Codes for India (CLCI · LOINC) - #1

Merged
bodhish merged 3 commits into
mainfrom
feat/clci-lab-codes
Jun 29, 2026
Merged

feat: add Common Lab Codes for India (CLCI · LOINC)#1
bodhish merged 3 commits into
mainfrom
feat/clci-lab-codes

Conversation

@bodhish

@bodhish bodhish commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Adds Common Lab Codes for India (CLCI) — a curated subset of LOINC v2.82 (1,473 lab tests) published by NRCeS/C-DAC — as a second terminology alongside the existing drug codes. The site becomes a two-section "Clinical Codes Browser" hub: Drugs (CDCI · SNOMED, unchanged) and Lab tests (CLCI · LOINC, new).

Labs data pipeline & module (self-contained, keyed on LOINC code — a separate identity space from SNOMED, so no drug code paths change)

  • src/lib/labs/*: types, a curated LOINC plain-English glossary, discipline-category derivation, and an in-memory client data layer
  • scripts/lib/loinc.ts: CSV parsing + best-effort, validated FSN decomposition (Component:Property:Time:System:Scale:Method)
  • scripts/build-labs.ts: emits public/data/labs/{tests,manifest}.json; the drug build's cleanup is scoped so the two builds coexist
  • build:data now chains drugs → labs; test:labs added

Labs UI

  • /labs: instant in-memory search + facet rails (Discipline, Scale, Specimen) with counts, mobile-collapsible, aria-pressed, deep-linkable (?q=/?category=/?specimen=)
  • /lab: decodes a test's cryptic LOINC FSN into six plain-English axes, with the Long Common Name as authoritative and a graceful raw-FSN fallback for the ~22 rows that don't cleanly parse; LOINC code / FHIR Coding copy; related-by-specimen
  • Home reworked into the two-section hub; nav, footer LOINC attribution, <head> metadata; off-palette substance badge tokenized

The "split": e.g. ACnc→"Arbitrary concentration", Ser→"Serum", Qn→"Quantitative". Discipline categories (Chemistry, Hematology, Microbiology, Molecular, …) are derived by a transparent heuristic with a reviewable data/source/clci/categories.json override file. CARE lab export is deferred to v2.

Test Coverage

  • scripts/lib/loinc.test.ts — 12 checks over the pure parse/validate/derive helpers: FSN with/without method, no-colon rows, drifted-split rejection, scale whitelist, specimen/scale facet derivation, ^super-system collapsing, immunoglobulin word-boundary matching, category derivation, CSV edge cases.
  • Build asserts all 1,473 rows parse (1,451 clean split, 22 graceful fallback) with 0 dropped.

Pre-Landing Review

A multi-agent adversarial review (3 dimensions → per-finding verification) confirmed 10 of 12 findings; all 10 were fixed and re-verified: deep-link facet resync, aria-pressed on chips, mobile-collapsible facet rail, immunology regex word-boundaries (dropped exactly 1 false positive, 485→484), specimen ^super-system stripping (63→61 clean labels), component-axis gloss, specimen "See all" drill-down, dead import, off-palette badge token, build-cleanup scoping.

Design Review

Live-dogfooded every flow (home, /labs search + facet filtering, parsed + unparsed detail, deep-links, mobile collapse) — zero console errors. Token-only styling consistent with the existing teal palette.

Verification

  • npm run typecheck clean
  • npm run build (drug + lab data builds + static export) succeeds — all 7 routes export statically
  • npm run test:labs — 12/12 pass

Test plan

  • Unit tests pass (12 checks)
  • Typecheck clean
  • Full static build succeeds; drug + lab artifacts coexist
  • Manual dogfooding of all labs flows, zero console errors

🤖 Generated with Claude Code

bodhish and others added 3 commits June 29, 2026 15:24
Add the Common Lab Codes for India (CLCI), a curated subset of LOINC v2.82
(1,473 tests), as a self-contained module keyed on LOINC code:
- src/lib/labs: types, curated LOINC glossary, discipline categories, client data layer
- scripts/lib/loinc.ts: CSV parse + best-effort/validated FSN decomposition (+ tests)
- scripts/build-labs.ts: emits public/data/labs/{tests,manifest}.json
- scope the drug build's cleanup so the two builds coexist under public/data
- package.json: build:data chains drugs then labs; add test:labs; bump 0.1.0 -> 0.2.0

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- /labs: instant in-memory search + specimen/scale/discipline facets (mobile-collapsible,
  aria-pressed, deep-linkable via ?q=/?category=/?specimen=)
- /lab: decodes a test's LOINC FSN into six plain-English axes, graceful raw-FSN
  fallback for unparsed codes, LOINC code / FHIR Coding copy, related-by-specimen
- rework home into a two-section "Clinical Codes Browser" hub (Drugs + Labs); nav,
  footer LOINC attribution, head metadata; tokenize the off-palette substance badge

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- README: describe the two-section hub, labs data model, build wiring
- NOTICE / DATA_LICENSE.md: add LOINC (c) Regenstrief attribution + non-endorsement
- docs/superpowers/specs: CLCI design spec

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bodhish
bodhish merged commit c6c800b into main Jun 29, 2026
1 check passed
@bodhish
bodhish deleted the feat/clci-lab-codes branch June 29, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant