@fhirust/sdk 0.2.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/dist/bin/cli.d.ts +10 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +217 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/events.d.ts +18 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +22 -0
- package/dist/events.js.map +1 -0
- package/dist/fhir-client.d.ts +80 -0
- package/dist/fhir-client.d.ts.map +1 -0
- package/dist/fhir-client.js +65 -0
- package/dist/fhir-client.js.map +1 -0
- package/dist/helpers.d.ts +19 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +38 -0
- package/dist/helpers.js.map +1 -0
- package/dist/http-client.d.ts +63 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +98 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +27 -0
- package/dist/logger.js.map +1 -0
- package/dist/plugin.d.ts +70 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +219 -0
- package/dist/plugin.js.map +1 -0
- package/dist/r4/allergy-intolerance.d.ts +37 -0
- package/dist/r4/allergy-intolerance.d.ts.map +1 -0
- package/dist/r4/allergy-intolerance.js +2 -0
- package/dist/r4/allergy-intolerance.js.map +1 -0
- package/dist/r4/common.d.ts +148 -0
- package/dist/r4/common.d.ts.map +1 -0
- package/dist/r4/common.js +5 -0
- package/dist/r4/common.js.map +1 -0
- package/dist/r4/condition.d.ts +42 -0
- package/dist/r4/condition.d.ts.map +1 -0
- package/dist/r4/condition.js +2 -0
- package/dist/r4/condition.js.map +1 -0
- package/dist/r4/diagnostic-report.d.ts +31 -0
- package/dist/r4/diagnostic-report.d.ts.map +1 -0
- package/dist/r4/diagnostic-report.js +2 -0
- package/dist/r4/diagnostic-report.js.map +1 -0
- package/dist/r4/encounter.d.ts +66 -0
- package/dist/r4/encounter.d.ts.map +1 -0
- package/dist/r4/encounter.js +2 -0
- package/dist/r4/encounter.js.map +1 -0
- package/dist/r4/index.d.ts +19 -0
- package/dist/r4/index.d.ts.map +1 -0
- package/dist/r4/index.js +9 -0
- package/dist/r4/index.js.map +1 -0
- package/dist/r4/medication-request.d.ts +54 -0
- package/dist/r4/medication-request.d.ts.map +1 -0
- package/dist/r4/medication-request.js +2 -0
- package/dist/r4/medication-request.js.map +1 -0
- package/dist/r4/observation.d.ts +65 -0
- package/dist/r4/observation.d.ts.map +1 -0
- package/dist/r4/observation.js +2 -0
- package/dist/r4/observation.js.map +1 -0
- package/dist/r4/organization.d.ts +24 -0
- package/dist/r4/organization.d.ts.map +1 -0
- package/dist/r4/organization.js +2 -0
- package/dist/r4/organization.js.map +1 -0
- package/dist/r4/patient.d.ts +43 -0
- package/dist/r4/patient.d.ts.map +1 -0
- package/dist/r4/patient.js +2 -0
- package/dist/r4/patient.js.map +1 -0
- package/dist/r4/practitioner.d.ts +24 -0
- package/dist/r4/practitioner.d.ts.map +1 -0
- package/dist/r4/practitioner.js +2 -0
- package/dist/r4/practitioner.js.map +1 -0
- package/dist/r4/procedure.d.ts +42 -0
- package/dist/r4/procedure.d.ts.map +1 -0
- package/dist/r4/procedure.js +2 -0
- package/dist/r4/procedure.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
- package/wit/plugin.wit +114 -0
- package/wit/world.wit +12 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Meta, Narrative, Identifier, HumanName, ContactPoint, Address, CodeableConcept, Reference, Period, Attachment } from "./common.js";
|
|
2
|
+
export interface Practitioner {
|
|
3
|
+
resourceType: "Practitioner";
|
|
4
|
+
id?: string;
|
|
5
|
+
meta?: Meta;
|
|
6
|
+
text?: Narrative;
|
|
7
|
+
identifier?: Identifier[];
|
|
8
|
+
active?: boolean;
|
|
9
|
+
name?: HumanName[];
|
|
10
|
+
telecom?: ContactPoint[];
|
|
11
|
+
address?: Address[];
|
|
12
|
+
gender?: "male" | "female" | "other" | "unknown";
|
|
13
|
+
birthDate?: string;
|
|
14
|
+
photo?: Attachment[];
|
|
15
|
+
qualification?: PractitionerQualification[];
|
|
16
|
+
communication?: CodeableConcept[];
|
|
17
|
+
}
|
|
18
|
+
export interface PractitionerQualification {
|
|
19
|
+
identifier?: Identifier[];
|
|
20
|
+
code: CodeableConcept;
|
|
21
|
+
period?: Period;
|
|
22
|
+
issuer?: Reference;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=practitioner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"practitioner.d.ts","sourceRoot":"","sources":["../../src/r4/practitioner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,OAAO,EACP,eAAe,EACf,SAAS,EACT,MAAM,EACN,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,cAAc,CAAC;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,yBAAyB,EAAE,CAAC;IAC5C,aAAa,CAAC,EAAE,eAAe,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"practitioner.js","sourceRoot":"","sources":["../../src/r4/practitioner.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Meta, Narrative, Identifier, CodeableConcept, Reference, Period, Age, Range, Annotation } from "./common.js";
|
|
2
|
+
export interface Procedure {
|
|
3
|
+
resourceType: "Procedure";
|
|
4
|
+
id?: string;
|
|
5
|
+
meta?: Meta;
|
|
6
|
+
text?: Narrative;
|
|
7
|
+
identifier?: Identifier[];
|
|
8
|
+
basedOn?: Reference[];
|
|
9
|
+
partOf?: Reference[];
|
|
10
|
+
status: "preparation" | "in-progress" | "not-done" | "on-hold" | "stopped" | "completed" | "entered-in-error" | "unknown";
|
|
11
|
+
statusReason?: CodeableConcept;
|
|
12
|
+
category?: CodeableConcept;
|
|
13
|
+
code?: CodeableConcept;
|
|
14
|
+
subject: Reference;
|
|
15
|
+
encounter?: Reference;
|
|
16
|
+
performedDateTime?: string;
|
|
17
|
+
performedPeriod?: Period;
|
|
18
|
+
performedString?: string;
|
|
19
|
+
performedAge?: Age;
|
|
20
|
+
performedRange?: Range;
|
|
21
|
+
recorder?: Reference;
|
|
22
|
+
asserter?: Reference;
|
|
23
|
+
performer?: ProcedurePerformer[];
|
|
24
|
+
location?: Reference;
|
|
25
|
+
reasonCode?: CodeableConcept[];
|
|
26
|
+
reasonReference?: Reference[];
|
|
27
|
+
bodySite?: CodeableConcept[];
|
|
28
|
+
outcome?: CodeableConcept;
|
|
29
|
+
report?: Reference[];
|
|
30
|
+
complication?: CodeableConcept[];
|
|
31
|
+
complicationDetail?: Reference[];
|
|
32
|
+
followUp?: CodeableConcept[];
|
|
33
|
+
note?: Annotation[];
|
|
34
|
+
usedReference?: Reference[];
|
|
35
|
+
usedCode?: CodeableConcept[];
|
|
36
|
+
}
|
|
37
|
+
export interface ProcedurePerformer {
|
|
38
|
+
function?: CodeableConcept;
|
|
39
|
+
actor: Reference;
|
|
40
|
+
onBehalfOf?: Reference;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=procedure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/r4/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,GAAG,EACH,KAAK,EACL,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,WAAW,CAAC;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,MAAM,EAAE,aAAa,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,kBAAkB,GAAG,SAAS,CAAC;IAC1H,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,cAAc,CAAC,EAAE,KAAK,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,eAAe,EAAE,CAAC;IACjC,kBAAkB,CAAC,EAAE,SAAS,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;IAC7B,IAAI,CAAC,EAAE,UAAU,EAAE,CAAC;IACpB,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"procedure.js","sourceRoot":"","sources":["../../src/r4/procedure.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** Hook types supported by FHIRust */
|
|
2
|
+
export type HookType = "before-create" | "after-create" | "before-read" | "after-read" | "before-update" | "after-update" | "before-delete" | "after-delete";
|
|
3
|
+
/** FHIR resource type identifiers recognized by the WIT contract */
|
|
4
|
+
export type WitResourceType = "patient" | "observation" | "encounter" | "condition" | "medication-request" | "practitioner" | "organization" | "other";
|
|
5
|
+
/** Context passed to hook handlers */
|
|
6
|
+
export interface HookContext {
|
|
7
|
+
requestId: string;
|
|
8
|
+
userId?: string;
|
|
9
|
+
timestamp: string;
|
|
10
|
+
operation: string;
|
|
11
|
+
}
|
|
12
|
+
/** WIT-level hook context (kebab-case field names from Component Model) */
|
|
13
|
+
export interface WitHookContext {
|
|
14
|
+
"request-id": string;
|
|
15
|
+
"user-id"?: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
operation: string;
|
|
18
|
+
}
|
|
19
|
+
/** WIT-level modified resource */
|
|
20
|
+
export interface WitModifiedResource {
|
|
21
|
+
json: string;
|
|
22
|
+
}
|
|
23
|
+
/** WIT-level operation outcome */
|
|
24
|
+
export interface WitOperationOutcome {
|
|
25
|
+
json: string;
|
|
26
|
+
}
|
|
27
|
+
/** WIT-level result encoding */
|
|
28
|
+
export type WitResult = {
|
|
29
|
+
tag: "ok";
|
|
30
|
+
val: WitModifiedResource;
|
|
31
|
+
} | {
|
|
32
|
+
tag: "err";
|
|
33
|
+
val: WitOperationOutcome;
|
|
34
|
+
};
|
|
35
|
+
/** WIT-level plugin metadata */
|
|
36
|
+
export interface WitPluginMetadata {
|
|
37
|
+
name: string;
|
|
38
|
+
version: string;
|
|
39
|
+
hooks: [WitResourceType, HookType[]][];
|
|
40
|
+
}
|
|
41
|
+
/** FHIR OperationOutcome issue */
|
|
42
|
+
export interface OperationOutcomeIssue {
|
|
43
|
+
severity: "fatal" | "error" | "warning" | "information";
|
|
44
|
+
code: string;
|
|
45
|
+
diagnostics?: string;
|
|
46
|
+
details?: {
|
|
47
|
+
text?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** FHIR OperationOutcome resource */
|
|
51
|
+
export interface OperationOutcome {
|
|
52
|
+
resourceType: "OperationOutcome";
|
|
53
|
+
issue: OperationOutcomeIssue[];
|
|
54
|
+
}
|
|
55
|
+
/** FHIR Bundle */
|
|
56
|
+
export interface Bundle<T = any> {
|
|
57
|
+
resourceType: "Bundle";
|
|
58
|
+
type: string;
|
|
59
|
+
total?: number;
|
|
60
|
+
entry?: BundleEntry<T>[];
|
|
61
|
+
link?: BundleLink[];
|
|
62
|
+
}
|
|
63
|
+
export interface BundleEntry<T = any> {
|
|
64
|
+
fullUrl?: string;
|
|
65
|
+
resource?: T;
|
|
66
|
+
}
|
|
67
|
+
export interface BundleLink {
|
|
68
|
+
relation: string;
|
|
69
|
+
url: string;
|
|
70
|
+
}
|
|
71
|
+
/** Handler for before-create / before-update hooks */
|
|
72
|
+
export type BeforeHook<T = any> = (resource: T, ctx: HookContext) => T | Rejection | void;
|
|
73
|
+
/** Handler for after-create / after-read / after-update hooks */
|
|
74
|
+
export type AfterHook<T = any> = (resource: T, ctx: HookContext) => void;
|
|
75
|
+
/** Handler for before-read hooks (no resource body yet) */
|
|
76
|
+
export type BeforeReadHook = (params: {
|
|
77
|
+
resourceType: string;
|
|
78
|
+
id: string;
|
|
79
|
+
}, ctx: HookContext) => void | Rejection;
|
|
80
|
+
/** Handler for before-delete hooks */
|
|
81
|
+
export type BeforeDeleteHook = (params: {
|
|
82
|
+
resourceType: string;
|
|
83
|
+
id: string;
|
|
84
|
+
}, ctx: HookContext) => void | Rejection;
|
|
85
|
+
/** Handler for after-delete hooks */
|
|
86
|
+
export type AfterDeleteHook = (params: {
|
|
87
|
+
resourceType: string;
|
|
88
|
+
id: string;
|
|
89
|
+
}, ctx: HookContext) => void;
|
|
90
|
+
/** Rejection marker returned by reject() */
|
|
91
|
+
export declare class Rejection {
|
|
92
|
+
readonly outcome: OperationOutcome;
|
|
93
|
+
constructor(outcome: OperationOutcome);
|
|
94
|
+
}
|
|
95
|
+
/** Convert a resource type name to WIT enum value */
|
|
96
|
+
export declare function toWitResourceType(name: string): WitResourceType;
|
|
97
|
+
/** Convert a WIT resource type back to a display name */
|
|
98
|
+
export declare function fromWitResourceType(wit: WitResourceType): string;
|
|
99
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Rejection marker returned by reject() */
|
|
2
|
+
export class Rejection {
|
|
3
|
+
outcome;
|
|
4
|
+
constructor(outcome) {
|
|
5
|
+
this.outcome = outcome;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** Map of resource type name to WIT enum value */
|
|
9
|
+
const RESOURCE_TYPE_MAP = {
|
|
10
|
+
Patient: "patient",
|
|
11
|
+
Observation: "observation",
|
|
12
|
+
Encounter: "encounter",
|
|
13
|
+
Condition: "condition",
|
|
14
|
+
MedicationRequest: "medication-request",
|
|
15
|
+
Practitioner: "practitioner",
|
|
16
|
+
Organization: "organization",
|
|
17
|
+
};
|
|
18
|
+
/** Convert a resource type name to WIT enum value */
|
|
19
|
+
export function toWitResourceType(name) {
|
|
20
|
+
return RESOURCE_TYPE_MAP[name] ?? "other";
|
|
21
|
+
}
|
|
22
|
+
/** Convert a WIT resource type back to a display name */
|
|
23
|
+
export function fromWitResourceType(wit) {
|
|
24
|
+
for (const [name, value] of Object.entries(RESOURCE_TYPE_MAP)) {
|
|
25
|
+
if (value === wit)
|
|
26
|
+
return name;
|
|
27
|
+
}
|
|
28
|
+
return wit;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAqHA,4CAA4C;AAC5C,MAAM,OAAO,SAAS;IACX,OAAO,CAAmB;IAEnC,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,kDAAkD;AAClD,MAAM,iBAAiB,GAAoC;IACzD,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,iBAAiB,EAAE,oBAAoB;IACvC,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;CAC7B,CAAC;AAEF,qDAAqD;AACrD,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC;AAC5C,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,mBAAmB,CAAC,GAAoB;IACtD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC9D,IAAI,KAAK,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fhirust/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "TypeScript SDK for building FHIRust WASM plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./r4": {
|
|
14
|
+
"types": "./dist/r4/index.d.ts",
|
|
15
|
+
"import": "./dist/r4/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"fhirust-sdk": "./dist/bin/cli.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist/",
|
|
23
|
+
"wit/",
|
|
24
|
+
"templates/"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"fhir",
|
|
33
|
+
"fhirust",
|
|
34
|
+
"wasm",
|
|
35
|
+
"plugin",
|
|
36
|
+
"healthcare",
|
|
37
|
+
"hl7"
|
|
38
|
+
],
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@bytecodealliance/componentize-js": ">=0.14.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@bytecodealliance/componentize-js": {
|
|
45
|
+
"optional": false
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@bytecodealliance/componentize-js": "^0.14.0",
|
|
50
|
+
"@types/node": "^25.2.2",
|
|
51
|
+
"typescript": "^5.5.0"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/wit/plugin.wit
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// FHIR Plugin Interface
|
|
2
|
+
// Defines the contract between FHIRust and WASM plugins
|
|
3
|
+
|
|
4
|
+
package fhirust:plugin@0.2.0;
|
|
5
|
+
|
|
6
|
+
interface types {
|
|
7
|
+
// Hook types supported by FHIRust - symmetric set for all CRUD operations
|
|
8
|
+
enum hook-type {
|
|
9
|
+
before-create,
|
|
10
|
+
after-create,
|
|
11
|
+
before-read,
|
|
12
|
+
after-read,
|
|
13
|
+
before-update,
|
|
14
|
+
after-update,
|
|
15
|
+
before-delete,
|
|
16
|
+
after-delete,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Common FHIR resource types
|
|
20
|
+
enum resource-type {
|
|
21
|
+
patient,
|
|
22
|
+
observation,
|
|
23
|
+
encounter,
|
|
24
|
+
condition,
|
|
25
|
+
medication-request,
|
|
26
|
+
practitioner,
|
|
27
|
+
organization,
|
|
28
|
+
other, // Catch-all for extensibility
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Hook context passed to plugins
|
|
32
|
+
record hook-context {
|
|
33
|
+
request-id: string,
|
|
34
|
+
user-id: option<string>,
|
|
35
|
+
timestamp: string, // ISO-8601 instant (e.g., "2024-01-15T10:00:00Z")
|
|
36
|
+
operation: string,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Modified resource returned on success
|
|
40
|
+
record modified-resource {
|
|
41
|
+
json: string,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// OperationOutcome returned on validation failure
|
|
45
|
+
record operation-outcome {
|
|
46
|
+
json: string,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Plugin metadata
|
|
50
|
+
record plugin-metadata {
|
|
51
|
+
name: string,
|
|
52
|
+
version: string,
|
|
53
|
+
hooks: list<tuple<resource-type, list<hook-type>>>, // Use enum types
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// HTTP response from host
|
|
57
|
+
record http-response {
|
|
58
|
+
status: u16,
|
|
59
|
+
headers: list<tuple<string, string>>,
|
|
60
|
+
body: string,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Exported by plugin — called by host
|
|
65
|
+
interface hooks {
|
|
66
|
+
use types.{hook-type, resource-type, hook-context, modified-resource, operation-outcome};
|
|
67
|
+
|
|
68
|
+
// Execute a hook - called by FHIRust
|
|
69
|
+
execute-hook: func(
|
|
70
|
+
hook-type: hook-type,
|
|
71
|
+
resource-type: resource-type,
|
|
72
|
+
resource-json: string,
|
|
73
|
+
context: hook-context
|
|
74
|
+
) -> result<modified-resource, operation-outcome>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Exported by plugin — called by host at load time
|
|
78
|
+
interface lifecycle {
|
|
79
|
+
use types.{plugin-metadata};
|
|
80
|
+
|
|
81
|
+
// Called by host at plugin load time
|
|
82
|
+
get-metadata: func() -> plugin-metadata;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Imported by plugin — FHIR data access (calls repository directly)
|
|
86
|
+
interface fhir {
|
|
87
|
+
use types.{operation-outcome};
|
|
88
|
+
|
|
89
|
+
read: func(resource-type: string, id: string) -> result<string, operation-outcome>;
|
|
90
|
+
search: func(resource-type: string, params: list<tuple<string, string>>) -> result<string, operation-outcome>;
|
|
91
|
+
create: func(resource-type: string, resource-json: string) -> result<string, operation-outcome>;
|
|
92
|
+
update: func(resource-type: string, id: string, resource-json: string) -> result<string, operation-outcome>;
|
|
93
|
+
delete: func(resource-type: string, id: string) -> result<bool, operation-outcome>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Imported by plugin — utilities
|
|
97
|
+
interface utils {
|
|
98
|
+
log: func(level: string, message: string);
|
|
99
|
+
emit-event: func(event-type: string, payload: string);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Imported by plugin — outbound HTTP
|
|
103
|
+
interface http {
|
|
104
|
+
use types.{http-response};
|
|
105
|
+
|
|
106
|
+
fetch: func(
|
|
107
|
+
url: string,
|
|
108
|
+
method: string,
|
|
109
|
+
headers: list<tuple<string, string>>,
|
|
110
|
+
body: option<string>,
|
|
111
|
+
timeout-ms: u32,
|
|
112
|
+
) -> result<http-response, string>;
|
|
113
|
+
}
|
|
114
|
+
|