{"library":"picorules-compiler-js-core","title":"Picorules Compiler JS Core","description":"Pure JavaScript/TypeScript compiler and runtime evaluator for the Picorules clinical decision support language. Compiles ruleblocks to optimized SQL (Oracle, SQL Server, PostgreSQL) or evaluates directly in JavaScript for single-patient use (browser, Node.js, edge). v1.1.1 – production-ready, zero runtime dependencies (Zod only for input validation), full type safety, tree-shakeable ESM/CJS, 406 tests. Unique: dual execution mode (SQL batch vs in-memory), pluggable data adapters (EADV built-in), automatic cross-ruleblock dependency resolution.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install picorules-compiler-js-core"],"cli":null},"imports":["import { compile } from 'picorules-compiler-js-core'","import { parse } from 'picorules-compiler-js-core'","import { evaluate } from 'picorules-compiler-js-core'","import { EadvDataAdapter } from 'picorules-compiler-js-core'","import { Dialect } from 'picorules-compiler-js-core'","import { evaluateAll } from 'picorules-compiler-js-core'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { parse, evaluate, EadvDataAdapter } from 'picorules-compiler-js-core';\n\nconst prbSource = `\n  #define_ruleblock(cd_obesity, {\n    description: \"BMI assessment\",\n    is_active: 2\n  });\n\n  ht => eadv.obs_height.val.lastdv();\n  wt => eadv.obs_weight.val.lastdv();\n\n  bmi : { ht_val!? and wt_val!? => round(wt_val / power(ht_val / 100, 2), 1) };\n  is_obese : { bmi > 30 => 1 }, { => 0 };\n`;\n\nconst parsed = parse([{ name: 'cd_obesity', text: prbSource, isActive: true }]);\nconst adapter = new EadvDataAdapter([\n  { eid: 1, att: 'obs_height', dt: '2024-06-01', val: 170 },\n  { eid: 1, att: 'obs_weight', dt: '2024-06-01', val: 95 },\n]);\nconst result = evaluate(parsed[0], adapter);\nconsole.log(result);\n// { ht_val: 170, ht_dt: Date, wt_val: 95, wt_dt: Date, bmi: 32.9, is_obese: 1 }","lang":"typescript","description":"Parses a Picorules ruleblock, loads EADV patient data, and evaluates the rule in JavaScript (no SQL required).","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}