A simple Java library for ICD-10-CM codes
- Release notes
- Introduction
- Setup
- The format of the codes
- About the file "Instructional Notations.md"
- Blocks containing only one category
- About the special seventh character
- Documentation
- ICD10CMCodesManipulator()
- boolean isValidItem(String code)
- boolean isChapter(String code)
- boolean isBlock(String code)
- boolean isCategory(String code)
- boolean isSubcategory(String code, boolean includeExtendedSubcategories)
- boolean isSubcategory(String code)
- boolean isExtendedSubcategory(String code)
- boolean isChapterOrBlock(String code)
- boolean isCategoryOrSubcategory(String code)
- String getDescription(String code, boolean prioritizeBlocks)
- String getDescription(String code)
- ArrayList<String> getExcludes1(String code, boolean prioritizeBlocks)
- ArrayList<String> getExcludes1(String code)
- ArrayList<String> getExcludes2(String code, boolean prioritizeBlocks)
- ArrayList<String> getExcludes2(String code)
- ArrayList<String> getIncludes(String code, boolean prioritizeBlocks)
- ArrayList<String> getIncludes(String code)
- ArrayList<String> getInclusionTerm(String code, boolean prioritizeBlocks)
- ArrayList<String> getInclusionTerm(String code)
- String getSevenChrNote(String code,boolean searchInAncestors, boolean prioritizeBlocks)
- String getSevenChrNote(String code)
- HashMap<String, String> getSevenChrDef(String code,boolean searchInAncestors, boolean prioritizeBlocks)
- HashMap<String, String> getSevenChrDef(String code)
- String getUseAdditionalCode(String code,boolean searchInAncestors, boolean prioritizeBlocks)
- String getUseAdditionalCode(String code)
- String getCodeFirst(String code,boolean searchInAncestors, boolean prioritizeBlocks)
- String getCodeFirst(String code)
- String getFullData(String code,boolean searchInAncestors, boolean prioritizeBlocks)
- String getFullData(String code)
- String getParent(String code, boolean prioritizeBlocks)
- String getParent(String code)
- ArrayList<String> getChildren(String code, boolean prioritizeBlocks)
- ArrayList<String> getChildren(String code)
- ArrayList<String> getAncestors(String code, boolean prioritizeBlocks)
- ArrayList<String> getAncestors(String code)
- ArrayList<String> getDescendants(String code, boolean prioritizeBlocks)
- ArrayList<String> getDescendants(String code)
- boolean isAncestor(String a, String b, boolean prioritizeBlocksA, boolean prioritizeBlocksB)
- boolean isAncestor(String a, String b)
- boolean isDescendant(String a, String b, boolean prioritizeBlocksA, boolean prioritizeBlocksB)
- boolean isDescendant(String a, String b)
- String getNearestCommonAncestor(String a, String b, boolean prioritizeBlocksA, boolean prioritizeBlocksB)
- String getNearestCommonAncestor(String a, String b)
- boolean isLeaf(String code, boolean prioritizeBlocks)
- boolean isLeaf(String code)
- ArrayList<String> getAllCodes(boolean withDots)
- ArrayList<String> getAllCodes()
- int getIndex(String code)
- String removeDot(String code)
- String addDot(String code)
- Conclusion
- 1.0.0: Inital release
The objective of this library is to provide a simple instrument for dealing with ICD-10-CM codes in Java. 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.
If you are looking for a library that deals with ICD-10 codes instead of ICD-10-CM codes, you can check the SimpleICD10-Java-edition, which is based on the 2019 version of ICD-10.
If you are looking for a Python version of this project, you can check the simple_icd_10_cm library.
The data used in this library was taken from the websites of the CDC and of the CMS. This library currently uses the January 2021 release of ICD-10-CM.
All the classes in this library are contained in the package "it.trvi.simpleicd10cm
".
SimpleICD10CM-Java-edition uses the library EasyXML to parse the XML code that contains the data of the ICD-10-CM classification.
You can download the jar containing the most recent recent version of this library from the releases page on Github.
The codes of subcategories can be written in two different ways: with a dot (for example "I13.1") and with no dot (for example "I131"). The methods 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.
You can easily change the format of a code by using the removeDot
and addDot
functions.
The file Instructional Notations.md contains the introduction present in the file icd10cm_tabular_2021.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.
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:
cm.isBlock("B99")
//true
cm.isCategory("B99")
//true
To solve this ambiguity, I've introduced in most methods the parameter prioritizeBlocks
. This parameter has an effect only when the string passed as input could be the name of a category or of its parent block: when this ambiguity is not present, the value of this parameter won't have any impact on the computation. When prioritizeBlocks
is false, which is the default value when its omitted by using overloading, the ambiguous code will be interpreted as the category, when it's set to true the same code will be interpreted as being the block. The following code shows an example of this in action:
cm.getChildren("B99")
//[B99.8, B99.9]
cm.getChildren("B99",true)
//[B99]
If you want to know if a specific code is ambiguous, it's pretty simple: you just have to check if it's at the same time a block and a category, as in the following examples:
cm.isBlock("B10") && cm.isCategory("B10")
//true
cm.isBlock("I12") && cm.isCategory("I12")
//false
The file icd10cm_tabular_2021.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.
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 (for example in the file icd10cm-order-Jan-2021.txt
), so it's not my invention but the actual official format. All the other fields are empty, but the optional argument searchInAncestors
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 for more details).
If you need to know whether a code has been automatically generated using a rule described in a "sevenChrDef" field, you can use the isExtendedSubcategory
method.
This library is comprised of a single class, ICD10CMCodesManipulator. When an object of this class is instantiated, it loads all the relevant data and creates the appropriate data structures to work effectively with it. It's through these objects that the functionalities of this library can be accessed.
This class is contained in the package "it.trvi.simpleicd10cm
".
ICD10CMCodesManipulator cm = new ICD10CMCodesManipulator();
The constructor that reads the data from the XML file to load all the data relative to the ICD-10-CM classification.
ICD10CMCodesManipulator cm = new ICD10CMCodesManipulator();
It checks whether a String is a valid chapter, block, category or subcategory in ICD-10-CM.
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM code, otherwise false
cm.isValidItem("cat")
//false
cm.isValidItem("B99")
//true
It checks whether a String is a valid chapter in ICD-10-CM.
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM chapter, otherwise false
cm.isChapter("12")
//true
cm.isChapter("B99")
//false
It checks whether a String is a valid block in ICD-10-CM.
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM block, otherwise false
cm.isBlock("L80-L99")
//true
cm.isBlock("L99")
//false
It checks whether a String is a valid category in ICD-10-CM.
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM category, otherwise false
cm.isCategory("B99")
//true
cm.isCategory("14")
//false
It checks whether a String is a valid subcategory in ICD-10-CM.
By changing the value of includeExtendedSubcategories
, it's possible to chose whether valid subcategories obtained by adding the 7th character to another code are included or not (see Instructional Notations for more information).
Parameters:
code
is the String that must be checked
includeExtendedSubcategories
when it's true valid subcategories obtained by adding the 7th character to another code are considered as subcategories, otherwise they are not
Returns:
true if code is a valid ICD-10-CM subcategory, otherwise false
cm.isSubcategory("B95.1")
//true
cm.isSubcategory("B99")
//false
cm.isSubcategory("S12.000G")
//true
cm.isSubcategory("S12.000G",false)
//false
It checks whether a String is a valid subcategory in ICD-10-CM. Valid subcategories obtained by adding the 7th character to another code are always included (see Instructional Notations for more information).
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM subcategory, otherwise false
It checks whether a String is a valid subcategory obtained by adding the 7th character to another code in ICD-10-CM (see Instructional Notations and About the special seventh character for more information).
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM subcategory, otherwise false
cm.isExtendedSubcategory("S12.000G")
//true
cm.isExtendedSubcategory("S12.000")
//false
It checks whether a String is a valid chapter or block in ICD-10-CM.
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM chapter or block, otherwise false
cm.isChapterOrBlock("L80-L99")
//true
cm.isChapterOrBlock("L99")
//false
It checks whether a String is a valid category or subcategory in ICD-10-CM.
Parameters:
code
is the String that must be checked
Returns:
true if code is a valid ICD-10-CM category or subcategory, otherwise false
cm.isCategoryOrSubcategory("B99")
//true
cm.isCategoryOrSubcategory("A00-B99")
//false
Given a String that contains an ICD-10-CM code, it returns the description of said code.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
the description of code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getDescription("12")
//"Diseases of the skin and subcutaneous tissue (L00-L99)"
cm.getDescription("I70.501")
//"Unspecified atherosclerosis of nonautologous biological bypass graft(s) of the extremities, right leg"
Given a String that contains an ICD-10-CM code, it returns the description of said code.
Version of getDescription
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
the description of code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "excludes1" field of this code. If this code does not have an "excludes1" field, it returns an empty ArrayList<String>. Please see Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> containing the data of the "excludes1" field of this code, an empty ArrayList<String> if this code does not have an "excludes1" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getExcludes1("12")
//[]
cm.getExcludes1("I82.40")
//[acute embolism and thrombosis of unspecified deep veins of distal lower extremity (I82.4Z-), acute embolism and thrombosis of unspecified deep veins of proximal lower extremity (I82.4Y-)]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "excludes1" field of this code.
If this code does not have an "excludes1" field, it returns an empty ArrayList<String>.
Version of getExcludes1
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter and Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> containing the data of the "excludes1" field of this code, an empty ArrayList<String> if this code does not have an "excludes1" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "excludes2" field of this code. If this code does not have an "excludes2" field, it returns an empty ArrayList<String>. Please see Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> containing the data of the "excludes2" field of this code, an empty ArrayList<String> if this code does not have an "excludes2" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getExcludes2("I82.40")
//[]
cm.getExcludes2("J34.81")
//[gastrointestinal mucositis (ulcerative) (K92.81), mucositis (ulcerative) of vagina and vulva (N76.81), oral mucositis (ulcerative) (K12.3-)]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "excludes2" field of this code.
If this code does not have an "excludes2" field, it returns an empty ArrayList<String>.
Version of getExcludes2
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter and Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> containing the data of the "excludes2" field of this code, an empty ArrayList<String> if this code does not have an "excludes2" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "includes" field of this code. If this code does not have an "includes" field, it returns an empty ArrayList<String>. Please see Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> containing the data of the "includes" field of this code, an empty ArrayList<String> if this code does not have an "includes" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getIncludes("I82.40")
//[]
cm.getIncludes("J36")
//[abscess of tonsil, peritonsillar cellulitis, quinsy]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "includes" field of this code.
If this code does not have an "includes" field, it returns an empty ArrayList<String>.
Version of getIncludes
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter and Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> containing the data of the "includes" field of this code, an empty ArrayList<String> if this code does not have an "includes" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "inclusionTerm" field of this code. If this code does not have an "inclusionTerm" field, it returns an empty ArrayList<String>.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> containing the data of the "inclusionTerm" field of this code, an empty ArrayList<String> if this code does not have an "inclusionTerm" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getInclusionTerm("A23")
//[]
cm.getInclusionTerm("J37.0")
//[Catarrhal laryngitis, Hypertrophic laryngitis, Sicca laryngitis]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing the data of the "inclusionTerm" field of this code.
If this code does not have an "inclusionTerm" field, it returns an empty ArrayList<String>.
Version of getInclusionTerm
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> containing the data of the "inclusionTerm" field of this code, an empty ArrayList<String> if this code does not have an "inclusionTerm" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns a String containing the data of the "sevenChrNote" field of this code. If this code does not have an "sevenChrNote" field, it returns an empty String. Please see Instructional Notations and About the special seventh character if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
searchInAncestors
if it's 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
prioritizeBlocks
please see Blocks containing only one category
Returns:
a String containing the data of the "sevenChrNote" field of this code, an empty String if this code does not have an "sevenChrNote" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getSevenChrNote("I82.40")
//""
cm.getSevenChrNote("M48.4")
//"The appropriate 7th character is to be added to each code from subcategory M48.4:"
cm.getSevenChrNote("R40.241")
//""
cm.getSevenChrNote("R40.241",true,false)
//"The following appropriate 7th character is to be added to subcategory R40.24-:"
Given a String that contains an ICD-10-CM code, it returns a String containing the data of the "sevenChrNote" field of this code.
If this code does not have an "sevenChrNote" field, it returns an empty String.
Version of getSevenChrNote
where the parameters searchInAncestors
and prioritizeBlocks
are implicitly false.
Please see getSevenChrNote(String, boolean, boolean) for the meaning of the missing parameters and Instructional Notations and About the special seventh character if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
a String containing the data of the "sevenChrNote" field of this code, an empty String if this code does not have an "sevenChrNote" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
HashMap<String, String> getSevenChrDef(String code,boolean searchInAncestors, boolean prioritizeBlocks)
Given a String that contains an ICD-10-CM code, it returns a HashMap<String, String> containing the data of the "sevenChrDef" field of this code. If this code does not have an "sevenChrDef" field, it returns an empty HashMap<String, String>. Please see Instructional Notations and About the special seventh character if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
searchInAncestors
if it's 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
prioritizeBlocks
please see Blocks containing only one category
Returns:
a HashMap<String, String> containing the data of the "sevenChrDef" field of this code, an empty HashMap<String, String> if this code does not have an "sevenChrDef" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getSevenChrDef("I82.40")
//{}
cm.getSevenChrDef("M48.4")
//{A=initial encounter for fracture, S=sequela of fracture, D=subsequent encounter for fracture with routine healing, G=subsequent encounter for fracture with delayed healing}
cm.getSevenChrDef("R40.241")
//{}
cm.getSevenChrDef("R40.241",true,false)
//{0=unspecified time, 1=in the field [EMT or ambulance], 2=at arrival to emergency department, 3=at hospital admission, 4=24 hours or more after hospital admission}
Given a String that contains an ICD-10-CM code, it returns a HashMap<String, String> containing the data of the "sevenChrDef" field of this code.
If this code does not have an "sevenChrDef" field, it returns an empty HashMap<String, String>.
Version of getSevenChrDef
where the parameters searchInAncestors
and prioritizeBlocks
are implicitly false.
Please see getSevenChrDef(String, boolean, boolean) for the meaning of the missing parameters and Instructional Notations and About the special seventh character if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
a HashMap<String, String> containing the data of the "sevenChrDef" field of this code, an empty HashMap<String, String> if this code does not have an "sevenChrDef" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns a String containing the data of the "useAdditionalCode" field of this code. If this code does not have an "useAdditionalCode" field, it returns an empty String. Please see Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
searchInAncestors
if it's set to true, if the given code doesn't have a "useAdditionalCode" field but one of its ancestor does, the "useAdditionalCode" data of the closer ancestor that contains such a field is returned
prioritizeBlocks
please see Blocks containing only one category
Returns:
a String containing the data of the "useAdditionalCode" field of this code, an empty String if this code does not have an "useAdditionalCode" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getUseAdditionalCode("I82.41")
//""
cm.getUseAdditionalCode("R50.2")
//"code for adverse effect, if applicable, to identify drug (T36-T50 with fifth or sixth character 5)"
cm.getUseAdditionalCode("R65.20")
//""
cm.getUseAdditionalCode("R65.20",true,false)
//"code to identify specific acute organ dysfunction, such as:
// acute kidney failure (N17.-)
// acute respiratory failure (J96.0-)
// critical illness myopathy (G72.81)
// critical illness polyneuropathy (G62.81)
// disseminated intravascular coagulopathy [DIC] (D65)
// encephalopathy (metabolic) (septic) (G93.41)
// hepatic failure (K72.0-)"
Given a String that contains an ICD-10-CM code, it returns a String containing the data of the "useAdditionalCode" field of this code.
If this code does not have an "useAdditionalCode" field, it returns an empty String.
Version of getUseAdditionalCode
where the parameters searchInAncestors
and prioritizeBlocks
are implicitly false.
Please see getUseAdditionalCode(String, boolean, boolean) for the meaning of the missing parameters and Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
a String containing the data of the "useAdditionalCode" field of this code, an empty String if this code does not have an "useAdditionalCode" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns a String containing the data of the "codeFirst" field of this code. If this code does not have an "codeFirst" field, it returns an empty String. Please see Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
searchInAncestors
if it's 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
prioritizeBlocks
please see Blocks containing only one category
Returns:
a String containing the data of the "codeFirst" field of this code, an empty String if this code does not have an "codeFirst" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getCodeFirst("I82.41")
//""
cm.getCodeFirst("R68.13")
//"confirmed diagnosis, if known"
cm.getCodeFirst("S04.01")
//""
cm.getCodeFirst("S04.01",true,false)
//"any associated intracranial injury (S06.-)"
Given a String that contains an ICD-10-CM code, it returns a String containing the data of the "codeFirst" field of this code.
If this code does not have an "codeFirst" field, it returns an empty String.
Version of getCodeFirst
where the parameters searchInAncestors
and prioritizeBlocks
are implicitly false.
Please see getCodeFirst(String, boolean, boolean) for the meaning of the missing parameters and Instructional Notations if you have doubts about the meaning of this field.
Parameters:
code
is the ICD-10-CM code
Returns:
a String containing the data of the "codeFirst" field of this code, an empty String if this code does not have an "codeFirst" field
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns a String containing all the available data of the code. The empty fields are omitted from the String, except for the list of children (see the examples below).
Parameters:
code
is the ICD-10-CM code
searchInAncestors
if it's 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
prioritizeBlocks
please see Blocks containing only one category
Returns:
a String containing all the available data of the code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getFullData("I82.41")
//"Name:
// I82.41
// Description:
// Acute embolism and thrombosis of femoral vein
// Parent:
// I82.4
// inclusion term:
// Acute embolism and thrombosis of common femoral vein
// Acute embolism and thrombosis of deep femoral vein
// Children:
// I82.411, I82.412, I82.413, I82.419"
cm.getFullData("C8401")
//"Name:
// C84.01
// Description:
// Mycosis fungoides, lymph nodes of head, face, and neck
// Parent:
// C84.0
// Children:
// None"
Given a String that contains an ICD-10-CM code, it returns a String containing all the available data of the code.
The empty fields are omitted from the String, except for the list of children.
Version of getFullData
where the parameters searchInAncestors
and prioritizeBlocks
are implicitly false.
Please see getFullData(String, boolean, boolean) for the meaning of the missing parameters.
Parameters:
code
is the ICD-10-CM code
Returns:
a String containing all the available data of the code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns a String containing its parent in the ICD-10-CM classification. If the code doesn't have a parent (that is, if it's a chapter), it returns an empty String.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
a String containing the parent of the code, or an empty String if it does not have a parent
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getParent("I70.501")
//"I70.50"
cm.getParent("12")
//""
Given a String that contains an ICD-10-CM code, it returns a String containing its parent in the ICD-10-CM classification.
If the code doesn't have a parent (that is, if it's a chapter), it returns an empty String.
Version of getParent
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
a String containing the parent of the code, or an empty String if it does not have a parent
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing its children in the ICD-10-CM classification. If the code doesn't have any children, it returns an empty ArrayList<String>.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> of strings containing its children, or an empty ArrayList<String> if it does not have any children
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getChildren("12")
//[L00-L08, L10-L14, L20-L30, L40-L45, L49-L54, L55-L59, L60-L75, L76, L80-L99]
cm.getChildren("I70.501")
//[]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing its children in the ICD-10-CM classification.
If the code doesn't have any children, it returns an empty ArrayList<String>.
Version of getParent
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> of strings containing its children, or an empty ArrayList<String> if it does not have any children
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing all its ancestors in the ICD-10-CM classification. The results are ordered from its parent to its most distant ancestor.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> containing the ancestors of code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getAncestors("S14.109S")
//[S14.109, S14.10, S14.1, S14, S10-S19, 19]
cm.getAncestors("7")
//[]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing all its ancestors in the ICD-10-CM classification.
The results are ordered from its parent to its most distant ancestor.
Version of getAncestors
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> containing the ancestors of code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing all its descendants in the ICD-10-CM classification. The returned codes are ordered as in a pre-order depth-first traversal of the tree containing the ICD-10-CM classification.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
an ArrayList<String> containing the descendants of code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getDescendants("G93")
//[G93.0, G93.1, G93.2, G93.3, G93.4, G93.40, G93.41, G93.49, G93.5, G93.6, G93.7, G93.8, G93.81, G93.82, G93.89, G93.9]
cm.getDescendants("S14.109S")
//[]
Given a String that contains an ICD-10-CM code, it returns an ArrayList<String> containing all its descendants in the ICD-10-CM classification.
The returned codes are ordered as in a pre-order depth-first traversal of the tree containing the ICD-10-CM classification.
Version of getDescendants
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
an ArrayList<String> containing the descendants of code
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
It checks whether a code (a
) is one of the ancestors of another code (b
). A code is never an ancestor of itself.
Parameters:
a
is the code that may or may not be an ancestor of b
b
is the code that whose ancestors could include a
prioritizeBlocksA
prioritizeBlocks referred to the code in a, please see Blocks containing only one category
prioritizeBlocksB
prioritizeBlocks referred to the code in b, please see Blocks containing only one category
Returns:
true if a is one of the ancestors of b, false otherwise
Throws:
IllegalArgumentException
if a or b are not a valid ICD-10-CM code
cm.isAncestor("18","R01.0")
//true
cm.isAncestor("K00-K14","M31")
//false
cm.isAncestor("B99","B99")
//false
cm.isAncestor("B99","B99",true,false)
//true
It checks whether a code (a
) is one of the ancestors of another code (b
). A code is never an ancestor of itself.
Version of isAncestor
where the parameters prioritizeBlocksA
and prioritizeBlocksB
are implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameters.
Parameters:
a
is the code that may or may not be an ancestor of b
b
is the code that whose ancestors could include a
Returns:
true if a is one of the ancestors of b, false otherwise
Throws:
IllegalArgumentException
if a or b are not a valid ICD-10-CM code
It checks whether a code (a
) is one of the descendants of another code (b
). A code is never a descendant of itself.
Parameters:
a
is the code that may or may not be a descendant of b
b
is the code that whose descendants could include a
prioritizeBlocksA
prioritizeBlocks referred to the code in a, please see Blocks containing only one category
prioritizeBlocksB
prioritizeBlocks referred to the code in b, please see Blocks containing only one category
Returns:
true if a is one of the descendants of b, false otherwise
Throws:
IllegalArgumentException
if a or b are not a valid ICD-10-CM code
cm.isDescendant("R01.0","18")
//true
cm.isDescendant("M31","K00-K14")
//false
It checks whether a code (a
) is one of the descendants of another code (b
). A code is never a descendant of itself.
Version of isDescendant
where the parameters prioritizeBlocksA
and prioritizeBlocksB
are implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameters.
Parameters:
a
is the code that may or may not be a descendant of b
b
is the code that whose descendants could include a
Returns:
true if a is one of the descendants of b, false otherwise
Throws:
IllegalArgumentException
if a or b are not a valid ICD-10-CM code
String getNearestCommonAncestor(String a, String b, boolean prioritizeBlocksA, boolean prioritizeBlocksB)
Given two ICD-10-CM codes a
and b
, it returns their nearest common ancestor in the ICD-10-CM classification (or an empty string if they don't have a nearest common ancestor).
Parameters:
a
is an ICD-10-CM code
b
is an ICD-10-CM code
prioritizeBlocksA
prioritizeBlocks referred to the code in a, please see Blocks containing only one category
prioritizeBlocksB
prioritizeBlocks referred to the code in b, please see Blocks containing only one category
Returns:
the nearest common ancestor of a and b if it exists, an empty string otherwise
Throws:
IllegalArgumentException
if a or b are not a valid ICD-10-CM code
cm.getNearestCommonAncestor("H28","H25.1")
//"H25-H28"
cm.getNearestCommonAncestor("K35","E21.0")
//""
Given two ICD-10-CM codes a
and b
, it returns their nearest common ancestor in the ICD-10-CM classification (or an empty string if they don't have a nearest common ancestor).
Version of getNearestCommonAncestor
where the parameters prioritizeBlocksA
and prioritizeBlocksB
are implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameters.
Parameters:
a
is an ICD-10-CM code
b
is an ICD-10-CM code
Returns:
the nearest common ancestor of a and b if it exists, an empty string otherwise
Throws:
IllegalArgumentException
if a or b are not a valid ICD-10-CM code
Given a String that contains an ICD-10-CM code, it checks whether that code is a leaf in the ICD-10 classification.
Parameters:
code
is the ICD-10-CM code
prioritizeBlocks
please see Blocks containing only one category
Returns:
true if code is a leaf in the ICD-10-CM classification (that is, if it has no children), false otherwise
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.isLeaf("12")
//false
cm.isLeaf("I70.501")
//true
Given a String that contains an ICD-10-CM code, it checks whether that code is a leaf in the ICD-10 classification.
Version of isLeaf
where the parameter prioritizeBlocks
is implicitly false.
Please see Blocks containing only one category for the meaning of the missing parameter.
Parameters:
code
is the ICD-10-CM code
Returns:
true if code is a leaf in the ICD-10-CM classification (that is, if it has no children), false otherwise
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
It returns an ArrayList<String> that contains all the codes in the ICD-10-CM classification, ordered as in a depth-first pre-order visit.
Parameters:
withDots
is a boolean that controls whether the codes in the list that is returned are in the format with or without the dot.
Returns:
the list of all the codes in the ICD-10-CM classification, ordered as in a depth-first pre-order visit, in the format with the dot if withDots is true, in the format without the dot otherwise
It returns an ArrayList<String> that contains all the codes in the ICD-10-CM classification, ordered as in a depth-first pre-order visit.
Returns:
the list of all the codes in the ICD-10-CM classification, ordered as in a depth-first pre-order visit, in the format with the dot
cm.getAllCodes()
//[1, A00-A09, A00, A00.0, A00.1, A00.9, A01, A01.0, A01.00, A01.01, ...
cm.getAllCodes(false)
//[1, A00-A09, A00, A000, A001, A009, A01, A010, A0100, A0101, ...
It returns the index of a particular code in the list returned by getAllCodes
.
Parameters:
code
is the code whose index we want to find
Returns:
the index of code in the list returned by getAllCodes
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.getIndex("P00")
//27735
cm.getAllCodes().get(27735)
//"P00"
Given an ICD-10-CM code, it returns the same code in the format without the dot.
Parameters:
code
is an ICD-10-CM code
Returns:
the same code in the format without the dot
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.removeDot("C84.Z0")
//"C84Z0"
cm.removeDot("C84Z0")
//"C84Z0"
cm.removeDot("K00-K14")
//"K00-K14"
Given an ICD-10-CM code, it returns the same code in the format with the dot.
Parameters:
code
is an ICD-10-CM code
Returns:
the same code in the format with the dot
Throws:
IllegalArgumentException
if code is not a valid ICD-10-CM code
cm.addDot("C84Z0")
//"C84.Z0"
cm.addDot("C84.Z0")
//"C84.Z0"
cm.addDot("K00-K14")
//"K00-K14"
This should be everything you need to know about the SimpleICD10CM-Java-edition 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. 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. This library currently only support the January 2021 release of ICD-10-CM: let me know if you'd like me to implement the ability to switch between different versions of ICD-10-CM, and also tell me which release or releases you are interested in.
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.
Stefano Travasci
Curecoin: BMq2siLdqgF1htamKcrRPedUE4CBTRsZsT
Bitcoin: bc1qea8l4xge32ylw00l4dqrdjhzw72lu3hkg9fnlq
let me know if your favorite donation method is not in this list