Repository navigation
Conversation
…upplement supplements; FHIR CodeSystem carries it - Source gets supplements (a canonical URL, optionally |version), supplement_type and supplement_global (migration 0047, three nullable columns). supplements is required when content_type is supplement (FHIR csd-4) and holds at most one non-empty |version. REST create, update and read, new versions and the bulk importer carry all three. - FHIR CodeSystem read and write carry supplements and the codesystem-supplement-type and codesystem-supplement-global extensions. - A supplement's FHIR read shows its concepts as a code and their names: no display made up from another name, no conceptclass or datatype. Its preferred name in the CodeSystem's language is the display. It stays content supplement past the concept limit, its concepts left out (SUBSETTED). - The FHIR write adds nothing to a supplement's concepts, and a concept with designations but no display loads (data['display'] was read without a check). - /fhir/CodeSystem/ search takes supplements (url matches any version, url|version that one) and content-mode (the content the read shows). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTHAarCyLb2cuys8Yd
…; keep a designation with a use Review pass 1 (Codex): - F1.1: a supplement concept with no display and no designation got no name, so OCL's validator dropped it while the write reported success. The write now refuses it (400) before anything is saved. - F1.2: a designation that is also the display is shown as a designation too when it has a use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTHAarCyLb2cuys8Yd
Codex review, pass 1 (codex-cli 0.169.0, commit 0ac202d)Verdict: findings (2 P1).
Responses Fixed in 99ccf1e:
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "0ac202de",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/code_systems/serializers.py",
"line": 117,
"claim": "Property-only supplement concepts are silently discarded during FHIR import.",
"scenario": "POST a supplement containing a concept with code and property inactive=false, without display or designations. This branch leaves names empty. BasicConceptValidator rejects the concept during Concept.persist_new(), which deletes it and returns errors. CodeSystemDetailSerializer.create() ignores those errors, so the request reports success and publishes a version missing the concept.",
"action": "Allow nameless supplement concepts through the model validator without inventing names, propagate concept persistence errors, and add an import regression test.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P1",
"tag": null,
"file": "core/code_systems/serializers.py",
"line": 151,
"claim": "Removing the display name also removes explicitly supplied designation-use metadata.",
"scenario": "Write a French supplement concept with display='Choléra' and designation={language:'fr', value:'Choléra', use:{code:'synonym'}}. add_preferred_name() promotes that designation, and this filter removes it from the read response. Only display remains, losing the explicit synonym designation; writing that response back loses its stored use too.",
"action": "Retain designations carrying a distinct explicit use when their text also supplies display. Add a round-trip test covering matching display and typed designation values.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex review, pass 2 (codex-cli 0.169.0, commit 99ccf1e)Verdict: clean. No findings. Earlier findings: F1.1 resolved, F1.2 resolved. findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "99ccf1e8",
"verdict": "clean",
"prior": [
{
"id": "F1.1",
"status": "resolved"
},
{
"id": "F1.2",
"status": "resolved"
}
],
"findings": []
} |
…ch had one caller left Simplification review S1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTHAarCyLb2cuys8Yd
Simplification review (fresh Claude subagent, commit 99ccf1e)Verdict: findings (1 dup-test, 1 shrink, 1 yagni).
Responses
findings.json{
"reviewer": "claude subagent",
"perspective": "simplify",
"mode": "full",
"commit": "99ccf1e8",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "S1",
"severity": null,
"tag": "yagni",
"file": "core/fhir/search.py",
"line": 249,
"claim": "with_concepts_over_limit() is now a one-line wrapper with a single caller (line ~621). The PR split it from the new concepts_over_limit() only so by_content_mode could reuse the Exists expression, and the wrapper adds nothing on top.",
"scenario": null,
"action": "Delete with_concepts_over_limit and at its one call site write rows = rows.annotate(concepts_over_limit=concepts_over_limit()).",
"lines_delta": -5,
"confidence": "medium"
},
{
"id": "S2",
"severity": null,
"tag": "shrink",
"file": "core/sources/models.py",
"line": 718,
"claim": "clean_supplements has an early return and a nested if, just to separate 'missing' from 'malformed'.",
"scenario": null,
"action": "self.supplements = self.supplements or None\nif self.is_supplement and not self.supplements:\n raise ValidationError({'supplements': [SUPPLEMENTS_REQUIRED]})\nversion = (self.supplements or '').split('|')[1:]\nif len(version) > 1 or version == ['']:\n raise ValidationError({'supplements': [SUPPLEMENTS_FORMAT]})",
"lines_delta": -3,
"confidence": "low"
},
{
"id": "S3",
"severity": null,
"tag": "dup-test",
"file": "core/sources/tests/tests.py",
"line": 851,
"claim": "test_supplements_is_optional_for_other_content makes a whole POST to pin one boolean branch of clean_supplements. The same branch is already hit by the other tests, since every non-supplement source created in the existing suite leaves supplements empty. The test also needs no setup that the sibling tests lack.",
"scenario": null,
"action": "Fold its single assertion (a plain source created with supplements returns 201 and keeps the value) into test_create_update_read_and_versions_carry_supplements, or drop it. Nothing else replaces it.",
"lines_delta": -6,
"confidence": "low"
}
]
} |
|
@snyaggarwal this is ready for review. Jon asks you to merge it if you approve; he knows you're working this weekend.
|
snyaggarwal
left a comment
There was a problem hiding this comment.
Review covering class vs module design, DRY and feature envy, performance, and test coverage. Six findings inline (P1 is the most severe), plus nits.
- P1: the two supplement extension URLs aren't defined by HL7. The one HL7 defines is
codesystem-globalLangPack. - P2: an existing
content_type=supplementsource with nosupplementscan no longer be edited, from TBv3 or anywhere else. - P3: a
content-modesearch runs the over-limit subquery on every candidate row, not just the page. - P4: supplement handling is split between a context flag in the base serializer and a read-only subclass, and the concept field reaches into its parent serializer.
- P5: the content-mode rule is written twice, in
get_contentand inby_content_mode. - P6: test gaps.
Questions that came up during the review:
- New versions: they carry the fields.
update_version_datacopies all three from HEAD, and RESTversions/, FHIR PUT andSourceVersionImporterall go through it. - Imports: the JSON bulk
SourceImporterand the FHIR CodeSystem bulk import (throughCodeSystemDetailSerializer) both carry them.CodeSystemConverter.from_fhirdoesn't, but nothing calls it. - TBv3: none of the three fields is in the create/edit form or the repo attributes dialog. The form PUTs only its own fields, and
prepare_objectkeeps the stored value for anything missing, so a TBv3 edit leavessupplementsas it was. TBv3 can't set, clear or override it, on purpose or by accident. P2 covers the one case where TBv3 still hits it.
…able; the supplement concept serializer owns its write and read - csd-4 (a supplement names what it supplements) is checked when content_type or supplements is set or changed, so a supplement stored without supplements before the rule stays editable. - CodeSystemSupplementConceptSerializer owns both sides (add_names, to_representation); CodeSystemDetailSerializer puts supplement and language into the context and CodeSystemConceptField only picks the class. Concept.preferred_name_in. - get_content uses fhir_search.STATED_CONTENT and points to by_content_mode; split_canonical parses url|version for clean_supplements and by_supplements. - Tests: the legacy supplement (REST, FHIR PUT), no language, a retired concept, extension not a list, a PUT without extension, content-mode fragment and an unknown code, a display with a type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTHAarCyLb2cuys8Yd
… the row being saved over, so a FHIR PUT can't clear HEAD's supplements A FHIR CodeSystem PUT loads the latest release and saves it over HEAD, so dirty tracking compared against the release: a release stored without supplements let the PUT clear the one HEAD had since been given. The exception now asks the database about the row with the object's id (Codex check FC.1 of d710222). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTHAarCyLb2cuys8Yd
Codex check of commits febca13..d710222 (codex-cli 0.169.0, commit d710222)Verdict: 1 finding.
These are the commits that answer the maintainer review. Response:
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "d710222e",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC.1",
"severity": "P2",
"tag": null,
"file": "core/sources/models.py",
"line": 311,
"claim": "The legacy exception can silently clear a valid HEAD supplements target during FHIR PUT.",
"scenario": "A legacy release has content_type='supplement' and supplements=NULL, while HEAD has since received a valid target through REST. A FHIR PUT creating a new version without supplements loads the legacy release, then CodeSystemDetailSerializer.update changes its id to HEAD's. Dirty tracking still compares against the release, so neither checked field appears changed. Validation passes, overwriting HEAD's target with NULL and creating another invalid release. The previous validation rejected this write.",
"action": "Evaluate the legacy exception against the persisted row being overwritten, including HEAD during FHIR PUT. Add a regression test with a legacy release and a corrected HEAD.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex check of commits d710222..aef5e31 (codex-cli 0.169.0, commit aef5e31)Verdict: clean. No findings.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "aef5e314",
"verdict": "clean",
"prior": [
{
"id": "FC.1",
"status": "resolved"
}
],
"findings": []
} |
snyaggarwal
left a comment
There was a problem hiding this comment.
Re-review of d710222 and aef5e31. All six findings are resolved or answered, and CI is green on aef5e31. Two nits are inline; neither blocks merging.
| Status | |
|---|---|
| P1 extension URLs | Withdrawn. I was wrong. I checked the evidence: HL7/fhir-tx-ecosystem-ig requirements.md defines a global language pack as codesystem-supplement-type = lang-pack plus codesystem-supplement-global = true, and tests/global-lang-pack/codesystem-glp-base-de.json uses exactly these two URLs. Keeping them, and keeping supplement_type free text, is right. |
| P2 legacy supplements | Resolved. The rule now looks at the stored row with this id (is_stored_supplement_without_supplements), so a legacy supplement stays editable. Creating a supplement, making a source one, or clearing supplements still needs a value. The FC.1 case (a FHIR PUT loading a release and saving it over HEAD) is handled and has a test. The extra query only runs for a supplement without supplements. Thanks for checking prod: no affected rows. |
| P3 content-mode cost | Answered. About 1.28M index-only entries across 1,975 versions, 28 ms warm, and FHIR_SEARCH_TIMEOUT_MS still bounds a cold run. Agreed, no stored count. |
| P4 design | Resolved. The supplement subclass now owns both directions (add_names, to_representation). CodeSystemDetailSerializer.to_internal_value sets the context, and the field only picks the class, without reading self.parent. Concept.preferred_name_in is on the model. ValueSetConceptSerializer inherits the unchanged base add_names. |
| P5 DRY | Resolved. get_content uses STATED_CONTENT, the two docstrings point to each other, and split_canonical is shared. Keeping it apart from canonical_url_to_url_and_version (which raises on a second |) makes sense. |
| P6 tests | Resolved. One test per gap. Items 2, 4 and 6 are pinned as intended behaviour, and I agree with the reasoning. |
| nits | All three done. |
I re-read the new code for regressions:
self.context.update(...)into_internal_valueis safe. The views andsave_fhir_resourcebuild a fresh context for each serializer, andCodeSystemConceptFieldhas no other parent.- The new validation for
|and an empty version accepts and rejects the same values as the old split-based code. name != display(model equality by pk) matches the earlieris noton the prefetched names.
| @@ -1 +1,5 @@ | |||
| RESOURCE_TYPE = 'CodeSystem' | |||
| SUPPLEMENT_TYPE_EXTENSION = 'http://hl7.org/fhir/StructureDefinition/codesystem-supplement-type' | |||
There was a problem hiding this comment.
nit: since the extensions pack doesn't define these two yet, a one-line comment saying where they come from (the tx ecosystem IG and FHIRsmith) would save the next reviewer from repeating my P1:
# Not in the extensions pack yet; from HL7's tx ecosystem IG (global language packs), as FHIRsmith reads them|
|
||
| def test_a_supplement_stored_without_supplements_stays_editable(self): | ||
| """ | ||
| csd-4 is checked when content_type or supplements is set or changed, so a supplement stored without supplements |
There was a problem hiding this comment.
nit: this docstring still describes the dirty-tracking version from d710222 ("checked when content_type or supplements is set or changed"). Since aef5e31 the stored row decides, as clean_supplements now says. Maybe: "A supplement stored without supplements before the rule stays editable; making a source a supplement still needs one." The test itself is right.
snyaggarwal
left a comment
There was a problem hiding this comment.
Approving at aef5e31. The two nits are optional.
closes OpenConceptLab/ocl_issues#3030 (part of OpenConceptLab/ocl_issues#3029)
A supplement source can now say which code system it supplements, and FHIR CodeSystem reads, writes and searches carry it. A supplement's FHIR read no longer gains a made-up display, an extra English designation, or concept class and datatype properties. The first users are French and Brazilian Portuguese ICD-10 supplements, shaped like HL7 Denmark's
http://hl7.dk/fhir/core/CodeSystem/icd10-daon tx.fhir.org.This PR adds a migration:
sources/0047_source_supplementsadds three nullable columns tosources(no default, no data migration). Reversing it drops them.Changes
core/sources/models.py): new fieldssupplements(canonical URL, optionally|version),supplement_typeandsupplement_global.clean_supplementsrequiressupplementswhencontent_typeissupplement(FHIR csd-4), except on a row already stored as a supplement without one, and allows at most one non-empty|version; the URL itself goes throughURIValidatorlikecanonical_url. New versions copy all three from HEAD.Source.is_supplementis the shared check.core/sources/serializers.py): create, update and read carry the three fields on sources and source versions. The bulk importer'sSourceImporteraccepts them.core/code_systems/serializers.py):supplements, and thecodesystem-supplement-type(valueCode) andcodesystem-supplement-global(valueBoolean) extensions, on read and write. These are the extensions HL7's terminology ecosystem IG and tx.fhir.org use for language packs and global supplements.CodeSystemSupplementConceptSerializer, which owns both the write and the read) are a code and its names, plusinactivewhen retired. Noconceptclassordatatypeon the concepts or in the CodeSystem'spropertylist.data['display']is no longer read unchecked, so a concept with designations and no display loads. For a supplement nothing is added. A display that is sent becomes the preferred name in the CodeSystem'slanguage. If that name also came as a designation with its ownuse, it is still listed as a designation.content: supplementpastFHIR_CODE_SYSTEM_CONCEPT_LIMIT; its concepts are left out and the read is tagged SUBSETTED.core/fhir/search.py):/fhir/CodeSystem/takessupplements(a URL matches any version of it;url|versionmatches that version only, as tx.fhir.org does) andcontent-mode(the content the read shows; systemhttp://hl7.org/fhir/codesystem-content-mode). Both are listed in the CapabilityStatement and Swagger.Tests
SourceSupplementsTest(REST create/update/read/versions and validation),CodeSystemSupplementTest(FHIR write and read, an update, the concept limit, designations without a display),CodeSystemSupplementSearchTest(both search parameters), and a bulk importer test.supplements(REST and FHIR PUT), nolanguage, a retired concept, anextensionthat isn't a list, a PUT withoutextension,content-mode=fragmentand an unknown mode, and a display with a type.PYTHONHASHSEED=2): 3,224 tests withTEST_ES=off --exclude-tag es --parallel=4, then 630 with--tag es, all OK. For the review commit:core.fhir,core.sources,core.code_systems,core.value_sets,core.concept_maps,core.importers,core.conceptsand the source integration tests, 1,798 tests OK. After a last move ofsplit_canonicalintocore/common/utils.py(d710222),core.sources,core.code_systems,core.commonand the search tests, 607 OK. With the Codex check's fix (aef5e31) and its regression test,core.sources,core.code_systems,core.importers, the search tests and the source integration tests, 812 OK.pylint -j0 core/10.00, no messages.Decisions to confirm
supplementsis required only forcontent_type: supplement, and any other source may set it. FHIR's csd-4 only goes that way. A supplement already stored without one (from before this PR) stays editable, but a create, switching tosupplement, or clearingsupplementsis refused. The stored row being saved over decides. Production has no such rows.supplement_typeandsupplement_global, kept as the publisher gives them. Nothing applies them yet; whether a global flag can affect another owner's code system is D4 in Supplements: decide how OCL finds, scopes, turns on and merges supplements ocl_issues#3033. They're read from and written to thecodesystem-supplement-typeandcodesystem-supplement-globalextensions. HL7's terminology ecosystem IG requires these, and its tests and tx.fhir.org use them. HL7's extensions pack doesn't define them yet: it has only the oldercodesystem-globalLangPack, which the IG and tx.fhir.org don't read.language. That name isn't repeated as a designation unless it has a type, which becomes the designation'suse. FHIR defines the display as the designation in the resource language. Without alanguage, the display is stored in the source's default locale, as for any CodeSystem.supplement, its concepts left out and tagged SUBSETTED, instead ofnot-present. ICD-10 supplements have about 10,000 concepts, so their FHIR read won't list concepts, the same as the base ICD-10 today.content-modematches the content the read shows, so a large non-supplement code system isnot-present, not its stored mode.supplementsis matched as text. Checking that it resolves, and that a supplement's codes exist in it, is Supplements: check a supplement against the code system it supplements ocl_issues#3032.Not in this PR
supplementsisn't indexed in Elasticsearch, and the REST source list doesn't filter on it (D1 in Supplements: decide how OCL finds, scopes, turns on and merges supplements ocl_issues#3033).🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qTHAarCyLb2cuys8Yd