@oystehr/sdk 4.3.3 → 4.3.4
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 +1 -1
- package/dist/cjs/config.d.ts +15 -0
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/fhir-ext.cjs +290 -19
- package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
- package/dist/cjs/resources/classes/index.cjs +7 -0
- package/dist/cjs/resources/classes/index.cjs.map +1 -1
- package/dist/cjs/resources/types/RcmListPayersParams.d.ts +4 -0
- package/dist/cjs/resources/types/RcmListPayersResponse.d.ts +9 -1
- package/dist/cjs/resources/types/fhir.d.ts +13 -3
- package/dist/esm/config.d.ts +15 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.js +290 -19
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/index.js +7 -0
- package/dist/esm/resources/classes/index.js.map +1 -1
- package/dist/esm/resources/types/RcmListPayersParams.d.ts +4 -0
- package/dist/esm/resources/types/RcmListPayersResponse.d.ts +9 -1
- package/dist/esm/resources/types/fhir.d.ts +13 -3
- package/package.json +1 -1
- package/src/config.ts +16 -0
- package/src/resources/classes/fhir-ext.ts +322 -19
- package/src/resources/classes/index.ts +7 -0
- package/src/resources/types/RcmListPayersParams.ts +4 -0
- package/src/resources/types/RcmListPayersResponse.ts +9 -1
- package/src/resources/types/fhir.ts +16 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { addParamsToSearch } from '../../client/client.js';
|
|
2
|
+
import { OystehrFHIRError, OystehrSdkError } from '../../errors/index.js';
|
|
2
3
|
|
|
3
4
|
// Code adapted from https://github.com/sindresorhus/uint8array-extras
|
|
4
5
|
const MAX_BLOCK_SIZE = 65_535;
|
|
@@ -12,6 +13,186 @@ function stringToBase64(input) {
|
|
|
12
13
|
}
|
|
13
14
|
return base64;
|
|
14
15
|
}
|
|
16
|
+
function base64ToString(input) {
|
|
17
|
+
const binaryString = globalThis.atob(input);
|
|
18
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
19
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
20
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
21
|
+
}
|
|
22
|
+
return new globalThis.TextDecoder().decode(bytes);
|
|
23
|
+
}
|
|
24
|
+
// ─── Tag-mode helpers ────────────────────────────────────────────────────────
|
|
25
|
+
/** Converts a Coding to the FHIR _tag parameter value format "system|code". */
|
|
26
|
+
function codingToTagValue(coding) {
|
|
27
|
+
return coding.system ? `${coding.system}|${coding.code ?? ''}` : coding.code ?? '';
|
|
28
|
+
}
|
|
29
|
+
/** Returns true if two Codings match on system (treating absent as empty string) and code. */
|
|
30
|
+
function codingMatches(a, b) {
|
|
31
|
+
return (a.system ?? '') === (b.system ?? '') && (a.code ?? '') === (b.code ?? '');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Appends _tag (tag-workspace mode) or _tag:not (ignore-tags mode) search
|
|
35
|
+
* params to an existing SearchParam array and returns the new array.
|
|
36
|
+
*/
|
|
37
|
+
function applyTagSearchParams(config, params) {
|
|
38
|
+
const out = params ? [...params] : [];
|
|
39
|
+
if (config.workspaceTag) {
|
|
40
|
+
out.push({ name: '_tag', value: codingToTagValue(config.workspaceTag) });
|
|
41
|
+
}
|
|
42
|
+
else if (config.ignoreTags?.length) {
|
|
43
|
+
for (const tag of config.ignoreTags) {
|
|
44
|
+
out.push({ name: '_tag:not', value: codingToTagValue(tag) });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* In ignore-tags mode: throws OystehrSdkError if the resource carries any ignored tag.
|
|
51
|
+
* In tag-workspace mode: injects the workspace tag into resource.meta.tag if not already present.
|
|
52
|
+
* Returns the (possibly cloned) resource.
|
|
53
|
+
*/
|
|
54
|
+
function applyTagToResource(config, resource) {
|
|
55
|
+
const resourceLike = resource;
|
|
56
|
+
if (config.ignoreTags?.length) {
|
|
57
|
+
const resourceTags = (resourceLike.meta?.tag ?? []);
|
|
58
|
+
for (const ignored of config.ignoreTags) {
|
|
59
|
+
if (resourceTags.some((t) => codingMatches(t, ignored))) {
|
|
60
|
+
throw new OystehrSdkError({
|
|
61
|
+
message: `Resource has an ignored tag (system: "${ignored.system ?? ''}", code: "${ignored.code ?? ''}") and cannot be mutated in ignoreTags mode`,
|
|
62
|
+
code: 400,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return resource;
|
|
67
|
+
}
|
|
68
|
+
if (config.workspaceTag) {
|
|
69
|
+
const tag = config.workspaceTag;
|
|
70
|
+
const existingTags = (resourceLike.meta?.tag ?? []);
|
|
71
|
+
if (!existingTags.some((t) => codingMatches(t, tag))) {
|
|
72
|
+
return {
|
|
73
|
+
...resource,
|
|
74
|
+
meta: {
|
|
75
|
+
...resourceLike.meta,
|
|
76
|
+
tag: [...existingTags, tag],
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return resource;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* In ignore-tags mode: throws OystehrSdkError if any operation value resembles an ignored tag.
|
|
85
|
+
* In tag-workspace mode: guards against removal or loss of the workspace tag:
|
|
86
|
+
* - add/replace of the tag array: ensures workspace tag is present in the value
|
|
87
|
+
* - add/replace of meta: ensures workspace tag is present in meta.tag
|
|
88
|
+
* - remove of /meta/tag or /meta: keeps the remove and appends an operation to restore the workspace tag
|
|
89
|
+
* - add of a single tag (path ends in /-): left unchanged (workspace tag already on the resource)
|
|
90
|
+
*/
|
|
91
|
+
function applyTagToPatchOperations(config, operations) {
|
|
92
|
+
if (config.ignoreTags?.length) {
|
|
93
|
+
for (const op of operations) {
|
|
94
|
+
if (op.op === 'add' || op.op === 'replace' || op.op === 'test') {
|
|
95
|
+
const opValue = op.value;
|
|
96
|
+
if (opValue !== null && opValue !== undefined && typeof opValue === 'object') {
|
|
97
|
+
const v = opValue;
|
|
98
|
+
if (v.code !== undefined) {
|
|
99
|
+
for (const ignored of config.ignoreTags) {
|
|
100
|
+
if (codingMatches(v, ignored)) {
|
|
101
|
+
throw new OystehrSdkError({
|
|
102
|
+
message: `Patch operation contains an ignored tag (system: "${ignored.system ?? ''}", code: "${ignored.code ?? ''}") and cannot be applied in ignoreTags mode`,
|
|
103
|
+
code: 400,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return operations;
|
|
112
|
+
}
|
|
113
|
+
if (config.workspaceTag) {
|
|
114
|
+
const tag = config.workspaceTag;
|
|
115
|
+
return operations.reduce((result, op) => {
|
|
116
|
+
// remove /meta/tag — restore workspace tag afterwards
|
|
117
|
+
if (op.op === 'remove' && op.path === '/meta/tag') {
|
|
118
|
+
result.push(op);
|
|
119
|
+
result.push({ op: 'add', path: '/meta/tag', value: [tag] });
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
// remove /meta — restore workspace tag afterwards
|
|
123
|
+
if (op.op === 'remove' && op.path === '/meta') {
|
|
124
|
+
result.push(op);
|
|
125
|
+
result.push({ op: 'add', path: '/meta', value: { tag: [tag] } });
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
// add/replace the entire tag array — ensure workspace tag is present
|
|
129
|
+
if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta/tag') {
|
|
130
|
+
const tags = Array.isArray(op.value) ? op.value : [];
|
|
131
|
+
if (!tags.some((t) => codingMatches(t, tag))) {
|
|
132
|
+
result.push({ ...op, value: [...tags, tag] });
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
result.push(op);
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
// add/replace the entire meta object — ensure workspace tag is present in meta.tag
|
|
140
|
+
if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta') {
|
|
141
|
+
const metaValue = op.value != null && typeof op.value === 'object' ? op.value : {};
|
|
142
|
+
const tags = metaValue.tag ?? [];
|
|
143
|
+
if (!tags.some((t) => codingMatches(t, tag))) {
|
|
144
|
+
result.push({ ...op, value: { ...metaValue, tag: [...tags, tag] } });
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
result.push(op);
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
// All other operations (including add /meta/tag/- for individual tags) pass through unchanged.
|
|
152
|
+
// Workspace tag is assumed already present on the resource from create/update.
|
|
153
|
+
result.push(op);
|
|
154
|
+
return result;
|
|
155
|
+
}, []);
|
|
156
|
+
}
|
|
157
|
+
return operations;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Throws OystehrFHIRError (404) if the retrieved resource violates the tag configuration:
|
|
161
|
+
* - workspaceTag mode: resource must carry the workspace tag
|
|
162
|
+
* - ignoreTags mode: resource must not carry any ignored tag
|
|
163
|
+
*/
|
|
164
|
+
function assertRetrievedResource(config, resource) {
|
|
165
|
+
const resourceLike = resource;
|
|
166
|
+
const resourceTags = (resourceLike.meta?.tag ?? []);
|
|
167
|
+
if (config.workspaceTag) {
|
|
168
|
+
const tag = config.workspaceTag;
|
|
169
|
+
if (!resourceTags.some((t) => codingMatches(t, tag))) {
|
|
170
|
+
throw new OystehrFHIRError({
|
|
171
|
+
error: {
|
|
172
|
+
resourceType: 'OperationOutcome',
|
|
173
|
+
id: 'not-found',
|
|
174
|
+
issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],
|
|
175
|
+
},
|
|
176
|
+
code: 404,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (config.ignoreTags?.length) {
|
|
182
|
+
for (const ignored of config.ignoreTags) {
|
|
183
|
+
if (resourceTags.some((t) => codingMatches(t, ignored))) {
|
|
184
|
+
throw new OystehrFHIRError({
|
|
185
|
+
error: {
|
|
186
|
+
resourceType: 'OperationOutcome',
|
|
187
|
+
id: 'not-found',
|
|
188
|
+
issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],
|
|
189
|
+
},
|
|
190
|
+
code: 404,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
15
196
|
/**
|
|
16
197
|
* Performs a FHIR search and returns the results as a Bundle resource
|
|
17
198
|
*
|
|
@@ -20,10 +201,11 @@ function stringToBase64(input) {
|
|
|
20
201
|
* @returns FHIR Bundle resource
|
|
21
202
|
*/
|
|
22
203
|
async function search(params, request) {
|
|
23
|
-
const { resourceType
|
|
204
|
+
const { resourceType } = params;
|
|
205
|
+
const taggedParams = applyTagSearchParams(this.config, params.params);
|
|
24
206
|
let paramMap;
|
|
25
|
-
if (
|
|
26
|
-
paramMap =
|
|
207
|
+
if (taggedParams.length) {
|
|
208
|
+
paramMap = taggedParams.reduce((acc, param) => {
|
|
27
209
|
if (!acc[param.name]) {
|
|
28
210
|
acc[param.name] = [];
|
|
29
211
|
}
|
|
@@ -45,21 +227,26 @@ async function search(params, request) {
|
|
|
45
227
|
return bundle;
|
|
46
228
|
}
|
|
47
229
|
async function create(params, request) {
|
|
48
|
-
const
|
|
49
|
-
|
|
230
|
+
const tagged = applyTagToResource(this.config, params);
|
|
231
|
+
const { resourceType } = tagged;
|
|
232
|
+
return this.fhirRequest(`/${resourceType}`, 'POST')(tagged, request);
|
|
50
233
|
}
|
|
51
234
|
async function get({ resourceType, id }, request) {
|
|
52
|
-
|
|
235
|
+
const result = await this.fhirRequest(`/${resourceType}/${id}`, 'GET')({}, request);
|
|
236
|
+
assertRetrievedResource(this.config, result);
|
|
237
|
+
return result;
|
|
53
238
|
}
|
|
54
239
|
async function update(params, request) {
|
|
55
|
-
const
|
|
56
|
-
|
|
240
|
+
const tagged = applyTagToResource(this.config, params);
|
|
241
|
+
const { id, resourceType } = tagged;
|
|
242
|
+
return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(tagged, {
|
|
57
243
|
...request,
|
|
58
244
|
ifMatch: request?.optimisticLockingVersionId ? `W/"${request.optimisticLockingVersionId}"` : undefined,
|
|
59
245
|
});
|
|
60
246
|
}
|
|
61
247
|
async function patch({ resourceType, id, operations }, request) {
|
|
62
|
-
|
|
248
|
+
const taggedOperations = applyTagToPatchOperations(this.config, operations);
|
|
249
|
+
return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {
|
|
63
250
|
...request,
|
|
64
251
|
contentType: 'application/json-patch+json',
|
|
65
252
|
ifMatch: request?.optimisticLockingVersionId ? `W/"${request.optimisticLockingVersionId}"` : undefined,
|
|
@@ -78,8 +265,42 @@ async function history({ resourceType, id, versionId, count, offset, }, request)
|
|
|
78
265
|
}
|
|
79
266
|
return this.fhirRequest(`/${resourceType}/${id}/_history?_total=accurate`, 'GET')({}, request);
|
|
80
267
|
}
|
|
81
|
-
|
|
82
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Returns true when a batch GET/HEAD URL is a search (e.g. "Patient" or "Patient?name=foo")
|
|
270
|
+
* rather than a direct retrieval (e.g. "Patient/abc-123").
|
|
271
|
+
* A retrieval URL has a path segment after the resource type that is not a FHIR operation
|
|
272
|
+
* (operations start with "_", e.g. "_search" or "_history").
|
|
273
|
+
*/
|
|
274
|
+
function isBatchSearchUrl(url) {
|
|
275
|
+
const path = url.split('?')[0];
|
|
276
|
+
const segments = path.split('/').filter(Boolean);
|
|
277
|
+
// Only one segment → bare resource type, always a search
|
|
278
|
+
if (segments.length <= 1)
|
|
279
|
+
return true;
|
|
280
|
+
// Two or more segments: second segment is an ID if it doesn't start with '_'
|
|
281
|
+
return segments[1].startsWith('_');
|
|
282
|
+
}
|
|
283
|
+
/** Returns true when a batch POST URL targets a `_search` endpoint (e.g. "Patient/_search"). */
|
|
284
|
+
function isBatchSearchPostUrl(url) {
|
|
285
|
+
return url.split('?')[0].endsWith('/_search');
|
|
286
|
+
}
|
|
287
|
+
function batchInputRequestToBundleEntryItem(request, config) {
|
|
288
|
+
const { method } = request;
|
|
289
|
+
let url = request.url;
|
|
290
|
+
// Inject tag search params into search request URLs before URL encoding.
|
|
291
|
+
// GET/HEAD: only for search URLs (not retrievals like Patient/<id>).
|
|
292
|
+
// POST: only for _search endpoints (not creates).
|
|
293
|
+
if (((method === 'GET' || method === 'HEAD') && isBatchSearchUrl(url)) ||
|
|
294
|
+
(method === 'POST' && isBatchSearchPostUrl(url))) {
|
|
295
|
+
if (config.workspaceTag) {
|
|
296
|
+
url += (url.includes('?') ? '&' : '?') + `_tag=${codingToTagValue(config.workspaceTag)}`;
|
|
297
|
+
}
|
|
298
|
+
if (config.ignoreTags?.length) {
|
|
299
|
+
for (const tag of config.ignoreTags) {
|
|
300
|
+
url += (url.includes('?') ? '&' : '?') + `_tag:not=${codingToTagValue(tag)}`;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
83
304
|
const baseRequest = {
|
|
84
305
|
request: {
|
|
85
306
|
method,
|
|
@@ -115,7 +336,7 @@ function batchInputRequestToBundleEntryItem(request) {
|
|
|
115
336
|
}
|
|
116
337
|
// PUT updates require a full resource
|
|
117
338
|
if (method === 'PUT') {
|
|
118
|
-
const
|
|
339
|
+
const resource = applyTagToResource(config, request.resource);
|
|
119
340
|
return {
|
|
120
341
|
request: {
|
|
121
342
|
...baseRequest.request,
|
|
@@ -127,15 +348,24 @@ function batchInputRequestToBundleEntryItem(request) {
|
|
|
127
348
|
// PATCH can be Binary resource or JSON patch
|
|
128
349
|
if (method === 'PATCH') {
|
|
129
350
|
if ('resource' in request) {
|
|
351
|
+
// Binary patch — decode operations, apply tag transforms, re-encode
|
|
352
|
+
let patchResource = request.resource;
|
|
353
|
+
const binaryData = patchResource.data;
|
|
354
|
+
if (binaryData) {
|
|
355
|
+
const operations = JSON.parse(base64ToString(binaryData));
|
|
356
|
+
const taggedOperations = applyTagToPatchOperations(config, operations);
|
|
357
|
+
patchResource = { ...patchResource, data: stringToBase64(JSON.stringify(taggedOperations)) };
|
|
358
|
+
}
|
|
130
359
|
return {
|
|
131
360
|
request: {
|
|
132
361
|
...baseRequest.request,
|
|
133
362
|
ifMatch: request.ifMatch,
|
|
134
363
|
},
|
|
135
|
-
resource:
|
|
364
|
+
resource: patchResource,
|
|
136
365
|
};
|
|
137
366
|
}
|
|
138
|
-
const
|
|
367
|
+
const operations = applyTagToPatchOperations(config, request.operations);
|
|
368
|
+
const data = stringToBase64(JSON.stringify(operations));
|
|
139
369
|
return {
|
|
140
370
|
...baseRequest,
|
|
141
371
|
resource: {
|
|
@@ -145,9 +375,14 @@ function batchInputRequestToBundleEntryItem(request) {
|
|
|
145
375
|
},
|
|
146
376
|
};
|
|
147
377
|
}
|
|
378
|
+
// POST _search — no resource body; tag params were already injected into the URL above
|
|
379
|
+
if (method === 'POST' && isBatchSearchPostUrl(url)) {
|
|
380
|
+
return baseRequest;
|
|
381
|
+
}
|
|
148
382
|
// POST creates require a full resource
|
|
149
|
-
if (method === 'POST') {
|
|
150
|
-
const
|
|
383
|
+
if (method === 'POST' && 'resource' in request) {
|
|
384
|
+
const resource = applyTagToResource(config, request.resource);
|
|
385
|
+
const { fullUrl } = request;
|
|
151
386
|
return {
|
|
152
387
|
...baseRequest,
|
|
153
388
|
resource: resource,
|
|
@@ -167,11 +402,35 @@ async function batch(input, request) {
|
|
|
167
402
|
const resp = await this.fhirRequest('/', 'POST')({
|
|
168
403
|
resourceType: 'Bundle',
|
|
169
404
|
type: 'batch',
|
|
170
|
-
entry: input.requests.map(batchInputRequestToBundleEntryItem),
|
|
405
|
+
entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),
|
|
171
406
|
}, request);
|
|
407
|
+
// Validate each GET/HEAD retrieval entry against the tag config.
|
|
408
|
+
// Violations are replaced with a synthetic 404 OperationOutcome entry; batch entries are independent.
|
|
409
|
+
const rawEntries = resp.entry;
|
|
410
|
+
const processedEntries = this.config.workspaceTag || this.config.ignoreTags?.length
|
|
411
|
+
? rawEntries?.map((entry, i) => {
|
|
412
|
+
const req = input.requests[i];
|
|
413
|
+
if (!req || !entry?.resource)
|
|
414
|
+
return entry;
|
|
415
|
+
if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {
|
|
416
|
+
try {
|
|
417
|
+
assertRetrievedResource(this.config, entry.resource);
|
|
418
|
+
}
|
|
419
|
+
catch (err) {
|
|
420
|
+
if (!(err instanceof OystehrFHIRError))
|
|
421
|
+
throw err;
|
|
422
|
+
return {
|
|
423
|
+
request: entry.request,
|
|
424
|
+
response: { status: '404', outcome: err.cause },
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return entry;
|
|
429
|
+
})
|
|
430
|
+
: rawEntries;
|
|
172
431
|
const bundle = {
|
|
173
432
|
...resp,
|
|
174
|
-
entry:
|
|
433
|
+
entry: processedEntries,
|
|
175
434
|
unbundle: function () {
|
|
176
435
|
return (this.entry
|
|
177
436
|
?.map((entry) => entry.resource)
|
|
@@ -190,8 +449,20 @@ async function transaction(input, request) {
|
|
|
190
449
|
const resp = await this.fhirRequest('/', 'POST')({
|
|
191
450
|
resourceType: 'Bundle',
|
|
192
451
|
type: 'transaction',
|
|
193
|
-
entry: input.requests.map(batchInputRequestToBundleEntryItem),
|
|
452
|
+
entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),
|
|
194
453
|
}, request);
|
|
454
|
+
// Validate each GET/HEAD retrieval entry against the tag config.
|
|
455
|
+
// A violation throws OystehrFHIRError(404) — transactions are all-or-nothing.
|
|
456
|
+
if (this.config.workspaceTag || this.config.ignoreTags?.length) {
|
|
457
|
+
resp.entry?.forEach((entry, i) => {
|
|
458
|
+
const req = input.requests[i];
|
|
459
|
+
if (!req || !entry?.resource)
|
|
460
|
+
return;
|
|
461
|
+
if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {
|
|
462
|
+
assertRetrievedResource(this.config, entry.resource);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
195
466
|
const bundle = {
|
|
196
467
|
...resp,
|
|
197
468
|
entry: resp.entry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';\nimport { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';\nimport {\n BatchBundle,\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirResourceReturnValue,\n FhirSearchParams,\n FhirUpdateParams,\n OperationOutcome,\n TransactionBundle,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\n\n// Code adapted from https://github.com/sindresorhus/uint8array-extras\nconst MAX_BLOCK_SIZE = 65_535;\nfunction stringToBase64(input: string): string {\n const data: Uint8Array<ArrayBuffer> = new globalThis.TextEncoder().encode(input);\n let base64 = '';\n\n for (let index = 0; index < data.length; index += MAX_BLOCK_SIZE) {\n const chunk = data.subarray(index, index + MAX_BLOCK_SIZE);\n // Required as `btoa` and `atob` don't properly support Unicode: https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem\n base64 += globalThis.btoa(String.fromCodePoint.apply(undefined, chunk as unknown as number[]));\n }\n return base64;\n}\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n const { resourceType, params: searchParams } = params;\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (searchParams) {\n paramMap = Object.entries(searchParams).reduce((acc, [_, param]) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {\n return (\n this.entry?.map((entry) => entry.resource).filter((resource): resource is T => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const { resourceType } = params;\n return this.fhirRequest(`/${resourceType}`, 'POST')(params as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n return this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'GET')({}, request);\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const { id, resourceType } = params;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(params as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, count, offset }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n {\n resourceType,\n id,\n versionId,\n count,\n offset,\n }: { resourceType: string; id: string; versionId?: string; count?: number; offset?: number },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n if (versionId) {\n return this.fhirRequest(`/${resourceType}/${id}/_history/${versionId}`, 'GET')({}, request);\n }\n if (count) {\n return this.fhirRequest(\n `/${resourceType}/${id}/_history?_total=accurate&_count=${count}\n ${offset ? `&_offset=${offset}` : ''}`,\n 'GET'\n )({}, request);\n }\n return this.fhirRequest(`/${resourceType}/${id}/_history?_total=accurate`, 'GET')({}, request);\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>\n): BundleEntry<T | Binary<T>> {\n const { method, url } = request;\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n if (!name) {\n return acc;\n }\n if (!acc[name]) {\n acc[name] = [];\n }\n acc[name].push(value);\n return acc;\n }, {} as Record<string, string[]>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const { resource } = request;\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: request.resource,\n } as BundleEntry<Binary<T>>;\n }\n const data = stringToBase64(JSON.stringify(request.operations));\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data,\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST creates require a full resource\n if (method === 'POST') {\n const { resource, fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n\n // // Add ifMatch for the entries that support it\n // if ('ifMatch' in request) {\n // baseRequest.request = {\n // ...baseRequest.request,\n // ifMatch: request.ifMatch,\n // };\n // }\n\n throw new Error('Unrecognized method');\n}\n\nexport async function batch<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>> {\n const resp = await this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type: 'batch',\n entry: input.requests.map(batchInputRequestToBundleEntryItem),\n },\n request\n );\n const bundle: BatchBundle<BundleContentType> = {\n ...resp,\n entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n errors: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return this.entry\n ?.filter((entry) => entry.response?.status?.startsWith('4') || entry.response?.status?.startsWith('5'))\n .map((entry) => entry.response?.outcome)\n .filter((outcome): outcome is OperationOutcome => outcome !== undefined);\n },\n };\n return bundle;\n}\n\nexport async function transaction<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>> {\n const resp = await this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type: 'transaction',\n entry: input.requests.map(batchInputRequestToBundleEntryItem),\n },\n request\n );\n const bundle: TransactionBundle<BundleContentType> = {\n ...resp,\n entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport function formatAddress(\n address: AddressR4B | AddressR5,\n options?: { all?: boolean; use?: boolean; lineSeparator?: string }\n): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\nexport function formatHumanName(\n name: HumanNameR4B | HumanNameR5,\n options?: {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n }\n): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join(' ').trim();\n}\n"],"names":[],"mappings":";;AAyBA;AACA,MAAM,cAAc,GAAG,MAAM;AAC7B,SAAS,cAAc,CAAC,KAAa,EAAA;AACnC,IAAA,MAAM,IAAI,GAA4B,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IAChF,IAAI,MAAM,GAAG,EAAE;AAEf,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,cAAc,EAAE;AAChE,QAAA,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,cAAc,CAAC;;AAE1D,QAAA,MA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I,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B;AAEA,IAAA,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC7B;AAEA,IAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACf,QAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3B;IAEA,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B;AAEA,IAAA,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,CAAC,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACpC;IAEA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AACjC;;;;"}
|
|
1
|
+
{"version":3,"file":"fhir-ext.js","sources":["../../../../src/resources/classes/fhir-ext.ts"],"sourcesContent":["import type { Operation } from 'fast-json-patch';\nimport { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';\nimport { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';\nimport {\n BatchBundle,\n BatchInput,\n BatchInputRequest,\n Binary,\n Bundle,\n BundleEntry,\n Coding,\n FhirBundle,\n FhirCreateParams,\n FhirDeleteParams,\n FhirGetParams,\n FhirHistoryGetParams,\n FhirHistorySearchParams,\n FhirPatchParams,\n FhirResource,\n FhirResourceReturnValue,\n FhirSearchParams,\n FhirUpdateParams,\n OperationOutcome,\n Resource,\n SearchParam,\n TransactionBundle,\n} from '../..';\nimport { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../../errors';\n\n// Code adapted from https://github.com/sindresorhus/uint8array-extras\nconst MAX_BLOCK_SIZE = 65_535;\nfunction stringToBase64(input: string): string {\n const data: Uint8Array<ArrayBuffer> = new globalThis.TextEncoder().encode(input);\n let base64 = '';\n\n for (let index = 0; index < data.length; index += MAX_BLOCK_SIZE) {\n const chunk = data.subarray(index, index + MAX_BLOCK_SIZE);\n // Required as `btoa` and `atob` don't properly support Unicode: https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem\n base64 += globalThis.btoa(String.fromCodePoint.apply(undefined, chunk as unknown as number[]));\n }\n return base64;\n}\n\nfunction base64ToString(input: string): string {\n const binaryString = globalThis.atob(input);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return new globalThis.TextDecoder().decode(bytes);\n}\n\n// ─── Tag-mode helpers ────────────────────────────────────────────────────────\n\n/** Converts a Coding to the FHIR _tag parameter value format \"system|code\". */\nfunction codingToTagValue(coding: Coding): string {\n return coding.system ? `${coding.system}|${coding.code ?? ''}` : coding.code ?? '';\n}\n\n/** Returns true if two Codings match on system (treating absent as empty string) and code. */\nfunction codingMatches(a: Coding, b: Coding): boolean {\n return (a.system ?? '') === (b.system ?? '') && (a.code ?? '') === (b.code ?? '');\n}\n\n/**\n * Appends _tag (tag-workspace mode) or _tag:not (ignore-tags mode) search\n * params to an existing SearchParam array and returns the new array.\n */\nfunction applyTagSearchParams(config: OystehrConfig, params: SearchParam[] | undefined): SearchParam[] {\n const out: SearchParam[] = params ? [...params] : [];\n if (config.workspaceTag) {\n out.push({ name: '_tag', value: codingToTagValue(config.workspaceTag) });\n } else if (config.ignoreTags?.length) {\n for (const tag of config.ignoreTags) {\n out.push({ name: '_tag:not', value: codingToTagValue(tag) });\n }\n }\n return out;\n}\n\n/**\n * In ignore-tags mode: throws OystehrSdkError if the resource carries any ignored tag.\n * In tag-workspace mode: injects the workspace tag into resource.meta.tag if not already present.\n * Returns the (possibly cloned) resource.\n */\nfunction applyTagToResource<T extends FhirResource>(config: OystehrConfig, resource: T): T {\n const resourceLike = resource as unknown as Resource;\n\n if (config.ignoreTags?.length) {\n const resourceTags = (resourceLike.meta?.tag ?? []) as Coding[];\n for (const ignored of config.ignoreTags) {\n if (resourceTags.some((t) => codingMatches(t, ignored))) {\n throw new OystehrSdkError({\n message: `Resource has an ignored tag (system: \"${ignored.system ?? ''}\", code: \"${\n ignored.code ?? ''\n }\") and cannot be mutated in ignoreTags mode`,\n code: 400,\n });\n }\n }\n return resource;\n }\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n const existingTags = (resourceLike.meta?.tag ?? []) as Coding[];\n if (!existingTags.some((t) => codingMatches(t, tag))) {\n return {\n ...resource,\n meta: {\n ...resourceLike.meta,\n tag: [...existingTags, tag],\n },\n } as T;\n }\n }\n\n return resource;\n}\n\n/**\n * In ignore-tags mode: throws OystehrSdkError if any operation value resembles an ignored tag.\n * In tag-workspace mode: guards against removal or loss of the workspace tag:\n * - add/replace of the tag array: ensures workspace tag is present in the value\n * - add/replace of meta: ensures workspace tag is present in meta.tag\n * - remove of /meta/tag or /meta: keeps the remove and appends an operation to restore the workspace tag\n * - add of a single tag (path ends in /-): left unchanged (workspace tag already on the resource)\n */\nfunction applyTagToPatchOperations(config: OystehrConfig, operations: Operation[]): Operation[] {\n if (config.ignoreTags?.length) {\n for (const op of operations) {\n if (op.op === 'add' || op.op === 'replace' || op.op === 'test') {\n const opValue: unknown = op.value;\n if (opValue !== null && opValue !== undefined && typeof opValue === 'object') {\n const v = opValue as Coding;\n if (v.code !== undefined) {\n for (const ignored of config.ignoreTags) {\n if (codingMatches(v, ignored)) {\n throw new OystehrSdkError({\n message: `Patch operation contains an ignored tag (system: \"${ignored.system ?? ''}\", code: \"${\n ignored.code ?? ''\n }\") and cannot be applied in ignoreTags mode`,\n code: 400,\n });\n }\n }\n }\n }\n }\n }\n return operations;\n }\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n return operations.reduce<Operation[]>((result, op) => {\n // remove /meta/tag — restore workspace tag afterwards\n if (op.op === 'remove' && op.path === '/meta/tag') {\n result.push(op);\n result.push({ op: 'add' as const, path: '/meta/tag', value: [tag] });\n return result;\n }\n\n // remove /meta — restore workspace tag afterwards\n if (op.op === 'remove' && op.path === '/meta') {\n result.push(op);\n result.push({ op: 'add' as const, path: '/meta', value: { tag: [tag] } });\n return result;\n }\n\n // add/replace the entire tag array — ensure workspace tag is present\n if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta/tag') {\n const tags: Coding[] = Array.isArray(op.value) ? (op.value as Coding[]) : [];\n if (!tags.some((t) => codingMatches(t, tag))) {\n result.push({ ...op, value: [...tags, tag] });\n } else {\n result.push(op);\n }\n return result;\n }\n\n // add/replace the entire meta object — ensure workspace tag is present in meta.tag\n if ((op.op === 'add' || op.op === 'replace') && op.path === '/meta') {\n const metaValue: { tag?: Coding[] } =\n op.value != null && typeof op.value === 'object' ? (op.value as { tag?: Coding[] }) : {};\n const tags = metaValue.tag ?? [];\n if (!tags.some((t) => codingMatches(t, tag))) {\n result.push({ ...op, value: { ...metaValue, tag: [...tags, tag] } });\n } else {\n result.push(op);\n }\n return result;\n }\n\n // All other operations (including add /meta/tag/- for individual tags) pass through unchanged.\n // Workspace tag is assumed already present on the resource from create/update.\n result.push(op);\n return result;\n }, []);\n }\n\n return operations;\n}\n\n/**\n * Throws OystehrFHIRError (404) if the retrieved resource violates the tag configuration:\n * - workspaceTag mode: resource must carry the workspace tag\n * - ignoreTags mode: resource must not carry any ignored tag\n */\nfunction assertRetrievedResource(config: OystehrConfig, resource: FhirResource): void {\n const resourceLike = resource as unknown as Resource;\n const resourceTags = (resourceLike.meta?.tag ?? []) as Coding[];\n\n if (config.workspaceTag) {\n const tag = config.workspaceTag;\n if (!resourceTags.some((t) => codingMatches(t, tag))) {\n throw new OystehrFHIRError({\n error: {\n resourceType: 'OperationOutcome',\n id: 'not-found',\n issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],\n },\n code: 404,\n });\n }\n return;\n }\n\n if (config.ignoreTags?.length) {\n for (const ignored of config.ignoreTags) {\n if (resourceTags.some((t) => codingMatches(t, ignored))) {\n throw new OystehrFHIRError({\n error: {\n resourceType: 'OperationOutcome',\n id: 'not-found',\n issue: [{ severity: 'error', code: 'not-found', details: { text: 'Not found' } }],\n },\n code: 404,\n });\n }\n }\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'. Also support enabling optimistic locking.\n */\nexport interface OystehrFHIRUpdateClientRequest extends OystehrClientRequest {\n /**\n * Enable optimistic locking for the request. If set to a version ID, the request will\n * include the 'If-Match' header with that value in the FHIR optimistic-locking format.\n * If the resource has been updated since the version provided, the request\n * will fail with a 412 Precondition Failed error.\n */\n optimisticLockingVersionId?: string;\n}\n\n/**\n * Performs a FHIR search and returns the results as a Bundle resource\n *\n * @param options FHIR resource type and FHIR search parameters\n * @param request optional OystehrClientRequest object\n * @returns FHIR Bundle resource\n */\nexport async function search<T extends FhirResource>(\n this: SDKResource,\n params: FhirSearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>> {\n const { resourceType } = params;\n const taggedParams = applyTagSearchParams(this.config, params.params);\n let paramMap: Record<string, (string | number)[]> | undefined;\n if (taggedParams.length) {\n paramMap = taggedParams.reduce((acc, param) => {\n if (!acc[param.name]) {\n acc[param.name] = [];\n }\n acc[param.name].push(param.value);\n return acc;\n }, {} as Record<string, (string | number)[]>);\n }\n const requestBundle = await this.fhirRequest<FhirBundle<T>>(`/${resourceType}/_search`, 'POST')(paramMap, {\n ...request,\n contentType: 'application/x-www-form-urlencoded',\n });\n const bundle: Bundle<T> = {\n ...requestBundle,\n entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {\n return (\n this.entry?.map((entry) => entry.resource).filter((resource): resource is T => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport async function create<T extends FhirResource>(\n this: SDKResource,\n params: FhirCreateParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const tagged = applyTagToResource(this.config, params);\n const { resourceType } = tagged;\n return this.fhirRequest(`/${resourceType}`, 'POST')(tagged as unknown as Record<string, unknown>, request);\n}\n\nexport async function get<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const result = await this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'GET')({}, request);\n assertRetrievedResource(this.config, result);\n return result;\n}\n\nexport async function update<T extends FhirResource>(\n this: SDKResource,\n params: FhirUpdateParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const tagged = applyTagToResource(this.config, params);\n const { id, resourceType } = tagged;\n return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(tagged as unknown as Record<string, unknown>, {\n ...request,\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nexport async function patch<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, operations }: FhirPatchParams<T>,\n request?: OystehrFHIRUpdateClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n const taggedOperations = applyTagToPatchOperations(this.config, operations);\n return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(taggedOperations, {\n ...request,\n contentType: 'application/json-patch+json',\n ifMatch: request?.optimisticLockingVersionId ? `W/\"${request.optimisticLockingVersionId}\"` : undefined,\n });\n}\n\nasync function del<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirDeleteParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {\n return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);\n}\nexport { del as delete };\n\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, versionId }: FhirHistoryGetParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<T>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n { resourceType, id, count, offset }: FhirHistorySearchParams<T>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>>>;\nexport async function history<T extends FhirResource>(\n this: SDKResource,\n {\n resourceType,\n id,\n versionId,\n count,\n offset,\n }: { resourceType: string; id: string; versionId?: string; count?: number; offset?: number },\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<Bundle<T>> | FhirFetcherResponse<T>> {\n if (versionId) {\n return this.fhirRequest(`/${resourceType}/${id}/_history/${versionId}`, 'GET')({}, request);\n }\n if (count) {\n return this.fhirRequest(\n `/${resourceType}/${id}/_history?_total=accurate&_count=${count}\n ${offset ? `&_offset=${offset}` : ''}`,\n 'GET'\n )({}, request);\n }\n return this.fhirRequest(`/${resourceType}/${id}/_history?_total=accurate`, 'GET')({}, request);\n}\n\n/**\n * Returns true when a batch GET/HEAD URL is a search (e.g. \"Patient\" or \"Patient?name=foo\")\n * rather than a direct retrieval (e.g. \"Patient/abc-123\").\n * A retrieval URL has a path segment after the resource type that is not a FHIR operation\n * (operations start with \"_\", e.g. \"_search\" or \"_history\").\n */\nfunction isBatchSearchUrl(url: string): boolean {\n const path = url.split('?')[0];\n const segments = path.split('/').filter(Boolean);\n // Only one segment → bare resource type, always a search\n if (segments.length <= 1) return true;\n // Two or more segments: second segment is an ID if it doesn't start with '_'\n return segments[1].startsWith('_');\n}\n\n/** Returns true when a batch POST URL targets a `_search` endpoint (e.g. \"Patient/_search\"). */\nfunction isBatchSearchPostUrl(url: string): boolean {\n return url.split('?')[0].endsWith('/_search');\n}\n\nfunction batchInputRequestToBundleEntryItem<T extends FhirResource>(\n request: BatchInputRequest<T>,\n config: OystehrConfig\n): BundleEntry<T | Binary<T>> {\n const { method } = request;\n let url = request.url;\n\n // Inject tag search params into search request URLs before URL encoding.\n // GET/HEAD: only for search URLs (not retrievals like Patient/<id>).\n // POST: only for _search endpoints (not creates).\n if (\n ((method === 'GET' || method === 'HEAD') && isBatchSearchUrl(url)) ||\n (method === 'POST' && isBatchSearchPostUrl(url))\n ) {\n if (config.workspaceTag) {\n url += (url.includes('?') ? '&' : '?') + `_tag=${codingToTagValue(config.workspaceTag)}`;\n }\n if (config.ignoreTags?.length) {\n for (const tag of config.ignoreTags) {\n url += (url.includes('?') ? '&' : '?') + `_tag:not=${codingToTagValue(tag)}`;\n }\n }\n }\n\n const baseRequest = {\n request: {\n method,\n url,\n },\n };\n\n // Escape query string parameters in entry.request.url\n if (url.split('?').length > 1) {\n const [resource, query] = url.split('?');\n const params = query\n .split('&')\n .map((param) => {\n const [name, value] = param.split('=');\n return { name, value };\n })\n .reduce((acc, { name, value }) => {\n if (!name) {\n return acc;\n }\n if (!acc[name]) {\n acc[name] = [];\n }\n acc[name].push(value);\n return acc;\n }, {} as Record<string, string[]>);\n const search = new URLSearchParams();\n addParamsToSearch(params, search);\n baseRequest.request.url = `${resource}?${search.toString()}`;\n }\n\n // GET, DELETE, and HEAD require no further parameters\n if (['GET', 'DELETE', 'HEAD'].includes(method)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // PUT updates require a full resource\n if (method === 'PUT') {\n const resource = applyTagToResource(config, request.resource);\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: resource as T,\n } as BundleEntry<T>;\n }\n\n // PATCH can be Binary resource or JSON patch\n if (method === 'PATCH') {\n if ('resource' in request) {\n // Binary patch — decode operations, apply tag transforms, re-encode\n let patchResource = request.resource;\n const binaryData = patchResource.data;\n if (binaryData) {\n const operations = JSON.parse(base64ToString(binaryData)) as Operation[];\n const taggedOperations = applyTagToPatchOperations(config, operations);\n patchResource = { ...patchResource, data: stringToBase64(JSON.stringify(taggedOperations)) } as Binary<T>;\n }\n return {\n request: {\n ...baseRequest.request,\n ifMatch: request.ifMatch,\n },\n resource: patchResource,\n } as BundleEntry<Binary<T>>;\n }\n const operations = applyTagToPatchOperations(config, request.operations);\n const data = stringToBase64(JSON.stringify(operations));\n return {\n ...baseRequest,\n resource: {\n resourceType: 'Binary',\n contentType: 'application/json-patch+json',\n data,\n },\n } as BundleEntry<Binary<T>>;\n }\n\n // POST _search — no resource body; tag params were already injected into the URL above\n if (method === 'POST' && isBatchSearchPostUrl(url)) {\n return baseRequest as BundleEntry<T>;\n }\n\n // POST creates require a full resource\n if (method === 'POST' && 'resource' in request) {\n const resource = applyTagToResource(config, request.resource);\n const { fullUrl } = request;\n return {\n ...baseRequest,\n resource: resource as T,\n fullUrl,\n } as BundleEntry<T>;\n }\n\n // // Add ifMatch for the entries that support it\n // if ('ifMatch' in request) {\n // baseRequest.request = {\n // ...baseRequest.request,\n // ifMatch: request.ifMatch,\n // };\n // }\n\n throw new Error('Unrecognized method');\n}\n\nexport async function batch<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>> {\n const resp = await this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type: 'batch',\n entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),\n },\n request\n );\n // Validate each GET/HEAD retrieval entry against the tag config.\n // Violations are replaced with a synthetic 404 OperationOutcome entry; batch entries are independent.\n const rawEntries = resp.entry as Array<BundleEntry<BundleContentType>> | undefined;\n const processedEntries: Array<BundleEntry<BundleContentType>> | undefined =\n this.config.workspaceTag || this.config.ignoreTags?.length\n ? rawEntries?.map((entry, i) => {\n const req = input.requests[i];\n if (!req || !entry?.resource) return entry;\n if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {\n try {\n assertRetrievedResource(this.config, entry.resource);\n } catch (err) {\n if (!(err instanceof OystehrFHIRError)) throw err;\n return {\n request: entry.request,\n response: { status: '404', outcome: err.cause },\n } as unknown as BundleEntry<BundleContentType>;\n }\n }\n return entry;\n })\n : rawEntries;\n const bundle: BatchBundle<BundleContentType> = {\n ...resp,\n entry: processedEntries,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n errors: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return this.entry\n ?.filter((entry) => entry.response?.status?.startsWith('4') || entry.response?.status?.startsWith('5'))\n .map((entry) => entry.response?.outcome)\n .filter((outcome): outcome is OperationOutcome => outcome !== undefined);\n },\n };\n return bundle;\n}\n\nexport async function transaction<BundleContentType extends FhirResource>(\n this: SDKResource,\n input: BatchInput<BundleContentType>,\n request?: OystehrClientRequest\n): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>> {\n const resp = await this.fhirRequest('/', 'POST')(\n {\n resourceType: 'Bundle',\n type: 'transaction',\n entry: input.requests.map((req) => batchInputRequestToBundleEntryItem(req, this.config)),\n },\n request\n );\n // Validate each GET/HEAD retrieval entry against the tag config.\n // A violation throws OystehrFHIRError(404) — transactions are all-or-nothing.\n if (this.config.workspaceTag || this.config.ignoreTags?.length) {\n (resp.entry as Array<BundleEntry<BundleContentType>> | undefined)?.forEach((entry, i) => {\n const req = input.requests[i];\n if (!req || !entry?.resource) return;\n if ((req.method === 'GET' || req.method === 'HEAD') && !isBatchSearchUrl(req.url)) {\n assertRetrievedResource(this.config, entry.resource);\n }\n });\n }\n const bundle: TransactionBundle<BundleContentType> = {\n ...resp,\n entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,\n unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {\n return (\n this.entry\n ?.map((entry) => entry.resource)\n .filter((resource): resource is BundleContentType => resource !== undefined) ?? []\n );\n },\n };\n return bundle;\n}\n\nexport function formatAddress(\n address: AddressR4B | AddressR5,\n options?: { all?: boolean; use?: boolean; lineSeparator?: string }\n): string {\n const builder = [];\n\n if (address.line) {\n builder.push(...address.line);\n }\n\n if (address.city || address.state || address.postalCode) {\n const cityStateZip = [];\n if (address.city) {\n cityStateZip.push(address.city);\n }\n if (address.state) {\n cityStateZip.push(address.state);\n }\n if (address.postalCode) {\n cityStateZip.push(address.postalCode);\n }\n builder.push(cityStateZip.join(', '));\n }\n\n if (address.use && (options?.all || options?.use)) {\n builder.push('[' + address.use + ']');\n }\n\n return builder.join(options?.lineSeparator || ', ').trim();\n}\n\nexport function formatHumanName(\n name: HumanNameR4B | HumanNameR5,\n options?: {\n all?: boolean;\n prefix?: boolean;\n suffix?: boolean;\n use?: boolean;\n }\n): string {\n const builder = [];\n\n if (name.prefix && options?.prefix !== false) {\n builder.push(...name.prefix);\n }\n\n if (name.given) {\n builder.push(...name.given);\n }\n\n if (name.family) {\n builder.push(name.family);\n }\n\n if (name.suffix && options?.suffix !== false) {\n builder.push(...name.suffix);\n }\n\n if (name.use && (options?.all || options?.use)) {\n builder.push('[' + name.use + ']');\n }\n\n return builder.join(' ').trim();\n}\n"],"names":[],"mappings":";;;AA+BA;AACA,MAAM,cAAc,GAAG,MAAM;AAC7B,SAAS,cAAc,CAAC,KAAa,EAAA;AACnC,IAAA,MAAM,IAAI,GAA4B,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IAChF,IAAI,MAAM,GAAG,EAAE;AAEf,IAAA,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,cAAc,EAAE;AAChE,Q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IAAI,CAAC,KAAK,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC7B;AAEA,IAAA,IAAI,IAAI,CAAC,MAAM,EAAE;AACf,QAAA,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IAC3B;IAEA,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,EAAE,MAAM,KAAK,KAAK,EAAE;QAC5C,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B;AAEA,IAAA,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,CAAC,EAAE;QAC9C,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACpC;IAEA,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;AACjC;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OystehrSdkError } from '../../errors/index.js';
|
|
1
2
|
import { Application } from './application.js';
|
|
2
3
|
import { Charge } from './charge.js';
|
|
3
4
|
import { Conversation } from './conversation.js';
|
|
@@ -49,6 +50,12 @@ let Oystehr$1 = class Oystehr {
|
|
|
49
50
|
rcm;
|
|
50
51
|
fhir;
|
|
51
52
|
constructor(config) {
|
|
53
|
+
if (config.workspaceTag && config.ignoreTags) {
|
|
54
|
+
throw new OystehrSdkError({
|
|
55
|
+
message: 'workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config',
|
|
56
|
+
code: 400,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
52
59
|
this.config = config;
|
|
53
60
|
this.config.services ??= {};
|
|
54
61
|
this.config.services['projectApiUrl'] ??= config.projectApiUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/resources/classes/index.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { OystehrConfig } from '../../config';\nimport { Application } from './application';\nimport { Charge } from './charge';\nimport { Conversation } from './conversation';\nimport { Developer } from './developer';\nimport { Erx } from './erx';\nimport { Fax } from './fax';\nimport { Fhir } from './fhir';\nimport { Lab } from './lab';\nimport { M2m } from './m2m';\nimport { Messaging } from './messaging';\nimport { PaymentMethod } from './paymentMethod';\nimport { Project } from './project';\nimport { Rcm } from './rcm';\nimport { Role } from './role';\nimport { Secret } from './secret';\nimport { Telemed } from './telemed';\nimport { Terminology } from './terminology';\nimport { TransactionalSMS } from './transactionalSMS';\nimport { User } from './user';\nimport { Version } from './version';\nimport { Z3 } from './z3';\nimport { Zambda } from './zambda';\nimport { ZambdaLogStream } from './zambdaLogStream';\n\nexport class Oystehr {\n readonly config: OystehrConfig;\n readonly application: Application;\n readonly developer: Developer;\n readonly m2m: M2m;\n readonly messaging: Messaging;\n readonly conversation: Conversation;\n readonly transactionalSMS: TransactionalSMS;\n readonly paymentMethod: PaymentMethod;\n readonly charge: Charge;\n readonly project: Project;\n readonly role: Role;\n readonly secret: Secret;\n readonly telemed: Telemed;\n readonly user: User;\n readonly version: Version;\n readonly z3: Z3;\n readonly fax: Fax;\n readonly lab: Lab;\n readonly erx: Erx;\n readonly terminology: Terminology;\n readonly zambda: Zambda;\n readonly zambdaLogStream: ZambdaLogStream;\n readonly rcm: Rcm;\n readonly fhir: Fhir;\n constructor(config: OystehrConfig) {\n this.config = config;\n this.config.services ??= {};\n this.config.services['projectApiUrl'] ??= config.projectApiUrl;\n this.config.services['fhirApiUrl'] ??= config.fhirApiUrl;\n this.application = new Application(config);\n this.developer = new Developer(config);\n this.m2m = new M2m(config);\n this.messaging = new Messaging(config);\n this.conversation = new Conversation(config);\n this.transactionalSMS = new TransactionalSMS(config);\n this.paymentMethod = new PaymentMethod(config);\n this.charge = new Charge(config);\n this.project = new Project(config);\n this.role = new Role(config);\n this.secret = new Secret(config);\n this.telemed = new Telemed(config);\n this.user = new User(config);\n this.version = new Version(config);\n this.z3 = new Z3(config);\n this.fax = new Fax(config);\n this.lab = new Lab(config);\n this.erx = new Erx(config);\n this.terminology = new Terminology(config);\n this.zambda = new Zambda(config);\n this.zambdaLogStream = new ZambdaLogStream(config);\n this.rcm = new Rcm(config);\n this.fhir = new Fhir(config);\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/resources/classes/index.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport { OystehrConfig } from '../../config';\nimport { OystehrSdkError } from '../../errors';\nimport { Application } from './application';\nimport { Charge } from './charge';\nimport { Conversation } from './conversation';\nimport { Developer } from './developer';\nimport { Erx } from './erx';\nimport { Fax } from './fax';\nimport { Fhir } from './fhir';\nimport { Lab } from './lab';\nimport { M2m } from './m2m';\nimport { Messaging } from './messaging';\nimport { PaymentMethod } from './paymentMethod';\nimport { Project } from './project';\nimport { Rcm } from './rcm';\nimport { Role } from './role';\nimport { Secret } from './secret';\nimport { Telemed } from './telemed';\nimport { Terminology } from './terminology';\nimport { TransactionalSMS } from './transactionalSMS';\nimport { User } from './user';\nimport { Version } from './version';\nimport { Z3 } from './z3';\nimport { Zambda } from './zambda';\nimport { ZambdaLogStream } from './zambdaLogStream';\n\nexport class Oystehr {\n readonly config: OystehrConfig;\n readonly application: Application;\n readonly developer: Developer;\n readonly m2m: M2m;\n readonly messaging: Messaging;\n readonly conversation: Conversation;\n readonly transactionalSMS: TransactionalSMS;\n readonly paymentMethod: PaymentMethod;\n readonly charge: Charge;\n readonly project: Project;\n readonly role: Role;\n readonly secret: Secret;\n readonly telemed: Telemed;\n readonly user: User;\n readonly version: Version;\n readonly z3: Z3;\n readonly fax: Fax;\n readonly lab: Lab;\n readonly erx: Erx;\n readonly terminology: Terminology;\n readonly zambda: Zambda;\n readonly zambdaLogStream: ZambdaLogStream;\n readonly rcm: Rcm;\n readonly fhir: Fhir;\n constructor(config: OystehrConfig) {\n if (config.workspaceTag && config.ignoreTags) {\n throw new OystehrSdkError({\n message: 'workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config',\n code: 400,\n });\n }\n this.config = config;\n this.config.services ??= {};\n this.config.services['projectApiUrl'] ??= config.projectApiUrl;\n this.config.services['fhirApiUrl'] ??= config.fhirApiUrl;\n this.application = new Application(config);\n this.developer = new Developer(config);\n this.m2m = new M2m(config);\n this.messaging = new Messaging(config);\n this.conversation = new Conversation(config);\n this.transactionalSMS = new TransactionalSMS(config);\n this.paymentMethod = new PaymentMethod(config);\n this.charge = new Charge(config);\n this.project = new Project(config);\n this.role = new Role(config);\n this.secret = new Secret(config);\n this.telemed = new Telemed(config);\n this.user = new User(config);\n this.version = new Version(config);\n this.z3 = new Z3(config);\n this.fax = new Fax(config);\n this.lab = new Lab(config);\n this.erx = new Erx(config);\n this.terminology = new Terminology(config);\n this.zambda = new Zambda(config);\n this.zambdaLogStream = new ZambdaLogStream(config);\n this.rcm = new Rcm(config);\n this.fhir = new Fhir(config);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;sBA4Ba,OAAO,CAAA;AACT,IAAA,MAAM;AACN,IAAA,WAAW;AACX,IAAA,SAAS;AACT,IAAA,GAAG;AACH,IAAA,SAAS;AACT,IAAA,YAAY;AACZ,IAAA,gBAAgB;AAChB,IAAA,aAAa;AACb,IAAA,MAAM;AACN,IAAA,OAAO;AACP,IAAA,IAAI;AACJ,IAAA,MAAM;AACN,IAAA,OAAO;AACP,IAAA,IAAI;AACJ,IAAA,OAAO;AACP,IAAA,EAAE;AACF,IAAA,GAAG;AACH,IAAA,GAAG;AACH,IAAA,GAAG;AACH,IAAA,WAAW;AACX,IAAA,MAAM;AACN,IAAA,eAAe;AACf,IAAA,GAAG;AACH,IAAA,IAAI;AACb,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,UAAU,EAAE;YAC5C,MAAM,IAAI,eAAe,CAAC;AACx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,EAAE,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC;QAClD,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC;IAC9B;AACD;;;;"}
|
|
@@ -2,4 +2,12 @@ import { Organization } from 'fhir/r4b';
|
|
|
2
2
|
/**
|
|
3
3
|
* List of payers matching the search criteria.
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export interface RcmListPayersResponse {
|
|
6
|
+
data: Organization[];
|
|
7
|
+
metadata: {
|
|
8
|
+
/**
|
|
9
|
+
* Cursor to fetch the next page of results. Null if there are no further pages.
|
|
10
|
+
*/
|
|
11
|
+
nextCursor: string | null;
|
|
12
|
+
};
|
|
13
|
+
}
|