Skip to content

Created helper, endpoint, templates, tests for biomedical concept categories#23

Merged
pendingintent merged 4 commits intomasterfrom
add-concept-categories
Nov 21, 2025
Merged

Created helper, endpoint, templates, tests for biomedical concept categories#23
pendingintent merged 4 commits intomasterfrom
add-concept-categories

Conversation

@pendingintent
Copy link
Owner

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

Copilot AI review requested due to automatic review settings November 21, 2025 20:03
@pendingintent pendingintent self-assigned this Nov 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and fetch_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>
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }}\"

Suggested change
<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>

Copilot uses AI. Check for mistakes.
Comment on lines +1090 to +1093
if "%" in category:
encoded = category # assume already percent-encoded
else:
encoded = requests.utils.quote(category, safe="")
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Remove noqa comment

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 21, 2025 20:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1090 to +1093
if "%" in category:
encoded = category # assume already percent-encoded
else:
encoded = requests.utils.quote(category, safe="")
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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="")

Copilot uses AI. Check for mistakes.
@pendingintent pendingintent merged commit f5da67a into master Nov 21, 2025
6 checks passed
@pendingintent pendingintent deleted the add-concept-categories branch December 4, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants