Created helper, endpoint, templates, tests for biomedical concept categories#23
Created helper, endpoint, templates, tests for biomedical concept categories#23pendingintent merged 4 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new biomedical concept categories feature that enables hierarchical navigation from categories to individual biomedical concepts. The implementation adds three template files, helper functions to fetch category data from the CDISC Library API, new UI endpoints, and comprehensive test coverage.
Key changes:
- Added helper functions
fetch_biomedical_concept_categories()andfetch_biomedical_concepts_by_category()to retrieve category and concept data from the CDISC API - Created two new UI endpoints:
/ui/concept_categories(category list) and/ui/concept_categories/view(concepts within a category) - Updated the concepts list template to make biomedical concept codes clickable links instead of separate "Detail" links
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_concept_categories.py | Adds 7 comprehensive tests covering URL encoding, response parsing (items and HAL links), error handling, and UI endpoint rendering |
| src/soa_builder/web/templates/concepts_list.html | Refactored code column to display the code as a clickable link, removing the redundant "Href" column |
| src/soa_builder/web/templates/concept_category_detail.html | New template displaying biomedical concepts within a selected category with links to individual concept details |
| src/soa_builder/web/templates/concept_categories.html | New template listing all biomedical concept categories with client-side search functionality |
| src/soa_builder/web/templates/base.html | Added navigation link to the new biomedical concept categories page |
| src/soa_builder/web/app.py | Implemented two helper functions for fetching category data and two UI endpoints for rendering categories and category-specific concepts |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <td> | ||
| {% if r.name %} | ||
| <!-- Pass raw name; backend will encode once to avoid double-encoding --> | ||
| <a href="/ui/concept_categories/view?name={{ r.name }}">{{ r.name }}</a> |
There was a problem hiding this comment.
The category name is inserted directly into the URL without HTML encoding. Use Jinja's | urlencode filter to properly encode the name parameter: href=\"/ui/concept_categories/view?name={{ r.name | urlencode }}\"
| <a href="/ui/concept_categories/view?name={{ r.name }}">{{ r.name }}</a> | |
| <a href="/ui/concept_categories/view?name={{ r.name | urlencode }}">{{ r.name }}</a> |
src/soa_builder/web/app.py
Outdated
| if "%" in category: | ||
| encoded = category # assume already percent-encoded | ||
| else: | ||
| encoded = requests.utils.quote(category, safe="") |
There was a problem hiding this comment.
This encoding logic is unreliable. A category name like 'Test%20Category' with a literal percent sign would incorrectly skip encoding. Use urllib.parse.unquote() to decode first, then quote() to ensure consistent encoding regardless of input state.
Remove noqa comment Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/soa_builder/web/app.py
Outdated
| if "%" in category: | ||
| encoded = category # assume already percent-encoded | ||
| else: | ||
| encoded = requests.utils.quote(category, safe="") |
There was a problem hiding this comment.
The logic to detect already-encoded values is insufficient. A category name like 'Liver & Kidney' contains no '%' but would fail encoding, while 'Test%' would be incorrectly treated as encoded. Use urllib.parse.unquote(category) == category to reliably detect unencoded strings, or always encode and let the library handle already-encoded values safely.
| if "%" in category: | |
| encoded = category # assume already percent-encoded | |
| else: | |
| encoded = requests.utils.quote(category, safe="") | |
| # Always percent-encode the category value for safety | |
| encoded = requests.utils.quote(category, safe="") |
…tent/soa-workbench into add-concept-categories fixing test
New page added for biomedical concept categories that supports drill down from category to child bcs and then selecting of individual bc to further drill down to concept_detail.html.
7 new Tests included for endpoint and helper