// src/services/chargeItemDefinitionSearch.ts // Pure builder for the ChargeItemDefinition list query. The API forwards these straight to HealthLake // and forces the org scope server-side (via _tag), so no org param is sent. `category` filters Fee vs // Inventory via the searchable category identifier (see config/chargeItemDefinition.ts). `title` is a // starts-with search - the single place to switch to `title:contains` if HealthLake support is confirmed // (see the infra plan's `:contains` note). import { catalogCategorySearchToken } from '../config/chargeItemDefinition'; export const buildChargeItemDefinitionSearchParams = ( { pageSize, pageParam, query, category }: { pageSize: number; pageParam?: string; query?: string; category?: 'fee' | 'inventory' }, ): URLSearchParams => { const params = new URLSearchParams(); params.set('_count', String(pageSize)); if (pageParam) params.set('page', pageParam); if (query && query.trim()) params.set('title', query.trim()); if (category) params.set('identifier', catalogCategorySearchToken(category)); return params; };