simple-icd-10-cm 1.2.0__py3-none-any.whl → 1.4.0__py3-none-any.whl
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/data/code-list-April-2025.txt +97902 -0
- simple_icd_10_cm/data/{icd10cm_tabular_2021.xml → icd10cm-tabular-April-2025.xml} +9970 -959
- simple_icd_10_cm/simple_icd_10_cm.py +189 -103
- {simple_icd_10_cm-1.2.0.dist-info → simple_icd_10_cm-1.4.0.dist-info}/METADATA +106 -27
- simple_icd_10_cm-1.4.0.dist-info/RECORD +10 -0
- {simple_icd_10_cm-1.2.0.dist-info → simple_icd_10_cm-1.4.0.dist-info}/WHEEL +1 -1
- {simple_icd_10_cm-1.2.0.dist-info → simple_icd_10_cm-1.4.0.dist-info/licenses}/LICENSE +1 -1
- simple_icd_10_cm/data/icd10cm-order-Jan-2021.txt +0 -95358
- simple_icd_10_cm-1.2.0.dist-info/RECORD +0 -10
- {simple_icd_10_cm-1.2.0.dist-info → simple_icd_10_cm-1.4.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 1.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: simple_icd_10_cm
|
|
3
|
+
Version: 1.4.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
|
|
@@ -12,6 +12,16 @@ Classifier: Operating System :: OS Independent
|
|
|
12
12
|
Requires-Python: >=3.9
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: keywords
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-python
|
|
24
|
+
Dynamic: summary
|
|
15
25
|
|
|
16
26
|
# simple_icd_10_cm
|
|
17
27
|
A simple python library for ICD-10-CM codes
|
|
@@ -20,6 +30,7 @@ A simple python library for ICD-10-CM codes
|
|
|
20
30
|
* [Release notes](#release-notes)
|
|
21
31
|
* [Introduction](#introduction)
|
|
22
32
|
* [Setup](#setup)
|
|
33
|
+
* [Using other ICD-10-CM releases](#using-other-icd-10-cm-releases)
|
|
23
34
|
* [The format of the codes](#the-format-of-the-codes)
|
|
24
35
|
* [About the file "Instructional Notations.md"](#about-the-file-instructional-notationsmd)
|
|
25
36
|
* [Blocks containing only one category](#blocks-containing-only-one-category)
|
|
@@ -42,6 +53,8 @@ A simple python library for ICD-10-CM codes
|
|
|
42
53
|
* [get_seven_chr_def(code, search_in_ancestors=False, prioritize_blocks=False)](#get_seven_chr_defcode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
43
54
|
* [get_use_additional_code(code, search_in_ancestors=False, prioritize_blocks=False)](#get_use_additional_codecode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
44
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)
|
|
45
58
|
* [get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)](#get_full_datacode-search_in_ancestorsfalse-prioritize_blocksfalse)
|
|
46
59
|
* [get_parent(code, prioritize_blocks=False)](#get_parentcode-prioritize_blocksfalse)
|
|
47
60
|
* [get_children(code, prioritize_blocks=False)](#get_childrencode-prioritize_blocksfalse)
|
|
@@ -55,11 +68,20 @@ A simple python library for ICD-10-CM codes
|
|
|
55
68
|
* [get_index(code)](#get_indexcode)
|
|
56
69
|
* [remove_dot(code)](#remove_dotcode)
|
|
57
70
|
* [add_dot(code)](#add_dotcode)
|
|
71
|
+
* [change_version(all_codes_file_path=None, classification_data_file_path=None)](#change_versionall_codes_file_pathnone-classification_data_file_pathnone)
|
|
58
72
|
* [Conclusion](#conclusion)
|
|
59
73
|
|
|
60
74
|
## Release notes
|
|
75
|
+
* **1.4.0**: The data in the fields "codeAlso" and "notes" can now be retrieved using the get_code_also() and get_notes() functions
|
|
76
|
+
* **1.3.0**:
|
|
77
|
+
* Users can now use their preferred ICD-10-CM release by providing properly formatted files as inputs
|
|
78
|
+
* The default ICD-10-CM release of the library is now the **April 2025 release**
|
|
79
|
+
* Renamed some internal variables (you should not have been using them anyway!)
|
|
80
|
+
* Dropped Conda support, older versions are still available
|
|
81
|
+
* Added type hints for optional parameters
|
|
82
|
+
* **1.2.0**: Added type hints - thanks to @JosephSBoyle on GitHub
|
|
61
83
|
* **1.1.2**: Minor fix in get_full_data
|
|
62
|
-
* **1.1.1**: Fixed minor error in the release
|
|
84
|
+
* **1.1.1**: Fixed a minor error in the release
|
|
63
85
|
* **1.1.0**: Fixed a bug that caused many codes not to be included
|
|
64
86
|
* **1.0.5**: Fixed a minor bug that affected get_nearest_common_ancestor(a,b) when a and b were the same code but written in different formats.
|
|
65
87
|
* **1.0.4**: Managed to get the built package to read the data files
|
|
@@ -67,9 +89,14 @@ A simple python library for ICD-10-CM codes
|
|
|
67
89
|
|
|
68
90
|
## Introduction
|
|
69
91
|
The objective of this library is to provide a simple instrument for dealing with **ICD-10-CM** codes in Python. It provides ways to check whether a code exists, find its ancestors and descendants, see the data associated with it, including its description, and much more.
|
|
70
|
-
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.
|
|
92
|
+
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).
|
|
93
|
+
There is also a Java version of this library, [SimpleICD10CM-Java-edition](https://github.com/StefanoTrv/SimpleICD10CM-Java-edition).
|
|
71
94
|
|
|
72
|
-
The data used in this library was taken from the
|
|
95
|
+
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 2025 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.
|
|
96
|
+
|
|
97
|
+
If you feel like supporting me, please check out the [Conclusion section](#conclusion).
|
|
98
|
+
|
|
99
|
+
simple_icd_10_cm is licensed under [the MIT License](https://github.com/StefanoTrv/simple_icd_10_cm/blob/master/LICENSE).
|
|
73
100
|
|
|
74
101
|
## Setup
|
|
75
102
|
You can install the package with pip, using this command:
|
|
@@ -77,22 +104,41 @@ You can install the package with pip, using this command:
|
|
|
77
104
|
pip install simple-icd-10-cm
|
|
78
105
|
```
|
|
79
106
|
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
conda install -c stefanotrv simple_icd_10_cm
|
|
83
|
-
```
|
|
107
|
+
The distribution files are also available as [releases in the Github repository](https://github.com/StefanoTrv/simple_icd_10_cm/releases).
|
|
84
108
|
|
|
85
109
|
You can also use the "simple_icd_10_cm.py" file, which contains all the source code, in conjunction with the "data" folder, which contains the data used in this library (you can find them in the [GitHub repository](https://github.com/StefanoTrv/simple_icd_10_CM)).
|
|
86
110
|
|
|
111
|
+
### Using other ICD-10-CM releases
|
|
112
|
+
You can use other releases of ICD-10-CM by providing properly formatted data files.
|
|
113
|
+
|
|
114
|
+
The default release is automatically loaded when the package is imported. Therefore, no further setup is required for users who want to use the default release. On the other hand, it is loaded even if the user wants to load a different release, resulting in additional unnecessary overhead. Since most users are expected to use the default release, and to guarantee backward compatibility with earlier versions of the library, this approach was considered the best overall compromise.
|
|
115
|
+
|
|
116
|
+
The function that allows to use different releases is the `change_version` function. It takes two optional arguments `all_codes_file_path` and `classification_data_file_path`, which specify, respectively, the path to the file containing a list of all the codes and the path to the XML file containing the whole structured classification. These files are described in more detail later. If both paths are provided, `change_version` loads the ICD-10-CM release described in those files. If both parameters are left empty, it loads the default release. If one parameter is provided and the other is left empty, `change_version` raises a `ValueError` exception.
|
|
117
|
+
```python
|
|
118
|
+
# loads the files of another release
|
|
119
|
+
cm.change_version(all_codes_file_path="code-list-January-2021.txt",classification_data_file_path="icd10cm_tabular_2021.xml")
|
|
120
|
+
|
|
121
|
+
# loads the default release
|
|
122
|
+
cm.change_version()
|
|
123
|
+
|
|
124
|
+
# these both raise an exception
|
|
125
|
+
cm.change_version(all_codes_file_path="code-list-January-2021.txt")
|
|
126
|
+
cm.change_version(classification_data_file_path="icd10cm_tabular_2021.xml")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
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.
|
|
130
|
+
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.
|
|
131
|
+
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 a previous release.
|
|
132
|
+
|
|
87
133
|
## The format of the codes
|
|
88
|
-
|
|
134
|
+
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.
|
|
89
135
|
You can easily change the format of a code by using the [`remove_dot`](#remove_dotcode) and [`add_dot`](#add_dotcode) functions.
|
|
90
136
|
|
|
91
137
|
## About the file "Instructional Notations.md"
|
|
92
|
-
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 `
|
|
138
|
+
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-2025.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.
|
|
93
139
|
|
|
94
140
|
## Blocks containing only one category
|
|
95
|
-
Unlike ICD-10, ICD-10-CM includes blocks of categories that contain only one (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:
|
|
141
|
+
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:
|
|
96
142
|
```python
|
|
97
143
|
cm.is_block("B99")
|
|
98
144
|
#True
|
|
@@ -115,9 +161,10 @@ cm.is_block("I12") and cm.is_category("I12")
|
|
|
115
161
|
```
|
|
116
162
|
|
|
117
163
|
## About the special seventh character
|
|
118
|
-
The file `
|
|
119
|
-
Due to the lack of a complete entry for these 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
|
|
120
|
-
|
|
164
|
+
The file `icd10cm-tabular-April-2025.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).
|
|
165
|
+
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).
|
|
166
|
+
Seven-characters codes that have an entry in `icd10cm-tabular-April-2025.xml` are treated like any other code, and their data is taken directly from the file.
|
|
167
|
+
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".
|
|
121
168
|
|
|
122
169
|
## Documentation
|
|
123
170
|
Here I list all the functions provided by this library and describe how to use them. If you are interested in a more interactive introduction to simple_icd_10_cm, please take a look at the Jupyter Notebook ["Showcase notebook.ipynb"](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Showcase%20notebook.ipynb); there you can also find more examples.
|
|
@@ -175,7 +222,7 @@ cm.is_category("14")
|
|
|
175
222
|
#False
|
|
176
223
|
```
|
|
177
224
|
### is_subcategory(code, include_extended_subcategories=True)
|
|
178
|
-
This function takes a string as input and returns True if the string is a valid subcategory in ICD-10-CM, False otherwise. By setting the optional argument `include_extended_subcategories` to False, this function will also return False if the string is a valid subcategory obtained by adding the 7th character to another code (see [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) for more information).
|
|
225
|
+
This function takes a string as input and returns True if the string is a valid subcategory in ICD-10-CM, False otherwise. By setting the optional argument `include_extended_subcategories` to False, this function will also return False if the string is a valid subcategory obtained by programmatically adding the 7th character to another code (see [About the special seventh character](#about-the-special-seventh-character) and [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) for more information).
|
|
179
226
|
```python
|
|
180
227
|
cm.is_subcategory("B95.1")
|
|
181
228
|
#True
|
|
@@ -185,14 +232,18 @@ cm.is_subcategory("S12.000G")
|
|
|
185
232
|
#True
|
|
186
233
|
cm.is_subcategory("S12.000G", include_extended_subcategories=False)
|
|
187
234
|
#False
|
|
235
|
+
cm.is_subcategory("C44.1192", include_extended_subcategories=False)
|
|
236
|
+
#True
|
|
188
237
|
```
|
|
189
238
|
### is_extended_subcategory(code)
|
|
190
|
-
This function takes a string as input and returns True if the string is a valid subcategory in ICD-10-CM obtained by adding the 7th character to another code (see [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md)
|
|
239
|
+
This function takes a string as input and returns True if the string is a valid subcategory in ICD-10-CM obtained by programmatically adding the 7th character to another code (see [About the special seventh character](#about-the-special-seventh-character) and [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) for more information), False otherwise.
|
|
191
240
|
```python
|
|
192
241
|
cm.is_extended_subcategory("S12.000G")
|
|
193
242
|
#True
|
|
194
243
|
cm.is_extended_subcategory("S12.000")
|
|
195
244
|
#False
|
|
245
|
+
cm.is_extended_subcategory("C44.1192")
|
|
246
|
+
#False
|
|
196
247
|
```
|
|
197
248
|
### get_description(code, prioritize_blocks=False)
|
|
198
249
|
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **string** containing its description, otherwise it raises a ValueError. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
@@ -238,7 +289,7 @@ cm.get_inclusion_term("J37.0")
|
|
|
238
289
|
#['Catarrhal laryngitis', 'Hypertrophic laryngitis', 'Sicca laryngitis']
|
|
239
290
|
```
|
|
240
291
|
### get_seven_chr_note(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
241
|
-
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 "sevenChrNote" field of this code, otherwise it raises a ValueError. If this code does not have
|
|
292
|
+
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 "sevenChrNote" field of this code, otherwise it raises a ValueError. If this code does not have a "sevenChrNote" field, it returns an empty string. Please see [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) and [About the special seventh character](#about-the-special-seventh-character) 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 "sevenChrNote" field but one of its ancestor does, the "sevenChrNote" 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).
|
|
242
293
|
```python
|
|
243
294
|
cm.get_seven_chr_note("I82.40")
|
|
244
295
|
#''
|
|
@@ -250,7 +301,7 @@ cm.get_seven_chr_note("R40.241",search_in_ancestors=True)
|
|
|
250
301
|
#'The following appropriate 7th character is to be added to subcategory R40.24-:'
|
|
251
302
|
```
|
|
252
303
|
### get_seven_chr_def(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
253
|
-
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **dictionary** containing the data of the "sevenChrDef" field of this code, otherwise it raises a ValueError. The dictionary maps the seventh character to a string that contains its meaning. If this code does not have
|
|
304
|
+
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns a **dictionary** containing the data of the "sevenChrDef" field of this code, otherwise it raises a ValueError. The dictionary maps the seventh character to a string that contains its meaning. If this code does not have a "sevenChrDef" field, it returns an empty list. Please see [Instructional Notations](https://github.com/StefanoTrv/simple_icd_10_CM/blob/master/Instructional%20Notations.md) and [About the special seventh character](#about-the-special-seventh-character) 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 "sevenChrDef" field but one of its ancestor does, the "sevenChrDef" 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).
|
|
254
305
|
```python
|
|
255
306
|
cm.get_seven_chr_def("I82.40")
|
|
256
307
|
#{}
|
|
@@ -288,7 +339,7 @@ cm.get_use_additional_code("R65.20",search_in_ancestors=True)
|
|
|
288
339
|
# hepatic failure (K72.0-)'
|
|
289
340
|
```
|
|
290
341
|
### get_code_first(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
291
|
-
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 "codeFirst" field of this code, otherwise it raises a ValueError. If this code does not have
|
|
342
|
+
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 "codeFirst" field of this code, otherwise it raises a ValueError. If this code does not have a "codeFirst" 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 "codeFirst" field but one of its ancestor does, the "codeFirst" 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).
|
|
292
343
|
```python
|
|
293
344
|
cm.get_code_first("I82.41")
|
|
294
345
|
#''
|
|
@@ -299,6 +350,30 @@ cm.get_code_first("S04.01")
|
|
|
299
350
|
cm.get_code_first("S04.01",search_in_ancestors=True)
|
|
300
351
|
#'any associated intracranial injury (S06.-)'
|
|
301
352
|
```
|
|
353
|
+
### get_code_also(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
354
|
+
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).
|
|
355
|
+
```python
|
|
356
|
+
cm.get_code_also("I82.41")
|
|
357
|
+
#''
|
|
358
|
+
cm.get_code_also("Z23")
|
|
359
|
+
#', if applicable, encounter for immunization safety counseling (Z71.85)'
|
|
360
|
+
cm.get_code_also("Z49.0")
|
|
361
|
+
#''
|
|
362
|
+
cm.get_code_also("Z49.0",search_in_ancestors=True)
|
|
363
|
+
#'associated end stage renal disease (N18.6)'
|
|
364
|
+
```
|
|
365
|
+
### get_notes(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
366
|
+
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).
|
|
367
|
+
```python
|
|
368
|
+
cm.get_notes("I82.41")
|
|
369
|
+
#''
|
|
370
|
+
cm.get_notes("Z23")
|
|
371
|
+
#'procedure codes are required to identify the types of immunizations given'
|
|
372
|
+
cm.get_notes("C91.00")
|
|
373
|
+
#''
|
|
374
|
+
cm.get_notes("C91.00",search_in_ancestors=True)
|
|
375
|
+
#'Codes in subcategory C91.0- should only be used for T-cell and B-cell precursor leukemia'
|
|
376
|
+
```
|
|
302
377
|
### get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
303
378
|
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).
|
|
304
379
|
```python
|
|
@@ -357,7 +432,7 @@ cm.get_descendants("S14.109S")
|
|
|
357
432
|
#[]
|
|
358
433
|
```
|
|
359
434
|
### is_ancestor(a, b, prioritize_blocks_a=False, prioritize_blocks_b=False)
|
|
360
|
-
This function takes two strings as input. If both strings are valid ICD-10-CM codes, it returns True if the first string is an ancestor of the second string. If at least one of the strings is not a valid ICD-10-CM code, it raises a ValueError. The optional arguments `prioritize_blocks_a` and `prioritize_blocks_b` refer, respectively, to the codes in `a` and
|
|
435
|
+
This function takes two strings as input. If both strings are valid ICD-10-CM codes, it returns True if the first string is an ancestor of the second string. If at least one of the strings is not a valid ICD-10-CM code, it raises a ValueError. The optional arguments `prioritize_blocks_a` and `prioritize_blocks_b` refer, respectively, to the codes in `a` and `b`; please see [Blocks containing only one category](#blocks-containing-only-one-category) for the meaning of these optional arguments.
|
|
361
436
|
```python
|
|
362
437
|
cm.is_ancestor("18","R01.0")
|
|
363
438
|
#True
|
|
@@ -369,7 +444,7 @@ cm.is_ancestor("B99","B99",prioritize_blocks_a=True)
|
|
|
369
444
|
#True
|
|
370
445
|
```
|
|
371
446
|
### is_descendant(a, b, prioritize_blocks_a=False, prioritize_blocks_b=False)
|
|
372
|
-
This function takes two strings as input. If both strings are valid ICD-10-CM codes, it returns True if the first string is a descendant of the second string. If at least one of the strings is not a valid ICD-10-CM code, it raises a ValueError. The optional arguments `prioritize_blocks_a` and `prioritize_blocks_b` refer, respectively, to the codes in `a` and
|
|
447
|
+
This function takes two strings as input. If both strings are valid ICD-10-CM codes, it returns True if the first string is a descendant of the second string. If at least one of the strings is not a valid ICD-10-CM code, it raises a ValueError. The optional arguments `prioritize_blocks_a` and `prioritize_blocks_b` refer, respectively, to the codes in `a` and `b`; please see [Blocks containing only one category](#blocks-containing-only-one-category) for the meaning of these optional arguments.
|
|
373
448
|
```python
|
|
374
449
|
cm.is_descendant("R01.0","18")
|
|
375
450
|
#True
|
|
@@ -377,7 +452,7 @@ cm.is_descendant("M31","K00-K14")
|
|
|
377
452
|
#False
|
|
378
453
|
```
|
|
379
454
|
### get_nearest_common_ancestor(a, b, prioritize_blocks_a=False, prioritize_blocks_b=False)
|
|
380
|
-
This function takes two strings as input. If both strings are valid ICD-10-CM codes, it returns their nearest common ancestor if it exists, an empty string if it doesn't exist. If at least one of the strings is not a valid ICD-10-CM code, it raises a ValueError. The optional arguments `prioritize_blocks_a` and `prioritize_blocks_b` refer, respectively, to the codes in `a` and
|
|
455
|
+
This function takes two strings as input. If both strings are valid ICD-10-CM codes, it returns their nearest common ancestor if it exists, an empty string if it doesn't exist. If at least one of the strings is not a valid ICD-10-CM code, it raises a ValueError. The optional arguments `prioritize_blocks_a` and `prioritize_blocks_b` refer, respectively, to the codes in `a` and `b`; please see [Blocks containing only one category](#blocks-containing-only-one-category) for the meaning of these optional arguments.
|
|
381
456
|
```python
|
|
382
457
|
cm.get_nearest_common_ancestor("H28","H25.1")
|
|
383
458
|
#'H25-H28'
|
|
@@ -385,7 +460,7 @@ cm.get_nearest_common_ancestor("K35","E21.0")
|
|
|
385
460
|
#''
|
|
386
461
|
```
|
|
387
462
|
### is_leaf(code, prioritize_blocks=False)
|
|
388
|
-
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns True if it's a leaf in the ICD-10-CM classification (that is, if it has no children), otherwise it returns False. If the string is not a valid ICD-10-CM code it raises a ValueError. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
463
|
+
This function takes a string as input. If the string is a valid ICD-10-CM code, it returns True if it's a leaf in the ICD-10-CM classification (that is, if it has no children), otherwise it returns False. If the string is not a valid ICD-10-CM code, it raises a ValueError. For the meaning of the optional argument `prioritize_blocks`, please see [Blocks containing only one category](#blocks-containing-only-one-category).
|
|
389
464
|
```python
|
|
390
465
|
cm.is_leaf("12")
|
|
391
466
|
#False
|
|
@@ -429,8 +504,11 @@ cm.add_dot("K00-K14")
|
|
|
429
504
|
#'K00-K14'
|
|
430
505
|
```
|
|
431
506
|
|
|
507
|
+
### change_version(all_codes_file_path=None, classification_data_file_path=None)
|
|
508
|
+
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).
|
|
509
|
+
|
|
432
510
|
## Conclusion
|
|
433
|
-
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.
|
|
511
|
+
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.
|
|
434
512
|
|
|
435
513
|
If you find this library useful and are feeling generous, consider making a donation using one of the methods listed at the end of this document.
|
|
436
514
|
|
|
@@ -438,7 +516,8 @@ If you find this library useful and are feeling generous, consider making a dona
|
|
|
438
516
|
|
|
439
517
|
---
|
|
440
518
|
|
|
441
|
-
|
|
519
|
+
[](https://ko-fi.com/J3J81G2OSG)
|
|
520
|
+
[](https://www.paypal.com/donate?hosted_button_id=9HMMFAZE248VN)
|
|
442
521
|
|
|
443
522
|
Curecoin: BKxCWuWzsqtLzAvAjtpsHpJ7LqFHPubqft
|
|
444
523
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
simple_icd_10_cm/__init__.py,sha256=Z1KTvT112WEfhmGoTFyloLMte55xISt0t0CQAeUysRk,31
|
|
2
|
+
simple_icd_10_cm/simple_icd_10_cm.py,sha256=auQ8dcioKjU9r9cuOSrjwR2mO9LU9ZOMXm-5I7-8VbE,25594
|
|
3
|
+
simple_icd_10_cm/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
simple_icd_10_cm/data/code-list-April-2025.txt,sha256=75Pd9bOV14HTokVY-lw2v5jD_Dt3sYb2Dm_xlaNNcWI,794065
|
|
5
|
+
simple_icd_10_cm/data/icd10cm-tabular-April-2025.xml,sha256=1s31KD81oQLXfq0jbsjIkp8iun8zVtut_xjt4Bo6PeU,9658391
|
|
6
|
+
simple_icd_10_cm-1.4.0.dist-info/licenses/LICENSE,sha256=ESrc5DumgzIiwvf1981qtBgmqpE4pH8H8x1vxcIzVlI,1099
|
|
7
|
+
simple_icd_10_cm-1.4.0.dist-info/METADATA,sha256=QUEA00sNj2rpZtippJiHpQJywruO_RWYtZ2_-3wmu1k,40214
|
|
8
|
+
simple_icd_10_cm-1.4.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
9
|
+
simple_icd_10_cm-1.4.0.dist-info/top_level.txt,sha256=6SUf2VHvXP1HmldCp4mtErBEUJHSI0FH39s9aYDAmx4,17
|
|
10
|
+
simple_icd_10_cm-1.4.0.dist-info/RECORD,,
|