cms-icd 0.1.0__tar.gz

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.
@@ -0,0 +1,22 @@
1
+ cff-version: 1.2.0
2
+ title: cms-icd
3
+ message: >-
4
+ If you use this software in research or published work, please cite cms-icd
5
+ and acknowledge IPOL at MGH.
6
+ type: software
7
+ authors:
8
+ - given-names: Pawel
9
+ family-names: Renc
10
+ affiliation: IPOL at MGH
11
+ version: 0.1.0
12
+ license: Apache-2.0
13
+ repository-code: https://github.com/ipolharvard/cms-icd
14
+ url: https://ipolharvard.github.io/cms-icd/
15
+ abstract: >-
16
+ Version-aware structured access to official CMS ICD-10-CM, ICD-10-PCS, and
17
+ General Equivalence Mapping materials.
18
+ keywords:
19
+ - CMS
20
+ - ICD-10-CM
21
+ - ICD-10-PCS
22
+ - clinical informatics
cms_icd-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,3 @@
1
+ include CITATION.cff
2
+ include LICENSE
3
+ include NOTICE
cms_icd-0.1.0/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ cms-icd
2
+ Copyright 2026 Paweł Renc
3
+
4
+ This software was developed by IPOL at MGH.
5
+ https://ipol.mgh.harvard.edu/
cms_icd-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: cms-icd
3
+ Version: 0.1.0
4
+ Summary: Version-aware structured access to official CMS ICD-10 materials
5
+ Author: Pawel Renc
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Documentation, https://ipolharvard.github.io/cms-icd/
8
+ Project-URL: Issues, https://github.com/ipolharvard/cms-icd/issues
9
+ Project-URL: Repository, https://github.com/ipolharvard/cms-icd
10
+ Keywords: CMS,ICD-10,ICD-10-CM,ICD-10-PCS,healthcare
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Healthcare Industry
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
19
+ Requires-Python: >=3.12
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: beautifulsoup4
24
+ Requires-Dist: pypdf<7,>=6.16.1
25
+ Requires-Dist: requests
26
+ Provides-Extra: dev
27
+ Requires-Dist: pre-commit; extra == "dev"
28
+ Requires-Dist: pytest; extra == "dev"
29
+ Provides-Extra: docs
30
+ Requires-Dist: mkdocs-material; extra == "docs"
31
+ Requires-Dist: mkdocstrings[python]; extra == "docs"
32
+ Dynamic: license-file
33
+
34
+ # CMS ICD
35
+
36
+ [![CI](https://github.com/ipolharvard/cms-icd/actions/workflows/ci.yml/badge.svg)](https://github.com/ipolharvard/cms-icd/actions/workflows/ci.yml)
37
+ [![Documentation](https://github.com/ipolharvard/cms-icd/actions/workflows/docs.yml/badge.svg)](https://ipolharvard.github.io/cms-icd/)
38
+ [![CMS catalog](https://github.com/ipolharvard/cms-icd/actions/workflows/catalog-cms.yml/badge.svg)](https://github.com/ipolharvard/cms-icd/actions/workflows/catalog-cms.yml)
39
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
40
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-green.svg)](https://github.com/ipolharvard/cms-icd/blob/main/LICENSE)
41
+
42
+ `cms-icd` provides version-aware, structured access to official CMS ICD-10-CM
43
+ and ICD-10-PCS materials. Downloads and parsing are lazy: using diagnosis codes
44
+ does not download PCS files, and reading a tabular list does not parse indexes
45
+ or guideline PDFs.
46
+
47
+ Python 3.12 or newer is required. The package is tested on Python 3.12–3.14.
48
+ CMS-backed discovery supports production ICD-10 releases from FY 2016 onward,
49
+ including advertised intra-year updates.
50
+
51
+ Full documentation is available at
52
+ [ipolharvard.github.io/cms-icd](https://ipolharvard.github.io/cms-icd/).
53
+
54
+ The package also exposes the official ICD-9/ICD-10 General Equivalence Mappings
55
+ without imposing an application-specific target-selection policy:
56
+
57
+ ```python
58
+ from cms_icd import GEMKnowledgeBase
59
+
60
+ gems = GEMKnowledgeBase.from_cms(fiscal_year=2018)
61
+ entries = gems.cm.icd9_to_icd10["4280"]
62
+ ```
63
+
64
+ Use a retrospectively corrected view when historical target-code validity must be
65
+ preserved while later correction-only GEM revisions are incorporated:
66
+
67
+ ```python
68
+ gems = GEMKnowledgeBase.corrected_from_cms(
69
+ fiscal_year=2016,
70
+ )
71
+ mapping = gems.cm.icd9_to_icd10.mapping("27906")
72
+ provenance = gems.cm.icd9_to_icd10.provenance("27906")
73
+ ```
74
+
75
+ The same exact and retrospectively corrected views apply to procedure GEMs through
76
+ `gems.pcs`. The package also exports the stable ordered `ICD10_PCS_CHARACTERS` alphabet
77
+ for consumers that need a complete, fold-independent PCS vocabulary.
78
+
79
+ The correction horizon defaults to FY2018, the final CMS GEM release, and can be
80
+ overridden explicitly for a narrower audit. A source stops accepting later revisions
81
+ when its mapping encounters an introduced or retired source/target code.
82
+
83
+ ## Installation
84
+
85
+ Install the published package with `uv`:
86
+
87
+ ```bash
88
+ uv add cms-icd
89
+ ```
90
+
91
+ For development, install an editable checkout:
92
+
93
+ ```bash
94
+ uv pip install -e /path/to/cms-icd
95
+ ```
96
+
97
+ ## Choosing a release
98
+
99
+ Select the release using the date that controls coding:
100
+
101
+ ```python
102
+ from datetime import date
103
+
104
+ from cms_icd import ICD10KnowledgeBase
105
+
106
+ icd = ICD10KnowledgeBase.for_date(
107
+ date(2026, 5, 1),
108
+ cache_dir="data/cms_icd",
109
+ )
110
+ cm = icd.cm
111
+ code = cm["I10"] # downloads and parses CM tabular material on first use
112
+ ```
113
+
114
+ Use the discharge date for inpatient ICD-10-CM and ICD-10-PCS, and the encounter
115
+ or date of service for other ICD-10-CM coding.
116
+
117
+ For reproducible research, select an exact effective snapshot:
118
+
119
+ ```python
120
+ icd = ICD10KnowledgeBase.from_cms(
121
+ fiscal_year=2026,
122
+ release_date=date(2026, 4, 1),
123
+ cache_dir="data/cms_icd",
124
+ )
125
+ ```
126
+
127
+ CMS commonly publishes an October release and an April 1 update. Materials not
128
+ changed in an update are inherited from the latest earlier revision in that
129
+ fiscal year. CMS does not always retain every historical revision, so snapshot
130
+ selection is strict by default. Pass `fallback="latest_for_fy"` only when using
131
+ the latest available fiscal-year material is scientifically acceptable.
132
+
133
+ The [release guide](https://ipolharvard.github.io/cms-icd/guide/releases-and-caching/)
134
+ documents supported guideline years and the exact October/April selection
135
+ rules.
136
+
137
+ ## Offline and custom stores
138
+
139
+ An existing directory is not inspected until a material is requested:
140
+
141
+ ```pycon
142
+ >>> from datetime import date
143
+ >>> from pathlib import Path
144
+ >>> from tempfile import TemporaryDirectory
145
+ >>> from cms_icd import ICD10KnowledgeBase
146
+ >>> with TemporaryDirectory() as directory:
147
+ ... kb = ICD10KnowledgeBase.from_directory(
148
+ ... directory,
149
+ ... fiscal_year=2026,
150
+ ... release_date=date(2025, 10, 1),
151
+ ... )
152
+ ... repr(kb)
153
+ 'ICD10KnowledgeBase(release=Release(fiscal_year=2026, release_date=datetime.date(2025, 10, 1)), loaded=[])'
154
+
155
+ ```
156
+
157
+ Small custom or synthetic stores can be supplied directly:
158
+
159
+ ```pycon
160
+ >>> from cms_icd import Code, ICD10CMKnowledgeBase
161
+ >>> from cms_icd.models import Node
162
+ >>> from cms_icd.stores import TabularStore
163
+ >>> root = Node("cm", "cm", children_ids=("I10",))
164
+ >>> code = Code("I10", "I10", "Essential hypertension", parent_id="cm")
165
+ >>> tabular = TabularStore({"cm": root, "I10": code}, {"I10": "I10"}, ("cm",))
166
+ >>> cm = ICD10CMKnowledgeBase.from_stores(tabular=tabular)
167
+ >>> cm["I10"].description
168
+ 'Essential hypertension'
169
+ >>> cm.get_leaves("cm")
170
+ ['I10']
171
+
172
+ ```
173
+
174
+ ## Citation and acknowledgment
175
+
176
+ If you use `cms-icd` in research or published work, please cite the software
177
+ using
178
+ [`CITATION.cff`](https://github.com/ipolharvard/cms-icd/blob/main/CITATION.cff)
179
+ and acknowledge IPOL at MGH.
180
+
181
+ The source code is licensed under the
182
+ [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). See
183
+ [`NOTICE`](https://github.com/ipolharvard/cms-icd/blob/main/NOTICE) for
184
+ attribution information.
185
+
186
+ ## Development
187
+
188
+ ```bash
189
+ make install-dev
190
+ make test
191
+ make install-docs
192
+ make docs
193
+ ```
194
+
195
+ Normal tests are offline. `make test-live` accesses CMS and must be run only
196
+ when live integration testing is explicitly intended.
197
+
198
+ CMS compatibility is validated in separate catalog, fresh-current, historical,
199
+ and manual exhaustive lanes. See the
200
+ [testing strategy](https://ipolharvard.github.io/cms-icd/testing/).
201
+
202
+ `cms-icd` is an independent open-source project. It is not affiliated with,
203
+ endorsed by, or sponsored by the Centers for Medicare & Medicaid Services.
@@ -0,0 +1,170 @@
1
+ # CMS ICD
2
+
3
+ [![CI](https://github.com/ipolharvard/cms-icd/actions/workflows/ci.yml/badge.svg)](https://github.com/ipolharvard/cms-icd/actions/workflows/ci.yml)
4
+ [![Documentation](https://github.com/ipolharvard/cms-icd/actions/workflows/docs.yml/badge.svg)](https://ipolharvard.github.io/cms-icd/)
5
+ [![CMS catalog](https://github.com/ipolharvard/cms-icd/actions/workflows/catalog-cms.yml/badge.svg)](https://github.com/ipolharvard/cms-icd/actions/workflows/catalog-cms.yml)
6
+ [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
7
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-green.svg)](https://github.com/ipolharvard/cms-icd/blob/main/LICENSE)
8
+
9
+ `cms-icd` provides version-aware, structured access to official CMS ICD-10-CM
10
+ and ICD-10-PCS materials. Downloads and parsing are lazy: using diagnosis codes
11
+ does not download PCS files, and reading a tabular list does not parse indexes
12
+ or guideline PDFs.
13
+
14
+ Python 3.12 or newer is required. The package is tested on Python 3.12–3.14.
15
+ CMS-backed discovery supports production ICD-10 releases from FY 2016 onward,
16
+ including advertised intra-year updates.
17
+
18
+ Full documentation is available at
19
+ [ipolharvard.github.io/cms-icd](https://ipolharvard.github.io/cms-icd/).
20
+
21
+ The package also exposes the official ICD-9/ICD-10 General Equivalence Mappings
22
+ without imposing an application-specific target-selection policy:
23
+
24
+ ```python
25
+ from cms_icd import GEMKnowledgeBase
26
+
27
+ gems = GEMKnowledgeBase.from_cms(fiscal_year=2018)
28
+ entries = gems.cm.icd9_to_icd10["4280"]
29
+ ```
30
+
31
+ Use a retrospectively corrected view when historical target-code validity must be
32
+ preserved while later correction-only GEM revisions are incorporated:
33
+
34
+ ```python
35
+ gems = GEMKnowledgeBase.corrected_from_cms(
36
+ fiscal_year=2016,
37
+ )
38
+ mapping = gems.cm.icd9_to_icd10.mapping("27906")
39
+ provenance = gems.cm.icd9_to_icd10.provenance("27906")
40
+ ```
41
+
42
+ The same exact and retrospectively corrected views apply to procedure GEMs through
43
+ `gems.pcs`. The package also exports the stable ordered `ICD10_PCS_CHARACTERS` alphabet
44
+ for consumers that need a complete, fold-independent PCS vocabulary.
45
+
46
+ The correction horizon defaults to FY2018, the final CMS GEM release, and can be
47
+ overridden explicitly for a narrower audit. A source stops accepting later revisions
48
+ when its mapping encounters an introduced or retired source/target code.
49
+
50
+ ## Installation
51
+
52
+ Install the published package with `uv`:
53
+
54
+ ```bash
55
+ uv add cms-icd
56
+ ```
57
+
58
+ For development, install an editable checkout:
59
+
60
+ ```bash
61
+ uv pip install -e /path/to/cms-icd
62
+ ```
63
+
64
+ ## Choosing a release
65
+
66
+ Select the release using the date that controls coding:
67
+
68
+ ```python
69
+ from datetime import date
70
+
71
+ from cms_icd import ICD10KnowledgeBase
72
+
73
+ icd = ICD10KnowledgeBase.for_date(
74
+ date(2026, 5, 1),
75
+ cache_dir="data/cms_icd",
76
+ )
77
+ cm = icd.cm
78
+ code = cm["I10"] # downloads and parses CM tabular material on first use
79
+ ```
80
+
81
+ Use the discharge date for inpatient ICD-10-CM and ICD-10-PCS, and the encounter
82
+ or date of service for other ICD-10-CM coding.
83
+
84
+ For reproducible research, select an exact effective snapshot:
85
+
86
+ ```python
87
+ icd = ICD10KnowledgeBase.from_cms(
88
+ fiscal_year=2026,
89
+ release_date=date(2026, 4, 1),
90
+ cache_dir="data/cms_icd",
91
+ )
92
+ ```
93
+
94
+ CMS commonly publishes an October release and an April 1 update. Materials not
95
+ changed in an update are inherited from the latest earlier revision in that
96
+ fiscal year. CMS does not always retain every historical revision, so snapshot
97
+ selection is strict by default. Pass `fallback="latest_for_fy"` only when using
98
+ the latest available fiscal-year material is scientifically acceptable.
99
+
100
+ The [release guide](https://ipolharvard.github.io/cms-icd/guide/releases-and-caching/)
101
+ documents supported guideline years and the exact October/April selection
102
+ rules.
103
+
104
+ ## Offline and custom stores
105
+
106
+ An existing directory is not inspected until a material is requested:
107
+
108
+ ```pycon
109
+ >>> from datetime import date
110
+ >>> from pathlib import Path
111
+ >>> from tempfile import TemporaryDirectory
112
+ >>> from cms_icd import ICD10KnowledgeBase
113
+ >>> with TemporaryDirectory() as directory:
114
+ ... kb = ICD10KnowledgeBase.from_directory(
115
+ ... directory,
116
+ ... fiscal_year=2026,
117
+ ... release_date=date(2025, 10, 1),
118
+ ... )
119
+ ... repr(kb)
120
+ 'ICD10KnowledgeBase(release=Release(fiscal_year=2026, release_date=datetime.date(2025, 10, 1)), loaded=[])'
121
+
122
+ ```
123
+
124
+ Small custom or synthetic stores can be supplied directly:
125
+
126
+ ```pycon
127
+ >>> from cms_icd import Code, ICD10CMKnowledgeBase
128
+ >>> from cms_icd.models import Node
129
+ >>> from cms_icd.stores import TabularStore
130
+ >>> root = Node("cm", "cm", children_ids=("I10",))
131
+ >>> code = Code("I10", "I10", "Essential hypertension", parent_id="cm")
132
+ >>> tabular = TabularStore({"cm": root, "I10": code}, {"I10": "I10"}, ("cm",))
133
+ >>> cm = ICD10CMKnowledgeBase.from_stores(tabular=tabular)
134
+ >>> cm["I10"].description
135
+ 'Essential hypertension'
136
+ >>> cm.get_leaves("cm")
137
+ ['I10']
138
+
139
+ ```
140
+
141
+ ## Citation and acknowledgment
142
+
143
+ If you use `cms-icd` in research or published work, please cite the software
144
+ using
145
+ [`CITATION.cff`](https://github.com/ipolharvard/cms-icd/blob/main/CITATION.cff)
146
+ and acknowledge IPOL at MGH.
147
+
148
+ The source code is licensed under the
149
+ [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). See
150
+ [`NOTICE`](https://github.com/ipolharvard/cms-icd/blob/main/NOTICE) for
151
+ attribution information.
152
+
153
+ ## Development
154
+
155
+ ```bash
156
+ make install-dev
157
+ make test
158
+ make install-docs
159
+ make docs
160
+ ```
161
+
162
+ Normal tests are offline. `make test-live` accesses CMS and must be run only
163
+ when live integration testing is explicitly intended.
164
+
165
+ CMS compatibility is validated in separate catalog, fresh-current, historical,
166
+ and manual exhaustive lanes. See the
167
+ [testing strategy](https://ipolharvard.github.io/cms-icd/testing/).
168
+
169
+ `cms-icd` is an independent open-source project. It is not affiliated with,
170
+ endorsed by, or sponsored by the Centers for Medicare & Medicaid Services.
@@ -0,0 +1,78 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cms-icd"
7
+ version = "0.1.0"
8
+ description = "Version-aware structured access to official CMS ICD-10 materials"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE", "NOTICE"]
13
+ keywords = ["CMS", "ICD-10", "ICD-10-CM", "ICD-10-PCS", "healthcare"]
14
+ authors = [
15
+ { name = "Pawel Renc" },
16
+ ]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Intended Audience :: Healthcare Industry",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
26
+ ]
27
+ dependencies = [
28
+ "beautifulsoup4",
29
+ "pypdf>=6.16.1,<7",
30
+ "requests",
31
+ ]
32
+
33
+ [project.urls]
34
+ Documentation = "https://ipolharvard.github.io/cms-icd/"
35
+ Issues = "https://github.com/ipolharvard/cms-icd/issues"
36
+ Repository = "https://github.com/ipolharvard/cms-icd"
37
+
38
+ [project.optional-dependencies]
39
+ dev = ["pre-commit", "pytest"]
40
+ docs = [
41
+ "mkdocs-material",
42
+ "mkdocstrings[python]",
43
+ ]
44
+
45
+ [tool.setuptools.packages.find]
46
+ where = ["src"]
47
+
48
+ [tool.pytest.ini_options]
49
+ addopts = "--doctest-modules --doctest-glob=README.md --doctest-glob=docs/*.md -m 'not live_cms'"
50
+ doctest_optionflags = ["NORMALIZE_WHITESPACE", "ELLIPSIS"]
51
+ markers = [
52
+ "live_cms: integration tests that access official CMS endpoints",
53
+ "live_catalog: fetch and validate CMS catalog pages without artifacts",
54
+ "live_current: freshly download and parse the latest complete CMS snapshot",
55
+ "live_historical: parse representative historical CMS artifact formats",
56
+ "live_exhaustive: manually download and parse every advertised snapshot",
57
+ ]
58
+
59
+ [tool.ruff]
60
+ target-version = "py312"
61
+ line-length = 88
62
+
63
+ [tool.ruff.lint]
64
+ select = [
65
+ "E",
66
+ "F",
67
+ "I",
68
+ "UP",
69
+ "B",
70
+ "C4",
71
+ "DTZ",
72
+ "RUF",
73
+ "N",
74
+ "TC",
75
+ ]
76
+
77
+ [tool.ruff.lint.isort]
78
+ known-first-party = ["cms_icd"]