Add Test to Bill
Inbound HL7/SFTP documentation for appending tests to an existing bill.
Add Test to Bill
This operation appends tests from an inbound HL7 order to an existing active
bill. It is handled synchronously inside hl7/2_3/createOrder/.
When This Flow Runs
All conditions must be true:
orderNumberis present.- An active bill exists for the same lab and order number, or for the numeric
labBillIdequivalent of the order number. addTestToBill = 1.uniqueOrderNo = 0.testListcontains at least one test.
If testList is empty, the router returns 400 Invalid Test codes.
Implementation Path
| Step | Function | Description |
|---|---|---|
| Existing bill lookup | hl7/2_3/createOrder/ | Finds active matching bill. |
| Test resolution | hl7/2_3/createOrder/ | Resolves inbound test codes against allTests. |
| Add-test execution | bill_add_test_third_party | Calls the standard add-test controller. |
| Billing update | commonBillAddTestController | Adds tests, billing rows, reports, samples, and related data. |
| AOE persistence | create_question_values_from_aoe_data | Saves inbound AOE values after the add-test operation. |
Configuration
| Key | Required value | Description |
|---|---|---|
addTestToBill | 1 | Enables this operation. |
uniqueOrderNo | 0 | Allows an existing order number to be used for add-on tests. |
add_duplicate_test | Optional 1 | Adds inbound tests even when the bill already contains the same test. |
orgPriceList | Optional 1 | Uses the existing bill organization's price list for added tests. |
is_aoe_store | Optional 1 | Stores inbound OBX AOE values after tests are added. |
Test Selection
The router collects testCode values from
the inbound testList and fetches active allTests records for the lab.
For each resolved test:
- The test is skipped when it already exists on the bill, unless
add_duplicate_test = 1. - The test amount comes from the organization price list when
orgPriceList = 1and a list price is available. - Otherwise, the master test amount is used.
report_level_tagsfrom the inbound test item is preserved.
Internal Add-Test Request
The router creates an internal request object for bill_add_test_third_party.
| Field | Value |
|---|---|
billAddType | 2, indicating add tests to an existing bill. |
labBillId | Existing bill's labBillId. |
testList | Resolved tests that should be added to the bill. |
billTotalAmount | Sum of the resolved amounts for tests being added. |
paymentMode | Payment mode from the existing bill's organization. |
billAdvance | 0, because this integration add-test path does not collect advance payment. |
smsFlag | 0, patient SMS disabled for this internal call. |
orgSMSFlag | 0, organization SMS disabled for this internal call. |
sampleAccession | Lab feature flag used by the standard add-test controller. |
batchManagement | Lab feature flag used by the standard add-test controller. |
cashBoxManagement | Lab feature flag used by the standard add-test controller. |
loginUser | Lab user ID from the inbound token. |
Each resolved test item includes Crelio test fields
such as testId, testName, isProfile, testAmount, sampleId,
testQuantity, outsource fields, and report_level_tags.
Side Effects
After the add-test controller completes, the router:
- Saves AOE values using
create_question_values_from_aoe_data. - Writes an activity log in category
194. - Returns a successful response even if no new tests were eligible because all inbound tests already existed on the bill.
Responses
When at least one test is added:
{
"status": 200,
"Message": "[Add Tests to Bill] Tests <test names> have been added to Bill(ID: <labBillId>) for Patient <name> (ID: <patientId>) through HL7 integration"
}When the inbound tests are duplicates and no new test is added:
{
"status": 200,
"Message": "No new tests were added to the existing Bill(ID: <labBillId>) for Patient <name> (ID: <patientId>)"
}Common Issues
| Issue | Check |
|---|---|
| Add-test flow is not triggered | Confirm addTestToBill = 1 and uniqueOrderNo = 0. |
Endpoint returns Invalid Test codes | Confirm OBR-4 is parsed into testList. |
| Tests are skipped | Confirm whether the bill already has the tests and whether add_duplicate_test should be enabled. |
| Test amount is unexpected | Check orgPriceList and organization list priority. |