Query the Bear EHR database using the semantic layer. Use when asked about clients, billing, appointments, insurance, clinical data, procedures, scheduling, programs, staff, vitals, diagnoses, revenue, claims, or any data question about the Bear application.
You have access to the Bear EHR MariaDB database via MCP tools (mcp__bear-db__execute_query, mcp__bear-db__get_table_info, mcp__bear-db__get_schema).
/home/andres/code/claude/semantic/ to understand the schema00_query_guide.md for query patterns, naming conventions, and caveats| # | File | Use When Asking About |
|---|---|---|
| 00 | 00_query_guide.md | NL-to-SQL patterns, status derivation, caveats |
| 01 | 01_people_demographics.md | Clients, demographics, addresses, phones |
| 02 | 02_programs_enrollment.md | Programs, enrollment, locations |
| 03 | 03_insurance_coverage.md | Insurance policies, payors, plans, authorizations |
| 04 | 04_appointments_scheduling.md | Scheduling, calendar, appointment types |
| 05 | 05_encounters_forms.md | Clinical documentation, encounter forms |
| 06 | 06_billing_revenue.md | Charges, claims, payments, revenue cycle |
| 07 | 07_clinical_data.md | Diagnoses, medications, vitals, labs |
| 08 | 08_users_staff.md | Staff, providers, credentials, roles |
| 09 | 09_tfc.md | Treatment Foster Care |
| 10 | 10_otp.md | Opioid Treatment Program |
| 11 | 11_transportation.md | Client transportation |
| 12 | 12_crew_groups.md | Group therapy sessions |
| 13 | 13_bed_management.md | Residential bed tracking |
| 14 | 14_prescriptions_erx.md | Electronic prescribing |
| 15 | 15_labs.md | Laboratory orders and results |
CASE WHEN not FILTER(WHERE)CURDATE() not CURRENT_DATETIMESTAMPDIFF() for date mathDATE_FORMAT() for date formattingtinyint(1) is boolean — use = 1 / = 0, NOT IS TRUE / IS FALSEdeleted_at IS NULL to filter active recordscssrs_suicides, suicidal_ideations, client_high_risks) do NOT have deleted_at — check with get_table_info first if unsureJOIN names n ON n.person_id = p.id AND n.deleted_at IS NULLJOIN people p ON p.identifiable_id = u.id AND p.identifiable_type = 'User' then JOIN names n ON n.person_id = p.idMAX(n.id) subquery or ORDER BY n.id DESC LIMIT 1people.type = 'Client' for patientscompanies.type = 'Payor' for insurance companies(p.hidden IS NULL OR p.hidden = 0)*_cents columns (integers)100.0 for dollar display: amount_cents / 100.0 AS amount_dollarsstatus column — derive from timestamps:
checked_out_at IS NOT NULLnoshow_at IS NOT NULLcancelled_at IS NOT NULLchecked_in_at IS NOT NULL AND checked_out_at IS NULLdeleted_by IS NULL AND cancelled_at IS NULL AND noshow_at IS NULLcompanies.id = 1 (scope self_pay / not_self_pay in Rails)first, second, third, fourth, fifth, selfpictures table with picturable_type = 'InsurancePolicy'bp_right_arm_sys, bp_right_arm_dia, bp_left_arm_sys, bp_left_artm_dia (note typo on left arm diastolic)cssrs_suicides (no deleted_at column)suicidal_ideations joined via cssrs_suicide_idrisk_assessments (has deleted_at)mcp__bear-db__get_table_info to verify$ARGUMENTS