@healthcloudai/hc-safe-cdx 0.1.3 → 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/dist/index.d.cts CHANGED
@@ -2,167 +2,135 @@ import { HCLoginClient } from '@healthcloudai/hc-login-connector';
2
2
  import { HttpClient } from '@healthcloudai/hc-http';
3
3
 
4
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;
5
+ /**
6
+ * SDK callers pass only the inner payload; the client creates this wrapper.
7
+ */
8
+ interface ApiRequest<TPayload> {
9
+ Data: TPayload;
10
+ }
11
+ /**
12
+ * Successful standard Health Cloud API response envelope.
13
+ */
14
+ interface SuccessfulApiResponse<TData> {
15
+ IsOK: true;
16
+ Data: TData;
17
+ ErrorMessage: null;
18
+ }
19
+ /**
20
+ * Failed standard Health Cloud API response envelope.
21
+ */
22
+ interface FailedApiResponse<TData = unknown> {
23
+ IsOK: false;
24
+ Data: TData | null;
13
25
  ErrorMessage: string | null;
14
26
  }
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 ScanUpcOrderableData {
71
- _id: string | null;
72
- ShortName: string | null;
73
- CustomTestName: string | null;
74
- OrderableName: string | null;
75
- VendorTestID: string | null;
76
- SkuId: string | null;
77
- IsOrderable: boolean;
78
- IsSelfAssessmentMode: boolean;
79
- KitRegistrationRequired: boolean;
80
- RequiresResultsVerification: boolean;
81
- TestClassification: string | null;
82
- IsMLDisabled: boolean;
83
- IsPublicHealthReportingEnabled: boolean;
84
- IsActive: boolean;
85
- CaptureMethod: string | null;
86
- Created: string | null;
87
- Modified: string | null;
88
- ProductAssetDetail: unknown;
89
- DisclaimerDetail: unknown;
90
- ScanImageDetails: ScanUpcScanImageDetail | null;
91
- BillingDetail: ScanUpcBillingInfo | null;
92
- TestResults: ScanUpcTestResult[] | null;
93
- CollectionInstructionV2: ScanUpcInstruction[] | null;
94
- Articles: ScanUpcArticle[] | null;
95
- }
96
- interface ScanUpcResponseData {
97
- UserTestResultId: string | null;
98
- LegacyLabTestOrderable: {
99
- Data: ScanUpcOrderableData | null;
100
- } | null;
101
- }
27
+ /**
28
+ * Raw response received from endpoints that use the standard Health Cloud
29
+ * response envelope.
30
+ */
31
+ type ApiResponse<TData> = SuccessfulApiResponse<TData> | FailedApiResponse<TData>;
32
+ /**
33
+ * Successful inner/raw SafeCDX service result.
34
+ *
35
+ * Some endpoints return this directly.
36
+ * Other endpoints return it inside ApiResponse.Data.
37
+ */
38
+ interface SuccessfulServiceResult<TData> {
39
+ success: true;
40
+ data: TData;
41
+ message: string | null;
42
+ code: number;
43
+ }
44
+ /**
45
+ * Failed inner/raw SafeCDX service result.
46
+ */
47
+ interface FailedServiceResult<TData = unknown> {
48
+ success: false;
49
+ data: TData | null;
50
+ message: string | null;
51
+ code: number;
52
+ }
53
+ /**
54
+ * Service-level result used either directly or inside ApiResponse.Data.
55
+ */
56
+ type ServiceResult<TData> = SuccessfulServiceResult<TData> | FailedServiceResult<TData>;
57
+ /**
58
+ * Minimal entity reference returned by update/submit operations.
59
+ */
60
+ interface EntityReferenceData {
61
+ _id: string;
62
+ [key: string]: unknown;
63
+ }
64
+ /**
65
+ * Minimal test result summary used by pending/history responses.
66
+ */
67
+ interface TestResultSummary {
68
+ _id: string;
69
+ status: string | null;
70
+ testName?: string | null;
71
+ recordedDate?: string | null;
72
+ created?: string | null;
73
+ cvmlStatus?: string | null;
74
+ gtin?: string | null;
75
+ [key: string]: unknown;
76
+ }
77
+ /**
78
+ * Detailed result object returned by last-result and result-details routes.
79
+ */
80
+ interface TestResultDetails extends TestResultSummary {
81
+ gtin?: string | null;
82
+ cvmlStatus?: string | null;
83
+ finalized?: boolean;
84
+ resumed?: boolean;
85
+ [key: string]: unknown;
86
+ }
87
+ /**
88
+ * The nested test information used by the standard scan flow.
89
+ */
90
+ interface DiagnosticProfileTestInfo {
91
+ gtin: string;
92
+ cvmlTestName?: string | null;
93
+ isCVMLResult?: boolean;
94
+ [key: string]: unknown;
95
+ }
96
+ /**
97
+ * Only the nested diagnostic profile data required by SDK consumers is typed.
98
+ */
99
+ interface DiagnosticProfileData {
100
+ TestInfo: DiagnosticProfileTestInfo;
101
+ [key: string]: unknown;
102
+ }
103
+ /**
104
+ * Response data for resolving a test profile by GTIN.
105
+ *
106
+ */
102
107
  interface GetTestProfileByGTINData {
103
- ID: string | null;
104
- FHIRID: string | null;
105
- CQLID: string | null;
106
- TestName: string | null;
107
- CustomTestName: string | null;
108
- IsDeactivated: boolean;
109
- IsOrderable: boolean;
110
- EnablePublicHealthReporting: boolean;
111
- IsSelfAssessmentMode: boolean;
112
- CaptureMethod: number;
113
- IsMLDisabled: boolean;
114
- ShortName: string | null;
115
- DescriptionHTML: string | null;
116
- OrderableName: string | null;
117
- VendorName: string | null;
118
- ManufactureName: string | null;
119
- VendorTestID: string | null;
120
- Sku: string | null;
121
- LabTestType: string | null;
122
- TestClassification: string | null;
123
- DeviceFulfilmentPartner: string | null;
124
- FulfilmentPartnerCompediumId: string | null;
125
- KitRegistrationRequired: boolean;
126
- RequiresProviderVerificationOfResults: boolean;
127
- ShippingPartner: string | null;
128
- SpecimenTypeCode: string | null;
129
- SpecimenCollectionType: number;
130
- SpecimenSite: string | null;
131
- Frequency: number;
132
- UnitFrequency: number;
133
- ProcessingTime: number;
134
- UnitProcessingTime: number;
135
- DeviceDetails: unknown;
136
- Territories: ScanUpcTerritory[] | null;
137
- DiagnosticProfile: unknown;
138
- ProductAssetDetail: unknown;
139
- DisclaimerDetail: unknown;
140
- ScanImageDetail: ScanUpcScanImageDetail | null;
141
- Survey: unknown;
142
- Instructions: ScanUpcInstruction[] | null;
143
- BillingInfo: ScanUpcBillingInfo | null;
144
- Associations: unknown;
145
- TestReportAsset: unknown;
146
- Articles: ScanUpcArticle[] | null;
147
- TestResults: ScanUpcTestResult[] | null;
148
- GS1GTINs: string[] | null;
149
- Included: string[] | null;
150
- Analytes: ScanUpcAnalyte[] | null;
151
- LOINCCodes: unknown;
152
- TestLOINCCodes: unknown[];
153
- TestSNOMEDCTCodes: unknown[];
154
- Created: string | null;
155
- Modified: string | null;
156
- CreatedByID: string | null;
157
- ModifiedByID: string | null;
158
- TenantID: string | null;
159
- }
160
- interface GetTestProfileRequest {
161
- Gtin: string;
108
+ ID: string;
109
+ TestName?: string | null;
110
+ CustomTestName?: string | null;
111
+ DiagnosticProfile: DiagnosticProfileData;
112
+ [key: string]: unknown;
162
113
  }
163
114
  interface GetTestProfilesByAccountRequest {
164
115
  IncludeRegisterTestDetails: boolean;
165
116
  }
117
+ interface RegisterTestDetail {
118
+ title: string | null;
119
+ description: string | null;
120
+ buttonTitle: string | null;
121
+ imageURL: string | null;
122
+ [key: string]: unknown;
123
+ }
124
+ interface TestProfileByAccountItem {
125
+ gtin: string;
126
+ productName: string;
127
+ description: string | null;
128
+ testKitImageURL: string | null;
129
+ language: string | null;
130
+ registerTestDetail: RegisterTestDetail | null;
131
+ [key: string]: unknown;
132
+ }
133
+ type GetTestProfilesByAccountData = ServiceResult<TestProfileByAccountItem[]>;
166
134
  interface CreateUploadUrlRequest {
167
135
  Gtin: string;
168
136
  UserTestResultId: string;
@@ -170,96 +138,85 @@ interface CreateUploadUrlRequest {
170
138
  ImageType: string;
171
139
  };
172
140
  }
141
+ interface UploadMetadata {
142
+ UploadId: string;
143
+ Type: string | null;
144
+ File: string;
145
+ }
173
146
  interface CreateUploadUrlData {
174
- preSignedURL: string | null;
175
- Metadata: {
176
- UploadId: string | null;
177
- Type: string | null;
178
- File: string | null;
179
- } | null;
147
+ preSignedURL: string;
148
+ Metadata: UploadMetadata;
180
149
  }
181
150
  interface UpdateCvmlStatusRequest {
182
151
  ImageOfCaptureId: string;
183
152
  CvmlStatus: string;
184
153
  }
185
- interface GetPendingResultsRequest {
186
- ExcludeStatus?: string;
187
- }
188
- interface GetLastResultsRequest {
189
- ExcludeStatus?: string;
190
- }
191
- interface GetTestHistoryRequest {
192
- ExcludeStatus?: string;
193
- }
194
- interface GetResultDetailsRequest {
154
+ type UpdateCvmlStatusResponse = ServiceResult<EntityReferenceData>;
155
+ interface CvmlResultsData {
156
+ _id: string;
157
+ status: string | null;
158
+ cvmlStatus: string | null;
159
+ gtin: string | null;
160
+ resumed?: boolean;
161
+ [key: string]: unknown;
162
+ }
163
+ type GetCvmlResultsResponse = ServiceResult<CvmlResultsData>;
164
+ interface ExcludeStatusRequest {
165
+ ExcludeStatus: string;
166
+ }
167
+ type GetPendingResultsRequest = ExcludeStatusRequest;
168
+ type GetLastResultsRequest = ExcludeStatusRequest;
169
+ type GetTestHistoryRequest = ExcludeStatusRequest;
170
+ interface UserTestResultIdRequest {
195
171
  UserTestResultId: string;
196
172
  }
197
- interface GetResultPdfRequest {
198
- UserTestResultId: string;
199
- BirthDate?: string;
200
- FirstName?: string;
201
- LastName?: string;
202
- Gender?: string;
203
- }
204
- interface GetImageCaptureUrlRequest {
205
- UserTestResultId: string;
206
- }
207
- interface GetAnalyticsRequest {
208
- ExcludeStatus?: string;
209
- }
210
- interface ResumeFlowRequest {
211
- UserTestResultId: string;
173
+ type GetResultDetailsRequest = UserTestResultIdRequest;
174
+ type GetResultPdfRequest = UserTestResultIdRequest;
175
+ type GetImageCaptureUrlRequest = UserTestResultIdRequest;
176
+ type GetPendingResultsData = ServiceResult<TestResultSummary[]>;
177
+ type GetLastResultsData = ServiceResult<TestResultDetails>;
178
+ type GetTestHistoryData = ServiceResult<TestResultSummary[]>;
179
+ /**
180
+ * Raw service result returned directly by getResultDetails().
181
+ */
182
+ type GetResultDetailsResponse = ServiceResult<TestResultDetails>;
183
+ /**
184
+ * Standard API envelope Data returned by getResultPdf().
185
+ */
186
+ type GetResultPdfData = ServiceResult<string>;
187
+ /**
188
+ * Raw service result returned directly by getImageCaptureUrl().
189
+ */
190
+ type GetImageCaptureUrlResponse = ServiceResult<string>;
191
+ interface ResumeFlowRequest extends UserTestResultIdRequest {
212
192
  Resumed: boolean;
213
193
  }
194
+ interface ResumeFlowResult {
195
+ _id: string;
196
+ resumed: boolean;
197
+ cvmlStatus?: string | null;
198
+ [key: string]: unknown;
199
+ }
200
+ type ResumeFlowData = ServiceResult<ResumeFlowResult>;
214
201
  interface AnswerResult {
215
202
  Analyte: string;
216
203
  ReportedValue: string;
217
204
  StoredValue: string;
218
205
  Score: string;
219
206
  }
220
- interface SubmitAnswersRequest {
221
- UserTestResultId: string;
207
+ interface SubmitAnswersRequest extends UserTestResultIdRequest {
222
208
  Result: AnswerResult[];
223
209
  }
224
- interface CtaResult {
225
- Id?: string;
226
- Title?: string;
227
- Instructions?: string;
228
- UrlText?: string;
229
- Url?: string;
230
- }
231
- interface IndicationResult {
232
- Id?: string;
233
- Title?: string;
234
- Text?: string;
235
- RecommendTitle?: string;
236
- RecommendText?: string;
237
- CtaId?: string;
238
- }
239
- interface DecisionResultItem {
240
- IndicationId: string;
241
- Value: string;
242
- }
243
- interface DecisionResult {
244
- Calculation?: string;
245
- Results: DecisionResultItem[];
246
- }
247
- interface FinalizeTestRequest {
248
- UserTestResultId: string;
249
- CtaResult?: CtaResult;
250
- IndicationResult?: IndicationResult;
251
- DecisionResult?: DecisionResult;
252
- }
210
+ type SubmitAnswersData = ServiceResult<EntityReferenceData>;
211
+ type FinalizeTestRequest = UserTestResultIdRequest;
253
212
 
254
213
  declare class HCSafeCDXClient {
255
214
  private readonly http;
256
215
  private readonly auth;
257
- private readonly host;
258
- private readonly defaultLanguage;
259
- private readonly defaultImageType;
216
+ private readonly baseUrl;
260
217
  private apiKeyHeaderName?;
261
218
  private apiKeyValue?;
262
- constructor(httpClient: HttpClient, authClient: HCLoginClient, config: SafeCDXConfig);
219
+ constructor(httpClient: HttpClient, authClient: HCLoginClient);
263
220
  setApiKey(headerName: string, value: string): void;
264
221
  private getAuthHeaders;
265
222
  private getJsonHeaders;
@@ -269,17 +226,12 @@ declare class HCSafeCDXClient {
269
226
  * GET gs1/:gtin
270
227
  * Resolves a test profile by GTIN barcode and creates a UserTestResultId.
271
228
  */
272
- getTestProfileByGTIN(gtin: string, language?: string): Promise<ApiResponse<GetTestProfileByGTINData>>;
273
- /**
274
- * POST test/profile
275
- * Returns the full test profile for a given GTIN.
276
- */
277
- getTestProfile(payload: GetTestProfileRequest): Promise<ApiResponse<GetTestProfileByGTINData>>;
229
+ getTestProfileByGTIN(gtin: string): Promise<ApiResponse<GetTestProfileByGTINData>>;
278
230
  /**
279
231
  * POST test/profiles/by-account
280
232
  * Lists all test profiles available to the authenticated account.
281
233
  */
282
- getTestProfilesByAccount(payload?: GetTestProfilesByAccountRequest): Promise<ApiResponse<unknown>>;
234
+ getTestProfilesByAccount(payload?: GetTestProfilesByAccountRequest): Promise<ApiResponse<GetTestProfilesByAccountData>>;
283
235
  /**
284
236
  * POST upload/url
285
237
  * Requests a pre-signed S3 URL for image upload.
@@ -299,63 +251,58 @@ declare class HCSafeCDXClient {
299
251
  * Updates the ML processing status for a captured image.
300
252
  * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
301
253
  */
302
- updateCvmlStatus(imageOfCaptureId: string, cvmlStatus: string): Promise<unknown>;
254
+ updateCvmlStatus(imageOfCaptureId: string, cvmlStatus: string): Promise<UpdateCvmlStatusResponse>;
303
255
  /**
304
256
  * GET cvml/results
305
257
  * Polls ML analysis results for a captured image.
306
258
  * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
307
259
  */
308
- getCvmlResults(imageOfCaptureId: string): Promise<unknown>;
260
+ getCvmlResults(imageOfCaptureId: string): Promise<GetCvmlResultsResponse>;
309
261
  /**
310
262
  * POST test/result/pending
311
263
  * Returns test results in a pending/incomplete state.
312
264
  */
313
- getPendingResults(payload?: GetPendingResultsRequest): Promise<ApiResponse<unknown>>;
265
+ getPendingResults(payload?: GetPendingResultsRequest): Promise<ApiResponse<GetPendingResultsData>>;
314
266
  /**
315
267
  * POST test/result/last
316
268
  * Returns the most recent test result for the authenticated patient.
317
269
  */
318
- getLastResults(payload?: GetLastResultsRequest): Promise<ApiResponse<unknown>>;
270
+ getLastResults(payload?: GetLastResultsRequest): Promise<ApiResponse<GetLastResultsData>>;
319
271
  /**
320
272
  * POST test/result/history
321
273
  * Returns the full test history for the authenticated patient.
322
274
  */
323
- getTestHistory(payload?: GetTestHistoryRequest): Promise<ApiResponse<unknown>>;
275
+ getTestHistory(payload?: GetTestHistoryRequest): Promise<ApiResponse<GetTestHistoryData>>;
324
276
  /**
325
277
  * POST test/result/details
326
278
  * Returns detailed result data for a specific test attempt.
327
279
  * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
328
280
  */
329
- getResultDetails(userTestResultId: string): Promise<unknown>;
281
+ getResultDetails(userTestResultId: string): Promise<GetResultDetailsResponse>;
330
282
  /**
331
283
  * POST test/result/pdf
332
- * Generates a PDF report for a specific test result.
284
+ * Requests the PDF result for a specific test result.
333
285
  */
334
- getResultPdf(payload: GetResultPdfRequest): Promise<ApiResponse<unknown>>;
286
+ getResultPdf(payload: GetResultPdfRequest): Promise<ApiResponse<GetResultPdfData>>;
335
287
  /**
336
288
  * POST test/result/image/capture
337
- * Returns the image capture URL for a specific test result.
289
+ * Requests image capture data for a specific test result.
338
290
  * NOTE: Returns raw service result — no ApiResponse wrapper on this endpoint.
339
291
  */
340
- getImageCaptureUrl(userTestResultId: string): Promise<unknown>;
341
- /**
342
- * POST test/result/analytics
343
- * Returns analytics data for test results.
344
- */
345
- getAnalytics(payload?: GetAnalyticsRequest): Promise<ApiResponse<unknown>>;
292
+ getImageCaptureUrl(userTestResultId: string): Promise<GetImageCaptureUrlResponse>;
346
293
  /**
347
294
  * POST test/resume
348
295
  * Marks a test attempt as resumed (or not).
349
296
  */
350
- resumeFlow(userTestResultId: string, resumed?: boolean): Promise<ApiResponse<unknown>>;
297
+ resumeFlow(userTestResultId: string, resumed?: boolean): Promise<ApiResponse<ResumeFlowData>>;
351
298
  /**
352
299
  * POST test/answers
353
300
  * Submits analyte answers for a test attempt.
354
301
  */
355
- submitAnswers(payload: SubmitAnswersRequest): Promise<ApiResponse<unknown>>;
302
+ submitAnswers(payload: SubmitAnswersRequest): Promise<ApiResponse<SubmitAnswersData>>;
356
303
  /**
357
304
  * POST test/finalize
358
- * Finalizes a test attempt with CTA, indication, and decision results.
305
+ * Finalizes a test by UserTestResultId.
359
306
  */
360
307
  finalizeTest(payload: FinalizeTestRequest): Promise<ApiResponse<unknown>>;
361
308
  }
@@ -364,4 +311,4 @@ declare class ConfigError extends Error {
364
311
  constructor(message: string);
365
312
  }
366
313
 
367
- 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 ScanUpcAnalyte, type ScanUpcArticle, type ScanUpcBillingInfo, type ScanUpcInstruction, type ScanUpcOrderableData, type ScanUpcResponseData, type ScanUpcScanImageDetail, type ScanUpcTerritory, type ScanUpcTestResult, type SubmitAnswersRequest, type UpdateCvmlStatusRequest };
314
+ export { type AnswerResult, type ApiRequest, type ApiResponse, ConfigError, type CreateUploadUrlData, type CreateUploadUrlRequest, type CvmlResultsData, type DiagnosticProfileData, type DiagnosticProfileTestInfo, type EntityReferenceData, type Environment, type ExcludeStatusRequest, type FailedApiResponse, type FailedServiceResult, type FinalizeTestRequest, type GetCvmlResultsResponse, type GetImageCaptureUrlRequest, type GetImageCaptureUrlResponse, type GetLastResultsData, type GetLastResultsRequest, type GetPendingResultsData, type GetPendingResultsRequest, type GetResultDetailsRequest, type GetResultDetailsResponse, type GetResultPdfData, type GetResultPdfRequest, type GetTestHistoryData, type GetTestHistoryRequest, type GetTestProfileByGTINData, type GetTestProfilesByAccountData, type GetTestProfilesByAccountRequest, HCSafeCDXClient, type RegisterTestDetail, type ResumeFlowData, type ResumeFlowRequest, type ResumeFlowResult, type ServiceResult, type SubmitAnswersData, type SubmitAnswersRequest, type SuccessfulApiResponse, type SuccessfulServiceResult, type TestProfileByAccountItem, type TestResultDetails, type TestResultSummary, type UpdateCvmlStatusRequest, type UpdateCvmlStatusResponse, type UploadMetadata, type UserTestResultIdRequest };