feat: add Common Lab Codes for India (CLCI · LOINC) - #1
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 layerscripts/lib/loinc.ts: CSV parsing + best-effort, validated FSN decomposition (Component:Property:Time:System:Scale:Method)scripts/build-labs.ts: emitspublic/data/labs/{tests,manifest}.json; the drug build's cleanup is scoped so the two builds coexistbuild:datanow chains drugs → labs;test:labsaddedLabs 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<head>metadata; off-palette substance badge tokenizedThe "split": e.g.
ACnc→"Arbitrary concentration",Ser→"Serum",Qn→"Quantitative". Discipline categories (Chemistry, Hematology, Microbiology, Molecular, …) are derived by a transparent heuristic with a reviewabledata/source/clci/categories.jsonoverride 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-systemcollapsing, immunoglobulin word-boundary matching, category derivation, CSV edge cases.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-pressedon chips, mobile-collapsible facet rail, immunology regex word-boundaries (dropped exactly 1 false positive, 485→484), specimen^super-systemstripping (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,
/labssearch + facet filtering, parsed + unparsed detail, deep-links, mobile collapse) — zero console errors. Token-only styling consistent with the existing teal palette.Verification
npm run typecheckcleannpm run build(drug + lab data builds + static export) succeeds — all 7 routes export staticallynpm run test:labs— 12/12 passTest plan
🤖 Generated with Claude Code