Skip to content

feat:added service request datapoint#3592

Open
nandkishorr wants to merge 4 commits intodevelopfrom
feat/datapoints/service_request
Open

feat:added service request datapoint#3592
nandkishorr wants to merge 4 commits intodevelopfrom
feat/datapoints/service_request

Conversation

@nandkishorr
Copy link
Copy Markdown
Contributor

@nandkishorr nandkishorr commented Mar 26, 2026

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
    • Service requests are now visible within encounter reports.
    • Filtering added for service requests by status, intent, category, and priority.
    • Service request fields (title, requester, status/intent/category/priority) are included in report output for better visibility and filtering.

@nandkishorr nandkishorr requested a review from a team as a code owner March 26, 2026 10:51
@nandkishorr nandkishorr self-assigned this Mar 26, 2026
@nandkishorr nandkishorr changed the title feat:added service request datapoints feat:added service request datapoint Mar 26, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4a88268b-c073-4e2f-b718-4a2eb569c8d9

📥 Commits

Reviewing files that changed from the base of the PR and between 76c247b and 61d0032.

📒 Files selected for processing (1)
  • care/emr/reports/context_builder/data_points/encounter.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • care/emr/reports/context_builder/data_points/encounter.py

📝 Walkthrough

Walkthrough

Adds a ServiceRequest context builder and exposes service requests on EncounterReportContext via a new service_requests Field referencing ServiceRequestBaseContextBuilder. Includes choice mappings, filters, exported fields, and a get_context() that filters ServiceRequest by encounter. (45 words)

Changes

Cohort / File(s) Summary
Service Request Context Module
care/emr/reports/context_builder/data_points/service_request.py
New module adding ServiceRequestBaseContextBuilder, choice maps (STATUS_CHOICE, INTENT_CHOICE, CATEGORY_CHOICE, PRIORITY_CHOICE), ServiceRequestReportFilterSet (multi-select status, iexact filters for intent, category, priority), exported Fields (title, status, intent, category, priority, requester), and get_context() returning ServiceRequest.objects.filter(encounter=self.parent_context).
Encounter Report Enhancement
care/emr/reports/context_builder/data_points/encounter.py
Added service_requests = Field(display="Service Requests", target_context=ServiceRequestBaseContextBuilder, preview_value="", description="Service requests associated with the encounter") on EncounterReportContext.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is missing all required sections from the template, including proposed changes, associated issue, and architecture details—only the checklist is present. Add 'Proposed Changes' and 'Associated Issue' sections to explain what was changed and why, following the repository template structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a service request data point with new context builders and encounter integration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/datapoints/service_request

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.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 26, 2026

Greptile Summary

This PR adds a service_requests data point to the encounter report context, following the same pattern used by existing builders (symptoms, diagnoses, diagnostic reports, etc.). A new ServiceRequestBaseContextBuilder is introduced with filters for status, intent, category, and priority, and a requester sub-context using SingleUserRelatedContextBuilder.\n\nKey issues found:\n\n- P0 — ImportError at runtime: encounter.py imports ServiceRequestDataPointBuilder, but the class defined in service_request.py is named ServiceRequestBaseContextBuilder. This name mismatch will throw an ImportError when the module is loaded, breaking all encounter reports.\n- P2 — Missing note field: The ServiceRequest model has a note field that is not surfaced in the context builder. Comparable builders in the codebase (e.g. SymptomsContextBuilder) expose this field.\n- No tests are included, as noted in the PR checklist.

Confidence Score: 2/5

Not safe to merge — the class name mismatch causes an ImportError that breaks all encounter reports at module load time.

The PR introduces a single, easily-fixed P0 bug (wrong class name) that prevents the entire encounter reports module from loading. The fix is a one-line rename, but until that is addressed the feature is completely non-functional.

care/emr/reports/context_builder/data_points/service_request.py — class must be renamed to ServiceRequestDataPointBuilder.

Important Files Changed

Filename Overview
care/emr/reports/context_builder/data_points/service_request.py New data point builder for ServiceRequest — broken by a class name mismatch (ServiceRequestBaseContextBuilder vs the imported ServiceRequestDataPointBuilder), causing an ImportError at runtime.
care/emr/reports/context_builder/data_points/encounter.py Adds service_requests field to EncounterReportContext — the import and field definition are structurally correct; the bug lives in the imported module.

Reviews (1): Last reviewed commit: "feat:added service request datapoints" | Re-trigger Greptile

Comment thread care/emr/reports/context_builder/data_points/service_request.py
Comment on lines +86 to +93
priority = Field(
display="Priority",
preview_value="Routine",
mapping=lambda sr: PRIORITY_CHOICE.get(sr.priority, sr.priority.title())
if sr.priority
else "",
description="Priority level of the service request",
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 note field not exposed

The ServiceRequest model has a note = models.TextField(null=True, blank=True) field, but it is not included in the context builder. Comparable builders (e.g. SymptomsContextBuilder) expose their note field. Consider adding it for completeness:

note = Field(
    display="Note",
    preview_value="",
    description="Additional notes about the service request",
)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 26, 2026

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":500,"request":{"method":"PATCH","url":"https://api.github.com/repos/ohcnetwork/care/issues/comments/4133588151","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n<details>\n<summary>📝 Walkthrough</summary>\n\n## Walkthrough\n\nThis change integrates service request data into encounter report contexts. The `encounter.py` file is updated with a new `service_requests` field directed to `ServiceRequestDataPointBuilder`, while a new `service_request.py` module provides the complete service request context building infrastructure, including field mappings and filtering capabilities.\n\n## Changes\n\n|Cohort / File(s)|Summary|\n|---|---|\n|**Encounter Context Enhancement** <br> `care/emr/reports/context_builder/data_points/encounter.py`|Added `service_requests` field wired to `ServiceRequestDataPointBuilder` with display label, preview value, and description metadata.|\n|**Service Request Data Points** <br> `care/emr/reports/context_builder/data_points/service_request.py`|New module implementing service request context building with choice mappings for status, intent, category, and priority; `ServiceRequestReportFilterSet` supporting multi-select and case-insensitive filtering; and `ServiceRequestBaseContextBuilder` exposing title, status, intent, category, priority, and requester fields with value-to-label transformation and related-context targeting.|\n\n## Estimated code review effort\n\n🎯 3 (Moderate) | ⏱️ ~25 minutes\n\n</details>\n\n<!-- walkthrough_end -->\n\n\n<!-- pre_merge_checks_walkthrough_start -->\n\n<details>\n<summary>🚥 Pre-merge checks | ✅ 1 | ❌ 2</summary>\n\n### ❌ Failed checks (2 warnings)\n\n|     Check name     | Status     | Explanation                                                                                                                                                                                                   | Resolution                                                                                                                                                                                                  |\n| :----------------: | :--------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n|  Description check | ⚠️ Warning | The PR description is missing critical sections including 'Proposed Changes', 'Associated Issue', and 'Architecture changes', containing only the merge checklist without explaining the actual changes made. | Add 'Proposed Changes' section describing the new service request datapoint fields, include 'Associated Issue' link if applicable, and optionally add 'Architecture changes' section to match the template. |\n| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.                                                                                                                          | Write docstrings for the functions missing them to satisfy the coverage threshold.                                                                                                                          |\n\n<details>\n<summary>✅ Passed checks (1 passed)</summary>\n\n|  Check name | Status   | Explanation                                                                                                                                                    |\n| :---------: | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Title check | ✅ Passed | The title 'feat:added service request datapoint' clearly summarizes the main change—adding service request data point support to the encounter report context. |\n\n</details>\n\n<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>\n\n</details>\n\n<!-- pre_merge_checks_walkthrough_end -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing Touches</summary>\n\n<details>\n<summary>📝 Generate docstrings</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> Create stacked PR\n- [ ] <!-- {\"checkboxId\": \"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98\"} --> Commit on current branch\n\n</details>\n<details>\n<summary>🧪 Generate unit tests (beta)</summary>\n\n- [ ] <!-- {\"checkboxId\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Create PR with unit tests\n- [ ] <!-- {\"checkboxId\": \"6ba7b810-9dad-11d1-80b4-00c04fd430c8\", \"radioGroupId\": \"utg-output-choice-group-unknown_comment_id\"} -->   Commit unit tests in branch `feat/datapoints/service_request`\n\n</details>\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=ohcnetwork/care&utm_content=3592)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->\n\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAZiWocaLRK9IiUEvAMJJAUJACO2NK4kLTUaNz48Bi4yJAGAHKOApRcAMwArACcAEyQeQCqNgAyXLC4uNyIHAD03UTqsNgCGkzM3fiwDOS4AO74FADW3QzOJN3c2B4e3RU1dQb1YRRcGJi0C0iw83x5AMr42BRRkAJUGAywvv643am46ZlsohukcIlEAPqxBJJfbQZykZKvTAfLhKKQefDcfa3f64bBdfjcMj7GwkCIkGaUAkACgw+HIkA8SBotAAlPsmioSB4aXSGUzECz2XkAMKxah0d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Cyjr4r4Gg+Ar6Ki74agagKhoAr6lDxWH6ygkDKTlUr4r5oDr7xWyhoCKgr4KhYVej9EhU2DLE9EMCyjlClBdUai0CVBJUVUKgH6yhRDVCVA+ACDL4MAai7A+C0AMDr7DUr6VBX6iU+AajFUX6qAn4ZUKgCDVXVBoCFWVAiL2Fz5AH6ygGUDgHwU/4AED5AG14ECjS15hBT64gkBA3OCwEV4GBwG9XBVWAA10Bui4CkgT60D3SsDqD3Rzx4GyiPWD6/XHK4Rqqg00DVZmz6BAA -->\n\n<!-- internal state end -->"},"request":{"retryCount":3,"retries":3,"retryAfter":16}}}

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: 1

🧹 Nitpick comments (1)
care/emr/reports/context_builder/data_points/service_request.py (1)

54-54: Convert mutable list to tuple for configuration immutability.

Line 54 uses a mutable list for __filterset_backends__, which works fine—no mutations are happening anywhere in the codebase, but using a tuple is more idiomatic for static configuration and prevents accidental modification later.

Suggested fix
-    __filterset_backends__ = [filters.DjangoFilterBackend]
+    __filterset_backends__ = (filters.DjangoFilterBackend,)

Note: This pattern appears across multiple context builder files (diagnosis.py, symptom.py, medication.py, etc.); consider applying the same change consistently throughout for maintainability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@care/emr/reports/context_builder/data_points/service_request.py` at line 54,
The configuration attribute __filterset_backends__ is defined as a mutable list;
change it to an immutable tuple containing filters.DjangoFilterBackend (i.e.,
replace the list literal with a tuple literal) to prevent accidental mutation
and follow idiomatic static config; do the same replacement for the same
attribute in the related context builder modules (diagnosis.py, symptom.py,
medication.py, etc.) to keep consistency.
🤖 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/reports/context_builder/data_points/encounter.py`:
- Around line 29-31: The import and usages reference
ServiceRequestDataPointBuilder which doesn't exist; update the import to bring
in ServiceRequestBaseContextBuilder (from
care.emr.reports.context_builder.data_points.service_request) and then rename
all usages/references of ServiceRequestDataPointBuilder to
ServiceRequestBaseContextBuilder (e.g., in the encounter context builder where
it is referenced around the previous ServiceRequestDataPointBuilder mentions) so
the module can import and run without runtime failure.

---

Nitpick comments:
In `@care/emr/reports/context_builder/data_points/service_request.py`:
- Line 54: The configuration attribute __filterset_backends__ is defined as a
mutable list; change it to an immutable tuple containing
filters.DjangoFilterBackend (i.e., replace the list literal with a tuple
literal) to prevent accidental mutation and follow idiomatic static config; do
the same replacement for the same attribute in the related context builder
modules (diagnosis.py, symptom.py, medication.py, etc.) to keep consistency.
🪄 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: 021179a2-d008-42e3-adcc-523f09de7b7f

📥 Commits

Reviewing files that changed from the base of the PR and between 9a01a71 and 256cc8f.

📒 Files selected for processing (2)
  • care/emr/reports/context_builder/data_points/encounter.py
  • care/emr/reports/context_builder/data_points/service_request.py

Comment thread care/emr/reports/context_builder/data_points/encounter.py
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.

♻️ Duplicate comments (1)
care/emr/reports/context_builder/data_points/encounter.py (1)

216-221: ⚠️ Potential issue | 🔴 Critical

The import says one thing, the usage says another.

Line 30 imports ServiceRequestBaseContextBuilder, but line 218 references ServiceRequestDataPointBuilder which... doesn't exist. The pipeline is kindly letting you know about this as well. This will fail at import time.

🐛 Proposed fix
     service_requests = Field(
         display="Service Requests",
-        target_context=ServiceRequestDataPointBuilder,
+        target_context=ServiceRequestBaseContextBuilder,
         preview_value="",
         description="Service requests associated with the encounter",
     )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@care/emr/reports/context_builder/data_points/encounter.py` around lines 216 -
221, The Field declaration uses an undefined symbol
ServiceRequestDataPointBuilder while the file imports
ServiceRequestBaseContextBuilder; fix by making the symbols consistent: either
change the Field's target_context to ServiceRequestBaseContextBuilder or
import/define ServiceRequestDataPointBuilder (so the name used in the
service_requests Field matches an actual exported class), and ensure any
downstream usages expect the chosen class name.
🧹 Nitpick comments (1)
care/emr/reports/context_builder/data_points/service_request.py (1)

54-54: Consider using a tuple instead of a list for class attribute.

Ruff flags this as a mutable default value (RUF012). While it probably won't cause issues in practice since this is configuration, using a tuple would be more defensive and consistent with immutable configuration patterns.

🔧 Suggested fix
-    __filterset_backends__ = [filters.DjangoFilterBackend]
+    __filterset_backends__ = (filters.DjangoFilterBackend,)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@care/emr/reports/context_builder/data_points/service_request.py` at line 54,
The class attribute __filterset_backends__ is defined as a mutable list which
Ruff flags (RUF012); change it to an immutable tuple by replacing the list
literal with a tuple literal (e.g., (__filterset_backends__ =
(filters.DjangoFilterBackend,),) referencing the __filterset_backends__
attribute in service_request.py) so configuration is immutable and the linter
warning is resolved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@care/emr/reports/context_builder/data_points/encounter.py`:
- Around line 216-221: The Field declaration uses an undefined symbol
ServiceRequestDataPointBuilder while the file imports
ServiceRequestBaseContextBuilder; fix by making the symbols consistent: either
change the Field's target_context to ServiceRequestBaseContextBuilder or
import/define ServiceRequestDataPointBuilder (so the name used in the
service_requests Field matches an actual exported class), and ensure any
downstream usages expect the chosen class name.

---

Nitpick comments:
In `@care/emr/reports/context_builder/data_points/service_request.py`:
- Line 54: The class attribute __filterset_backends__ is defined as a mutable
list which Ruff flags (RUF012); change it to an immutable tuple by replacing the
list literal with a tuple literal (e.g., (__filterset_backends__ =
(filters.DjangoFilterBackend,),) referencing the __filterset_backends__
attribute in service_request.py) so configuration is immutable and the linter
warning is resolved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 75e961d4-0195-4e3b-b86c-b03ad201b46e

📥 Commits

Reviewing files that changed from the base of the PR and between 9a01a71 and 76c247b.

📒 Files selected for processing (2)
  • care/emr/reports/context_builder/data_points/encounter.py
  • care/emr/reports/context_builder/data_points/service_request.py

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.22%. Comparing base (c691750) to head (61d0032).

Files with missing lines Patch % Lines
...rts/context_builder/data_points/service_request.py 96.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3592      +/-   ##
===========================================
+ Coverage    77.20%   77.22%   +0.02%     
===========================================
  Files          474      475       +1     
  Lines        22421    22448      +27     
  Branches      2348     2348              
===========================================
+ Hits         17310    17336      +26     
- Misses        4531     4532       +1     
  Partials       580      580              

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

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.

1 participant