@eka-care/ekascribe-ts-sdk 1.5.83 → 1.5.86

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.
Files changed (37) hide show
  1. package/dist/api/get-transaction-history.d.ts +5 -0
  2. package/dist/api/get-transaction-history.js +28 -0
  3. package/dist/api/get-voice-api-v2-config.d.ts +2 -0
  4. package/dist/api/get-voice-api-v2-config.js +26 -0
  5. package/dist/api/get-voice-api-v2-status.d.ts +51 -0
  6. package/dist/api/get-voice-api-v2-status.js +25 -0
  7. package/dist/api/get-voice-api-v3-status.d.ts +51 -0
  8. package/dist/api/get-voice-api-v3-status.js +26 -0
  9. package/dist/api/patch-transaction-status.d.ts +4 -0
  10. package/dist/api/patch-transaction-status.js +43 -0
  11. package/dist/api/post-transaction-commit.d.ts +3 -0
  12. package/dist/api/post-transaction-commit.js +32 -0
  13. package/dist/api/post-transaction-init.d.ts +3 -0
  14. package/dist/api/post-transaction-init.js +40 -0
  15. package/dist/api/post-transaction-stop.d.ts +3 -0
  16. package/dist/api/post-transaction-stop.js +32 -0
  17. package/dist/api/templates/post-convert-transaction-to-template.d.ts +3 -0
  18. package/dist/api/templates/post-convert-transaction-to-template.js +32 -0
  19. package/dist/api/transaction/get-voice-api-v2-config.d.ts +2 -0
  20. package/dist/api/transaction/get-voice-api-v2-config.js +26 -0
  21. package/dist/api/transaction/get-voice-api-v3-status-transcription.d.ts +61 -0
  22. package/dist/api/transaction/get-voice-api-v3-status-transcription.js +26 -0
  23. package/dist/audio-chunker/__tests__/audio-file-manager.test.d.ts +1 -0
  24. package/dist/audio-chunker/__tests__/audio-file-manager.test.js +5 -0
  25. package/dist/audio-chunker/audio-file-manager.js +29 -11
  26. package/dist/constants/types.d.ts +2 -2
  27. package/dist/index.d.ts +4 -0
  28. package/dist/index.js +5 -0
  29. package/dist/main/poll-output-summary.d.ts +49 -0
  30. package/dist/main/poll-output-summary.js +71 -0
  31. package/dist/shared-worker/s3-file-upload.js +110 -60
  32. package/dist/shared-worker/s3-file-upload.ts +128 -0
  33. package/dist/utils/search-sessions-by-patient-name.d.ts +7 -0
  34. package/dist/utils/search-sessions-by-patient-name.js +27 -0
  35. package/package.json +3 -4
  36. package/dist/shared-worker/worker-code.generated.d.ts +0 -1
  37. package/dist/shared-worker/worker-code.generated.js +0 -4
package/dist/index.d.ts CHANGED
@@ -37,6 +37,10 @@ declare class EkaScribe {
37
37
  getOutputTranscription({ txn_id }: {
38
38
  txn_id: string;
39
39
  }): Promise<TGetStatusResponse>;
40
+ pollSessionOutput(request: {
41
+ txn_id: string;
42
+ max_polling_time: number;
43
+ }): Promise<import("./main/poll-output-summary").TPollingResponse>;
40
44
  getSessionHistory({ txn_count }: {
41
45
  txn_count: number;
42
46
  }): Promise<TGetTransactionHistoryResponse>;
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ import { getConfigV2MyTemplates } from './api/config/get-voice-api-v2-config-my-
34
34
  import putVoiceApiV2Config from './api/config/patch-voice-api-v2-config';
35
35
  import postConvertTranscriptionToTemplate from './api/templates/post-convert-transcription-to-template';
36
36
  import { getVoiceApiV3StatusTranscript } from './api/transaction/get-voice-api-v3-status-transcript';
37
+ import { pollOutputSummary } from './main/poll-output-summary';
37
38
  class EkaScribe {
38
39
  // Private constructor to prevent direct instantiation
39
40
  constructor() {
@@ -251,6 +252,10 @@ class EkaScribe {
251
252
  };
252
253
  }
253
254
  }
255
+ async pollSessionOutput(request) {
256
+ const pollingResponse = await pollOutputSummary(request);
257
+ return pollingResponse;
258
+ }
254
259
  async getSessionHistory({ txn_count }) {
255
260
  try {
256
261
  const transactionsResponse = await getTransactionHistory({
@@ -0,0 +1,49 @@
1
+ import { TOutputSummary } from '../api/transaction/get-voice-api-v3-status';
2
+ interface IError {
3
+ code: string;
4
+ msg: string;
5
+ }
6
+ interface IADDITIONAL_DATA {
7
+ doctor: {
8
+ _id: string;
9
+ profile: {
10
+ personal: {
11
+ name: {
12
+ l: string;
13
+ f: string;
14
+ };
15
+ };
16
+ };
17
+ };
18
+ }
19
+ interface IApiResponse {
20
+ data: {
21
+ output: TOutputSummary[];
22
+ additional_data?: IADDITIONAL_DATA;
23
+ meta_data?: {
24
+ total_resources?: number;
25
+ total_parsed_resources?: number;
26
+ };
27
+ audio_matrix?: {
28
+ quality: string;
29
+ };
30
+ created_at?: string;
31
+ template_results: {
32
+ integration: TOutputSummary[];
33
+ custom: TOutputSummary[];
34
+ transcript?: TOutputSummary[];
35
+ };
36
+ };
37
+ error?: IError;
38
+ }
39
+ export type TPollingResponse = {
40
+ response?: IApiResponse | null;
41
+ status_code: number;
42
+ errorMessage?: string;
43
+ errorCode?: string;
44
+ };
45
+ export declare const pollOutputSummary: ({ txn_id, max_polling_time, }: {
46
+ txn_id: string;
47
+ max_polling_time: number;
48
+ }) => Promise<TPollingResponse>;
49
+ export {};
@@ -0,0 +1,71 @@
1
+ import { getVoiceApiV3Status } from '../api/transaction/get-voice-api-v3-status';
2
+ export const pollOutputSummary = async ({ txn_id, max_polling_time = 5 * 60 * 1000, }) => {
3
+ try {
4
+ const time = new Date().getTime();
5
+ const maxPollingTimeout = time + max_polling_time;
6
+ let failedCount = 0;
7
+ const getSummary = async () => {
8
+ // this try-catch block is needed to handle the errors of this recursive call
9
+ try {
10
+ const getResponse = await getVoiceApiV3Status({ txnId: txn_id });
11
+ const { status_code, response } = getResponse;
12
+ const currentTime = new Date().getTime();
13
+ if (currentTime >= maxPollingTimeout) {
14
+ const errorMessage = 'We encountered an error while fetching analysis results due to timeout. Please try again.';
15
+ return {
16
+ status_code: 500,
17
+ errorMessage,
18
+ };
19
+ }
20
+ if (status_code === 401 || status_code === 403) {
21
+ return {
22
+ response,
23
+ status_code,
24
+ errorMessage: 'Unauthorized or Forbidden',
25
+ };
26
+ }
27
+ if (status_code === 202 || status_code === 400 || status_code >= 500) {
28
+ if (status_code >= 400) {
29
+ failedCount++;
30
+ if (failedCount >= 3) {
31
+ return {
32
+ response,
33
+ status_code,
34
+ errorMessage: response?.error?.msg ||
35
+ `We encountered a backend error while fetching results. Please try again.`,
36
+ };
37
+ }
38
+ }
39
+ else {
40
+ failedCount = 0;
41
+ }
42
+ // await new Promise((resolve) => setTimeout(resolve, 1000));
43
+ return getSummary();
44
+ }
45
+ return {
46
+ response,
47
+ status_code,
48
+ };
49
+ }
50
+ catch (error) {
51
+ return {
52
+ status_code: -1, // -1: non-https status_code to distinguish backend's 500 status_code
53
+ errorMessage: `Something went wrong from inside catch block. ${error}`,
54
+ };
55
+ }
56
+ };
57
+ return getSummary();
58
+ }
59
+ catch (error) {
60
+ if (error instanceof Error && error.name === 'AbortError') {
61
+ return {
62
+ status_code: -1,
63
+ errorMessage: 'Request was aborted due to timeout.',
64
+ };
65
+ }
66
+ return {
67
+ status_code: -1,
68
+ errorMessage: `Something went wrong from outer catch block, ${error}`,
69
+ };
70
+ }
71
+ };