Skip to content

Allow re-inclusion of previously-deleted orphan codes - #3209

Open
Jongmassey wants to merge 1 commit into
mainfrom
Jongmassey/fix-empty-uploaded
Open

Allow re-inclusion of previously-deleted orphan codes#3209
Jongmassey wants to merge 1 commit into
mainfrom
Jongmassey/fix-empty-uploaded

Conversation

@Jongmassey

Copy link
Copy Markdown
Contributor

Fixes #3206

Orphan codes are codes without related searches. This may be because the search whence they came has been deleted or because the codelist was originally created by upload of a csv file.

Orphan codes that are not either themselves included or descendants of an included code are deleted to avoid a broken state (see #2639 ). However, the UI is not immediately synchronised with the db state after this deletion and so they persist in the UI.
A user may then request inclusion of these deleted-in-the-db-but-persisting-in-the-ui codes which would then show them as included in the UI but they would still be missing from the db. Upon saving the codelist, these codes and their descendants would disappear from view, in some cases leaving completely empty codelists (see #3206 ).

This PR ensures that any request for inclusion of codes is honoured in the db such that what the user sees in the builder view is what they will get when they click save.

@Jongmassey
Jongmassey force-pushed the Jongmassey/fix-empty-uploaded branch from 3480480 to e3fe9be Compare August 19, 2026 12:43
An "orphan" code (one without a related search) will be deleted from the
draft codelistversion by `update_code_statuses` if it is not the
descendant of an included code but will still be present in the UI until
the point a user refreshes the page or saves the draft.

They may then chose to re-include this orphan code,
at which point the UI will show the code as included but since the code
had previously been deleted then it will not be included in the db state

This commit allows for previously-deleted orphan codes to be
re-included if the user requests so.
Any descendants of the re-included code are also implicitly re-included.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug report: all codes removed from codelists created via CSV upload

2 participants