sdac-fetch-costs
Purpose
Syncs SDAC cost report data from the TherapyLog system into the database via the Ingestion Server, then returns a report_id that downstream tools can use. The sync is idempotent -- if recent data already exists for the district and period, it returns the existing report_id without re-fetching.
Tool type
Deterministic (data sync)
Tool ID
sdac-fetch-costs
Inputs
district_id(string, required) -- District identifier from session contextyear(number, optional) -- Filter by year (e.g. 2025)quarter(number, optional) -- Filter by quarter (1-4)
Outputs
success(boolean)report_id(string | null) -- Report ID for use with downstream validation toolsstatus(string) -- Sync status:success,empty,duplicate, orfailedrecord_count(number) -- Number of records syncedsynced(boolean) -- Whether new data was synced (false= cache hit or empty)error(string, optional) -- Error message if sync failed
Example output
{
"success": true,
"report_id": "SDAC-2024-Q2-001",
"status": "success",
"record_count": 84,
"synced": true
}
Functional details
- POSTs to the Ingestion Server at
POST /sdac/sync. - TherapyLog data is mapped to the same DB tables as Excel uploads, so all downstream validation tools work identically regardless of data source.
- If
yearandquarterare omitted, the Ingestion Server defaults to the current reporting period.
Usage notes
- Call this tool at the start of a TherapyLog-sourced review session to get a
report_id. - Pass the returned
report_idto validation tools (e.g.sdac-validate-source-codes,sdac-get-report-info). - A
synced: falseresult with a validreport_idmeans cached data was reused -- no action needed.
Implementation details
- Reads
INGESTION_API_URLenvironment variable (defaults tohttp://localhost:8000). - Does not write directly to the database -- the Ingestion Server handles all DB writes.
Code Location: packages/domain-sdac/src/tools/fetch-sdac-costs.tool.ts