opensafely-core / opensafely-core/opencodelists

Allow downloads of ICD-10 codelists with HES-specific "X" padding

Open
#3,201 2 comments 0 reactions 0 assignees View on GitHub

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?

  1. Modify codelists/models.py::CodelistVersion.csv_data_for_download to have an optional kwarg of omit-hes-appended-x, add logic to conditionally append "X" to three-character codes in the returned csv data if this kwarg is True and the coding system is icd10.
  2. Modify codelists/views/version_download.py::version_download to handle a URL parameter of omit-hes-appended-x.
  3. Modify templates/codelists/version.html, specifically the div with a class of version_sidebar, to add a conditional block which checks if clv.coding_system == "icd10" which writes two buttons of class btn btn-outline-primary.
    1. 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 }}".
    2. 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"
  4. Add an explanation of the "X" padding behaviour to the APCS page on OpenSAFELY docs
  5. Modify templates/codelists/_about_tab.html to include the following in the div of class small 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 %}

Defining delivery tasks guidance

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.