@oystehr/sdk 3.0.5 → 3.0.7
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 +24 -8
- package/dist/cjs/client/client.d.ts +1 -1
- package/dist/cjs/config.d.ts +5 -0
- package/dist/cjs/errors/index.d.ts +4 -1
- package/dist/cjs/index.cjs +255 -92
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/application.d.ts +1 -0
- package/dist/cjs/resources/classes/charge.d.ts +1 -0
- package/dist/cjs/resources/classes/conversation.d.ts +1 -0
- package/dist/cjs/resources/classes/developer.d.ts +1 -0
- package/dist/cjs/resources/classes/erx.d.ts +10 -1
- package/dist/cjs/resources/classes/fax.d.ts +31 -0
- package/dist/cjs/resources/classes/fhir.d.ts +1 -0
- package/dist/cjs/resources/classes/index.d.ts +2 -0
- package/dist/cjs/resources/classes/m2m.d.ts +1 -0
- package/dist/cjs/resources/classes/messaging.d.ts +1 -0
- package/dist/cjs/resources/classes/paymentMethod.d.ts +1 -0
- package/dist/cjs/resources/classes/project.d.ts +1 -0
- package/dist/cjs/resources/classes/rcm.d.ts +2 -1
- package/dist/cjs/resources/classes/role.d.ts +1 -0
- package/dist/cjs/resources/classes/secret.d.ts +1 -0
- package/dist/cjs/resources/classes/telemed.d.ts +1 -0
- package/dist/cjs/resources/classes/transactionalSMS.d.ts +1 -0
- package/dist/cjs/resources/classes/user.d.ts +1 -0
- package/dist/cjs/resources/classes/version.d.ts +1 -0
- package/dist/cjs/resources/classes/z3.d.ts +1 -0
- package/dist/cjs/resources/classes/zambda.d.ts +1 -0
- package/dist/cjs/resources/classes/zambdaLogStream.d.ts +1 -0
- package/dist/cjs/resources/types/DeveloperInviteResponse.d.ts +0 -4
- package/dist/cjs/resources/types/ErxCancelOrderParams.d.ts +6 -0
- package/dist/cjs/resources/types/ErxCancelOrderResponse.d.ts +6 -0
- package/dist/cjs/resources/types/ErxCancelPrescriptionParams.d.ts +6 -0
- package/dist/cjs/resources/types/ErxCancelPrescriptionResponse.d.ts +6 -0
- package/dist/cjs/resources/types/FaxSendParams.d.ts +18 -0
- package/dist/cjs/resources/types/FaxSendResponse.d.ts +10 -0
- package/dist/cjs/resources/types/index.d.ts +6 -0
- package/dist/cjs/tests/setup/constants.d.ts +2 -6
- package/dist/cjs/tests/setup/global.d.ts +1 -0
- package/dist/esm/client/client.d.ts +1 -1
- package/dist/esm/client/client.js +4 -4
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/config.d.ts +5 -0
- package/dist/esm/errors/index.d.ts +4 -1
- package/dist/esm/errors/index.js +18 -2
- package/dist/esm/errors/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/application.d.ts +1 -0
- package/dist/esm/resources/classes/application.js +12 -8
- package/dist/esm/resources/classes/application.js.map +1 -1
- package/dist/esm/resources/classes/charge.d.ts +1 -0
- package/dist/esm/resources/classes/charge.js +6 -2
- package/dist/esm/resources/classes/charge.js.map +1 -1
- package/dist/esm/resources/classes/conversation.d.ts +1 -0
- package/dist/esm/resources/classes/conversation.js +9 -5
- package/dist/esm/resources/classes/conversation.js.map +1 -1
- package/dist/esm/resources/classes/developer.d.ts +1 -0
- package/dist/esm/resources/classes/developer.js +10 -6
- package/dist/esm/resources/classes/developer.js.map +1 -1
- package/dist/esm/resources/classes/erx.d.ts +10 -1
- package/dist/esm/resources/classes/erx.js +20 -4
- package/dist/esm/resources/classes/erx.js.map +1 -1
- package/dist/esm/resources/classes/fax.d.ts +31 -0
- package/dist/esm/resources/classes/fax.js +45 -0
- package/dist/esm/resources/classes/fax.js.map +1 -0
- package/dist/esm/resources/classes/fhir.d.ts +1 -0
- package/dist/esm/resources/classes/fhir.js +4 -0
- package/dist/esm/resources/classes/fhir.js.map +1 -1
- package/dist/esm/resources/classes/index.d.ts +2 -0
- package/dist/esm/resources/classes/index.js +7 -0
- package/dist/esm/resources/classes/index.js.map +1 -1
- package/dist/esm/resources/classes/m2m.d.ts +1 -0
- package/dist/esm/resources/classes/m2m.js +11 -7
- package/dist/esm/resources/classes/m2m.js.map +1 -1
- package/dist/esm/resources/classes/messaging.d.ts +1 -0
- package/dist/esm/resources/classes/messaging.js +5 -1
- package/dist/esm/resources/classes/messaging.js.map +1 -1
- package/dist/esm/resources/classes/paymentMethod.d.ts +1 -0
- package/dist/esm/resources/classes/paymentMethod.js +8 -4
- package/dist/esm/resources/classes/paymentMethod.js.map +1 -1
- package/dist/esm/resources/classes/project.d.ts +1 -0
- package/dist/esm/resources/classes/project.js +6 -2
- package/dist/esm/resources/classes/project.js.map +1 -1
- package/dist/esm/resources/classes/rcm.d.ts +2 -1
- package/dist/esm/resources/classes/rcm.js +8 -4
- package/dist/esm/resources/classes/rcm.js.map +1 -1
- package/dist/esm/resources/classes/role.d.ts +1 -0
- package/dist/esm/resources/classes/role.js +9 -5
- package/dist/esm/resources/classes/role.js.map +1 -1
- package/dist/esm/resources/classes/secret.d.ts +1 -0
- package/dist/esm/resources/classes/secret.js +8 -4
- package/dist/esm/resources/classes/secret.js.map +1 -1
- package/dist/esm/resources/classes/telemed.d.ts +1 -0
- package/dist/esm/resources/classes/telemed.js +6 -2
- package/dist/esm/resources/classes/telemed.js.map +1 -1
- package/dist/esm/resources/classes/transactionalSMS.d.ts +1 -0
- package/dist/esm/resources/classes/transactionalSMS.js +5 -1
- package/dist/esm/resources/classes/transactionalSMS.js.map +1 -1
- package/dist/esm/resources/classes/user.d.ts +1 -0
- package/dist/esm/resources/classes/user.js +11 -7
- package/dist/esm/resources/classes/user.js.map +1 -1
- package/dist/esm/resources/classes/version.d.ts +1 -0
- package/dist/esm/resources/classes/version.js +5 -1
- package/dist/esm/resources/classes/version.js.map +1 -1
- package/dist/esm/resources/classes/z3-ext.js +9 -5
- package/dist/esm/resources/classes/z3-ext.js.map +1 -1
- package/dist/esm/resources/classes/z3.d.ts +1 -0
- package/dist/esm/resources/classes/z3.js +10 -6
- package/dist/esm/resources/classes/z3.js.map +1 -1
- package/dist/esm/resources/classes/zambda-ext.js +5 -1
- package/dist/esm/resources/classes/zambda-ext.js.map +1 -1
- package/dist/esm/resources/classes/zambda.d.ts +1 -0
- package/dist/esm/resources/classes/zambda.js +12 -8
- package/dist/esm/resources/classes/zambda.js.map +1 -1
- package/dist/esm/resources/classes/zambdaLogStream.d.ts +1 -0
- package/dist/esm/resources/classes/zambdaLogStream.js +7 -3
- package/dist/esm/resources/classes/zambdaLogStream.js.map +1 -1
- package/dist/esm/resources/types/DeveloperInviteResponse.d.ts +0 -4
- package/dist/esm/resources/types/ErxCancelOrderParams.d.ts +6 -0
- package/dist/esm/resources/types/ErxCancelOrderResponse.d.ts +6 -0
- package/dist/esm/resources/types/ErxCancelPrescriptionParams.d.ts +6 -0
- package/dist/esm/resources/types/ErxCancelPrescriptionResponse.d.ts +6 -0
- package/dist/esm/resources/types/FaxSendParams.d.ts +18 -0
- package/dist/esm/resources/types/FaxSendResponse.d.ts +10 -0
- package/dist/esm/resources/types/index.d.ts +6 -0
- package/dist/esm/tests/setup/constants.d.ts +2 -6
- package/dist/esm/tests/setup/global.d.ts +1 -0
- package/package.json +4 -4
- package/src/client/client.ts +6 -6
- package/src/config.ts +5 -0
- package/src/errors/index.ts +18 -2
- package/src/resources/classes/application.ts +15 -8
- package/src/resources/classes/charge.ts +5 -2
- package/src/resources/classes/conversation.ts +20 -5
- package/src/resources/classes/developer.ts +9 -6
- package/src/resources/classes/erx.ts +26 -4
- package/src/resources/classes/fax.ts +44 -0
- package/src/resources/classes/fhir.ts +3 -0
- package/src/resources/classes/index.ts +6 -0
- package/src/resources/classes/m2m.ts +10 -7
- package/src/resources/classes/messaging.ts +4 -1
- package/src/resources/classes/paymentMethod.ts +7 -4
- package/src/resources/classes/project.ts +5 -2
- package/src/resources/classes/rcm.ts +7 -4
- package/src/resources/classes/role.ts +8 -5
- package/src/resources/classes/secret.ts +7 -4
- package/src/resources/classes/telemed.ts +5 -2
- package/src/resources/classes/transactionalSMS.ts +4 -1
- package/src/resources/classes/user.ts +10 -7
- package/src/resources/classes/version.ts +4 -1
- package/src/resources/classes/z3-ext.ts +10 -4
- package/src/resources/classes/z3.ts +9 -6
- package/src/resources/classes/zambda-ext.ts +5 -1
- package/src/resources/classes/zambda.ts +11 -8
- package/src/resources/classes/zambdaLogStream.ts +10 -3
- package/src/resources/types/DeveloperInviteResponse.ts +0 -4
- package/src/resources/types/ErxCancelOrderParams.ts +8 -0
- package/src/resources/types/ErxCancelOrderResponse.ts +8 -0
- package/src/resources/types/ErxCancelPrescriptionParams.ts +8 -0
- package/src/resources/types/ErxCancelPrescriptionResponse.ts +8 -0
- package/src/resources/types/FaxSendParams.ts +20 -0
- package/src/resources/types/FaxSendResponse.ts +12 -0
- package/src/resources/types/index.ts +6 -0
- /package/dist/cjs/tests/{common.d.ts → integrational/common.d.ts} +0 -0
- /package/dist/esm/tests/{common.d.ts → integrational/common.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ npm install @oystehr/sdk
|
|
|
46
46
|
## Usage
|
|
47
47
|
|
|
48
48
|
1. Import the SDK.
|
|
49
|
-
2. Initialize the SDK with
|
|
49
|
+
2. Initialize the SDK with an Oystehr access token. ([Learn how to get an access token](https://docs.oystehr.com/core-documentation/authenticating-api-requests)).
|
|
50
50
|
3. Invoke any of Oystehr's APIs with a function call.
|
|
51
51
|
|
|
52
52
|
```typescript filename="Example of using the SDK"
|
|
@@ -118,7 +118,7 @@ interface OystehrConfig {
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
## Features
|
|
121
|
+
## SDK Features
|
|
122
122
|
|
|
123
123
|
### Unauthenticated Usage
|
|
124
124
|
|
|
@@ -151,8 +151,6 @@ Note that the Oystehr FHIR API is eventually consistent, so if you are retrievin
|
|
|
151
151
|
|
|
152
152
|
To retry on additional status codes, change the number of retries, or register a callback for each retry, pass options to the Oystehr SDK configuration object as shown above.
|
|
153
153
|
|
|
154
|
-
## Types
|
|
155
|
-
|
|
156
154
|
### Oystehr Types
|
|
157
155
|
|
|
158
156
|
The SDK includes input and output types for all non-FHIR Oystehr services, as well as some reusable "component" types. These types provide a single interface for inputs — no need to worry about whether a value goes into a path parameters or the request body.
|
|
@@ -164,7 +162,7 @@ import Oystehr, { UserInviteParams, UserInviteResponse } from '@oystehr/sdk';
|
|
|
164
162
|
const APP_ID = process.env.OYSTEHR_APP_ID;
|
|
165
163
|
|
|
166
164
|
// Elsewhere in your project, initialize an Oystehr client
|
|
167
|
-
// with the currently-authenticated user's access token
|
|
165
|
+
// with the currently-authenticated user's access token
|
|
168
166
|
const oystehr = new Oystehr({ accessToken: accessTokenFromAuthn });
|
|
169
167
|
|
|
170
168
|
// Define a reusable helper function to add practitioners
|
|
@@ -181,8 +179,6 @@ async function inviteUserToMyApp(
|
|
|
181
179
|
}
|
|
182
180
|
```
|
|
183
181
|
|
|
184
|
-
## FHIR
|
|
185
|
-
|
|
186
182
|
### FHIR Types
|
|
187
183
|
|
|
188
184
|
The SDK supports both the R4B and R5 versions of FHIR from one shared set of generic functions. You shouldn't need to mix these types, since each Oystehr project can only have one FHIR version, but the example below shows how the SDK handles types for each version.
|
|
@@ -267,6 +263,27 @@ const getAppointments: BatchInputGetRequest = {
|
|
|
267
263
|
await oystehr.fhir.transaction({ requests: [patchAppointment, getAppointments ]});
|
|
268
264
|
```
|
|
269
265
|
|
|
266
|
+
### FHIR Search and Batch Types
|
|
267
|
+
|
|
268
|
+
When writing complex search and batch requests, you may end up with requests that return more than one type of FHIR Resource. To handle this, the Oystehr FHIR SDK supports generic types on all functions. Use type inference and [type predicates](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) to pull out individual collections of resources and ensure they have the correct type.
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import Oystehr from '@oystehr/sdk';
|
|
272
|
+
import { Encounter, Location } from 'fhir/r4b';
|
|
273
|
+
|
|
274
|
+
const bundle/*: Bundle<Encounter | Location>*/ = await oystehr.fhir.search<Encounter | Location>({
|
|
275
|
+
resourceType: 'Encounter',
|
|
276
|
+
params: [{
|
|
277
|
+
name: '_include',
|
|
278
|
+
value: 'Encounter.location',
|
|
279
|
+
}],
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const results/*: (Encounter | Location)[]*/ = bundle.unbundle();
|
|
283
|
+
const encounters/*: Encounter[]*/ = results.filter((res): res is Encounter => res.resourceType === 'Encounter');
|
|
284
|
+
const locations/*: Location[]*/ = results.filter((res): res is Location => res.resourceType === 'Location');
|
|
285
|
+
```
|
|
286
|
+
|
|
270
287
|
### Optimistic Locking
|
|
271
288
|
|
|
272
289
|
The Oystehr FHIR API and SDK supports [FHIR's optimistic locking specification](https://build.fhir.org/http.html#concurrency). To use optimistic locking, pass a valid [FHIR version ID](https://build.fhir.org/resource.html#metadata) to the request object on your SDK function call.
|
|
@@ -336,4 +353,3 @@ If you have questions about migrating to a new version of the Oystehr SDK, check
|
|
|
336
353
|
## Contact
|
|
337
354
|
|
|
338
355
|
Questions? Join our [public Slack](https://join.slack.com/t/oystehr/shared_invite/zt-1se6hw93b-olDYmAzDGDhU5ibnEugCmA) or contact [support](mailto:support@oystehr.com).
|
|
339
|
-
|
|
@@ -32,7 +32,7 @@ export type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;
|
|
|
32
32
|
export declare class SDKResource {
|
|
33
33
|
protected readonly config: OystehrConfig;
|
|
34
34
|
constructor(config: OystehrConfig);
|
|
35
|
-
protected request(path: string, method: string): FetcherFunction;
|
|
35
|
+
protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction;
|
|
36
36
|
protected fhirRequest<T extends FhirResource = any>(path: string, method: string): (params: any, request?: InternalClientRequest) => Promise<FhirFetcherResponse<T>>;
|
|
37
37
|
}
|
|
38
38
|
export type FetcherError = {
|
package/dist/cjs/config.d.ts
CHANGED
|
@@ -12,6 +12,11 @@ export interface OystehrConfig {
|
|
|
12
12
|
projectId?: string;
|
|
13
13
|
fhirApiUrl?: string;
|
|
14
14
|
projectApiUrl?: string;
|
|
15
|
+
services?: {
|
|
16
|
+
faxApiUrl?: string;
|
|
17
|
+
fhirApiUrl?: string;
|
|
18
|
+
projectApiUrl?: string;
|
|
19
|
+
};
|
|
15
20
|
/**
|
|
16
21
|
* Optionally provide a custom fetch implementation. This must conform to the
|
|
17
22
|
* built-in node.js fetch implementation (undici fetch).
|
|
@@ -2,11 +2,13 @@ import { OperationOutcome as OperationOutcomeR4B } from 'fhir/r4b';
|
|
|
2
2
|
import { OperationOutcome as OperationOutcomeR5 } from 'fhir/r5';
|
|
3
3
|
export declare class OystehrSdkError extends Error {
|
|
4
4
|
code: number;
|
|
5
|
-
constructor({ message, code }: {
|
|
5
|
+
constructor({ message, code, cause }: {
|
|
6
6
|
message: string;
|
|
7
7
|
code: number;
|
|
8
|
+
cause?: unknown;
|
|
8
9
|
});
|
|
9
10
|
toString(): string;
|
|
11
|
+
toJSON(): any;
|
|
10
12
|
}
|
|
11
13
|
export declare class OystehrFHIRError extends OystehrSdkError {
|
|
12
14
|
cause: OperationOutcomeR4B | OperationOutcomeR5;
|
|
@@ -14,4 +16,5 @@ export declare class OystehrFHIRError extends OystehrSdkError {
|
|
|
14
16
|
error: OperationOutcomeR4B | OperationOutcomeR5;
|
|
15
17
|
code: number;
|
|
16
18
|
});
|
|
19
|
+
toJSON(): any;
|
|
17
20
|
}
|