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

icd-11-search

v1.0.1

Published

Fast, fuzzy search for ICD-11 medical codes using Fuse.js. TypeScript-first with full type safety.

Readme

icd-11-search

A fast, developer-friendly ICD-11 search engine for healthcare applications.

icd-11-search provides a simple, reliable way to search and retrieve all 13,062 ICD-11 codes using fuzzy matching and type-safe APIs — without requiring direct integration with the WHO ICD API.


Why This Library Exists

Integrating ICD-11 into healthcare software is harder than it should be.

Developers face:

  • Complex hierarchical data
  • Slow or rate-limited external APIs
  • Poor search experience for clinicians
  • Inconsistent results when users misspell diagnoses

Clinicians, on the other hand, need:

  • Fast diagnosis lookup
  • Tolerance for spelling mistakes
  • Clear, accurate results
  • Minimal friction during patient care

This library exists to bridge that gap.

It improves developer experience with a zero-setup API, and improves clinical accuracy by making ICD-11 codes easy to find, even with imperfect input. Better search leads to better diagnosis capture, which supports reporting, monitoring, and public health decision-making.


What This Library Does

  • Loads the complete ICD-11 MMS dataset (26 chapters, 13,062 codes)
  • Builds an in-memory search index using Fuse.js
  • Exposes simple, predictable APIs for:
    • Fuzzy search
    • Code-based lookup
    • Chapter-based retrieval
  • Works offline, without external API calls

Key Features

| Feature | Description | |---------|-------------| | 🔍 Fuzzy Search | Typo-tolerant diagnosis search (e.g. diabtes → diabetes) | | 📦 Complete Dataset | All 26 chapters, 13,062 codes | | 🔒 TypeScript-First | Full type safety with exported interfaces | | ⚡ Zero Configuration | Install and use immediately | | 🌐 Runtime Agnostic | Works in Node.js, Bun, and modern bundlers |


Installation

npm install icd-11-search
yarn add icd-11-search
bun add icd-11-search

Quick Start

import { search, getByCode, getChapters } from 'icd-11-search';

// Fuzzy search (returns up to 8 results by default)
const results = search('diabetes');
console.log(results[0].item.title);
// → "Type 2 diabetes mellitus"

// Exact lookup
const code = getByCode('2A00');
console.log(code?.title);
// → "Primary neoplasms of brain"

// List chapters
console.log(getChapters().length);
// → 26

API Reference

Real-Time Autocomplete

autocomplete(query: string, limit?: number): ICD11Code[]

Best for real-time search as user types. Optimized for partial words (e.g., "dia" → "diabetes", "fea" → "fear"). Returns 8 results by default.

// As user types "dia"
const results = autocomplete('dia');
// → [{ code: '5A12', title: 'Malnutrition-related diabetes mellitus', ... }]

// As user types "fea"
const results = autocomplete('fea');
// → Results containing "fear", "febrile", etc.

// Get more results
const results = autocomplete('heart', 20);

Fuzzy Search

search(query: string, options?: SearchOptions): SearchResult[]

Searches ICD-11 titles and codes using fuzzy matching. Returns 8 results by default.

// Basic search
const results = search('diabetes');

// Get more results
const results = search('diabetes', { limit: 20 });

// With filtering
const results = search('diabetes', {
  threshold: 0.3,           // Stricter matching (0 = exact, 1 = loose)
  chapter: 'Endocrine, nutritional or metabolic diseases',
  kind: 'stem',             // Only stem codes (no extensions)
  limit: 10,
  includeMatches: true      // For highlighting
});

Options:

| Option | Type | Default | Description | |--------|------|---------|-------------| | limit | number | 8 | Maximum results to return | | threshold | number | 0.4 | Fuzzy threshold: 0.0 (exact) to 1.0 (loose) | | keys | ('title' \| 'code')[] | ['title', 'code'] | Fields to search | | chapter | string | — | Filter by chapter name | | kind | 'stem' \| 'extension' | — | Filter by code type | | includeMatches | boolean | false | Include match indices for highlighting |


Code-Based Search

searchByCode(code: string, limit?: number): ICD11Code[]

Returns codes starting with the given prefix.

const results = searchByCode('2A');
// All codes starting with "2A"

Title-Only Search

searchByTitle(title: string, options?: SearchOptions): SearchResult[]

Fuzzy search on titles only.

const results = searchByTitle('heart failure');

Chapter-Based Retrieval

getByChapter(chapter: string, limit?: number): ICD11Code[]

Get codes from a specific chapter.

const results = getByChapter('Neoplasms', 50);

All Codes

getAllCodes(limit?: number): ICD11Code[]

Get all codes with optional limit.

const codes = getAllCodes(100);

Direct Lookup

These methods return a single result (no limit).

Exact Code Match

const code = getByCode('2A00');
// → { code: '2A00', title: 'Primary neoplasms of brain', ... }

Entity ID Lookup

const code = getByEntityId('1630407678');
// → { code: '02', title: 'Neoplasms', ... }

List All Chapters

const chapters = getChapters();
// → [{ name: 'Neoplasms', codeCount: 833 }, ...]

Total Code Count

const total = getTotalCount();
// → 13062

TypeScript Types

All types are exported:

import type {
  ICD11Code,
  SearchOptions,
  SearchResult,
  ChapterInfo,
  FuseMatch
} from 'icd-11-search';

ICD11Code

interface ICD11Code {
  entityId: string;   // WHO entity ID
  code: string;       // ICD-11 code (e.g., "2A00")
  title: string;      // Human-readable title
  kind: 'stem' | 'extension' | 'non-codable';
  classKind?: 'chapter' | 'block' | 'window' | 'category';
  chapter: string;    // Parent chapter name
}

SearchResult

interface SearchResult {
  item: ICD11Code;
  score: number;         // 0 = perfect match, 1 = worst
  matches?: FuseMatch[]; // For highlighting
}

Example: Diagnosis Autocomplete

import { search } from 'icd-11-search';

function autocomplete(query: string) {
  if (query.length < 2) return [];
  
  return search(query, { limit: 10 }).map(r => ({
    code: r.item.code,
    title: r.item.title,
    chapter: r.item.chapter
  }));
}

// Usage
const suggestions = autocomplete('diab');
// → [{ code: '5A12', title: 'Malnutrition-related diabetes mellitus', ... }, ...]

ICD-11 Chapters

This module includes all 26 ICD-11 chapters:

| Chapter | Codes | |---------|-------| | Certain infectious or parasitic diseases | 703 | | Neoplasms | 833 | | Diseases of the blood or blood-forming organs | 177 | | Diseases of the immune system | 172 | | Endocrine, nutritional or metabolic diseases | 425 | | Mental, behavioural or neurodevelopmental disorders | 659 | | Sleep-wake disorders | 59 | | Diseases of the nervous system | 563 | | Diseases of the visual system | 487 | | Diseases of the ear or mastoid process | 104 | | Diseases of the circulatory system | 397 | | Diseases of the respiratory system | 246 | | Diseases of the digestive system | 668 | | Diseases of the skin | 538 | | Diseases of the musculoskeletal system or connective tissue | 303 | | Diseases of the genitourinary system | 392 | | Conditions related to sexual health | 48 | | Pregnancy, childbirth or the puerperium | 400 | | Certain conditions originating in the perinatal period | 447 | | Developmental anomalies | 892 | | Symptoms, signs or clinical findings, not elsewhere classified | 940 | | Injury, poisoning or certain other consequences of external causes | 1395 | | External causes of morbidity or mortality | 691 | | Factors influencing health status or contact with health services | 625 | | Codes for special purposes | 21 | | Supplementary Chapter Traditional Medicine Conditions | 877 |


How It Works

  1. Preprocessed Dataset: All ICD-11 codes are bundled at build time
  2. Fuse.js Index: Lazy-initialized fuzzy search index
  3. In-Memory: No network calls, predictable performance

Data Source

ICD-11 MMS dataset sourced from the WHO ICD API (2025-01 release).


Who Should Use This

  • Developers building EMRs / HMIS
  • Health-tech startups
  • Clinical decision support tools
  • Reporting and surveillance systems
  • Public health analytics platforms

License

MIT © 2026


Contributing

Contributions are welcome. Open an issue or submit a pull request.