Repository navigation
Conversation
…AD, and its new version is made from that HEAD A FHIR CodeSystem, ValueSet or ConceptMap update (PUT) loaded the version its URL resolved, usually the latest release, applied the resource to it and saved it over HEAD. Any HEAD field the resource doesn't carry took that release's value, so an edit made to HEAD through the API since that release was undone by a metadata-only PUT, and so was HEAD's own access. Now one helper on FhirRepositorySerializerMixin does it for all three: - update_head: HEAD is the stored HEAD with what the resource says. A private HEAD still stays private whatever a concurrent write does (persist_changes keep_private), and the resource's id never renames HEAD. - as_new_version: the new version is made from that HEAD, with the resource's version and status, as the latest version, without HEAD's background tasks or its record of removed members. A CodeSystem update that doesn't give a language writes a supplement's concepts in HEAD's language, which is the one it keeps. Kept as they were: the version-exists check, concepts, references and mappings, and the supplement fields. Tests: core/fhir/tests_updates.py, for each resource type. Three existing tests described the old behaviour (a private release's access copied onto HEAD; a release without supplements refusing the PUT) and now check the new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH
… schema and the access HEAD has when it's saved - HEAD is saved with its stored validation schema as the original schema, as an API edit that sends none is. With None, a HEAD whose schema differs from its latest release's, and which has concepts, was revalidated to None and the update failed. - The save keeps the access HEAD has once it's locked for the save (keep_access beside keep_private), so a publish made between the update's read of HEAD and its save isn't undone, as a make-private already wasn't. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH
… HEAD as read for update, and queues no schema revalidation - update_head reads HEAD FOR NO KEY UPDATE in the transaction that saves it, and applies the resource to that row, so an API edit committed before the update locks HEAD is the one kept, not the values read earlier. - persist_changes takes revalidates_schema=False from a write that can't change the validation schema. A FHIR update can't, so it no longer queues a revalidation of HEAD's concepts, whose full-row save could undo a concurrent change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH
…s stored once written, without HEAD's member counts - as_new_version reloads HEAD before making the version from it, so an edit made to HEAD after the update saved it (while concepts, references or mappings were written) gives one consistent version, not the update's values mixed with HEAD's. - The new version starts with no member counts, as any new version does, so a version that isn't expanded doesn't show HEAD's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH
…of revalidates_schema; the ValueSet update uses as_new_version's result Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH
… retired status from the update, as its released The version is made from HEAD reloaded, so a concurrent change to HEAD's retired flag no longer reaches it: like released, retired is the update's status, else the resolved version's. The member-count test checks each count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH
…rder written CodeSystem reads, $lookup and $expand listed names, and chose the first description as the definition, in the order the database gave them, which changes when a row is saved again. They're sorted by id now, so the same request always lists them in the same order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…mpared in any order As with the names FHIR lists, this depended on where rows sit in their table: the mappings are read with no order, and the test compared two reads of them in order, so it failed now and then. A search document's codes have no order, so only the test changes. It now saves one mapping again between the two reads, which made it fail every time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added Dec 4: reads and a test that depended on where rows sit in their table. Two commits,
91fa9125andfdb270b6, to review on their own (git diff 2c4026a5 fdb270b6, about 25 lines of code and 60 of tests). They're here because this PR already changescore/code_systems/serializers.py.$lookupand stored$expandlisted a concept's names in that order, and took its definition from the first description in it. So the same request could list the names in another order later.test_a_supplements_display_is_its_name_in_the_code_systems_languagefailed now and then because of it.test_mapped_codes_read_mappings_for_a_few_concepts_a_querycompared two such reads in order, and failed now and then too.core.concepts.models.in_order), from the rows a list has already loaded, so there are no more queries. The definition is the first description written. If a concept has two preferred names in the code system's language, the first one written is a supplement's display.afedc981(withmastermerged in), aspr.ymlruns it: pylint 10.00; 4,296 tests OK (2 skipped) and 815 search-index tests OK; coverage 97%.Part of phase B (B-9, accepted Dec 1). API users' own writes don't change.
Ticket: OpenConceptLab/ocl_online#798 (B-9: a resource written through FHIR keeps what it says).
The defect
A FHIR CodeSystem, ValueSet or ConceptMap update (PUT) loaded the version its URL resolves, usually the latest release, applied the resource to it, and saved it over HEAD. Any HEAD field the resource doesn't carry took that release's value. So an edit made to HEAD through the OCL API since that release (description, website, extras, a validation schema, HEAD's access and so on) was silently undone by a metadata-only PUT.
What changes
One helper on
FhirRepositorySerializerMixin(core/fhir/serializers.py), used by all three serializers:update_head: HEAD is the stored HEAD with what the resource says. It's read FOR NO KEY UPDATE in the transaction that saves it, so an edit committed meanwhile is the one kept.keep_privateandkeep_access).persist_changes(revalidates_schema=False)).as_new_version: the new version is made from HEAD as stored once the update has written it. It takes the resource's version label and status, and it's the latest version. Like any new version, it starts with no background tasks, member counts or record of removed members.Kept as they were: the version-exists check; concepts (CodeSystem), references (ValueSet) and mappings (ConceptMap); and the supplement fields.
Tests
core/fhir/tests_updates.py, for each of CodeSystem, ValueSet and ConceptMap:core/capabilities/tests/test_make_private.py:pr.ymlruns it: pylint 10.00; 4,186 tests OK (2 skipped) and 804 search-index tests OK; coverage 97%.Review
Not in this PR
Rollback
Revert this PR. No migrations, no settings.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qXBZMHpxmJnf6SMKTH