@fhirfly-io/shl 0.1.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 +21 -0
- package/README.md +118 -0
- package/dist/chunk-7WIM2QP5.js +133 -0
- package/dist/chunk-7WIM2QP5.js.map +1 -0
- package/dist/chunk-CNVYKA4D.cjs +135 -0
- package/dist/chunk-CNVYKA4D.cjs.map +1 -0
- package/dist/chunk-KI44MYPE.cjs +170 -0
- package/dist/chunk-KI44MYPE.cjs.map +1 -0
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-Q7SFCCGT.cjs +11 -0
- package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
- package/dist/chunk-XTLU6O32.js +163 -0
- package/dist/chunk-XTLU6O32.js.map +1 -0
- package/dist/express.cjs +37 -0
- package/dist/express.cjs.map +1 -0
- package/dist/express.d.cts +39 -0
- package/dist/express.d.ts +39 -0
- package/dist/express.js +35 -0
- package/dist/express.js.map +1 -0
- package/dist/fastify.cjs +49 -0
- package/dist/fastify.cjs.map +1 -0
- package/dist/fastify.d.cts +43 -0
- package/dist/fastify.d.ts +43 -0
- package/dist/fastify.js +47 -0
- package/dist/fastify.js.map +1 -0
- package/dist/index.cjs +1615 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +765 -0
- package/dist/index.d.ts +765 -0
- package/dist/index.js +1593 -0
- package/dist/index.js.map +1 -0
- package/dist/lambda.cjs +64 -0
- package/dist/lambda.cjs.map +1 -0
- package/dist/lambda.d.cts +53 -0
- package/dist/lambda.d.ts +53 -0
- package/dist/lambda.js +62 -0
- package/dist/lambda.js.map +1 -0
- package/dist/server.cjs +166 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +85 -0
- package/dist/server.d.ts +85 -0
- package/dist/server.js +159 -0
- package/dist/server.js.map +1 -0
- package/dist/storage-CHi9vLD_.d.cts +82 -0
- package/dist/storage-iI_tyHcX.d.ts +82 -0
- package/dist/types--f4ITgu9.d.cts +73 -0
- package/dist/types-DKtPO4DP.d.ts +73 -0
- package/dist/types-yk0mDByJ.d.cts +96 -0
- package/dist/types-yk0mDByJ.d.ts +96 -0
- package/package.json +137 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
import { S as SHLOptions, a as SHLResult, b as SHLStorage, M as Manifest, c as ManifestEntry, d as SHLAttachment, e as SHLMetadata } from './types-yk0mDByJ.cjs';
|
|
2
|
+
import { L as LocalStorage, a as LocalStorageConfig, S as S3Storage, b as S3StorageConfig } from './storage-CHi9vLD_.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared FHIR R4 datatypes used across IPS bundle construction.
|
|
6
|
+
*
|
|
7
|
+
* These types cover the subset of R4 datatypes needed for Patient resources
|
|
8
|
+
* and IPS document generation. All coded fields use string literal unions.
|
|
9
|
+
*/
|
|
10
|
+
/** FHIR Coding element — a code from a terminology system. */
|
|
11
|
+
interface Coding {
|
|
12
|
+
system?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
code?: string;
|
|
15
|
+
display?: string;
|
|
16
|
+
}
|
|
17
|
+
/** FHIR CodeableConcept — a set of codes with optional text. */
|
|
18
|
+
interface CodeableConcept {
|
|
19
|
+
coding?: Coding[];
|
|
20
|
+
text?: string;
|
|
21
|
+
}
|
|
22
|
+
/** FHIR HumanName — a name of a person. */
|
|
23
|
+
interface HumanName {
|
|
24
|
+
use?: "usual" | "official" | "temp" | "nickname" | "anonymous" | "old" | "maiden";
|
|
25
|
+
text?: string;
|
|
26
|
+
family?: string;
|
|
27
|
+
given?: string[];
|
|
28
|
+
prefix?: string[];
|
|
29
|
+
suffix?: string[];
|
|
30
|
+
}
|
|
31
|
+
/** FHIR Address — a postal/physical address. */
|
|
32
|
+
interface Address {
|
|
33
|
+
use?: "home" | "work" | "temp" | "old" | "billing";
|
|
34
|
+
type?: "postal" | "physical" | "both";
|
|
35
|
+
text?: string;
|
|
36
|
+
line?: string[];
|
|
37
|
+
city?: string;
|
|
38
|
+
district?: string;
|
|
39
|
+
state?: string;
|
|
40
|
+
postalCode?: string;
|
|
41
|
+
country?: string;
|
|
42
|
+
}
|
|
43
|
+
/** FHIR ContactPoint — phone, email, or other contact mechanism. */
|
|
44
|
+
interface ContactPoint {
|
|
45
|
+
system?: "phone" | "fax" | "email" | "pager" | "url" | "sms" | "other";
|
|
46
|
+
value?: string;
|
|
47
|
+
use?: "home" | "work" | "temp" | "old" | "mobile";
|
|
48
|
+
rank?: number;
|
|
49
|
+
}
|
|
50
|
+
/** FHIR Identifier — a business identifier for an entity. */
|
|
51
|
+
interface Identifier {
|
|
52
|
+
use?: "usual" | "official" | "temp" | "secondary" | "old";
|
|
53
|
+
system?: string;
|
|
54
|
+
value?: string;
|
|
55
|
+
}
|
|
56
|
+
/** FHIR Reference — a reference to another resource. */
|
|
57
|
+
interface Reference {
|
|
58
|
+
reference?: string;
|
|
59
|
+
display?: string;
|
|
60
|
+
}
|
|
61
|
+
/** FHIR Period — a time range. */
|
|
62
|
+
interface Period {
|
|
63
|
+
start?: string;
|
|
64
|
+
end?: string;
|
|
65
|
+
}
|
|
66
|
+
/** FHIR R4 administrative gender values. */
|
|
67
|
+
type AdministrativeGender = "male" | "female" | "other" | "unknown";
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Shorthand patient input for simple cases (90% of use).
|
|
71
|
+
*
|
|
72
|
+
* Use `given` + `family` for structured name, or `name` as a text string.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* new IPS.Bundle({
|
|
77
|
+
* given: "Jane",
|
|
78
|
+
* family: "Doe",
|
|
79
|
+
* birthDate: "1990-01-15",
|
|
80
|
+
* gender: "female",
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
interface PatientShorthand {
|
|
85
|
+
/** Given (first) name — mutually exclusive with `name` */
|
|
86
|
+
given?: string;
|
|
87
|
+
/** Family (last) name — mutually exclusive with `name` */
|
|
88
|
+
family?: string;
|
|
89
|
+
/** Full name as text (e.g., "Dr. Jane Q. Doe III") — mutually exclusive with given/family */
|
|
90
|
+
name?: string;
|
|
91
|
+
/** Date of birth in YYYY-MM-DD format (required for IPS) */
|
|
92
|
+
birthDate: string;
|
|
93
|
+
/** Administrative gender */
|
|
94
|
+
gender?: AdministrativeGender;
|
|
95
|
+
/** Phone number */
|
|
96
|
+
phone?: string;
|
|
97
|
+
/** Email address */
|
|
98
|
+
email?: string;
|
|
99
|
+
/** Patient identifier — plain string or { system, value } */
|
|
100
|
+
identifier?: string | {
|
|
101
|
+
system: string;
|
|
102
|
+
value: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Full FHIR-shaped patient input for complex cases.
|
|
107
|
+
*
|
|
108
|
+
* Arrays for all 0..* fields. Discriminated from shorthand by
|
|
109
|
+
* `Array.isArray(input.name)`.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* new IPS.Bundle({
|
|
114
|
+
* name: [{ use: "official", given: ["Jane"], family: "Doe" }],
|
|
115
|
+
* birthDate: "1990-01-15",
|
|
116
|
+
* gender: "female",
|
|
117
|
+
* });
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
interface PatientFull {
|
|
121
|
+
/** Patient name(s) — array of HumanName (discriminant: Array.isArray) */
|
|
122
|
+
name: HumanName[];
|
|
123
|
+
/** Date of birth in YYYY-MM-DD format (required for IPS) */
|
|
124
|
+
birthDate: string;
|
|
125
|
+
/** Administrative gender */
|
|
126
|
+
gender?: AdministrativeGender;
|
|
127
|
+
/** Patient identifier(s) */
|
|
128
|
+
identifier?: Identifier[];
|
|
129
|
+
/** Contact information */
|
|
130
|
+
telecom?: ContactPoint[];
|
|
131
|
+
/** Address(es) */
|
|
132
|
+
address?: Address[];
|
|
133
|
+
/** Whether this patient record is active */
|
|
134
|
+
active?: boolean;
|
|
135
|
+
/** Deceased indicator — boolean or dateTime string */
|
|
136
|
+
deceased?: boolean | string;
|
|
137
|
+
/** Marital status */
|
|
138
|
+
maritalStatus?: CodeableConcept;
|
|
139
|
+
/** General practitioner(s) */
|
|
140
|
+
generalPractitioner?: Reference[];
|
|
141
|
+
/** Communication preferences */
|
|
142
|
+
communication?: PatientCommunication[];
|
|
143
|
+
/** Contact parties (next of kin, emergency contacts) */
|
|
144
|
+
contact?: PatientContact[];
|
|
145
|
+
}
|
|
146
|
+
/** Patient communication preference. */
|
|
147
|
+
interface PatientCommunication {
|
|
148
|
+
/** Language as a CodeableConcept (e.g., BCP-47 coding) */
|
|
149
|
+
language: CodeableConcept;
|
|
150
|
+
/** Whether this is the preferred language */
|
|
151
|
+
preferred?: boolean;
|
|
152
|
+
}
|
|
153
|
+
/** Patient contact party (next of kin, emergency contact). */
|
|
154
|
+
interface PatientContact {
|
|
155
|
+
/** Relationship to the patient */
|
|
156
|
+
relationship?: CodeableConcept[];
|
|
157
|
+
/** Contact name */
|
|
158
|
+
name?: HumanName;
|
|
159
|
+
/** Contact information */
|
|
160
|
+
telecom?: ContactPoint[];
|
|
161
|
+
/** Contact address */
|
|
162
|
+
address?: Address;
|
|
163
|
+
/** Administrative gender of the contact */
|
|
164
|
+
gender?: AdministrativeGender;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Union type for patient input — accepts shorthand or full FHIR-shaped input.
|
|
168
|
+
*
|
|
169
|
+
* Discriminant: `Array.isArray(input.name)` — shorthand has `name?: string`,
|
|
170
|
+
* full has `name: HumanName[]`.
|
|
171
|
+
*/
|
|
172
|
+
type PatientDemographics = PatientShorthand | PatientFull;
|
|
173
|
+
/**
|
|
174
|
+
* Options for building an IPS bundle.
|
|
175
|
+
*/
|
|
176
|
+
interface BuildOptions {
|
|
177
|
+
/** FHIR profile to validate against */
|
|
178
|
+
profile: "ips" | "r4";
|
|
179
|
+
/** Bundle identifier (auto-generated if not provided) */
|
|
180
|
+
bundleId?: string;
|
|
181
|
+
/** Composition date (defaults to now) */
|
|
182
|
+
compositionDate?: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Result of IPS bundle validation.
|
|
186
|
+
*/
|
|
187
|
+
interface ValidationResult {
|
|
188
|
+
/** Whether the bundle is valid */
|
|
189
|
+
valid: boolean;
|
|
190
|
+
/** Validation issues found */
|
|
191
|
+
issues: ValidationIssue[];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A single validation issue.
|
|
195
|
+
*/
|
|
196
|
+
interface ValidationIssue {
|
|
197
|
+
/** Severity of the issue */
|
|
198
|
+
severity: "error" | "warning" | "information";
|
|
199
|
+
/** Human-readable description */
|
|
200
|
+
message: string;
|
|
201
|
+
/** FHIRPath expression to the element */
|
|
202
|
+
path?: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Duck-typed interface for a FHIRfly API client.
|
|
206
|
+
*
|
|
207
|
+
* Any object matching this shape works — including `@fhirfly-io/terminology`
|
|
208
|
+
* or a hand-crafted mock. The SDK does NOT import that package.
|
|
209
|
+
*/
|
|
210
|
+
interface FhirflyClient {
|
|
211
|
+
ndc: {
|
|
212
|
+
lookup(code: string, options?: {
|
|
213
|
+
shape?: string;
|
|
214
|
+
}): Promise<{
|
|
215
|
+
data: {
|
|
216
|
+
ndc: string;
|
|
217
|
+
product_name: string;
|
|
218
|
+
generic_name?: string;
|
|
219
|
+
dosage_form?: string;
|
|
220
|
+
route?: string;
|
|
221
|
+
active_ingredients: Array<{
|
|
222
|
+
name: string;
|
|
223
|
+
strength?: string;
|
|
224
|
+
unit?: string;
|
|
225
|
+
}>;
|
|
226
|
+
snomed?: Array<{
|
|
227
|
+
concept_id: string;
|
|
228
|
+
display?: string;
|
|
229
|
+
map_type?: string;
|
|
230
|
+
}>;
|
|
231
|
+
};
|
|
232
|
+
}>;
|
|
233
|
+
};
|
|
234
|
+
rxnorm: {
|
|
235
|
+
lookup(rxcui: string, options?: {
|
|
236
|
+
shape?: string;
|
|
237
|
+
}): Promise<{
|
|
238
|
+
data: {
|
|
239
|
+
rxcui: string;
|
|
240
|
+
name: string;
|
|
241
|
+
tty: string;
|
|
242
|
+
snomed?: Array<{
|
|
243
|
+
concept_id: string;
|
|
244
|
+
display?: string;
|
|
245
|
+
map_type?: string;
|
|
246
|
+
}>;
|
|
247
|
+
};
|
|
248
|
+
}>;
|
|
249
|
+
};
|
|
250
|
+
snomed: {
|
|
251
|
+
lookup(conceptId: string): Promise<{
|
|
252
|
+
data: {
|
|
253
|
+
concept_id: string;
|
|
254
|
+
preferred_term: string | null;
|
|
255
|
+
fsn: string | null;
|
|
256
|
+
ips_category: string | null;
|
|
257
|
+
};
|
|
258
|
+
}>;
|
|
259
|
+
};
|
|
260
|
+
icd10: {
|
|
261
|
+
lookup(code: string, options?: {
|
|
262
|
+
shape?: string;
|
|
263
|
+
}): Promise<{
|
|
264
|
+
data: {
|
|
265
|
+
code: string;
|
|
266
|
+
display: string;
|
|
267
|
+
snomed?: Array<{
|
|
268
|
+
concept_id: string;
|
|
269
|
+
display?: string;
|
|
270
|
+
map_type?: string;
|
|
271
|
+
}>;
|
|
272
|
+
};
|
|
273
|
+
}>;
|
|
274
|
+
};
|
|
275
|
+
cvx: {
|
|
276
|
+
lookup(cvxCode: string, options?: {
|
|
277
|
+
shape?: string;
|
|
278
|
+
}): Promise<{
|
|
279
|
+
data: {
|
|
280
|
+
code: string;
|
|
281
|
+
display: string;
|
|
282
|
+
full_vaccine_name: string | null;
|
|
283
|
+
};
|
|
284
|
+
}>;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/** Medication status values for MedicationStatement */
|
|
288
|
+
type MedicationStatus = "active" | "completed" | "stopped" | "on-hold";
|
|
289
|
+
/** Add a medication by NDC code. Requires FHIRfly API for enrichment. */
|
|
290
|
+
interface MedicationByNDC {
|
|
291
|
+
byNDC: string;
|
|
292
|
+
fhirfly: FhirflyClient;
|
|
293
|
+
status?: MedicationStatus;
|
|
294
|
+
dosageText?: string;
|
|
295
|
+
effectiveDate?: string;
|
|
296
|
+
byRxNorm?: never;
|
|
297
|
+
bySNOMED?: never;
|
|
298
|
+
fromResource?: never;
|
|
299
|
+
code?: never;
|
|
300
|
+
}
|
|
301
|
+
/** Add a medication by RxNorm CUI. Requires FHIRfly API for enrichment. */
|
|
302
|
+
interface MedicationByRxNorm {
|
|
303
|
+
byRxNorm: string;
|
|
304
|
+
fhirfly: FhirflyClient;
|
|
305
|
+
status?: MedicationStatus;
|
|
306
|
+
dosageText?: string;
|
|
307
|
+
effectiveDate?: string;
|
|
308
|
+
byNDC?: never;
|
|
309
|
+
bySNOMED?: never;
|
|
310
|
+
fromResource?: never;
|
|
311
|
+
code?: never;
|
|
312
|
+
}
|
|
313
|
+
/** Add a medication by SNOMED CT code. API optional (used for preferred_term lookup). */
|
|
314
|
+
interface MedicationBySNOMED {
|
|
315
|
+
bySNOMED: string;
|
|
316
|
+
display?: string;
|
|
317
|
+
fhirfly?: FhirflyClient;
|
|
318
|
+
status?: MedicationStatus;
|
|
319
|
+
dosageText?: string;
|
|
320
|
+
effectiveDate?: string;
|
|
321
|
+
byNDC?: never;
|
|
322
|
+
byRxNorm?: never;
|
|
323
|
+
fromResource?: never;
|
|
324
|
+
code?: never;
|
|
325
|
+
}
|
|
326
|
+
/** Pass through an existing MedicationStatement or MedicationRequest resource. */
|
|
327
|
+
interface MedicationFromResource {
|
|
328
|
+
fromResource: Record<string, unknown>;
|
|
329
|
+
fhirfly?: FhirflyClient;
|
|
330
|
+
byNDC?: never;
|
|
331
|
+
byRxNorm?: never;
|
|
332
|
+
bySNOMED?: never;
|
|
333
|
+
code?: never;
|
|
334
|
+
}
|
|
335
|
+
/** Manual medication input with code, system, and display. */
|
|
336
|
+
interface MedicationManual {
|
|
337
|
+
code: string;
|
|
338
|
+
system: string;
|
|
339
|
+
display: string;
|
|
340
|
+
status?: MedicationStatus;
|
|
341
|
+
dosageText?: string;
|
|
342
|
+
effectiveDate?: string;
|
|
343
|
+
byNDC?: never;
|
|
344
|
+
byRxNorm?: never;
|
|
345
|
+
bySNOMED?: never;
|
|
346
|
+
fromResource?: never;
|
|
347
|
+
fhirfly?: never;
|
|
348
|
+
}
|
|
349
|
+
/** Union of all medication input variants. */
|
|
350
|
+
type MedicationOptions = MedicationByNDC | MedicationByRxNorm | MedicationBySNOMED | MedicationFromResource | MedicationManual;
|
|
351
|
+
/** Clinical status values for Condition */
|
|
352
|
+
type ConditionClinicalStatus = "active" | "recurrence" | "relapse" | "inactive" | "remission" | "resolved";
|
|
353
|
+
/** Add a condition by ICD-10-CM code. Requires FHIRfly API for enrichment. */
|
|
354
|
+
interface ConditionByICD10 {
|
|
355
|
+
byICD10: string;
|
|
356
|
+
fhirfly: FhirflyClient;
|
|
357
|
+
clinicalStatus?: ConditionClinicalStatus;
|
|
358
|
+
onsetDate?: string;
|
|
359
|
+
bySNOMED?: never;
|
|
360
|
+
fromResource?: never;
|
|
361
|
+
code?: never;
|
|
362
|
+
}
|
|
363
|
+
/** Add a condition by SNOMED CT code. API optional (used for preferred_term lookup). */
|
|
364
|
+
interface ConditionBySNOMED {
|
|
365
|
+
bySNOMED: string;
|
|
366
|
+
display?: string;
|
|
367
|
+
fhirfly?: FhirflyClient;
|
|
368
|
+
clinicalStatus?: ConditionClinicalStatus;
|
|
369
|
+
onsetDate?: string;
|
|
370
|
+
byICD10?: never;
|
|
371
|
+
fromResource?: never;
|
|
372
|
+
code?: never;
|
|
373
|
+
}
|
|
374
|
+
/** Pass through an existing Condition resource. */
|
|
375
|
+
interface ConditionFromResource {
|
|
376
|
+
fromResource: Record<string, unknown>;
|
|
377
|
+
fhirfly?: FhirflyClient;
|
|
378
|
+
byICD10?: never;
|
|
379
|
+
bySNOMED?: never;
|
|
380
|
+
code?: never;
|
|
381
|
+
}
|
|
382
|
+
/** Manual condition input with code, system, and display. */
|
|
383
|
+
interface ConditionManual {
|
|
384
|
+
code: string;
|
|
385
|
+
system: string;
|
|
386
|
+
display: string;
|
|
387
|
+
clinicalStatus?: ConditionClinicalStatus;
|
|
388
|
+
onsetDate?: string;
|
|
389
|
+
byICD10?: never;
|
|
390
|
+
bySNOMED?: never;
|
|
391
|
+
fromResource?: never;
|
|
392
|
+
fhirfly?: never;
|
|
393
|
+
}
|
|
394
|
+
/** Union of all condition input variants. */
|
|
395
|
+
type ConditionOptions = ConditionByICD10 | ConditionBySNOMED | ConditionFromResource | ConditionManual;
|
|
396
|
+
/** Clinical status values for AllergyIntolerance */
|
|
397
|
+
type AllergyClinicalStatus = "active" | "inactive" | "resolved";
|
|
398
|
+
/** Add an allergy by SNOMED CT code. API optional (used for preferred_term lookup). */
|
|
399
|
+
interface AllergyBySNOMED {
|
|
400
|
+
bySNOMED: string;
|
|
401
|
+
display?: string;
|
|
402
|
+
fhirfly?: FhirflyClient;
|
|
403
|
+
clinicalStatus?: AllergyClinicalStatus;
|
|
404
|
+
criticality?: "low" | "high" | "unable-to-assess";
|
|
405
|
+
fromResource?: never;
|
|
406
|
+
code?: never;
|
|
407
|
+
}
|
|
408
|
+
/** Pass through an existing AllergyIntolerance resource. */
|
|
409
|
+
interface AllergyFromResource {
|
|
410
|
+
fromResource: Record<string, unknown>;
|
|
411
|
+
fhirfly?: FhirflyClient;
|
|
412
|
+
bySNOMED?: never;
|
|
413
|
+
code?: never;
|
|
414
|
+
}
|
|
415
|
+
/** Manual allergy input with code, system, and display. */
|
|
416
|
+
interface AllergyManual {
|
|
417
|
+
code: string;
|
|
418
|
+
system: string;
|
|
419
|
+
display: string;
|
|
420
|
+
clinicalStatus?: AllergyClinicalStatus;
|
|
421
|
+
criticality?: "low" | "high" | "unable-to-assess";
|
|
422
|
+
bySNOMED?: never;
|
|
423
|
+
fromResource?: never;
|
|
424
|
+
fhirfly?: never;
|
|
425
|
+
}
|
|
426
|
+
/** Union of all allergy input variants. */
|
|
427
|
+
type AllergyOptions = AllergyBySNOMED | AllergyFromResource | AllergyManual;
|
|
428
|
+
/** Add an immunization by CVX code. Requires FHIRfly API for enrichment. */
|
|
429
|
+
interface ImmunizationByCVX {
|
|
430
|
+
byCVX: string;
|
|
431
|
+
fhirfly: FhirflyClient;
|
|
432
|
+
status?: "completed" | "not-done";
|
|
433
|
+
occurrenceDate?: string;
|
|
434
|
+
fromResource?: never;
|
|
435
|
+
code?: never;
|
|
436
|
+
}
|
|
437
|
+
/** Pass through an existing Immunization resource. */
|
|
438
|
+
interface ImmunizationFromResource {
|
|
439
|
+
fromResource: Record<string, unknown>;
|
|
440
|
+
fhirfly?: FhirflyClient;
|
|
441
|
+
byCVX?: never;
|
|
442
|
+
code?: never;
|
|
443
|
+
}
|
|
444
|
+
/** Manual immunization input with code, system, and display. */
|
|
445
|
+
interface ImmunizationManual {
|
|
446
|
+
code: string;
|
|
447
|
+
system: string;
|
|
448
|
+
display: string;
|
|
449
|
+
status?: "completed" | "not-done";
|
|
450
|
+
occurrenceDate?: string;
|
|
451
|
+
byCVX?: never;
|
|
452
|
+
fromResource?: never;
|
|
453
|
+
fhirfly?: never;
|
|
454
|
+
}
|
|
455
|
+
/** Union of all immunization input variants. */
|
|
456
|
+
type ImmunizationOptions = ImmunizationByCVX | ImmunizationFromResource | ImmunizationManual;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Builder for creating IPS (International Patient Summary) FHIR bundles.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```ts
|
|
463
|
+
* const bundle = new IPS.Bundle({
|
|
464
|
+
* given: "Jane",
|
|
465
|
+
* family: "Doe",
|
|
466
|
+
* birthDate: "1990-01-15",
|
|
467
|
+
* gender: "female",
|
|
468
|
+
* });
|
|
469
|
+
*
|
|
470
|
+
* bundle.addMedication({
|
|
471
|
+
* code: "860975",
|
|
472
|
+
* system: "http://www.nlm.nih.gov/research/umls/rxnorm",
|
|
473
|
+
* display: "Metformin 500 MG Oral Tablet",
|
|
474
|
+
* status: "active",
|
|
475
|
+
* });
|
|
476
|
+
*
|
|
477
|
+
* const fhirBundle = await bundle.build({ profile: "ips" });
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
declare class Bundle {
|
|
481
|
+
private readonly _patient;
|
|
482
|
+
private readonly _medications;
|
|
483
|
+
private readonly _allergies;
|
|
484
|
+
private readonly _conditions;
|
|
485
|
+
private readonly _immunizations;
|
|
486
|
+
private readonly _warnings;
|
|
487
|
+
private _buildWarnings;
|
|
488
|
+
constructor(patient: PatientDemographics);
|
|
489
|
+
/** Returns the patient demographics for this bundle. */
|
|
490
|
+
get patient(): PatientDemographics;
|
|
491
|
+
/** Returns all warnings collected from add-time and build-time. */
|
|
492
|
+
get warnings(): readonly ValidationIssue[];
|
|
493
|
+
/**
|
|
494
|
+
* Add a medication statement to the IPS bundle.
|
|
495
|
+
*
|
|
496
|
+
* Throws immediately for `fromResource` with wrong resourceType.
|
|
497
|
+
* All other validation happens at build time.
|
|
498
|
+
*/
|
|
499
|
+
addMedication(medication: MedicationOptions): this;
|
|
500
|
+
/**
|
|
501
|
+
* Add an allergy/intolerance to the IPS bundle.
|
|
502
|
+
*
|
|
503
|
+
* Throws immediately for `fromResource` with wrong resourceType.
|
|
504
|
+
*/
|
|
505
|
+
addAllergy(allergy: AllergyOptions): this;
|
|
506
|
+
/**
|
|
507
|
+
* Add a condition/problem to the IPS bundle.
|
|
508
|
+
*
|
|
509
|
+
* Throws immediately for `fromResource` with wrong resourceType.
|
|
510
|
+
*/
|
|
511
|
+
addCondition(condition: ConditionOptions): this;
|
|
512
|
+
/**
|
|
513
|
+
* Add an immunization to the IPS bundle.
|
|
514
|
+
*
|
|
515
|
+
* Throws immediately for `fromResource` with wrong resourceType.
|
|
516
|
+
*/
|
|
517
|
+
addImmunization(immunization: ImmunizationOptions): this;
|
|
518
|
+
/**
|
|
519
|
+
* Build the IPS FHIR Bundle resource.
|
|
520
|
+
*
|
|
521
|
+
* Async because `byNDC`, `byRxNorm`, `byICD10`, and `byCVX` require API enrichment.
|
|
522
|
+
* If no enrichment is needed, the Promise resolves immediately.
|
|
523
|
+
*
|
|
524
|
+
* @returns A FHIR Bundle resource object
|
|
525
|
+
*/
|
|
526
|
+
build(options?: BuildOptions): Promise<Record<string, unknown>>;
|
|
527
|
+
/**
|
|
528
|
+
* Validate the bundle against the specified profile.
|
|
529
|
+
*
|
|
530
|
+
* @returns Validation result with any issues found
|
|
531
|
+
*/
|
|
532
|
+
validate(options?: BuildOptions): ValidationResult;
|
|
533
|
+
private hasValidName;
|
|
534
|
+
private buildComposition;
|
|
535
|
+
private buildMedicationSection;
|
|
536
|
+
private buildAllergySection;
|
|
537
|
+
private buildConditionSection;
|
|
538
|
+
private buildImmunizationSection;
|
|
539
|
+
private buildDynamicSection;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** Well-known FHIR code system URIs used across IPS resource generation. */
|
|
543
|
+
declare const CODE_SYSTEMS: {
|
|
544
|
+
readonly NDC: "http://hl7.org/fhir/sid/ndc";
|
|
545
|
+
readonly RXNORM: "http://www.nlm.nih.gov/research/umls/rxnorm";
|
|
546
|
+
readonly SNOMED: "http://snomed.info/sct";
|
|
547
|
+
readonly LOINC: "http://loinc.org";
|
|
548
|
+
readonly CVX: "http://hl7.org/fhir/sid/cvx";
|
|
549
|
+
readonly ICD10CM: "http://hl7.org/fhir/sid/icd-10-cm";
|
|
550
|
+
readonly CONDITION_CLINICAL: "http://terminology.hl7.org/CodeSystem/condition-clinical";
|
|
551
|
+
readonly ALLERGY_CLINICAL: "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical";
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
type index$1_Address = Address;
|
|
555
|
+
type index$1_AdministrativeGender = AdministrativeGender;
|
|
556
|
+
type index$1_AllergyBySNOMED = AllergyBySNOMED;
|
|
557
|
+
type index$1_AllergyClinicalStatus = AllergyClinicalStatus;
|
|
558
|
+
type index$1_AllergyFromResource = AllergyFromResource;
|
|
559
|
+
type index$1_AllergyManual = AllergyManual;
|
|
560
|
+
type index$1_AllergyOptions = AllergyOptions;
|
|
561
|
+
type index$1_BuildOptions = BuildOptions;
|
|
562
|
+
type index$1_Bundle = Bundle;
|
|
563
|
+
declare const index$1_Bundle: typeof Bundle;
|
|
564
|
+
declare const index$1_CODE_SYSTEMS: typeof CODE_SYSTEMS;
|
|
565
|
+
type index$1_CodeableConcept = CodeableConcept;
|
|
566
|
+
type index$1_Coding = Coding;
|
|
567
|
+
type index$1_ConditionByICD10 = ConditionByICD10;
|
|
568
|
+
type index$1_ConditionBySNOMED = ConditionBySNOMED;
|
|
569
|
+
type index$1_ConditionClinicalStatus = ConditionClinicalStatus;
|
|
570
|
+
type index$1_ConditionFromResource = ConditionFromResource;
|
|
571
|
+
type index$1_ConditionManual = ConditionManual;
|
|
572
|
+
type index$1_ConditionOptions = ConditionOptions;
|
|
573
|
+
type index$1_ContactPoint = ContactPoint;
|
|
574
|
+
type index$1_FhirflyClient = FhirflyClient;
|
|
575
|
+
type index$1_HumanName = HumanName;
|
|
576
|
+
type index$1_Identifier = Identifier;
|
|
577
|
+
type index$1_ImmunizationByCVX = ImmunizationByCVX;
|
|
578
|
+
type index$1_ImmunizationFromResource = ImmunizationFromResource;
|
|
579
|
+
type index$1_ImmunizationManual = ImmunizationManual;
|
|
580
|
+
type index$1_ImmunizationOptions = ImmunizationOptions;
|
|
581
|
+
type index$1_MedicationByNDC = MedicationByNDC;
|
|
582
|
+
type index$1_MedicationByRxNorm = MedicationByRxNorm;
|
|
583
|
+
type index$1_MedicationBySNOMED = MedicationBySNOMED;
|
|
584
|
+
type index$1_MedicationFromResource = MedicationFromResource;
|
|
585
|
+
type index$1_MedicationManual = MedicationManual;
|
|
586
|
+
type index$1_MedicationOptions = MedicationOptions;
|
|
587
|
+
type index$1_MedicationStatus = MedicationStatus;
|
|
588
|
+
type index$1_PatientCommunication = PatientCommunication;
|
|
589
|
+
type index$1_PatientContact = PatientContact;
|
|
590
|
+
type index$1_PatientDemographics = PatientDemographics;
|
|
591
|
+
type index$1_PatientFull = PatientFull;
|
|
592
|
+
type index$1_PatientShorthand = PatientShorthand;
|
|
593
|
+
type index$1_Period = Period;
|
|
594
|
+
type index$1_Reference = Reference;
|
|
595
|
+
type index$1_ValidationIssue = ValidationIssue;
|
|
596
|
+
type index$1_ValidationResult = ValidationResult;
|
|
597
|
+
declare namespace index$1 {
|
|
598
|
+
export { type index$1_Address as Address, type index$1_AdministrativeGender as AdministrativeGender, type index$1_AllergyBySNOMED as AllergyBySNOMED, type index$1_AllergyClinicalStatus as AllergyClinicalStatus, type index$1_AllergyFromResource as AllergyFromResource, type index$1_AllergyManual as AllergyManual, type index$1_AllergyOptions as AllergyOptions, type index$1_BuildOptions as BuildOptions, index$1_Bundle as Bundle, index$1_CODE_SYSTEMS as CODE_SYSTEMS, type index$1_CodeableConcept as CodeableConcept, type index$1_Coding as Coding, type index$1_ConditionByICD10 as ConditionByICD10, type index$1_ConditionBySNOMED as ConditionBySNOMED, type index$1_ConditionClinicalStatus as ConditionClinicalStatus, type index$1_ConditionFromResource as ConditionFromResource, type index$1_ConditionManual as ConditionManual, type index$1_ConditionOptions as ConditionOptions, type index$1_ContactPoint as ContactPoint, type index$1_FhirflyClient as FhirflyClient, type index$1_HumanName as HumanName, type index$1_Identifier as Identifier, type index$1_ImmunizationByCVX as ImmunizationByCVX, type index$1_ImmunizationFromResource as ImmunizationFromResource, type index$1_ImmunizationManual as ImmunizationManual, type index$1_ImmunizationOptions as ImmunizationOptions, type index$1_MedicationByNDC as MedicationByNDC, type index$1_MedicationByRxNorm as MedicationByRxNorm, type index$1_MedicationBySNOMED as MedicationBySNOMED, type index$1_MedicationFromResource as MedicationFromResource, type index$1_MedicationManual as MedicationManual, type index$1_MedicationOptions as MedicationOptions, type index$1_MedicationStatus as MedicationStatus, type index$1_PatientCommunication as PatientCommunication, type index$1_PatientContact as PatientContact, type index$1_PatientDemographics as PatientDemographics, type index$1_PatientFull as PatientFull, type index$1_PatientShorthand as PatientShorthand, type index$1_Period as Period, type index$1_Reference as Reference, type index$1_ValidationIssue as ValidationIssue, type index$1_ValidationResult as ValidationResult };
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Create a SMART Health Link from a FHIR Bundle.
|
|
603
|
+
*
|
|
604
|
+
* Encrypts the bundle, stores it using the provided storage backend,
|
|
605
|
+
* and returns a SHL URL with an embedded QR code.
|
|
606
|
+
*
|
|
607
|
+
* This implements manifest mode only (`L` flag always set).
|
|
608
|
+
* The user's server is responsible for serving the manifest and content
|
|
609
|
+
* files from the storage backend.
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* ```ts
|
|
613
|
+
* const result = await SHL.create({
|
|
614
|
+
* bundle: fhirBundle,
|
|
615
|
+
* passcode: "1234",
|
|
616
|
+
* expiresAt: new Date("2025-12-31"),
|
|
617
|
+
* storage: new SHL.LocalStorage({
|
|
618
|
+
* directory: "./shl-data",
|
|
619
|
+
* baseUrl: "https://shl.example.com",
|
|
620
|
+
* }),
|
|
621
|
+
* });
|
|
622
|
+
*
|
|
623
|
+
* console.log(result.url); // shlink:/...
|
|
624
|
+
* console.log(result.qrCode); // data:image/png;base64,...
|
|
625
|
+
* ```
|
|
626
|
+
*/
|
|
627
|
+
declare function create(options: SHLOptions): Promise<SHLResult>;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* A decoded SMART Health Link payload.
|
|
631
|
+
*
|
|
632
|
+
* Contains all fields from the shlink:/ URL payload,
|
|
633
|
+
* parsed and ready for use.
|
|
634
|
+
*/
|
|
635
|
+
interface DecodedSHL {
|
|
636
|
+
/** Manifest URL — POST here to retrieve the manifest */
|
|
637
|
+
url: string;
|
|
638
|
+
/** Decryption key (32 bytes) */
|
|
639
|
+
key: Buffer;
|
|
640
|
+
/** SHL flags (e.g., "L", "LP") */
|
|
641
|
+
flag: string;
|
|
642
|
+
/** SHL version (currently always 1) */
|
|
643
|
+
v: number;
|
|
644
|
+
/** Expiration as epoch seconds (undefined if no expiration) */
|
|
645
|
+
exp?: number;
|
|
646
|
+
/** Human-readable label (max 80 chars) */
|
|
647
|
+
label?: string;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Decode a `shlink:/` URL into its constituent parts.
|
|
651
|
+
*
|
|
652
|
+
* Extracts the manifest URL, decryption key, flags, version,
|
|
653
|
+
* optional expiration, and optional label from the SHL payload.
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* ```ts
|
|
657
|
+
* const decoded = SHL.decode("shlink:/eyJ1cmw...");
|
|
658
|
+
* // decoded.url → "https://shl.example.com/{shlId}"
|
|
659
|
+
* // decoded.key → Buffer (32 bytes)
|
|
660
|
+
* // decoded.flag → "LP"
|
|
661
|
+
* // decoded.exp → 1798761600 (or undefined)
|
|
662
|
+
* // decoded.label → "Jane's IPS" (or undefined)
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
665
|
+
declare function decode(url: string): DecodedSHL;
|
|
666
|
+
/**
|
|
667
|
+
* Decrypt a JWE compact serialization back to a FHIR bundle.
|
|
668
|
+
*
|
|
669
|
+
* This is a convenience wrapper around the internal `decryptBundle` function,
|
|
670
|
+
* exposed as a public API for consuming SHLs.
|
|
671
|
+
*
|
|
672
|
+
* @param jwe - JWE compact serialization string (5 dot-separated parts)
|
|
673
|
+
* @param key - 32-byte AES-256 key (from `SHL.decode().key`)
|
|
674
|
+
* @returns The decrypted FHIR bundle as a JSON object
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```ts
|
|
678
|
+
* const decoded = SHL.decode("shlink:/eyJ1cmw...");
|
|
679
|
+
* const manifest = await fetch(decoded.url, {
|
|
680
|
+
* method: "POST",
|
|
681
|
+
* headers: { "content-type": "application/json" },
|
|
682
|
+
* body: JSON.stringify({ passcode: "1234" }),
|
|
683
|
+
* }).then(r => r.json());
|
|
684
|
+
*
|
|
685
|
+
* const jwe = await fetch(manifest.files[0].location).then(r => r.text());
|
|
686
|
+
* const bundle = SHL.decrypt(jwe, decoded.key);
|
|
687
|
+
* ```
|
|
688
|
+
*/
|
|
689
|
+
declare function decrypt(jwe: string, key: Buffer): Record<string, unknown>;
|
|
690
|
+
/**
|
|
691
|
+
* Decrypt a JWE compact serialization to raw bytes and content type.
|
|
692
|
+
*
|
|
693
|
+
* Use this for non-FHIR content (PDFs, images, etc.) where the result
|
|
694
|
+
* is binary data rather than a JSON object.
|
|
695
|
+
*
|
|
696
|
+
* @param jwe - JWE compact serialization string
|
|
697
|
+
* @param key - 32-byte AES-256 key (from `SHL.decode().key`)
|
|
698
|
+
* @returns Object with `contentType` (from JWE header) and `data` (Buffer)
|
|
699
|
+
*/
|
|
700
|
+
declare function decryptContent(jwe: string, key: Buffer): {
|
|
701
|
+
contentType: string;
|
|
702
|
+
data: Buffer;
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Revoke a SMART Health Link by deleting all stored files.
|
|
707
|
+
*
|
|
708
|
+
* Removes the encrypted content, manifest, and metadata from storage.
|
|
709
|
+
* After revocation, the SHL URL and QR code will no longer work —
|
|
710
|
+
* viewers will receive a 404 when attempting to access the manifest.
|
|
711
|
+
*
|
|
712
|
+
* @param shlId - The SHL identifier (from `SHLResult.id`)
|
|
713
|
+
* @param storage - The storage backend where the SHL files are stored
|
|
714
|
+
*/
|
|
715
|
+
declare function revoke(shlId: string, storage: SHLStorage): Promise<void>;
|
|
716
|
+
|
|
717
|
+
type index_DecodedSHL = DecodedSHL;
|
|
718
|
+
declare const index_LocalStorage: typeof LocalStorage;
|
|
719
|
+
declare const index_LocalStorageConfig: typeof LocalStorageConfig;
|
|
720
|
+
declare const index_Manifest: typeof Manifest;
|
|
721
|
+
declare const index_ManifestEntry: typeof ManifestEntry;
|
|
722
|
+
declare const index_S3Storage: typeof S3Storage;
|
|
723
|
+
declare const index_S3StorageConfig: typeof S3StorageConfig;
|
|
724
|
+
declare const index_SHLAttachment: typeof SHLAttachment;
|
|
725
|
+
declare const index_SHLMetadata: typeof SHLMetadata;
|
|
726
|
+
declare const index_SHLOptions: typeof SHLOptions;
|
|
727
|
+
declare const index_SHLResult: typeof SHLResult;
|
|
728
|
+
declare const index_SHLStorage: typeof SHLStorage;
|
|
729
|
+
declare const index_create: typeof create;
|
|
730
|
+
declare const index_decode: typeof decode;
|
|
731
|
+
declare const index_decrypt: typeof decrypt;
|
|
732
|
+
declare const index_decryptContent: typeof decryptContent;
|
|
733
|
+
declare const index_revoke: typeof revoke;
|
|
734
|
+
declare namespace index {
|
|
735
|
+
export { type index_DecodedSHL as DecodedSHL, index_LocalStorage as LocalStorage, index_LocalStorageConfig as LocalStorageConfig, index_Manifest as Manifest, index_ManifestEntry as ManifestEntry, index_S3Storage as S3Storage, index_S3StorageConfig as S3StorageConfig, index_SHLAttachment as SHLAttachment, index_SHLMetadata as SHLMetadata, index_SHLOptions as SHLOptions, index_SHLResult as SHLResult, index_SHLStorage as SHLStorage, index_create as create, index_decode as decode, index_decrypt as decrypt, index_decryptContent as decryptContent, index_revoke as revoke };
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Base error class for all SHL SDK errors.
|
|
740
|
+
*/
|
|
741
|
+
declare class ShlError extends Error {
|
|
742
|
+
constructor(message: string);
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Error thrown when IPS bundle validation fails.
|
|
746
|
+
*/
|
|
747
|
+
declare class ValidationError extends ShlError {
|
|
748
|
+
readonly issues: string[];
|
|
749
|
+
constructor(message: string, issues?: string[]);
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Error thrown when a storage operation fails.
|
|
753
|
+
*/
|
|
754
|
+
declare class StorageError extends ShlError {
|
|
755
|
+
readonly operation: string;
|
|
756
|
+
constructor(message: string, operation: string);
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Error thrown when encryption or decryption fails.
|
|
760
|
+
*/
|
|
761
|
+
declare class EncryptionError extends ShlError {
|
|
762
|
+
constructor(message: string);
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export { EncryptionError, index$1 as IPS, index as SHL, SHLStorage, ShlError, StorageError, ValidationError };
|