[ENG-867] fix:Ignore unique checks on empty identifiers - #3727
[ENG-867] fix:Ignore unique checks on empty identifiers#3727nandkishorr wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe patient identifier validator now checks uniqueness only when an identifier value is present. Regex validation remains unchanged. ChangesPatient identifier validation
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates patient identifier validation to avoid running uniqueness validation when the identifier value is empty, aligning behavior with optional identifier fields in the EMR patient resource layer.
Changes:
- Skip uniqueness validation when
valueis empty invalidate_identifier_config. - Preserve existing regex validation behavior for non-empty values.
| queryset = queryset.filter(config__external_id=config["id"]) | ||
| if obj: | ||
| queryset = queryset.exclude(patient=obj) | ||
| if config["config"]["unique"] and queryset.exists(): | ||
| if value and config["config"]["unique"] and queryset.exists(): | ||
| err = f"Identifier config {config['config']['system']} is not unique" |
| if obj: | ||
| queryset = queryset.exclude(patient=obj) | ||
| if config["config"]["unique"] and queryset.exists(): | ||
| if value and config["config"]["unique"] and queryset.exists(): |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3727 +/- ##
========================================
Coverage 79.45% 79.45%
========================================
Files 480 480
Lines 23214 23214
Branches 2420 2420
========================================
Hits 18445 18445
Misses 4165 4165
Partials 604 604 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
eeshsaxena
left a comment
There was a problem hiding this comment.
Makes sense. Guarding the uniqueness check with value and ... means an empty or missing identifier no longer trips "is not unique" against other empty identifiers, while a real value still gets checked. Since identifier values are strings here, value being falsy covers empty string and None, which is the intended skip. Reads correct.
|
Missing tests. Also resolve the comments by the AI bot. |
Proposed Changes
Associated Issue
Merge Checklist
/docsOnly 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