Repository navigation
feat(examples): add an offline ValueSet validate-code example (#4657) - #5504
Open
batool-fariha wants to merge 1 commit into
Open
batool-fariha wants to merge 1 commit into
batool-fariha wants to merge 1 commit into
Conversation
…rpanahi#4657) Adds examples/valueset_validate_code.py, which builds a small synthetic ValueSet under urn:openmed:example: and validates a member, a non-member and an excluded code with validate_code(), then shows the annotate, drop and downgrade policies of validate_codeable_concept(). It prints one JSON line per case and runs offline. Adds a smoke test, a cookbook row (the cookbook index test requires every top-level example to be listed) and a changelog entry. Closes maziyarpanahi#4657
batool-fariha
force-pushed
the
feat/valueset-validate-code-example
branch
from
November 8, 2026 20:28
840e572 to
3933909
Compare
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.
Pull Request
Description
Adds an offline, runnable example of
validate_code()andvalidate_codeable_concept()fromopenmed/clinical/exporters/valueset.py, so new users can see how to check codes against a ValueSet without a terminology server. It uses a small invented ValueSet underurn:openmed:example:, so no real vocabulary content is involved.Type of Change
Changes Made
examples/valueset_validate_code.py(new, 100 lines): builds a synthetic ValueSet that includesroutine,soonandimmediateand then excludesimmediate, and prints one JSON line per case:routine), a non-member (unlisted) and an excluded code (immediate) throughvalidate_code();annotate,dropanddowngradepolicies ofvalidate_codeable_concept()on a CodeableConcept with one member and one non-member coding.tests/unit/examples/test_valueset_validate_code_example.py(new): checks one JSON line per case, that the excluded code is reported as a non-member, what each policy does to the non-member coding, that only the inventedurn:openmed:example:system is used, and that no network connection is opened.docs/cookbook.md: one row for the new script.tests/unit/test_docs_cookbook_links.py::test_cookbook_indexes_current_scripts_and_notebooksrequires every top-level example to be listed, and it fails without this row.CHANGELOG.md: one entry under Unreleased.Testing
What I ran, and what I could not. I could not install the project's full development environment, so I did not run
.venv/bin/python -m pytest tests/unit/examples/test_valueset_validate_code_example.py -qas written in the issue. Instead I loaded the realopenmed/clinical/exporters/valueset.py(it only uses the standard library) in an isolated environment containing justpytestandruff, and ran:All 12 tests pass and both ruff commands are clean with the repository's configuration. Two negative controls fail as expected: removing the
excludeclause from the ValueSet fails the excluded-code test, and changing the system to a real-looking URI fails the invented-system test. CI will run the full suite.Documentation
Code Quality
make format,make lint, andmake format-check(I ranruff checkandruff format --checkdirectly with the repository's configuration instead; see Testing)make format-swiftandmake lint-swift(not applicable)Dependencies
Checklist
Related Issues
Closes #4657
Screenshots/Examples
Output of
main()(one JSON line per case):AI assistance
This change was written with Claude Code (Claude Sonnet 5.5). It is disclosed here rather than in a commit trailer, because the repository's commit-attribution check rejects co-author and generated-by footers. It was checked only as described under Testing, which includes the limits noted there.