@tryvital/vital-node 1.6.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,120 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import {
3
+ ClientFacingLabTest,
4
+ LabResultsMetadata,
5
+ LabResultsResponse,
6
+ Order,
7
+ OrderRequestResponse,
8
+ PatientAdress,
9
+ PatientDetails,
10
+ Physician,
11
+ } from './models/testkit_models';
12
+
13
+
14
+
15
+ export class OrdersApi {
16
+ baseURL: string;
17
+ client: AxiosInstance;
18
+ constructor(baseURL: string, axios: AxiosInstance) {
19
+ this.baseURL = baseURL;
20
+ this.client = axios;
21
+ }
22
+
23
+ // Create new order
24
+ public async create_order(
25
+ user_id: string,
26
+ patient_details: PatientDetails,
27
+ patient_address: PatientAdress,
28
+ lab_test_id: string,
29
+ physician?: Physician,
30
+ ): Promise<OrderRequestResponse> {
31
+ const resp = await this.client.post(
32
+ this.baseURL.concat('/order'),
33
+ {
34
+ params: {
35
+ user_id: user_id,
36
+ patient_details: patient_details,
37
+ patient_address: patient_address,
38
+ lab_test_id: lab_test_id,
39
+ physician: physician ? physician : null
40
+ },
41
+ }
42
+ );
43
+ return resp.data;
44
+ }
45
+
46
+ // Get order status.
47
+ public async getOrder(orderId: string): Promise<Order> {
48
+ const resp = await this.client.get(
49
+ this.baseURL.concat(`/order/${orderId}`)
50
+ );
51
+ return resp.data;
52
+ }
53
+
54
+ // Cancels order.
55
+ public async cancelOrder(orderId: string): Promise<OrderRequestResponse> {
56
+ const resp = await this.client.post(
57
+ this.baseURL.concat(`/order/${orderId}/cancel`)
58
+ );
59
+ return resp.data;
60
+ }
61
+ }
62
+
63
+ export class ResultsApi {
64
+ baseURL: string;
65
+ client: AxiosInstance;
66
+ constructor(baseURL: string, axios: AxiosInstance) {
67
+ this.baseURL = baseURL;
68
+ this.client = axios;
69
+ }
70
+ // GET both metadata and raw json test data.
71
+ public async getResults(orderId: string): Promise<LabResultsResponse> {
72
+ const resp = await this.client.get(
73
+ this.baseURL.concat(`/order/${orderId}/result`)
74
+ );
75
+ return resp.data;
76
+ }
77
+
78
+ // GET gets the lab result for the order in PDF format.
79
+ // TODO Check response type for PDF
80
+ public async getResultsPdf(orderId: string): Promise<string> {
81
+ const resp = await this.client.get(
82
+ this.baseURL.concat(`/order/${orderId}/result/pdf`)
83
+ );
84
+ return resp.data;
85
+ }
86
+
87
+ // GET metadata related to order results, such as
88
+ // lab metadata, provider and sample dates.
89
+ public async getResultsMetadata(orderId: string): Promise<LabResultsMetadata> {
90
+ const resp = await this.client.get(
91
+ this.baseURL.concat(`/order/${orderId}/result/metadata`)
92
+ );
93
+ return resp.data;
94
+ }
95
+ }
96
+
97
+
98
+
99
+
100
+
101
+ export class LabTestsApi {
102
+ baseURL: string;
103
+ client: AxiosInstance;
104
+ Orders: OrdersApi;
105
+ Results: ResultsApi;
106
+
107
+ constructor(baseURL: string, axios: AxiosInstance) {
108
+ this.baseURL = baseURL;
109
+ this.client = axios;
110
+ this.Orders = new OrdersApi(baseURL, axios)
111
+ this.Results = new ResultsApi(baseURL, axios)
112
+
113
+ }
114
+ public async getTests(): Promise<ClientFacingLabTest> {
115
+ const resp = await this.client.get(
116
+ this.baseURL.concat(`/lab_tests`)
117
+ );
118
+ return resp.data;
119
+ }
120
+ }
package/client/Link.ts CHANGED
@@ -34,7 +34,7 @@ export class LinkApi {
34
34
  default_params['filter_on_providers'] = filter_on_providers;
35
35
  }
36
36
  const resp = await this.client.post(
37
- this.baseURL.concat('/link/token/'),
37
+ this.baseURL.concat('/link/token'),
38
38
  default_params
39
39
  );
40
40
  return resp.data;
@@ -11,7 +11,7 @@ export class ProviderApi {
11
11
  }
12
12
 
13
13
  public async getSupportedProviders(): Promise<Provider[]> {
14
- const resp = await this.client.get(this.baseURL.concat('/providers/'));
14
+ const resp = await this.client.get(this.baseURL.concat('/providers'));
15
15
  return resp.data;
16
16
  }
17
17
  }
package/client/User.ts CHANGED
@@ -35,7 +35,7 @@ export class UserApi {
35
35
  limit = 100,
36
36
  offset = 0,
37
37
  }: GetTeamUsersParams = {}): Promise<GetTeamUsersResponse> {
38
- const url = new URL(this.baseURL.concat('/user/'));
38
+ const url = new URL(this.baseURL.concat('/user'));
39
39
 
40
40
  url.searchParams.set('limit', String(limit));
41
41
  url.searchParams.set('offset', String(offset));
package/client/index.ts CHANGED
@@ -5,7 +5,7 @@ export { SleepApi } from './Sleep';
5
5
  export { UserApi } from './User';
6
6
  export { WebhooksApi } from './Webhooks';
7
7
  export { WorkoutsApi } from './Workouts';
8
- export { TestkitsApi } from './Testkits';
8
+ export { LabTestsApi } from './LabTests';
9
9
  export { ProfileApi } from './Profile';
10
10
  export { DevicesAPI } from './Devices';
11
11
  export { MealsApi } from './Meals';
@@ -1,18 +1,33 @@
1
+ import internal = require("stream");
2
+ import { IntegrationKeyOut } from "svix";
3
+
1
4
  export interface PatientAdress {
2
5
  receiver_name: string;
3
- first_line: string;
4
- second_line?: string;
6
+ street: string;
5
7
  city: string;
6
8
  state: string;
7
9
  zip: string;
8
10
  country: string;
9
11
  phone_number: string;
12
+ street_number?: string;
10
13
  }
11
14
 
12
15
  export interface PatientDetails {
13
16
  dob: string;
14
17
  gender: string;
18
+ email: string;
19
+ }
20
+
21
+ export interface Physician {
22
+ first_name: string;
23
+ last_name: string;
24
+ npi: string;
25
+ email?: string;
26
+ licensed_states?: string[];
27
+ created_at?: string;
28
+ updated_at?: string;
15
29
  }
30
+
16
31
  export interface Marker {
17
32
  name: string;
18
33
  slug: string;
@@ -29,12 +44,30 @@ export interface Testkit {
29
44
  price: number;
30
45
  }
31
46
 
47
+ export interface TestkitEvent {
48
+ id: number;
49
+ created_at: string;
50
+ status: string;
51
+ }
52
+
53
+
54
+
32
55
  export interface Order {
56
+ user_id: string;
33
57
  id: string;
34
58
  team_id: string;
35
- created_on: Date;
36
- updated_on: Date;
37
- status:
59
+ patient_details: PatientDetails;
60
+ patient_address: PatientAdress;
61
+ lab_test: Testkit;
62
+ // TODO CHECK WHAT DETAILS IS
63
+ details: Object;
64
+ created_at: string;
65
+ updated_at: string;
66
+ events: TestkitEvent;
67
+ user_key?: string;
68
+ sample_id?: string;
69
+ notes?: string;
70
+ status?:
38
71
  | 'ordered'
39
72
  | 'transit_customer'
40
73
  | 'out_for_delivery'
@@ -50,20 +83,6 @@ export interface Order {
50
83
  | 'unknown'
51
84
  | "rejected"
52
85
  | "lost";
53
- user_key: string;
54
- testkit_id: string;
55
- testkit: Testkit;
56
- inbound_tracking_number?: string;
57
- outbound_tracking_number?: string;
58
- outbound_courier?: string;
59
- inbound_courier?: string;
60
- }
61
-
62
- export interface OrderResponse {
63
- orders: Order[];
64
- total: number;
65
- page: number;
66
- size: number;
67
86
  }
68
87
 
69
88
  export interface OrderRequestResponse {
@@ -72,6 +91,25 @@ export interface OrderRequestResponse {
72
91
  message: string;
73
92
  }
74
93
 
94
+ export interface LabClientFacing {
95
+ slug: string;
96
+ name: string;
97
+ first_line_address: string;
98
+ city: string;
99
+ zipcode: string;
100
+ }
101
+
102
+ export interface ClientFacingLabTest {
103
+ id: string;
104
+ slug: string;
105
+ name: string;
106
+ sample_type: string;
107
+ method: string;
108
+ price: number;
109
+ is_active: boolean;
110
+ lab: LabClientFacing;
111
+ markers: Marker;
112
+ }
75
113
  export interface TestkitResponse {
76
114
  testkits: Testkit[];
77
115
  }
@@ -79,18 +117,17 @@ export interface TestkitResponse {
79
117
  export interface LabResultsMetadata {
80
118
  age: string;
81
119
  dob: string;
82
- clia_number: string;
83
120
  patient: string;
84
- provider: string;
85
- laboratory: string;
86
121
  date_reported: string;
87
122
  date_collected: string;
88
123
  specimen_number: string;
89
- date_received?: string;
90
124
  clia?: string;
125
+ provider?: string;
126
+ laboratory?: string;
127
+ date_received?: string;
91
128
  }
92
129
 
93
- export interface LabResultsRaw {
130
+ export interface LabResultsResponse {
94
131
  metadata: LabResultsMetadata;
95
- data: Record<string, string>;
132
+ results: Object;
96
133
  }
@@ -0,0 +1,26 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ClientFacingLabTest, LabResultsMetadata, LabResultsResponse, Order, OrderRequestResponse, PatientAdress, PatientDetails, Physician } from './models/testkit_models';
3
+ export declare class OrdersApi {
4
+ baseURL: string;
5
+ client: AxiosInstance;
6
+ constructor(baseURL: string, axios: AxiosInstance);
7
+ create_order(user_id: string, patient_details: PatientDetails, patient_address: PatientAdress, lab_test_id: string, physician?: Physician): Promise<OrderRequestResponse>;
8
+ getOrder(orderId: string): Promise<Order>;
9
+ cancelOrder(orderId: string): Promise<OrderRequestResponse>;
10
+ }
11
+ export declare class ResultsApi {
12
+ baseURL: string;
13
+ client: AxiosInstance;
14
+ constructor(baseURL: string, axios: AxiosInstance);
15
+ getResults(orderId: string): Promise<LabResultsResponse>;
16
+ getResultsPdf(orderId: string): Promise<string>;
17
+ getResultsMetadata(orderId: string): Promise<LabResultsMetadata>;
18
+ }
19
+ export declare class LabTestsApi {
20
+ baseURL: string;
21
+ client: AxiosInstance;
22
+ Orders: OrdersApi;
23
+ Results: ResultsApi;
24
+ constructor(baseURL: string, axios: AxiosInstance);
25
+ getTests(): Promise<ClientFacingLabTest>;
26
+ }
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,32 +36,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
36
  }
48
37
  };
49
38
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.TestkitsApi = void 0;
51
- var TestkitsApi = /** @class */ (function () {
52
- function TestkitsApi(baseURL, axios) {
39
+ exports.LabTestsApi = exports.ResultsApi = exports.OrdersApi = void 0;
40
+ var OrdersApi = /** @class */ (function () {
41
+ function OrdersApi(baseURL, axios) {
53
42
  this.baseURL = baseURL;
54
43
  this.client = axios;
55
44
  }
56
- TestkitsApi.prototype.get = function () {
45
+ // Create new order
46
+ OrdersApi.prototype.create_order = function (user_id, patient_details, patient_address, lab_test_id, physician) {
57
47
  return __awaiter(this, void 0, void 0, function () {
58
48
  var resp;
59
49
  return __generator(this, function (_a) {
60
50
  switch (_a.label) {
61
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/testkit'))];
62
- case 1:
63
- resp = _a.sent();
64
- return [2 /*return*/, resp.data];
65
- }
66
- });
67
- });
68
- };
69
- TestkitsApi.prototype.get_orders = function (startDate, endDate, status, userId, patientName, page, size) {
70
- return __awaiter(this, void 0, void 0, function () {
71
- var resp;
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
74
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/testkit/orders/'), {
75
- params: __assign(__assign({ start_date: startDate, end_date: endDate, status: status ? status : null, user_id: userId ? userId : null, patient_name: patientName ? patientName : null }, (page && { page: page })), (size && { size: size })),
51
+ case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/order'), {
52
+ params: {
53
+ user_id: user_id,
54
+ patient_details: patient_details,
55
+ patient_address: patient_address,
56
+ lab_test_id: lab_test_id,
57
+ physician: physician ? physician : null
58
+ },
76
59
  })];
77
60
  case 1:
78
61
  resp = _a.sent();
@@ -81,17 +64,13 @@ var TestkitsApi = /** @class */ (function () {
81
64
  });
82
65
  });
83
66
  };
84
- TestkitsApi.prototype.order = function (userId, testkitId, patientAddress, patientDetails) {
67
+ // Get order status.
68
+ OrdersApi.prototype.getOrder = function (orderId) {
85
69
  return __awaiter(this, void 0, void 0, function () {
86
70
  var resp;
87
71
  return __generator(this, function (_a) {
88
72
  switch (_a.label) {
89
- case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat('/testkit/orders'), {
90
- user_key: userId,
91
- testkit_id: testkitId,
92
- patient_address: patientAddress,
93
- patient_details: patientDetails,
94
- })];
73
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/order/" + orderId))];
95
74
  case 1:
96
75
  resp = _a.sent();
97
76
  return [2 /*return*/, resp.data];
@@ -99,12 +78,13 @@ var TestkitsApi = /** @class */ (function () {
99
78
  });
100
79
  });
101
80
  };
102
- TestkitsApi.prototype.get_order = function (orderId) {
81
+ // Cancels order.
82
+ OrdersApi.prototype.cancelOrder = function (orderId) {
103
83
  return __awaiter(this, void 0, void 0, function () {
104
84
  var resp;
105
85
  return __generator(this, function (_a) {
106
86
  switch (_a.label) {
107
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId))];
87
+ case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat("/order/" + orderId + "/cancel"))];
108
88
  case 1:
109
89
  resp = _a.sent();
110
90
  return [2 /*return*/, resp.data];
@@ -112,12 +92,21 @@ var TestkitsApi = /** @class */ (function () {
112
92
  });
113
93
  });
114
94
  };
115
- TestkitsApi.prototype.cancel_order = function (orderId) {
95
+ return OrdersApi;
96
+ }());
97
+ exports.OrdersApi = OrdersApi;
98
+ var ResultsApi = /** @class */ (function () {
99
+ function ResultsApi(baseURL, axios) {
100
+ this.baseURL = baseURL;
101
+ this.client = axios;
102
+ }
103
+ // GET both metadata and raw json test data.
104
+ ResultsApi.prototype.getResults = function (orderId) {
116
105
  return __awaiter(this, void 0, void 0, function () {
117
106
  var resp;
118
107
  return __generator(this, function (_a) {
119
108
  switch (_a.label) {
120
- case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat("/testkit/orders/" + orderId + "/cancel"))];
109
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/order/" + orderId + "/result"))];
121
110
  case 1:
122
111
  resp = _a.sent();
123
112
  return [2 /*return*/, resp.data];
@@ -125,14 +114,14 @@ var TestkitsApi = /** @class */ (function () {
125
114
  });
126
115
  });
127
116
  };
128
- TestkitsApi.prototype.get_results = function (orderId) {
117
+ // GET gets the lab result for the order in PDF format.
118
+ // TODO Check response type for PDF
119
+ ResultsApi.prototype.getResultsPdf = function (orderId) {
129
120
  return __awaiter(this, void 0, void 0, function () {
130
121
  var resp;
131
122
  return __generator(this, function (_a) {
132
123
  switch (_a.label) {
133
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results"), {
134
- responseType: 'arraybuffer',
135
- })];
124
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/order/" + orderId + "/result/pdf"))];
136
125
  case 1:
137
126
  resp = _a.sent();
138
127
  return [2 /*return*/, resp.data];
@@ -140,12 +129,14 @@ var TestkitsApi = /** @class */ (function () {
140
129
  });
141
130
  });
142
131
  };
143
- TestkitsApi.prototype.getMetadata = function (orderId) {
132
+ // GET metadata related to order results, such as
133
+ // lab metadata, provider and sample dates.
134
+ ResultsApi.prototype.getResultsMetadata = function (orderId) {
144
135
  return __awaiter(this, void 0, void 0, function () {
145
136
  var resp;
146
137
  return __generator(this, function (_a) {
147
138
  switch (_a.label) {
148
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/metadata"))];
139
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/order/" + orderId + "/result/metadata"))];
149
140
  case 1:
150
141
  resp = _a.sent();
151
142
  return [2 /*return*/, resp.data];
@@ -153,12 +144,22 @@ var TestkitsApi = /** @class */ (function () {
153
144
  });
154
145
  });
155
146
  };
156
- TestkitsApi.prototype.getRawResults = function (orderId) {
147
+ return ResultsApi;
148
+ }());
149
+ exports.ResultsApi = ResultsApi;
150
+ var LabTestsApi = /** @class */ (function () {
151
+ function LabTestsApi(baseURL, axios) {
152
+ this.baseURL = baseURL;
153
+ this.client = axios;
154
+ this.Orders = new OrdersApi(baseURL, axios);
155
+ this.Results = new ResultsApi(baseURL, axios);
156
+ }
157
+ LabTestsApi.prototype.getTests = function () {
157
158
  return __awaiter(this, void 0, void 0, function () {
158
159
  var resp;
159
160
  return __generator(this, function (_a) {
160
161
  switch (_a.label) {
161
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/testkit/orders/" + orderId + "/results/raw"))];
162
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/lab_tests"))];
162
163
  case 1:
163
164
  resp = _a.sent();
164
165
  return [2 /*return*/, resp.data];
@@ -166,6 +167,6 @@ var TestkitsApi = /** @class */ (function () {
166
167
  });
167
168
  });
168
169
  };
169
- return TestkitsApi;
170
+ return LabTestsApi;
170
171
  }());
171
- exports.TestkitsApi = TestkitsApi;
172
+ exports.LabTestsApi = LabTestsApi;
@@ -60,7 +60,7 @@ var LinkApi = /** @class */ (function () {
60
60
  // @ts-ignore
61
61
  default_params['filter_on_providers'] = filter_on_providers;
62
62
  }
63
- return [4 /*yield*/, this.client.post(this.baseURL.concat('/link/token/'), default_params)];
63
+ return [4 /*yield*/, this.client.post(this.baseURL.concat('/link/token'), default_params)];
64
64
  case 1:
65
65
  resp = _a.sent();
66
66
  return [2 /*return*/, resp.data];
@@ -47,7 +47,7 @@ var ProviderApi = /** @class */ (function () {
47
47
  var resp;
48
48
  return __generator(this, function (_a) {
49
49
  switch (_a.label) {
50
- case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/providers/'))];
50
+ case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat('/providers'))];
51
51
  case 1:
52
52
  resp = _a.sent();
53
53
  return [2 /*return*/, resp.data];
@@ -77,7 +77,7 @@ var UserApi = /** @class */ (function () {
77
77
  return __generator(this, function (_e) {
78
78
  switch (_e.label) {
79
79
  case 0:
80
- url = new URL(this.baseURL.concat('/user/'));
80
+ url = new URL(this.baseURL.concat('/user'));
81
81
  url.searchParams.set('limit', String(limit));
82
82
  url.searchParams.set('offset', String(offset));
83
83
  return [4 /*yield*/, this.client.get(url.toString())];
@@ -5,7 +5,7 @@ export { SleepApi } from './Sleep';
5
5
  export { UserApi } from './User';
6
6
  export { WebhooksApi } from './Webhooks';
7
7
  export { WorkoutsApi } from './Workouts';
8
- export { TestkitsApi } from './Testkits';
8
+ export { LabTestsApi } from './LabTests';
9
9
  export { ProfileApi } from './Profile';
10
10
  export { DevicesAPI } from './Devices';
11
11
  export { MealsApi } from './Meals';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.TestkitsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
3
+ exports.MealsApi = exports.DevicesAPI = exports.ProfileApi = exports.LabTestsApi = exports.WorkoutsApi = exports.WebhooksApi = exports.UserApi = exports.SleepApi = exports.LinkApi = exports.BodyApi = exports.ActivityApi = void 0;
4
4
  var Activity_1 = require("./Activity");
5
5
  Object.defineProperty(exports, "ActivityApi", { enumerable: true, get: function () { return Activity_1.ActivityApi; } });
6
6
  var Body_1 = require("./Body");
@@ -15,8 +15,8 @@ var Webhooks_1 = require("./Webhooks");
15
15
  Object.defineProperty(exports, "WebhooksApi", { enumerable: true, get: function () { return Webhooks_1.WebhooksApi; } });
16
16
  var Workouts_1 = require("./Workouts");
17
17
  Object.defineProperty(exports, "WorkoutsApi", { enumerable: true, get: function () { return Workouts_1.WorkoutsApi; } });
18
- var Testkits_1 = require("./Testkits");
19
- Object.defineProperty(exports, "TestkitsApi", { enumerable: true, get: function () { return Testkits_1.TestkitsApi; } });
18
+ var LabTests_1 = require("./LabTests");
19
+ Object.defineProperty(exports, "LabTestsApi", { enumerable: true, get: function () { return LabTests_1.LabTestsApi; } });
20
20
  var Profile_1 = require("./Profile");
21
21
  Object.defineProperty(exports, "ProfileApi", { enumerable: true, get: function () { return Profile_1.ProfileApi; } });
22
22
  var Devices_1 = require("./Devices");
@@ -1,16 +1,26 @@
1
1
  export interface PatientAdress {
2
2
  receiver_name: string;
3
- first_line: string;
4
- second_line?: string;
3
+ street: string;
5
4
  city: string;
6
5
  state: string;
7
6
  zip: string;
8
7
  country: string;
9
8
  phone_number: string;
9
+ street_number?: string;
10
10
  }
11
11
  export interface PatientDetails {
12
12
  dob: string;
13
13
  gender: string;
14
+ email: string;
15
+ }
16
+ export interface Physician {
17
+ first_name: string;
18
+ last_name: string;
19
+ npi: string;
20
+ email?: string;
21
+ licensed_states?: string[];
22
+ created_at?: string;
23
+ updated_at?: string;
14
24
  }
15
25
  export interface Marker {
16
26
  name: string;
@@ -26,48 +36,66 @@ export interface Testkit {
26
36
  turnaround_time_upper: number;
27
37
  price: number;
28
38
  }
39
+ export interface TestkitEvent {
40
+ id: number;
41
+ created_at: string;
42
+ status: string;
43
+ }
29
44
  export interface Order {
45
+ user_id: string;
30
46
  id: string;
31
47
  team_id: string;
32
- created_on: Date;
33
- updated_on: Date;
34
- status: 'ordered' | 'transit_customer' | 'out_for_delivery' | 'with_customer' | 'transit_lab' | 'delivered_to_lab' | 'processing_lab' | 'completed' | 'failure_to_deliver_to_customer' | 'failure_to_deliver_to_lab' | 'cancelled' | 'do_not_process' | 'unknown' | "rejected" | "lost";
35
- user_key: string;
36
- testkit_id: string;
37
- testkit: Testkit;
38
- inbound_tracking_number?: string;
39
- outbound_tracking_number?: string;
40
- outbound_courier?: string;
41
- inbound_courier?: string;
42
- }
43
- export interface OrderResponse {
44
- orders: Order[];
45
- total: number;
46
- page: number;
47
- size: number;
48
+ patient_details: PatientDetails;
49
+ patient_address: PatientAdress;
50
+ lab_test: Testkit;
51
+ details: Object;
52
+ created_at: string;
53
+ updated_at: string;
54
+ events: TestkitEvent;
55
+ user_key?: string;
56
+ sample_id?: string;
57
+ notes?: string;
58
+ status?: 'ordered' | 'transit_customer' | 'out_for_delivery' | 'with_customer' | 'transit_lab' | 'delivered_to_lab' | 'processing_lab' | 'completed' | 'failure_to_deliver_to_customer' | 'failure_to_deliver_to_lab' | 'cancelled' | 'do_not_process' | 'unknown' | "rejected" | "lost";
48
59
  }
49
60
  export interface OrderRequestResponse {
50
61
  order: Order;
51
62
  status: string;
52
63
  message: string;
53
64
  }
65
+ export interface LabClientFacing {
66
+ slug: string;
67
+ name: string;
68
+ first_line_address: string;
69
+ city: string;
70
+ zipcode: string;
71
+ }
72
+ export interface ClientFacingLabTest {
73
+ id: string;
74
+ slug: string;
75
+ name: string;
76
+ sample_type: string;
77
+ method: string;
78
+ price: number;
79
+ is_active: boolean;
80
+ lab: LabClientFacing;
81
+ markers: Marker;
82
+ }
54
83
  export interface TestkitResponse {
55
84
  testkits: Testkit[];
56
85
  }
57
86
  export interface LabResultsMetadata {
58
87
  age: string;
59
88
  dob: string;
60
- clia_number: string;
61
89
  patient: string;
62
- provider: string;
63
- laboratory: string;
64
90
  date_reported: string;
65
91
  date_collected: string;
66
92
  specimen_number: string;
67
- date_received?: string;
68
93
  clia?: string;
94
+ provider?: string;
95
+ laboratory?: string;
96
+ date_received?: string;
69
97
  }
70
- export interface LabResultsRaw {
98
+ export interface LabResultsResponse {
71
99
  metadata: LabResultsMetadata;
72
- data: Record<string, string>;
100
+ results: Object;
73
101
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { ActivityApi, BodyApi, LinkApi, SleepApi, TestkitsApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi } from './client';
1
+ import { ActivityApi, BodyApi, LinkApi, SleepApi, UserApi, WebhooksApi, WorkoutsApi, ProfileApi, DevicesAPI, MealsApi } from './client';
2
2
  import { ClientConfig } from './lib/models';
3
3
  import { ClientCredentials } from './lib/credentials';
4
4
  import { VitalsApi } from './client/Vitals';
5
5
  import { ProviderApi } from './client/Provider';
6
+ import { LabTestsApi } from './client/LabTests';
6
7
  export declare class VitalClient {
7
8
  config: ClientConfig;
8
9
  clientCredentials: ClientCredentials;
@@ -15,7 +16,7 @@ export declare class VitalClient {
15
16
  Workouts: WorkoutsApi;
16
17
  Webhooks: WebhooksApi;
17
18
  Vitals: VitalsApi;
18
- Testkits: TestkitsApi;
19
+ LabTests: LabTestsApi;
19
20
  Profile: ProfileApi;
20
21
  Providers: ProviderApi;
21
22
  Devices: DevicesAPI;
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ var config_1 = require("./lib/config");
55
55
  var credentials_1 = require("./lib/credentials");
56
56
  var Vitals_1 = require("./client/Vitals");
57
57
  var Provider_1 = require("./client/Provider");
58
- ;
58
+ var LabTests_1 = require("./client/LabTests");
59
59
  var VitalClient = /** @class */ (function () {
60
60
  function VitalClient(config) {
61
61
  var _this = this;
@@ -112,7 +112,7 @@ var VitalClient = /** @class */ (function () {
112
112
  this.Workouts = new client_1.WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
113
113
  this.Webhooks = new client_1.WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
114
114
  this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
115
- this.Testkits = new client_1.TestkitsApi(baseURL.concat('/v2'), axiosApiInstance);
115
+ this.LabTests = new LabTests_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
116
116
  this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
117
117
  this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
118
118
  this.Devices = new client_1.DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
package/index.ts CHANGED
@@ -5,7 +5,6 @@ import {
5
5
  BodyApi,
6
6
  LinkApi,
7
7
  SleepApi,
8
- TestkitsApi,
9
8
  UserApi,
10
9
  WebhooksApi,
11
10
  WorkoutsApi,
@@ -17,7 +16,8 @@ import { ClientConfig } from './lib/models';
17
16
  import CONFIG from './lib/config';
18
17
  import { ClientCredentials } from './lib/credentials';
19
18
  import { VitalsApi } from './client/Vitals';
20
- import { ProviderApi } from './client/Provider';;
19
+ import { ProviderApi } from './client/Provider';
20
+ import { LabTestsApi } from './client/LabTests';
21
21
 
22
22
  export class VitalClient {
23
23
  config: ClientConfig;
@@ -31,7 +31,7 @@ export class VitalClient {
31
31
  Workouts: WorkoutsApi;
32
32
  Webhooks: WebhooksApi;
33
33
  Vitals: VitalsApi;
34
- Testkits: TestkitsApi;
34
+ LabTests: LabTestsApi;
35
35
  Profile: ProfileApi;
36
36
  Providers: ProviderApi;
37
37
  Devices: DevicesAPI;
@@ -87,7 +87,7 @@ export class VitalClient {
87
87
  this.Workouts = new WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
88
88
  this.Webhooks = new WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
89
89
  this.Vitals = new VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
90
- this.Testkits = new TestkitsApi(baseURL.concat('/v2'), axiosApiInstance);
90
+ this.LabTests = new LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
91
91
  this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
92
92
  this.Providers = new ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
93
93
  this.Devices = new DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "1.6.3",
3
+ "version": "2.1.0",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [
@@ -56,4 +56,4 @@
56
56
  "ts-node": "^10.2.0",
57
57
  "typescript": "^4.3.5"
58
58
  }
59
- }
59
+ }
@@ -1,107 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import {
3
- LabResultsMetadata,
4
- LabResultsRaw,
5
- Order,
6
- OrderRequestResponse,
7
- OrderResponse,
8
- PatientAdress,
9
- PatientDetails,
10
- TestkitResponse,
11
- } from './models/testkit_models';
12
-
13
- export class TestkitsApi {
14
- baseURL: string;
15
- client: AxiosInstance;
16
- constructor(baseURL: string, axios: AxiosInstance) {
17
- this.baseURL = baseURL;
18
- this.client = axios;
19
- }
20
-
21
- public async get(): Promise<TestkitResponse> {
22
- const resp = await this.client.get(this.baseURL.concat('/testkit'));
23
- return resp.data;
24
- }
25
-
26
- public async get_orders(
27
- startDate: Date,
28
- endDate: Date,
29
- status?: string[],
30
- userId?: string,
31
- patientName?: string,
32
- page?: number,
33
- size?: number
34
- ): Promise<OrderResponse> {
35
- const resp = await this.client.get(
36
- this.baseURL.concat('/testkit/orders/'),
37
- {
38
- params: {
39
- start_date: startDate,
40
- end_date: endDate,
41
- status: status ? status : null,
42
- user_id: userId ? userId : null,
43
- patient_name: patientName ? patientName : null,
44
- ...(page && { page }),
45
- ...(size && { size }),
46
- },
47
- }
48
- );
49
- return resp.data;
50
- }
51
-
52
- public async order(
53
- userId: string,
54
- testkitId: string,
55
- patientAddress: PatientAdress,
56
- patientDetails: PatientDetails
57
- ): Promise<OrderRequestResponse> {
58
- const resp = await this.client.post(
59
- this.baseURL.concat('/testkit/orders'),
60
- {
61
- user_key: userId,
62
- testkit_id: testkitId,
63
- patient_address: patientAddress,
64
- patient_details: patientDetails,
65
- }
66
- );
67
- return resp.data;
68
- }
69
-
70
- public async get_order(orderId: string): Promise<Order> {
71
- const resp = await this.client.get(
72
- this.baseURL.concat(`/testkit/orders/${orderId}`)
73
- );
74
- return resp.data;
75
- }
76
-
77
- public async cancel_order(orderId: string): Promise<OrderRequestResponse> {
78
- const resp = await this.client.post(
79
- this.baseURL.concat(`/testkit/orders/${orderId}/cancel`)
80
- );
81
- return resp.data;
82
- }
83
-
84
- public async get_results(orderId: string): Promise<string> {
85
- const resp = await this.client.get(
86
- this.baseURL.concat(`/testkit/orders/${orderId}/results`),
87
- {
88
- responseType: 'arraybuffer',
89
- }
90
- );
91
- return resp.data;
92
- }
93
-
94
- public async getMetadata(orderId: string): Promise<LabResultsMetadata> {
95
- const resp = await this.client.get(
96
- this.baseURL.concat(`/testkit/orders/${orderId}/results/metadata`)
97
- );
98
- return resp.data;
99
- }
100
-
101
- public async getRawResults(orderId: string): Promise<LabResultsRaw> {
102
- const resp = await this.client.get(
103
- this.baseURL.concat(`/testkit/orders/${orderId}/results/raw`)
104
- );
105
- return resp.data;
106
- }
107
- }
@@ -1,15 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { LabResultsMetadata, LabResultsRaw, Order, OrderRequestResponse, OrderResponse, PatientAdress, PatientDetails, TestkitResponse } from './models/testkit_models';
3
- export declare class TestkitsApi {
4
- baseURL: string;
5
- client: AxiosInstance;
6
- constructor(baseURL: string, axios: AxiosInstance);
7
- get(): Promise<TestkitResponse>;
8
- get_orders(startDate: Date, endDate: Date, status?: string[], userId?: string, patientName?: string, page?: number, size?: number): Promise<OrderResponse>;
9
- order(userId: string, testkitId: string, patientAddress: PatientAdress, patientDetails: PatientDetails): Promise<OrderRequestResponse>;
10
- get_order(orderId: string): Promise<Order>;
11
- cancel_order(orderId: string): Promise<OrderRequestResponse>;
12
- get_results(orderId: string): Promise<string>;
13
- getMetadata(orderId: string): Promise<LabResultsMetadata>;
14
- getRawResults(orderId: string): Promise<LabResultsRaw>;
15
- }