Lab Provider
Function-calling namespace: labProvider
- Base URL:
https://api.aivida.in - Engine endpoint:
POST /api - Auth: Stack token middleware enabled in
optionalmode.
All APIs in this namespace require providerCode (v1 supported value: thyrocare).
Architecture and flow diagrams are documented in Provider Overview.
Endpoint Summary
| apiName | Purpose |
|---|---|
catalog | Fetch provider catalog (minPrice, maxPrice, gender, page, pageSize) |
getPincodes | Fetch serviceability details |
priceBreakup | Get provider-side price computation for cart payload |
searchSlots | Search available collection slots |
createOrder | Pay-then-book order creation |
getOrder | Fetch provider order details by externalOrderId |
listOrders | List provider orders by date/sort/page |
cancelOrder | Request provider cancellation |
rescheduleOrder | Request provider reschedule |
getReport | Pull report, store in Aivida FileStorage, insert lab_result_files |
Pay-Then-Book Guard (createOrder)
- Requires
organizationId,patientId,paymentId,payload. paymentIdmust exist in Aivida withstatus=success.- If payment is already linked to a provider order, API returns existing mapping (
idempotent=true) and does not rebook. - Success response returns:
providerOrderIdlabOrderIdexternalOrderId
Thyrocare Env Setup
Set these env vars in backend runtime (secrets should come from env/secret manager, not hardcoded in code):
THYROCARE_BASE_URL=https://api-sandbox.thyrocare.com
THYROCARE_PARTNER_ID=<partner_id>
THYROCARE_USERNAME=<username>
THYROCARE_PASSWORD=<password>
THYROCARE_ENTITY_TYPE=DSA
THYROCARE_CLIENT_TYPE=ALL
THYROCARE_API_VERSION=v1
THYROCARE_TIMEOUT_SECONDS=30Example Request
curl -X POST https://api.aivida.in/api \
-H "Content-Type: application/json" \
-H "x-stack-access-token: <access_token_optional>" \
-d '{
"namespace": "labProvider",
"apiName": "catalog",
"data": {
"providerCode": "thyrocare",
"page": 1,
"pageSize": 10
}
}'Example Response
{
"status": "ok",
"data": {
"providerCode": "thyrocare",
"providerRaw": {}
}
}Payload Notes (Important)
searchSlotsrequirespincode,appointmentDate, and patientitemsin payload.listOrdersrequiresstartDateandendDate; provider rejects futureendDate.createOrderis pay-then-book and fails fast if payment is missing/non-success.providerRawalways contains passthrough provider payload for debugging and completeness.
Smoke Test Script
Run smoke checks from backend:
cd backend
./scripts/thyrocare_smoke.shRun full booking flow smoke (payment-first path):
cd backend
ORG_ID=org_test_thyro \
PAYMENT_ID=<payment_with_status_success> \
PATIENT_ID=<aivida_patient_id> \
./scripts/thyrocare_smoke.sh