fhirpath-ts 0.0.0-bootstrap.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (414) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +391 -0
  3. package/THIRD-PARTY-NOTICES.md +296 -0
  4. package/dist/analyzer/analyze-dto.d.ts +45 -0
  5. package/dist/analyzer/analyze-dto.d.ts.map +1 -0
  6. package/dist/analyzer/analyze-dto.js +147 -0
  7. package/dist/analyzer/analyze-dto.js.map +1 -0
  8. package/dist/analyzer/analyze.d.ts +98 -0
  9. package/dist/analyzer/analyze.d.ts.map +1 -0
  10. package/dist/analyzer/analyze.js +925 -0
  11. package/dist/analyzer/analyze.js.map +1 -0
  12. package/dist/analyzer/expression-policy.d.ts +210 -0
  13. package/dist/analyzer/expression-policy.d.ts.map +1 -0
  14. package/dist/analyzer/expression-policy.js +254 -0
  15. package/dist/analyzer/expression-policy.js.map +1 -0
  16. package/dist/analyzer/index.d.ts +3 -0
  17. package/dist/analyzer/index.d.ts.map +1 -0
  18. package/dist/analyzer/index.js +6 -0
  19. package/dist/analyzer/index.js.map +1 -0
  20. package/dist/analyzer/regex-safety.d.ts +10 -0
  21. package/dist/analyzer/regex-safety.d.ts.map +1 -0
  22. package/dist/analyzer/regex-safety.js +84 -0
  23. package/dist/analyzer/regex-safety.js.map +1 -0
  24. package/dist/analyzer/signatures.d.ts +72 -0
  25. package/dist/analyzer/signatures.d.ts.map +1 -0
  26. package/dist/analyzer/signatures.js +195 -0
  27. package/dist/analyzer/signatures.js.map +1 -0
  28. package/dist/api/bundle.d.ts +29 -0
  29. package/dist/api/bundle.d.ts.map +1 -0
  30. package/dist/api/bundle.js +108 -0
  31. package/dist/api/bundle.js.map +1 -0
  32. package/dist/api/cache.d.ts +10 -0
  33. package/dist/api/cache.d.ts.map +1 -0
  34. package/dist/api/cache.js +38 -0
  35. package/dist/api/cache.js.map +1 -0
  36. package/dist/api/column-signature.d.ts +53 -0
  37. package/dist/api/column-signature.d.ts.map +1 -0
  38. package/dist/api/column-signature.js +43 -0
  39. package/dist/api/column-signature.js.map +1 -0
  40. package/dist/api/compile.d.ts +120 -0
  41. package/dist/api/compile.d.ts.map +1 -0
  42. package/dist/api/compile.js +167 -0
  43. package/dist/api/compile.js.map +1 -0
  44. package/dist/api/constraints.d.ts +48 -0
  45. package/dist/api/constraints.d.ts.map +1 -0
  46. package/dist/api/constraints.js +52 -0
  47. package/dist/api/constraints.js.map +1 -0
  48. package/dist/api/dto.d.ts +134 -0
  49. package/dist/api/dto.d.ts.map +1 -0
  50. package/dist/api/dto.js +295 -0
  51. package/dist/api/dto.js.map +1 -0
  52. package/dist/api/engine.d.ts +136 -0
  53. package/dist/api/engine.d.ts.map +1 -0
  54. package/dist/api/engine.js +183 -0
  55. package/dist/api/engine.js.map +1 -0
  56. package/dist/api/evaluate.d.ts +7 -0
  57. package/dist/api/evaluate.d.ts.map +1 -0
  58. package/dist/api/evaluate.js +10 -0
  59. package/dist/api/evaluate.js.map +1 -0
  60. package/dist/api/project.d.ts +89 -0
  61. package/dist/api/project.d.ts.map +1 -0
  62. package/dist/api/project.js +150 -0
  63. package/dist/api/project.js.map +1 -0
  64. package/dist/api/tagged.d.ts +14 -0
  65. package/dist/api/tagged.d.ts.map +1 -0
  66. package/dist/api/tagged.js +13 -0
  67. package/dist/api/tagged.js.map +1 -0
  68. package/dist/cli/dto-check.d.ts +25 -0
  69. package/dist/cli/dto-check.d.ts.map +1 -0
  70. package/dist/cli/dto-check.js +77 -0
  71. package/dist/cli/dto-check.js.map +1 -0
  72. package/dist/cli/fhirpath-check.d.ts +3 -0
  73. package/dist/cli/fhirpath-check.d.ts.map +1 -0
  74. package/dist/cli/fhirpath-check.js +149 -0
  75. package/dist/cli/fhirpath-check.js.map +1 -0
  76. package/dist/cli/ts-loader.d.mts +3 -0
  77. package/dist/cli/ts-loader.d.mts.map +1 -0
  78. package/dist/cli/ts-loader.mjs +48 -0
  79. package/dist/cli/ts-loader.mjs.map +1 -0
  80. package/dist/engine/context.d.ts +173 -0
  81. package/dist/engine/context.d.ts.map +1 -0
  82. package/dist/engine/context.js +118 -0
  83. package/dist/engine/context.js.map +1 -0
  84. package/dist/engine/evaluator.d.ts +7 -0
  85. package/dist/engine/evaluator.d.ts.map +1 -0
  86. package/dist/engine/evaluator.js +196 -0
  87. package/dist/engine/evaluator.js.map +1 -0
  88. package/dist/engine/navigation.d.ts +11 -0
  89. package/dist/engine/navigation.d.ts.map +1 -0
  90. package/dist/engine/navigation.js +102 -0
  91. package/dist/engine/navigation.js.map +1 -0
  92. package/dist/engine/operators/collections.d.ts +12 -0
  93. package/dist/engine/operators/collections.d.ts.map +1 -0
  94. package/dist/engine/operators/collections.js +31 -0
  95. package/dist/engine/operators/collections.js.map +1 -0
  96. package/dist/engine/operators/comparison.d.ts +13 -0
  97. package/dist/engine/operators/comparison.d.ts.map +1 -0
  98. package/dist/engine/operators/comparison.js +77 -0
  99. package/dist/engine/operators/comparison.js.map +1 -0
  100. package/dist/engine/operators/equality.d.ts +19 -0
  101. package/dist/engine/operators/equality.d.ts.map +1 -0
  102. package/dist/engine/operators/equality.js +203 -0
  103. package/dist/engine/operators/equality.js.map +1 -0
  104. package/dist/engine/operators/index.d.ts +18 -0
  105. package/dist/engine/operators/index.d.ts.map +1 -0
  106. package/dist/engine/operators/index.js +30 -0
  107. package/dist/engine/operators/index.js.map +1 -0
  108. package/dist/engine/operators/logic.d.ts +8 -0
  109. package/dist/engine/operators/logic.d.ts.map +1 -0
  110. package/dist/engine/operators/logic.js +38 -0
  111. package/dist/engine/operators/logic.js.map +1 -0
  112. package/dist/engine/operators/math.d.ts +13 -0
  113. package/dist/engine/operators/math.d.ts.map +1 -0
  114. package/dist/engine/operators/math.js +198 -0
  115. package/dist/engine/operators/math.js.map +1 -0
  116. package/dist/engine/operators/strings.d.ts +8 -0
  117. package/dist/engine/operators/strings.d.ts.map +1 -0
  118. package/dist/engine/operators/strings.js +22 -0
  119. package/dist/engine/operators/strings.js.map +1 -0
  120. package/dist/engine/operators/types.d.ts +3 -0
  121. package/dist/engine/operators/types.d.ts.map +1 -0
  122. package/dist/engine/operators/types.js +15 -0
  123. package/dist/engine/operators/types.js.map +1 -0
  124. package/dist/engine/type-matching.d.ts +20 -0
  125. package/dist/engine/type-matching.d.ts.map +1 -0
  126. package/dist/engine/type-matching.js +122 -0
  127. package/dist/engine/type-matching.js.map +1 -0
  128. package/dist/errors.d.ts +25 -0
  129. package/dist/errors.d.ts.map +1 -0
  130. package/dist/errors.js +21 -0
  131. package/dist/errors.js.map +1 -0
  132. package/dist/eslint/index.d.ts +12 -0
  133. package/dist/eslint/index.d.ts.map +1 -0
  134. package/dist/eslint/index.js +316 -0
  135. package/dist/eslint/index.js.map +1 -0
  136. package/dist/fhir/html-checks.d.ts +7 -0
  137. package/dist/fhir/html-checks.d.ts.map +1 -0
  138. package/dist/fhir/html-checks.js +256 -0
  139. package/dist/fhir/html-checks.js.map +1 -0
  140. package/dist/fhir/model-navigation.d.ts +11 -0
  141. package/dist/fhir/model-navigation.d.ts.map +1 -0
  142. package/dist/fhir/model-navigation.js +142 -0
  143. package/dist/fhir/model-navigation.js.map +1 -0
  144. package/dist/functions/aggregate.d.ts +2 -0
  145. package/dist/functions/aggregate.d.ts.map +1 -0
  146. package/dist/functions/aggregate.js +127 -0
  147. package/dist/functions/aggregate.js.map +1 -0
  148. package/dist/functions/boundary.d.ts +2 -0
  149. package/dist/functions/boundary.d.ts.map +1 -0
  150. package/dist/functions/boundary.js +189 -0
  151. package/dist/functions/boundary.js.map +1 -0
  152. package/dist/functions/combining.d.ts +2 -0
  153. package/dist/functions/combining.d.ts.map +1 -0
  154. package/dist/functions/combining.js +13 -0
  155. package/dist/functions/combining.js.map +1 -0
  156. package/dist/functions/control.d.ts +2 -0
  157. package/dist/functions/control.d.ts.map +1 -0
  158. package/dist/functions/control.js +25 -0
  159. package/dist/functions/control.js.map +1 -0
  160. package/dist/functions/conversion.d.ts +3 -0
  161. package/dist/functions/conversion.d.ts.map +1 -0
  162. package/dist/functions/conversion.js +316 -0
  163. package/dist/functions/conversion.js.map +1 -0
  164. package/dist/functions/date-components.d.ts +2 -0
  165. package/dist/functions/date-components.d.ts.map +1 -0
  166. package/dist/functions/date-components.js +81 -0
  167. package/dist/functions/date-components.js.map +1 -0
  168. package/dist/functions/existence.d.ts +4 -0
  169. package/dist/functions/existence.d.ts.map +1 -0
  170. package/dist/functions/existence.js +97 -0
  171. package/dist/functions/existence.js.map +1 -0
  172. package/dist/functions/fhir.d.ts +2 -0
  173. package/dist/functions/fhir.d.ts.map +1 -0
  174. package/dist/functions/fhir.js +222 -0
  175. package/dist/functions/fhir.js.map +1 -0
  176. package/dist/functions/filtering.d.ts +2 -0
  177. package/dist/functions/filtering.d.ts.map +1 -0
  178. package/dist/functions/filtering.js +112 -0
  179. package/dist/functions/filtering.js.map +1 -0
  180. package/dist/functions/install.d.ts +18 -0
  181. package/dist/functions/install.d.ts.map +1 -0
  182. package/dist/functions/install.js +20 -0
  183. package/dist/functions/install.js.map +1 -0
  184. package/dist/functions/iteration.d.ts +7 -0
  185. package/dist/functions/iteration.d.ts.map +1 -0
  186. package/dist/functions/iteration.js +9 -0
  187. package/dist/functions/iteration.js.map +1 -0
  188. package/dist/functions/math.d.ts +2 -0
  189. package/dist/functions/math.d.ts.map +1 -0
  190. package/dist/functions/math.js +152 -0
  191. package/dist/functions/math.js.map +1 -0
  192. package/dist/functions/reflection.d.ts +2 -0
  193. package/dist/functions/reflection.d.ts.map +1 -0
  194. package/dist/functions/reflection.js +23 -0
  195. package/dist/functions/reflection.js.map +1 -0
  196. package/dist/functions/registry.d.ts +28 -0
  197. package/dist/functions/registry.d.ts.map +1 -0
  198. package/dist/functions/registry.js +46 -0
  199. package/dist/functions/registry.js.map +1 -0
  200. package/dist/functions/sort.d.ts +2 -0
  201. package/dist/functions/sort.d.ts.map +1 -0
  202. package/dist/functions/sort.js +48 -0
  203. package/dist/functions/sort.js.map +1 -0
  204. package/dist/functions/string.d.ts +2 -0
  205. package/dist/functions/string.d.ts.map +1 -0
  206. package/dist/functions/string.js +353 -0
  207. package/dist/functions/string.js.map +1 -0
  208. package/dist/functions/subsetting.d.ts +2 -0
  209. package/dist/functions/subsetting.d.ts.map +1 -0
  210. package/dist/functions/subsetting.js +72 -0
  211. package/dist/functions/subsetting.js.map +1 -0
  212. package/dist/functions/tree.d.ts +8 -0
  213. package/dist/functions/tree.d.ts.map +1 -0
  214. package/dist/functions/tree.js +109 -0
  215. package/dist/functions/tree.js.map +1 -0
  216. package/dist/functions/type-specifier.d.ts +8 -0
  217. package/dist/functions/type-specifier.d.ts.map +1 -0
  218. package/dist/functions/type-specifier.js +27 -0
  219. package/dist/functions/type-specifier.js.map +1 -0
  220. package/dist/functions/utility.d.ts +2 -0
  221. package/dist/functions/utility.d.ts.map +1 -0
  222. package/dist/functions/utility.js +76 -0
  223. package/dist/functions/utility.js.map +1 -0
  224. package/dist/functions/variables.d.ts +2 -0
  225. package/dist/functions/variables.d.ts.map +1 -0
  226. package/dist/functions/variables.js +35 -0
  227. package/dist/functions/variables.js.map +1 -0
  228. package/dist/index.d.ts +25 -0
  229. package/dist/index.d.ts.map +1 -0
  230. package/dist/index.js +11 -0
  231. package/dist/index.js.map +1 -0
  232. package/dist/lexer/lexer.d.ts +4 -0
  233. package/dist/lexer/lexer.d.ts.map +1 -0
  234. package/dist/lexer/lexer.js +318 -0
  235. package/dist/lexer/lexer.js.map +1 -0
  236. package/dist/lexer/tokens.d.ts +23 -0
  237. package/dist/lexer/tokens.d.ts.map +1 -0
  238. package/dist/lexer/tokens.js +40 -0
  239. package/dist/lexer/tokens.js.map +1 -0
  240. package/dist/model/provider.d.ts +36 -0
  241. package/dist/model/provider.d.ts.map +1 -0
  242. package/dist/model/provider.js +2 -0
  243. package/dist/model/provider.js.map +1 -0
  244. package/dist/parser/ast.d.ts +104 -0
  245. package/dist/parser/ast.d.ts.map +1 -0
  246. package/dist/parser/ast.js +2 -0
  247. package/dist/parser/ast.js.map +1 -0
  248. package/dist/parser/parser.d.ts +4 -0
  249. package/dist/parser/parser.d.ts.map +1 -0
  250. package/dist/parser/parser.js +299 -0
  251. package/dist/parser/parser.js.map +1 -0
  252. package/dist/parser/precedence.d.ts +24 -0
  253. package/dist/parser/precedence.d.ts.map +1 -0
  254. package/dist/parser/precedence.js +52 -0
  255. package/dist/parser/precedence.js.map +1 -0
  256. package/dist/parser/printer.d.ts +4 -0
  257. package/dist/parser/printer.d.ts.map +1 -0
  258. package/dist/parser/printer.js +112 -0
  259. package/dist/parser/printer.js.map +1 -0
  260. package/dist/r4/generated/resources-data.d.ts +3 -0
  261. package/dist/r4/generated/resources-data.d.ts.map +1 -0
  262. package/dist/r4/generated/resources-data.js +28628 -0
  263. package/dist/r4/generated/resources-data.js.map +1 -0
  264. package/dist/r4/generated/type-maps.d.ts +43153 -0
  265. package/dist/r4/generated/type-maps.d.ts.map +1 -0
  266. package/dist/r4/generated/type-maps.js +4 -0
  267. package/dist/r4/generated/type-maps.js.map +1 -0
  268. package/dist/r4/generated/types-data.d.ts +3 -0
  269. package/dist/r4/generated/types-data.d.ts.map +1 -0
  270. package/dist/r4/generated/types-data.js +2205 -0
  271. package/dist/r4/generated/types-data.js.map +1 -0
  272. package/dist/r4/index.d.ts +9 -0
  273. package/dist/r4/index.d.ts.map +1 -0
  274. package/dist/r4/index.js +94 -0
  275. package/dist/r4/index.js.map +1 -0
  276. package/dist/r4/model-data.d.ts +17 -0
  277. package/dist/r4/model-data.d.ts.map +1 -0
  278. package/dist/r4/model-data.js +2 -0
  279. package/dist/r4/model-data.js.map +1 -0
  280. package/dist/sites/index.d.ts +31 -0
  281. package/dist/sites/index.d.ts.map +1 -0
  282. package/dist/sites/index.js +205 -0
  283. package/dist/sites/index.js.map +1 -0
  284. package/dist/typed/infer.d.ts +234 -0
  285. package/dist/typed/infer.d.ts.map +1 -0
  286. package/dist/typed/infer.js +85 -0
  287. package/dist/typed/infer.js.map +1 -0
  288. package/dist/typed/perf-fixture.types.d.ts +136 -0
  289. package/dist/typed/perf-fixture.types.d.ts.map +1 -0
  290. package/dist/typed/perf-fixture.types.js +2 -0
  291. package/dist/typed/perf-fixture.types.js.map +1 -0
  292. package/dist/values/collection.d.ts +24 -0
  293. package/dist/values/collection.d.ts.map +1 -0
  294. package/dist/values/collection.js +51 -0
  295. package/dist/values/collection.js.map +1 -0
  296. package/dist/values/datetime.d.ts +54 -0
  297. package/dist/values/datetime.d.ts.map +1 -0
  298. package/dist/values/datetime.js +226 -0
  299. package/dist/values/datetime.js.map +1 -0
  300. package/dist/values/decimal.d.ts +48 -0
  301. package/dist/values/decimal.d.ts.map +1 -0
  302. package/dist/values/decimal.js +188 -0
  303. package/dist/values/decimal.js.map +1 -0
  304. package/dist/values/numeric.d.ts +24 -0
  305. package/dist/values/numeric.d.ts.map +1 -0
  306. package/dist/values/numeric.js +53 -0
  307. package/dist/values/numeric.js.map +1 -0
  308. package/dist/values/quantity.d.ts +49 -0
  309. package/dist/values/quantity.d.ts.map +1 -0
  310. package/dist/values/quantity.js +297 -0
  311. package/dist/values/quantity.js.map +1 -0
  312. package/dist/values/temporal-arithmetic.d.ts +17 -0
  313. package/dist/values/temporal-arithmetic.d.ts.map +1 -0
  314. package/dist/values/temporal-arithmetic.js +183 -0
  315. package/dist/values/temporal-arithmetic.js.map +1 -0
  316. package/dist/values/temporal-compare.d.ts +9 -0
  317. package/dist/values/temporal-compare.d.ts.map +1 -0
  318. package/dist/values/temporal-compare.js +59 -0
  319. package/dist/values/temporal-compare.js.map +1 -0
  320. package/dist/values/type-compat.d.ts +47 -0
  321. package/dist/values/type-compat.d.ts.map +1 -0
  322. package/dist/values/type-compat.js +100 -0
  323. package/dist/values/type-compat.js.map +1 -0
  324. package/dist/values/typed-value.d.ts +48 -0
  325. package/dist/values/typed-value.d.ts.map +1 -0
  326. package/dist/values/typed-value.js +117 -0
  327. package/dist/values/typed-value.js.map +1 -0
  328. package/dist/values/ucum.d.ts +14 -0
  329. package/dist/values/ucum.d.ts.map +1 -0
  330. package/dist/values/ucum.js +146 -0
  331. package/dist/values/ucum.js.map +1 -0
  332. package/package.json +137 -0
  333. package/src/analyzer/analyze-dto.ts +195 -0
  334. package/src/analyzer/analyze.ts +1181 -0
  335. package/src/analyzer/expression-policy.ts +434 -0
  336. package/src/analyzer/index.ts +23 -0
  337. package/src/analyzer/regex-safety.ts +85 -0
  338. package/src/analyzer/signatures.ts +260 -0
  339. package/src/api/bundle.ts +132 -0
  340. package/src/api/cache.ts +40 -0
  341. package/src/api/column-signature.ts +71 -0
  342. package/src/api/compile.ts +308 -0
  343. package/src/api/constraints.ts +104 -0
  344. package/src/api/dto.ts +445 -0
  345. package/src/api/engine.ts +328 -0
  346. package/src/api/evaluate.ts +11 -0
  347. package/src/api/project.ts +255 -0
  348. package/src/api/tagged.ts +35 -0
  349. package/src/cli/dto-check.ts +94 -0
  350. package/src/cli/fhirpath-check.ts +168 -0
  351. package/src/cli/ts-loader.mjs +49 -0
  352. package/src/engine/context.ts +282 -0
  353. package/src/engine/evaluator.ts +246 -0
  354. package/src/engine/navigation.ts +106 -0
  355. package/src/engine/operators/collections.ts +34 -0
  356. package/src/engine/operators/comparison.ts +82 -0
  357. package/src/engine/operators/equality.ts +232 -0
  358. package/src/engine/operators/index.ts +65 -0
  359. package/src/engine/operators/logic.ts +53 -0
  360. package/src/engine/operators/math.ts +225 -0
  361. package/src/engine/operators/strings.ts +25 -0
  362. package/src/engine/operators/types.ts +16 -0
  363. package/src/engine/type-matching.ts +148 -0
  364. package/src/errors.ts +33 -0
  365. package/src/eslint/index.ts +388 -0
  366. package/src/fhir/html-checks.ts +266 -0
  367. package/src/fhir/model-navigation.ts +148 -0
  368. package/src/functions/aggregate.ts +136 -0
  369. package/src/functions/boundary.ts +209 -0
  370. package/src/functions/combining.ts +15 -0
  371. package/src/functions/control.ts +25 -0
  372. package/src/functions/conversion.ts +349 -0
  373. package/src/functions/date-components.ts +88 -0
  374. package/src/functions/existence.ts +107 -0
  375. package/src/functions/fhir.ts +247 -0
  376. package/src/functions/filtering.ts +120 -0
  377. package/src/functions/install.ts +19 -0
  378. package/src/functions/iteration.ts +21 -0
  379. package/src/functions/math.ts +167 -0
  380. package/src/functions/reflection.ts +24 -0
  381. package/src/functions/registry.ts +72 -0
  382. package/src/functions/sort.ts +68 -0
  383. package/src/functions/string.ts +413 -0
  384. package/src/functions/subsetting.ts +89 -0
  385. package/src/functions/tree.ts +112 -0
  386. package/src/functions/type-specifier.ts +29 -0
  387. package/src/functions/utility.ts +82 -0
  388. package/src/functions/variables.ts +36 -0
  389. package/src/index.ts +30 -0
  390. package/src/lexer/lexer.ts +341 -0
  391. package/src/lexer/tokens.ts +69 -0
  392. package/src/model/provider.ts +36 -0
  393. package/src/parser/ast.ts +164 -0
  394. package/src/parser/parser.ts +321 -0
  395. package/src/parser/precedence.ts +52 -0
  396. package/src/parser/printer.ts +114 -0
  397. package/src/r4/generated/resources-data.ts +28631 -0
  398. package/src/r4/generated/type-maps.ts +22145 -0
  399. package/src/r4/generated/types-data.ts +2208 -0
  400. package/src/r4/index.ts +107 -0
  401. package/src/r4/model-data.ts +17 -0
  402. package/src/sites/index.ts +285 -0
  403. package/src/typed/infer.ts +433 -0
  404. package/src/typed/perf-fixture.types.ts +143 -0
  405. package/src/values/collection.ts +57 -0
  406. package/src/values/datetime.ts +285 -0
  407. package/src/values/decimal.ts +213 -0
  408. package/src/values/numeric.ts +63 -0
  409. package/src/values/quantity.ts +358 -0
  410. package/src/values/temporal-arithmetic.ts +231 -0
  411. package/src/values/temporal-compare.ts +65 -0
  412. package/src/values/type-compat.ts +133 -0
  413. package/src/values/typed-value.ts +151 -0
  414. package/src/values/ucum.ts +181 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one of
111
+ the following places: within a NOTICE text file distributed as
112
+ part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Vinta Software
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,391 @@
1
+ # fhirpath-ts
2
+
3
+ A TypeScript-native [FHIRPath](https://hl7.org/fhirpath/) engine for application
4
+ development. It has zero runtime dependencies and includes:
5
+
6
+ - typed results for literal expressions in plain TypeScript;
7
+ - DTOs that transform FHIR resources into typed application data;
8
+ - static checks through TypeScript, ESLint, a CLI linter/analyzer, and a public analyzer API;
9
+ - official HL7 conformance tests plus tests from other FHIRPath engines;
10
+ - [Medplum](https://www.medplum.com/) compatibility;
11
+ - currently focused in FHIR R4, the most commonly used FHIR version.
12
+
13
+ Check the [playground demo](demo/README.md) or keep reading!
14
+
15
+ ## Quick start
16
+
17
+ ```ts
18
+ import { r4 } from 'fhirpath-ts/r4'
19
+
20
+ const patient = {
21
+ resourceType: 'Patient',
22
+ active: true,
23
+ name: [{ family: 'Okoro', given: ['Adaeze', 'Mina'] }],
24
+ } as const
25
+
26
+ r4.evaluate('Patient.name.given', patient) // ['Adaeze', 'Mina']
27
+ r4.first('Patient.name.family', patient) // 'Okoro'
28
+ r4.test(patient, 'Patient.active = true') // true
29
+
30
+ const family = r4.compile('Patient.name.family')
31
+ family.evaluate(patient) // ['Okoro']
32
+ ```
33
+
34
+ Engine methods parse on demand and cache by expression text. Build a separate
35
+ engine when you need different defaults:
36
+
37
+ ```ts
38
+ import { FhirPathEngine } from 'fhirpath-ts'
39
+ import { r4Model } from 'fhirpath-ts/r4'
40
+
41
+ const fp = new FhirPathEngine({ model: r4Model, env: { threshold: 5 } })
42
+ fp.evaluate('%threshold + 1') // [6]
43
+ ```
44
+
45
+ See [API reference](docs/api.md) for all entry points, options, custom functions,
46
+ DTO behavior, parse caching, and Medplum type compatibility.
47
+
48
+ ## Suggested usage: DTOs
49
+
50
+ For application code, prefer a DTO when several expressions build one row or
51
+ view model. The resource type is declared once. Each field keeps its TypeScript
52
+ type, and getters or methods can handle work that is clearer in TypeScript.
53
+
54
+ ```ts
55
+ import { column, criteria, defineDto } from 'fhirpath-ts'
56
+ import { r4 } from 'fhirpath-ts/r4'
57
+
58
+ class PatientRow extends defineDto('Patient') {
59
+ @column('id', { default: '' })
60
+ id!: string
61
+
62
+ @column("name.where(use = 'official').first().family", { default: '' })
63
+ family!: string
64
+
65
+ @column('name.given', { collection: true })
66
+ givenNames!: string[]
67
+
68
+ @criteria('active = true')
69
+ active!: boolean
70
+
71
+ get label(): string {
72
+ return this.family || this.id
73
+ }
74
+ }
75
+
76
+ const rows = r4.project([patient], PatientRow)
77
+ rows[0] // PatientRow { id: '', family: '', givenNames: [], active: true }
78
+ rows[0]?.label // ''
79
+ ```
80
+
81
+ `@column` and `@criteria` use standard JavaScript decorators. Your build must
82
+ transpile them. TypeScript works with `target` set to ES2024 or lower. SWC and Babel
83
+ also support them. For a build without decorator support,
84
+ [use records with `project()`](docs/api.md#project).
85
+
86
+ Pass DTOs through `resourceDtos` to call their columns from expressions with other
87
+ FHIR resources as root:
88
+
89
+ ```ts
90
+ class CodeableConceptDto extends defineDto('CodeableConcept') {
91
+ @column('(text | coding.display.first() | coding.first().code).first()')
92
+ displayText!: string | undefined
93
+ }
94
+
95
+ const fp = new FhirPathEngine({
96
+ model: r4Model,
97
+ resourceDtos: [CodeableConceptDto],
98
+ })
99
+
100
+ fp.first('Condition.code.displayText()', condition)
101
+ ```
102
+
103
+ This is useful for shared application vocabulary such as `displayText()` or `isFinal()`.
104
+
105
+ ## Usage recipes
106
+
107
+ These short examples show the main application APIs. The
108
+ [playground demo](demo/README.md) is the best place to explore expressions
109
+ interactively. A test runs every static expression in this section and checks it
110
+ with the analyzer.
111
+
112
+ ### Read, test, and filter
113
+
114
+ ```ts
115
+ r4.evaluate('Patient.name.given', patient)
116
+ r4.first('Patient.name.family', patient)
117
+ r4.test(patient, 'birthDate <= today()', { now: new Date('2026-08-04T12:00:00Z') })
118
+
119
+ const systolic = r4.filter(
120
+ observations,
121
+ "Observation.code.coding.exists(system = %loinc and code = '8480-6')",
122
+ { env: { loinc: 'http://loinc.org' } },
123
+ )
124
+ const newestFirst = r4.evaluate(
125
+ 'Observation.sort(-(effective.ofType(dateTime) | issued).first())',
126
+ systolic,
127
+ )
128
+ ```
129
+
130
+ ### Check constraints
131
+
132
+ `checkConstraints()` evaluates constraint expressions. It does not perform full
133
+ profile validation such as cardinality, bindings, or slicing.
134
+
135
+ ```ts
136
+ const result = r4.checkConstraints(patient, [
137
+ {
138
+ key: 'pat-1',
139
+ severity: 'error',
140
+ human: 'Contact needs a name or telecom',
141
+ expression: 'contact.all(name.exists() or telecom.exists())',
142
+ },
143
+ ])
144
+
145
+ result.valid // true
146
+ result.issues // []
147
+ result.toOperationOutcome() // { resourceType: 'OperationOutcome', issue: [{ severity: 'information', ... }] }
148
+ ```
149
+
150
+ ### Convert quantities
151
+
152
+ Known [UCUM](https://ucum.org/ucum) units compare and convert automatically.
153
+ Unknown units can still compare with the same unit.
154
+
155
+ ```ts
156
+ r4.filter(observations, "value.ofType(Quantity) > 140 'mm[Hg]'")
157
+ r4.filter(observations, "value.ofType(Quantity).convertsToQuantity('kg')")
158
+ r4.first("Observation.value.ofType(Quantity).toQuantity('kg').value", weight)
159
+ ```
160
+
161
+ ### Map status labels
162
+
163
+ `choices` converts codes into typed application values. A missing code becomes
164
+ empty, so `default` also handles future or unexpected codes.
165
+
166
+ ```ts
167
+ const STATUS_CHOICES = [
168
+ { code: 'active', label: 'Active', tone: 'info' },
169
+ { code: 'recurrence', label: 'Recurrence', tone: 'danger' },
170
+ { code: 'resolved', label: 'Resolved', tone: 'neutral' },
171
+ ] as const
172
+
173
+ const statusRows = r4.project(conditions, {
174
+ label: {
175
+ path: 'Condition.clinicalStatus.coding.first().code',
176
+ choices: STATUS_CHOICES,
177
+ pick: 'label',
178
+ default: 'Unknown',
179
+ },
180
+ tone: {
181
+ path: 'Condition.clinicalStatus.coding.first().code',
182
+ choices: STATUS_CHOICES,
183
+ pick: 'tone',
184
+ default: 'neutral' as const,
185
+ },
186
+ })
187
+
188
+ statusRows // [{ label: 'Active', tone: 'info' }, ..., { label: 'Unknown', tone: 'neutral' }]
189
+ ```
190
+
191
+ ### Join related resources
192
+
193
+ Pass lookup data through `env`. Use `vars` to find the related item once per
194
+ row. `%context` is the resource for the current row.
195
+
196
+ ```ts
197
+ const reports = [...reportsByOrderId].map(([orderId, report]) => ({ orderId, report }))
198
+
199
+ r4.project(
200
+ orders,
201
+ {
202
+ resultDate: {
203
+ path: '(%report.effective.ofType(dateTime) | %report.issued).first()',
204
+ type: 'string',
205
+ default: null,
206
+ },
207
+ hasResult: { test: '%report.exists()' },
208
+ },
209
+ { env: { reports }, vars: { report: '%reports.where(orderId = %context.id).report' } },
210
+ )
211
+ ```
212
+
213
+ ### Follow references in a Bundle
214
+
215
+ `resolve()` follows contained references and references to another Bundle entry.
216
+ Start at `Bundle` so the Bundle remains available as the lookup scope.
217
+
218
+ ```ts
219
+ r4.evaluate(
220
+ 'Bundle.entry.resource.ofType(Observation).subject.resolve().name.family',
221
+ searchset,
222
+ )
223
+ ```
224
+
225
+ ### Walk nested structures
226
+
227
+ `repeat(item)` follows every nested `item` collection and returns the items at
228
+ all depths, so this reads each questionnaire item's `linkId`.
229
+
230
+ ```ts
231
+ r4.evaluate('Questionnaire.repeat(item).linkId', questionnaire)
232
+ ```
233
+
234
+ ### Deterministic tests and debugging
235
+
236
+ `now` fixes the evaluation clock. `trace()` sends values to the sink you provide
237
+ and does not log by itself.
238
+
239
+ ```ts
240
+ r4.test(patient, 'birthDate <= today()', {
241
+ now: new Date('2026-08-04T12:00:00Z'),
242
+ })
243
+
244
+ r4.evaluate("Patient.name.trace('names').given", patient, {
245
+ trace: (name, values) => debugSink(name, values),
246
+ })
247
+ ```
248
+
249
+ ## Important gotchas
250
+
251
+ - FHIRPath always evaluates collections. Use `first()` when application code
252
+ expects one optional value.
253
+ - Unknown elements evaluate to an empty collection, as they do in other
254
+ engines. Use [static checking](#static-checking) to catch misspellings before runtime.
255
+ - Use choice stems such as `Observation.value`, not JSON keys such as
256
+ `valueQuantity`. The analyzer reports the latter as an error.
257
+ - A bare search Bundle is treated as its entry resources for application helpers.
258
+ Start an expression at `Bundle` to address the Bundle itself, or wrap it in an
259
+ array to force one-resource treatment.
260
+ - Inside `where()`, the focus is the item being scanned. Use `%context` or a
261
+ `%var` when a join condition needs the outer resource.
262
+ - `env` contains plain host values. `vars` contains FHIRPath expressions evaluated
263
+ against the input and keeps FHIRPath type information.
264
+
265
+ ## Static checking
266
+
267
+ Literal expressions infer useful result and input types without a compiler
268
+ plugin:
269
+
270
+ ```ts
271
+ const given = r4.compile('Patient.name.given')
272
+ given.evaluate(patient) // string[]; the input must be a Patient
273
+ ```
274
+
275
+ Type inference stays conservative. Expressions outside its supported subset
276
+ become `unknown[]` instead of producing an incorrect type.
277
+
278
+ Static checking has three layers:
279
+
280
+ 1. TypeScript infers common literal expressions at compile time.
281
+ 2. `fhirpath-ts/eslint` checks expression literals while linting.
282
+ 3. `fhirpath-check` runs the same analyzer without requiring ESLint and can load
283
+ exported DTOs for a complete DTO check.
284
+
285
+ The analyzer is also public for editors, tests, and other tools. It follows the
286
+ [FHIRPath §11 rules](https://hl7.org/fhirpath/en/index.html#type-safety-and-strict-evaluation)
287
+ and is tested against the official valid and invalid cases.
288
+ See [Static checking](docs/static-checking.md) for configuration, supported call
289
+ sites, DTO discovery, and cases where source-only checks stay quiet.
290
+
291
+ ## Conformance
292
+
293
+ The engine passes every non-skipped case in the vendored official R4 and R5
294
+ FHIRPath suites. It also runs the fhirpath.js and fhirpath-py corpora. Each skip
295
+ and intentional difference has a checked manifest entry with its reason.
296
+
297
+ Property tests cover parser round trips, decimal arithmetic, and temporal
298
+ comparisons. Generated expressions are also compared with fhirpath.js. A weekly
299
+ job checks for changes in the upstream official suite (FHIR/fhir-test-cases).
300
+
301
+ See [Conformance](docs/conformance.md) for counts, skip categories, phase checks,
302
+ reference-suite results, and test maintenance. See
303
+ [Engine comparison](docs/engine-comparison.md) for the feature and correctness
304
+ comparison with other implementations.
305
+
306
+ ## Licensing and attribution
307
+
308
+ Package code is part of this private repository. Third-party material and full
309
+ license texts are collected in
310
+ [`THIRD-PARTY-NOTICES.md`](./THIRD-PARTY-NOTICES.md).
311
+
312
+ - The parser structure is adapted from Medplum (Apache-2.0).
313
+ - Official FHIRPath tests come from FHIR/fhir-test-cases (Apache-2.0 and FHIR CC0
314
+ content).
315
+ - Reference tests come from HL7/fhirpath.js (NLM BSD-style) and fhirpath-py (MIT).
316
+ - Additional cases come from fhirpath-rs (Apache-2.0) and Medplum.
317
+ - R4 model data is generated from HL7 FHIR R4 StructureDefinitions (CC0) in
318
+ `@medplum/definitions`. FHIR® is a registered trademark of HL7.
319
+
320
+ ## Development
321
+
322
+ ```bash
323
+ pnpm test
324
+ pnpm coverage
325
+ pnpm typecheck
326
+ pnpm lint
327
+ pnpm check:fhirpath
328
+ pnpm check:type-perf
329
+ pnpm generate:r4
330
+ ```
331
+
332
+ Run the demo separately:
333
+
334
+ ```bash
335
+ cd demo
336
+ npm install
337
+ npm run dev
338
+ ```
339
+
340
+ After changing the public API, run `npm run generate:dts` in `demo/` to refresh
341
+ the Monaco declarations. See [AGENTS.md](AGENTS.md) for repository decisions that
342
+ are easy to break during maintenance.
343
+
344
+ ## Gaps and deferred features
345
+
346
+ The package currently ships only an R4 model. The engine is synchronous. Tagged
347
+ templates remain untyped because TypeScript does not preserve their literal type
348
+ ([TypeScript #33304](https://github.com/microsoft/TypeScript/issues/33304)); use
349
+ `fhirpath('...')` or `compile('...')` for inference in strings.
350
+ Regex evaluation of user-authored expressions needs the security setup below.
351
+
352
+ These features are deferred and fail with a clear error today:
353
+
354
+ | Feature | What it needs |
355
+ | --- | --- |
356
+ | `memberOf()`, `subsumes()`, `subsumedBy()`, `%terminologies` | An async `TerminologyProvider` |
357
+ | External `resolve()` | The same async evaluation path |
358
+ | `conformsTo()` beyond base StructureDefinitions | Profile-aware validation |
359
+ | `slice()`, `elementDefinition()`, `checkModifiers()` | Profile definitions in the model |
360
+ | `weight()` | Code-system `itemWeight` lookups |
361
+ | `%factory` | Demand for the current R5 draft API |
362
+ | CDA mode | A CDA `ModelProvider` |
363
+ | Full UCUM | A full UCUM implementation behind the current interface |
364
+ | R5 model package | Generated R5 definitions and types |
365
+
366
+ ## Security guidelines
367
+
368
+ ### Expression trust
369
+
370
+ Parser depth, tokenization, decimal and UCUM exponents, and property navigation
371
+ have limits suitable for untrusted input. Regular expressions need one extra
372
+ step. By default, `matches()`, `matchesFull()`, and `replaceMatches()` use the
373
+ host `RegExp`, so a pattern with catastrophic backtracking can block the event
374
+ loop.
375
+
376
+ The analyzer warns about backtracking-prone literal patterns. If users can write
377
+ expressions, also provide a linear-time regular expression engine, such as an RE2
378
+ binding, through `EvaluateOptions.regex`. Review or sandbox user expressions as
379
+ appropriate for the application.
380
+
381
+ ### Narrative checking
382
+
383
+ `htmlChecks()` checks FHIR narrative rules and allows only inert URL schemes. It
384
+ decodes attribute entities in the same way as a browser. A `true` result means
385
+ the narrative contains no active content.
386
+
387
+ ### PHI and tracing
388
+
389
+ `trace()` does nothing unless a trace sink is provided. Traced values may contain
390
+ patient data. Never send PHI values to console output or production logs; use
391
+ record identifiers instead.