Skip to content

[ENG-1021] Restrict delivery and requesr orders with same origin and destination - #3759

Open
rithviknishad wants to merge 3 commits into
ohcnetwork:developfrom
rithviknishad:ENG-1021-restrict-delivery-orders-with-same-origin-and-destination
Open

rithviknishad wants to merge 3 commits into
ohcnetwork:developfrom
rithviknishad:ENG-1021-restrict-delivery-orders-with-same-origin-and-destination

Conversation

@rithviknishad

@rithviknishad rithviknishad commented Sep 16, 2026

Copy link
Copy Markdown
Member

Proposed Changes

  • Validation to restrict creating delivery orders with same origin and destination location

Associated Issue

Merge Checklist

  • Tests added/fixed
  • Update docs in /docs
  • Linting Complete

@ohcnetwork/care-backend-maintainers @ohcnetwork/care-backend-admins

Summary by CodeRabbit

  • Bug Fixes
    • Delivery orders can no longer be created when the origin and destination are the same facility location.
    • Supply requests now reject identical origin and destination locations.
    • Invalid requests display the clear message: “Origin and destination locations must be different.”
    • These validations help prevent orders from being submitted with an invalid route and provide immediate feedback when the selected locations are identical.

@rithviknishad
rithviknishad requested a review from a team as a code owner September 16, 2026 08:34
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4d1036c0-63b4-453b-a7be-453cb146f106

📥 Commits

Reviewing files that changed from the base of the PR and between bc8e370 and 4a52529.

📒 Files selected for processing (4)
  • care/emr/resources/inventory/supply_delivery/delivery_order.py
  • care/emr/resources/inventory/supply_request/request_order.py
  • care/emr/tests/test_delivery_order_api.py
  • care/emr/tests/test_request_order_api.py

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change rejects supply delivery and request orders when their origin and destination resolve to the same facility location. API tests verify the 400 response and validation message for both order types.

Changes

Supply location validation

Layer / File(s) Summary
Reject identical delivery locations
care/emr/resources/inventory/supply_delivery/delivery_order.py, care/emr/tests/test_delivery_order_api.py
SupplyDeliveryOrderWriteSpec rejects orders with the same origin and destination. The API test verifies the 400 response and validation message.
Reject identical request locations
care/emr/resources/inventory/supply_request/request_order.py, care/emr/tests/test_request_order_api.py
SupplyRequestOrderWriteSpec rejects requests with the same origin and destination. The API test verifies the 400 response and validation message.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: vigneshhari

Merge Risk: ⚪ Minimal · up to 4a525

The change rejects identical locations during order creation while preserving valid orders without an origin; no merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: preventing delivery and request orders from using the same origin and destination. It contains a minor typo in “requesr,” but the meaning remains clear.
Description check ✅ Passed The description identifies the change, links the associated issue, and confirms that tests and linting are complete. The optional architecture section is correctly omitted.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@rithviknishad rithviknishad changed the title [ENG-1021] Restrict delivery orders with same origin and destination [ENG-1021] Restrict delivery and requesr orders with same origin and destination Sep 16, 2026
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.75%. Comparing base (6de21bb) to head (4a52529).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3759   +/-   ##
========================================
  Coverage    79.74%   79.75%           
========================================
  Files          482      482           
  Lines        23297    23301    +4     
  Branches      2424     2426    +2     
========================================
+ Hits         18579    18583    +4     
  Misses        4115     4115           
  Partials       603      603           

☔ View full report in Codecov by Harness.
📢 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant