@healthcloudai/hc-safe-cdx 0.0.1 → 0.1.2

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/dist/index.d.ts CHANGED
@@ -1,2 +1,376 @@
1
+ import { HCLoginClient } from '@healthcloudai/hc-login-connector';
2
+ import { HttpClient } from '@healthcloudai/hc-http';
1
3
 
2
- export { }
4
+ type Environment = "dev" | "uat" | "prod";
5
+ interface SafeCDXConfig {
6
+ environment: Environment;
7
+ defaultLanguage?: string;
8
+ defaultImageType?: string;
9
+ }
10
+ interface ApiResponse<T> {
11
+ IsOK: boolean;
12
+ Data: T | null;
13
+ ErrorMessage: string | null;
14
+ }
15
+ interface ScanUpcTerritory {
16
+ Code: string | null;
17
+ StateName: string | null;
18
+ IsEnabled: boolean;
19
+ }
20
+ interface ScanUpcScanImageDetail {
21
+ ImageUrl: string | null;
22
+ }
23
+ interface ScanUpcInstruction {
24
+ NavigationTitle: string | null;
25
+ Type: string | null;
26
+ Title: string | null;
27
+ Body: string | null;
28
+ ButtonTitle: string | null;
29
+ TimeInSeconds: number;
30
+ AutoStartTimer: boolean;
31
+ AutoContinue: boolean;
32
+ CanContinue: boolean;
33
+ IsFullscreenVideo: boolean;
34
+ ShowBackButton: boolean;
35
+ ImageUrl: string | null;
36
+ VideoUrl: string | null;
37
+ SequenceOrder: number;
38
+ ResumeInstructionHere: boolean;
39
+ }
40
+ interface ScanUpcBillingInfo {
41
+ Taxable: boolean;
42
+ }
43
+ interface ScanUpcArticle {
44
+ ImageUrl: string | null;
45
+ Title: string | null;
46
+ DateCreated: string | null;
47
+ Owner: string | null;
48
+ Status: string | null;
49
+ Actions: unknown;
50
+ }
51
+ interface ScanUpcTestResult {
52
+ PatientTestResult: number;
53
+ ResultTitle: string | null;
54
+ ResultDisplay: string | null;
55
+ ResultLongDescription: string | null;
56
+ TreatmentPlanDescription: string | null;
57
+ IsReturnToDashboardAllowed: boolean;
58
+ IsOrderTestAllowed: boolean;
59
+ IsFindTestRetailerAllowed: boolean;
60
+ }
61
+ interface ScanUpcAnalyte {
62
+ _id: string | null;
63
+ DisplayOrder: number;
64
+ Display: string | null;
65
+ Name: string | null;
66
+ Question: string | null;
67
+ Image: string | null;
68
+ Responses: unknown[];
69
+ }
70
+ interface Scan2DdmRequest {
71
+ Code: string;
72
+ ExternalQuestionnaireResultId?: string;
73
+ }
74
+ interface ScanUpcOrderableData {
75
+ _id: string | null;
76
+ ShortName: string | null;
77
+ CustomTestName: string | null;
78
+ OrderableName: string | null;
79
+ VendorTestID: string | null;
80
+ SkuId: string | null;
81
+ IsOrderable: boolean;
82
+ IsSelfAssessmentMode: boolean;
83
+ KitRegistrationRequired: boolean;
84
+ RequiresResultsVerification: boolean;
85
+ TestClassification: string | null;
86
+ IsMLDisabled: boolean;
87
+ IsPublicHealthReportingEnabled: boolean;
88
+ IsActive: boolean;
89
+ CaptureMethod: string | null;
90
+ Created: string | null;
91
+ Modified: string | null;
92
+ ProductAssetDetail: unknown;
93
+ DisclaimerDetail: unknown;
94
+ ScanImageDetails: ScanUpcScanImageDetail | null;
95
+ BillingDetail: ScanUpcBillingInfo | null;
96
+ TestResults: ScanUpcTestResult[] | null;
97
+ CollectionInstructionV2: ScanUpcInstruction[] | null;
98
+ Articles: ScanUpcArticle[] | null;
99
+ }
100
+ interface ScanUpcResponseData {
101
+ UserTestResultId: string | null;
102
+ LegacyLabTestOrderable: {
103
+ Data: ScanUpcOrderableData | null;
104
+ } | null;
105
+ }
106
+ interface GetTestProfileByGTINData {
107
+ ID: string | null;
108
+ FHIRID: string | null;
109
+ CQLID: string | null;
110
+ TestName: string | null;
111
+ CustomTestName: string | null;
112
+ IsDeactivated: boolean;
113
+ IsOrderable: boolean;
114
+ EnablePublicHealthReporting: boolean;
115
+ IsSelfAssessmentMode: boolean;
116
+ CaptureMethod: number;
117
+ IsMLDisabled: boolean;
118
+ ShortName: string | null;
119
+ DescriptionHTML: string | null;
120
+ OrderableName: string | null;
121
+ VendorName: string | null;
122
+ ManufactureName: string | null;
123
+ VendorTestID: string | null;
124
+ Sku: string | null;
125
+ LabTestType: string | null;
126
+ TestClassification: string | null;
127
+ DeviceFulfilmentPartner: string | null;
128
+ FulfilmentPartnerCompediumId: string | null;
129
+ KitRegistrationRequired: boolean;
130
+ RequiresProviderVerificationOfResults: boolean;
131
+ ShippingPartner: string | null;
132
+ SpecimenTypeCode: string | null;
133
+ SpecimenCollectionType: number;
134
+ SpecimenSite: string | null;
135
+ Frequency: number;
136
+ UnitFrequency: number;
137
+ ProcessingTime: number;
138
+ UnitProcessingTime: number;
139
+ DeviceDetails: unknown;
140
+ Territories: ScanUpcTerritory[] | null;
141
+ DiagnosticProfile: unknown;
142
+ ProductAssetDetail: unknown;
143
+ DisclaimerDetail: unknown;
144
+ ScanImageDetail: ScanUpcScanImageDetail | null;
145
+ Survey: unknown;
146
+ Instructions: ScanUpcInstruction[] | null;
147
+ BillingInfo: ScanUpcBillingInfo | null;
148
+ Associations: unknown;
149
+ TestReportAsset: unknown;
150
+ Articles: ScanUpcArticle[] | null;
151
+ TestResults: ScanUpcTestResult[] | null;
152
+ GS1GTINs: string[] | null;
153
+ Included: string[] | null;
154
+ Analytes: ScanUpcAnalyte[] | null;
155
+ LOINCCodes: unknown;
156
+ TestLOINCCodes: unknown[];
157
+ TestSNOMEDCTCodes: unknown[];
158
+ Created: string | null;
159
+ Modified: string | null;
160
+ CreatedByID: string | null;
161
+ ModifiedByID: string | null;
162
+ TenantID: string | null;
163
+ }
164
+ interface GetTestProfileRequest {
165
+ Gtin: string;
166
+ }
167
+ interface GetTestProfilesByAccountRequest {
168
+ IncludeRegisterTestDetails: boolean;
169
+ }
170
+ interface CreateUploadUrlRequest {
171
+ Gtin: string;
172
+ UserTestResultId: string;
173
+ Metadata: {
174
+ ImageType: string;
175
+ };
176
+ }
177
+ interface CreateUploadUrlData {
178
+ preSignedURL: string | null;
179
+ Metadata: {
180
+ UploadId: string | null;
181
+ Type: string | null;
182
+ File: string | null;
183
+ } | null;
184
+ }
185
+ interface UpdateCvmlStatusRequest {
186
+ ImageOfCaptureId: string;
187
+ CvmlStatus: string;
188
+ }
189
+ interface GetPendingResultsRequest {
190
+ ExcludeStatus?: string;
191
+ }
192
+ interface GetLastResultsRequest {
193
+ ExcludeStatus?: string;
194
+ }
195
+ interface GetTestHistoryRequest {
196
+ ExcludeStatus?: string;
197
+ }
198
+ interface GetResultDetailsRequest {
199
+ UserTestResultId: string;
200
+ }
201
+ interface GetResultPdfRequest {
202
+ UserTestResultId: string;
203
+ BirthDate?: string;
204
+ FirstName?: string;
205
+ LastName?: string;
206
+ Gender?: string;
207
+ }
208
+ interface GetImageCaptureUrlRequest {
209
+ UserTestResultId: string;
210
+ }
211
+ interface GetAnalyticsRequest {
212
+ ExcludeStatus?: string;
213
+ }
214
+ interface ResumeFlowRequest {
215
+ UserTestResultId: string;
216
+ Resumed: boolean;
217
+ }
218
+ interface AnswerResult {
219
+ Analyte: string;
220
+ ReportedValue: string;
221
+ StoredValue: string;
222
+ Score: string;
223
+ }
224
+ interface SubmitAnswersRequest {
225
+ UserTestResultId: string;
226
+ Result: AnswerResult[];
227
+ }
228
+ interface CtaResult {
229
+ Id?: string;
230
+ Title?: string;
231
+ Instructions?: string;
232
+ UrlText?: string;
233
+ Url?: string;
234
+ }
235
+ interface IndicationResult {
236
+ Id?: string;
237
+ Title?: string;
238
+ Text?: string;
239
+ RecommendTitle?: string;
240
+ RecommendText?: string;
241
+ CtaId?: string;
242
+ }
243
+ interface DecisionResultItem {
244
+ IndicationId: string;
245
+ Value: string;
246
+ }
247
+ interface DecisionResult {
248
+ Calculation?: string;
249
+ Results: DecisionResultItem[];
250
+ }
251
+ interface FinalizeTestRequest {
252
+ UserTestResultId: string;
253
+ CtaResult?: CtaResult;
254
+ IndicationResult?: IndicationResult;
255
+ DecisionResult?: DecisionResult;
256
+ }
257
+
258
+ declare class HCSafeCDXClient {
259
+ private readonly http;
260
+ private readonly auth;
261
+ private readonly host;
262
+ private readonly defaultLanguage;
263
+ private readonly defaultImageType;
264
+ private apiKeyHeaderName?;
265
+ private apiKeyValue?;
266
+ constructor(httpClient: HttpClient, authClient: HCLoginClient, config: SafeCDXConfig);
267
+ setApiKey(headerName: string, value: string): void;
268
+ private getAuthHeaders;
269
+ private getJsonHeaders;
270
+ private getApiKeyHeader;
271
+ private url;
272
+ /**
273
+ * GET gs1/:gtin
274
+ * Resolves a test profile by GTIN barcode and creates a UserTestResultId.
275
+ */
276
+ getTestProfileByGTIN(gtin: string, language?: string): Promise<ApiResponse<GetTestProfileByGTINData>>;
277
+ /**
278
+ * POST scan/2ddm
279
+ * Scans a 2D data matrix barcode and resolves a UserTestResultId.
280
+ */
281
+ scan2Ddm(payload: Scan2DdmRequest): Promise<ApiResponse<ScanUpcResponseData>>;
282
+ /**
283
+ * POST test/profile
284
+ * Returns the full test profile for a given GTIN.
285
+ */
286
+ getTestProfile(payload: GetTestProfileRequest): Promise<ApiResponse<GetTestProfileByGTINData>>;
287
+ /**
288
+ * POST test/profiles/by-account
289
+ * Lists all test profiles available to the authenticated account.
290
+ */
291
+ getTestProfilesByAccount(payload?: GetTestProfilesByAccountRequest): Promise<ApiResponse<unknown>>;
292
+ /**
293
+ * POST upload/url
294
+ * Requests a pre-signed S3 URL for image upload.
295
+ * Use the returned Data.preSignedURL and Data.Metadata.UploadId in the next steps.
296
+ */
297
+ createUploadUrl(userTestResultId: string, gtin: string, imageType?: string): Promise<ApiResponse<CreateUploadUrlData>>;
298
+ /**
299
+ * PUT preSignedURL — direct S3 upload, not a SafeCDX API route.
300
+ * preSignedURL comes from createUploadUrl() response: Data.preSignedURL.
301
+ *
302
+ * This intentionally does not use the shared HttpClient because the existing
303
+ * HttpClient.put() is JSON-oriented and stringifies the request body.
304
+ */
305
+ uploadImage(preSignedURL: string, image: BodyInit, contentType?: string): Promise<void>;
306
+ /**
307
+ * POST cvml/status
308
+ * Updates the ML processing status for a captured image.
309
+ * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
310
+ */
311
+ updateCvmlStatus(imageOfCaptureId: string, cvmlStatus: string): Promise<unknown>;
312
+ /**
313
+ * GET cvml/results
314
+ * Polls ML analysis results for a captured image.
315
+ * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
316
+ */
317
+ getCvmlResults(imageOfCaptureId: string): Promise<unknown>;
318
+ /**
319
+ * POST test/result/pending
320
+ * Returns test results in a pending/incomplete state.
321
+ */
322
+ getPendingResults(payload?: GetPendingResultsRequest): Promise<ApiResponse<unknown>>;
323
+ /**
324
+ * POST test/result/last
325
+ * Returns the most recent test result for the authenticated patient.
326
+ */
327
+ getLastResults(payload?: GetLastResultsRequest): Promise<ApiResponse<unknown>>;
328
+ /**
329
+ * POST test/result/history
330
+ * Returns the full test history for the authenticated patient.
331
+ */
332
+ getTestHistory(payload?: GetTestHistoryRequest): Promise<ApiResponse<unknown>>;
333
+ /**
334
+ * POST test/result/details
335
+ * Returns detailed result data for a specific test attempt.
336
+ * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
337
+ */
338
+ getResultDetails(userTestResultId: string): Promise<unknown>;
339
+ /**
340
+ * POST test/result/pdf
341
+ * Generates a PDF report for a specific test result.
342
+ */
343
+ getResultPdf(payload: GetResultPdfRequest): Promise<ApiResponse<unknown>>;
344
+ /**
345
+ * POST test/result/image/capture
346
+ * Returns the image capture URL for a specific test result.
347
+ * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
348
+ */
349
+ getImageCaptureUrl(userTestResultId: string): Promise<unknown>;
350
+ /**
351
+ * POST test/result/analytics
352
+ * Returns analytics data for test results.
353
+ */
354
+ getAnalytics(payload?: GetAnalyticsRequest): Promise<ApiResponse<unknown>>;
355
+ /**
356
+ * POST test/resume
357
+ * Marks a test attempt as resumed (or not).
358
+ */
359
+ resumeFlow(userTestResultId: string, resumed?: boolean): Promise<ApiResponse<unknown>>;
360
+ /**
361
+ * POST test/answers
362
+ * Submits analyte answers for a test attempt.
363
+ */
364
+ submitAnswers(payload: SubmitAnswersRequest): Promise<ApiResponse<unknown>>;
365
+ /**
366
+ * POST test/finalize
367
+ * Finalizes a test attempt with CTA, indication, and decision results.
368
+ */
369
+ finalizeTest(payload: FinalizeTestRequest): Promise<ApiResponse<unknown>>;
370
+ }
371
+
372
+ declare class ConfigError extends Error {
373
+ constructor(message: string);
374
+ }
375
+
376
+ export { type AnswerResult, type ApiResponse, ConfigError, type CreateUploadUrlData, type CreateUploadUrlRequest, type CtaResult, type DecisionResult, type DecisionResultItem, type Environment, type FinalizeTestRequest, type GetAnalyticsRequest, type GetImageCaptureUrlRequest, type GetLastResultsRequest, type GetPendingResultsRequest, type GetResultDetailsRequest, type GetResultPdfRequest, type GetTestHistoryRequest, type GetTestProfileByGTINData, type GetTestProfileRequest, type GetTestProfilesByAccountRequest, HCSafeCDXClient, type IndicationResult, type ResumeFlowRequest, type SafeCDXConfig, type Scan2DdmRequest, type ScanUpcAnalyte, type ScanUpcArticle, type ScanUpcBillingInfo, type ScanUpcInstruction, type ScanUpcOrderableData, type ScanUpcResponseData, type ScanUpcScanImageDetail, type ScanUpcTerritory, type ScanUpcTestResult, type SubmitAnswersRequest, type UpdateCvmlStatusRequest };