candidhealth 0.1.0 → 0.1.1

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.
@@ -0,0 +1,14 @@
1
+ import * as environments from "./environments";
2
+ import { CandidApiClient as GeneratedCandidApiClient } from "./Client";
3
+ export declare namespace CandidApiClient {
4
+ interface Options {
5
+ environment?: environments.CandidApiEnvironment;
6
+ token?: string;
7
+ clientId?: string;
8
+ clientSecret?: string;
9
+ }
10
+ }
11
+ export declare class CandidApiClient extends GeneratedCandidApiClient {
12
+ constructor(options: CandidApiClient.Options);
13
+ private static createToken;
14
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CandidApiClient = void 0;
4
+ const Client_1 = require("./Client");
5
+ class CandidApiClient extends Client_1.CandidApiClient {
6
+ constructor(options) {
7
+ super({
8
+ environment: options.environment,
9
+ token: CandidApiClient.createToken(options),
10
+ });
11
+ }
12
+ static async createToken(options) {
13
+ if (options.token != null)
14
+ return options.token;
15
+ if (options.clientId == null || options.clientSecret == null)
16
+ throw Error("Must provide a token or client id and client secret to authenticate to the Candid API");
17
+ const noAuthRequiredClient = new Client_1.CandidApiClient({ environment: options.environment, token: undefined });
18
+ const tokenResponse = await noAuthRequiredClient.auth.v2.getToken({
19
+ clientId: options.clientId,
20
+ clientSecret: options.clientSecret,
21
+ });
22
+ if (tokenResponse.ok) {
23
+ return tokenResponse.body.accessToken;
24
+ }
25
+ else {
26
+ throw Error("Could not get token");
27
+ }
28
+ }
29
+ }
30
+ exports.CandidApiClient = CandidApiClient;
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ ## candid-node: A [Candid Health](https://joincandidhealth.com) TypeScript client
2
+
3
+ [![npm](https://img.shields.io/npm/v/candidhealth)](https://www.npmjs.com/package/candidhealth)
4
+
5
+ ### Installation
6
+
7
+ ```bash
8
+ yarn add candidhealth # or npm install, pnpm i, etc.
9
+ ```
@@ -48,7 +48,7 @@ class V2 {
48
48
  Authorization: await this._getAuthorizationHeader(),
49
49
  "X-Fern-Language": "JavaScript",
50
50
  "X-Fern-SDK-Name": "candidhealth",
51
- "X-Fern-SDK-Version": "0.1.0",
51
+ "X-Fern-SDK-Version": "0.1.1",
52
52
  },
53
53
  contentType: "application/json",
54
54
  body: await serializers.auth.v2.AuthGetTokenRequest.jsonOrThrow(request, {
@@ -48,7 +48,7 @@ class BillingNotes {
48
48
  Authorization: await this._getAuthorizationHeader(),
49
49
  "X-Fern-Language": "JavaScript",
50
50
  "X-Fern-SDK-Name": "candidhealth",
51
- "X-Fern-SDK-Version": "0.1.0",
51
+ "X-Fern-SDK-Version": "0.1.1",
52
52
  },
53
53
  contentType: "application/json",
54
54
  body: await serializers.StandaloneBillingNoteCreate.jsonOrThrow(request, {
@@ -97,7 +97,7 @@ class V4 {
97
97
  Authorization: await this._getAuthorizationHeader(),
98
98
  "X-Fern-Language": "JavaScript",
99
99
  "X-Fern-SDK-Name": "candidhealth",
100
- "X-Fern-SDK-Version": "0.1.0",
100
+ "X-Fern-SDK-Version": "0.1.1",
101
101
  },
102
102
  contentType: "application/json",
103
103
  queryParameters: _queryParams,
@@ -127,7 +127,7 @@ class V4 {
127
127
  Authorization: await this._getAuthorizationHeader(),
128
128
  "X-Fern-Language": "JavaScript",
129
129
  "X-Fern-SDK-Name": "candidhealth",
130
- "X-Fern-SDK-Version": "0.1.0",
130
+ "X-Fern-SDK-Version": "0.1.1",
131
131
  },
132
132
  contentType: "application/json",
133
133
  timeoutMs: 60000,
@@ -156,7 +156,7 @@ class V4 {
156
156
  Authorization: await this._getAuthorizationHeader(),
157
157
  "X-Fern-Language": "JavaScript",
158
158
  "X-Fern-SDK-Name": "candidhealth",
159
- "X-Fern-SDK-Version": "0.1.0",
159
+ "X-Fern-SDK-Version": "0.1.1",
160
160
  },
161
161
  contentType: "application/json",
162
162
  body: await serializers.encounters.v4.EncounterCreate.jsonOrThrow(request, {
@@ -188,7 +188,7 @@ class V4 {
188
188
  Authorization: await this._getAuthorizationHeader(),
189
189
  "X-Fern-Language": "JavaScript",
190
190
  "X-Fern-SDK-Name": "candidhealth",
191
- "X-Fern-SDK-Version": "0.1.0",
191
+ "X-Fern-SDK-Version": "0.1.1",
192
192
  },
193
193
  contentType: "application/json",
194
194
  body: await serializers.encounters.v4.EncounterUpdate.jsonOrThrow(request, {
@@ -220,7 +220,7 @@ class V4 {
220
220
  Authorization: await this._getAuthorizationHeader(),
221
221
  "X-Fern-Language": "JavaScript",
222
222
  "X-Fern-SDK-Name": "candidhealth",
223
- "X-Fern-SDK-Version": "0.1.0",
223
+ "X-Fern-SDK-Version": "0.1.1",
224
224
  },
225
225
  contentType: "application/json",
226
226
  timeoutMs: 60000,
@@ -249,7 +249,7 @@ class V4 {
249
249
  Authorization: await this._getAuthorizationHeader(),
250
250
  "X-Fern-Language": "JavaScript",
251
251
  "X-Fern-SDK-Name": "candidhealth",
252
- "X-Fern-SDK-Version": "0.1.0",
252
+ "X-Fern-SDK-Version": "0.1.1",
253
253
  },
254
254
  contentType: "application/json",
255
255
  timeoutMs: 60000,
@@ -281,7 +281,7 @@ class V4 {
281
281
  Authorization: await this._getAuthorizationHeader(),
282
282
  "X-Fern-Language": "JavaScript",
283
283
  "X-Fern-SDK-Name": "candidhealth",
284
- "X-Fern-SDK-Version": "0.1.0",
284
+ "X-Fern-SDK-Version": "0.1.1",
285
285
  },
286
286
  contentType: "application/json",
287
287
  timeoutMs: 60000,
@@ -310,7 +310,7 @@ class V4 {
310
310
  Authorization: await this._getAuthorizationHeader(),
311
311
  "X-Fern-Language": "JavaScript",
312
312
  "X-Fern-SDK-Name": "candidhealth",
313
- "X-Fern-SDK-Version": "0.1.0",
313
+ "X-Fern-SDK-Version": "0.1.1",
314
314
  },
315
315
  contentType: "application/json",
316
316
  timeoutMs: 60000,
@@ -48,7 +48,7 @@ class ExpectedNetworkStatus {
48
48
  Authorization: await this._getAuthorizationHeader(),
49
49
  "X-Fern-Language": "JavaScript",
50
50
  "X-Fern-SDK-Name": "candidhealth",
51
- "X-Fern-SDK-Version": "0.1.0",
51
+ "X-Fern-SDK-Version": "0.1.1",
52
52
  },
53
53
  contentType: "application/json",
54
54
  body: await serializers.ExpectedNetworkStatusRequest.jsonOrThrow(request, {
@@ -49,7 +49,7 @@ class Payers {
49
49
  Authorization: await this._getAuthorizationHeader(),
50
50
  "X-Fern-Language": "JavaScript",
51
51
  "X-Fern-SDK-Name": "candidhealth",
52
- "X-Fern-SDK-Version": "0.1.0",
52
+ "X-Fern-SDK-Version": "0.1.1",
53
53
  },
54
54
  contentType: "application/json",
55
55
  timeoutMs: 60000,
@@ -89,7 +89,7 @@ class Payers {
89
89
  Authorization: await this._getAuthorizationHeader(),
90
90
  "X-Fern-Language": "JavaScript",
91
91
  "X-Fern-SDK-Name": "candidhealth",
92
- "X-Fern-SDK-Version": "0.1.0",
92
+ "X-Fern-SDK-Version": "0.1.1",
93
93
  },
94
94
  contentType: "application/json",
95
95
  queryParameters: _queryParams,
@@ -0,0 +1,14 @@
1
+ import * as environments from "./environments";
2
+ import { CandidApiClient as GeneratedCandidApiClient } from "./Client";
3
+ export declare namespace CandidApiClient {
4
+ interface Options {
5
+ environment?: environments.CandidApiEnvironment;
6
+ token?: string;
7
+ clientId?: string;
8
+ clientSecret?: string;
9
+ }
10
+ }
11
+ export declare class CandidApiClient extends GeneratedCandidApiClient {
12
+ constructor(options: CandidApiClient.Options);
13
+ private static createToken;
14
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CandidApiClient = void 0;
4
+ const Client_1 = require("./Client");
5
+ class CandidApiClient extends Client_1.CandidApiClient {
6
+ constructor(options) {
7
+ super({
8
+ environment: options.environment,
9
+ token: CandidApiClient.createToken(options),
10
+ });
11
+ }
12
+ static async createToken(options) {
13
+ if (options.token != null)
14
+ return options.token;
15
+ if (options.clientId == null || options.clientSecret == null)
16
+ throw Error("Must provide a token or client id and client secret to authenticate to the Candid API");
17
+ const noAuthRequiredClient = new Client_1.CandidApiClient({ environment: options.environment, token: undefined });
18
+ const tokenResponse = await noAuthRequiredClient.auth.v2.getToken({
19
+ clientId: options.clientId,
20
+ clientSecret: options.clientSecret,
21
+ });
22
+ if (tokenResponse.ok) {
23
+ return tokenResponse.body.accessToken;
24
+ }
25
+ else {
26
+ throw Error("Could not get token");
27
+ }
28
+ }
29
+ }
30
+ exports.CandidApiClient = CandidApiClient;
@@ -48,7 +48,7 @@ class V2 {
48
48
  Authorization: await this._getAuthorizationHeader(),
49
49
  "X-Fern-Language": "JavaScript",
50
50
  "X-Fern-SDK-Name": "candidhealth",
51
- "X-Fern-SDK-Version": "0.1.0",
51
+ "X-Fern-SDK-Version": "0.1.1",
52
52
  },
53
53
  contentType: "application/json",
54
54
  body: await serializers.auth.v2.AuthGetTokenRequest.jsonOrThrow(request, {
@@ -48,7 +48,7 @@ class BillingNotes {
48
48
  Authorization: await this._getAuthorizationHeader(),
49
49
  "X-Fern-Language": "JavaScript",
50
50
  "X-Fern-SDK-Name": "candidhealth",
51
- "X-Fern-SDK-Version": "0.1.0",
51
+ "X-Fern-SDK-Version": "0.1.1",
52
52
  },
53
53
  contentType: "application/json",
54
54
  body: await serializers.StandaloneBillingNoteCreate.jsonOrThrow(request, {
@@ -97,7 +97,7 @@ class V4 {
97
97
  Authorization: await this._getAuthorizationHeader(),
98
98
  "X-Fern-Language": "JavaScript",
99
99
  "X-Fern-SDK-Name": "candidhealth",
100
- "X-Fern-SDK-Version": "0.1.0",
100
+ "X-Fern-SDK-Version": "0.1.1",
101
101
  },
102
102
  contentType: "application/json",
103
103
  queryParameters: _queryParams,
@@ -127,7 +127,7 @@ class V4 {
127
127
  Authorization: await this._getAuthorizationHeader(),
128
128
  "X-Fern-Language": "JavaScript",
129
129
  "X-Fern-SDK-Name": "candidhealth",
130
- "X-Fern-SDK-Version": "0.1.0",
130
+ "X-Fern-SDK-Version": "0.1.1",
131
131
  },
132
132
  contentType: "application/json",
133
133
  timeoutMs: 60000,
@@ -156,7 +156,7 @@ class V4 {
156
156
  Authorization: await this._getAuthorizationHeader(),
157
157
  "X-Fern-Language": "JavaScript",
158
158
  "X-Fern-SDK-Name": "candidhealth",
159
- "X-Fern-SDK-Version": "0.1.0",
159
+ "X-Fern-SDK-Version": "0.1.1",
160
160
  },
161
161
  contentType: "application/json",
162
162
  body: await serializers.encounters.v4.EncounterCreate.jsonOrThrow(request, {
@@ -188,7 +188,7 @@ class V4 {
188
188
  Authorization: await this._getAuthorizationHeader(),
189
189
  "X-Fern-Language": "JavaScript",
190
190
  "X-Fern-SDK-Name": "candidhealth",
191
- "X-Fern-SDK-Version": "0.1.0",
191
+ "X-Fern-SDK-Version": "0.1.1",
192
192
  },
193
193
  contentType: "application/json",
194
194
  body: await serializers.encounters.v4.EncounterUpdate.jsonOrThrow(request, {
@@ -220,7 +220,7 @@ class V4 {
220
220
  Authorization: await this._getAuthorizationHeader(),
221
221
  "X-Fern-Language": "JavaScript",
222
222
  "X-Fern-SDK-Name": "candidhealth",
223
- "X-Fern-SDK-Version": "0.1.0",
223
+ "X-Fern-SDK-Version": "0.1.1",
224
224
  },
225
225
  contentType: "application/json",
226
226
  timeoutMs: 60000,
@@ -249,7 +249,7 @@ class V4 {
249
249
  Authorization: await this._getAuthorizationHeader(),
250
250
  "X-Fern-Language": "JavaScript",
251
251
  "X-Fern-SDK-Name": "candidhealth",
252
- "X-Fern-SDK-Version": "0.1.0",
252
+ "X-Fern-SDK-Version": "0.1.1",
253
253
  },
254
254
  contentType: "application/json",
255
255
  timeoutMs: 60000,
@@ -281,7 +281,7 @@ class V4 {
281
281
  Authorization: await this._getAuthorizationHeader(),
282
282
  "X-Fern-Language": "JavaScript",
283
283
  "X-Fern-SDK-Name": "candidhealth",
284
- "X-Fern-SDK-Version": "0.1.0",
284
+ "X-Fern-SDK-Version": "0.1.1",
285
285
  },
286
286
  contentType: "application/json",
287
287
  timeoutMs: 60000,
@@ -310,7 +310,7 @@ class V4 {
310
310
  Authorization: await this._getAuthorizationHeader(),
311
311
  "X-Fern-Language": "JavaScript",
312
312
  "X-Fern-SDK-Name": "candidhealth",
313
- "X-Fern-SDK-Version": "0.1.0",
313
+ "X-Fern-SDK-Version": "0.1.1",
314
314
  },
315
315
  contentType: "application/json",
316
316
  timeoutMs: 60000,
@@ -48,7 +48,7 @@ class ExpectedNetworkStatus {
48
48
  Authorization: await this._getAuthorizationHeader(),
49
49
  "X-Fern-Language": "JavaScript",
50
50
  "X-Fern-SDK-Name": "candidhealth",
51
- "X-Fern-SDK-Version": "0.1.0",
51
+ "X-Fern-SDK-Version": "0.1.1",
52
52
  },
53
53
  contentType: "application/json",
54
54
  body: await serializers.ExpectedNetworkStatusRequest.jsonOrThrow(request, {
@@ -49,7 +49,7 @@ class Payers {
49
49
  Authorization: await this._getAuthorizationHeader(),
50
50
  "X-Fern-Language": "JavaScript",
51
51
  "X-Fern-SDK-Name": "candidhealth",
52
- "X-Fern-SDK-Version": "0.1.0",
52
+ "X-Fern-SDK-Version": "0.1.1",
53
53
  },
54
54
  contentType: "application/json",
55
55
  timeoutMs: 60000,
@@ -89,7 +89,7 @@ class Payers {
89
89
  Authorization: await this._getAuthorizationHeader(),
90
90
  "X-Fern-Language": "JavaScript",
91
91
  "X-Fern-SDK-Name": "candidhealth",
92
- "X-Fern-SDK-Version": "0.1.0",
92
+ "X-Fern-SDK-Version": "0.1.1",
93
93
  },
94
94
  contentType: "application/json",
95
95
  queryParameters: _queryParams,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * as CandidApi from "./api";
2
- export { CandidApiClient } from "./Client";
2
+ export { CandidApiClient } from "./CandidApiClient";
3
3
  export { CandidApiEnvironment } from "./environments";
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.CandidApiEnvironment = exports.CandidApiClient = exports.CandidApi = void 0;
27
27
  exports.CandidApi = __importStar(require("./api"));
28
- var Client_1 = require("./Client");
29
- Object.defineProperty(exports, "CandidApiClient", { enumerable: true, get: function () { return Client_1.CandidApiClient; } });
28
+ var CandidApiClient_1 = require("./CandidApiClient");
29
+ Object.defineProperty(exports, "CandidApiClient", { enumerable: true, get: function () { return CandidApiClient_1.CandidApiClient; } });
30
30
  var environments_1 = require("./environments");
31
31
  Object.defineProperty(exports, "CandidApiEnvironment", { enumerable: true, get: function () { return environments_1.CandidApiEnvironment; } });
@@ -0,0 +1,85 @@
1
+ import { CandidApi } from "../src/index";
2
+ import { CandidApiClient } from "../src/CandidApiClient";
3
+ import { CandidApiEnvironment } from "../src/environments";
4
+
5
+ if (process.env.clientId == null || process.env.clientSecret == null) {
6
+ throw Error("Need a client ID and secret to use Candid API!");
7
+ }
8
+
9
+ const client = new CandidApiClient({
10
+ environment: CandidApiEnvironment.Staging,
11
+ clientId: process.env.clientId,
12
+ clientSecret: process.env.clientSecret,
13
+ });
14
+
15
+ const createEncounter = async () => {
16
+ // Create a new encounter for patient Loki Laufeyson
17
+ const createEncounterResponse = await client.encounters.v4.create({
18
+ externalId: CandidApi.EncounterExternalId("emr-claim-id-abc"),
19
+ dateOfService: CandidApi.Date_("2023-05-23"),
20
+ patient: {
21
+ externalId: "emr-patient-id-123",
22
+ firstName: "Loki",
23
+ lastName: "Laufeyson",
24
+ dateOfBirth: CandidApi.Date_("1983-12-17"),
25
+ gender: "male",
26
+ address: {
27
+ address1: "1234 Main St",
28
+ address2: "Apt 9876",
29
+ city: "Asgard",
30
+ state: "CA",
31
+ zipCode: "94109",
32
+ zipPlusFourCode: "1234",
33
+ },
34
+ },
35
+ patientAuthorizedRelease: true,
36
+ billingProvider: {
37
+ organizationName: "Acme Health PC",
38
+ npi: "1234567890",
39
+ taxId: "123456789",
40
+ address: {
41
+ address1: "1234 Main St",
42
+ address2: "Apt 9876",
43
+ city: "Asgard",
44
+ state: "CA",
45
+ zipCode: "94109",
46
+ zipPlusFourCode: "1234",
47
+ },
48
+ },
49
+ renderingProvider: {
50
+ firstName: "Doctor",
51
+ lastName: "Strange",
52
+ npi: "9876543210",
53
+ },
54
+ diagnoses: [
55
+ { codeType: "ABF", code: "Z63.88" },
56
+ { codeType: "ABF", code: "E66.66" },
57
+ ],
58
+ placeOfServiceCode: "02", // telemedicine
59
+ serviceLines: [
60
+ {
61
+ procedureCode: "99212",
62
+ modifiers: [],
63
+ quantity: "1",
64
+ units: "UN",
65
+ chargeAmountCents: 1500,
66
+ diagnosisPointers: [0, 1],
67
+ }
68
+ ],
69
+ clinicalNotes: [],
70
+ providerAcceptsAssignment: true,
71
+ benefitsAssignedToProvider: true,
72
+ });
73
+
74
+ // visit the new encounter
75
+ if (createEncounterResponse.ok) {
76
+ const { body: newEncounter } = createEncounterResponse;
77
+ console.log(newEncounter.encounterId);
78
+ } else {
79
+ // or handle errors
80
+ console.error(createEncounterResponse.error);
81
+ }
82
+
83
+ }
84
+
85
+ createEncounter();
package/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * as CandidApi from "./api";
2
- export { CandidApiClient } from "./Client";
2
+ export { CandidApiClient } from "./CandidApiClient";
3
3
  export { CandidApiEnvironment } from "./environments";
package/index.js CHANGED
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.CandidApiEnvironment = exports.CandidApiClient = exports.CandidApi = void 0;
27
27
  exports.CandidApi = __importStar(require("./api"));
28
- var Client_1 = require("./Client");
29
- Object.defineProperty(exports, "CandidApiClient", { enumerable: true, get: function () { return Client_1.CandidApiClient; } });
28
+ var CandidApiClient_1 = require("./CandidApiClient");
29
+ Object.defineProperty(exports, "CandidApiClient", { enumerable: true, get: function () { return CandidApiClient_1.CandidApiClient; } });
30
30
  var environments_1 = require("./environments");
31
31
  Object.defineProperty(exports, "CandidApiEnvironment", { enumerable: true, get: function () { return environments_1.CandidApiEnvironment; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "candidhealth",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "repository": "https://github.com/candidhealth/candid-node",
6
6
  "main": "./index.js",