simple-icd-10-cm 1.3.0__tar.gz → 1.4.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.4.0}/LICENSE +1 -1
- {simple_icd_10_cm-1.3.0/simple_icd_10_cm.egg-info → simple_icd_10_cm-1.4.0}/PKG-INFO +31 -3
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/README.md +30 -2
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/setup.py +1 -1
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm/simple_icd_10_cm.py +56 -4
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0/simple_icd_10_cm.egg-info}/PKG-INFO +31 -3
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/setup.cfg +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm/__init__.py +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm/data/__init__.py +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm/data/code-list-April-2025.txt +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm/data/icd10cm-tabular-April-2025.xml +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm.egg-info/SOURCES.txt +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm.egg-info/dependency_links.txt +0 -0
- {simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.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.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
|
|
@@ -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)
|
|
@@ -70,6 +72,7 @@ A simple python library for ICD-10-CM codes
|
|
|
70
72
|
* [Conclusion](#conclusion)
|
|
71
73
|
|
|
72
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
|
|
73
76
|
* **1.3.0**:
|
|
74
77
|
* Users can now use their preferred ICD-10-CM release by providing properly formatted files as inputs
|
|
75
78
|
* The default ICD-10-CM release of the library is now the **April 2025 release**
|
|
@@ -89,7 +92,7 @@ The objective of this library is to provide a simple instrument for dealing with
|
|
|
89
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).
|
|
90
93
|
There is also a Java version of this library, [SimpleICD10CM-Java-edition](https://github.com/StefanoTrv/SimpleICD10CM-Java-edition).
|
|
91
94
|
|
|
92
|
-
The data used in this library was taken from the [website of the CDC](
|
|
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.
|
|
93
96
|
|
|
94
97
|
If you feel like supporting me, please check out the [Conclusion section](#conclusion).
|
|
95
98
|
|
|
@@ -347,6 +350,30 @@ cm.get_code_first("S04.01")
|
|
|
347
350
|
cm.get_code_first("S04.01",search_in_ancestors=True)
|
|
348
351
|
#'any associated intracranial injury (S06.-)'
|
|
349
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
|
+
```
|
|
350
377
|
### get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
351
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).
|
|
352
379
|
```python
|
|
@@ -489,7 +516,8 @@ If you find this library useful and are feeling generous, consider making a dona
|
|
|
489
516
|
|
|
490
517
|
---
|
|
491
518
|
|
|
492
|
-
|
|
519
|
+
[](https://ko-fi.com/J3J81G2OSG)
|
|
520
|
+
[](https://www.paypal.com/donate?hosted_button_id=9HMMFAZE248VN)
|
|
493
521
|
|
|
494
522
|
Curecoin: BKxCWuWzsqtLzAvAjtpsHpJ7LqFHPubqft
|
|
495
523
|
|
|
@@ -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)
|
|
@@ -45,6 +47,7 @@ A simple python library for ICD-10-CM codes
|
|
|
45
47
|
* [Conclusion](#conclusion)
|
|
46
48
|
|
|
47
49
|
## Release notes
|
|
50
|
+
* **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
51
|
* **1.3.0**:
|
|
49
52
|
* Users can now use their preferred ICD-10-CM release by providing properly formatted files as inputs
|
|
50
53
|
* The default ICD-10-CM release of the library is now the **April 2025 release**
|
|
@@ -64,7 +67,7 @@ The objective of this library is to provide a simple instrument for dealing with
|
|
|
64
67
|
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
68
|
There is also a Java version of this library, [SimpleICD10CM-Java-edition](https://github.com/StefanoTrv/SimpleICD10CM-Java-edition).
|
|
66
69
|
|
|
67
|
-
The data used in this library was taken from the [website of the CDC](
|
|
70
|
+
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.
|
|
68
71
|
|
|
69
72
|
If you feel like supporting me, please check out the [Conclusion section](#conclusion).
|
|
70
73
|
|
|
@@ -322,6 +325,30 @@ cm.get_code_first("S04.01")
|
|
|
322
325
|
cm.get_code_first("S04.01",search_in_ancestors=True)
|
|
323
326
|
#'any associated intracranial injury (S06.-)'
|
|
324
327
|
```
|
|
328
|
+
### get_code_also(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
329
|
+
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).
|
|
330
|
+
```python
|
|
331
|
+
cm.get_code_also("I82.41")
|
|
332
|
+
#''
|
|
333
|
+
cm.get_code_also("Z23")
|
|
334
|
+
#', if applicable, encounter for immunization safety counseling (Z71.85)'
|
|
335
|
+
cm.get_code_also("Z49.0")
|
|
336
|
+
#''
|
|
337
|
+
cm.get_code_also("Z49.0",search_in_ancestors=True)
|
|
338
|
+
#'associated end stage renal disease (N18.6)'
|
|
339
|
+
```
|
|
340
|
+
### get_notes(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
341
|
+
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).
|
|
342
|
+
```python
|
|
343
|
+
cm.get_notes("I82.41")
|
|
344
|
+
#''
|
|
345
|
+
cm.get_notes("Z23")
|
|
346
|
+
#'procedure codes are required to identify the types of immunizations given'
|
|
347
|
+
cm.get_notes("C91.00")
|
|
348
|
+
#''
|
|
349
|
+
cm.get_notes("C91.00",search_in_ancestors=True)
|
|
350
|
+
#'Codes in subcategory C91.0- should only be used for T-cell and B-cell precursor leukemia'
|
|
351
|
+
```
|
|
325
352
|
### get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
326
353
|
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
354
|
```python
|
|
@@ -464,7 +491,8 @@ If you find this library useful and are feeling generous, consider making a dona
|
|
|
464
491
|
|
|
465
492
|
---
|
|
466
493
|
|
|
467
|
-
|
|
494
|
+
[](https://ko-fi.com/J3J81G2OSG)
|
|
495
|
+
[](https://www.paypal.com/donate?hosted_button_id=9HMMFAZE248VN)
|
|
468
496
|
|
|
469
497
|
Curecoin: BKxCWuWzsqtLzAvAjtpsHpJ7LqFHPubqft
|
|
470
498
|
|
|
@@ -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.4.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",
|
|
@@ -27,7 +27,7 @@ _all_codes_package_file_name:str = 'code-list-April-2025.txt'
|
|
|
27
27
|
_classification_data_package_file_name:str = 'icd10cm-tabular-April-2025.xml'
|
|
28
28
|
|
|
29
29
|
class _CodeTree:
|
|
30
|
-
def __init__(self, tree, parent = None, seven_chr_def_ancestor = None, seven_chr_note_ancestor = None, use_additional_code_ancestor = None, code_first_ancestor = None):
|
|
30
|
+
def __init__(self, tree, parent = None, seven_chr_def_ancestor = None, seven_chr_note_ancestor = None, use_additional_code_ancestor = None, code_first_ancestor = None, code_also_ancestor = None, notes_ancestor = None):
|
|
31
31
|
#initialize all the values
|
|
32
32
|
self.name = ""
|
|
33
33
|
self.description = ""
|
|
@@ -46,17 +46,24 @@ class _CodeTree:
|
|
|
46
46
|
self.use_additional_code_ancestor = use_additional_code_ancestor
|
|
47
47
|
self.code_first = ""
|
|
48
48
|
self.code_first_ancestor = code_first_ancestor
|
|
49
|
+
self.code_also = ""
|
|
50
|
+
self.code_also_ancestor = code_also_ancestor
|
|
51
|
+
self.notes = ""
|
|
52
|
+
self.notes_ancestor = notes_ancestor
|
|
49
53
|
|
|
50
54
|
#reads the data from the subtrees
|
|
51
55
|
new_seven_chr_def_ancestor=seven_chr_def_ancestor
|
|
52
56
|
new_seven_chr_note_ancestor=seven_chr_note_ancestor
|
|
53
57
|
new_use_additional_code_ancestor=use_additional_code_ancestor
|
|
54
58
|
new_code_first_ancestor=code_first_ancestor
|
|
59
|
+
new_code_also_ancestor=code_also_ancestor
|
|
60
|
+
new_notes_ancestor=notes_ancestor
|
|
55
61
|
if "id" in tree.attrib: #the name of sections is an attribute instead of text inside an XML element
|
|
56
62
|
self.name=tree.attrib["id"]
|
|
57
63
|
for subtree in tree:
|
|
58
64
|
if subtree.tag=="section" or subtree.tag=="diag": #creates a new child for this node
|
|
59
|
-
|
|
65
|
+
# This is only correct because the XML elements for the children codes always follow the XML elements for this code's data
|
|
66
|
+
self.children.append(_CodeTree(subtree,parent=self,seven_chr_def_ancestor=new_seven_chr_def_ancestor,seven_chr_note_ancestor=new_seven_chr_note_ancestor,use_additional_code_ancestor=new_use_additional_code_ancestor,code_first_ancestor=new_code_first_ancestor,code_also_ancestor=new_code_also_ancestor,notes_ancestor=new_notes_ancestor))
|
|
60
67
|
elif subtree.tag=="name":
|
|
61
68
|
self.name=subtree.text
|
|
62
69
|
elif subtree.tag=="desc":
|
|
@@ -86,6 +93,7 @@ class _CodeTree:
|
|
|
86
93
|
self.seven_chr_note=subtree[0].text
|
|
87
94
|
new_seven_chr_note_ancestor=self
|
|
88
95
|
elif subtree.tag=="useAdditionalCode":
|
|
96
|
+
# NOTE: multiple useAdditionalCode elements may be present, so self.use_additional_code should always be appended and never overwritten
|
|
89
97
|
for i in range(0,len(subtree)):#in case there are multiple lines
|
|
90
98
|
self.use_additional_code=self.use_additional_code+"\n"+subtree[i].text
|
|
91
99
|
new_use_additional_code_ancestor=self
|
|
@@ -93,12 +101,26 @@ class _CodeTree:
|
|
|
93
101
|
for i in range(0,len(subtree)):#in case there are multiple lines
|
|
94
102
|
self.code_first=self.code_first+"\n"+subtree[i].text
|
|
95
103
|
new_code_first_ancestor=self
|
|
104
|
+
elif subtree.tag=="codeAlso":
|
|
105
|
+
# see NOTE for useAdditionalCode
|
|
106
|
+
for i in range(0,len(subtree)):#in case there are multiple lines
|
|
107
|
+
self.code_also=self.code_also+"\n"+subtree[i].text
|
|
108
|
+
new_code_also_ancestor=self
|
|
109
|
+
elif subtree.tag=="notes":
|
|
110
|
+
# see NOTE for useAdditionalCode
|
|
111
|
+
for i in range(0,len(subtree)):#in case there are multiple lines
|
|
112
|
+
self.notes=self.notes+"\n"+subtree[i].text
|
|
113
|
+
new_notes_ancestor=self
|
|
96
114
|
|
|
97
|
-
#cleans the use_additional_code and
|
|
115
|
+
#cleans the use_additional_code, code_first, code_also and notes fields from extra new lines
|
|
98
116
|
if self.use_additional_code!="" and self.use_additional_code[0]=="\n":
|
|
99
117
|
self.use_additional_code=self.use_additional_code[1:]
|
|
100
118
|
if self.code_first!="" and self.code_first[0]=="\n":
|
|
101
119
|
self.code_first=self.code_first[1:]
|
|
120
|
+
if self.code_also!="" and self.code_also[0]=="\n":
|
|
121
|
+
self.code_also=self.code_also[1:]
|
|
122
|
+
if self.notes!="" and self.notes[0]=="\n":
|
|
123
|
+
self.notes=self.notes[1:]
|
|
102
124
|
|
|
103
125
|
#sets the type
|
|
104
126
|
if tree.tag=="chapter":
|
|
@@ -130,7 +152,7 @@ class _CodeTree:
|
|
|
130
152
|
for extension in dictionary:
|
|
131
153
|
if((extended_name[:3]+extended_name[4:]+extension) in all_confirmed_codes):#checks if there's a special rule that excludes this new code
|
|
132
154
|
new_XML = "<diag_ext><name>"+extended_name+extension+"</name><desc>"+self.description+", "+dictionary[extension]+"</desc></diag_ext>"
|
|
133
|
-
self.children.append(_CodeTree(ET.fromstring(new_XML),parent=self,seven_chr_def_ancestor=new_seven_chr_def_ancestor,seven_chr_note_ancestor=new_seven_chr_note_ancestor,use_additional_code_ancestor=new_use_additional_code_ancestor,code_first_ancestor=new_code_first_ancestor))
|
|
155
|
+
self.children.append(_CodeTree(ET.fromstring(new_XML),parent=self,seven_chr_def_ancestor=new_seven_chr_def_ancestor,seven_chr_note_ancestor=new_seven_chr_note_ancestor,use_additional_code_ancestor=new_use_additional_code_ancestor,code_first_ancestor=new_code_first_ancestor,code_also_ancestor=new_code_also_ancestor,notes_ancestor=new_notes_ancestor))
|
|
134
156
|
|
|
135
157
|
def _load_codes(all_codes_file_path:Optional[str] = None, classification_data_file_path:Optional[str] = None) -> None: # either both or none of the strings must be None
|
|
136
158
|
#loads the list of all codes, to remove later from the tree the ones that do not exist for very specific rules not easily extracted from the XML file
|
|
@@ -324,6 +346,30 @@ def get_code_first(code:str, search_in_ancestors:bool=False, prioritize_blocks:b
|
|
|
324
346
|
else:
|
|
325
347
|
return res
|
|
326
348
|
|
|
349
|
+
def get_code_also(code:str, search_in_ancestors:bool=False, prioritize_blocks:bool=False) -> str:
|
|
350
|
+
if not is_valid_item(code):
|
|
351
|
+
raise ValueError("The code \""+code+"\" does not exist.")
|
|
352
|
+
node = _code_to_node[_add_dot_to_code(code)]
|
|
353
|
+
if prioritize_blocks and node.parent!=None and node.parent.name==node.name:
|
|
354
|
+
node = node.parent
|
|
355
|
+
res = node.code_also
|
|
356
|
+
if search_in_ancestors and res=="" and node.code_also_ancestor!=None:
|
|
357
|
+
return node.code_also_ancestor.code_also
|
|
358
|
+
else:
|
|
359
|
+
return res
|
|
360
|
+
|
|
361
|
+
def get_notes(code:str, search_in_ancestors:bool=False, prioritize_blocks:bool=False) -> str:
|
|
362
|
+
if not is_valid_item(code):
|
|
363
|
+
raise ValueError("The code \""+code+"\" does not exist.")
|
|
364
|
+
node = _code_to_node[_add_dot_to_code(code)]
|
|
365
|
+
if prioritize_blocks and node.parent!=None and node.parent.name==node.name:
|
|
366
|
+
node = node.parent
|
|
367
|
+
res = node.notes
|
|
368
|
+
if search_in_ancestors and res=="" and node.notes_ancestor!=None:
|
|
369
|
+
return node.notes_ancestor.notes
|
|
370
|
+
else:
|
|
371
|
+
return res
|
|
372
|
+
|
|
327
373
|
def get_parent(code:str, prioritize_blocks:bool=False) -> str:
|
|
328
374
|
if not is_valid_item(code):
|
|
329
375
|
raise ValueError("The code \""+code+"\" does not exist.")
|
|
@@ -393,6 +439,12 @@ def get_full_data(code:str, search_in_ancestors:bool=False, prioritize_blocks:bo
|
|
|
393
439
|
code_first=get_code_first(code,search_in_ancestors=search_in_ancestors,prioritize_blocks=prioritize_blocks)
|
|
394
440
|
if code_first!="":
|
|
395
441
|
str = str + "\ncode first:\n" + code_first
|
|
442
|
+
code_also=get_code_also(code,search_in_ancestors=search_in_ancestors,prioritize_blocks=prioritize_blocks)
|
|
443
|
+
if code_also!="":
|
|
444
|
+
str = str + "\ncode also:\n" + code_also
|
|
445
|
+
notes=get_notes(code,search_in_ancestors=search_in_ancestors,prioritize_blocks=prioritize_blocks)
|
|
446
|
+
if notes!="":
|
|
447
|
+
str = str + "\nnotes:\n" + notes
|
|
396
448
|
if node.children==[]:
|
|
397
449
|
str = str + "\nChildren:\nNone--"
|
|
398
450
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: simple_icd_10_cm
|
|
3
|
-
Version: 1.
|
|
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
|
|
@@ -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)
|
|
@@ -70,6 +72,7 @@ A simple python library for ICD-10-CM codes
|
|
|
70
72
|
* [Conclusion](#conclusion)
|
|
71
73
|
|
|
72
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
|
|
73
76
|
* **1.3.0**:
|
|
74
77
|
* Users can now use their preferred ICD-10-CM release by providing properly formatted files as inputs
|
|
75
78
|
* The default ICD-10-CM release of the library is now the **April 2025 release**
|
|
@@ -89,7 +92,7 @@ The objective of this library is to provide a simple instrument for dealing with
|
|
|
89
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).
|
|
90
93
|
There is also a Java version of this library, [SimpleICD10CM-Java-edition](https://github.com/StefanoTrv/SimpleICD10CM-Java-edition).
|
|
91
94
|
|
|
92
|
-
The data used in this library was taken from the [website of the CDC](
|
|
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.
|
|
93
96
|
|
|
94
97
|
If you feel like supporting me, please check out the [Conclusion section](#conclusion).
|
|
95
98
|
|
|
@@ -347,6 +350,30 @@ cm.get_code_first("S04.01")
|
|
|
347
350
|
cm.get_code_first("S04.01",search_in_ancestors=True)
|
|
348
351
|
#'any associated intracranial injury (S06.-)'
|
|
349
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
|
+
```
|
|
350
377
|
### get_full_data(code, search_in_ancestors=False, prioritize_blocks=False)
|
|
351
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).
|
|
352
379
|
```python
|
|
@@ -489,7 +516,8 @@ If you find this library useful and are feeling generous, consider making a dona
|
|
|
489
516
|
|
|
490
517
|
---
|
|
491
518
|
|
|
492
|
-
|
|
519
|
+
[](https://ko-fi.com/J3J81G2OSG)
|
|
520
|
+
[](https://www.paypal.com/donate?hosted_button_id=9HMMFAZE248VN)
|
|
493
521
|
|
|
494
522
|
Curecoin: BKxCWuWzsqtLzAvAjtpsHpJ7LqFHPubqft
|
|
495
523
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm/data/code-list-April-2025.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_icd_10_cm-1.3.0 → simple_icd_10_cm-1.4.0}/simple_icd_10_cm.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|