@fhir-dsl/runtime 0.7.0 → 0.9.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 (2) hide show
  1. package/README.md +97 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # @fhir-dsl/runtime
2
+
3
+ Runtime execution layer for `fhir-dsl` queries — HTTP client, pagination, and error handling.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @fhir-dsl/runtime
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### FhirExecutor
14
+
15
+ Executes compiled queries against a FHIR server:
16
+
17
+ ```ts
18
+ import { FhirExecutor } from "@fhir-dsl/runtime";
19
+
20
+ const executor = new FhirExecutor({
21
+ baseUrl: "https://hapi.fhir.org/baseR4",
22
+ auth: { type: "bearer", credentials: "your-token" },
23
+ });
24
+
25
+ const bundle = await executor.execute({
26
+ method: "GET",
27
+ path: "Patient",
28
+ params: [{ name: "family", value: "Smith" }],
29
+ });
30
+ ```
31
+
32
+ ### Pagination
33
+
34
+ Handle paginated FHIR Bundle responses:
35
+
36
+ ```ts
37
+ import { FhirExecutor, paginate, fetchAllPages } from "@fhir-dsl/runtime";
38
+
39
+ const executor = new FhirExecutor({ baseUrl: "https://hapi.fhir.org/baseR4" });
40
+ const firstBundle = await executor.execute(query);
41
+
42
+ // Stream pages with an async generator
43
+ for await (const page of paginate(executor, firstBundle)) {
44
+ console.log(`Processing ${page.length} resources`);
45
+ }
46
+
47
+ // Or collect all pages at once
48
+ const allResources = await fetchAllPages(executor, firstBundle);
49
+ ```
50
+
51
+ ### Bundle Unwrapping
52
+
53
+ Parse a FHIR Bundle into typed primary and included resources:
54
+
55
+ ```ts
56
+ import { unwrapBundle } from "@fhir-dsl/runtime";
57
+
58
+ const result = unwrapBundle<Patient, Practitioner>(bundle);
59
+ // result.data — Patient[]
60
+ // result.included — Practitioner[]
61
+ // result.total — number | undefined
62
+ // result.hasNext — boolean
63
+ // result.nextUrl — string | undefined
64
+ // result.raw — original Bundle
65
+ ```
66
+
67
+ ### Error Handling
68
+
69
+ ```ts
70
+ import { FhirError } from "@fhir-dsl/runtime";
71
+
72
+ try {
73
+ await executor.execute(query);
74
+ } catch (error) {
75
+ if (error instanceof FhirError) {
76
+ console.error(error.status, error.statusText);
77
+ for (const issue of error.issues) {
78
+ console.error(issue.severity, issue.diagnostics);
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ ## Configuration
85
+
86
+ ```ts
87
+ interface FhirClientConfig {
88
+ baseUrl: string;
89
+ auth?: { type: "bearer" | "basic"; credentials: string };
90
+ headers?: Record<string, string>;
91
+ fetch?: typeof globalThis.fetch; // custom fetch implementation
92
+ }
93
+ ```
94
+
95
+ ## License
96
+
97
+ [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/runtime",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Runtime execution layer for FHIR DSL queries with pagination and error handling",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -19,8 +19,8 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@fhir-dsl/core": "0.7.0",
23
- "@fhir-dsl/types": "0.7.0"
22
+ "@fhir-dsl/core": "0.9.0",
23
+ "@fhir-dsl/types": "0.9.0"
24
24
  },
25
25
  "files": [
26
26
  "dist"