CID-10
The Brazilian edition of the ICD-10 (CID-10), the disease classification codes DATASUS publishes.
Validate
Checks whether a CID-10 category or subcategory exists in the Brazilian tables DATASUS publishes.
- Accepts a category (3 characters,
A00) or a subcategory (4 characters), with the dot (A00.0) or without it (A000). Letter case and surrounding whitespace are ignored. - Other separators (
A00-0), a fifth character, a dagger or asterisk suffix and a value that is not a string are rejected. - A subcategory is valid only when the table lists it under its category.
I10.0is invalid because I10 has no subcategories;I10is valid as a category. - Data: CID-10 V2008 of DATASUS, 2045 categories and 12188 subcategories, plus U07, U07.0, U07.1 and U07.2 from the SIM table of DATASUS (COVID-19 codes among them). Codes the WHO added later, such as U09.9 and U10.9, are invalid.
- The
codCIDlayout of eSocial event S-2230 was not checked against this function.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | boolean |
Check if a CID-10 code exists in the tables DATASUS publishes, the Brazilian Portuguese edition of the ICD-10 (Classificação Estatística Internacional de Doenças e Problemas Relacionados à Saúde, 10th revision), the code medical certificates and health systems carry.
- Both levels of the classification are valid: the 3 character categories (
A00) and the 4 character subcategories, written with the dot (A00.0) or without it (A000). - Letter case and surrounding whitespace are ignored. Anything else (another separator, a fifth character, a dagger or asterisk suffix, a value that is not a string) is rejected.
- The tables are the DATASUS V2008 ones, plus the
U07category of the CID-10 table DATASUS keeps for the SIM (U07,U07.0,U07.1COVID-19 virus identified andU07.2virus not identified), which the V2008 files predate. A code in neither is not found, such asU09.9(post COVID-19 condition) andU10.9(multisystem inflammatory syndrome associated with COVID-19). Up to 2.4.0 theU07codes were not found either. - Only a table of codes is read (about 7 KB minified), not the descriptions
getCid10carries.
import { isValidCid10 } from '@brazilian-utils/brazilian-utils';
isValidCid10('A00.0'); // true
isValidCid10('a000'); // true
isValidCid10('A00'); // true (a category)
isValidCid10('I10'); // true (a category that is not subdivided)
isValidCid10('A00.5'); // false (A00 has no subcategory 5)
isValidCid10('I10.0'); // false (I10 has no subcategories)
isValidCid10('A00-0'); // false (not a documented form)Try it with JavaScript isValidCid10
Shared test cases (27) and the result in each library cid10.isValid
Format
Formats a CID-10 code the way it is printed: upper case, with a dot between the 3-character category and the fourth character (A00.0). Only the structure changes (use cid10.isValid to check the code).
- The mask is applied as far as the value goes. A category stays without a dot (
A00). The dot shows up with the fourth character. - Only the letters A to Z (any case) and the digits 0 to 9 are read; every other character is dropped, accented letters included. The result is capped at 4 characters plus the dot. The mask does not check which characters are letters and which are digits (
"1234"gives123.4). - A value that is not a string returns an empty string.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | string |
Format a CID-10 code the way it is printed: upper case, with a dot between the 3 character category and the fourth character of the subcategory. Only the structure changes; use isValidCid10 to check a code against the tables.
- The mask is applied as far as the value goes, so a category stays as it is and the dot only shows up with the fourth character.
- Characters outside the mask are dropped and the value is capped at 4 characters.
import { formatCid10 } from '@brazilian-utils/brazilian-utils';
formatCid10('A000'); // A00.0
formatCid10('f322'); // F32.2
formatCid10('A00'); // A00 (a category has no dot)
formatCid10('A00.0'); // A00.0Try it with JavaScript formatCid10
Shared test cases (16) and the result in each library cid10.format
Parse
Removes the formatting of a CID-10 code and returns it in upper case without the dot, the form the DATASUS tables store.
- Keeps only letters and digits, capped at 4 characters. A shorter value (a category, or a code being typed) passes through as far as it goes.
- It does not check the code against the table (use
cid10.isValid). - A value that is not a string returns an empty string.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | string |
Remove CID-10 formatting, keep only letters and digits, upper case them and cap the result to the 4 characters of a subcategory, the form the DATASUS tables store.
- A shorter value passes through as far as it goes.
import { parseCid10 } from '@brazilian-utils/brazilian-utils';
parseCid10('A00.0'); // 'A000'
parseCid10('f32.2'); // 'F322'
parseCid10('A00'); // 'A00'Try it with JavaScript parseCid10
Shared test cases (13) and the result in each library cid10.parse
Look up
Looks up a CID-10 category or subcategory in the DATASUS tables and returns its code and official Portuguese description.
- Same input rules as
cid10.isValid. Returnsnullexactly when that function returnsfalse. - The returned code is upper case and without the dot (
A000). - Same table as
cid10.isValid: the DATASUS V2008 tables plus the U07 codes of the SIM table (U07.1is{ code: "U071", description: "Infecção pelo novo Coronavírus (COVID-19)" }). U09.9 and U10.9 are not found.
| Parameter | Type | Required |
|---|---|---|
value | string | yes |
| returns | Cid10 | null |
Look a CID-10 code up and get its official Brazilian Portuguese description. The result is a Cid10 record: { code, description }.
- Same input rules as
isValidCid10.codeis upper case and has no dot. Returnsnullwhen the code is unknown or the value is not in a documented form. - Same table as
isValidCid10: the DATASUS V2008 one plus theU07codes of the SIM table (getCid10('U07.1')is{ code: 'U071', description: 'Infecção pelo novo Coronavírus (COVID-19)' });U09.9andU10.9are not found. - This is the heaviest util of the package: it embeds the 2046 categories and 12191 subcategories with their descriptions, about 722 KB minified (113 KB gzipped). Load it lazily through its subpath, as shown in Bundle size, and use
isValidCid10when the description is not needed.
import { getCid10 } from '@brazilian-utils/brazilian-utils';
getCid10('A00.0'); // { code: 'A000', description: 'Cólera devida a Vibrio cholerae 01, biótipo cholerae' }
getCid10('a000'); // { code: 'A000', description: 'Cólera devida a Vibrio cholerae 01, biótipo cholerae' }
getCid10('A00'); // { code: 'A00', description: 'Cólera' }
getCid10('A00.5'); // null
getCid10('A00-0'); // null (not a documented form)Source: CID-10 V2008 tables DATASUS publishes as CSV and the CID-10 table of the SIM for the U07 codes.
Try it with JavaScript getCid10
Shared test cases (26) and the result in each library cid10.get
Official sources
- www2.datasus.gov.br/cid10/V2008/…/descrcsv.htm
- www2.datasus.gov.br/cid10/V2008/…/CID10CSV.zip
- ftp.datasus.gov.br/dissemin/publicos/…/CID10.DBF
See also CNS (SUS card)
Last updated on
