@peerbits/medical-terminology 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +105 -0
- package/README.md +137 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity.
|
|
18
|
+
|
|
19
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
20
|
+
exercising permissions granted by this License.
|
|
21
|
+
|
|
22
|
+
"Source" form shall mean the preferred form for making modifications.
|
|
23
|
+
|
|
24
|
+
"Object" form shall mean any form resulting from mechanical
|
|
25
|
+
transformation or translation of a Source form.
|
|
26
|
+
|
|
27
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
28
|
+
Object form, made available under the License, as indicated by a
|
|
29
|
+
copyright notice that is included in or attached to the work.
|
|
30
|
+
|
|
31
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
32
|
+
form, that is based on (or derived from) the Work.
|
|
33
|
+
|
|
34
|
+
"Contribution" shall mean any work of authorship intentionally
|
|
35
|
+
submitted to Licensor for inclusion in the Work.
|
|
36
|
+
|
|
37
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
38
|
+
on behalf of whom a Contribution has been received by Licensor.
|
|
39
|
+
|
|
40
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
41
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
42
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
43
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
44
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
45
|
+
Work and such Derivative Works in Source or Object form.
|
|
46
|
+
|
|
47
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
48
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
49
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
50
|
+
(except as stated in this section) patent license to make, have
|
|
51
|
+
made, use, offer to sell, sell, import, and otherwise transfer the
|
|
52
|
+
Work. If You institute patent litigation against any entity
|
|
53
|
+
alleging that the Work constitutes direct or contributory patent
|
|
54
|
+
infringement, then any patent licenses granted to You under this
|
|
55
|
+
License for that Work shall terminate as of the date such
|
|
56
|
+
litigation is filed.
|
|
57
|
+
|
|
58
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
59
|
+
Work or Derivative Works thereof provided that You meet the
|
|
60
|
+
following conditions:
|
|
61
|
+
|
|
62
|
+
(a) You must give any other recipients a copy of this License; and
|
|
63
|
+
(b) You must cause modified files to carry prominent notices; and
|
|
64
|
+
(c) You must retain all copyright, patent, trademark, and
|
|
65
|
+
attribution notices from the Source form; and
|
|
66
|
+
(d) If the Work includes a NOTICE file, any Derivative Works must
|
|
67
|
+
include a readable copy of its attribution notices.
|
|
68
|
+
|
|
69
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
70
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
71
|
+
by You shall be under the terms of this License, without additional
|
|
72
|
+
terms or conditions.
|
|
73
|
+
|
|
74
|
+
6. Trademarks. This License does not grant permission to use trade
|
|
75
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
76
|
+
|
|
77
|
+
7. Disclaimer of Warranty. The Work is provided on an "AS IS" BASIS,
|
|
78
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
79
|
+
implied.
|
|
80
|
+
|
|
81
|
+
8. Limitation of Liability. In no event shall any Contributor be
|
|
82
|
+
liable for damages arising as a result of this License or out of
|
|
83
|
+
the use or inability to use the Work.
|
|
84
|
+
|
|
85
|
+
9. Accepting Warranty or Additional Liability. You may choose to offer
|
|
86
|
+
support, warranty, indemnity, or other liability obligations, but
|
|
87
|
+
only on Your own behalf and sole responsibility.
|
|
88
|
+
|
|
89
|
+
END OF TERMS AND CONDITIONS
|
|
90
|
+
|
|
91
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
92
|
+
|
|
93
|
+
Copyright [yyyy] [name of copyright owner]
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
96
|
+
you may not use this file except in compliance with the License.
|
|
97
|
+
You may obtain a copy of the License at
|
|
98
|
+
|
|
99
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
100
|
+
|
|
101
|
+
Unless required by applicable law or agreed to in writing, software
|
|
102
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
103
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
104
|
+
See the License for the specific language governing permissions and
|
|
105
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# @peerbits/medical-terminology
|
|
2
|
+
|
|
3
|
+
> Terminology system-URI registry and code format/checksum validation utilities — ships zero licensed terminology datasets (see [Licensing](./docs/LICENSING.md))
|
|
4
|
+
|
|
5
|
+
**Category:** Medical Coding — Terminology & Code-Handling Utilities · **License:** Apache-2.0 · **Status:** Stable
|
|
6
|
+
|
|
7
|
+
[](https://github.com/PeerbitsSolution/medical-terminology/actions/workflows/ci.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://www.npmjs.com/package/@peerbits/medical-terminology)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. What problem does this solve?
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
`@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.
|
|
18
|
+
|
|
19
|
+
> **⚠️ 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](./docs/LICENSING.md) for full compliance details.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Features
|
|
24
|
+
|
|
25
|
+
- **Canonical System URI Registry**: Standardized URIs, OIDs, and short-names for 6 major medical coding systems:
|
|
26
|
+
- **LOINC** (`http://loinc.org`)
|
|
27
|
+
- **SNOMED CT** (`http://snomed.info/sct`)
|
|
28
|
+
- **ICD-10-CM** (`http://hl7.org/fhir/sid/icd-10-cm`)
|
|
29
|
+
- **RxNorm** (`http://www.nlm.nih.gov/research/umls/rxnorm`)
|
|
30
|
+
- **CPT** (`http://www.ama-assn.org/go/cpt`)
|
|
31
|
+
- **UCUM** (`http://unitsofmeasure.org`)
|
|
32
|
+
- **Fast Structural & Checksum Validation**:
|
|
33
|
+
- Full Verhoeff check-digit calculation and validation for SNOMED SCTIDs.
|
|
34
|
+
- RegEx & structural format validation for LOINC, ICD-10-CM, CPT (5-digit syntax), RxNorm (RxCUI numeric format), and UCUM syntax.
|
|
35
|
+
- **Pluggable Provider Architecture**: Register runtime lookup hooks (e.g., UMLS REST API, local Terminology Server) to augment structural checks with real-time concept validation.
|
|
36
|
+
- **Zero Runtime Dependencies**: Pure TypeScript with zero external network or database requirements.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 3. Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @peerbits/medical-terminology
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 4. Quick Start
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { validate, SYSTEM_REGISTRY, isValidSctid } from "@peerbits/medical-terminology";
|
|
52
|
+
|
|
53
|
+
// 1. Validate a LOINC observation code
|
|
54
|
+
const loincResult = validate({
|
|
55
|
+
system: "http://loinc.org",
|
|
56
|
+
code: "8867-4",
|
|
57
|
+
});
|
|
58
|
+
console.log(loincResult.valid); // true
|
|
59
|
+
|
|
60
|
+
// 2. Validate SNOMED CT Concept ID with Verhoeff check-digit
|
|
61
|
+
const snomedResult = validate({
|
|
62
|
+
system: "http://snomed.info/sct",
|
|
63
|
+
code: "73211009", // Diabetes mellitus
|
|
64
|
+
});
|
|
65
|
+
console.log(snomedResult.valid); // true
|
|
66
|
+
|
|
67
|
+
// 3. Catch invalid formats early
|
|
68
|
+
const invalidResult = validate({
|
|
69
|
+
system: "http://hl7.org/fhir/sid/icd-10-cm",
|
|
70
|
+
code: "INVALID_CODE",
|
|
71
|
+
});
|
|
72
|
+
console.log(invalidResult.valid); // false
|
|
73
|
+
console.log(invalidResult.issues);
|
|
74
|
+
// [ { severity: "error", path: "code", code: "invalid-format", message: "..." } ]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 5. Pluggable Terminology Providers
|
|
80
|
+
|
|
81
|
+
You can register custom terminology lookup providers to resolve live concepts while falling back gracefully if offline:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { registerProvider, validateWithProvider } from "@peerbits/medical-terminology";
|
|
85
|
+
|
|
86
|
+
// Register an in-house or external terminology resolver
|
|
87
|
+
registerProvider("loinc", async (code) => {
|
|
88
|
+
const isFound = await checkLocalDatabase(code);
|
|
89
|
+
return { found: isFound, display: isFound ? "Heart rate" : undefined };
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Validate format AND verify existence through the provider
|
|
93
|
+
const result = await validateWithProvider({
|
|
94
|
+
system: "http://loinc.org",
|
|
95
|
+
code: "8867-4",
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
console.log(result.valid); // true
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 6. Architecture
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
src/
|
|
107
|
+
├── index.ts # Package entry point and exports
|
|
108
|
+
├── registry.ts # Canonical URIs, OIDs, and system metadata
|
|
109
|
+
├── provider.ts # Pluggable terminology provider interface
|
|
110
|
+
├── types.ts # TypeScript declarations and error shapes
|
|
111
|
+
├── validate.ts # Unified validation engine
|
|
112
|
+
└── validators/
|
|
113
|
+
├── cpt.ts # CPT 5-digit format check (Zero dataset content)
|
|
114
|
+
├── icd10cm.ts # ICD-10-CM alphanumeric structural check
|
|
115
|
+
├── loinc.ts # LOINC hyphenated identifier check
|
|
116
|
+
├── rxnorm.ts # RxNorm RxCUI numeric format check
|
|
117
|
+
├── snomed.ts # SNOMED CT Verhoeff check-digit algorithm
|
|
118
|
+
└── ucum.ts # UCUM unit syntax validator
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 7. Contributing
|
|
124
|
+
|
|
125
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 8. License
|
|
130
|
+
|
|
131
|
+
Apache License 2.0 — see [LICENSE](./LICENSE).
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 9. About PeerbitsSolution
|
|
136
|
+
|
|
137
|
+
`@peerbits/medical-terminology` is part of the [PeerbitsSolution HealthTech Open Source](https://github.com/PeerbitsSolution) 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.
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@peerbits/medical-terminology",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Terminology system-URI registry and code format/checksum validation utilities — ships zero licensed terminology datasets (see docs/LICENSING.md)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "PeerbitsSolution",
|
|
7
|
+
"homepage": "https://github.com/PeerbitsSolution/medical-terminology#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/PeerbitsSolution/medical-terminology/issues"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.json",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"test": "vitest run"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/PeerbitsSolution/medical-terminology.git"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"healthcare",
|
|
39
|
+
"fhir",
|
|
40
|
+
"snomed",
|
|
41
|
+
"loinc",
|
|
42
|
+
"icd-10",
|
|
43
|
+
"rxnorm",
|
|
44
|
+
"cpt",
|
|
45
|
+
"ucum",
|
|
46
|
+
"typescript",
|
|
47
|
+
"terminology"
|
|
48
|
+
],
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"typescript": "^5.5.0",
|
|
51
|
+
"vitest": "^2.0.0",
|
|
52
|
+
"eslint": "^9.0.0",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
54
|
+
"@typescript-eslint/parser": "^8.0.0"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18"
|
|
58
|
+
}
|
|
59
|
+
}
|