+- **Hydration pattern**: All location queries go through `_fetch_locations(conn, suffix_sql, params)` — a single entry point that appends WHERE/ORDER to `_LOCATION_SELECT` and returns hydrated objects. `_LOCATION_SELECT` uses DuckDB correlated subqueries to pull codes, synonyms, and references inline in one query (DuckDB optimizes these into a join plan). `_build_location(row)` is a pure transform using `AnatomicLocation.model_validate(data)` — Pydantic handles enum coercion, nested-model construction, and extra-key ignoring automatically. `_get_locations_by_ids(conn, ids)` wraps `_fetch_locations` and re-sorts to preserve input order.
0 commit comments