Skip to content

fix:added requester field in DiagnosticReportRetrieveSpec#3443

Merged
vigneshhari merged 2 commits into
developfrom
nandkishorr/fix/diagnostic_report_retrieve_spec
Jan 6, 2026
Merged

fix:added requester field in DiagnosticReportRetrieveSpec#3443
vigneshhari merged 2 commits into
developfrom
nandkishorr/fix/diagnostic_report_retrieve_spec

Conversation

@nandkishorr
Copy link
Copy Markdown
Contributor

@nandkishorr nandkishorr commented Jan 5, 2026

Proposed Changes

  • Added SR requester field in the DiagnosticReportRetrieveSpec

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete
  • Any other necessary step

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

  • New Features
    • Diagnostic reports now include requester details when a service request is associated, showing who requested the report.
    • If no requester is associated, reports remain unchanged (requester field will be empty).
    • Provides additional context for clinicians and downstream workflows.
    • Visible wherever diagnostic reports are viewed; no changes to existing privacy or access controls.

✏️ Tip: You can customize this high-level summary in your review settings.

@nandkishorr nandkishorr requested a review from a team as a code owner January 5, 2026 12:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

Added a nullable requester field to DiagnosticReportRetrieveSpec and updated serialization to populate it from a related service_request. Also imported model_from_cache and UserSpec to resolve the requester lazily.

Changes

Cohort / File(s) Summary
Diagnostic Report Spec Enhancement
care/emr/resources/diagnostic_report/spec.py
Added public field requester: dict | None to DiagnosticReportRetrieveSpec. Imported model_from_cache from care.emr.resources.base and UserSpec from care.emr.resources.user.spec. Serialization now sets mapping["requester"] via model_from_cache(UserSpec, id=obj.service_request.requester_id) when a service_request exists.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing critical sections including 'Associated Issue' link and detailed explanation of the change, making it incomplete. Add the 'Associated Issue' section with a link and explanation of how this change addresses the issue. Provide more context about why the requester field was needed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a requester field to DiagnosticReportRetrieveSpec, though it could be slightly more polished.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nandkishorr/fix/diagnostic_report_retrieve_spec

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f5d7d75 and 9dacc1d.

📒 Files selected for processing (1)
  • care/emr/resources/diagnostic_report/spec.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • care/emr/resources/diagnostic_report/spec.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test / Test
  • GitHub Check: Analyze (python)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
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: 2

Fix all issues with AI Agents 🤖
In @care/emr/resources/diagnostic_report/spec.py:
- Around line 82-85: The assignment to mapping["requester"] is creating a
one-element tuple because of the trailing comma; change the assignment so it
stores the dict returned by model_from_cache(UserSpec,
id=obj.service_request.requester_id) directly (remove the trailing comma) so
mapping["requester"] becomes the expected dict | None instead of a tuple.
- Around line 82-85: The code sets mapping["requester"] from
obj.service_request.requester_id without guarding against a null requester_id;
update the conditional to verify both that obj.service_request exists and that
obj.service_request.requester_id is truthy (e.g., if obj.service_request and
obj.service_request.requester_id:) before assigning mapping["requester"] with
model_from_cache(UserSpec, id=...), matching the guard pattern used in
service_request/spec.py and medication/request/spec.py.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 649f9cf and f5d7d75.

📒 Files selected for processing (1)
  • care/emr/resources/diagnostic_report/spec.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.cursorrules)

**/*.py: Prioritize readability and maintainability; follow Django's coding style guide (PEP 8 compliance).
Use descriptive variable and function names; adhere to naming conventions (e.g., lowercase with underscores for functions and variables).

Files:

  • care/emr/resources/diagnostic_report/spec.py
🧬 Code graph analysis (1)
care/emr/resources/diagnostic_report/spec.py (2)
care/emr/resources/base.py (2)
  • EMRResource (13-168)
  • model_from_cache (232-275)
care/emr/resources/user/spec.py (1)
  • UserSpec (124-138)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Test
🔇 Additional comments (2)
care/emr/resources/diagnostic_report/spec.py (2)

9-9: LGTM on the imports.

The addition of model_from_cache and UserSpec imports are necessary and correctly used in the serialization logic below.

Also applies to: 16-16


69-69: Field definition looks good.

The requester field follows the same pattern as created_by and updated_by, which is consistent and appropriate.

Comment thread care/emr/resources/diagnostic_report/spec.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.46%. Comparing base (649f9cf) to head (9dacc1d).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
care/emr/resources/diagnostic_report/spec.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3443      +/-   ##
===========================================
- Coverage    74.46%   74.46%   -0.01%     
===========================================
  Files          449      449              
  Lines        20701    20705       +4     
  Branches      2152     2153       +1     
===========================================
+ Hits         15416    15418       +2     
- Misses        4822     4824       +2     
  Partials       463      463              

☔ 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.

@vigneshhari vigneshhari merged commit 00ad709 into develop Jan 6, 2026
7 of 9 checks passed
@vigneshhari vigneshhari deleted the nandkishorr/fix/diagnostic_report_retrieve_spec branch January 6, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants