[Eng-93] fix: Added start time in service_period on system generated accounts#3635
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThe ChangesAccount Service Period Initialization
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
🧹 Nitpick comments (1)
care/emr/resources/account/default_account.py (1)
18-25: ⚡ Quick winConsolidate
care_now()to avoid redundant calls and inconsistent timestamps.Two separate
care_now()invocations on lines 23 and 24 — while unlikely to differ in practice, they could theoretically return different instants (e.g., at a date boundary), makingservice_period.startand the date innameinconsistent. Assigning it once is cleaner:now = care_now() return Account.objects.create( patient=patient, facility=facility, status=AccountStatusOptions.active.value, billing_status=AccountBillingStatusOptions.open.value, service_period={"start": now.strftime("%Y-%m-%dT%H:%M:%S.%fZ")}, name=f"{patient.name} {now.strftime('%Y-%m-%d')}", )The hardcoded
Zformat is appropriate here (it's the correct ISO 8601 representation for UTC), so no change to the format string is needed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@care/emr/resources/account/default_account.py` around lines 18 - 25, Assign care_now() to a local variable and reuse it when building the Account in Account.objects.create so service_period["start"] and the name use the exact same timestamp; i.e., capture now = care_now() before constructing the dict and use now.strftime(...) for both service_period and the f"{patient.name} ..." name to avoid redundant calls and potential timestamp inconsistencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@care/emr/resources/account/default_account.py`:
- Around line 18-25: Assign care_now() to a local variable and reuse it when
building the Account in Account.objects.create so service_period["start"] and
the name use the exact same timestamp; i.e., capture now = care_now() before
constructing the dict and use now.strftime(...) for both service_period and the
f"{patient.name} ..." name to avoid redundant calls and potential timestamp
inconsistencies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0e81dbb8-5f7c-4195-a5ca-019f048f0da9
📒 Files selected for processing (1)
care/emr/resources/account/default_account.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3635 +/- ##
========================================
Coverage 75.55% 75.56%
========================================
Files 479 479
Lines 22958 22958
Branches 2369 2369
========================================
+ Hits 17347 17349 +2
+ Misses 5040 5039 -1
+ Partials 571 570 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Proposed Changes
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