opensafely-core / opensafely-core/opencodelists
Allow downloads of ICD-10 codelists with HES-specific "X" padding
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 60
- Forks
- 16
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 17
Description
Why are we doing this?
Three-character ICD-10 codes are appended with an "X" to four character codes in HES/SUS.
This affects the APCS dataset in OpenSAFELY-TPP.
There is an existing issue for how to handle this in ehrQL but it is non-trivial.
We could handle this in OpenCodelists in a manner akin to how we do for the VMP mapping issue in dm+d codelists.
How will we know when it's done?
The default download for an ICD-10 codelists as used by the opensafely CLI tool contains three-character codes (if present in the codelist) both in their original form and with an "X" appended.
There are available two download buttons on an ICD-10 CodelistVersion page - one for the codelists without the appended "X"s and one with.
What are we doing?
- Modify
codelists/models.py::CodelistVersion.csv_data_for_downloadto have an optional kwarg ofomit-hes-appended-x, add logic to conditionally append "X" to three-character codes in the returned csv data if this kwarg isTrueand the coding system isicd10. - Modify
codelists/views/version_download.py::version_downloadto handle a URL parameter ofomit-hes-appended-x. - Modify
templates/codelists/version.html, specifically the div with a class ofversion_sidebar, to add a conditional block which checks ifclv.coding_system == "icd10"which writes twobuttonsof classbtn btn-outline-primary.- The first will have an inner text of
Download CSV <small class="d-block"> with HES/SUS X appended*<small>and an href of"{{ clv.get_download_url }}". - The second will have an inner text of
"Download CSV <small class="d-block"> original</small>"and an href of"{{ clv.get_download_url }}?omit-mapped-vmps"
- The first will have an inner text of
- Add an explanation of the "X" padding behaviour to the APCS page on OpenSAFELY docs
- Modify
templates/codelists/_about_tab.htmlto include the following in thedivof classsmall pt-4:
{% if codelist.coding_system_id == "icd10" %}
<p>
* ICD-10 codelists can be downloaded with three-character codes padded to four-characters with an "X" at the end - this is the default
for an OpenSAFELY project. See the <a href="https://docs.opensafely.org/data-sources/apc/">
documentation the APCS data source</a> for more details.
</p>
{% endif %}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with codelists/models.py::CodelistVersion.csv_data_for_download and codelists/views/version_download.py::version_download, then inspect the version_sidebar in templates/codelists/version.html and templates/codelists/_about_tab.html. Check the APCS documentation page requirements and existing download behavior. Done means ICD-10 downloads offer both padded and original forms, the default includes HES/SUS X padding, and the related explanations appear in the UI and APCS documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, documentation, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100