Truveta Prose — VSCode Extension
Syntax highlighting, bracket matching, comment toggling, and code snippets for the Truveta Prose query language.
Truveta Prose is a domain-specific language for patient cohort selection, data extraction, and aggregation over electronic health record (EHR) data in Truveta Studio.
Features
- Syntax highlighting for all Prose constructs — keywords, codesets, event set types, operators, interval literals (
@2026-03), template substitutions, and more
- Distinct terminology coloring —
"ICD10CM", "SNOMED CT", "RxNorm", "CPT", etc. stand out from regular strings
- Comment toggling —
Cmd+/ (Ctrl+/ on Windows/Linux) for line comments, Shift+Alt+A for block comments
- Bracket matching and auto-closing for
{}, (), [], ""
- Auto-indentation after
{ blocks
- 35 code snippets — type
filter, codeset, build, fe, aggdate, etc. and press Tab
Snippets
Core Statements
| Prefix |
Description |
imports |
Import base + event-base definitions |
importdef |
Import a data definition by URL |
export |
Export events from a data definition |
codeset |
Codeset with terminology and hierarchy mode picker |
codesetmulti |
Codeset combining two terminology systems |
filter |
Filter events from a base event set |
filterperson |
Filter PersonSet by demographics |
filterfirst |
Filter events, return first by sort order |
filterany |
Filter events, return any single match |
build |
Build/transform events with output projection |
buildindex |
Build an index event with asIndex |
bbs |
buildBySequence multi-event join |
bbstemporal |
buildBySequence with temporal distance constraints |
union |
Merge event sets |
population |
Population statement |
populationnot |
Population with inclusion and exclusion criteria |
return |
Return statement |
table |
Feature table |
tabledemog |
Feature table with standard demographics |
tablemerge |
Merge two tables column-wise |
aggregate |
Aggregate statistics |
Analytical Functions
| Prefix |
Description |
fe |
findEvent — find a single event by property match |
fer |
findEventInRange — find event within temporal window |
ce |
countEvents — count events matching a property value |
cer |
countEventsInRange — count events in temporal window |
exists |
hasValue(findEvent(...)) — existence check (SQL EXISTS equivalent) |
Aggregate Variants
| Prefix |
Description |
aggusing |
Aggregate with using eventSelector option |
aggdate |
Aggregate as time series (by date in months) |
aggage |
Aggregate age distribution (by age in years) |
aggtop |
Aggregate with output top N limit |
Patterns & Utilities
| Prefix |
Description |
listaccess |
Access first element of a base definition set |
ageat |
Age range filter using ageAt() |
coalesceindex |
Coalesce dates for IndexDateTime |
datevar |
Date literal assignment (@2024-01) |
section |
Section header comment banner |
Installation
From the VSCode Marketplace
Search for "Truveta Prose" in the Extensions panel (Cmd+Shift+X).
From .vsix file
code --install-extension truveta-prose-*.vsix
From source
git clone https://github.com/xiaosongz/truveta-prose-vscode.git
cd truveta-prose-vscode
npm install -g @vscode/vsce
vsce package
code --install-extension truveta-prose-*.vsix
Token Highlighting Reference
| Prose Element |
Highlighted As |
filter, build, buildBySequence, union, table, aggregate, population, return, export, datadef, output |
Statement keywords |
include, import |
Import keywords |
and, or, not, in, matches |
Logical operators |
closest, before, after, equal, equalSameDay, insideClosestStart, etc. |
Analytical operators (19 total) |
first, last, any, all, atLeast, sortBy, asc, desc, dedupe, asIndex, top, max |
Output modifiers |
using, eventSelector, operation, count, distinctCount, by, as, date, age, etc. |
Aggregate flags |
"ICD10CM", "SNOMED CT", "RxNorm", "CPT", "ICD10PCS", "ICD9CM", etc. |
Terminology constants (distinct color) |
self, selfAndDescendants, descendants |
Hierarchy modes |
true, false |
Boolean literals |
@2022, @2024-02, @2024-02-05 |
Date literals |
years, months, weeks, days, hours, minutes, seconds |
Time units |
ConditionSet, PersonSet, EncounterSet, MedicationUnionSet, DemographicsSet, etc. |
Event set types (21 total) |
hasValue(), coalesce(), ageAt(), countEvents(), findEvent(), findEventInRange(), etc. |
Built-in functions (40 total) |
Patient, indexTime, indexEvent, indexSet, PersonId, TruvetaId |
Reserved names |
${{ variable\|tocodeset }} |
Template substitution |
- truveta-prose-skill — Claude Code skill for writing, reviewing, and debugging Truveta Prose queries with AI assistance
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
MIT
| |