simple-icd-10-cm 1.3.0__tar.gz → 1.5.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.
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/LICENSE +1 -1
- {simple_icd_10_cm-1.3.0/simple_icd_10_cm.egg-info → simple_icd_10_cm-1.5.0}/PKG-INFO +43 -10
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/README.md +42 -9
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/setup.py +1 -1
- simple_icd_10_cm-1.3.0/simple_icd_10_cm/data/code-list-April-2025.txt → simple_icd_10_cm-1.5.0/simple_icd_10_cm/data/code-list-April-2026.txt +615 -12
- simple_icd_10_cm-1.3.0/simple_icd_10_cm/data/icd10cm-tabular-April-2025.xml → simple_icd_10_cm-1.5.0/simple_icd_10_cm/data/icd10c-tabular-April-1-2026.xml +2255 -199
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/simple_icd_10_cm/simple_icd_10_cm.py +144 -25
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0/simple_icd_10_cm.egg-info}/PKG-INFO +43 -10
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/simple_icd_10_cm.egg-info/SOURCES.txt +2 -2
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/setup.cfg +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/simple_icd_10_cm/__init__.py +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/simple_icd_10_cm/data/__init__.py +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/simple_icd_10_cm.egg-info/dependency_links.txt +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.5.0}/simple_icd_10_cm.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simple_icd_10_cm
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: A simple python library for ICD-10-CM codes
|
|
5
5
|
Home-page: https://github.com/StefanoTrv/simple_icd_10_CM
|
|
6
6
|
Author: Stefano Travasci
|
|
@@ -53,6 +53,8 @@ A simple python library for ICD-10-CM codes
|
|
|
53
53
|
* [get_seven_chr_def(code, search_in_ancestors=False, prioritize_blocks=False)](#get_seven_chr_defcode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
54
54
|
* [get_use_additional_code(code, search_in_ancestors=False, prioritize_blocks=False)](#get_use_additional_codecode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
55
55
|
* [get_code_first(code, search_in_ancestors=False, prioritize_blocks=False)](#get_code_firstcode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
56
|
+
* [get_code_also(code, search_in_ancestors=False, prioritize_blocks=False)](#get_code_alsocode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
57
|
+
* [get_notes(code, search_in_ancestors=False, prioritize_blocks=False)](#get_notescode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
56
58
|
* [get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)](#get_full_datacode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
57
59
|
* [get_parent(code, prioritize_blocks=False)](#get_parentcode-prioritize_blocksfalse)
|
|
58
60
|
* [get_children(code, prioritize_blocks=False)](#get_childrencode-prioritize_blocksfalse)
|
|
@@ -66,10 +68,16 @@ A simple python library for ICD-10-CM codes
|
|
|
66
68
|
* [get_index(code)](#get_indexcode)
|
|
67
69
|
* [remove_dot(code)](#remove_dotcode)
|
|
68
70
|
* [add_dot(code)](#add_dotcode)
|
|
69
|
-
* [change_version(all_codes_file_path=None, classification_data_file_path=None)](#change_versionall_codes_file_pathnone-classification_data_file_pathnone)
|
|
71
|
+
* [change_version(all_codes_file_path=None, classification_data_file_path=None, suppress_warnings=None)](#change_versionall_codes_file_pathnone-classification_data_file_pathnone-suppress_warningsnone)
|
|
70
72
|
* [Conclusion](#conclusion)
|
|
71
73
|
|
|
72
74
|
## Release notes
|
|
75
|
+
* **1.5.0**:
|
|
76
|
+
* The default ICD-10-CM release of the library is now the **April 2026 release**
|
|
77
|
+
* Certain kinds of defects in the data will now emit warnings instead of crashing the library
|
|
78
|
+
* Small refactoring for my own sanity
|
|
79
|
+
* Thanks to @Qwemep on Github for her valuable insights!
|
|
80
|
+
* **1.4.0**: The data in the fields "codeAlso" and "notes" can now be retrieved using the get_code_also() and get_notes() functions
|
|
73
81
|
* **1.3.0**:
|
|
74
82
|
* Users can now use their preferred ICD-10-CM release by providing properly formatted files as inputs
|
|
75
83
|
* The default ICD-10-CM release of the library is now the **April 2025 release**
|
|
@@ -89,7 +97,7 @@ The objective of this library is to provide a simple instrument for dealing with
|
|
|
89
97
|
If you are looking for a library that deals with ICD-10 codes instead of ICD-10-CM codes, you can check the [simple_icd_10 library](https://github.com/StefanoTrv/simple_icd_10), which is based on the 2019 version of ICD-10. If you are interested in the ICD-11 MMS classification, you can check out instead the [simple_icd_11 library](https://github.com/StefanoTrv/simple_icd_11).
|
|
90
98
|
There is also a Java version of this library, [SimpleICD10CM-Java-edition](https://github.com/StefanoTrv/SimpleICD10CM-Java-edition).
|
|
91
99
|
|
|
92
|
-
The data used in this library was taken from the [website of the CDC](
|
|
100
|
+
The data used in this library was taken from the [website of the CDC](https://www.cdc.gov/nchs/icd/icd-10-cm/files.html). This library currently uses the **April 2026 release of ICD-10-CM**. This package can be configured to use other releases of the ICD-10-CM classification, read the section [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases) for more details.
|
|
93
101
|
|
|
94
102
|
If you feel like supporting me, please check out the [Conclusion section](#conclusion).
|
|
95
103
|
|
|
@@ -125,14 +133,14 @@ cm.change_version(classification_data_file_path="icd10cm_tabular_2021.xml")
|
|
|
125
133
|
|
|
126
134
|
The file specified in `all_codes_file_path` should contain all the unique codes of the desired release. However, it is sufficient that it contains all the seven-characters codes that must be generated programmatically, that is all the valid codes that are not explicitly listed in the XML file (see [About the special seventh character](#about-the-special-seventh-character) for more information). Each line in this file must contain a single code. Codes can be written in the format with or without the dot. In each line, the code may be followed by any text, as long as there is at least one space character immediately after the code. The `icd10cm-codes` text files available from the [CDC's website](https://www.cdc.gov/nchs/icd/icd-10-cm/files.html) can be used for this purpose, without modification.
|
|
127
135
|
The file specified in `classification_data_file_path` is the XML containing the whole classification. This typically corresponds to the `icd10cm-tabular` XML files available from the [CDC's website](https://www.cdc.gov/nchs/icd/icd-10-cm/files.html). If using XML files from another origin, note that, in the official releases, the first two children of the root XML element are not part of the structure of the classification, and are therefore skipped by the library.
|
|
128
|
-
Examples of both file types can be found in the [all-data folder](https://github.com/StefanoTrv/simple_icd_10_CM/tree/master/all-data), which includes data for the current default release and for
|
|
136
|
+
Examples of both file types can be found in the [all-data folder](https://github.com/StefanoTrv/simple_icd_10_CM/tree/master/all-data), which includes data for the current default release and for previous releases.
|
|
129
137
|
|
|
130
138
|
## The format of the codes
|
|
131
139
|
Subcategories codes can be written in two different ways: with a dot (for example "I13.1") and with no dot (for example "I131"). The functions in this library can receive as input codes in both these formats. The codes returned by the functions will always be in the format with the dot.
|
|
132
140
|
You can easily change the format of a code by using the [`remove_dot`](#remove_dotcode) and [`add_dot`](#add_dotcode) functions.
|
|
133
141
|
|
|
134
142
|
## About the file "Instructional Notations.md"
|
|
135
|
-
The file [Instructional Notations.md](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) contains the introduction present in the file `icd10cm-tabular-April-
|
|
143
|
+
The file [Instructional Notations.md](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) contains the introduction present in the file `icd10cm-tabular-April-2026.xml` (the file that contains the whole ICD-10-CM classification), copied there in a more accessible and readable format. There you can find an explanation about the meaning of most of the additional fields that can accompany a code.
|
|
136
144
|
|
|
137
145
|
## Blocks containing only one category
|
|
138
146
|
Unlike ICD-10, ICD-10-CM includes blocks of categories that contain only one category (and its subcategories). These blocks are named after the category that they contain, which means that ICD-10-CM contains blocks and categories that have the same exact code. This is a problem: because of this questionable decision, we can't know for sure if the code "B99", for example, refers to the category "B99" or to the block with the same name. This can be seen in the following example, where "B99" is recognized as both a block and a category:
|
|
@@ -158,9 +166,9 @@ cm.is_block("I12") and cm.is_category("I12")
|
|
|
158
166
|
```
|
|
159
167
|
|
|
160
168
|
## About the special seventh character
|
|
161
|
-
The file `icd10cm-tabular-April-
|
|
169
|
+
The file `icd10cm-tabular-April-2026.xml`, which is the XML file that contains the whole ICD-10-CM classification, doesn't have an entry for all the codes generated by adding the "special" seventh character, but it often contains instead rules that explain how to generate these codes in the "sevenChrDef" field (and sometimes in the "sevenChrNote" field too, just to complicate things a little bit...). You can find more about the structure of these particular codes in [Instructional Notations.md](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md).
|
|
162
170
|
Due to the lack of a complete entry for these missing codes, I had to decide how they would be handled in this library. So I decided that their only field would be the description, composed of the description of their parent followed by the description of the meaning of the additional character, with a comma between the two: this description appears in official documents about ICD-10-CM, so it's not my invention but the actual official format. All the other fields are empty, but the optional argument `search_in_ancestors` of certain functions can be used to automatically retrieve the content of certain fields from the ancestors of the code (see the description of the specific functions in the [Documentation](#documentation) for more details).
|
|
163
|
-
Seven-characters codes that have an entry in `icd10cm-tabular-April-
|
|
171
|
+
Seven-characters codes that have an entry in `icd10cm-tabular-April-2026.xml` are treated like any other code, and their data is taken directly from the file.
|
|
164
172
|
If you need to know whether a code has been automatically generated using a rule described in a "sevenChrDef" field, you can use the [`is_extended_subcategory`](#is_extended_subcategorycode) function. Only the codes generated programmatically are classified as "extended subcategories", the seven-characters codes explicitly listed in the data are classified as "subcategories".
|
|
165
173
|
|
|
166
174
|
## Documentation
|
|
@@ -347,6 +355,30 @@ cm.get_code_first("S04.01")
|
|
|
347
355
|
cm.get_code_first("S04.01",search_in_ancestors=True)
|
|
348
356
|
#'any associated intracranial injury (S06.-)'
|
|
349
357
|
```
|
|
358
|
+
### get_code_also(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
359
|
+
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **string** containing the data of the "codeAlso" field of this code, otherwise it raises a ValueError. If this code does not have a "codeAlso" field, it returns an empty string. Please see [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) if you have doubts about the meaning of this field. When the optional argument `search_in_ancestors` is set to True, if the given code doesn't have a "codeAlso" field but one of its ancestor does, the "codeAlso" data of the closer ancestor that contains such a field is returned. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
360
|
+
```python
|
|
361
|
+
cm.get_code_also("I82.41")
|
|
362
|
+
#''
|
|
363
|
+
cm.get_code_also("Z23")
|
|
364
|
+
#', if applicable, encounter for immunization safety counseling (Z71.85)'
|
|
365
|
+
cm.get_code_also("Z49.0")
|
|
366
|
+
#''
|
|
367
|
+
cm.get_code_also("Z49.0",search_in_ancestors=True)
|
|
368
|
+
#'associated end stage renal disease (N18.6)'
|
|
369
|
+
```
|
|
370
|
+
### get_notes(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
371
|
+
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **string** containing the data of the "notes" field of this code, otherwise it raises a ValueError. If this code does not have a "notes" field, it returns an empty string. When the optional argument `search_in_ancestors` is set to True, if the given code doesn't have a "notes" field but one of its ancestor does, the "notes" data of the closer ancestor that contains such a field is returned. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
372
|
+
```python
|
|
373
|
+
cm.get_notes("I82.41")
|
|
374
|
+
#''
|
|
375
|
+
cm.get_notes("Z23")
|
|
376
|
+
#'procedure codes are required to identify the types of immunizations given'
|
|
377
|
+
cm.get_notes("C91.00")
|
|
378
|
+
#''
|
|
379
|
+
cm.get_notes("C91.00",search_in_ancestors=True)
|
|
380
|
+
#'Codes in subcategory C91.0- should only be used for T-cell and B-cell precursor leukemia'
|
|
381
|
+
```
|
|
350
382
|
### get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
351
383
|
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a string containing all the available data of the code, otherwise it raises a ValueError. The empty fields are omitted from the string, except for the list of children (see second example below). When the optional argument `search_in_ancestors` is set to True, if the given code doesn't have a certain field but one of its ancestor does, the data of the closer ancestor that contains such a field is returned: see the previous functions to know which are the fields that are influenced by this argument and which are not. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
352
384
|
```python
|
|
@@ -477,8 +509,8 @@ cm.add_dot("K00-K14")
|
|
|
477
509
|
#'K00-K14'
|
|
478
510
|
```
|
|
479
511
|
|
|
480
|
-
### change_version(all_codes_file_path=None, classification_data_file_path=None)
|
|
481
|
-
This function can be used to load any ICD-10-CM release provided by the user, or to revert to using the default release for the package. Its usage is explained in the paragraph [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases).
|
|
512
|
+
### change_version(all_codes_file_path=None, classification_data_file_path=None, suppress_warnings=None)
|
|
513
|
+
This function can be used to load any ICD-10-CM release provided by the user, or to revert to using the default release for the package. Its usage is explained in the paragraph [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases). The optional argument `suppress_warnings` can be used to hide the warnings that are emitted when some kinds of small inconsistencies are detected in the loaded data. Setting this parameter to `True` will hide the warnings, setting it to `False` will show them, setting it to `None` or omitting it will not change whether warnings are hidden or shown. It is recommended that you always omit this parameter.
|
|
482
514
|
|
|
483
515
|
## Conclusion
|
|
484
516
|
This should be everything you need to know about the simple_icd_10_cm library. Please contact me if you find any mistake, bug, missing feature or anything else that could be improved or made easier to comprehend, both in this documentation and in the library itself as well as in the [Showcase notebook](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Showcase%20notebook.ipynb). You can also contact me if you need any help using this library, but I may not be able to help with questions about the ICD-10-CM classification itself.
|
|
@@ -489,7 +521,8 @@ If you find this library useful and are feeling generous, consider making a dona
|
|
|
489
521
|
|
|
490
522
|
---
|
|
491
523
|
|
|
492
|
-
|
|
524
|
+
[](https://ko-fi.com/J3J81G2OSG)
|
|
525
|
+
[](https://www.paypal.com/donate?hosted_button_id=9HMMFAZE248VN)
|
|
493
526
|
|
|
494
527
|
Curecoin: BKxCWuWzsqtLzAvAjtpsHpJ7LqFHPubqft
|
|
495
528
|
|
|
@@ -28,6 +28,8 @@ A simple python library for ICD-10-CM codes
|
|
|
28
28
|
* [get_seven_chr_def(code, search_in_ancestors=False, prioritize_blocks=False)](#get_seven_chr_defcode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
29
29
|
* [get_use_additional_code(code, search_in_ancestors=False, prioritize_blocks=False)](#get_use_additional_codecode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
30
30
|
* [get_code_first(code, search_in_ancestors=False, prioritize_blocks=False)](#get_code_firstcode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
31
|
+
* [get_code_also(code, search_in_ancestors=False, prioritize_blocks=False)](#get_code_alsocode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
32
|
+
* [get_notes(code, search_in_ancestors=False, prioritize_blocks=False)](#get_notescode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
31
33
|
* [get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)](#get_full_datacode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
32
34
|
* [get_parent(code, prioritize_blocks=False)](#get_parentcode-prioritize_blocksfalse)
|
|
33
35
|
* [get_children(code, prioritize_blocks=False)](#get_childrencode-prioritize_blocksfalse)
|
|
@@ -41,10 +43,16 @@ A simple python library for ICD-10-CM codes
|
|
|
41
43
|
* [get_index(code)](#get_indexcode)
|
|
42
44
|
* [remove_dot(code)](#remove_dotcode)
|
|
43
45
|
* [add_dot(code)](#add_dotcode)
|
|
44
|
-
* [change_version(all_codes_file_path=None, classification_data_file_path=None)](#change_versionall_codes_file_pathnone-classification_data_file_pathnone)
|
|
46
|
+
* [change_version(all_codes_file_path=None, classification_data_file_path=None, suppress_warnings=None)](#change_versionall_codes_file_pathnone-classification_data_file_pathnone-suppress_warningsnone)
|
|
45
47
|
* [Conclusion](#conclusion)
|
|
46
48
|
|
|
47
49
|
## Release notes
|
|
50
|
+
* **1.5.0**:
|
|
51
|
+
* The default ICD-10-CM release of the library is now the **April 2026 release**
|
|
52
|
+
* Certain kinds of defects in the data will now emit warnings instead of crashing the library
|
|
53
|
+
* Small refactoring for my own sanity
|
|
54
|
+
* Thanks to @Qwemep on Github for her valuable insights!
|
|
55
|
+
* **1.4.0**: The data in the fields "codeAlso" and "notes" can now be retrieved using the get_code_also() and get_notes() functions
|
|
48
56
|
* **1.3.0**:
|
|
49
57
|
* Users can now use their preferred ICD-10-CM release by providing properly formatted files as inputs
|
|
50
58
|
* The default ICD-10-CM release of the library is now the **April 2025 release**
|
|
@@ -64,7 +72,7 @@ The objective of this library is to provide a simple instrument for dealing with
|
|
|
64
72
|
If you are looking for a library that deals with ICD-10 codes instead of ICD-10-CM codes, you can check the [simple_icd_10 library](https://github.com/StefanoTrv/simple_icd_10), which is based on the 2019 version of ICD-10. If you are interested in the ICD-11 MMS classification, you can check out instead the [simple_icd_11 library](https://github.com/StefanoTrv/simple_icd_11).
|
|
65
73
|
There is also a Java version of this library, [SimpleICD10CM-Java-edition](https://github.com/StefanoTrv/SimpleICD10CM-Java-edition).
|
|
66
74
|
|
|
67
|
-
The data used in this library was taken from the [website of the CDC](
|
|
75
|
+
The data used in this library was taken from the [website of the CDC](https://www.cdc.gov/nchs/icd/icd-10-cm/files.html). This library currently uses the **April 2026 release of ICD-10-CM**. This package can be configured to use other releases of the ICD-10-CM classification, read the section [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases) for more details.
|
|
68
76
|
|
|
69
77
|
If you feel like supporting me, please check out the [Conclusion section](#conclusion).
|
|
70
78
|
|
|
@@ -100,14 +108,14 @@ cm.change_version(classification_data_file_path="icd10cm_tabular_2021.xml")
|
|
|
100
108
|
|
|
101
109
|
The file specified in `all_codes_file_path` should contain all the unique codes of the desired release. However, it is sufficient that it contains all the seven-characters codes that must be generated programmatically, that is all the valid codes that are not explicitly listed in the XML file (see [About the special seventh character](#about-the-special-seventh-character) for more information). Each line in this file must contain a single code. Codes can be written in the format with or without the dot. In each line, the code may be followed by any text, as long as there is at least one space character immediately after the code. The `icd10cm-codes` text files available from the [CDC's website](https://www.cdc.gov/nchs/icd/icd-10-cm/files.html) can be used for this purpose, without modification.
|
|
102
110
|
The file specified in `classification_data_file_path` is the XML containing the whole classification. This typically corresponds to the `icd10cm-tabular` XML files available from the [CDC's website](https://www.cdc.gov/nchs/icd/icd-10-cm/files.html). If using XML files from another origin, note that, in the official releases, the first two children of the root XML element are not part of the structure of the classification, and are therefore skipped by the library.
|
|
103
|
-
Examples of both file types can be found in the [all-data folder](https://github.com/StefanoTrv/simple_icd_10_CM/tree/master/all-data), which includes data for the current default release and for
|
|
111
|
+
Examples of both file types can be found in the [all-data folder](https://github.com/StefanoTrv/simple_icd_10_CM/tree/master/all-data), which includes data for the current default release and for previous releases.
|
|
104
112
|
|
|
105
113
|
## The format of the codes
|
|
106
114
|
Subcategories codes can be written in two different ways: with a dot (for example "I13.1") and with no dot (for example "I131"). The functions in this library can receive as input codes in both these formats. The codes returned by the functions will always be in the format with the dot.
|
|
107
115
|
You can easily change the format of a code by using the [`remove_dot`](#remove_dotcode) and [`add_dot`](#add_dotcode) functions.
|
|
108
116
|
|
|
109
117
|
## About the file "Instructional Notations.md"
|
|
110
|
-
The file [Instructional Notations.md](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) contains the introduction present in the file `icd10cm-tabular-April-
|
|
118
|
+
The file [Instructional Notations.md](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) contains the introduction present in the file `icd10cm-tabular-April-2026.xml` (the file that contains the whole ICD-10-CM classification), copied there in a more accessible and readable format. There you can find an explanation about the meaning of most of the additional fields that can accompany a code.
|
|
111
119
|
|
|
112
120
|
## Blocks containing only one category
|
|
113
121
|
Unlike ICD-10, ICD-10-CM includes blocks of categories that contain only one category (and its subcategories). These blocks are named after the category that they contain, which means that ICD-10-CM contains blocks and categories that have the same exact code. This is a problem: because of this questionable decision, we can't know for sure if the code "B99", for example, refers to the category "B99" or to the block with the same name. This can be seen in the following example, where "B99" is recognized as both a block and a category:
|
|
@@ -133,9 +141,9 @@ cm.is_block("I12") and cm.is_category("I12")
|
|
|
133
141
|
```
|
|
134
142
|
|
|
135
143
|
## About the special seventh character
|
|
136
|
-
The file `icd10cm-tabular-April-
|
|
144
|
+
The file `icd10cm-tabular-April-2026.xml`, which is the XML file that contains the whole ICD-10-CM classification, doesn't have an entry for all the codes generated by adding the "special" seventh character, but it often contains instead rules that explain how to generate these codes in the "sevenChrDef" field (and sometimes in the "sevenChrNote" field too, just to complicate things a little bit...). You can find more about the structure of these particular codes in [Instructional Notations.md](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md).
|
|
137
145
|
Due to the lack of a complete entry for these missing codes, I had to decide how they would be handled in this library. So I decided that their only field would be the description, composed of the description of their parent followed by the description of the meaning of the additional character, with a comma between the two: this description appears in official documents about ICD-10-CM, so it's not my invention but the actual official format. All the other fields are empty, but the optional argument `search_in_ancestors` of certain functions can be used to automatically retrieve the content of certain fields from the ancestors of the code (see the description of the specific functions in the [Documentation](#documentation) for more details).
|
|
138
|
-
Seven-characters codes that have an entry in `icd10cm-tabular-April-
|
|
146
|
+
Seven-characters codes that have an entry in `icd10cm-tabular-April-2026.xml` are treated like any other code, and their data is taken directly from the file.
|
|
139
147
|
If you need to know whether a code has been automatically generated using a rule described in a "sevenChrDef" field, you can use the [`is_extended_subcategory`](#is_extended_subcategorycode) function. Only the codes generated programmatically are classified as "extended subcategories", the seven-characters codes explicitly listed in the data are classified as "subcategories".
|
|
140
148
|
|
|
141
149
|
## Documentation
|
|
@@ -322,6 +330,30 @@ cm.get_code_first("S04.01")
|
|
|
322
330
|
cm.get_code_first("S04.01",search_in_ancestors=True)
|
|
323
331
|
#'any associated intracranial injury (S06.-)'
|
|
324
332
|
```
|
|
333
|
+
### get_code_also(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
334
|
+
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **string** containing the data of the "codeAlso" field of this code, otherwise it raises a ValueError. If this code does not have a "codeAlso" field, it returns an empty string. Please see [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) if you have doubts about the meaning of this field. When the optional argument `search_in_ancestors` is set to True, if the given code doesn't have a "codeAlso" field but one of its ancestor does, the "codeAlso" data of the closer ancestor that contains such a field is returned. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
335
|
+
```python
|
|
336
|
+
cm.get_code_also("I82.41")
|
|
337
|
+
#''
|
|
338
|
+
cm.get_code_also("Z23")
|
|
339
|
+
#', if applicable, encounter for immunization safety counseling (Z71.85)'
|
|
340
|
+
cm.get_code_also("Z49.0")
|
|
341
|
+
#''
|
|
342
|
+
cm.get_code_also("Z49.0",search_in_ancestors=True)
|
|
343
|
+
#'associated end stage renal disease (N18.6)'
|
|
344
|
+
```
|
|
345
|
+
### get_notes(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
346
|
+
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **string** containing the data of the "notes" field of this code, otherwise it raises a ValueError. If this code does not have a "notes" field, it returns an empty string. When the optional argument `search_in_ancestors` is set to True, if the given code doesn't have a "notes" field but one of its ancestor does, the "notes" data of the closer ancestor that contains such a field is returned. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
347
|
+
```python
|
|
348
|
+
cm.get_notes("I82.41")
|
|
349
|
+
#''
|
|
350
|
+
cm.get_notes("Z23")
|
|
351
|
+
#'procedure codes are required to identify the types of immunizations given'
|
|
352
|
+
cm.get_notes("C91.00")
|
|
353
|
+
#''
|
|
354
|
+
cm.get_notes("C91.00",search_in_ancestors=True)
|
|
355
|
+
#'Codes in subcategory C91.0- should only be used for T-cell and B-cell precursor leukemia'
|
|
356
|
+
```
|
|
325
357
|
### get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
326
358
|
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a string containing all the available data of the code, otherwise it raises a ValueError. The empty fields are omitted from the string, except for the list of children (see second example below). When the optional argument `search_in_ancestors` is set to True, if the given code doesn't have a certain field but one of its ancestor does, the data of the closer ancestor that contains such a field is returned: see the previous functions to know which are the fields that are influenced by this argument and which are not. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
327
359
|
```python
|
|
@@ -452,8 +484,8 @@ cm.add_dot("K00-K14")
|
|
|
452
484
|
#'K00-K14'
|
|
453
485
|
```
|
|
454
486
|
|
|
455
|
-
### change_version(all_codes_file_path=None, classification_data_file_path=None)
|
|
456
|
-
This function can be used to load any ICD-10-CM release provided by the user, or to revert to using the default release for the package. Its usage is explained in the paragraph [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases).
|
|
487
|
+
### change_version(all_codes_file_path=None, classification_data_file_path=None, suppress_warnings=None)
|
|
488
|
+
This function can be used to load any ICD-10-CM release provided by the user, or to revert to using the default release for the package. Its usage is explained in the paragraph [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases). The optional argument `suppress_warnings` can be used to hide the warnings that are emitted when some kinds of small inconsistencies are detected in the loaded data. Setting this parameter to `True` will hide the warnings, setting it to `False` will show them, setting it to `None` or omitting it will not change whether warnings are hidden or shown. It is recommended that you always omit this parameter.
|
|
457
489
|
|
|
458
490
|
## Conclusion
|
|
459
491
|
This should be everything you need to know about the simple_icd_10_cm library. Please contact me if you find any mistake, bug, missing feature or anything else that could be improved or made easier to comprehend, both in this documentation and in the library itself as well as in the [Showcase notebook](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Showcase%20notebook.ipynb). You can also contact me if you need any help using this library, but I may not be able to help with questions about the ICD-10-CM classification itself.
|
|
@@ -464,7 +496,8 @@ If you find this library useful and are feeling generous, consider making a dona
|
|
|
464
496
|
|
|
465
497
|
---
|
|
466
498
|
|
|
467
|
-
|
|
499
|
+
[](https://ko-fi.com/J3J81G2OSG)
|
|
500
|
+
[](https://www.paypal.com/donate?hosted_button_id=9HMMFAZE248VN)
|
|
468
501
|
|
|
469
502
|
Curecoin: BKxCWuWzsqtLzAvAjtpsHpJ7LqFHPubqft
|
|
470
503
|
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
5
5
|
|
|
6
6
|
setuptools.setup(
|
|
7
7
|
name="simple_icd_10_cm",
|
|
8
|
-
version="1.
|
|
8
|
+
version="1.5.0",
|
|
9
9
|
author="Stefano Travasci",
|
|
10
10
|
author_email="stefanotravasci@gmail.com",
|
|
11
11
|
description="A simple python library for ICD-10-CM codes",
|