IntegrationsHL7 (Old Flow)Inbound

Add Test to Bill

Inbound HL7/SFTP documentation for appending tests to an existing bill.

👤 Development Team📅 Updated: May 5, 2026📁 Integrations🏷️ HL7🏷️ SFTP🏷️ Inbound🏷️ Add Test

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:

  • orderNumber is present.
  • An active bill exists for the same lab and order number, or for the numeric labBillId equivalent of the order number.
  • addTestToBill = 1.
  • uniqueOrderNo = 0.
  • testList contains at least one test.

If testList is empty, the router returns 400 Invalid Test codes.

Implementation Path

StepFunctionDescription
Existing bill lookuphl7/2_3/createOrder/Finds active matching bill.
Test resolutionhl7/2_3/createOrder/Resolves inbound test codes against allTests.
Add-test executionbill_add_test_third_partyCalls the standard add-test controller.
Billing updatecommonBillAddTestControllerAdds tests, billing rows, reports, samples, and related data.
AOE persistencecreate_question_values_from_aoe_dataSaves inbound AOE values after the add-test operation.

Configuration

KeyRequired valueDescription
addTestToBill1Enables this operation.
uniqueOrderNo0Allows an existing order number to be used for add-on tests.
add_duplicate_testOptional 1Adds inbound tests even when the bill already contains the same test.
orgPriceListOptional 1Uses the existing bill organization's price list for added tests.
is_aoe_storeOptional 1Stores 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 = 1 and a list price is available.
  • Otherwise, the master test amount is used.
  • report_level_tags from the inbound test item is preserved.

Internal Add-Test Request

The router creates an internal request object for bill_add_test_third_party.

FieldValue
billAddType2, indicating add tests to an existing bill.
labBillIdExisting bill's labBillId.
testListResolved tests that should be added to the bill.
billTotalAmountSum of the resolved amounts for tests being added.
paymentModePayment mode from the existing bill's organization.
billAdvance0, because this integration add-test path does not collect advance payment.
smsFlag0, patient SMS disabled for this internal call.
orgSMSFlag0, organization SMS disabled for this internal call.
sampleAccessionLab feature flag used by the standard add-test controller.
batchManagementLab feature flag used by the standard add-test controller.
cashBoxManagementLab feature flag used by the standard add-test controller.
loginUserLab 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

IssueCheck
Add-test flow is not triggeredConfirm addTestToBill = 1 and uniqueOrderNo = 0.
Endpoint returns Invalid Test codesConfirm OBR-4 is parsed into testList.
Tests are skippedConfirm whether the bill already has the tests and whether add_duplicate_test should be enabled.
Test amount is unexpectedCheck orgPriceList and organization list priority.

On this page