@haste-health/generated-ops 0.127.1 → 0.127.3

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 +68 -8
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,14 +1,74 @@
1
- # Generated Operations
1
+ # @haste-health/generated-ops
2
2
 
3
- Generated Operation classes based on OperationDefintions found in load-artifacts (covers hl7 and haste-health operations).
4
- Provides utility methods to validate parameters and parses parameters from simple javascript maps using internally stored OperationDefinition.
3
+ Typed operation objects for every FHIR R4 OperationDefinition that Haste Health ships: the HL7 core operations (`$expand`, `$validate-code`, `$lookup`, `$everything`, `$validate`, `$lastn`, `$match`, `$snapshot`, ...) and the Haste Health operations (`$invite-user`, `$evaluate-policy`, `$hl7v2-parse`, `$run` on a ViewDefinition, `$tenant-branding`, ...). Each is an `Operation` from [`@haste-health/operation-execution`](https://www.npmjs.com/package/@haste-health/operation-execution), so its `Input` and `Output` types are known at compile time and its parameters are validated before and after the call.
4
+
5
+ [`@haste-health/client`](https://www.npmjs.com/package/@haste-health/client) accepts these objects in `invoke_system`, `invoke_type` and `invoke_instance`. The Haste Health admin app, CLI and [`@haste-health/components`](https://www.npmjs.com/package/@haste-health/components) call the server through them.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @haste-health/generated-ops @haste-health/client
11
+ ```
5
12
 
6
13
  ## Usage
7
14
 
8
- ```typescript
9
- import httpClient from "@haste-health/client/http";
10
- import { ValueSetExpand } from "./ops.js";
15
+ ```ts
16
+ import createHTTPClient from "@haste-health/client/http";
17
+ import { R4 } from "@haste-health/fhir-types/versions";
18
+ import type { uri } from "@haste-health/fhir-types/r4/types";
19
+ import {
20
+ PatientEverything,
21
+ ValueSetExpand,
22
+ } from "@haste-health/generated-ops/r4";
11
23
 
12
- const client = httpClient(configuration);
13
- const response = await client.invoke_system(ValueSetExpand.Op, ctx, { url: "value-set-url" }))
24
+ const client = createHTTPClient({
25
+ url: "http://localhost:3000/w/my-tenant/my-project/api/v1/fhir",
26
+ getAccessToken: async () => token,
27
+ });
28
+
29
+ // Type level: POST ValueSet/$expand. The input is ValueSetExpand.Input and
30
+ // the result ValueSetExpand.Output, a ValueSet.
31
+ const expansion = await client.invoke_type(
32
+ ValueSetExpand.Op,
33
+ {},
34
+ R4,
35
+ "ValueSet",
36
+ {
37
+ url: "http://hl7.org/fhir/ValueSet/administrative-gender" as uri,
38
+ },
39
+ );
40
+
41
+ // Instance level: POST Patient/123/$everything.
42
+ const bundle = await client.invoke_instance(
43
+ PatientEverything.Op,
44
+ {},
45
+ R4,
46
+ "Patient",
47
+ "123",
48
+ {},
49
+ );
14
50
  ```
51
+
52
+ Every export is a namespace named after the OperationDefinition `id` in PascalCase (`ValueSet-expand` becomes `ValueSetExpand`, `haste-health-invite-user` becomes `HasteHealthInviteUser`) with four members:
53
+
54
+ | Member | Meaning |
55
+ | -------- | -------------------------------------------------------------------------------- |
56
+ | `Input` | Object type of the `in` parameters; arrays where `max` is `*`, nested for `part` |
57
+ | `Output` | Object type of the `out` parameters, or the returned resource type |
58
+ | `Op` | The `Operation<Input, Output>` instance, with the full `operationDefinition` |
59
+ | `IOp` | `IOperation<Input, Output>`, for functions that take the operation as a value |
60
+
61
+ For an operation the server supports but this package does not define, the client's `invoke_*` methods also accept the operation code as a string, without typing or validation.
62
+
63
+ ## Regenerating
64
+
65
+ `src/r4/ops.ts` is generated. From `frontend/`, `pnpm --filter @haste-health/generated-ops run generate` runs the `generate operations` command of the Haste Health CLI over the OperationDefinitions in the FHIR artifact packages (`@haste-health/hl7.fhir.r4.core` and `@haste-health/haste-health.fhir.r4.core`) and rewrites the file. Add or change an OperationDefinition in the artifacts and regenerate rather than editing it by hand. Only R4 is generated at present.
66
+
67
+ ## Links
68
+
69
+ - [API reference](https://typescript.haste.health/modules/_haste-health_generated-ops.html)
70
+ - [Source](https://github.com/HasteHealth/HasteHealth/tree/main/frontend/packages/generated-ops)
71
+ - [FHIR REST API: invoking operations](https://haste.health/docs/api/rest_api/fhir/intro) and the [TypeScript SDK overview](https://haste.health/docs/api/sdks/typescript)
72
+ - Rust equivalent: [haste-fhir-generated-ops](https://crates.io/crates/haste-fhir-generated-ops)
73
+
74
+ Part of [Haste Health](https://haste.health), licensed under [Apache-2.0](https://github.com/HasteHealth/HasteHealth/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haste-health/generated-ops",
3
- "version": "0.127.1",
3
+ "version": "0.127.3",
4
4
  "homepage": "https://haste.health",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "type": "module",
12
12
  "types": "./lib/index.d.ts",
13
13
  "dependencies": {
14
- "@haste-health/operation-execution": "^0.127.1"
14
+ "@haste-health/operation-execution": "^0.127.3"
15
15
  },
16
16
  "exports": {
17
17
  "./lib/r4/ops": "./lib/r4/ops.js",
@@ -23,10 +23,10 @@
23
23
  "prettier": "^3.9.4",
24
24
  "ts-jest": "^29.4.11",
25
25
  "typescript": "6.0.3",
26
- "@haste-health/artifacts": "^0.127.1",
27
- "@haste-health/fhir-types": "^0.127.1",
28
- "@haste-health/haste-health.fhir.r4.core": "^0.127.1",
29
- "@haste-health/hl7.fhir.r4.core": "^0.127.1"
26
+ "@haste-health/artifacts": "^0.127.3",
27
+ "@haste-health/haste-health.fhir.r4.core": "^0.127.3",
28
+ "@haste-health/fhir-types": "^0.127.3",
29
+ "@haste-health/hl7.fhir.r4.core": "^0.127.3"
30
30
  },
31
31
  "files": [
32
32
  "README.md",