primary_care_admin_binder 0.1.202 → 0.1.203

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 (2) hide show
  1. package/dist/index.cjs.js +66 -20
  2. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -2383,6 +2383,35 @@ var getBinderEnv = function getBinderEnv(key) {
2383
2383
  }
2384
2384
  return fallback;
2385
2385
  };
2386
+ function isAbsoluteUrl(value) {
2387
+ // Scheme-agnostic on purpose - covers http(s):// as well as ws(s):// and
2388
+ // anything else shaped like "scheme://...".
2389
+ return /^[a-z][a-z0-9+.-]*:\/\//i.test(value || "");
2390
+ }
2391
+
2392
+ // When REACT_APP_BASE_URL is configured, each service's own env var (e.g.
2393
+ // REACT_APP_KEY_CLOCK_API) holds only that service's path instead of a full
2394
+ // origin, and the two are joined here. If the value is already an absolute
2395
+ // URL (today's per-service-domain setup, no shared base), it's used as-is -
2396
+ // the shared base is only applied to bare paths, so this is safe to call
2397
+ // unconditionally regardless of environment.
2398
+ function withSharedBase(rawValue) {
2399
+ if (!rawValue) return "";
2400
+ var base = getBinderEnv("REACT_APP_BASE_URL");
2401
+ if (!base || isAbsoluteUrl(rawValue)) return rawValue;
2402
+ var trimmedBase = base.replace(/\/+$/, "");
2403
+ var path = rawValue.startsWith("/") ? rawValue : "/".concat(rawValue);
2404
+ return "".concat(trimmedBase).concat(path);
2405
+ }
2406
+
2407
+ // Base-aware lookup for vars that ARE a full URL or a full path on their
2408
+ // own (e.g. REACT_APP_KEY_CLOCK_API) - used for every per-service endpoint
2409
+ // base below. Not used for getBinderEnv's other callers (REACT_APP_APPNAME,
2410
+ // REACT_APP_TENANTID, REACT_APP_BASE_URL_HOST, etc.) since those aren't URLs
2411
+ // or paths and joining them with a shared base would corrupt them.
2412
+ function getBinderServiceUrl(key) {
2413
+ return withSharedBase(getBinderEnv(key));
2414
+ }
2386
2415
  var _dbName = "";
2387
2416
  var _dbNameNg = "";
2388
2417
  var _ruleDBName = "";
@@ -2394,14 +2423,14 @@ var _tenantId = "";
2394
2423
  * Builds all Binder URLs dynamically from runtime env
2395
2424
  */
2396
2425
  function getBinderUrls() {
2397
- var commonApi = getBinderEnv("REACT_APP_AIQOE_COMMON_API_URL");
2398
- var keyClockApi = getBinderEnv("REACT_APP_KEY_CLOCK_API");
2399
- var nifiApi = getBinderEnv("REACT_APP_NIFI_API");
2400
- var tokenApi = getBinderEnv("REACT_APP_TOKEN_URL");
2401
- var registrationApi = getBinderEnv("REACT_APP_REGISTRATION_API");
2402
- var appointmentApi = getBinderEnv("REACT_APP_APPOINTMENT_API");
2403
- getBinderEnv("REACT_APP_VHC_INTEGRATION_URL");
2404
- var getMohUserDetailUrl = getBinderEnv("REACT_APP_GET_MOH_USER_DETAIL_URL");
2426
+ var commonApi = getBinderServiceUrl("REACT_APP_AIQOE_COMMON_API_URL");
2427
+ var keyClockApi = getBinderServiceUrl("REACT_APP_KEY_CLOCK_API");
2428
+ var nifiApi = getBinderServiceUrl("REACT_APP_NIFI_API");
2429
+ var tokenApi = getBinderServiceUrl("REACT_APP_TOKEN_URL");
2430
+ var registrationApi = getBinderServiceUrl("REACT_APP_REGISTRATION_API");
2431
+ var appointmentApi = getBinderServiceUrl("REACT_APP_APPOINTMENT_API");
2432
+ getBinderServiceUrl("REACT_APP_VHC_INTEGRATION_URL");
2433
+ var getMohUserDetailUrl = getBinderServiceUrl("REACT_APP_GET_MOH_USER_DETAIL_URL");
2405
2434
  return {
2406
2435
  // Database & Metadata
2407
2436
  dbtype: getBinderEnv("REACT_APP_BASE_URL_HOST").split(".")[0],
@@ -18916,10 +18945,12 @@ var queries$j = {
18916
18945
  }
18917
18946
  };
18918
18947
  },
18919
- holiday_master: {
18920
- holiday_type: "{\n \"appcode\": \"".concat(_dbName, "\",\n \"requestid\": \"49d3a86e-226d-4d76-9160-0e93e56c9dea\",\n \"filter\": {\n \"type\": \"HOLIDAYTYPE\"\n } \n }"),
18921
- entity_name: "{\n \"appcode\":\"".concat(_dbName, "\",\n \"requestid\": \"79a77938-7200-48db-8f69-462c46ffd447\" \n }"),
18922
- entity_type: "{\n \"appcode\":\"".concat(_dbName, "\",\n \"requestid\": \"09335a68-08b0-48b2-ad47-58ffbb5fef33\",\n \"filter\": {\n \"type\": \"ORGTYPE\"\n }\n }")
18948
+ holiday_master: function holiday_master() {
18949
+ return {
18950
+ holiday_type: "{\n \"appcode\": \"".concat(dbName, "\",\n \"requestid\": \"49d3a86e-226d-4d76-9160-0e93e56c9dea\",\n \"filter\": {\n \"type\": \"HOLIDAYTYPE\"\n } \n }"),
18951
+ entity_name: "{\n \"appcode\":\"".concat(dbName, "\",\n \"requestid\": \"79a77938-7200-48db-8f69-462c46ffd447\" \n }"),
18952
+ entity_type: "{\n \"appcode\":\"".concat(dbName, "\",\n \"requestid\": \"09335a68-08b0-48b2-ad47-58ffbb5fef33\",\n \"filter\": {\n \"type\": \"ORGTYPE\"\n }\n }")
18953
+ };
18923
18954
  },
18924
18955
  appointment_type_read: function appointment_type_read(page, perPage, search) {
18925
18956
  return "{\n \"appcode\": \"".concat(dbName, "\",\n \"filter\": {\n \"type\": \"APPTYPE\",\n \"search\": \"").concat(search || "", "\",\n \"status\": true,\n \"activestatus\": true\n },\n \"limit\": {\n \"offset\": ").concat(page, ",\n \"count\": ").concat(perPage, "\n }\n}");
@@ -19308,17 +19339,18 @@ var HOLIDAY_SINGLE_READ_SELECTED_QDM = createAsyncThunk("holidaySlice/holidaySin
19308
19339
  var loopMasters$8 = function loopMasters() {
19309
19340
  return new es6Promise.Promise(/*#__PURE__*/function () {
19310
19341
  var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(resolve, reject) {
19311
- var calls;
19342
+ var masters, calls;
19312
19343
  return _regenerator().w(function (_context6) {
19313
19344
  while (1) switch (_context6.n) {
19314
19345
  case 0:
19315
- calls = Object.keys(queries$j.holiday_master).map(/*#__PURE__*/function () {
19346
+ masters = queries$j.holiday_master();
19347
+ calls = Object.keys(masters).map(/*#__PURE__*/function () {
19316
19348
  var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(val) {
19317
19349
  return _regenerator().w(function (_context5) {
19318
19350
  while (1) switch (_context5.n) {
19319
19351
  case 0:
19320
19352
  _context5.n = 1;
19321
- return fetchMaster$8(val, queries$j.holiday_master[val]);
19353
+ return fetchMaster$8(val, masters[val]);
19322
19354
  case 1:
19323
19355
  return _context5.a(2, _context5.v);
19324
19356
  }
@@ -19332,22 +19364,36 @@ var loopMasters$8 = function loopMasters() {
19332
19364
  var json = {};
19333
19365
  data.map(function (val) {
19334
19366
  var arr = [];
19335
- val.data.map(function (value) {
19367
+ var responseData = val.data || [];
19368
+ if (Array.isArray(responseData) && responseData.length > 0) {
19369
+ var firstItem = responseData[0];
19370
+ if (firstItem && _typeof(firstItem) === "object" && !firstItem._id && !firstItem._key) {
19371
+ var _firstItem$keys$;
19372
+ var keys = Object.keys(firstItem);
19373
+ if (keys.length === 1 && (_firstItem$keys$ = firstItem[keys[0]]) !== null && _firstItem$keys$ !== void 0 && _firstItem$keys$.Value) {
19374
+ responseData = firstItem[keys[0]].Value;
19375
+ } else if (firstItem.result) {
19376
+ responseData = firstItem.result;
19377
+ }
19378
+ }
19379
+ }
19380
+ if (!Array.isArray(responseData)) responseData = [];
19381
+ responseData.map(function (value) {
19336
19382
  if (["entity_name"].indexOf(val.name) === 0) {
19337
19383
  arr.push(_objectSpread2({
19338
- label: value.name ? value.name : "",
19339
- value: value.OrgID ? value.OrgID : ""
19384
+ label: value.name ? value.name : value.display || "",
19385
+ value: value.OrgID ? value.OrgID : value._id || ""
19340
19386
  }, value));
19341
19387
  } else {
19342
19388
  arr.push(_objectSpread2({
19343
- label: value.coding ? value.coding[0] ? value.coding[0].display : "" : val,
19389
+ label: value.coding && value.coding[0] ? value.coding[0].display || "" : value.display || "",
19344
19390
  value: value._id
19345
19391
  }, value));
19346
19392
  }
19347
19393
  });
19348
19394
  json[val.name] = arr;
19349
- resolve(json);
19350
19395
  });
19396
+ resolve(json);
19351
19397
  })["catch"](function (err) {
19352
19398
  resolve([]);
19353
19399
  console.log(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primary_care_admin_binder",
3
- "version": "0.1.202",
3
+ "version": "0.1.203",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",