Metadata-Version: 2.4
Name: codedx
Version: 0.1.0
Summary: Swedish medical coding used for diagnosis codes
Author-email: Ludvig Hult <ludvig.hult@gmail.com>
Requires-Python: >=3.12
Requires-Dist: fastexcel>=0.7
Requires-Dist: polars>=1.0
Description-Content-Type: text/markdown

# codeDx

**codeDx** (pronounced *code-dex*) is a codex for medical diagnosis codes — a lookup library for Swedish healthcare datasets. Install as `pip install codedx`, import as `import codedx`.

Built for regional datasets where ICD-10-SE (specialist care), KSH97-P (primary care), and rehab function codes coexist across many years and releases.

```python
import codedx

# J440 exists in WHO, ICD-10-CM and ICD-10-SE
codedx.get_name("J440")               # 'Chronic obstructive pulmonary disease...'
codedx.get_name("J440", lang="sv")    # 'Kroniskt obstruktiv lungsjukdom...'
codedx.is_icd10who_code("J440")       # True
codedx.is_icd10cm_code("J440")        # True
codedx.is_icd10se_code("J440")        # True

codedx.get_ancestors("R060")          # ('R060', 'R06', 'R00-R09', '18')

# code_systems maps each system to its name in that system
codedx.code_systems("A00")
# {'icd10who': 'Cholera', 'icd10cm': 'Cholera', 'icd10se': 'Kolera'}
codedx.code_systems("UA3290")         # {'rehab': 'Kommunicera, att vara mottagare...'}

# KSH97-P sometimes uses colloquial names — G258 is 'Restless legs' in primary care
# but 'Andra specificerade basalgangliesjukdomar och rörelserubbningar' in ICD-10-SE
codedx.code_systems("G258")
# {'icd10se': 'Andra specificerade basalgangliesjukdomar och rörelserubbningar',
#  'ksh97p': 'Restless legs'}
```

Dots are dropped throughout, matching what is typically found in databases: `A011` not `A01.1`.

## Installation

```bash
pip install codedx
```

Downloads data at install time from Socialstyrelsen, WHO, and CDC. Raw files are not redistributed due to licence restrictions.

> **Note:** Socialstyrelsen is migrating data to Ehälsomyndigheten — download URLs may stop working in the future.
