pih-appointment-widget 0.0.38 → 0.0.39

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.
@@ -14,16 +14,15 @@ const getApi = async function (url) {
14
14
  method: "GET",
15
15
  headers: {
16
16
  "Content-Type": "application/json",
17
- "Authorization": "".concat(token)
17
+ "Authorization": `${token}`
18
18
  // "X-CLIENT-APP": header,
19
19
  }
20
20
  };
21
21
  return fetch(urlWithParams, options).then(async response => {
22
22
  const data = await response.json().catch(() => ({}));
23
23
  if (!response.ok) {
24
- var _data$resultInfo;
25
24
  return {
26
- err: (data === null || data === void 0 || (_data$resultInfo = data.resultInfo) === null || _data$resultInfo === void 0 ? void 0 : _data$resultInfo.message) || "Something went wrong!",
25
+ err: data?.resultInfo?.message || "Something went wrong!",
27
26
  status: response.status
28
27
  };
29
28
  }
@@ -31,7 +30,7 @@ const getApi = async function (url) {
31
30
  }).catch(error => {
32
31
  console.error("Fetch error:", error);
33
32
  return {
34
- err: (error === null || error === void 0 ? void 0 : error.message) || String(error) || "Network error"
33
+ err: error?.message || String(error) || "Network error"
35
34
  };
36
35
  });
37
36
  };
@@ -57,9 +56,8 @@ const postApi = async function (url) {
57
56
  return fetch(urlWithParams.toString(), options).then(async response => {
58
57
  const data = await response.json().catch(() => ({}));
59
58
  if (!response.ok) {
60
- var _data$resultInfo2;
61
59
  return {
62
- err: (data === null || data === void 0 || (_data$resultInfo2 = data.resultInfo) === null || _data$resultInfo2 === void 0 ? void 0 : _data$resultInfo2.message) || "Something went wrong!",
60
+ err: data?.resultInfo?.message || "Something went wrong!",
63
61
  status: response.status
64
62
  };
65
63
  }
@@ -72,18 +70,18 @@ const postApi = async function (url) {
72
70
  });
73
71
  };
74
72
 
75
- /**
76
- * SSO login: exchange idToken + email for app token.
77
- * @param {string} apiBaseUrl - e.g. https://afiyaapiqa.powermindinc.com
78
- * @param {string} hospitalId - e.g. dMtEGhak
79
- * @param {string} idToken - JWT id token from auth provider
80
- * @param {string} email - User email
81
- * @returns {Promise<{ token?: string, err?: string, ... }>} - Response with token on success, or { err } on failure
73
+ /**
74
+ * SSO login: exchange idToken + email for app token.
75
+ * @param {string} apiBaseUrl - e.g. https://afiyaapiqa.powermindinc.com
76
+ * @param {string} hospitalId - e.g. dMtEGhak
77
+ * @param {string} idToken - JWT id token from auth provider
78
+ * @param {string} email - User email
79
+ * @returns {Promise<{ token?: string, err?: string, ... }>} - Response with token on success, or { err } on failure
82
80
  */
83
81
  exports.postApi = postApi;
84
82
  const getTokenFromSso = async (apiBaseUrl, hospitalId, idToken, email) => {
85
83
  const base = apiBaseUrl.replace(/\/$/, "");
86
- const url = "".concat(base, "/um/user/V1/sso/login?hospitalId=").concat(encodeURIComponent(hospitalId));
84
+ const url = `${base}/um/user/V1/sso/login?hospitalId=${encodeURIComponent(hospitalId)}`;
87
85
  const options = {
88
86
  method: "POST",
89
87
  headers: {
@@ -105,8 +103,7 @@ const getTokenFromSso = async (apiBaseUrl, hospitalId, idToken, email) => {
105
103
  console.log("[getTokenFromSso] response status", response.status, response.statusText);
106
104
  if (!response.ok) {
107
105
  return response.json().then(errorData => {
108
- var _errorData$resultInfo;
109
- const errorMessage = (errorData === null || errorData === void 0 || (_errorData$resultInfo = errorData.resultInfo) === null || _errorData$resultInfo === void 0 ? void 0 : _errorData$resultInfo.message) || "SSO login failed";
106
+ const errorMessage = errorData?.resultInfo?.message || "SSO login failed";
110
107
  console.log("[getTokenFromSso] error body", errorData);
111
108
  return {
112
109
  err: errorMessage,
@@ -118,11 +115,10 @@ const getTokenFromSso = async (apiBaseUrl, hospitalId, idToken, email) => {
118
115
  }));
119
116
  }
120
117
  return response.json().then(data => {
121
- var _data$data;
122
118
  console.log("[getTokenFromSso] success", {
123
119
  hasData: !!data,
124
120
  dataKeys: data ? Object.keys(data) : [],
125
- hasAccessToken: !!(data !== null && data !== void 0 && (_data$data = data.data) !== null && _data$data !== void 0 && _data$data.access_token)
121
+ hasAccessToken: !!data?.data?.access_token
126
122
  });
127
123
  return data;
128
124
  });
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ICD_MODE = void 0;
7
7
  exports.getICDSuggestions = getICDSuggestions;
8
8
  var _apiConfig = require("../constants/apiConfig");
9
- /**
10
- * icdService.js
11
- * Calls the Afiya ICD suggestion API.
12
- *
13
- * POST /insurance/api/icd/suggest
14
- * Body: { query: string, mode: ICD_MODE }
9
+ /**
10
+ * icdService.js
11
+ * Calls the Afiya ICD suggestion API.
12
+ *
13
+ * POST /insurance/api/icd/suggest
14
+ * Body: { query: string, mode: ICD_MODE }
15
15
  */
16
16
 
17
- /**
18
- * Enum for ICD suggest API modes.
19
- * Use these constants everywhere — never hardcode the string values.
20
- *
21
- * @readonly
22
- * @enum {string}
17
+ /**
18
+ * Enum for ICD suggest API modes.
19
+ * Use these constants everywhere — never hardcode the string values.
20
+ *
21
+ * @readonly
22
+ * @enum {string}
23
23
  */
24
24
  const ICD_MODE = exports.ICD_MODE = Object.freeze({
25
25
  /** Real-time ICD-10 code lookup (fast, no AI) */
@@ -29,15 +29,14 @@ const ICD_MODE = exports.ICD_MODE = Object.freeze({
29
29
  /** Backend decides best strategy automatically */
30
30
  AUTO: "AUTO"
31
31
  });
32
- const SUGGEST_URL = "".concat(_apiConfig.API_BASE_URL, "/insurance/api/icd/suggest");
32
+ const SUGGEST_URL = `${_apiConfig.API_BASE_URL}/insurance/api/icd/suggest`;
33
33
 
34
- /**
35
- * @param {string} query - Plain-language diagnosis / procedure
36
- * @param {"ICD_ONLY"|"CLAUDE_ONLY"|"AUTO"} mode
37
- * @returns {Promise<{ matches: Array<{ code, description, reason }>, note: string }>}
34
+ /**
35
+ * @param {string} query - Plain-language diagnosis / procedure
36
+ * @param {"ICD_ONLY"|"CLAUDE_ONLY"|"AUTO"} mode
37
+ * @returns {Promise<{ matches: Array<{ code, description, reason }>, note: string }>}
38
38
  */
39
39
  async function getICDSuggestions(query, mode) {
40
- var _data$data;
41
40
  if (!query || !query.trim()) throw new Error("Query cannot be empty");
42
41
  const response = await fetch(SUGGEST_URL, {
43
42
  method: "POST",
@@ -50,18 +49,17 @@ async function getICDSuggestions(query, mode) {
50
49
  })
51
50
  });
52
51
  if (!response.ok) {
53
- var _errBody$error;
54
52
  const errBody = await response.json().catch(() => ({}));
55
- const msg = (errBody === null || errBody === void 0 ? void 0 : errBody.message) || (errBody === null || errBody === void 0 || (_errBody$error = errBody.error) === null || _errBody$error === void 0 ? void 0 : _errBody$error.message) || "API error: ".concat(response.status, " ").concat(response.statusText);
53
+ const msg = errBody?.message || errBody?.error?.message || `API error: ${response.status} ${response.statusText}`;
56
54
  throw new Error(msg);
57
55
  }
58
56
  const data = await response.json();
59
57
 
60
58
  // API wraps response in { data: { matches, note, ... }, resultInfo }
61
- const payload = (_data$data = data === null || data === void 0 ? void 0 : data.data) !== null && _data$data !== void 0 ? _data$data : data;
59
+ const payload = data?.data ?? data;
62
60
 
63
61
  // Normalise response → always return { matches, note }
64
- if (Array.isArray(payload === null || payload === void 0 ? void 0 : payload.matches)) {
62
+ if (Array.isArray(payload?.matches)) {
65
63
  return {
66
64
  matches: payload.matches,
67
65
  note: payload.note || ""
@@ -73,7 +71,7 @@ async function getICDSuggestions(query, mode) {
73
71
  note: ""
74
72
  };
75
73
  }
76
- if (Array.isArray(payload === null || payload === void 0 ? void 0 : payload.results)) {
74
+ if (Array.isArray(payload?.results)) {
77
75
  return {
78
76
  matches: payload.results.map(r => ({
79
77
  code: r.code,
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "pih-appointment-widget",
3
- "version": "0.0.38",
4
- "main": "dist/App.js",
5
- "module": "dist/App.js",
6
- "exports": {
7
- ".": {
8
- "require": "./dist/App.js",
9
- "import": "./dist/App.js"
10
- }
11
- },
12
- "dependencies": {
13
- "@babel/cli": "^7.25.9",
14
- "@testing-library/jest-dom": "^5.17.0",
15
- "@testing-library/react": "^13.4.0",
16
- "@testing-library/user-event": "^13.5.0",
17
- "@zoom/videosdk": "^2.1.10",
18
- "@zoomus/websdk": "^2.18.3",
19
- "crypto": "^1.0.1",
20
- "crypto-js": "^4.2.0",
21
- "react": "^18.3.1",
22
- "react-dom": "^18.3.1",
23
- "react-scripts": "5.0.1",
24
- "web-vitals": "^2.1.4"
25
- },
26
- "scripts": {
27
- "build": "babel src -d dist",
28
- "build:roll": "rollup -c",
29
- "prepublishOnly": "npm run build",
30
- "start": "react-scripts start",
31
- "test": "react-scripts test",
32
- "eject": "react-scripts eject"
33
- },
34
- "eslintConfig": {
35
- "extends": [
36
- "react-app",
37
- "react-app/jest"
38
- ]
39
- },
40
- "browserslist": {
41
- "production": [
42
- ">0.2%",
43
- "not dead",
44
- "not op_mini all"
45
- ],
46
- "development": [
47
- "last 1 chrome version",
48
- "last 1 firefox version",
49
- "last 1 safari version"
50
- ]
51
- },
52
- "peerDependencies": {
53
- "axios": "^1.8.4"
54
- },
55
- "devDependencies": {
56
- "@babel/core": "^7.26.0",
57
- "@babel/preset-env": "^7.26.0",
58
- "@babel/preset-react": "^7.26.3",
59
- "@rollup/plugin-babel": "^6.0.4",
60
- "@rollup/plugin-commonjs": "^28.0.9",
61
- "@rollup/plugin-image": "^3.0.3",
62
- "@rollup/plugin-node-resolve": "^15.3.1",
63
- "axios": "1.8.4",
64
- "rollup": "^2.79.2",
65
- "rollup-plugin-terser": "^7.0.2"
66
- }
67
- }
1
+ {
2
+ "name": "pih-appointment-widget",
3
+ "version": "0.0.39",
4
+ "main": "dist/App.js",
5
+ "module": "dist/App.js",
6
+ "exports": {
7
+ ".": {
8
+ "require": "./dist/App.js",
9
+ "import": "./dist/App.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "@babel/cli": "^7.25.9",
14
+ "@testing-library/jest-dom": "^5.17.0",
15
+ "@testing-library/react": "^13.4.0",
16
+ "@testing-library/user-event": "^13.5.0",
17
+ "@zoom/videosdk": "^2.1.10",
18
+ "@zoomus/websdk": "^2.18.3",
19
+ "crypto": "^1.0.1",
20
+ "crypto-js": "^4.2.0",
21
+ "react": "^18.3.1",
22
+ "react-dom": "^18.3.1",
23
+ "react-scripts": "5.0.1",
24
+ "web-vitals": "^2.1.4"
25
+ },
26
+ "scripts": {
27
+ "build": "babel src -d dist",
28
+ "build:roll": "rollup -c",
29
+ "prepublishOnly": "npm run build",
30
+ "start": "react-scripts start",
31
+ "test": "react-scripts test",
32
+ "eject": "react-scripts eject"
33
+ },
34
+ "eslintConfig": {
35
+ "extends": [
36
+ "react-app",
37
+ "react-app/jest"
38
+ ]
39
+ },
40
+ "browserslist": {
41
+ "production": [
42
+ ">0.2%",
43
+ "not dead",
44
+ "not op_mini all"
45
+ ],
46
+ "development": [
47
+ "last 1 chrome version",
48
+ "last 1 firefox version",
49
+ "last 1 safari version"
50
+ ]
51
+ },
52
+ "peerDependencies": {
53
+ "axios": "^1.8.4"
54
+ },
55
+ "devDependencies": {
56
+ "@babel/core": "^7.26.0",
57
+ "@babel/preset-env": "^7.26.0",
58
+ "@babel/preset-react": "^7.26.3",
59
+ "@rollup/plugin-babel": "^6.0.4",
60
+ "@rollup/plugin-commonjs": "^28.0.9",
61
+ "@rollup/plugin-image": "^3.0.3",
62
+ "@rollup/plugin-node-resolve": "^15.3.1",
63
+ "axios": "1.8.4",
64
+ "rollup": "^2.79.2",
65
+ "rollup-plugin-terser": "^7.0.2"
66
+ }
67
+ }
package/public/index.html CHANGED
@@ -1,43 +1,43 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="theme-color" content="#000000" />
8
- <meta
9
- name="description"
10
- content="Web site created using create-react-app"
11
- />
12
- <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
- <!--
14
- manifest.json provides metadata used when your web app is installed on a
15
- user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
- -->
17
- <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
- <!--
19
- Notice the use of %PUBLIC_URL% in the tags above.
20
- It will be replaced with the URL of the `public` folder during the build.
21
- Only files inside the `public` folder can be referenced from the HTML.
22
-
23
- Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
- work correctly both with client-side routing and a non-root public URL.
25
- Learn how to configure a non-root public URL by running `npm run build`.
26
- -->
27
- <title>React App</title>
28
- </head>
29
- <body style="margin: 0;">
30
- <noscript>You need to enable JavaScript to run this app.</noscript>
31
- <div id="root"></div>
32
- <!--
33
- This HTML file is a template.
34
- If you open it directly in the browser, you will see an empty page.
35
-
36
- You can add webfonts, meta tags, or analytics to this file.
37
- The build step will place the bundled scripts into the <body> tag.
38
-
39
- To begin the development, run `npm start` or `yarn start`.
40
- To create a production bundle, use `npm run build` or `yarn build`.
41
- -->
42
- </body>
43
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="theme-color" content="#000000" />
8
+ <meta
9
+ name="description"
10
+ content="Web site created using create-react-app"
11
+ />
12
+ <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13
+ <!--
14
+ manifest.json provides metadata used when your web app is installed on a
15
+ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16
+ -->
17
+ <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18
+ <!--
19
+ Notice the use of %PUBLIC_URL% in the tags above.
20
+ It will be replaced with the URL of the `public` folder during the build.
21
+ Only files inside the `public` folder can be referenced from the HTML.
22
+
23
+ Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24
+ work correctly both with client-side routing and a non-root public URL.
25
+ Learn how to configure a non-root public URL by running `npm run build`.
26
+ -->
27
+ <title>React App</title>
28
+ </head>
29
+ <body style="margin: 0;">
30
+ <noscript>You need to enable JavaScript to run this app.</noscript>
31
+ <div id="root"></div>
32
+ <!--
33
+ This HTML file is a template.
34
+ If you open it directly in the browser, you will see an empty page.
35
+
36
+ You can add webfonts, meta tags, or analytics to this file.
37
+ The build step will place the bundled scripts into the <body> tag.
38
+
39
+ To begin the development, run `npm start` or `yarn start`.
40
+ To create a production bundle, use `npm run build` or `yarn build`.
41
+ -->
42
+ </body>
43
+ </html>
@@ -1,25 +1,25 @@
1
- {
2
- "short_name": "React App",
3
- "name": "Create React App Sample",
4
- "icons": [
5
- {
6
- "src": "favicon.ico",
7
- "sizes": "64x64 32x32 24x24 16x16",
8
- "type": "image/x-icon"
9
- },
10
- {
11
- "src": "logo192.png",
12
- "type": "image/png",
13
- "sizes": "192x192"
14
- },
15
- {
16
- "src": "logo512.png",
17
- "type": "image/png",
18
- "sizes": "512x512"
19
- }
20
- ],
21
- "start_url": ".",
22
- "display": "standalone",
23
- "theme_color": "#000000",
24
- "background_color": "#ffffff"
25
- }
1
+ {
2
+ "short_name": "React App",
3
+ "name": "Create React App Sample",
4
+ "icons": [
5
+ {
6
+ "src": "favicon.ico",
7
+ "sizes": "64x64 32x32 24x24 16x16",
8
+ "type": "image/x-icon"
9
+ },
10
+ {
11
+ "src": "logo192.png",
12
+ "type": "image/png",
13
+ "sizes": "192x192"
14
+ },
15
+ {
16
+ "src": "logo512.png",
17
+ "type": "image/png",
18
+ "sizes": "512x512"
19
+ }
20
+ ],
21
+ "start_url": ".",
22
+ "display": "standalone",
23
+ "theme_color": "#000000",
24
+ "background_color": "#ffffff"
25
+ }
package/public/robots.txt CHANGED
@@ -1,3 +1,3 @@
1
- # https://www.robotstxt.org/robotstxt.html
2
- User-agent: *
3
- Disallow:
1
+ # https://www.robotstxt.org/robotstxt.html
2
+ User-agent: *
3
+ Disallow:
package/rollup.config.js CHANGED
@@ -1,43 +1,43 @@
1
- import { terser } from 'rollup-plugin-terser'; // For minification
2
- import resolve from '@rollup/plugin-node-resolve'; // To resolve npm dependencies
3
- import commonjs from '@rollup/plugin-commonjs'; // To handle CommonJS modules
4
- import babel from '@rollup/plugin-babel'; // To transpile with Babel
5
- import image from '@rollup/plugin-image';
6
-
7
- export default {
8
- input: 'src/App.js', // Path to your package's main entry point
9
- output: [
10
- {
11
- file: 'dist/pih-appointment-widget.umd.js', // UMD build output file
12
- format: 'umd', // UMD format
13
- name: 'MyPackage', // Global variable name (use a unique name)
14
- globals: {
15
- react: 'React', // Define global variable for React
16
- 'react-dom': 'ReactDOM', // Define global variable for ReactDOM
17
- axios: 'axios', // Add axios here as well if you want to expose it globally
18
- },
19
- },
20
- {
21
- file: 'dist/pih-appointment-widget.umd.min.js', // UMD minified output
22
- format: 'umd',
23
- name: 'MyPackage',
24
- plugins: [terser()], // Minify the output
25
- globals: {
26
- react: 'React', // Define global variable for React
27
- 'react-dom': 'ReactDOM', // Define global variable for ReactDOM
28
- axios: 'axios', // Minified version should still handle axios externally
29
- },
30
- },
31
- ],
32
- plugins: [
33
- image(),
34
- resolve(), // Resolve modules from node_modules
35
- babel({
36
- exclude: 'node_modules/**', // Exclude transpiling node_modules
37
- presets: ['@babel/preset-env', '@babel/preset-react'], // Use Babel presets
38
- babelHelpers: 'bundled', // Ensure the correct Babel helper functions are included
39
- }),
40
- commonjs(), // Convert CommonJS modules to ES6
41
- ],
42
- external: ['react', 'react-dom', 'axios'], // Mark react, react-dom, and axios as external dependencies
43
- };
1
+ import { terser } from 'rollup-plugin-terser'; // For minification
2
+ import resolve from '@rollup/plugin-node-resolve'; // To resolve npm dependencies
3
+ import commonjs from '@rollup/plugin-commonjs'; // To handle CommonJS modules
4
+ import babel from '@rollup/plugin-babel'; // To transpile with Babel
5
+ import image from '@rollup/plugin-image';
6
+
7
+ export default {
8
+ input: 'src/App.js', // Path to your package's main entry point
9
+ output: [
10
+ {
11
+ file: 'dist/pih-appointment-widget.umd.js', // UMD build output file
12
+ format: 'umd', // UMD format
13
+ name: 'MyPackage', // Global variable name (use a unique name)
14
+ globals: {
15
+ react: 'React', // Define global variable for React
16
+ 'react-dom': 'ReactDOM', // Define global variable for ReactDOM
17
+ axios: 'axios', // Add axios here as well if you want to expose it globally
18
+ },
19
+ },
20
+ {
21
+ file: 'dist/pih-appointment-widget.umd.min.js', // UMD minified output
22
+ format: 'umd',
23
+ name: 'MyPackage',
24
+ plugins: [terser()], // Minify the output
25
+ globals: {
26
+ react: 'React', // Define global variable for React
27
+ 'react-dom': 'ReactDOM', // Define global variable for ReactDOM
28
+ axios: 'axios', // Minified version should still handle axios externally
29
+ },
30
+ },
31
+ ],
32
+ plugins: [
33
+ image(),
34
+ resolve(), // Resolve modules from node_modules
35
+ babel({
36
+ exclude: 'node_modules/**', // Exclude transpiling node_modules
37
+ presets: ['@babel/preset-env', '@babel/preset-react'], // Use Babel presets
38
+ babelHelpers: 'bundled', // Ensure the correct Babel helper functions are included
39
+ }),
40
+ commonjs(), // Convert CommonJS modules to ES6
41
+ ],
42
+ external: ['react', 'react-dom', 'axios'], // Mark react, react-dom, and axios as external dependencies
43
+ };
package/src/App.js CHANGED
@@ -1,50 +1,50 @@
1
- import React from "react";
2
- import ReactDOM from "react-dom";
3
- import AppointmentPage, { PIH_APPOINTMENT_WIDGET_CLASS } from "./components/AppointmentPage.js";
4
- import ICD10Assistant from "./components/ICD10Assistant.jsx";
5
-
6
- let bookingWidgetInstance = null;
7
-
8
- // SDK for embedding appointment widget
9
- const BookingSDK = {
10
- /**
11
- * Show appointment widget with configuration
12
- * @param {object} config - Configuration object
13
- * @param {string} config.apiBaseUrl - Base URL for API
14
- * @param {string} config.hospitalId - Hospital ID
15
- * @param {number} config.doctorId - Doctor ID
16
- * @param {string} config.joinCallUrl - Video call URL
17
- * @param {function} onAction - Optional callback for actions
18
- */
19
- showWidget: (config, onAction) => {
20
- if (!bookingWidgetInstance) {
21
- bookingWidgetInstance = document.createElement("div");
22
- document.body.appendChild(bookingWidgetInstance);
23
- }
24
-
25
- const PopupWrapper = () => {
26
- return (
27
- <>
28
- <AppointmentPage config={config} />
29
- {config.showIcdAssistant && <ICD10Assistant />}
30
- </>
31
- );
32
- };
33
-
34
- ReactDOM.render(<PopupWrapper />, bookingWidgetInstance);
35
- },
36
-
37
- closePopup: () => {
38
- if (bookingWidgetInstance) {
39
- ReactDOM.unmountComponentAtNode(bookingWidgetInstance);
40
- bookingWidgetInstance = null;
41
- }
42
- },
43
- };
44
-
45
- // Expose SDK globally for non-React apps
46
- window.BookingSDK = BookingSDK;
47
-
48
- // Export for React/module usage
49
- export { AppointmentPage, ICD10Assistant, PIH_APPOINTMENT_WIDGET_CLASS };
50
- export default BookingSDK;
1
+ import React from "react";
2
+ import ReactDOM from "react-dom";
3
+ import AppointmentPage, { PIH_APPOINTMENT_WIDGET_CLASS } from "./components/AppointmentPage.js";
4
+ import ICD10Assistant from "./components/ICD10Assistant.jsx";
5
+
6
+ let bookingWidgetInstance = null;
7
+
8
+ // SDK for embedding appointment widget
9
+ const BookingSDK = {
10
+ /**
11
+ * Show appointment widget with configuration
12
+ * @param {object} config - Configuration object
13
+ * @param {string} config.apiBaseUrl - Base URL for API
14
+ * @param {string} config.hospitalId - Hospital ID
15
+ * @param {number} config.doctorId - Doctor ID
16
+ * @param {string} config.joinCallUrl - Video call URL
17
+ * @param {function} onAction - Optional callback for actions
18
+ */
19
+ showWidget: (config, onAction) => {
20
+ if (!bookingWidgetInstance) {
21
+ bookingWidgetInstance = document.createElement("div");
22
+ document.body.appendChild(bookingWidgetInstance);
23
+ }
24
+
25
+ const PopupWrapper = () => {
26
+ return (
27
+ <>
28
+ <AppointmentPage config={config} />
29
+ {config.showIcdAssistant && <ICD10Assistant />}
30
+ </>
31
+ );
32
+ };
33
+
34
+ ReactDOM.render(<PopupWrapper />, bookingWidgetInstance);
35
+ },
36
+
37
+ closePopup: () => {
38
+ if (bookingWidgetInstance) {
39
+ ReactDOM.unmountComponentAtNode(bookingWidgetInstance);
40
+ bookingWidgetInstance = null;
41
+ }
42
+ },
43
+ };
44
+
45
+ // Expose SDK globally for non-React apps
46
+ window.BookingSDK = BookingSDK;
47
+
48
+ // Export for React/module usage
49
+ export { AppointmentPage, ICD10Assistant, PIH_APPOINTMENT_WIDGET_CLASS };
50
+ export default BookingSDK;