bug fixes and testcases for medication dispense#3589
bug fixes and testcases for medication dispense#3589nandkishorr wants to merge 12 commits intodevelopfrom
Conversation
Greptile SummaryThis PR delivers three targeted changes to the medication dispense feature: a bug fix converting the
Confidence Score: 3/5
Important Files Changed
Reviews (1): Last reviewed commit: "bug:update the location filter and summa..." | Re-trigger Greptile |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 8 minutes and 47 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request adds a comprehensive test suite for medication dispense API endpoints and updates the medication dispense viewset to use a custom UUID filter for location validation and explicit encounter_id ordering in the summary action results. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@care/emr/tests/test_medication_dispense_api.py`:
- Around line 833-853: The test test_summary_medication_dispense_as_superuser
currently only verifies aggregation because both dispenses share the same
encounter; modify it to create a second MedicationDispense tied to a different
encounter (use create_dispense_order to create a second encounter-order pair,
then create_medication_dispense for that order), call generate_summary_url the
same way, then assert that response.data["results"] contains two entries in the
expected encounter order and that their counts correspond to each encounter
(this will detect removal of the order_by("encounter_id") sorting).
- Around line 727-753: The test
test_list_medication_dispense_with_location_include_children_filter creates a
child_location and a dispense order for it but then calls
create_medication_dispense(order=another_dispense_order) without passing
location, so both dispenses end up attached to self.location; update the second
create_medication_dispense call to include location=child_location (i.e. call
create_medication_dispense(order=another_dispense_order,
location=child_location)) so the include_children=True path is actually
exercised.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 65eb251d-9f49-4098-b652-a72f6618cb6a
📒 Files selected for processing (2)
care/emr/api/viewsets/medication_dispense.pycare/emr/tests/test_medication_dispense_api.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3589 +/- ##
===========================================
+ Coverage 77.20% 77.71% +0.51%
===========================================
Files 474 474
Lines 22421 22421
Branches 2348 2348
===========================================
+ Hits 17310 17425 +115
+ Misses 4531 4414 -117
- Partials 580 582 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| queryset = ( | ||
| self.filter_queryset(self.get_queryset()) | ||
| .values("encounter_id") | ||
| .order_by("encounter_id") |
There was a problem hiding this comment.
@vigneshhari ,instead of showing the n count of medication dispense related to an encounter in the response ,the api response returns n times encounter details with each count =1
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
Tests
Bug Fixes