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.
- package/LICENSE +201 -0
- package/README.md +391 -0
- package/THIRD-PARTY-NOTICES.md +296 -0
- package/dist/analyzer/analyze-dto.d.ts +45 -0
- package/dist/analyzer/analyze-dto.d.ts.map +1 -0
- package/dist/analyzer/analyze-dto.js +147 -0
- package/dist/analyzer/analyze-dto.js.map +1 -0
- package/dist/analyzer/analyze.d.ts +98 -0
- package/dist/analyzer/analyze.d.ts.map +1 -0
- package/dist/analyzer/analyze.js +925 -0
- package/dist/analyzer/analyze.js.map +1 -0
- package/dist/analyzer/expression-policy.d.ts +210 -0
- package/dist/analyzer/expression-policy.d.ts.map +1 -0
- package/dist/analyzer/expression-policy.js +254 -0
- package/dist/analyzer/expression-policy.js.map +1 -0
- package/dist/analyzer/index.d.ts +3 -0
- package/dist/analyzer/index.d.ts.map +1 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/analyzer/index.js.map +1 -0
- package/dist/analyzer/regex-safety.d.ts +10 -0
- package/dist/analyzer/regex-safety.d.ts.map +1 -0
- package/dist/analyzer/regex-safety.js +84 -0
- package/dist/analyzer/regex-safety.js.map +1 -0
- package/dist/analyzer/signatures.d.ts +72 -0
- package/dist/analyzer/signatures.d.ts.map +1 -0
- package/dist/analyzer/signatures.js +195 -0
- package/dist/analyzer/signatures.js.map +1 -0
- package/dist/api/bundle.d.ts +29 -0
- package/dist/api/bundle.d.ts.map +1 -0
- package/dist/api/bundle.js +108 -0
- package/dist/api/bundle.js.map +1 -0
- package/dist/api/cache.d.ts +10 -0
- package/dist/api/cache.d.ts.map +1 -0
- package/dist/api/cache.js +38 -0
- package/dist/api/cache.js.map +1 -0
- package/dist/api/column-signature.d.ts +53 -0
- package/dist/api/column-signature.d.ts.map +1 -0
- package/dist/api/column-signature.js +43 -0
- package/dist/api/column-signature.js.map +1 -0
- package/dist/api/compile.d.ts +120 -0
- package/dist/api/compile.d.ts.map +1 -0
- package/dist/api/compile.js +167 -0
- package/dist/api/compile.js.map +1 -0
- package/dist/api/constraints.d.ts +48 -0
- package/dist/api/constraints.d.ts.map +1 -0
- package/dist/api/constraints.js +52 -0
- package/dist/api/constraints.js.map +1 -0
- package/dist/api/dto.d.ts +134 -0
- package/dist/api/dto.d.ts.map +1 -0
- package/dist/api/dto.js +295 -0
- package/dist/api/dto.js.map +1 -0
- package/dist/api/engine.d.ts +136 -0
- package/dist/api/engine.d.ts.map +1 -0
- package/dist/api/engine.js +183 -0
- package/dist/api/engine.js.map +1 -0
- package/dist/api/evaluate.d.ts +7 -0
- package/dist/api/evaluate.d.ts.map +1 -0
- package/dist/api/evaluate.js +10 -0
- package/dist/api/evaluate.js.map +1 -0
- package/dist/api/project.d.ts +89 -0
- package/dist/api/project.d.ts.map +1 -0
- package/dist/api/project.js +150 -0
- package/dist/api/project.js.map +1 -0
- package/dist/api/tagged.d.ts +14 -0
- package/dist/api/tagged.d.ts.map +1 -0
- package/dist/api/tagged.js +13 -0
- package/dist/api/tagged.js.map +1 -0
- package/dist/cli/dto-check.d.ts +25 -0
- package/dist/cli/dto-check.d.ts.map +1 -0
- package/dist/cli/dto-check.js +77 -0
- package/dist/cli/dto-check.js.map +1 -0
- package/dist/cli/fhirpath-check.d.ts +3 -0
- package/dist/cli/fhirpath-check.d.ts.map +1 -0
- package/dist/cli/fhirpath-check.js +149 -0
- package/dist/cli/fhirpath-check.js.map +1 -0
- package/dist/cli/ts-loader.d.mts +3 -0
- package/dist/cli/ts-loader.d.mts.map +1 -0
- package/dist/cli/ts-loader.mjs +48 -0
- package/dist/cli/ts-loader.mjs.map +1 -0
- package/dist/engine/context.d.ts +173 -0
- package/dist/engine/context.d.ts.map +1 -0
- package/dist/engine/context.js +118 -0
- package/dist/engine/context.js.map +1 -0
- package/dist/engine/evaluator.d.ts +7 -0
- package/dist/engine/evaluator.d.ts.map +1 -0
- package/dist/engine/evaluator.js +196 -0
- package/dist/engine/evaluator.js.map +1 -0
- package/dist/engine/navigation.d.ts +11 -0
- package/dist/engine/navigation.d.ts.map +1 -0
- package/dist/engine/navigation.js +102 -0
- package/dist/engine/navigation.js.map +1 -0
- package/dist/engine/operators/collections.d.ts +12 -0
- package/dist/engine/operators/collections.d.ts.map +1 -0
- package/dist/engine/operators/collections.js +31 -0
- package/dist/engine/operators/collections.js.map +1 -0
- package/dist/engine/operators/comparison.d.ts +13 -0
- package/dist/engine/operators/comparison.d.ts.map +1 -0
- package/dist/engine/operators/comparison.js +77 -0
- package/dist/engine/operators/comparison.js.map +1 -0
- package/dist/engine/operators/equality.d.ts +19 -0
- package/dist/engine/operators/equality.d.ts.map +1 -0
- package/dist/engine/operators/equality.js +203 -0
- package/dist/engine/operators/equality.js.map +1 -0
- package/dist/engine/operators/index.d.ts +18 -0
- package/dist/engine/operators/index.d.ts.map +1 -0
- package/dist/engine/operators/index.js +30 -0
- package/dist/engine/operators/index.js.map +1 -0
- package/dist/engine/operators/logic.d.ts +8 -0
- package/dist/engine/operators/logic.d.ts.map +1 -0
- package/dist/engine/operators/logic.js +38 -0
- package/dist/engine/operators/logic.js.map +1 -0
- package/dist/engine/operators/math.d.ts +13 -0
- package/dist/engine/operators/math.d.ts.map +1 -0
- package/dist/engine/operators/math.js +198 -0
- package/dist/engine/operators/math.js.map +1 -0
- package/dist/engine/operators/strings.d.ts +8 -0
- package/dist/engine/operators/strings.d.ts.map +1 -0
- package/dist/engine/operators/strings.js +22 -0
- package/dist/engine/operators/strings.js.map +1 -0
- package/dist/engine/operators/types.d.ts +3 -0
- package/dist/engine/operators/types.d.ts.map +1 -0
- package/dist/engine/operators/types.js +15 -0
- package/dist/engine/operators/types.js.map +1 -0
- package/dist/engine/type-matching.d.ts +20 -0
- package/dist/engine/type-matching.d.ts.map +1 -0
- package/dist/engine/type-matching.js +122 -0
- package/dist/engine/type-matching.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/eslint/index.d.ts +12 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +316 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/fhir/html-checks.d.ts +7 -0
- package/dist/fhir/html-checks.d.ts.map +1 -0
- package/dist/fhir/html-checks.js +256 -0
- package/dist/fhir/html-checks.js.map +1 -0
- package/dist/fhir/model-navigation.d.ts +11 -0
- package/dist/fhir/model-navigation.d.ts.map +1 -0
- package/dist/fhir/model-navigation.js +142 -0
- package/dist/fhir/model-navigation.js.map +1 -0
- package/dist/functions/aggregate.d.ts +2 -0
- package/dist/functions/aggregate.d.ts.map +1 -0
- package/dist/functions/aggregate.js +127 -0
- package/dist/functions/aggregate.js.map +1 -0
- package/dist/functions/boundary.d.ts +2 -0
- package/dist/functions/boundary.d.ts.map +1 -0
- package/dist/functions/boundary.js +189 -0
- package/dist/functions/boundary.js.map +1 -0
- package/dist/functions/combining.d.ts +2 -0
- package/dist/functions/combining.d.ts.map +1 -0
- package/dist/functions/combining.js +13 -0
- package/dist/functions/combining.js.map +1 -0
- package/dist/functions/control.d.ts +2 -0
- package/dist/functions/control.d.ts.map +1 -0
- package/dist/functions/control.js +25 -0
- package/dist/functions/control.js.map +1 -0
- package/dist/functions/conversion.d.ts +3 -0
- package/dist/functions/conversion.d.ts.map +1 -0
- package/dist/functions/conversion.js +316 -0
- package/dist/functions/conversion.js.map +1 -0
- package/dist/functions/date-components.d.ts +2 -0
- package/dist/functions/date-components.d.ts.map +1 -0
- package/dist/functions/date-components.js +81 -0
- package/dist/functions/date-components.js.map +1 -0
- package/dist/functions/existence.d.ts +4 -0
- package/dist/functions/existence.d.ts.map +1 -0
- package/dist/functions/existence.js +97 -0
- package/dist/functions/existence.js.map +1 -0
- package/dist/functions/fhir.d.ts +2 -0
- package/dist/functions/fhir.d.ts.map +1 -0
- package/dist/functions/fhir.js +222 -0
- package/dist/functions/fhir.js.map +1 -0
- package/dist/functions/filtering.d.ts +2 -0
- package/dist/functions/filtering.d.ts.map +1 -0
- package/dist/functions/filtering.js +112 -0
- package/dist/functions/filtering.js.map +1 -0
- package/dist/functions/install.d.ts +18 -0
- package/dist/functions/install.d.ts.map +1 -0
- package/dist/functions/install.js +20 -0
- package/dist/functions/install.js.map +1 -0
- package/dist/functions/iteration.d.ts +7 -0
- package/dist/functions/iteration.d.ts.map +1 -0
- package/dist/functions/iteration.js +9 -0
- package/dist/functions/iteration.js.map +1 -0
- package/dist/functions/math.d.ts +2 -0
- package/dist/functions/math.d.ts.map +1 -0
- package/dist/functions/math.js +152 -0
- package/dist/functions/math.js.map +1 -0
- package/dist/functions/reflection.d.ts +2 -0
- package/dist/functions/reflection.d.ts.map +1 -0
- package/dist/functions/reflection.js +23 -0
- package/dist/functions/reflection.js.map +1 -0
- package/dist/functions/registry.d.ts +28 -0
- package/dist/functions/registry.d.ts.map +1 -0
- package/dist/functions/registry.js +46 -0
- package/dist/functions/registry.js.map +1 -0
- package/dist/functions/sort.d.ts +2 -0
- package/dist/functions/sort.d.ts.map +1 -0
- package/dist/functions/sort.js +48 -0
- package/dist/functions/sort.js.map +1 -0
- package/dist/functions/string.d.ts +2 -0
- package/dist/functions/string.d.ts.map +1 -0
- package/dist/functions/string.js +353 -0
- package/dist/functions/string.js.map +1 -0
- package/dist/functions/subsetting.d.ts +2 -0
- package/dist/functions/subsetting.d.ts.map +1 -0
- package/dist/functions/subsetting.js +72 -0
- package/dist/functions/subsetting.js.map +1 -0
- package/dist/functions/tree.d.ts +8 -0
- package/dist/functions/tree.d.ts.map +1 -0
- package/dist/functions/tree.js +109 -0
- package/dist/functions/tree.js.map +1 -0
- package/dist/functions/type-specifier.d.ts +8 -0
- package/dist/functions/type-specifier.d.ts.map +1 -0
- package/dist/functions/type-specifier.js +27 -0
- package/dist/functions/type-specifier.js.map +1 -0
- package/dist/functions/utility.d.ts +2 -0
- package/dist/functions/utility.d.ts.map +1 -0
- package/dist/functions/utility.js +76 -0
- package/dist/functions/utility.js.map +1 -0
- package/dist/functions/variables.d.ts +2 -0
- package/dist/functions/variables.d.ts.map +1 -0
- package/dist/functions/variables.js +35 -0
- package/dist/functions/variables.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/lexer.d.ts +4 -0
- package/dist/lexer/lexer.d.ts.map +1 -0
- package/dist/lexer/lexer.js +318 -0
- package/dist/lexer/lexer.js.map +1 -0
- package/dist/lexer/tokens.d.ts +23 -0
- package/dist/lexer/tokens.d.ts.map +1 -0
- package/dist/lexer/tokens.js +40 -0
- package/dist/lexer/tokens.js.map +1 -0
- package/dist/model/provider.d.ts +36 -0
- package/dist/model/provider.d.ts.map +1 -0
- package/dist/model/provider.js +2 -0
- package/dist/model/provider.js.map +1 -0
- package/dist/parser/ast.d.ts +104 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +2 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/parser.d.ts +4 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +299 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/precedence.d.ts +24 -0
- package/dist/parser/precedence.d.ts.map +1 -0
- package/dist/parser/precedence.js +52 -0
- package/dist/parser/precedence.js.map +1 -0
- package/dist/parser/printer.d.ts +4 -0
- package/dist/parser/printer.d.ts.map +1 -0
- package/dist/parser/printer.js +112 -0
- package/dist/parser/printer.js.map +1 -0
- package/dist/r4/generated/resources-data.d.ts +3 -0
- package/dist/r4/generated/resources-data.d.ts.map +1 -0
- package/dist/r4/generated/resources-data.js +28628 -0
- package/dist/r4/generated/resources-data.js.map +1 -0
- package/dist/r4/generated/type-maps.d.ts +43153 -0
- package/dist/r4/generated/type-maps.d.ts.map +1 -0
- package/dist/r4/generated/type-maps.js +4 -0
- package/dist/r4/generated/type-maps.js.map +1 -0
- package/dist/r4/generated/types-data.d.ts +3 -0
- package/dist/r4/generated/types-data.d.ts.map +1 -0
- package/dist/r4/generated/types-data.js +2205 -0
- package/dist/r4/generated/types-data.js.map +1 -0
- package/dist/r4/index.d.ts +9 -0
- package/dist/r4/index.d.ts.map +1 -0
- package/dist/r4/index.js +94 -0
- package/dist/r4/index.js.map +1 -0
- package/dist/r4/model-data.d.ts +17 -0
- package/dist/r4/model-data.d.ts.map +1 -0
- package/dist/r4/model-data.js +2 -0
- package/dist/r4/model-data.js.map +1 -0
- package/dist/sites/index.d.ts +31 -0
- package/dist/sites/index.d.ts.map +1 -0
- package/dist/sites/index.js +205 -0
- package/dist/sites/index.js.map +1 -0
- package/dist/typed/infer.d.ts +234 -0
- package/dist/typed/infer.d.ts.map +1 -0
- package/dist/typed/infer.js +85 -0
- package/dist/typed/infer.js.map +1 -0
- package/dist/typed/perf-fixture.types.d.ts +136 -0
- package/dist/typed/perf-fixture.types.d.ts.map +1 -0
- package/dist/typed/perf-fixture.types.js +2 -0
- package/dist/typed/perf-fixture.types.js.map +1 -0
- package/dist/values/collection.d.ts +24 -0
- package/dist/values/collection.d.ts.map +1 -0
- package/dist/values/collection.js +51 -0
- package/dist/values/collection.js.map +1 -0
- package/dist/values/datetime.d.ts +54 -0
- package/dist/values/datetime.d.ts.map +1 -0
- package/dist/values/datetime.js +226 -0
- package/dist/values/datetime.js.map +1 -0
- package/dist/values/decimal.d.ts +48 -0
- package/dist/values/decimal.d.ts.map +1 -0
- package/dist/values/decimal.js +188 -0
- package/dist/values/decimal.js.map +1 -0
- package/dist/values/numeric.d.ts +24 -0
- package/dist/values/numeric.d.ts.map +1 -0
- package/dist/values/numeric.js +53 -0
- package/dist/values/numeric.js.map +1 -0
- package/dist/values/quantity.d.ts +49 -0
- package/dist/values/quantity.d.ts.map +1 -0
- package/dist/values/quantity.js +297 -0
- package/dist/values/quantity.js.map +1 -0
- package/dist/values/temporal-arithmetic.d.ts +17 -0
- package/dist/values/temporal-arithmetic.d.ts.map +1 -0
- package/dist/values/temporal-arithmetic.js +183 -0
- package/dist/values/temporal-arithmetic.js.map +1 -0
- package/dist/values/temporal-compare.d.ts +9 -0
- package/dist/values/temporal-compare.d.ts.map +1 -0
- package/dist/values/temporal-compare.js +59 -0
- package/dist/values/temporal-compare.js.map +1 -0
- package/dist/values/type-compat.d.ts +47 -0
- package/dist/values/type-compat.d.ts.map +1 -0
- package/dist/values/type-compat.js +100 -0
- package/dist/values/type-compat.js.map +1 -0
- package/dist/values/typed-value.d.ts +48 -0
- package/dist/values/typed-value.d.ts.map +1 -0
- package/dist/values/typed-value.js +117 -0
- package/dist/values/typed-value.js.map +1 -0
- package/dist/values/ucum.d.ts +14 -0
- package/dist/values/ucum.d.ts.map +1 -0
- package/dist/values/ucum.js +146 -0
- package/dist/values/ucum.js.map +1 -0
- package/package.json +137 -0
- package/src/analyzer/analyze-dto.ts +195 -0
- package/src/analyzer/analyze.ts +1181 -0
- package/src/analyzer/expression-policy.ts +434 -0
- package/src/analyzer/index.ts +23 -0
- package/src/analyzer/regex-safety.ts +85 -0
- package/src/analyzer/signatures.ts +260 -0
- package/src/api/bundle.ts +132 -0
- package/src/api/cache.ts +40 -0
- package/src/api/column-signature.ts +71 -0
- package/src/api/compile.ts +308 -0
- package/src/api/constraints.ts +104 -0
- package/src/api/dto.ts +445 -0
- package/src/api/engine.ts +328 -0
- package/src/api/evaluate.ts +11 -0
- package/src/api/project.ts +255 -0
- package/src/api/tagged.ts +35 -0
- package/src/cli/dto-check.ts +94 -0
- package/src/cli/fhirpath-check.ts +168 -0
- package/src/cli/ts-loader.mjs +49 -0
- package/src/engine/context.ts +282 -0
- package/src/engine/evaluator.ts +246 -0
- package/src/engine/navigation.ts +106 -0
- package/src/engine/operators/collections.ts +34 -0
- package/src/engine/operators/comparison.ts +82 -0
- package/src/engine/operators/equality.ts +232 -0
- package/src/engine/operators/index.ts +65 -0
- package/src/engine/operators/logic.ts +53 -0
- package/src/engine/operators/math.ts +225 -0
- package/src/engine/operators/strings.ts +25 -0
- package/src/engine/operators/types.ts +16 -0
- package/src/engine/type-matching.ts +148 -0
- package/src/errors.ts +33 -0
- package/src/eslint/index.ts +388 -0
- package/src/fhir/html-checks.ts +266 -0
- package/src/fhir/model-navigation.ts +148 -0
- package/src/functions/aggregate.ts +136 -0
- package/src/functions/boundary.ts +209 -0
- package/src/functions/combining.ts +15 -0
- package/src/functions/control.ts +25 -0
- package/src/functions/conversion.ts +349 -0
- package/src/functions/date-components.ts +88 -0
- package/src/functions/existence.ts +107 -0
- package/src/functions/fhir.ts +247 -0
- package/src/functions/filtering.ts +120 -0
- package/src/functions/install.ts +19 -0
- package/src/functions/iteration.ts +21 -0
- package/src/functions/math.ts +167 -0
- package/src/functions/reflection.ts +24 -0
- package/src/functions/registry.ts +72 -0
- package/src/functions/sort.ts +68 -0
- package/src/functions/string.ts +413 -0
- package/src/functions/subsetting.ts +89 -0
- package/src/functions/tree.ts +112 -0
- package/src/functions/type-specifier.ts +29 -0
- package/src/functions/utility.ts +82 -0
- package/src/functions/variables.ts +36 -0
- package/src/index.ts +30 -0
- package/src/lexer/lexer.ts +341 -0
- package/src/lexer/tokens.ts +69 -0
- package/src/model/provider.ts +36 -0
- package/src/parser/ast.ts +164 -0
- package/src/parser/parser.ts +321 -0
- package/src/parser/precedence.ts +52 -0
- package/src/parser/printer.ts +114 -0
- package/src/r4/generated/resources-data.ts +28631 -0
- package/src/r4/generated/type-maps.ts +22145 -0
- package/src/r4/generated/types-data.ts +2208 -0
- package/src/r4/index.ts +107 -0
- package/src/r4/model-data.ts +17 -0
- package/src/sites/index.ts +285 -0
- package/src/typed/infer.ts +433 -0
- package/src/typed/perf-fixture.types.ts +143 -0
- package/src/values/collection.ts +57 -0
- package/src/values/datetime.ts +285 -0
- package/src/values/decimal.ts +213 -0
- package/src/values/numeric.ts +63 -0
- package/src/values/quantity.ts +358 -0
- package/src/values/temporal-arithmetic.ts +231 -0
- package/src/values/temporal-compare.ts +65 -0
- package/src/values/type-compat.ts +133 -0
- package/src/values/typed-value.ts +151 -0
- 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.
|