@tryvital/vital-node 1.6.0 → 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.
- package/client/LabTests.ts +120 -0
- package/client/Link.ts +1 -1
- package/client/Meals.ts +27 -0
- package/client/Provider.ts +1 -1
- package/client/User.ts +1 -1
- package/client/index.ts +2 -1
- package/client/models/meal_model.ts +61 -0
- package/client/models/testkit_models.ts +62 -25
- package/client/models/user_models.ts +11 -0
- package/dist/client/LabTests.d.ts +26 -0
- package/dist/client/{Testkits.js → LabTests.js} +52 -51
- package/dist/client/Link.js +1 -1
- package/dist/client/Meals.d.ts +8 -0
- package/dist/client/Meals.js +62 -0
- package/dist/client/Provider.js +1 -1
- package/dist/client/User.js +1 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +5 -3
- package/dist/client/models/meal_model.d.ts +55 -0
- package/dist/client/models/meal_model.js +2 -0
- package/dist/client/models/testkit_models.d.ts +52 -24
- package/dist/client/models/user_models.d.ts +12 -1
- package/dist/client/models/user_models.js +11 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/index.ts +6 -3
- package/package.json +2 -2
- package/.github/workflows/size.yml +0 -12
- package/client/Testkits.ts +0 -107
- package/dist/client/Testkits.d.ts +0 -15
@@ -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
package/client/Meals.ts
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
2
|
+
import { ClientFacingMealResponse } from './models/meal_model';
|
3
|
+
|
4
|
+
export class MealsApi {
|
5
|
+
baseURL: string;
|
6
|
+
client: AxiosInstance;
|
7
|
+
|
8
|
+
constructor(baseURL: string, axios: AxiosInstance) {
|
9
|
+
this.baseURL = baseURL;
|
10
|
+
this.client = axios;
|
11
|
+
}
|
12
|
+
|
13
|
+
public async get(
|
14
|
+
userId: string,
|
15
|
+
startDate: Date,
|
16
|
+
endDate?: Date,
|
17
|
+
provider?: string
|
18
|
+
): Promise<ClientFacingMealResponse> {
|
19
|
+
const resp = await this.client.get(
|
20
|
+
this.baseURL.concat(`/summary/meal/${userId}`),
|
21
|
+
{
|
22
|
+
params: { start_date: startDate, end_date: endDate, provider },
|
23
|
+
}
|
24
|
+
);
|
25
|
+
return resp.data;
|
26
|
+
}
|
27
|
+
}
|
package/client/Provider.ts
CHANGED
@@ -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,6 +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 {
|
8
|
+
export { LabTestsApi } from './LabTests';
|
9
9
|
export { ProfileApi } from './Profile';
|
10
10
|
export { DevicesAPI } from './Devices';
|
11
|
+
export { MealsApi } from './Meals';
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { SourceClientFacing } from './user_models';
|
2
|
+
|
3
|
+
/* tslint:disable */
|
4
|
+
/* eslint-disable */
|
5
|
+
/**
|
6
|
+
/* This file was automatically generated from pydantic models by running pydantic2ts.
|
7
|
+
/* Do not modify it by hand - just update the pydantic models and then re-run the script
|
8
|
+
*/
|
9
|
+
|
10
|
+
export interface MealInDBBaseClientFacingSource {
|
11
|
+
id: string;
|
12
|
+
user_id: string;
|
13
|
+
priority_id: number;
|
14
|
+
source_id: number;
|
15
|
+
provider_id: string;
|
16
|
+
timestamp: string;
|
17
|
+
name: string;
|
18
|
+
energy?: Energy;
|
19
|
+
macros?: Macros;
|
20
|
+
micros?: Micros;
|
21
|
+
source: SourceClientFacing;
|
22
|
+
created_at: string;
|
23
|
+
updated_at: string;
|
24
|
+
}
|
25
|
+
export interface Energy {
|
26
|
+
unit: "kcal";
|
27
|
+
value: number;
|
28
|
+
}
|
29
|
+
export interface Macros {
|
30
|
+
carbs?: number;
|
31
|
+
protein?: number;
|
32
|
+
fats?: Fats;
|
33
|
+
alcohol?: number;
|
34
|
+
water?: number;
|
35
|
+
fibre?: number;
|
36
|
+
sugar?: number;
|
37
|
+
}
|
38
|
+
export interface Fats {
|
39
|
+
saturated?: number;
|
40
|
+
monounsaturated?: number;
|
41
|
+
polyunsaturated?: number;
|
42
|
+
omega3?: number;
|
43
|
+
omega6?: number;
|
44
|
+
total?: number;
|
45
|
+
}
|
46
|
+
export interface Micros {
|
47
|
+
minerals?: {
|
48
|
+
[k: string]: number;
|
49
|
+
};
|
50
|
+
trace_elements?: {
|
51
|
+
[k: string]: number;
|
52
|
+
};
|
53
|
+
vitamins?: {
|
54
|
+
[k: string]: number;
|
55
|
+
};
|
56
|
+
}
|
57
|
+
|
58
|
+
export interface ClientFacingMealResponse {
|
59
|
+
meals: MealInDBBaseClientFacingSource[];
|
60
|
+
}
|
61
|
+
|
@@ -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
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
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
|
130
|
+
export interface LabResultsResponse {
|
94
131
|
metadata: LabResultsMetadata;
|
95
|
-
|
132
|
+
results: Object;
|
96
133
|
}
|
@@ -50,6 +50,17 @@ export enum Providers {
|
|
50
50
|
Wahoo = 'wahoo',
|
51
51
|
Zwift = 'zwift',
|
52
52
|
Hammerhead = 'hammerhead',
|
53
|
+
FreestyleLibre = "freestyle_libre",
|
54
|
+
Withings = "withings",
|
55
|
+
EightSleep = "eight_sleep",
|
56
|
+
GoogleFit = "google_fit",
|
57
|
+
AppleHealthKit = "apple_health_kit",
|
58
|
+
IHealth = "ihealth",
|
59
|
+
AccuchekBle = "accuchek_ble",
|
60
|
+
ContourBle = "contour_ble",
|
61
|
+
Beurer = "beurer",
|
62
|
+
Dexcom = "dexcom",
|
63
|
+
MyFitnessPal = "my_fitness_pal",
|
53
64
|
}
|
54
65
|
|
55
66
|
export interface GetTeamUsersParams {
|
@@ -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.
|
51
|
-
var
|
52
|
-
function
|
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
|
-
|
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.
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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("/
|
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
|
-
|
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("/
|
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
|
-
|
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("/
|
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
|
170
|
+
return LabTestsApi;
|
170
171
|
}());
|
171
|
-
exports.
|
172
|
+
exports.LabTestsApi = LabTestsApi;
|
package/dist/client/Link.js
CHANGED
@@ -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
|
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];
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
2
|
+
import { ClientFacingMealResponse } from './models/meal_model';
|
3
|
+
export declare class MealsApi {
|
4
|
+
baseURL: string;
|
5
|
+
client: AxiosInstance;
|
6
|
+
constructor(baseURL: string, axios: AxiosInstance);
|
7
|
+
get(userId: string, startDate: Date, endDate?: Date, provider?: string): Promise<ClientFacingMealResponse>;
|
8
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
15
|
+
function step(op) {
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
17
|
+
while (_) try {
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
20
|
+
switch (op[0]) {
|
21
|
+
case 0: case 1: t = op; break;
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
25
|
+
default:
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
30
|
+
if (t[2]) _.ops.pop();
|
31
|
+
_.trys.pop(); continue;
|
32
|
+
}
|
33
|
+
op = body.call(thisArg, _);
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
36
|
+
}
|
37
|
+
};
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
+
exports.MealsApi = void 0;
|
40
|
+
var MealsApi = /** @class */ (function () {
|
41
|
+
function MealsApi(baseURL, axios) {
|
42
|
+
this.baseURL = baseURL;
|
43
|
+
this.client = axios;
|
44
|
+
}
|
45
|
+
MealsApi.prototype.get = function (userId, startDate, endDate, provider) {
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
47
|
+
var resp;
|
48
|
+
return __generator(this, function (_a) {
|
49
|
+
switch (_a.label) {
|
50
|
+
case 0: return [4 /*yield*/, this.client.get(this.baseURL.concat("/summary/meal/" + userId), {
|
51
|
+
params: { start_date: startDate, end_date: endDate, provider: provider },
|
52
|
+
})];
|
53
|
+
case 1:
|
54
|
+
resp = _a.sent();
|
55
|
+
return [2 /*return*/, resp.data];
|
56
|
+
}
|
57
|
+
});
|
58
|
+
});
|
59
|
+
};
|
60
|
+
return MealsApi;
|
61
|
+
}());
|
62
|
+
exports.MealsApi = MealsApi;
|
package/dist/client/Provider.js
CHANGED
@@ -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];
|
package/dist/client/User.js
CHANGED
@@ -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())];
|
package/dist/client/index.d.ts
CHANGED
@@ -5,6 +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 {
|
8
|
+
export { LabTestsApi } from './LabTests';
|
9
9
|
export { ProfileApi } from './Profile';
|
10
10
|
export { DevicesAPI } from './Devices';
|
11
|
+
export { MealsApi } from './Meals';
|
package/dist/client/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DevicesAPI = exports.ProfileApi = exports.
|
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,9 +15,11 @@ 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
|
19
|
-
Object.defineProperty(exports, "
|
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");
|
23
23
|
Object.defineProperty(exports, "DevicesAPI", { enumerable: true, get: function () { return Devices_1.DevicesAPI; } });
|
24
|
+
var Meals_1 = require("./Meals");
|
25
|
+
Object.defineProperty(exports, "MealsApi", { enumerable: true, get: function () { return Meals_1.MealsApi; } });
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { SourceClientFacing } from './user_models';
|
2
|
+
/**
|
3
|
+
/* This file was automatically generated from pydantic models by running pydantic2ts.
|
4
|
+
/* Do not modify it by hand - just update the pydantic models and then re-run the script
|
5
|
+
*/
|
6
|
+
export interface MealInDBBaseClientFacingSource {
|
7
|
+
id: string;
|
8
|
+
user_id: string;
|
9
|
+
priority_id: number;
|
10
|
+
source_id: number;
|
11
|
+
provider_id: string;
|
12
|
+
timestamp: string;
|
13
|
+
name: string;
|
14
|
+
energy?: Energy;
|
15
|
+
macros?: Macros;
|
16
|
+
micros?: Micros;
|
17
|
+
source: SourceClientFacing;
|
18
|
+
created_at: string;
|
19
|
+
updated_at: string;
|
20
|
+
}
|
21
|
+
export interface Energy {
|
22
|
+
unit: "kcal";
|
23
|
+
value: number;
|
24
|
+
}
|
25
|
+
export interface Macros {
|
26
|
+
carbs?: number;
|
27
|
+
protein?: number;
|
28
|
+
fats?: Fats;
|
29
|
+
alcohol?: number;
|
30
|
+
water?: number;
|
31
|
+
fibre?: number;
|
32
|
+
sugar?: number;
|
33
|
+
}
|
34
|
+
export interface Fats {
|
35
|
+
saturated?: number;
|
36
|
+
monounsaturated?: number;
|
37
|
+
polyunsaturated?: number;
|
38
|
+
omega3?: number;
|
39
|
+
omega6?: number;
|
40
|
+
total?: number;
|
41
|
+
}
|
42
|
+
export interface Micros {
|
43
|
+
minerals?: {
|
44
|
+
[k: string]: number;
|
45
|
+
};
|
46
|
+
trace_elements?: {
|
47
|
+
[k: string]: number;
|
48
|
+
};
|
49
|
+
vitamins?: {
|
50
|
+
[k: string]: number;
|
51
|
+
};
|
52
|
+
}
|
53
|
+
export interface ClientFacingMealResponse {
|
54
|
+
meals: MealInDBBaseClientFacingSource[];
|
55
|
+
}
|
@@ -1,16 +1,26 @@
|
|
1
1
|
export interface PatientAdress {
|
2
2
|
receiver_name: string;
|
3
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
98
|
+
export interface LabResultsResponse {
|
71
99
|
metadata: LabResultsMetadata;
|
72
|
-
|
100
|
+
results: Object;
|
73
101
|
}
|
@@ -42,7 +42,18 @@ export declare enum Providers {
|
|
42
42
|
Peloton = "peloton",
|
43
43
|
Wahoo = "wahoo",
|
44
44
|
Zwift = "zwift",
|
45
|
-
Hammerhead = "hammerhead"
|
45
|
+
Hammerhead = "hammerhead",
|
46
|
+
FreestyleLibre = "freestyle_libre",
|
47
|
+
Withings = "withings",
|
48
|
+
EightSleep = "eight_sleep",
|
49
|
+
GoogleFit = "google_fit",
|
50
|
+
AppleHealthKit = "apple_health_kit",
|
51
|
+
IHealth = "ihealth",
|
52
|
+
AccuchekBle = "accuchek_ble",
|
53
|
+
ContourBle = "contour_ble",
|
54
|
+
Beurer = "beurer",
|
55
|
+
Dexcom = "dexcom",
|
56
|
+
MyFitnessPal = "my_fitness_pal"
|
46
57
|
}
|
47
58
|
export interface GetTeamUsersParams {
|
48
59
|
limit?: number;
|
@@ -13,4 +13,15 @@ var Providers;
|
|
13
13
|
Providers["Wahoo"] = "wahoo";
|
14
14
|
Providers["Zwift"] = "zwift";
|
15
15
|
Providers["Hammerhead"] = "hammerhead";
|
16
|
+
Providers["FreestyleLibre"] = "freestyle_libre";
|
17
|
+
Providers["Withings"] = "withings";
|
18
|
+
Providers["EightSleep"] = "eight_sleep";
|
19
|
+
Providers["GoogleFit"] = "google_fit";
|
20
|
+
Providers["AppleHealthKit"] = "apple_health_kit";
|
21
|
+
Providers["IHealth"] = "ihealth";
|
22
|
+
Providers["AccuchekBle"] = "accuchek_ble";
|
23
|
+
Providers["ContourBle"] = "contour_ble";
|
24
|
+
Providers["Beurer"] = "beurer";
|
25
|
+
Providers["Dexcom"] = "dexcom";
|
26
|
+
Providers["MyFitnessPal"] = "my_fitness_pal";
|
16
27
|
})(Providers = exports.Providers || (exports.Providers = {}));
|
package/dist/index.d.ts
CHANGED
@@ -1,20 +1,22 @@
|
|
1
|
-
import { ActivityApi, BodyApi, LinkApi, SleepApi,
|
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;
|
9
10
|
Activity: ActivityApi;
|
10
11
|
Link: LinkApi;
|
11
12
|
Body: BodyApi;
|
13
|
+
Meals: MealsApi;
|
12
14
|
Sleep: SleepApi;
|
13
15
|
User: UserApi;
|
14
16
|
Workouts: WorkoutsApi;
|
15
17
|
Webhooks: WebhooksApi;
|
16
18
|
Vitals: VitalsApi;
|
17
|
-
|
19
|
+
LabTests: LabTestsApi;
|
18
20
|
Profile: ProfileApi;
|
19
21
|
Providers: ProviderApi;
|
20
22
|
Devices: DevicesAPI;
|
package/dist/index.js
CHANGED
@@ -55,6 +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
|
+
var LabTests_1 = require("./client/LabTests");
|
58
59
|
var VitalClient = /** @class */ (function () {
|
59
60
|
function VitalClient(config) {
|
60
61
|
var _this = this;
|
@@ -111,10 +112,11 @@ var VitalClient = /** @class */ (function () {
|
|
111
112
|
this.Workouts = new client_1.WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
|
112
113
|
this.Webhooks = new client_1.WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
|
113
114
|
this.Vitals = new Vitals_1.VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
|
114
|
-
this.
|
115
|
+
this.LabTests = new LabTests_1.LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
|
115
116
|
this.Profile = new client_1.ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
|
116
117
|
this.Providers = new Provider_1.ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
|
117
118
|
this.Devices = new client_1.DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
|
119
|
+
this.Meals = new client_1.MealsApi(baseURL.concat('/v2'), axiosApiInstance);
|
118
120
|
}
|
119
121
|
return VitalClient;
|
120
122
|
}());
|
package/index.ts
CHANGED
@@ -5,18 +5,19 @@ import {
|
|
5
5
|
BodyApi,
|
6
6
|
LinkApi,
|
7
7
|
SleepApi,
|
8
|
-
TestkitsApi,
|
9
8
|
UserApi,
|
10
9
|
WebhooksApi,
|
11
10
|
WorkoutsApi,
|
12
11
|
ProfileApi,
|
13
12
|
DevicesAPI,
|
13
|
+
MealsApi
|
14
14
|
} from './client';
|
15
15
|
import { ClientConfig } from './lib/models';
|
16
16
|
import CONFIG from './lib/config';
|
17
17
|
import { ClientCredentials } from './lib/credentials';
|
18
18
|
import { VitalsApi } from './client/Vitals';
|
19
19
|
import { ProviderApi } from './client/Provider';
|
20
|
+
import { LabTestsApi } from './client/LabTests';
|
20
21
|
|
21
22
|
export class VitalClient {
|
22
23
|
config: ClientConfig;
|
@@ -24,12 +25,13 @@ export class VitalClient {
|
|
24
25
|
Activity: ActivityApi;
|
25
26
|
Link: LinkApi;
|
26
27
|
Body: BodyApi;
|
28
|
+
Meals: MealsApi;
|
27
29
|
Sleep: SleepApi;
|
28
30
|
User: UserApi;
|
29
31
|
Workouts: WorkoutsApi;
|
30
32
|
Webhooks: WebhooksApi;
|
31
33
|
Vitals: VitalsApi;
|
32
|
-
|
34
|
+
LabTests: LabTestsApi;
|
33
35
|
Profile: ProfileApi;
|
34
36
|
Providers: ProviderApi;
|
35
37
|
Devices: DevicesAPI;
|
@@ -85,9 +87,10 @@ export class VitalClient {
|
|
85
87
|
this.Workouts = new WorkoutsApi(baseURL.concat('/v2'), axiosApiInstance);
|
86
88
|
this.Webhooks = new WebhooksApi(baseURL.concat('/v2'), axiosApiInstance);
|
87
89
|
this.Vitals = new VitalsApi(baseURL.concat('/v2'), axiosApiInstance);
|
88
|
-
this.
|
90
|
+
this.LabTests = new LabTestsApi(baseURL.concat('/v3'), axiosApiInstance);
|
89
91
|
this.Profile = new ProfileApi(baseURL.concat('/v2'), axiosApiInstance);
|
90
92
|
this.Providers = new ProviderApi(baseURL.concat('/v2'), axiosApiInstance);
|
91
93
|
this.Devices = new DevicesAPI(baseURL.concat('/v2'), axiosApiInstance);
|
94
|
+
this.Meals = new MealsApi(baseURL.concat('/v2'), axiosApiInstance);
|
92
95
|
}
|
93
96
|
}
|
package/package.json
CHANGED
package/client/Testkits.ts
DELETED
@@ -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
|
-
}
|