Skip to content

Commit

Permalink
Add getters for ICD10, ICD11, and ICF (#43)
Browse files Browse the repository at this point in the history
* Create icd11.py

* Update

* Add icd10
  • Loading branch information
cthoyt authored Mar 25, 2024
1 parent f1a7879 commit 10d074b
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/bioversions/sources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
from .guidetopharmacology import GuideToPharmacologyGetter
from .hgnc import HGNCGetter
from .homologene import HomoloGeneGetter
from .icd10 import ICD10Getter
from .icd11 import ICD11Getter
from .icf import ICFGetter
from .intact import IntActGetter
from .interpro import InterProGetter
from .itis import ITISGetter
Expand Down Expand Up @@ -129,6 +132,9 @@ def get_getters() -> List[Type[Getter]]:
CellosaurusGetter,
MGIGetter,
OMIMGetter,
ICFGetter,
ICD10Getter,
ICD11Getter,
]
getters.extend(iter_obo_getters())
extend_ols_getters(getters)
Expand Down
32 changes: 32 additions & 0 deletions src/bioversions/sources/icd10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-

"""A getter for ICD10."""

import requests

from bioversions.utils import Getter, VersionType

__all__ = [
"ICD10Getter",
]

URL = "https://icd.who.int/browse10/"


class ICD10Getter(Getter):
"""A getter for ICD10."""

bioregistry_id = "icd10"
name = "International Classification of Diseases, 10th Revision"
version_type = VersionType.date
date_version_fmt = "%Y"

def get(self) -> str:
"""Get the latest ICD10 version number."""
response = requests.get(URL, allow_redirects=True)
final_url = response.url
return final_url[len("https://icd.who.int/browse10/") :].split("/")[0]


if __name__ == "__main__":
ICD10Getter.print()
32 changes: 32 additions & 0 deletions src/bioversions/sources/icd11.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-

"""A getter for ICD11."""

import requests

from bioversions.utils import Getter, VersionType

__all__ = [
"ICD11Getter",
]

URL = "https://icd.who.int/browse/latest-release/mms/en"


class ICD11Getter(Getter):
"""A getter for ICD11."""

bioregistry_id = "icd11"
name = "International Classification of Diseases, 11th Revision"
version_type = VersionType.date
date_version_fmt = "%Y-%m"

def get(self) -> str:
"""Get the latest ICD11 version number."""
response = requests.get(URL, allow_redirects=True)
final_url = response.url
return final_url[len("https://icd.who.int/browse/") :].split("/")[0]


if __name__ == "__main__":
ICD11Getter.print()
32 changes: 32 additions & 0 deletions src/bioversions/sources/icf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-

"""A getter for ICF."""

import requests

from bioversions.utils import Getter, VersionType

__all__ = [
"ICFGetter",
]

URL = "https://icd.who.int/browse/latest-release/icf/en"


class ICFGetter(Getter):
"""A getter for ICF."""

bioregistry_id = "icf"
name = "International Classification of Functioning, Disability and Health"
version_type = VersionType.date
date_version_fmt = "%Y-%m"

def get(self) -> str:
"""Get the latest ICF version number."""
response = requests.get(URL, allow_redirects=True)
final_url = response.url
return final_url[len("https://icd.who.int/browse/") :].split("/")[0]


if __name__ == "__main__":
ICFGetter.print()

0 comments on commit 10d074b

Please sign in to comment.