You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ pip install -e ".[dev,mcp]"
18
18
## Commands
19
19
20
20
```bash
21
-
# Run all tests (1000+ tests, pytest)
21
+
# Run all tests (1120+ tests, pytest)
22
22
python -m pytest tests/
23
23
24
24
# Run a single test file
@@ -134,7 +134,7 @@ SQLite with WAL mode and foreign keys enabled. 17 clinical tables + `load_log` a
134
134
135
135
### MCP Server (mcp/server.py)
136
136
137
-
FastMCP server with `CHARTFOLD_DB` env var for database path. Design principle: the LLM writes its own SQL for all reads via `run_sql` + `get_schema`. Write operations (notes, analyses) go through dedicated tools with controlled parameters.
137
+
FastMCP server with `CHARTFOLD_DB` env var for database path. 24 tools. Design principle: the LLM writes its own SQL for all reads via `run_sql` + `get_schema`. Write operations (notes, analyses) go through dedicated tools with controlled parameters.
138
138
139
139
### Data Access Modules (analysis/)
140
140
@@ -151,9 +151,10 @@ Parameterized query helpers that surface structured views of the data for LLMs (
151
151
### Export Modules
152
152
153
153
-`spa/export.py` — Self-contained HTML SPA with embedded SQLite database via sql.js (WebAssembly). All data stays client-side with in-browser SQL queries. Supports `--embed-images`, `--config`, `--ai-chat`, and `--proxy-url`.
154
-
-`spa/chat_prompt.py` — System prompt generation for AI chat (schema + stats + current analyses).
155
-
-`spa/js/chat.js` — Client-side agent loop + chat UI (conditionally included with `--ai-chat`).
154
+
-`spa/chat_prompt.py` — System prompt generation for AI chat (schema + stats + current analyses).`_CLINICAL_TABLES` derived from `db.py`'s `_UNIQUE_KEYS` (not hardcoded).
155
+
-`spa/js/chat.js` — Client-side agent loop + chat UI (conditionally included with `--ai-chat`). Two tools: `run_sql` (SQL queries) and `render_chart` (inline line charts via `ChartRenderer`). Conversation persists across SPA navigation via DOM detach/reattach (`_container`). Sliding window (`MAX_MESSAGES=40`) with pair-aware trimming.
156
156
-`spa/css/chat.css` — Chat panel styling (conditionally included with `--ai-chat`).
157
+
-`spa/js/sections.js` — All SPA sections including `visit_prep` (auto-detected date, 9 clinical categories, parameterized queries) and `print_summary` (one-page printable view with demographics, conditions, meds, labs with trend arrows, encounters).
157
158
-`export_arkiv.py` — Arkiv universal record format (JSONL + README.md + schema.yaml). Primary backup/restore format with full round-trip support. Source assets exported to `media/` or inline base64 via `--embed`.
158
159
-`import_arkiv.py` — Arkiv import with validation, FK remapping, tag unfolding, and source asset restoration.
159
160
@@ -185,4 +186,4 @@ TOML config (`chartfold.toml`) for personalized settings. Key tests to chart, da
185
186
-`mhtml_test_result.py`: The function `test_result_to_unified` starts with `test_` — pytest tries to collect it as a test. Import it with `from ... import test_result_to_unified as adapt_test_result` in tests.
186
187
-`source_assets` are inserted via raw SQL in tests (not through the adapter pipeline).
187
188
-`_UNIQUE_KEYS` in `db.py` must match the UNIQUE constraints declared in `schema.sql`.
188
-
- When adding a new table: update `_TABLE_MAP`, `_UNIQUE_KEYS`, `schema.sql`, `models.py`, `export_arkiv.py` (`_TIMESTAMP_FIELDS`, `_COLLECTION_DESCRIPTIONS`, `_FK_FIELDS` if applicable), and `analysis/visit_diff.py`.
189
+
- When adding a new table: update `_TABLE_MAP`, `_UNIQUE_KEYS`, `schema.sql`, `models.py`, `export_arkiv.py` (`_TIMESTAMP_FIELDS`, `_COLLECTION_DESCRIPTIONS`, `_FK_FIELDS` if applicable), `analysis/visit_diff.py`, and if it's a non-clinical table add it to `_NON_CLINICAL_TABLES` in `spa/chat_prompt.py`.
0 commit comments