@oystehr/sdk 4.2.6 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +30 -1
  2. package/dist/cjs/client/client.cjs +35 -7
  3. package/dist/cjs/client/client.cjs.map +1 -1
  4. package/dist/cjs/config.d.ts +2 -0
  5. package/dist/cjs/index.min.cjs +1 -1
  6. package/dist/cjs/index.min.cjs.map +1 -1
  7. package/dist/cjs/resources/classes/fhir-ext.cjs +39 -10
  8. package/dist/cjs/resources/classes/fhir-ext.cjs.map +1 -1
  9. package/dist/cjs/resources/classes/fhir-ext.d.ts +8 -8
  10. package/dist/cjs/resources/classes/fhir.d.ts +2 -2
  11. package/dist/cjs/resources/classes/index.cjs +6 -6
  12. package/dist/cjs/resources/classes/index.cjs.map +1 -1
  13. package/dist/cjs/resources/classes/index.d.ts +3 -3
  14. package/dist/cjs/resources/classes/rcm.cjs +12 -15
  15. package/dist/cjs/resources/classes/rcm.cjs.map +1 -1
  16. package/dist/cjs/resources/classes/rcm.d.ts +9 -12
  17. package/dist/cjs/resources/classes/zambda.cjs +1 -1
  18. package/dist/cjs/resources/classes/zambda.cjs.map +1 -1
  19. package/dist/cjs/resources/classes/zambdaLogStream.cjs +1 -1
  20. package/dist/cjs/resources/classes/zambdaLogStream.cjs.map +1 -1
  21. package/dist/cjs/resources/types/RcmSetClaimStatusParams.d.ts +7 -0
  22. package/dist/cjs/resources/types/RcmSetClaimStatusResponse.d.ts +5 -0
  23. package/dist/cjs/resources/types/RcmSubmitClaimParams.d.ts +3 -0
  24. package/dist/cjs/resources/types/RcmSubmitClaimResponse.d.ts +5 -0
  25. package/dist/cjs/resources/types/ZambdaCreateParams.d.ts +1 -1
  26. package/dist/cjs/resources/types/ZambdaExecuteResult.d.ts +6 -0
  27. package/dist/cjs/resources/types/ZambdaUpdateParams.d.ts +1 -1
  28. package/dist/cjs/resources/types/fhir.d.ts +20 -0
  29. package/dist/cjs/resources/types/index.d.ts +29 -29
  30. package/dist/esm/client/client.js +35 -7
  31. package/dist/esm/client/client.js.map +1 -1
  32. package/dist/esm/config.d.ts +2 -0
  33. package/dist/esm/index.min.js +1 -1
  34. package/dist/esm/index.min.js.map +1 -1
  35. package/dist/esm/resources/classes/fhir-ext.d.ts +8 -8
  36. package/dist/esm/resources/classes/fhir-ext.js +39 -10
  37. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  38. package/dist/esm/resources/classes/fhir.d.ts +2 -2
  39. package/dist/esm/resources/classes/index.d.ts +3 -3
  40. package/dist/esm/resources/classes/index.js +6 -6
  41. package/dist/esm/resources/classes/index.js.map +1 -1
  42. package/dist/esm/resources/classes/rcm.d.ts +9 -12
  43. package/dist/esm/resources/classes/rcm.js +12 -15
  44. package/dist/esm/resources/classes/rcm.js.map +1 -1
  45. package/dist/esm/resources/classes/zambda.js +1 -1
  46. package/dist/esm/resources/classes/zambda.js.map +1 -1
  47. package/dist/esm/resources/classes/zambdaLogStream.js +1 -1
  48. package/dist/esm/resources/classes/zambdaLogStream.js.map +1 -1
  49. package/dist/esm/resources/types/RcmSetClaimStatusParams.d.ts +7 -0
  50. package/dist/esm/resources/types/RcmSetClaimStatusResponse.d.ts +5 -0
  51. package/dist/esm/resources/types/RcmSubmitClaimParams.d.ts +3 -0
  52. package/dist/esm/resources/types/RcmSubmitClaimResponse.d.ts +5 -0
  53. package/dist/esm/resources/types/ZambdaCreateParams.d.ts +1 -1
  54. package/dist/esm/resources/types/ZambdaExecuteResult.d.ts +6 -0
  55. package/dist/esm/resources/types/ZambdaUpdateParams.d.ts +1 -1
  56. package/dist/esm/resources/types/fhir.d.ts +20 -0
  57. package/dist/esm/resources/types/index.d.ts +29 -29
  58. package/package.json +2 -2
  59. package/src/client/client.ts +37 -6
  60. package/src/config.ts +2 -0
  61. package/src/resources/classes/fhir-ext.ts +69 -23
  62. package/src/resources/classes/index.ts +6 -6
  63. package/src/resources/classes/rcm.ts +16 -25
  64. package/src/resources/classes/zambda.ts +1 -1
  65. package/src/resources/classes/zambdaLogStream.ts +1 -1
  66. package/src/resources/types/RcmSetClaimStatusParams.ts +9 -0
  67. package/src/resources/types/RcmSetClaimStatusResponse.ts +7 -0
  68. package/src/resources/types/RcmSubmitClaimParams.ts +5 -0
  69. package/src/resources/types/RcmSubmitClaimResponse.ts +7 -0
  70. package/src/resources/types/ZambdaCreateParams.ts +1 -1
  71. package/src/resources/types/ZambdaExecuteResult.ts +6 -0
  72. package/src/resources/types/ZambdaUpdateParams.ts +1 -1
  73. package/src/resources/types/fhir.ts +13 -0
  74. package/src/resources/types/index.ts +29 -29
  75. package/dist/cjs/resources/types/RcmSubmitProfessionalClaimParams.d.ts +0 -10
  76. package/dist/cjs/resources/types/RcmSubmitProfessionalClaimResponse.d.ts +0 -5
  77. package/dist/cjs/resources/types/RcmValidateProfessionalClaimParams.d.ts +0 -6
  78. package/dist/cjs/resources/types/RcmValidateProfessionalClaimResponse.d.ts +0 -21
  79. package/dist/esm/resources/types/RcmSubmitProfessionalClaimParams.d.ts +0 -10
  80. package/dist/esm/resources/types/RcmSubmitProfessionalClaimResponse.d.ts +0 -5
  81. package/dist/esm/resources/types/RcmValidateProfessionalClaimParams.d.ts +0 -6
  82. package/dist/esm/resources/types/RcmValidateProfessionalClaimResponse.d.ts +0 -21
  83. package/src/resources/types/RcmSubmitProfessionalClaimParams.ts +0 -13
  84. package/src/resources/types/RcmSubmitProfessionalClaimResponse.ts +0 -7
  85. package/src/resources/types/RcmValidateProfessionalClaimParams.ts +0 -9
  86. package/src/resources/types/RcmValidateProfessionalClaimResponse.ts +0 -23
@@ -10,6 +10,21 @@ export type Bundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
10
10
  entry?: Array<BundleEntry<F>>;
11
11
  }) => F[];
12
12
  };
13
+ export type BatchBundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
14
+ entry?: Array<BundleEntry<F>> | undefined;
15
+ unbundle: (this: {
16
+ entry?: Array<BundleEntry<F>>;
17
+ }) => F[];
18
+ errors: (this: {
19
+ entry?: Array<BundleEntry<F>>;
20
+ }) => OperationOutcome[] | undefined;
21
+ };
22
+ export type TransactionBundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
23
+ entry?: Array<BundleEntry<F>> | undefined;
24
+ unbundle: (this: {
25
+ entry?: Array<BundleEntry<F>>;
26
+ }) => F[];
27
+ };
13
28
  export type BundleEntry<F extends FhirResource> = F extends FhirResourceR4B ? BundleEntryR4B<F> : BundleEntryR5<F>;
14
29
  export type Binary<F extends FhirResource> = F extends FhirResourceR4B ? BinaryR4B : BinaryR5;
15
30
  export type OperationOutcome = OperationOutcomeR4B | OperationOutcomeR5;
@@ -17,6 +32,11 @@ export type SearchParam = {
17
32
  name: string;
18
33
  value: string | number;
19
34
  };
35
+ export type FhirResourceReturnValue<T extends FhirResource> = T extends {
36
+ id?: string | undefined;
37
+ } ? Omit<T, 'id'> & {
38
+ id: string;
39
+ } : T;
20
40
  export interface FhirSearchParams<T extends FhirResource> {
21
41
  resourceType: T['resourceType'];
22
42
  params?: SearchParam[];
@@ -8,9 +8,6 @@ export * from './Application';
8
8
  export * from './RoleStub';
9
9
  export * from './RoleListItem';
10
10
  export * from './Role';
11
- export * from './ZambdaSchedule';
12
- export * from './ZambdaFunction';
13
- export * from './ZambdaExecuteResult';
14
11
  export * from './Secret';
15
12
  export * from './SecretListItem';
16
13
  export * from './UserListItem';
@@ -87,12 +84,6 @@ export * from './ChargeStatusResponse';
87
84
  export * from './ProjectGetResponse';
88
85
  export * from './ProjectUpdateParams';
89
86
  export * from './ProjectUpdateResponse';
90
- export * from './RcmEligibilityCheckParams';
91
- export * from './RcmEligibilityCheckResponse';
92
- export * from './RcmValidateProfessionalClaimParams';
93
- export * from './RcmValidateProfessionalClaimResponse';
94
- export * from './RcmSubmitProfessionalClaimParams';
95
- export * from './RcmSubmitProfessionalClaimResponse';
96
87
  export * from './RoleListResponse';
97
88
  export * from './RoleCreateParams';
98
89
  export * from './RoleCreateResponse';
@@ -134,26 +125,6 @@ export * from './Z3ListObjectsResponse';
134
125
  export * from './Z3GetPresignedUrlParams';
135
126
  export * from './Z3GetPresignedUrlResponse';
136
127
  export * from './Z3DeleteObjectParams';
137
- export * from './ZambdaListResponse';
138
- export * from './ZambdaCreateParams';
139
- export * from './ZambdaCreateResponse';
140
- export * from './ZambdaGetParams';
141
- export * from './ZambdaGetResponse';
142
- export * from './ZambdaUpdateParams';
143
- export * from './ZambdaUpdateResponse';
144
- export * from './ZambdaDeleteParams';
145
- export * from './ZambdaExecuteParams';
146
- export * from './ZambdaExecuteResponse';
147
- export * from './ZambdaExecutePublicParams';
148
- export * from './ZambdaExecutePublicResponse';
149
- export * from './ZambdaLogStreamListParams';
150
- export * from './ZambdaLogStreamListResponse';
151
- export * from './ZambdaS3UploadParams';
152
- export * from './ZambdaS3UploadResponse';
153
- export * from './ZambdaLogStreamSearchParams';
154
- export * from './ZambdaLogStreamSearchResponse';
155
- export * from './ZambdaLogStreamGetParams';
156
- export * from './ZambdaLogStreamGetResponse';
157
128
  export * from './FaxOnboardResponse';
158
129
  export * from './FaxGetConfigurationResponse';
159
130
  export * from './FaxSendParams';
@@ -195,7 +166,36 @@ export * from './ErxCheckPractitionerEnrollmentParams';
195
166
  export * from './ErxCheckPractitionerEnrollmentResponse';
196
167
  export * from './ErxEnrollPractitionerParams';
197
168
  export * from './ErxUnenrollPractitionerParams';
169
+ export * from './RcmEligibilityCheckParams';
170
+ export * from './RcmEligibilityCheckResponse';
171
+ export * from './RcmSubmitClaimParams';
172
+ export * from './RcmSubmitClaimResponse';
173
+ export * from './RcmSetClaimStatusParams';
174
+ export * from './RcmSetClaimStatusResponse';
198
175
  export * from './TerminologySearchCptParams';
199
176
  export * from './TerminologySearchCptResponse';
200
177
  export * from './TerminologySearchHcpcsParams';
201
178
  export * from './TerminologySearchHcpcsResponse';
179
+ export * from './ZambdaSchedule';
180
+ export * from './ZambdaFunction';
181
+ export * from './ZambdaExecuteResult';
182
+ export * from './ZambdaListResponse';
183
+ export * from './ZambdaCreateParams';
184
+ export * from './ZambdaCreateResponse';
185
+ export * from './ZambdaGetParams';
186
+ export * from './ZambdaGetResponse';
187
+ export * from './ZambdaUpdateParams';
188
+ export * from './ZambdaUpdateResponse';
189
+ export * from './ZambdaDeleteParams';
190
+ export * from './ZambdaExecuteParams';
191
+ export * from './ZambdaExecuteResponse';
192
+ export * from './ZambdaExecutePublicParams';
193
+ export * from './ZambdaExecutePublicResponse';
194
+ export * from './ZambdaLogStreamListParams';
195
+ export * from './ZambdaLogStreamListResponse';
196
+ export * from './ZambdaS3UploadParams';
197
+ export * from './ZambdaS3UploadResponse';
198
+ export * from './ZambdaLogStreamSearchParams';
199
+ export * from './ZambdaLogStreamSearchResponse';
200
+ export * from './ZambdaLogStreamGetParams';
201
+ export * from './ZambdaLogStreamGetResponse';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oystehr/sdk",
3
- "version": "4.2.6",
3
+ "version": "4.3.2",
4
4
  "description": "Oystehr SDK",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -14,7 +14,7 @@
14
14
  "parser": "tsx debug-parser.ts",
15
15
  "publish-to-npmjs": "npm run build && npm publish",
16
16
  "publish-to-npmjs-next": "npm run build && npm publish --tag next",
17
- "generate": "ts-node --project scripts/tsconfig.json scripts/generate-sdk-v3 project,fax,lab,erx,terminology src/resources"
17
+ "generate": "ts-node --project scripts/tsconfig.json scripts/generate-sdk-v3 project,fax,lab,erx,terminology,zambda,rcm src/resources"
18
18
  },
19
19
  "engines": {
20
20
  "npm": ">=8.0.0",
@@ -104,6 +104,29 @@ function isInternalClientRequest(request: Record<string, any>): request is Inter
104
104
  return 'accessToken' in request;
105
105
  }
106
106
 
107
+ /**
108
+ * Parse XML response in format <response><status>...</status><output>...</output></response>
109
+ */
110
+ function parseXmlResponse(xmlString: string): Record<string, unknown> | null {
111
+ try {
112
+ // Extract status
113
+ const statusMatch = xmlString.match(/<status>(\d+)<\/status>/);
114
+ const status = statusMatch ? parseInt(statusMatch[1], 10) : null;
115
+
116
+ // Extract output - everything between <output> and </output>
117
+ const outputMatch = xmlString.match(/<output>([\s\S]*?)<\/output>/);
118
+ const output = outputMatch ? outputMatch[1] : null;
119
+
120
+ if (status === null || output === null) {
121
+ return null;
122
+ }
123
+
124
+ return { status, output };
125
+ } catch (_err) {
126
+ return null;
127
+ }
128
+ }
129
+
107
130
  function fetcher(
108
131
  baseUrlThunk: () => string,
109
132
  configThunk: () => OystehrConfig,
@@ -196,13 +219,19 @@ function fetcher(
196
219
  );
197
220
  const responseBody = response.body ? await response.text() : null;
198
221
  let responseJson: Record<string, unknown> | null;
222
+ const contentType = response.headers.get('content-type');
199
223
  try {
200
- responseJson =
224
+ if (
201
225
  responseBody &&
202
- (response.headers.get('content-type')?.includes('application/json') ||
203
- response.headers.get('content-type')?.includes('application/fhir+json'))
204
- ? JSON.parse(responseBody)
205
- : null;
226
+ (contentType?.includes('application/json') || contentType?.includes('application/fhir+json'))
227
+ ) {
228
+ responseJson = JSON.parse(responseBody);
229
+ } else if (responseBody && (contentType?.includes('application/xml') || contentType?.includes('text/xml'))) {
230
+ // Parse XML response into { status, output } structure
231
+ responseJson = parseXmlResponse(responseBody);
232
+ } else {
233
+ responseJson = null;
234
+ }
206
235
  } catch (_err) {
207
236
  // ignore JSON.parse errors
208
237
  responseJson = null;
@@ -211,7 +240,9 @@ function fetcher(
211
240
  if (isError) {
212
241
  const errObj = {
213
242
  message:
214
- (responseJson?.output as Record<string, unknown>)?.message ?? // official zambda output format
243
+ (typeof responseJson?.output === 'string'
244
+ ? responseJson.output // XML error case - output is XML string
245
+ : (responseJson?.output as Record<string, unknown>)?.message) ?? // official zambda output format (JSON)
215
246
  responseJson?.message ?? // normal endpoint output format
216
247
  responseJson ?? // parsable json
217
248
  responseBody ?? // raw response
package/src/config.ts CHANGED
@@ -18,7 +18,9 @@ export interface OystehrConfig {
18
18
  fhirApiUrl?: string;
19
19
  labApiUrl?: string;
20
20
  projectApiUrl?: string;
21
+ rcmApiUrl?: string;
21
22
  terminologyApiUrl?: string;
23
+ zambdaApiUrl?: string;
22
24
  };
23
25
  /**
24
26
  * Optionally provide a custom fetch implementation. This must conform to the
@@ -1,6 +1,7 @@
1
1
  import { Address as AddressR4B, HumanName as HumanNameR4B } from 'fhir/r4b';
2
2
  import { Address as AddressR5, HumanName as HumanNameR5 } from 'fhir/r5';
3
3
  import {
4
+ BatchBundle,
4
5
  BatchInput,
5
6
  BatchInputRequest,
6
7
  Binary,
@@ -14,8 +15,11 @@ import {
14
15
  FhirHistorySearchParams,
15
16
  FhirPatchParams,
16
17
  FhirResource,
18
+ FhirResourceReturnValue,
17
19
  FhirSearchParams,
18
20
  FhirUpdateParams,
21
+ OperationOutcome,
22
+ TransactionBundle,
19
23
  } from '../..';
20
24
  import { addParamsToSearch, FhirFetcherResponse, OystehrClientRequest, SDKResource } from '../../client/client';
21
25
 
@@ -79,7 +83,9 @@ export async function search<T extends FhirResource>(
79
83
  ...requestBundle,
80
84
  entry: requestBundle.entry as Array<BundleEntry<T>> | undefined,
81
85
  unbundle: function (this: { entry?: Array<BundleEntry<T>> | undefined }) {
82
- return this.entry?.map((entry) => entry.resource).filter((entry): entry is T => entry !== undefined) ?? [];
86
+ return (
87
+ this.entry?.map((entry) => entry.resource).filter((resource): resource is T => resource !== undefined) ?? []
88
+ );
83
89
  },
84
90
  };
85
91
  return bundle;
@@ -89,7 +95,7 @@ export async function create<T extends FhirResource>(
89
95
  this: SDKResource,
90
96
  params: FhirCreateParams<T>,
91
97
  request?: OystehrClientRequest
92
- ): Promise<FhirFetcherResponse<T>> {
98
+ ): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {
93
99
  const { resourceType } = params;
94
100
  return this.fhirRequest(`/${resourceType}`, 'POST')(params as unknown as Record<string, unknown>, request);
95
101
  }
@@ -98,15 +104,15 @@ export async function get<T extends FhirResource>(
98
104
  this: SDKResource,
99
105
  { resourceType, id }: FhirGetParams<T>,
100
106
  request?: OystehrClientRequest
101
- ): Promise<FhirFetcherResponse<T>> {
102
- return this.fhirRequest<T>(`/${resourceType}/${id}`, 'GET')({}, request);
107
+ ): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {
108
+ return this.fhirRequest<FhirResourceReturnValue<T>>(`/${resourceType}/${id}`, 'GET')({}, request);
103
109
  }
104
110
 
105
111
  export async function update<T extends FhirResource>(
106
112
  this: SDKResource,
107
113
  params: FhirUpdateParams<T>,
108
114
  request?: OystehrFHIRUpdateClientRequest
109
- ): Promise<FhirFetcherResponse<T>> {
115
+ ): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {
110
116
  const { id, resourceType } = params;
111
117
  return this.fhirRequest(`/${resourceType}/${id}`, 'PUT')(params as unknown as Record<string, unknown>, {
112
118
  ...request,
@@ -118,7 +124,7 @@ export async function patch<T extends FhirResource>(
118
124
  this: SDKResource,
119
125
  { resourceType, id, operations }: FhirPatchParams<T>,
120
126
  request?: OystehrFHIRUpdateClientRequest
121
- ): Promise<FhirFetcherResponse<T>> {
127
+ ): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {
122
128
  return this.fhirRequest(`/${resourceType}/${id}`, 'PATCH')(operations, {
123
129
  ...request,
124
130
  contentType: 'application/json-patch+json',
@@ -130,7 +136,7 @@ async function del<T extends FhirResource>(
130
136
  this: SDKResource,
131
137
  { resourceType, id }: FhirDeleteParams<T>,
132
138
  request?: OystehrClientRequest
133
- ): Promise<FhirFetcherResponse<T>> {
139
+ ): Promise<FhirFetcherResponse<FhirResourceReturnValue<T>>> {
134
140
  return this.fhirRequest(`/${resourceType}/${id}`, 'DELETE')({}, request);
135
141
  }
136
142
  export { del as delete };
@@ -269,25 +275,65 @@ function batchInputRequestToBundleEntryItem<T extends FhirResource>(
269
275
  throw new Error('Unrecognized method');
270
276
  }
271
277
 
272
- function bundleRequest(type: 'batch' | 'transaction') {
273
- return async function <BundleContentType extends FhirResource>(
274
- this: SDKResource,
275
- input: BatchInput<BundleContentType>,
276
- request?: OystehrClientRequest
277
- ): Promise<FhirFetcherResponse<Bundle<BundleContentType>>> {
278
- return this.fhirRequest('/', 'POST')(
279
- {
280
- resourceType: 'Bundle',
281
- type,
282
- entry: input.requests.map(batchInputRequestToBundleEntryItem),
283
- },
284
- request
285
- );
278
+ export async function batch<BundleContentType extends FhirResource>(
279
+ this: SDKResource,
280
+ input: BatchInput<BundleContentType>,
281
+ request?: OystehrClientRequest
282
+ ): Promise<FhirFetcherResponse<BatchBundle<BundleContentType>>> {
283
+ const resp = await this.fhirRequest('/', 'POST')(
284
+ {
285
+ resourceType: 'Bundle',
286
+ type: 'batch',
287
+ entry: input.requests.map(batchInputRequestToBundleEntryItem),
288
+ },
289
+ request
290
+ );
291
+ const bundle: BatchBundle<BundleContentType> = {
292
+ ...resp,
293
+ entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,
294
+ unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {
295
+ return (
296
+ this.entry
297
+ ?.map((entry) => entry.resource)
298
+ .filter((resource): resource is BundleContentType => resource !== undefined) ?? []
299
+ );
300
+ },
301
+ errors: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {
302
+ return this.entry
303
+ ?.filter((entry) => entry.response?.status?.startsWith('4') || entry.response?.status?.startsWith('5'))
304
+ .map((entry) => entry.response?.outcome)
305
+ .filter((outcome): outcome is OperationOutcome => outcome !== undefined);
306
+ },
286
307
  };
308
+ return bundle;
287
309
  }
288
310
 
289
- export const batch = bundleRequest('batch');
290
- export const transaction = bundleRequest('transaction');
311
+ export async function transaction<BundleContentType extends FhirResource>(
312
+ this: SDKResource,
313
+ input: BatchInput<BundleContentType>,
314
+ request?: OystehrClientRequest
315
+ ): Promise<FhirFetcherResponse<TransactionBundle<BundleContentType>>> {
316
+ const resp = await this.fhirRequest('/', 'POST')(
317
+ {
318
+ resourceType: 'Bundle',
319
+ type: 'transaction',
320
+ entry: input.requests.map(batchInputRequestToBundleEntryItem),
321
+ },
322
+ request
323
+ );
324
+ const bundle: TransactionBundle<BundleContentType> = {
325
+ ...resp,
326
+ entry: resp.entry as Array<BundleEntry<BundleContentType>> | undefined,
327
+ unbundle: function (this: { entry?: Array<BundleEntry<BundleContentType>> | undefined }) {
328
+ return (
329
+ this.entry
330
+ ?.map((entry) => entry.resource)
331
+ .filter((resource): resource is BundleContentType => resource !== undefined) ?? []
332
+ );
333
+ },
334
+ };
335
+ return bundle;
336
+ }
291
337
 
292
338
  export function formatAddress(
293
339
  address: AddressR4B | AddressR5,
@@ -36,19 +36,19 @@ export class Oystehr {
36
36
  readonly paymentMethod: PaymentMethod;
37
37
  readonly charge: Charge;
38
38
  readonly project: Project;
39
- readonly rcm: Rcm;
40
39
  readonly role: Role;
41
40
  readonly secret: Secret;
42
41
  readonly telemed: Telemed;
43
42
  readonly user: User;
44
43
  readonly version: Version;
45
44
  readonly z3: Z3;
46
- readonly zambda: Zambda;
47
- readonly zambdaLogStream: ZambdaLogStream;
48
45
  readonly fax: Fax;
49
46
  readonly lab: Lab;
50
47
  readonly erx: Erx;
48
+ readonly rcm: Rcm;
51
49
  readonly terminology: Terminology;
50
+ readonly zambda: Zambda;
51
+ readonly zambdaLogStream: ZambdaLogStream;
52
52
  readonly fhir: Fhir;
53
53
  constructor(config: OystehrConfig) {
54
54
  this.config = config;
@@ -64,19 +64,19 @@ export class Oystehr {
64
64
  this.paymentMethod = new PaymentMethod(config);
65
65
  this.charge = new Charge(config);
66
66
  this.project = new Project(config);
67
- this.rcm = new Rcm(config);
68
67
  this.role = new Role(config);
69
68
  this.secret = new Secret(config);
70
69
  this.telemed = new Telemed(config);
71
70
  this.user = new User(config);
72
71
  this.version = new Version(config);
73
72
  this.z3 = new Z3(config);
74
- this.zambda = new Zambda(config);
75
- this.zambdaLogStream = new ZambdaLogStream(config);
76
73
  this.fax = new Fax(config);
77
74
  this.lab = new Lab(config);
78
75
  this.erx = new Erx(config);
76
+ this.rcm = new Rcm(config);
79
77
  this.terminology = new Terminology(config);
78
+ this.zambda = new Zambda(config);
79
+ this.zambdaLogStream = new ZambdaLogStream(config);
80
80
  this.fhir = new Fhir(config);
81
81
  }
82
82
  }
@@ -4,10 +4,10 @@ import {
4
4
  OystehrClientRequest,
5
5
  RcmEligibilityCheckParams,
6
6
  RcmEligibilityCheckResponse,
7
- RcmSubmitProfessionalClaimParams,
8
- RcmSubmitProfessionalClaimResponse,
9
- RcmValidateProfessionalClaimParams,
10
- RcmValidateProfessionalClaimResponse,
7
+ RcmSetClaimStatusParams,
8
+ RcmSetClaimStatusResponse,
9
+ RcmSubmitClaimParams,
10
+ RcmSubmitClaimResponse,
11
11
  } from '../..';
12
12
  import { SDKResource } from '../../client/client';
13
13
  import { OystehrConfig } from '../../config';
@@ -17,7 +17,7 @@ export class Rcm extends SDKResource {
17
17
  super(config);
18
18
  }
19
19
  #baseUrlThunk(): string {
20
- return this.config.services?.['projectApiUrl'] ?? 'https://project-api.zapehr.com/v1';
20
+ return this.config.services?.['rcmApiUrl'] ?? 'https://rcm-api.zapehr.com/v1';
21
21
  }
22
22
  /**
23
23
  * Check [Insurance Eligibility](https://docs.oystehr.com/oystehr/services/rcm/eligibility/).
@@ -32,39 +32,30 @@ export class Rcm extends SDKResource {
32
32
  params: RcmEligibilityCheckParams,
33
33
  request?: OystehrClientRequest
34
34
  ): Promise<RcmEligibilityCheckResponse> {
35
- return this.request('/rcm/eligibility-check', 'post', this.#baseUrlThunk.bind(this))(params, request);
35
+ return this.request('/eligibility-check', 'post', this.#baseUrlThunk.bind(this))(params, request);
36
36
  }
37
37
  /**
38
- * Check [Validate Professional Claim](https://docs.oystehr.com/oystehr/services/rcm/professional-claim-submission/).
38
+ * Submit a claim to a payer.
39
39
  *
40
- * Access Policy Action: `RCM:ValidateProfessionalClaim`
40
+ * Access Policy Action: `RCM:SubmitClaim`
41
41
  * Access Policy Resource: `RCM:Claim`
42
42
  *
43
43
  * Access Policy Action: `FHIR:Create`
44
- * Access Policy Resource: `FHIR:AuditEvent`
44
+ * Access Policy Resource: `FHIR:ClaimResponse`
45
45
  */
46
- validateProfessionalClaim(
47
- params: RcmValidateProfessionalClaimParams,
48
- request?: OystehrClientRequest
49
- ): Promise<RcmValidateProfessionalClaimResponse> {
50
- return this.request('/rcm/professional-claim/validate', 'post', this.#baseUrlThunk.bind(this))(params, request);
46
+ submitClaim(params: RcmSubmitClaimParams, request?: OystehrClientRequest): Promise<RcmSubmitClaimResponse> {
47
+ return this.request('/claim/{claimId}/submit', 'post', this.#baseUrlThunk.bind(this))(params, request);
51
48
  }
52
49
  /**
53
- * Check [Submit Professional Claim](https://docs.oystehr.com/oystehr/services/rcm/professional-claim-submission/).
50
+ * Emulate asynchronous claim responses by manually setting claim status.
54
51
  *
55
- * Access Policy Action: `RCM:SubmitProfessionalClaim`
52
+ * Access Policy Action: `RCM:SubmitClaim`
56
53
  * Access Policy Resource: `RCM:Claim`
57
54
  *
58
55
  * Access Policy Action: `FHIR:Create`
59
- * Access Policy Resource: `FHIR:AuditEvent`
60
- *
61
- * Access Policy Actions: `FHIR:Create, FHIR:Update`
62
- * Access Policy Resource: `FHIR:Claim`
56
+ * Access Policy Resource: `FHIR:ClaimResponse`
63
57
  */
64
- submitProfessionalClaim(
65
- params: RcmSubmitProfessionalClaimParams,
66
- request?: OystehrClientRequest
67
- ): Promise<RcmSubmitProfessionalClaimResponse> {
68
- return this.request('/rcm/professional-claim/submit', 'post', this.#baseUrlThunk.bind(this))(params, request);
58
+ setClaimStatus(params: RcmSetClaimStatusParams, request?: OystehrClientRequest): Promise<RcmSetClaimStatusResponse> {
59
+ return this.request('/claim/{claimId}/status', 'post', this.#baseUrlThunk.bind(this))(params, request);
69
60
  }
70
61
  }
@@ -26,7 +26,7 @@ export class Zambda extends SDKResource {
26
26
  super(config);
27
27
  }
28
28
  #baseUrlThunk(): string {
29
- return this.config.services?.['projectApiUrl'] ?? 'https://project-api.zapehr.com/v1';
29
+ return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
30
30
  }
31
31
  uploadFile = ext.uploadFile;
32
32
  /**
@@ -17,7 +17,7 @@ export class ZambdaLogStream extends SDKResource {
17
17
  super(config);
18
18
  }
19
19
  #baseUrlThunk(): string {
20
- return this.config.services?.['projectApiUrl'] ?? 'https://project-api.zapehr.com/v1';
20
+ return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
21
21
  }
22
22
  /**
23
23
  * Get the log streams for the Zambda Function with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
@@ -0,0 +1,9 @@
1
+ // AUTOGENERATED -- DO NOT EDIT
2
+
3
+ export interface RcmSetClaimStatusParams {
4
+ /**
5
+ * The new status for the claim.
6
+ */
7
+ status: 'accepted' | 'rejected';
8
+ claimId: string;
9
+ }
@@ -0,0 +1,7 @@
1
+ // AUTOGENERATED -- DO NOT EDIT
2
+
3
+ import { ClaimResponse } from 'fhir/r4b';
4
+ /**
5
+ * A valid FHIR ClaimResponse object will be returned with details on the claim result.
6
+ */
7
+ export type RcmSetClaimStatusResponse = ClaimResponse;
@@ -0,0 +1,5 @@
1
+ // AUTOGENERATED -- DO NOT EDIT
2
+
3
+ export interface RcmSubmitClaimParams {
4
+ claimId: string;
5
+ }
@@ -0,0 +1,7 @@
1
+ // AUTOGENERATED -- DO NOT EDIT
2
+
3
+ import { ClaimResponse } from 'fhir/r4b';
4
+ /**
5
+ * A valid FHIR ClaimResponse object will be returned with details on the claim result.
6
+ */
7
+ export type RcmSubmitClaimResponse = ClaimResponse;
@@ -15,7 +15,7 @@ export interface ZambdaCreateParams {
15
15
  /**
16
16
  * The runtime to use for the Zambda Function.
17
17
  */
18
- runtime: 'nodejs20.x' | 'nodejs22.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
18
+ runtime: 'nodejs20.x' | 'nodejs22.x' | 'nodejs24.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
19
19
  /**
20
20
  * The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
21
21
  */
@@ -16,4 +16,10 @@ export interface ZambdaExecuteResult {
16
16
  | string
17
17
  | number
18
18
  | null;
19
+ /**
20
+ * Optional HTTP headers returned by the Zambda Function
21
+ */
22
+ headers?: {
23
+ [k: string]: any;
24
+ };
19
25
  }
@@ -15,7 +15,7 @@ export interface ZambdaUpdateParams {
15
15
  /**
16
16
  * The runtime to use for the Zambda Function.
17
17
  */
18
- runtime?: 'nodejs20.x' | 'nodejs22.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
18
+ runtime?: 'nodejs20.x' | 'nodejs22.x' | 'nodejs24.x' | 'python3.13' | 'python3.12' | 'java21' | 'dotnet8' | 'ruby3.3';
19
19
  /**
20
20
  * The amount of memory in MB to allocate to the Zambda Function. If not specified, a system default (1024MB) will be used. Min: 128MB, Max: 10240MB.
21
21
  */
@@ -34,12 +34,25 @@ export type Bundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
34
34
  entry?: Array<BundleEntry<F>> | undefined;
35
35
  unbundle: (this: { entry?: Array<BundleEntry<F>> }) => F[];
36
36
  };
37
+ export type BatchBundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
38
+ entry?: Array<BundleEntry<F>> | undefined;
39
+ unbundle: (this: { entry?: Array<BundleEntry<F>> }) => F[];
40
+ errors: (this: { entry?: Array<BundleEntry<F>> }) => OperationOutcome[] | undefined;
41
+ };
42
+ export type TransactionBundle<F extends FhirResource> = EntrylessFhirBundle<F> & {
43
+ entry?: Array<BundleEntry<F>> | undefined;
44
+ unbundle: (this: { entry?: Array<BundleEntry<F>> }) => F[];
45
+ };
37
46
  export type BundleEntry<F extends FhirResource> = F extends FhirResourceR4B ? BundleEntryR4B<F> : BundleEntryR5<F>;
38
47
  export type Binary<F extends FhirResource> = F extends FhirResourceR4B ? BinaryR4B : BinaryR5;
39
48
  export type OperationOutcome = OperationOutcomeR4B | OperationOutcomeR5;
40
49
 
41
50
  export type SearchParam = { name: string; value: string | number };
42
51
 
52
+ export type FhirResourceReturnValue<T extends FhirResource> = T extends { id?: string | undefined }
53
+ ? Omit<T, 'id'> & { id: string }
54
+ : T;
55
+
43
56
  export interface FhirSearchParams<T extends FhirResource> {
44
57
  resourceType: T['resourceType'];
45
58
  params?: SearchParam[];