@tryvital/vital-node 2.1.19 → 2.1.21

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.
@@ -2,15 +2,15 @@ import { VitalClient } from "..";
2
2
  import { testEUClient, testUSClient, getUserId, randomString, test_user_id } from "./arrange";
3
3
 
4
4
  describe('User', () => {
5
- const user_id = randomString(10);
5
+ const clientUserId = randomString(10);
6
6
  it.each([
7
7
  ["eu_api_key", testEUClient],
8
8
  ["us_api_key", testUSClient],
9
9
  ])('should create a user %p', async (region: string, client: VitalClient) => {
10
10
  const user = await client.User.create(
11
- user_id,
11
+ clientUserId,
12
12
  )
13
- expect(user.client_user_id).toBe(user_id)
13
+ expect(user.client_user_id).toBe(clientUserId)
14
14
  });
15
15
 
16
16
  it.each([
@@ -23,15 +23,23 @@ describe('User', () => {
23
23
  expect(user.client_user_id).toBe(test_user_id)
24
24
  });
25
25
 
26
+ it.each([
27
+ testEUClient,
28
+ testUSClient,
29
+ ])('should create a sign-in token', async (client: VitalClient) => {
30
+ const userId = await getUserId(client, clientUserId);
31
+ const user = await client.User.createSignInToken(userId);
32
+ expect(user.user_id).toBe(userId)
33
+ });
34
+
26
35
  it.each([
27
36
  testEUClient,
28
37
  testUSClient,
29
38
  ])('should delete a user', async (client: VitalClient) => {
30
- const userToDelete = await getUserId(client, user_id);
39
+ const userToDelete = await getUserId(client, clientUserId);
31
40
  const user = await client.User.delete(
32
41
  userToDelete,
33
42
  )
34
43
  expect(user.success).toBe(true)
35
44
  });
36
-
37
45
  })
@@ -10,8 +10,8 @@ describe('Vitals', () => {
10
10
  const data = await client.Vitals.heartrate(
11
11
  userId,
12
12
  new Date("2022-10-01"),
13
- new Date("2022-11-01"),
13
+ new Date("2022-10-07"),
14
14
  )
15
- expect(data.length).toBeGreaterThan(0)
15
+ expect(data.length).toBeGreaterThanOrEqual(0)
16
16
  });
17
17
  })
package/client/User.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AxiosInstance } from 'axios';
2
2
  import {
3
3
  UserIdResponse,
4
+ CreateSignInTokenResponse,
4
5
  SuccessResponse,
5
6
  ClientFacingUser,
6
7
  Providers,
@@ -56,6 +57,11 @@ export class UserApi {
56
57
  return resp.data;
57
58
  }
58
59
 
60
+ public async createSignInToken(userId: string): Promise<CreateSignInTokenResponse> {
61
+ const resp = await this.client.post(this.baseURL.concat(`/user/${userId}/sign_in_token`), {});
62
+ return resp.data;
63
+ }
64
+
59
65
  public async providers(userId: string): Promise<ProvidersResponse> {
60
66
  const resp = await this.client.get(
61
67
  this.baseURL.concat(`/user/providers/${userId}`)
@@ -1,6 +1,12 @@
1
- import {USAddress} from "./athome_phlebotomy_models";
1
+ import { USAddress } from './athome_phlebotomy_models';
2
2
 
3
- export type ConsentType = "terms-of-use" | "telehealth-informed-consent" | "mobile-terms-and-conditions" | "notice-of-privacy-practices" | "privacy-policy" | "hipaa-authorization";
3
+ export type ConsentType =
4
+ | 'terms-of-use'
5
+ | 'telehealth-informed-consent'
6
+ | 'mobile-terms-and-conditions'
7
+ | 'notice-of-privacy-practices'
8
+ | 'privacy-policy'
9
+ | 'hipaa-authorization';
4
10
 
5
11
  export type Consent = {
6
12
  consentType: ConsentType;
@@ -73,7 +79,7 @@ export interface TestkitEvent {
73
79
  status: string;
74
80
  }
75
81
 
76
- export interface PayorAddress{
82
+ export interface PayorAddress {
77
83
  city: string;
78
84
  state: string;
79
85
  zip: string;
@@ -170,7 +176,35 @@ export interface LabResultsMetadata {
170
176
 
171
177
  export interface LabResultsResponse {
172
178
  metadata: LabResultsMetadata;
173
- results: Object;
179
+ results: Result[];
180
+ }
181
+
182
+ export enum Interpretation {
183
+ NORMAL = 'normal',
184
+ ABNORMAL = 'abnormal',
185
+ CRITICAL = 'critical',
186
+ }
187
+
188
+ export enum ResultType {
189
+ NUMERIC = 'numeric',
190
+ RANGE = 'range',
191
+ COMMENT = 'comment',
192
+ }
193
+
194
+ export interface Result {
195
+ name: string;
196
+ slug: string; // Optional and has a default value of an empty string
197
+ value: number; // Deprecated
198
+ result: string;
199
+ type: ResultType;
200
+ unit?: string; // Optional
201
+ timestamp?: Date; // Optional
202
+ notes?: string; // Optional
203
+ min_range_value?: number; // Optional
204
+ max_range_value?: number; // Optional
205
+ is_above_max_range?: boolean; // Optional
206
+ is_below_min_range?: boolean; // Optional
207
+ interpretation: Interpretation; // default value of Interpretation.NORMAL
174
208
  }
175
209
 
176
210
  export interface AreaInfo {
@@ -3,6 +3,11 @@ export interface UserIdResponse {
3
3
  user_id: string;
4
4
  }
5
5
 
6
+ export interface CreateSignInTokenResponse {
7
+ user_id: string;
8
+ sign_in_token: string;
9
+ }
10
+
6
11
  export interface SuccessResponse {
7
12
  success: boolean;
8
13
  }
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { UserIdResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse, GetTeamUsersParams, GetTeamUsersResponse } from './models/user_models';
2
+ import { UserIdResponse, CreateSignInTokenResponse, SuccessResponse, ClientFacingUser, Providers, ProvidersResponse, GetTeamUsersParams, GetTeamUsersResponse } from './models/user_models';
3
3
  export declare class UserApi {
4
4
  baseURL: string;
5
5
  client: AxiosInstance;
@@ -9,6 +9,7 @@ export declare class UserApi {
9
9
  getAll({ limit, offset, }?: GetTeamUsersParams): Promise<GetTeamUsersResponse>;
10
10
  get(userId: string): Promise<ClientFacingUser>;
11
11
  resolve(clientUserId: string): Promise<ClientFacingUser>;
12
+ createSignInToken(userId: string): Promise<CreateSignInTokenResponse>;
12
13
  providers(userId: string): Promise<ProvidersResponse>;
13
14
  deregisterProvider(userId: string, provider: Providers): Promise<SuccessResponse>;
14
15
  refresh(userId: string): Promise<SuccessResponse>;
@@ -114,6 +114,19 @@ var UserApi = /** @class */ (function () {
114
114
  });
115
115
  });
116
116
  };
117
+ UserApi.prototype.createSignInToken = function (userId) {
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ var resp;
120
+ return __generator(this, function (_a) {
121
+ switch (_a.label) {
122
+ case 0: return [4 /*yield*/, this.client.post(this.baseURL.concat("/user/" + userId + "/sign_in_token"), {})];
123
+ case 1:
124
+ resp = _a.sent();
125
+ return [2 /*return*/, resp.data];
126
+ }
127
+ });
128
+ });
129
+ };
117
130
  UserApi.prototype.providers = function (userId) {
118
131
  return __awaiter(this, void 0, void 0, function () {
119
132
  var resp;
@@ -1,4 +1,4 @@
1
- export declare type ConsentType = "terms-of-use" | "telehealth-informed-consent" | "mobile-terms-and-conditions" | "notice-of-privacy-practices" | "privacy-policy" | "hipaa-authorization";
1
+ export declare type ConsentType = 'terms-of-use' | 'telehealth-informed-consent' | 'mobile-terms-and-conditions' | 'notice-of-privacy-practices' | 'privacy-policy' | 'hipaa-authorization';
2
2
  export declare type Consent = {
3
3
  consentType: ConsentType;
4
4
  };
@@ -134,7 +134,32 @@ export interface LabResultsMetadata {
134
134
  }
135
135
  export interface LabResultsResponse {
136
136
  metadata: LabResultsMetadata;
137
- results: Object;
137
+ results: Result[];
138
+ }
139
+ export declare enum Interpretation {
140
+ NORMAL = "normal",
141
+ ABNORMAL = "abnormal",
142
+ CRITICAL = "critical"
143
+ }
144
+ export declare enum ResultType {
145
+ NUMERIC = "numeric",
146
+ RANGE = "range",
147
+ COMMENT = "comment"
148
+ }
149
+ export interface Result {
150
+ name: string;
151
+ slug: string;
152
+ value: number;
153
+ result: string;
154
+ type: ResultType;
155
+ unit?: string;
156
+ timestamp?: Date;
157
+ notes?: string;
158
+ min_range_value?: number;
159
+ max_range_value?: number;
160
+ is_above_max_range?: boolean;
161
+ is_below_min_range?: boolean;
162
+ interpretation: Interpretation;
138
163
  }
139
164
  export interface AreaInfo {
140
165
  zip_code: string;
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResultType = exports.Interpretation = void 0;
4
+ var Interpretation;
5
+ (function (Interpretation) {
6
+ Interpretation["NORMAL"] = "normal";
7
+ Interpretation["ABNORMAL"] = "abnormal";
8
+ Interpretation["CRITICAL"] = "critical";
9
+ })(Interpretation = exports.Interpretation || (exports.Interpretation = {}));
10
+ var ResultType;
11
+ (function (ResultType) {
12
+ ResultType["NUMERIC"] = "numeric";
13
+ ResultType["RANGE"] = "range";
14
+ ResultType["COMMENT"] = "comment";
15
+ })(ResultType = exports.ResultType || (exports.ResultType = {}));
@@ -2,6 +2,10 @@ export interface UserIdResponse {
2
2
  client_user_id: string;
3
3
  user_id: string;
4
4
  }
5
+ export interface CreateSignInTokenResponse {
6
+ user_id: string;
7
+ sign_in_token: string;
8
+ }
5
9
  export interface SuccessResponse {
6
10
  success: boolean;
7
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvital/vital-node",
3
- "version": "2.1.19",
3
+ "version": "2.1.21",
4
4
  "description": "Node client for Vital",
5
5
  "author": "maitham",
6
6
  "keywords": [