Repository navigation
feat(resolvers): implement post-coordinated name resolution - #955
Open
filiperochalopes wants to merge 1 commit into
Open
filiperochalopes wants to merge 1 commit into
filiperochalopes wants to merge 1 commit into
Conversation
* Introduce a dedicated mechanism to resolve display names for concepts and mappings, including complex compositions * This allows the system to display human-readable names derived from multiple components (e.g., a pattern and a placeholder) in a single code * The resolution process is cacheable and is designed to fall back to the stored/original code name if a part of the composition is missing
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Closes OpenConceptLab/ocl_issues#2951
TL;DR: Adds a configurable, read-time
namesresolver (Source.resolvers) that shows a display name forpost-coordinated codes (ICD-11
A&B/C, SNOMED CT, LOINC) in mappings, with no stored data, no new endpoint and nofrontend change.
Main Changes
core/resolvers/core.py(+153),core/resolvers/names.py(+194)Resolver(config validation, access check, batched concept lookup, cache) andNamesResolver(replacerules,literals,{{name}}). One module per family; new family = subclass + registry entry.core/sources/models.py,core/sources/serializers.py,core/sources/views.py,core/sources/migrations/0047_source_resolvers.pySource.resolvers, validated inclean()and in the version serializer (POST of a version skipsfull_clean). New versions inherit it from HEAD.core/mappings/name_resolution.py(+110),core/mappings/models.py,core/mappings/serializers.py,core/concepts/serializers.pyfrom/to_concept_name_resolvedandcascade_target_concept_name.core/resolvers/tests.py,core/integration_tests/tests_sources.py,tests_mappings.py,test_utils.pyDOCS_RESOLVERS.mdconcepts/mappingsfamilies.Configuration format
{"names": { "replace": [{"pattern": "&", "substitution": " [{{name}}]"}], "literals": [{"start": "{", "end": "}"}] }}replace(required, 1–16 rules):pattern(1–8 chars, no whitespace) →substitution(0–32 chars).{{name}}(at most once) receives the name of the code or literal right after the pattern.
literals(optional, 0–4 pairs): text betweenstartandendis copied without the delimiters, never looked up.A delimiter cannot also be a
pattern.Example — ICD-11
{"names": {"replace": [ {"pattern": "&", "substitution": " [{{name}}]"}, {"pattern": "/", "substitution": " / "}]}}ND13.2&XJ44E/ND13.3&XJ44E→Fracture of unspecified tarsal bone [Closed fracture] / Fracture of metatarsal bone [Closed fracture]Example — SNOMED CT
{"names": {"replace": [ {"pattern": ":", "substitution": " with "}, {"pattern": "{", "substitution": ""}, {"pattern": "}", "substitution": ""}, {"pattern": ",", "substitution": " and "}, {"pattern": "=", "substitution": ": "}]}}71388002:{260686004=129304002,405813007=15497006}→Procedure with Method: Excision - action and Procedure site - Direct: Ovarian structureExample — LOINC
{"names": { "literals": [{"start": "{", "end": "}"}], "replace": [ {"pattern": ":", "substitution": ", "}, {"pattern": "=", "substitution": ": "}, {"pattern": ",", "substitution": ", "}]}}104765-3:{Specimen}=LP7681-2,{Molgen}=LP6464-4→<name of 104765-3>, Specimen: <name of LP7681-2>, Molgen: <name of LP6464-4>(the axis in braces is a label, copied without braces; the
LP…parts must exist in the destination Source).Name fields on a mapping
to_concept_name/from_concept_nameto_concept_name_resolved/from_concept_name_resolveddisplay_name. Omitted when neither exists, as before.cascade_target_concept_nameKey Decisions
Source.resolvers, one key per familymetais display metadata.{{name}}oclweb3.{Specimen}→Specimen)$resolve-names)oclweb3,ocl-mapper, exports.Verification Checklist
Results on this branch: resolvers 4 OK · regression 714 OK ·
tests_sources120 OK · pylint 10.00/10 · no pendingsourcesmigration (themap_projectspending migration is pre-existing).resolversnothing is splitnull, inherit in a new version$cascadeshow the composed name; stored name/URL intactWHO/ICD-11-WHO:NC52.10&XA5R12→Laceration without foreign body of other parts of wrist or hand [Hand]0047is a nullableAddField; no index, no reindexNotes for the reviewer
literalsare new; a pattern with an empty substitution may sit at anend of the expression (SNOMED ends in
});{{name}}with nothing after it gives no name.resolvers, not HEAD's.resolvers.concepts/mappings, FHIR$lookup, frontend changes, any production configuration.