Skip to content

Pricing Queries

Pricing Queries

DELPHOS resolves procedure prices through a multi-level resolution chain that respects temporal pricing — every price query is resolved against the contract period active on the event date, not the current date.


Price Resolution Chain

DELPHOS resolves prices in strict priority order. The first match wins:

1. Manual Override — procedure-specific price set on the contract period
2. CBHPM — CBHPM table price x contract percentage
3. Type Rule — price rule by appointment type
4. Base Price — fallback base price
SourceDescription
manual_overrideProcedure-specific price explicitly set for this contract period
cbhpmCalculated from the CBHPM reference table using the contract’s table version and percentage
type_rulePrice defined per appointment type on the contract period
base_priceDefault fallback price

The pricing_source field in every response tells you which level produced the price.


Calculate Binding Price

Returns the binding price for a scheduling event. Use this when creating appointments or generating billing guides.

POST /v1/scheduling/pricing/calculate

Request body

FieldTypeRequiredDefaultDescription
convenio_idUUIDYesConvenio (insurance plan) UUID
appointment_type_idUUIDYesAppointment type UUID
procedure_codesarrayNo[]List of TUSS procedure codes to price
event_datedateNotodayDate of the medical event for temporal resolution
provider_idUUIDNonullProvider UUID (reserved for future provider-specific pricing)

Response

FieldTypeDescription
total_price_centsintegerTotal price in centavos
pricing_sourcestringDominant resolution source
procedure_breakdownarrayPer-procedure price details
copay_centsintegerPatient copay amount in centavos
insurance_centsintegerInsurance payment in centavos
event_datedateEvent date used for resolution
contract_period_idUUIDContract period used

Each item in procedure_breakdown:

FieldTypeDescription
procedure_codestringTUSS procedure code
price_centsintegerResolved price in centavos
pricing_sourcestringWhich resolution level produced this price
cbhpm_detailsobjectCBHPM calculation details (when source is cbhpm)
copay_percentdecimalCopay percentage for this procedure
copay_max_centsintegerMaximum copay cap in centavos

Status codes

CodeMeaning
200Price calculated successfully
422No price resolvable for the procedure or pricing error
500Internal server error
Terminal window
curl -X POST "https://your-instance.delphos.app/v1/scheduling/pricing/calculate" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"convenio_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"appointment_type_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"procedure_codes": ["10101012", "10101039"],
"event_date": "2026-03-15"
}'

Example response

{
"total_price_cents": 25000,
"pricing_source": "manual_override",
"procedure_breakdown": [
{
"procedure_code": "10101012",
"price_cents": 15000,
"pricing_source": "manual_override",
"cbhpm_details": null,
"copay_percent": 30,
"copay_max_cents": 5000
},
{
"procedure_code": "10101039",
"price_cents": 10000,
"pricing_source": "cbhpm",
"cbhpm_details": {
"table_version": "2024",
"base_value_cents": 14285,
"percentage": 70
},
"copay_percent": 30,
"copay_max_cents": null
}
],
"copay_cents": 7500,
"insurance_cents": 17500,
"event_date": "2026-03-15",
"contract_period_id": "c3d4e5f6-a7b8-9012-cdef-234567890abc"
}

Calculate Non-Binding Estimate

Returns a non-binding estimate for informational purposes (e.g. patient cost preview before booking). Uses today’s date for contract period resolution.

POST /v1/scheduling/pricing/estimate

Request body

FieldTypeRequiredDefaultDescription
convenio_idUUIDYesConvenio UUID
appointment_type_idUUIDYesAppointment type UUID
procedure_codesarrayNo[]TUSS procedure codes

Response

FieldTypeDescription
non_bindingbooleanAlways true
total_price_centsintegerEstimated total in centavos
pricing_sourcestringDominant resolution source
procedure_breakdownarrayPer-procedure details (same schema as calculate)
copay_centsintegerEstimated patient copay
insurance_centsintegerEstimated insurance payment
Terminal window
curl -X POST "https://your-instance.delphos.app/v1/scheduling/pricing/estimate" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"convenio_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"appointment_type_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
"procedure_codes": ["10101012"]
}'

Monetary Values

All monetary values are expressed in centavos (integer cents) to avoid floating-point precision issues in healthcare billing.

API valueMeaning
15000R$ 150.00
7500R$ 75.00
250R$ 2.50

To display in Reais: value / 100 with two decimal places.


Copay Calculation

When a convenio has copay (coparticipacao) enabled, the pricing engine calculates the patient’s share automatically:

copay_cents = min(total_price_cents * copay_percent / 100, copay_max_cents)
insurance_cents = total_price_cents - copay_cents
  • copay_percent comes from the contract period or provider-convenio link.
  • copay_max_cents caps the patient’s maximum out-of-pocket amount.
  • If no cap is set (copay_max_cents is null), the percentage applies without limit.

Temporal Pricing Walkthrough

Consider a convenio with two contract periods:

PeriodValidityCBHPM VersionPercentage
AJan 1 - Jun 30202370%
BJul 1 - Dec 31202475%

Scenario: A procedure performed on March 15 (within Period A) is billed in August (Period B is now active).

# Correct: event_date ensures Period A prices are used
response = httpx.post(
"https://your-instance.delphos.app/v1/scheduling/pricing/calculate",
headers={"x-api-key": "YOUR_API_KEY"},
json={
"convenio_id": convenio_id,
"appointment_type_id": type_id,
"procedure_codes": ["10101012"],
"event_date": "2026-03-15", # Uses Period A (CBHPM 2023, 70%)
},
)
# result['contract_period_id'] will be Period A's UUID

Without event_date, the engine would use today’s date and resolve to Period B, producing incorrect prices for the March event.


Contract Period Snapshots

For billing audit trails, retrieve a full snapshot of the pricing configuration that was active on a specific date:

GET /v1/scheduling/convenios/{convenio_id}/contracts/{period_id}/snapshot

The snapshot includes all overrides, particular prices, and type rules, providing a complete record of the pricing state at that point in time. See Contract Management for details.


Error Handling

CodeMeaning
200Price calculated successfully
422No price resolvable — no matching contract period, no override, no CBHPM entry
500Internal server error

Error response format:

{
"detail": "No price resolvable for procedure 10101012 in contract period c3d4e5f6-..."
}

Common causes of 422 errors:

  • No active contract period for the given convenio on the event date
  • Procedure code not found in any resolution level
  • Convenio has no CBHPM table version configured