Skip to content

Comments

feat(O3-5372): auto-generate bill from medication orders via BillableService fallback#114

Open
Chennamma-Hotkar wants to merge 1 commit intoopenmrs:mainfrom
Chennamma-Hotkar:feat/O3-5372-auto-bill-medication-order
Open

feat(O3-5372): auto-generate bill from medication orders via BillableService fallback#114
Chennamma-Hotkar wants to merge 1 commit intoopenmrs:mainfrom
Chennamma-Hotkar:feat/O3-5372-auto-bill-medication-order

Conversation

@Chennamma-Hotkar
Copy link

@Chennamma-Hotkar Chennamma-Hotkar commented Feb 19, 2026

Overview

When a clinician saves a medication order, the billing module now automatically generates a pending bill line item — without requiring manual cashier intervention.

Problem

The existing GenerateBillFromOrderAdvice only billed DrugOrders when a matching StockManagement item existed. StockManagement items cannot be configured via Iniz, making automated billing impossible in reference application deployments.

Solution

Added a BillableService fallback path for DrugOrders — mirroring the existing TestOrder billing pattern. When no StockItem is found, the advice now looks up an enabled BillableService matching the drug's concept UUID. This allows drug billing to be fully configured via Iniz CSV, consistent with the rest of the billing metadata.

Changes

  • GenerateBillFromOrderAdvice: added BillableService fallback for DrugOrder
  • GenerateBillFromOrderAdviceTest: 10 tests covering:
    • DrugOrder billed via BillableService fallback
    • TestOrder billed via BillableService
    • Separate bill created per order
    • No bill for DISCONTINUE / REVISE / RENEW actions
    • No bill when no matching BillableService
    • No bill when BillableService is DISABLED
    • No bill when method is not saveOrder
    • No bill when DrugOrder has no concept

Test Results

Tests run: 10, Failures: 0, Errors: 0, Skipped: 0 
BUILD SUCCESS

How It Works

saveOrder() called
    │
    ├─ DrugOrder?
    │      ├─ StockItem found? → Bill via StockItem (existing path)
    │      └─ No StockItem?   → Bill via BillableService by concept UUID (NEW)
    │
    └─ TestOrder?
           └─ Bill via BillableService by concept UUID (existing path)

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