Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a dynamic valueset type #2945

Merged
merged 5 commits into from
Mar 21, 2025
Merged

Conversation

praffq
Copy link
Contributor

@praffq praffq commented Mar 21, 2025

Proposed Changes

  • add ValueboundCode class that dynamically generates type as per slugs

Only PR's with test cases included and passing lint and test pipelines will be reviewed

@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins

Summary by CodeRabbit

  • Refactor
    • Streamlined the data validation process for healthcare records across multiple modules such as allergy, condition, medication, observation, and questionnaire by updating data field types to ValueSetBoundCoding.
    • Removed explicit validation methods for various fields, enhancing consistency and simplifying data processing.
  • New Features
    • Introduced a new configuration constant DISABLE_RATELIMIT for controlling rate limiting behavior during testing.
  • Chores
    • Updated import paths for the validate_valueset function across multiple test files to reflect changes in module organization.
  • Bug Fixes
    • Simplified rate limiting checks in MFA functions by removing specific time window parameters.

@praffq praffq requested a review from a team as a code owner March 21, 2025 16:08
Copy link
Contributor

coderabbitai bot commented Mar 21, 2025

📝 Walkthrough

Walkthrough

This pull request updates several specifications in the medical records module by replacing the generic Coding type with a specialized ValueSetBoundCoding type across allergy intolerance, condition, medication, observation, and questionnaire resources. The custom field validators have been removed, relying on the new type’s built-in validation. A new utility class supporting this behavior is also introduced. Everything remains functionally the same—if you can call it that—but the data model is now far more explicit.

Changes

Files Change Summary
care/emr/.../allergy_intolerance/spec.py
care/emr/.../condition/spec.py
Updated code attribute from Coding to ValueSetBoundCoding[...] and removed custom validators.
care/emr/.../medication/administration/spec.py
care/emr/.../medication/statement/spec.py
Revised several fields (e.g., medication, site, route, method, status_reason) to use ValueSetBoundCoding[...] and eliminated explicit validation logic.
care/emr/.../medication/request/spec.py Modified multiple fields in DosageInstruction and BaseMedicationRequestSpec to use ValueSetBoundCoding[...], with associated validators removed.
care/emr/.../observation/spec.py Changed body_site and method fields to ValueSetBoundCoding[...] and added the necessary import.
care/emr/.../questionnaire/spec.py Updated code and unit types to ValueSetBoundCoding[...], removing the unit field validator.
care/emr/utils/valueset_coding_type.py Introduced the new ValueSetBoundCoding class with custom type binding and validation via class methods.

Possibly related PRs

  • Add chronic condition api #2775: The changes regarding the AllergyIntoleranceWriteSpec class and the modifications to the code attribute type and validation logic are related to similar changes made to the ConditionSpec and ConditionUpdateSpec classes.
  • adding swagger support #2772: The modifications in the AllergyIntoleranceWriteSpec class's code attribute and validation method are related to similar adjustments in the ConditionSpec and ConditionUpdateSpec classes.
  • more validation, constraints and adding sort index #2918: The changes regarding the code attribute's type and validation method in the AllergyIntoleranceWriteSpec class are related to similar modifications in the ConditionSpec and ConditionUpdateSpec classes.

In the realm of refactored code so neat,
We replaced old types and validators obsolete.
ValueSetBoundCoding now takes the lead,
Cutting through clutter with precision and speed.
The specs are cleaner—perhaps not perfect, but indeed!
Cheers to the changes, so shiny and replete.
🎉 Keep coding and cleaning—no need to repeat!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 25298c2 and 7b412d8.

📒 Files selected for processing (1)
  • care/emr/resources/medication/administration/spec.py (3 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
care/emr/resources/medication/administration/spec.py (1)
care/emr/utils/valueset_coding_type.py (1) (1)
  • ValueSetBoundCoding (5-19)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test / Test
🔇 Additional comments (4)
care/emr/resources/medication/administration/spec.py (4)

10-10: Nice improvement with the ValueSetBoundCoding import!

The switch from generic Coding to the more specific ValueSetBoundCoding type helps enforce valueset constraints at the type level. This provides better static analysis and reduces the need for redundant validation code throughout the codebase.

Also applies to: 18-18


68-70: Type constraints add much-needed guardrails

Replacing generic Coding types with ValueSetBoundCoding parameterized with specific valuesets is a cleaner approach that ensures validation at the type level. This change eliminates the need for separate validator methods while making the constraints more explicit in the type signatures.

The binding to specific valuesets (CARE_BODY_SITE_VALUESET.slug, CARE_ROUTE_VALUESET.slug, and CARE_ADMINISTRATION_METHOD_VALUESET.slug) ensures that only valid codes from the appropriate valuesets can be assigned to these fields.


88-88: Strong typing prevents errors before they happen

Changing status_reason and medication to use ValueSetBoundCoding with the appropriate valueset slug (CARE_MEDICATION_VALUESET.slug) properly enforces that these fields must contain valid medication codes.

I notice you've used the medication valueset for status_reason as well - might want to double-check if that's actually the intended valueset for status reasons, or if it should be bound to a different valueset. The field name suggests it might need a different set of codes than medications.

Also applies to: 91-91


10-91: Overall approach is more type-safe and maintainable

The consistent application of ValueSetBoundCoding across all fields that previously used generic Coding types with separate validators is a good architectural choice. This approach:

  1. Makes the constraints explicit in the type signatures
  2. Centralizes validation logic
  3. Enforces validation at assignment time
  4. Provides better static analysis capabilities
  5. Reduces code duplication by eliminating separate validator methods

The PR successfully implements the dynamic valueset type as stated in the objectives.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
care/emr/utils/valueset_coding_type.py (1)

1-20: Nice implementation of a parameterized type for value set bound coding.

This is a well-designed implementation that uses the __class_getitem__ method to create a specialized type bound to a specific value set. This approach significantly improves type safety and validation compared to the previous approach of using separate field validators.

A few minor suggestions that might make this even better:

 from care.emr.registries.care_valueset.care_valueset import validate_valueset
 from care.emr.resources.common import Coding


 class ValueSetBoundCoding:
+    """
+    A parametrized type that creates a Coding class bound to a specific value set.
+    
+    Usage:
+        field: ValueSetBoundCoding[SOME_VALUESET.slug]
+    """
     @classmethod
     def __class_getitem__(cls, slug: str):
         class BoundCoding(Coding):
             @classmethod
             def __get_validators__(cls):
                 yield cls.validate_input

             @classmethod
             def validate_input(cls, v):
                 if isinstance(v, dict):
                     v = Coding.model_validate(v)
                 return validate_valueset("code", slug, v)

         return BoundCoding
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a59045 and d344366.

📒 Files selected for processing (8)
  • care/emr/resources/allergy_intolerance/spec.py (2 hunks)
  • care/emr/resources/condition/spec.py (3 hunks)
  • care/emr/resources/medication/administration/spec.py (3 hunks)
  • care/emr/resources/medication/request/spec.py (3 hunks)
  • care/emr/resources/medication/statement/spec.py (2 hunks)
  • care/emr/resources/observation/spec.py (2 hunks)
  • care/emr/resources/questionnaire/spec.py (3 hunks)
  • care/emr/utils/valueset_coding_type.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (5)
care/emr/resources/medication/statement/spec.py (1)
care/emr/utils/valueset_coding_type.py (1) (1)
  • ValueSetBoundCoding (5-19)
care/emr/resources/observation/spec.py (1)
care/emr/utils/valueset_coding_type.py (1) (1)
  • ValueSetBoundCoding (5-19)
care/emr/resources/questionnaire/spec.py (1)
care/emr/utils/valueset_coding_type.py (1) (1)
  • ValueSetBoundCoding (5-19)
care/emr/resources/medication/administration/spec.py (1)
care/emr/utils/valueset_coding_type.py (1) (1)
  • ValueSetBoundCoding (5-19)
care/emr/resources/medication/request/spec.py (1)
care/emr/utils/valueset_coding_type.py (1) (1)
  • ValueSetBoundCoding (5-19)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test / Test
🔇 Additional comments (24)
care/emr/resources/medication/statement/spec.py (2)

12-12: Good addition of the import.

The import statement is correctly placed and follows the existing import organization pattern.


40-40: Excellent refactoring of the medication field.

Replacing the explicit Coding type and field validator with ValueSetBoundCoding[CARE_MEDICATION_VALUESET.slug] is a cleaner approach. This change removes the need for a separate validation method while maintaining the same validation logic, which should make the code more maintainable.

care/emr/resources/allergy_intolerance/spec.py (3)

4-4: Field validator import cleaner now.

The Field import has been removed since it's no longer needed with the ValueSetBoundCoding approach. This is a nice cleanup.


12-12: Good addition of the import.

The import statement is correctly placed among the other imports.


92-92: Excellent refactoring of the code field.

Replacing the explicit Coding type with field validation using ValueSetBoundCoding[CARE_ALLERGY_CODE_VALUESET.slug] is much cleaner. This change improves type safety and makes the validation requirements clearer at the point of declaration rather than hidden in a separate validator method.

care/emr/resources/observation/spec.py (2)

19-19: Good addition of the import.

The import statement for ValueSetBoundCoding is correctly placed with the other imports.


95-95: Nice consistent refactoring of body_site and method fields.

Both fields have been updated to use ValueSetBoundCoding with their respective value set slugs, which is consistent with the changes in other files. This approach properly enforces type constraints at the field declaration level rather than through separate validators.

I notice you've maintained the optional nature of these fields with | None, which is good for backward compatibility.

Also applies to: 97-97

care/emr/resources/condition/spec.py (5)

5-5: New import for validators looks properly integrated.
The field_validator import appears valid and is used consistently in existing validators. No conflicts observed.


14-16: Good step towards consistent validation.
Importing ValueSetBoundCoding is a solid move for standardized value set checks, aligning with the new approach across the codebase.


139-139: Same possible typo for code-based attribute.
As with line 85, ensure the references to CARE_CODITION_CODE_VALUESET are correct.


144-144: Ensure naming and references remain consistent.
This change repeats the same pattern and the same potential slug naming concern.


85-85:

✅ Verification successful

Confirm correctness of value set slug naming.
The type annotation for code references CARE_CODITION_CODE_VALUESET.slug. The term “CODITION” might be a typo.

Please run this script to scan for other references and confirm the slug usage is intentional:


🏁 Script executed:

#!/bin/bash
# Searching for references to CARE_CODITION_CODE_VALUESET to verify consistency
rg 'CARE_CODITION_CODE_VALUESET'

Length of output: 612


Slug Naming Verification: Naming Is Consistent

After verifying the references across the repository, it turns out that the term CARE_CODITION_CODE_VALUESET is used throughout (notably in care/emr/resources/condition/valueset.py and care/emr/resources/condition/spec.py). While it might initially look like a typo, the consistency here indicates that it's intentional. Please disregard the presumed typo unless there's a coordinated refactor plan.

care/emr/resources/questionnaire/spec.py (3)

15-15: Import aligns with unified validation stance.
Introducing ValueSetBoundCoding here is consistent with the project-wide approach of binding codes to value sets.


116-116: Refined attribute type for question code.
Switching code to ValueSetBoundCoding[CARE_OBSERVATION_VALUSET.slug] elegantly streamlines validation of observation codes.


143-143: Consistent extension to ‘unit’ field.
Binding unit to CARE_UCUM_UNITS.slug ensures more robust data integrity.

care/emr/resources/medication/administration/spec.py (5)

10-10: Sensible addition of Quantity import.
Importing Quantity matches the usage in dosage logic. Implementation looks good.


18-18: Adoption of shared coding utility.
Leveraging ValueSetBoundCoding is consistent with the PR’s shift away from custom field validators.


88-88: Refined attribute for status reason.
Transitioning status_reason to ValueSetBoundCoding[CARE_MEDICATION_VALUESET.slug] fits the pattern and should streamline validations.


91-91: Consistent usage of medication binding.
This update helps unify medication coding and eliminates manual validations.


68-70:

✅ Verification successful

Unified approach for site, route, and method.
Switching these fields to ValueSetBoundCoding supports a centralized validation model.

Could you confirm no leftover references to the older Coding type exist for these fields? Please run:


🏁 Script executed:

#!/bin/bash
rg -A3 "site: Coding" 
rg -A3 "route: Coding" 
rg -A3 "method: Coding"

Length of output: 786


Unified approach confirmed in medication administration spec

The updates in care/emr/resources/medication/administration/spec.py look good—site, route, and method are now using ValueSetBoundCoding as intended. The grep check revealed no lingering usages of the old Coding type in this file. (For reference, while there are still a couple of Coding usages in care/emr/resources/questionnaire_response/spec.py, those seem to be unrelated to the current changes.)

care/emr/resources/medication/request/spec.py (4)

24-24: Import approach looks fine.
No immediate concerns. This import of ValueSetBoundCoding appears consistent with the rest of the application’s architecture.


131-133: Improved type safety with ValueSetBoundCoding.
Switching additional_instruction from Coding to a list of ValueSetBoundCoding references the correct slug and should eliminate the need for manual validator methods. Please confirm that any tests for additional_instruction remain valid or have been updated to reflect the new type.


137-142: Consistent approach to slug-bound codings.
All these fields now rely on built-in validation from ValueSetBoundCoding, removing the need for separate validation code. This should simplify maintenance. Confirm you have test coverage for the new usage, especially around optional fields.


166-166: Direct ValueSetBoundCoding usage for medication.
Replacing the old Coding field and JSON schema extra with ValueSetBoundCoding[CARE_MEDICATION_VALUESET.slug] is cleaner and more explicit. Verify that no external references or manual validations still expect the previous Coding type.

@praffq praffq marked this pull request as draft March 21, 2025 16:15
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 52.11%. Comparing base (3a59045) to head (7b412d8).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
care/emr/utils/valueset_coding_type.py 73.33% 4 Missing ⚠️
care/emr/utils/mfa.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2945      +/-   ##
===========================================
+ Coverage    52.02%   52.11%   +0.08%     
===========================================
  Files          239      240       +1     
  Lines        10900    10796     -104     
  Branches      1189     1173      -16     
===========================================
- Hits          5671     5626      -45     
+ Misses        5210     5151      -59     
  Partials        19       19              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@praffq praffq marked this pull request as ready for review March 21, 2025 17:11
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
care/emr/resources/base.py (1)

13-13: Unused class variable may need cleanup.

Since you've commented out the as_questionnaire method, the __questionnaire_cache__ class variable on line 13 might no longer be needed. It would be nice if you could remove unused variables when you're making these kinds of changes, but I guess that's asking a bit much.

-    __questionnaire_cache__ = {}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d344366 and 25298c2.

📒 Files selected for processing (9)
  • care/emr/api/viewsets/base.py (1 hunks)
  • care/emr/resources/base.py (2 hunks)
  • care/emr/tests/test_allergy_intolerance_api.py (1 hunks)
  • care/emr/tests/test_chronic_condition_api.py (1 hunks)
  • care/emr/tests/test_diagnosis_api.py (1 hunks)
  • care/emr/tests/test_medication_request.py (1 hunks)
  • care/emr/tests/test_symptom_api.py (1 hunks)
  • care/emr/utils/mfa.py (1 hunks)
  • config/settings/test.py (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • care/emr/api/viewsets/base.py
🔇 Additional comments (10)
care/emr/resources/base.py (2)

2-2: Import statement simplification noted.

You've reduced the import statement from what was likely more extensive to just Annotated, Union from typing. Given that you've commented out the as_questionnaire method that probably used the removed imports, this makes sense... I suppose.


90-139:

❓ Verification inconclusive

Verify impact on frontend consumers.

The docstring of the commented-out method indicates it was created "so that the FE has an idea about bound valuesets and other metadata about the form." Have you verified that removing this method won't break frontend code that might be relying on it? I'm sure you've thought of this, but just double-checking.


🏁 Script executed:

#!/bin/bash
# Search for any references to 'as_questionnaire' in the codebase
echo "Searching for references to as_questionnaire method..."
rg "as_questionnaire" --type py

Length of output: 461


Action: Verify Frontend Dependency on as_questionnaire

It appears that the removal (or commenting out) of as_questionnaire in care/emr/resources/base.py might be incomplete—there’s still a reference in care/emr/api/viewsets/base.py (even though it's currently within commented code). Since the original intent was to provide the frontend with metadata (like bound valuesets), please double-check that none of the frontend consumers rely on this method. If the function is no longer needed, consider cleaning up all related commented-out references to avoid future confusion. Otherwise, ensure an appropriate fallback or replacement is in place.

care/emr/utils/mfa.py (2)

37-37:

❓ Verification inconclusive

Rate limiting parameter removal may have security implications.

The removal of the explicit rate limit "10/5m" parameter from the IP-based rate limiting check could potentially change how aggressively this security mechanism throttles requests.


🏁 Script executed:

#!/bin/bash
# Check how ratelimit function is implemented and where the rate limits are defined now.
grep -r "def ratelimit" --include="*.py" .
grep -r "mfa-login" --include="*.py" .
cat config/ratelimit.py

Length of output: 2378


Action Required: Confirm Rate Limit Configuration in Settings

We've verified that the explicit "10/5m" parameter is no longer passed directly. Instead, the ratelimit function now defaults to using settings.DJANGO_RATE_LIMIT as its rate limit. This change affects both the IP-based and the user-based rate limiting in care/emr/utils/mfa.py.

  • File: care/emr/utils/mfa.py (around line 37)
  • Details: The call if ratelimit(request, "mfa-login", ["ip"]): now relies on the default rate defined in settings rather than the previously hard-coded "10/5m".
  • Next Steps: Please double-check that settings.DJANGO_RATE_LIMIT is set to the correct value (i.e., "10/5m" if that was the intended value) to ensure the throttling behavior remains as expected.

43-43:

❓ Verification inconclusive

User-based rate limit parameter removed.

Similar to the IP-based rate limiting, the explicit "3/5m" parameter has been removed from the user-based rate limiting check. Assuming this is now controlled via a central configuration.


🏁 Script executed:

#!/bin/bash
# Check if there are any settings files that might define these rate limits
grep -r "RATELIMIT_" --include="*.py" .
grep -r "mfa-login" --include="*.settings.py" .

Length of output: 87


Action Required: Verify Central Rate Limit Configuration

It appears that the explicit rate limit parameters for the user-based check have been removed—mirroring the changes made for IP-based rate limiting. However, the preliminary grep results didn’t locate any configuration references (e.g., no settings with "RATELIMIT_" or "mfa-login" in *.settings.py files). This could indicate one of two things: either the central configuration isn’t named as expected (and is defined elsewhere), or it might have been overlooked.

  • The ratelimit call in care/emr/utils/mfa.py (line 43) now uses only "mfa-login" and [user_id].
  • Compare this with the IP-based rate limiting that now also relies on central configuration.
  • Kindly ensure that a corresponding central configuration exists and is correctly referenced for user-based rate limiting.

Please manually verify that the intended central configuration is in place and that the changes here are correctly backed by it.

config/settings/test.py (1)

104-104: LGTM - Test setting to disable rate limiting added.

Adding the DISABLE_RATELIMIT = True setting for testing environments is good practice. This will prevent rate limiting from interfering with test execution, which could otherwise lead to flaky tests.

care/emr/tests/test_diagnosis_api.py (1)

43-43:

✅ Verification successful

Import path updated for validate_valueset.

The import path has been updated to reflect the movement of validate_valueset from a resource-specific module to a more general utility module. This change appears to be part of a refactoring effort to improve code organization.


🏁 Script executed:

#!/bin/bash
# Verify that the new module exists and contains the validate_valueset function
if [ -f "care/emr/utils/valueset_coding_type.py" ]; then
  echo "File exists, checking for validate_valueset function:"
  grep -n "def validate_valueset" care/emr/utils/valueset_coding_type.py
else
  echo "File does not exist: care/emr/utils/valueset_coding_type.py"
fi

# Check if this change is consistent across other test files
grep -r "validate_valueset" --include="test_*.py" care/emr/tests/

Length of output: 1745


Verified: Updated Import Path for validate_valueset

Our checks confirm that the function now resides in care/emr/utils/valueset_coding_type.py as expected and that all tests (including test_diagnosis_api.py) reference this updated path consistently. Nice work ensuring consistency across the test suite.

care/emr/tests/test_chronic_condition_api.py (1)

42-42: Import path updated for consistency.

The import path has been updated to match the new location of validate_valueset. This ensures consistency across the test suite and reflects the module reorganization.

care/emr/tests/test_symptom_api.py (1)

43-44: Import path update looks good for centralizing validation.

The update to import validate_valueset from the utils module instead of from the condition-specific module indicates a positive refactoring effort to centralize validation logic. This move makes the codebase a bit more maintainable and adheres to the DRY principle.

care/emr/tests/test_medication_request.py (1)

37-37: Consistent import path update maintained across test files.

The same import path change has been implemented here, which shows consistency in the refactoring effort. Moving common validation logic to a central utility module improves maintainability and reduces duplication. I suppose I'll just have to trust that you've tested this thoroughly.

care/emr/tests/test_allergy_intolerance_api.py (1)

42-42: Import path modification continues the pattern of centralization.

This is the third instance of moving the validate_valueset function to the utility module, which confirms a systematic effort to centralize validation logic. This type of refactoring improves code organization and maintainability by putting related functionality in a single location instead of scattered across different modules.

@vigneshhari vigneshhari merged commit fa74e47 into develop Mar 21, 2025
8 checks passed
@vigneshhari vigneshhari deleted the create-valueset-code-validations branch March 21, 2025 19:40
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