@fhir-dsl/fhirpath 0.7.0 → 0.8.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/README.md +76 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# @fhir-dsl/fhirpath
|
|
2
|
+
|
|
3
|
+
Type-safe FHIRPath expression builder for TypeScript with IDE autocomplete, compilation to FHIRPath strings, and runtime evaluation.
|
|
4
|
+
|
|
5
|
+
Covers ~85% of the official FHIRPath spec including 60+ functions, expression predicates, and operators.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @fhir-dsl/fhirpath @fhir-dsl/types
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Build expressions with autocomplete
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { fhirpath } from "@fhir-dsl/fhirpath";
|
|
19
|
+
import type { Patient } from "./fhir/r4"; // generated types
|
|
20
|
+
|
|
21
|
+
const expr = fhirpath<Patient>("Patient").name.family;
|
|
22
|
+
expr.compile(); // "Patient.name.family"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Every step in the chain is type-checked — you get autocomplete for valid property names and can't navigate to fields that don't exist.
|
|
26
|
+
|
|
27
|
+
### Evaluate against resources
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const families = fhirpath<Patient>("Patient").name.family.evaluate(patient);
|
|
31
|
+
// ["Smith", "Doe"]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Expression predicates
|
|
35
|
+
|
|
36
|
+
Use `$this` for filtering with `where()`, `exists()`, `all()`, and more:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
fhirpath<Patient>("Patient")
|
|
40
|
+
.name.where($this => $this.use.eq("official")).given
|
|
41
|
+
.compile();
|
|
42
|
+
// "Patient.name.where($this.use = 'official').given"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Collection operations
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
fhirpath<Patient>("Patient").name.first().family.compile();
|
|
49
|
+
fhirpath<Patient>("Patient").name.count().compile();
|
|
50
|
+
fhirpath<Patient>("Patient").name.exists().compile();
|
|
51
|
+
fhirpath<Patient>("Patient").identifier.distinct().compile();
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### String, math, and conversion functions
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
fhirpath<Patient>("Patient").name.family.upper().compile();
|
|
58
|
+
fhirpath<Patient>("Patient").name.family.startsWith("Sm").compile();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### `ofType()` for polymorphic fields
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
fhirpath<Observation>("Observation")
|
|
65
|
+
.value.ofType("Quantity").value
|
|
66
|
+
.compile();
|
|
67
|
+
// "Observation.value.ofType(Quantity).value"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Supported Functions
|
|
71
|
+
|
|
72
|
+
Navigation, filtering, subsetting, string manipulation, math, type conversion, utility, and boolean operators — 60+ FHIRPath functions are supported. See the [FHIRPath docs](https://awbx.github.io/fhir-dsl/docs/fhirpath/overview) for the full list.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
[MIT](https://github.com/awbx/fhir-dsl/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fhir-dsl/fhirpath",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Type-safe FHIRPath expression builder with autocomplete",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fhir-dsl/types": "0.
|
|
22
|
+
"@fhir-dsl/types": "0.8.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist"
|