remove unused code from specimen and minor bug in role update viewset
Proposed Changes
- for specimen we don't have List Apis so no use for filters and ordering
- In roles create we were facing issue due to exclude default , so fixed that using
perform_extra_deserialization - Update ServiceRequestWriteSpec to use get_or_404 instead of objects.get() which can throw exceptions
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
-
Breaking Changes
- Specimen API: query-parameter filtering by accession identifier and ordering by created/modified date removed.
- ServiceRequest: missing referenced healthcare service now returns a 404 error.
-
Behavior Changes
- Roles: creating a role without “is_archived” now defaults the role to archived; updates unchanged.
📝 Walkthrough
Walkthrough
Removed Django filter and ordering support from SpecimenViewSet; made RoleBaseSpec.is_archived optional and default new creates to archived when unset; switched ServiceRequest healthcare service lookup from Model.objects.get(...) to get_object_or_404(...), changing missing-object error to Http404.
Changes
| Cohort / File(s) | Summary |
|---|---|
Specimen API filtering removalcare/emr/api/viewsets/specimen.py |
Deleted SpecimenFilters and removed filter_backends, ordering_fields, and filterset_class from SpecimenViewSet. Authorization methods unchanged. |
Role spec default and deserializationcare/emr/resources/role/spec.py |
Changed RoleBaseSpec.is_archived from `bool |
ServiceRequest lookup error handlingcare/emr/resources/service_request/spec.py |
Replaced HealthcareService.objects.get(external_id=...) with get_object_or_404(HealthcareService, external_id=...), so missing healthcare service now raises Http404 instead of DoesNotExist. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant Client
participant RoleCreate as RoleCreateSpec.perform_extra_deserialization
participant RoleObj as Role instance
Client->>RoleCreate: create payload (is_archived may be missing)
alt is_archived provided
RoleCreate->>RoleObj: keep provided is_archived
else is_archived missing
Note right of RoleCreate: New behavior — default to archived
RoleCreate->>RoleObj: set is_archived = True
end
RoleCreate-->>Client: deserialized Role object
sequenceDiagram
autonumber
participant Client
participant ServiceReqSpec as ServiceRequestWriteSpec
participant DB as HealthcareService DB
Client->>ServiceReqSpec: provide healthcare_service.external_id
ServiceReqSpec->>DB: lookup by external_id
alt found
DB-->>ServiceReqSpec: return HealthcareService
ServiceReqSpec->>Client: proceed with deserialization
else not found
Note right of ServiceReqSpec: Changed to raise Http404
DB--x ServiceReqSpec: 404 (get_object_or_404)
ServiceReqSpec--x Client: Http404
end
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- ohcnetwork/care#3035 — touches the same role spec classes (
RoleBaseSpec/RoleCreateSpec) and appears related to is_archived/default handling.
Suggested reviewers
- vigneshhari
- sainak
Poem
Filters quietly retired, left the view to rest,
Roles now default to sleeping in the archive chest.
A lookup now complains with a proper 404,
Small nudges, tiny changes — nothing dramatic, of course. ✨
[!TIP]
🔌 Remote MCP (Model Context Protocol) integration is now available!
Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
prafful/bugs/default-value-issue-in-role-viewset
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
:x: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 54.83%. Comparing base (6ed5e5d) to head (7ba8fb5).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| care/emr/resources/role/spec.py | 33.33% | 2 Missing :warning: |
| care/emr/resources/service_request/spec.py | 0.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #3210 +/- ##
===========================================
- Coverage 54.86% 54.83% -0.03%
===========================================
Files 380 380
Lines 16473 16468 -5
Branches 1724 1725 +1
===========================================
- Hits 9038 9031 -7
- Misses 7409 7411 +2
Partials 26 26
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Let the default be None and let them use False and True. that should work