npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@peerbits/medical-terminology

v0.2.0

Published

Terminology system-URI registry and code format/checksum validation utilities — ships zero licensed terminology datasets (see docs/LICENSING.md)

Readme

@peerbits/medical-terminology

Version 0.2 adds batch validation, canonical code-system URI resolution, and an optional strict mode that treats unknown systems as errors. The default remains backward compatible and reports unknown systems as warnings.

Terminology system-URI registry and code format/checksum validation utilities — ships zero licensed terminology datasets (see Licensing)

Category: Medical Coding — Terminology & Code-Handling Utilities · License: Apache-2.0 · Status: Stable

CI License npm version


1. What problem does this solve?

Healthcare applications regularly handle coded concepts across disparate medical terminology systems—LOINC, SNOMED CT, ICD-10-CM, RxNorm, CPT, and UCUM. Validating these concepts in ingestion pipelines typically forces teams to either deploy heavy terminology servers (like Ontoserver or UMLS TS) or omit validation entirely, allowing malformed identifiers and invalid URIs to corrupt downstream FHIR records.

@peerbits/medical-terminology provides a zero-dependency, in-memory validation engine that standardizes canonical system URIs and validates code syntax, pattern structures, and Verhoeff check-digits client-side, with an optional pluggable provider architecture for teams that connect real terminology services.

⚠️ Licensing Note: This repository ships canonical code-system URI metadata and structural format/checksum validators only. It does not include or distribute any proprietary CPT, SNOMED CT, or RxNorm concept datasets. See docs/LICENSING.md for full compliance details.


2. Features

  • Canonical System URI Registry: Standardized URIs, OIDs, and short-names for 6 major medical coding systems:
    • LOINC (http://loinc.org)
    • SNOMED CT (http://snomed.info/sct)
    • ICD-10-CM (http://hl7.org/fhir/sid/icd-10-cm)
    • RxNorm (http://www.nlm.nih.gov/research/umls/rxnorm)
    • CPT (http://www.ama-assn.org/go/cpt)
    • UCUM (http://unitsofmeasure.org)
  • Fast Structural & Checksum Validation:
    • Full Verhoeff check-digit calculation and validation for SNOMED SCTIDs.
    • RegEx & structural format validation for LOINC, ICD-10-CM, CPT (5-digit syntax), RxNorm (RxCUI numeric format), and UCUM syntax.
  • Pluggable Provider Architecture: Register runtime lookup hooks (e.g., UMLS REST API, local Terminology Server) to augment structural checks with real-time concept validation.
  • Zero Runtime Dependencies: Pure TypeScript with zero external network or database requirements.

3. Installation

npm install @peerbits/medical-terminology

4. Demo and Quick Start

Peerbits HealthTech - Medical Terminology Demo

import { canonicalizeSystemIdentifier, validate, validateMany } from "@peerbits/medical-terminology";

// 1. Validate a LOINC observation code
const loincResult = validate({
  system: "http://loinc.org",
  code: "8867-4",
});
console.log(loincResult.valid); // true

// 2. Validate SNOMED CT Concept ID with Verhoeff check-digit
const snomedResult = validate({
  system: "http://snomed.info/sct",
  code: "73211009", // Diabetes mellitus
});
console.log(snomedResult.valid); // true

// 3. Catch invalid formats early
const invalidResult = validate({
  system: "http://hl7.org/fhir/sid/icd-10-cm",
  code: "INVALID_CODE",
});
console.log(invalidResult.valid); // false
console.log(invalidResult.issues);
// [ { severity: "error", path: "code", code: "invalid-format", message: "..." } ]

// Validate batches and reject unknown code systems when required
const batch = validateMany([
  { system: "LOINC", code: "8867-4" },
  { system: "UCUM", code: "mm[Hg]" },
], { unknownSystem: "error" });

// Resolve aliases and OIDs to the canonical URI
const canonicalUri = canonicalizeSystemIdentifier("LOINC");
// http://loinc.org

5. Pluggable Terminology Providers

You can register custom terminology lookup providers to resolve live concepts while falling back gracefully if offline:

import { registerProvider, validateWithProvider } from "@peerbits/medical-terminology";

// Register an in-house or external terminology resolver
registerProvider("loinc", async (code) => {
  const isFound = await checkLocalDatabase(code);
  return { found: isFound, display: isFound ? "Heart rate" : undefined };
});

// Validate format AND verify existence through the provider
const result = await validateWithProvider({
  system: "http://loinc.org",
  code: "8867-4",
});

console.log(result.valid); // true

6. Architecture

src/
├── index.ts              # Package entry point and exports
├── registry.ts           # Canonical URIs, OIDs, and system metadata
├── provider.ts           # Pluggable terminology provider interface
├── types.ts              # TypeScript declarations and error shapes
├── validate.ts           # Unified validation engine
└── validators/
    ├── cpt.ts            # CPT 5-digit format check (Zero dataset content)
    ├── icd10cm.ts        # ICD-10-CM alphanumeric structural check
    ├── loinc.ts          # LOINC hyphenated identifier check
    ├── rxnorm.ts         # RxNorm RxCUI numeric format check
    ├── snomed.ts         # SNOMED CT Verhoeff check-digit algorithm
    └── ucum.ts           # UCUM unit syntax validator

7. Contributing

See CONTRIBUTING.md.


8. License

Apache License 2.0 — see LICENSE.


9. About PeerbitsSolution

@peerbits/medical-terminology is part of the PeerbitsSolution HealthTech Open Source initiative—reusable engineering components extracted from our healthcare technology work. This repository contains generalized, reusable logic only; it is not tied to any specific client engagement or commercial product.