@healthcloudai/hc-safe-cdx 0.1.4 → 0.2.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/README.md +860 -98
- package/dist/index.cjs +83 -93
- package/dist/index.d.cts +193 -246
- package/dist/index.d.ts +193 -246
- package/dist/index.js +83 -93
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,10 +40,15 @@ var ENV_HOST = {
|
|
|
40
40
|
prod: "api-hcs.healthcloud-services.com"
|
|
41
41
|
};
|
|
42
42
|
var ROUTE_PREFIX = "api/console/hcservice/safecdx";
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
function buildSafeCdxBaseUrl(environment) {
|
|
44
|
+
const host = ENV_HOST[environment];
|
|
45
|
+
if (!host) {
|
|
46
|
+
throw new SafeCDXError("Invalid Safe CDX environment.");
|
|
47
|
+
}
|
|
48
|
+
return `https://${host}/${ROUTE_PREFIX}`;
|
|
49
|
+
}
|
|
50
|
+
function buildUrl(baseUrl, route, query) {
|
|
51
|
+
const url = new URL(`${baseUrl}/${route.replace(/^\/+/, "")}`);
|
|
47
52
|
if (query) {
|
|
48
53
|
for (const [key, value] of Object.entries(query)) {
|
|
49
54
|
if (value !== void 0 && value !== "") {
|
|
@@ -53,30 +58,11 @@ function buildUrl(host, route, query) {
|
|
|
53
58
|
}
|
|
54
59
|
return url.toString();
|
|
55
60
|
}
|
|
56
|
-
function wrapData(payload) {
|
|
57
|
-
return { Data: payload };
|
|
58
|
-
}
|
|
59
|
-
function assertApiResponse(envelope, route) {
|
|
60
|
-
var _a;
|
|
61
|
-
if (!envelope.IsOK) {
|
|
62
|
-
throw new SafeCDXError(
|
|
63
|
-
(_a = envelope.ErrorMessage) != null ? _a : `${route} returned IsOK=false.`,
|
|
64
|
-
envelope
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return envelope;
|
|
68
|
-
}
|
|
69
61
|
var HCSafeCDXClient = class {
|
|
70
|
-
constructor(httpClient, authClient
|
|
71
|
-
var _a;
|
|
72
|
-
if (!ENV_HOST[config.environment]) {
|
|
73
|
-
throw new SafeCDXError(`Invalid environment: ${config.environment}`);
|
|
74
|
-
}
|
|
62
|
+
constructor(httpClient, authClient) {
|
|
75
63
|
this.http = httpClient;
|
|
76
64
|
this.auth = authClient;
|
|
77
|
-
this.
|
|
78
|
-
this.defaultLanguage = config.defaultLanguage;
|
|
79
|
-
this.defaultImageType = (_a = config.defaultImageType) != null ? _a : "jpg";
|
|
65
|
+
this.baseUrl = buildSafeCdxBaseUrl(authClient.getEnvironment());
|
|
80
66
|
}
|
|
81
67
|
setApiKey(headerName, value) {
|
|
82
68
|
const trimmedHeaderName = headerName == null ? void 0 : headerName.trim();
|
|
@@ -114,7 +100,7 @@ var HCSafeCDXClient = class {
|
|
|
114
100
|
};
|
|
115
101
|
}
|
|
116
102
|
url(route, query) {
|
|
117
|
-
return buildUrl(this.
|
|
103
|
+
return buildUrl(this.baseUrl, route, query);
|
|
118
104
|
}
|
|
119
105
|
// ---------------------------------------------------------------------------
|
|
120
106
|
// Scan
|
|
@@ -123,30 +109,15 @@ var HCSafeCDXClient = class {
|
|
|
123
109
|
* GET gs1/:gtin
|
|
124
110
|
* Resolves a test profile by GTIN barcode and creates a UserTestResultId.
|
|
125
111
|
*/
|
|
126
|
-
async getTestProfileByGTIN(gtin
|
|
127
|
-
|
|
128
|
-
this.url(`gs1/${encodeURIComponent(gtin)}
|
|
129
|
-
language: language != null ? language : this.defaultLanguage
|
|
130
|
-
}),
|
|
112
|
+
async getTestProfileByGTIN(gtin) {
|
|
113
|
+
return this.http.get(
|
|
114
|
+
this.url(`gs1/${encodeURIComponent(gtin)}`),
|
|
131
115
|
this.getAuthHeaders()
|
|
132
116
|
);
|
|
133
|
-
return assertApiResponse(envelope, "gs1/:gtin");
|
|
134
117
|
}
|
|
135
118
|
// ---------------------------------------------------------------------------
|
|
136
119
|
// Test Profiles
|
|
137
120
|
// ---------------------------------------------------------------------------
|
|
138
|
-
/**
|
|
139
|
-
* POST test/profile
|
|
140
|
-
* Returns the full test profile for a given GTIN.
|
|
141
|
-
*/
|
|
142
|
-
async getTestProfile(payload) {
|
|
143
|
-
const envelope = await this.http.post(
|
|
144
|
-
this.url("test/profile"),
|
|
145
|
-
wrapData(payload),
|
|
146
|
-
this.getJsonHeaders()
|
|
147
|
-
);
|
|
148
|
-
return assertApiResponse(envelope, "test/profile");
|
|
149
|
-
}
|
|
150
121
|
/**
|
|
151
122
|
* POST test/profiles/by-account
|
|
152
123
|
* Lists all test profiles available to the authenticated account.
|
|
@@ -154,12 +125,14 @@ var HCSafeCDXClient = class {
|
|
|
154
125
|
async getTestProfilesByAccount(payload = {
|
|
155
126
|
IncludeRegisterTestDetails: true
|
|
156
127
|
}) {
|
|
157
|
-
const
|
|
128
|
+
const request = {
|
|
129
|
+
Data: payload
|
|
130
|
+
};
|
|
131
|
+
return this.http.post(
|
|
158
132
|
this.url("test/profiles/by-account"),
|
|
159
|
-
|
|
133
|
+
request,
|
|
160
134
|
this.getJsonHeaders()
|
|
161
135
|
);
|
|
162
|
-
return assertApiResponse(envelope, "test/profiles/by-account");
|
|
163
136
|
}
|
|
164
137
|
// ---------------------------------------------------------------------------
|
|
165
138
|
// Upload
|
|
@@ -174,15 +147,17 @@ var HCSafeCDXClient = class {
|
|
|
174
147
|
Gtin: gtin,
|
|
175
148
|
UserTestResultId: userTestResultId,
|
|
176
149
|
Metadata: {
|
|
177
|
-
ImageType: imageType != null ? imageType :
|
|
150
|
+
ImageType: imageType != null ? imageType : "jpg"
|
|
178
151
|
}
|
|
179
152
|
};
|
|
180
|
-
const
|
|
153
|
+
const request = {
|
|
154
|
+
Data: payload
|
|
155
|
+
};
|
|
156
|
+
return this.http.post(
|
|
181
157
|
this.url("upload/url"),
|
|
182
|
-
|
|
158
|
+
request,
|
|
183
159
|
this.getJsonHeaders()
|
|
184
160
|
);
|
|
185
|
-
return assertApiResponse(envelope, "upload/url");
|
|
186
161
|
}
|
|
187
162
|
/**
|
|
188
163
|
* PUT preSignedURL — direct S3 upload, not a SafeCDX API route.
|
|
@@ -227,9 +202,12 @@ var HCSafeCDXClient = class {
|
|
|
227
202
|
ImageOfCaptureId: imageOfCaptureId,
|
|
228
203
|
CvmlStatus: cvmlStatus
|
|
229
204
|
};
|
|
205
|
+
const request = {
|
|
206
|
+
Data: payload
|
|
207
|
+
};
|
|
230
208
|
return this.http.post(
|
|
231
209
|
this.url("cvml/status"),
|
|
232
|
-
|
|
210
|
+
request,
|
|
233
211
|
this.getJsonHeaders()
|
|
234
212
|
);
|
|
235
213
|
}
|
|
@@ -254,38 +232,48 @@ var HCSafeCDXClient = class {
|
|
|
254
232
|
* Returns test results in a pending/incomplete state.
|
|
255
233
|
*/
|
|
256
234
|
async getPendingResults(payload = {
|
|
257
|
-
ExcludeStatus: "
|
|
235
|
+
ExcludeStatus: "Invalid,Canceled"
|
|
258
236
|
}) {
|
|
259
|
-
const
|
|
237
|
+
const request = {
|
|
238
|
+
Data: payload
|
|
239
|
+
};
|
|
240
|
+
return this.http.post(
|
|
260
241
|
this.url("test/result/pending"),
|
|
261
|
-
|
|
242
|
+
request,
|
|
262
243
|
this.getJsonHeaders()
|
|
263
244
|
);
|
|
264
|
-
return assertApiResponse(envelope, "test/result/pending");
|
|
265
245
|
}
|
|
266
246
|
/**
|
|
267
247
|
* POST test/result/last
|
|
268
248
|
* Returns the most recent test result for the authenticated patient.
|
|
269
249
|
*/
|
|
270
|
-
async getLastResults(payload = {
|
|
271
|
-
|
|
250
|
+
async getLastResults(payload = {
|
|
251
|
+
ExcludeStatus: "Invalid"
|
|
252
|
+
}) {
|
|
253
|
+
const request = {
|
|
254
|
+
Data: payload
|
|
255
|
+
};
|
|
256
|
+
return this.http.post(
|
|
272
257
|
this.url("test/result/last"),
|
|
273
|
-
|
|
258
|
+
request,
|
|
274
259
|
this.getJsonHeaders()
|
|
275
260
|
);
|
|
276
|
-
return assertApiResponse(envelope, "test/result/last");
|
|
277
261
|
}
|
|
278
262
|
/**
|
|
279
263
|
* POST test/result/history
|
|
280
264
|
* Returns the full test history for the authenticated patient.
|
|
281
265
|
*/
|
|
282
|
-
async getTestHistory(payload = {
|
|
283
|
-
|
|
266
|
+
async getTestHistory(payload = {
|
|
267
|
+
ExcludeStatus: "Invalid"
|
|
268
|
+
}) {
|
|
269
|
+
const request = {
|
|
270
|
+
Data: payload
|
|
271
|
+
};
|
|
272
|
+
return this.http.post(
|
|
284
273
|
this.url("test/result/history"),
|
|
285
|
-
|
|
274
|
+
request,
|
|
286
275
|
this.getJsonHeaders()
|
|
287
276
|
);
|
|
288
|
-
return assertApiResponse(envelope, "test/result/history");
|
|
289
277
|
}
|
|
290
278
|
/**
|
|
291
279
|
* POST test/result/details
|
|
@@ -296,51 +284,47 @@ var HCSafeCDXClient = class {
|
|
|
296
284
|
const payload = {
|
|
297
285
|
UserTestResultId: userTestResultId
|
|
298
286
|
};
|
|
287
|
+
const request = {
|
|
288
|
+
Data: payload
|
|
289
|
+
};
|
|
299
290
|
return this.http.post(
|
|
300
291
|
this.url("test/result/details"),
|
|
301
|
-
|
|
292
|
+
request,
|
|
302
293
|
this.getJsonHeaders()
|
|
303
294
|
);
|
|
304
295
|
}
|
|
305
296
|
/**
|
|
306
297
|
* POST test/result/pdf
|
|
307
|
-
*
|
|
298
|
+
* Requests the PDF result for a specific test result.
|
|
308
299
|
*/
|
|
309
300
|
async getResultPdf(payload) {
|
|
310
|
-
const
|
|
301
|
+
const request = {
|
|
302
|
+
Data: payload
|
|
303
|
+
};
|
|
304
|
+
return this.http.post(
|
|
311
305
|
this.url("test/result/pdf"),
|
|
312
|
-
|
|
306
|
+
request,
|
|
313
307
|
this.getJsonHeaders()
|
|
314
308
|
);
|
|
315
|
-
return assertApiResponse(envelope, "test/result/pdf");
|
|
316
309
|
}
|
|
317
310
|
/**
|
|
318
311
|
* POST test/result/image/capture
|
|
319
|
-
*
|
|
312
|
+
* Requests image capture data for a specific test result.
|
|
320
313
|
* NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
|
|
321
314
|
*/
|
|
322
315
|
async getImageCaptureUrl(userTestResultId) {
|
|
323
316
|
const payload = {
|
|
324
317
|
UserTestResultId: userTestResultId
|
|
325
318
|
};
|
|
319
|
+
const request = {
|
|
320
|
+
Data: payload
|
|
321
|
+
};
|
|
326
322
|
return this.http.post(
|
|
327
323
|
this.url("test/result/image/capture"),
|
|
328
|
-
|
|
324
|
+
request,
|
|
329
325
|
this.getJsonHeaders()
|
|
330
326
|
);
|
|
331
327
|
}
|
|
332
|
-
/**
|
|
333
|
-
* POST test/result/analytics
|
|
334
|
-
* Returns analytics data for test results.
|
|
335
|
-
*/
|
|
336
|
-
async getAnalytics(payload = {}) {
|
|
337
|
-
const envelope = await this.http.post(
|
|
338
|
-
this.url("test/result/analytics"),
|
|
339
|
-
wrapData(payload),
|
|
340
|
-
this.getJsonHeaders()
|
|
341
|
-
);
|
|
342
|
-
return assertApiResponse(envelope, "test/result/analytics");
|
|
343
|
-
}
|
|
344
328
|
// ---------------------------------------------------------------------------
|
|
345
329
|
// Resume / Answers / Finalize
|
|
346
330
|
// ---------------------------------------------------------------------------
|
|
@@ -353,36 +337,42 @@ var HCSafeCDXClient = class {
|
|
|
353
337
|
UserTestResultId: userTestResultId,
|
|
354
338
|
Resumed: resumed
|
|
355
339
|
};
|
|
356
|
-
const
|
|
340
|
+
const request = {
|
|
341
|
+
Data: payload
|
|
342
|
+
};
|
|
343
|
+
return this.http.post(
|
|
357
344
|
this.url("test/resume"),
|
|
358
|
-
|
|
345
|
+
request,
|
|
359
346
|
this.getJsonHeaders()
|
|
360
347
|
);
|
|
361
|
-
return assertApiResponse(envelope, "test/resume");
|
|
362
348
|
}
|
|
363
349
|
/**
|
|
364
350
|
* POST test/answers
|
|
365
351
|
* Submits analyte answers for a test attempt.
|
|
366
352
|
*/
|
|
367
353
|
async submitAnswers(payload) {
|
|
368
|
-
const
|
|
354
|
+
const request = {
|
|
355
|
+
Data: payload
|
|
356
|
+
};
|
|
357
|
+
return this.http.post(
|
|
369
358
|
this.url("test/answers"),
|
|
370
|
-
|
|
359
|
+
request,
|
|
371
360
|
this.getJsonHeaders()
|
|
372
361
|
);
|
|
373
|
-
return assertApiResponse(envelope, "test/answers");
|
|
374
362
|
}
|
|
375
363
|
/**
|
|
376
364
|
* POST test/finalize
|
|
377
|
-
* Finalizes a test
|
|
365
|
+
* Finalizes a test by UserTestResultId.
|
|
378
366
|
*/
|
|
379
367
|
async finalizeTest(payload) {
|
|
380
|
-
const
|
|
368
|
+
const request = {
|
|
369
|
+
Data: payload
|
|
370
|
+
};
|
|
371
|
+
return this.http.post(
|
|
381
372
|
this.url("test/finalize"),
|
|
382
|
-
|
|
373
|
+
request,
|
|
383
374
|
this.getJsonHeaders()
|
|
384
375
|
);
|
|
385
|
-
return assertApiResponse(envelope, "test/finalize");
|
|
386
376
|
}
|
|
387
377
|
};
|
|
388
378
|
|