primary_care_admin_binder 0.1.201 → 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 +248 -153
  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],
@@ -10463,7 +10492,7 @@ var query$a = {
10463
10492
  facilityid: "",
10464
10493
  lang: ""
10465
10494
  },
10466
- requestid: qdm_query_ids.gmLoadQuery
10495
+ requestid: query_ids.gmLoadQuery
10467
10496
  };
10468
10497
  },
10469
10498
  gender: function gender() {
@@ -10475,7 +10504,7 @@ var query$a = {
10475
10504
  facilityid: "",
10476
10505
  lang: ""
10477
10506
  },
10478
- requestid: qdm_query_ids.gmLoadQuery
10507
+ requestid: query_ids.gmLoadQuery
10479
10508
  };
10480
10509
  },
10481
10510
  specialityCodeOrgId: function specialityCodeOrgId(data) {
@@ -10487,7 +10516,7 @@ var query$a = {
10487
10516
  facilityid: "",
10488
10517
  lang: ""
10489
10518
  },
10490
- requestid: qdm_query_ids.gmLoadQuery
10519
+ requestid: query_ids.gmLoadQuery
10491
10520
  };
10492
10521
  },
10493
10522
  specialityCode: function specialityCode() {
@@ -10499,7 +10528,7 @@ var query$a = {
10499
10528
  facilityid: "",
10500
10529
  lang: ""
10501
10530
  },
10502
- requestid: qdm_query_ids.gmLoadQuery
10531
+ requestid: query_ids.gmLoadQuery
10503
10532
  };
10504
10533
  },
10505
10534
  diagnosis: function diagnosis() {
@@ -10551,13 +10580,10 @@ var query$a = {
10551
10580
  };
10552
10581
  },
10553
10582
  editVitalApplicable: function editVitalApplicable(id) {
10554
- var idStr = String(id || "");
10555
- var idx = idStr.lastIndexOf("/");
10556
- var key = idx !== -1 ? idStr.slice(idx + 1) : idStr;
10557
10583
  return {
10558
10584
  appcode: _dbName,
10559
10585
  filter: {
10560
- _id: key || id
10586
+ _id: id
10561
10587
  },
10562
10588
  requestid: query_ids.vitalsApplicableEdit
10563
10589
  };
@@ -10637,65 +10663,58 @@ var generateApplicableResJson = function generateApplicableResJson(data, state)
10637
10663
  return (a === null || a === void 0 ? void 0 : a.createddate) - (b === null || b === void 0 ? void 0 : b.createddate);
10638
10664
  });
10639
10665
  var list = TableData.map(function (val) {
10640
- // Look up gender from state if it is a raw ID string
10666
+ // ── gender ──────────────────────────────────────────────────────────────
10667
+ // API may return a fully-populated object OR a raw ID string.
10641
10668
  var genderVal = "";
10642
10669
  if (val.gender) {
10643
- if (typeof val.gender === "string") {
10670
+ if (_typeof(val.gender) === "object" && !Array.isArray(val.gender)) {
10671
+ // Populated object: { display, shortdesc, code, _id, … }
10672
+ genderVal = val.gender.display || val.gender.shortdesc || val.gender.code || "";
10673
+ } else if (Array.isArray(val.gender) && val.gender.length > 0) {
10674
+ var _g$coding;
10675
+ var g = val.gender[0];
10676
+ genderVal = _typeof(g) === "object" ? g.display || g.shortdesc || ((_g$coding = g.coding) === null || _g$coding === void 0 || (_g$coding = _g$coding[0]) === null || _g$coding === void 0 ? void 0 : _g$coding.display) || "" : String(g);
10677
+ } else if (typeof val.gender === "string") {
10644
10678
  var _state$gender;
10679
+ // Legacy: raw ID — look up label from state
10645
10680
  var genderObj = state === null || state === void 0 || (_state$gender = state.gender) === null || _state$gender === void 0 || (_state$gender = _state$gender.data) === null || _state$gender === void 0 ? void 0 : _state$gender.find(function (sys) {
10646
10681
  return String(val.gender).indexOf(String(sys.value)) > -1;
10647
10682
  });
10648
- genderVal = genderObj ? {
10649
- display: genderObj.label,
10650
- value: genderObj.value
10651
- } : val.gender;
10652
- } else if (Array.isArray(val.gender) && val.gender.length > 0) {
10653
- var _val$gender$;
10654
- genderVal = ((_val$gender$ = val.gender[0]) === null || _val$gender$ === void 0 || (_val$gender$ = _val$gender$.coding) === null || _val$gender$ === void 0 ? void 0 : _val$gender$[0]) || "";
10655
- } else {
10656
- genderVal = val.gender;
10683
+ genderVal = genderObj ? genderObj.label : val.gender;
10657
10684
  }
10658
10685
  }
10659
10686
 
10660
- // Look up specialty from state if it is a raw ID string
10687
+ // ── specialty ────────────────────────────────────────────────────────────
10661
10688
  var specialtyVal = "";
10662
10689
  if (val.spltycode) {
10663
- if (typeof val.spltycode === "string") {
10664
- var _state$speciality_cod;
10665
- var specialtyObj = state === null || state === void 0 || (_state$speciality_cod = state.speciality_code) === null || _state$speciality_cod === void 0 || (_state$speciality_cod = _state$speciality_cod.data) === null || _state$speciality_cod === void 0 ? void 0 : _state$speciality_cod.find(function (sys) {
10666
- return String(val.spltycode).indexOf(String(sys.value)) > -1;
10667
- });
10668
- specialtyVal = specialtyObj ? specialtyObj.label : val.spltycode;
10669
- } else if (Array.isArray(val.spltycode) && val.spltycode.length > 0) {
10670
- var _val$spltycode$, _val$spltycode$2;
10671
- specialtyVal = ((_val$spltycode$ = val.spltycode[0]) === null || _val$spltycode$ === void 0 || (_val$spltycode$ = _val$spltycode$.coding) === null || _val$spltycode$ === void 0 || (_val$spltycode$ = _val$spltycode$[0]) === null || _val$spltycode$ === void 0 ? void 0 : _val$spltycode$.display) || ((_val$spltycode$2 = val.spltycode[0]) === null || _val$spltycode$2 === void 0 ? void 0 : _val$spltycode$2.display) || "";
10672
- } else {
10673
- var _val$spltycode;
10674
- specialtyVal = ((_val$spltycode = val.spltycode) === null || _val$spltycode === void 0 ? void 0 : _val$spltycode.display) || "";
10690
+ if (_typeof(val.spltycode) === "object" && !Array.isArray(val.spltycode)) {
10691
+ // Populated object: { display, shortdesc, _id, … }
10692
+ specialtyVal = val.spltycode.shortdesc || val.spltycode.display || "";
10675
10693
  }
10676
10694
  }
10677
10695
 
10678
- // Look up ageRange from state if it is a raw ID string
10696
+ // ── age range ────────────────────────────────────────────────────────────
10679
10697
  var ageRangeVal = "";
10680
10698
  if (val.agerangecode) {
10681
- if (typeof val.agerangecode === "string" || typeof val.agerangecode === "number") {
10699
+ if (_typeof(val.agerangecode) === "object" && !Array.isArray(val.agerangecode)) {
10700
+ // Populated object: { shortdesc, longdesc, agerangecode, _id, … }
10701
+ ageRangeVal = val.agerangecode.shortdesc || val.agerangecode.longdesc || val.agerangecode.agerangecode || "";
10702
+ } else if (typeof val.agerangecode === "string" || typeof val.agerangecode === "number") {
10682
10703
  var _state$ageranges_code;
10683
10704
  var ageRangeObj = state === null || state === void 0 || (_state$ageranges_code = state.ageranges_code) === null || _state$ageranges_code === void 0 || (_state$ageranges_code = _state$ageranges_code.data) === null || _state$ageranges_code === void 0 ? void 0 : _state$ageranges_code.find(function (sys) {
10684
10705
  return String(val.agerangecode).indexOf(String(sys.value)) > -1;
10685
10706
  });
10686
10707
  ageRangeVal = ageRangeObj ? ageRangeObj.label : String(val.agerangecode);
10687
- } else {
10688
- var _val$agerangecode;
10689
- ageRangeVal = ((_val$agerangecode = val.agerangecode) === null || _val$agerangecode === void 0 ? void 0 : _val$agerangecode.agerangecode) || "";
10690
10708
  }
10691
10709
  }
10692
10710
 
10693
- // Look up ageCategory from state if it is a raw ID string
10711
+ // ── age category ─────────────────────────────────────────────────────────
10694
10712
  var ageCategoryVal = "";
10695
10713
  if (val.agecategorycode && val.agecategorycode.length > 0) {
10696
10714
  var firstCat = val.agecategorycode[0];
10697
- if (_typeof(firstCat) === "object") {
10698
- ageCategoryVal = firstCat.code || firstCat.display || "";
10715
+ if (_typeof(firstCat) === "object" && firstCat !== null) {
10716
+ // Populated object: { description, code, _id, … }
10717
+ ageCategoryVal = firstCat.description || firstCat.code || firstCat._id || "";
10699
10718
  } else {
10700
10719
  ageCategoryVal = String(firstCat);
10701
10720
  }
@@ -10754,43 +10773,77 @@ var generateApplicableReadResJson = function generateApplicableReadResJson() {
10754
10773
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
10755
10774
  var state = arguments.length > 1 ? arguments[1] : undefined;
10756
10775
  var list = (data || []).map(function (v) {
10757
- var _state$entity_name, _state$entity_type;
10758
- // organization_id is a string like "10002" in QDM response
10759
- var orgIdStr = _typeof(v.organization_id) === "object" && v.organization_id !== null ? v.organization_id._id || v.organization_id.id || "" : String(v.organization_id || "");
10760
-
10761
- // Look up org name from the entity_name dropdown list loaded in state
10762
- var orgEntry = state === null || state === void 0 || (_state$entity_name = state.entity_name) === null || _state$entity_name === void 0 || (_state$entity_name = _state$entity_name.data) === null || _state$entity_name === void 0 ? void 0 : _state$entity_name.find(function (sys) {
10763
- return getRawId$3(sys.value) === orgIdStr || getRawId$3(sys._id) === orgIdStr;
10764
- });
10765
- var orgName = (orgEntry === null || orgEntry === void 0 ? void 0 : orgEntry.label) || (orgEntry === null || orgEntry === void 0 ? void 0 : orgEntry.name) || orgIdStr;
10776
+ // ── organization_id ───────────────────────────────────────────────────────
10777
+ // API may return a fully-populated object OR a raw ID string.
10778
+ var orgIdStr = "";
10779
+ var orgName = "";
10780
+ if (_typeof(v.organization_id) === "object" && v.organization_id !== null) {
10781
+ // Populated object: { name, _id, _key, … }
10782
+ orgIdStr = getRawId$3(v.organization_id._id || v.organization_id._key || "");
10783
+ orgName = v.organization_id.name || v.organization_id.label || orgIdStr;
10784
+ } else {
10785
+ var _state$entity_name;
10786
+ orgIdStr = getRawId$3(String(v.organization_id || ""));
10787
+ // Fallback: look up label from state dropdown
10788
+ var orgEntry = state === null || state === void 0 || (_state$entity_name = state.entity_name) === null || _state$entity_name === void 0 || (_state$entity_name = _state$entity_name.data) === null || _state$entity_name === void 0 ? void 0 : _state$entity_name.find(function (sys) {
10789
+ return getRawId$3(sys.value) === orgIdStr || getRawId$3(sys._id) === orgIdStr;
10790
+ });
10791
+ orgName = (orgEntry === null || orgEntry === void 0 ? void 0 : orgEntry.label) || (orgEntry === null || orgEntry === void 0 ? void 0 : orgEntry.name) || orgIdStr;
10792
+ }
10766
10793
 
10767
- // orgentitytype: QDM returns lowercase "orgentitytype", value is a string ID like "10010"
10794
+ // ── orgEntityType ─────────────────────────────────────────────────────────
10768
10795
  var orgTypeRaw = v.orgentitytype || v.orgEntityType || v.OrgEntityType;
10769
- var orgTypeId = _typeof(orgTypeRaw) === "object" && orgTypeRaw !== null ? orgTypeRaw._id || orgTypeRaw.value || "" : String(orgTypeRaw || "");
10770
- var entityTypeVal = orgTypeId ? (state === null || state === void 0 || (_state$entity_type = state.entity_type) === null || _state$entity_type === void 0 || (_state$entity_type = _state$entity_type.data) === null || _state$entity_type === void 0 ? void 0 : _state$entity_type.find(function (sys) {
10771
- return getRawId$3(sys.value) === getRawId$3(orgTypeId);
10772
- })) || {
10773
- _id: orgTypeId,
10774
- value: orgTypeId,
10775
- label: orgTypeId
10776
- } : null;
10777
-
10778
- // specialty code
10796
+ var entityTypeVal = null;
10797
+ if (_typeof(orgTypeRaw) === "object" && orgTypeRaw !== null) {
10798
+ var _state$entity_type;
10799
+ // Populated object: { display, shortdesc, _id, … }
10800
+ var orgTypeId = getRawId$3(orgTypeRaw._id || orgTypeRaw._key || "");
10801
+ var orgTypeLabel = orgTypeRaw.display || orgTypeRaw.shortdesc || orgTypeId;
10802
+ // Try to match against the state dropdown for a complete option object
10803
+ entityTypeVal = (state === null || state === void 0 || (_state$entity_type = state.entity_type) === null || _state$entity_type === void 0 || (_state$entity_type = _state$entity_type.data) === null || _state$entity_type === void 0 ? void 0 : _state$entity_type.find(function (sys) {
10804
+ return getRawId$3(sys.value) === orgTypeId;
10805
+ })) || {
10806
+ _id: orgTypeId,
10807
+ value: orgTypeId,
10808
+ label: orgTypeLabel
10809
+ };
10810
+ } else if (orgTypeRaw) {
10811
+ var _state$entity_type2;
10812
+ var _orgTypeId = getRawId$3(String(orgTypeRaw));
10813
+ entityTypeVal = _orgTypeId ? (state === null || state === void 0 || (_state$entity_type2 = state.entity_type) === null || _state$entity_type2 === void 0 || (_state$entity_type2 = _state$entity_type2.data) === null || _state$entity_type2 === void 0 ? void 0 : _state$entity_type2.find(function (sys) {
10814
+ return getRawId$3(sys.value) === _orgTypeId;
10815
+ })) || {
10816
+ _id: _orgTypeId,
10817
+ value: _orgTypeId,
10818
+ label: _orgTypeId
10819
+ } : null;
10820
+ }
10821
+
10822
+ // ── specialty code ────────────────────────────────────────────────────────
10779
10823
  var specialCodeVal = null;
10780
10824
  var splyRaw = v.spltycodeId || v.spltycode;
10781
10825
  if (splyRaw) {
10782
10826
  var firstSply = Array.isArray(splyRaw) ? splyRaw[0] : splyRaw;
10783
10827
  if (_typeof(firstSply) === "object" && firstSply !== null) {
10784
- specialCodeVal = {
10785
- _id: String(firstSply._id || firstSply.value || ""),
10786
- value: firstSply._id || firstSply.value || "",
10787
- label: String(firstSply.display || firstSply.label || firstSply._id || "")
10828
+ var _state$speciality_cod, _state$speciality_cod2;
10829
+ // Populated object: { display, shortdesc, _id, … }
10830
+ var spId = getRawId$3(firstSply._id || firstSply._key || "");
10831
+ var spLabel = firstSply.shortdesc || firstSply.display || firstSply.label || spId;
10832
+ specialCodeVal = (state === null || state === void 0 || (_state$speciality_cod = state.speciality_code_org) === null || _state$speciality_cod === void 0 || (_state$speciality_cod = _state$speciality_cod.data) === null || _state$speciality_cod === void 0 ? void 0 : _state$speciality_cod.find(function (sys) {
10833
+ return getRawId$3(sys.value) === spId;
10834
+ })) || (state === null || state === void 0 || (_state$speciality_cod2 = state.speciality_code) === null || _state$speciality_cod2 === void 0 || (_state$speciality_cod2 = _state$speciality_cod2.data) === null || _state$speciality_cod2 === void 0 ? void 0 : _state$speciality_cod2.find(function (sys) {
10835
+ return getRawId$3(sys.value) === spId;
10836
+ })) || {
10837
+ _id: spId,
10838
+ value: spId,
10839
+ label: spLabel
10788
10840
  };
10789
10841
  } else {
10790
- var _state$speciality_cod2, _state$speciality_cod3;
10791
- var foundSp = (state === null || state === void 0 || (_state$speciality_cod2 = state.speciality_code_org) === null || _state$speciality_cod2 === void 0 || (_state$speciality_cod2 = _state$speciality_cod2.data) === null || _state$speciality_cod2 === void 0 ? void 0 : _state$speciality_cod2.find(function (sys) {
10842
+ var _state$speciality_cod3, _state$speciality_cod4;
10843
+ // Legacy: raw ID string
10844
+ var foundSp = (state === null || state === void 0 || (_state$speciality_cod3 = state.speciality_code_org) === null || _state$speciality_cod3 === void 0 || (_state$speciality_cod3 = _state$speciality_cod3.data) === null || _state$speciality_cod3 === void 0 ? void 0 : _state$speciality_cod3.find(function (sys) {
10792
10845
  return getRawId$3(sys.value) === getRawId$3(firstSply);
10793
- })) || (state === null || state === void 0 || (_state$speciality_cod3 = state.speciality_code) === null || _state$speciality_cod3 === void 0 || (_state$speciality_cod3 = _state$speciality_cod3.data) === null || _state$speciality_cod3 === void 0 ? void 0 : _state$speciality_cod3.find(function (sys) {
10846
+ })) || (state === null || state === void 0 || (_state$speciality_cod4 = state.speciality_code) === null || _state$speciality_cod4 === void 0 || (_state$speciality_cod4 = _state$speciality_cod4.data) === null || _state$speciality_cod4 === void 0 ? void 0 : _state$speciality_cod4.find(function (sys) {
10794
10847
  return getRawId$3(sys.value) === getRawId$3(firstSply);
10795
10848
  }));
10796
10849
  specialCodeVal = foundSp || (firstSply ? {
@@ -10801,46 +10854,61 @@ var generateApplicableReadResJson = function generateApplicableReadResJson() {
10801
10854
  }
10802
10855
  }
10803
10856
 
10804
- // gender: QDM returns gender as a code (e.g. "ACS004"), genderId as the _id (e.g. "11189")
10857
+ // ── gender ────────────────────────────────────────────────────────────────
10858
+ // API may return a fully-populated object (with _id, code, display) or a raw
10859
+ // ID / code string. Match against the state dropdown for a consistent option.
10805
10860
  var genderVal = null;
10806
10861
  var rawGender = v.genderId || v.gender;
10807
- var firstGender = Array.isArray(rawGender) ? rawGender[0] : _typeof(rawGender) === "object" ? rawGender : null;
10808
- var genderId = firstGender ? firstGender._id || firstGender.id || firstGender.code || firstGender.value : rawGender;
10809
- if (genderId) {
10810
- var _state$gender2;
10811
- var gIdStr = String(genderId).toLowerCase();
10812
- genderVal = (state === null || state === void 0 || (_state$gender2 = state.gender) === null || _state$gender2 === void 0 || (_state$gender2 = _state$gender2.data) === null || _state$gender2 === void 0 ? void 0 : _state$gender2.find(function (sys) {
10813
- return getRawId$3(sys.value).toLowerCase() === gIdStr || String(sys.code).toLowerCase() === gIdStr || String(sys.label).toLowerCase() === gIdStr;
10814
- })) || null;
10815
- // Fallback: try matching by gender code if genderId doesn't match
10816
- var genderCodeStr = (firstGender === null || firstGender === void 0 ? void 0 : firstGender.code) || (firstGender === null || firstGender === void 0 ? void 0 : firstGender.display) || v.gender;
10817
- if (!genderVal && genderCodeStr) {
10862
+ if (rawGender) {
10863
+ var firstGender = Array.isArray(rawGender) ? rawGender[0] : _typeof(rawGender) === "object" ? rawGender : null;
10864
+ if (firstGender && _typeof(firstGender) === "object") {
10865
+ var _state$gender2;
10866
+ // Populated object — try matching by _id first, then by code
10867
+ var gId = getRawId$3(firstGender._id || firstGender._key || "");
10868
+ var gCode = (firstGender.code || "").toLowerCase();
10869
+ var gDisplay = (firstGender.display || firstGender.shortdesc || "").toLowerCase();
10870
+ genderVal = (state === null || state === void 0 || (_state$gender2 = state.gender) === null || _state$gender2 === void 0 || (_state$gender2 = _state$gender2.data) === null || _state$gender2 === void 0 ? void 0 : _state$gender2.find(function (sys) {
10871
+ return getRawId$3(sys.value) === gId || String(sys.code || "").toLowerCase() === gCode || String(sys.label || "").toLowerCase() === gDisplay;
10872
+ })) || {
10873
+ _id: gId,
10874
+ value: gId,
10875
+ label: firstGender.display || firstGender.shortdesc || gId
10876
+ };
10877
+ } else {
10818
10878
  var _state$gender3;
10819
- var gCodeStr = String(genderCodeStr).toLowerCase();
10879
+ // Legacy: raw ID / code string
10880
+ var gIdStr = String(rawGender).toLowerCase();
10820
10881
  genderVal = (state === null || state === void 0 || (_state$gender3 = state.gender) === null || _state$gender3 === void 0 || (_state$gender3 = _state$gender3.data) === null || _state$gender3 === void 0 ? void 0 : _state$gender3.find(function (sys) {
10821
- return getRawId$3(sys.value).toLowerCase() === gCodeStr || String(sys.code).toLowerCase() === gCodeStr || String(sys.label).toLowerCase() === gCodeStr;
10822
- })) || null;
10823
- }
10824
- // If still not found, fallback to 'Other' option from the list
10825
- if (!genderVal) {
10826
- var _state$gender4;
10827
- genderVal = (state === null || state === void 0 || (_state$gender4 = state.gender) === null || _state$gender4 === void 0 || (_state$gender4 = _state$gender4.data) === null || _state$gender4 === void 0 ? void 0 : _state$gender4.find(function (sys) {
10828
- return String(sys.code).toLowerCase() === "other" || String(sys.label).toLowerCase() === "other";
10882
+ return getRawId$3(sys.value).toLowerCase() === gIdStr || String(sys.code || "").toLowerCase() === gIdStr || String(sys.label || "").toLowerCase() === gIdStr;
10829
10883
  })) || null;
10830
10884
  }
10831
10885
  }
10832
10886
 
10833
- // ageRange: QDM returns agerangecode as a code (e.g. "AGEMONTHTEST"), agerangeId as the _id (e.g. "10004")
10887
+ // ── age range ─────────────────────────────────────────────────────────────
10834
10888
  var ageRangeIdRaw = v.agerangeId || v.agerangecode;
10835
10889
  var ageRangeVal = null;
10836
10890
  if (ageRangeIdRaw) {
10837
- var firstAgeRange = _typeof(ageRangeIdRaw) === "object" && ageRangeIdRaw !== null ? ageRangeIdRaw._id || ageRangeIdRaw.value || ageRangeIdRaw.id || ageRangeIdRaw.agerangecode || "" : ageRangeIdRaw;
10838
- var cleanAgeRangeId = getRawId$3(firstAgeRange);
10839
- if (cleanAgeRangeId) {
10891
+ var cleanAgeRangeId = "";
10892
+ if (_typeof(ageRangeIdRaw) === "object" && ageRangeIdRaw !== null) {
10840
10893
  var _state$ageranges_code2;
10894
+ // Populated object: { _id, agerangecode, shortdesc, … }
10895
+ cleanAgeRangeId = getRawId$3(ageRangeIdRaw._id || ageRangeIdRaw._key || ageRangeIdRaw.agerangecode || "");
10896
+ var arLabel = ageRangeIdRaw.shortdesc || ageRangeIdRaw.longdesc || ageRangeIdRaw.agerangecode || cleanAgeRangeId;
10841
10897
  ageRangeVal = (state === null || state === void 0 || (_state$ageranges_code2 = state.ageranges_code) === null || _state$ageranges_code2 === void 0 || (_state$ageranges_code2 = _state$ageranges_code2.data) === null || _state$ageranges_code2 === void 0 ? void 0 : _state$ageranges_code2.find(function (sys) {
10842
10898
  return getRawId$3(sys.value) === cleanAgeRangeId;
10843
- })) || null;
10899
+ })) || {
10900
+ _id: cleanAgeRangeId,
10901
+ value: cleanAgeRangeId,
10902
+ label: arLabel
10903
+ };
10904
+ } else {
10905
+ cleanAgeRangeId = getRawId$3(String(ageRangeIdRaw));
10906
+ if (cleanAgeRangeId) {
10907
+ var _state$ageranges_code3;
10908
+ ageRangeVal = (state === null || state === void 0 || (_state$ageranges_code3 = state.ageranges_code) === null || _state$ageranges_code3 === void 0 || (_state$ageranges_code3 = _state$ageranges_code3.data) === null || _state$ageranges_code3 === void 0 ? void 0 : _state$ageranges_code3.find(function (sys) {
10909
+ return getRawId$3(sys.value) === cleanAgeRangeId;
10910
+ })) || null;
10911
+ }
10844
10912
  }
10845
10913
  }
10846
10914
  return {
@@ -10870,14 +10938,15 @@ var getDiagGroup = function getDiagGroup(data) {
10870
10938
  var arrData = Array.isArray(data) ? data : [data];
10871
10939
  return arrData.map(function (v) {
10872
10940
  if (_typeof(v) === "object" && v !== null) {
10941
+ var cleanId = v._id ? getRawId$3(v._id) : "";
10873
10942
  return {
10874
10943
  label: String(v.icdname || v.label || v._id || v.value || ""),
10875
- value: v._id || v.value || ""
10944
+ value: cleanId
10876
10945
  };
10877
10946
  } else {
10878
10947
  return {
10879
10948
  label: String(v),
10880
- value: String(v)
10949
+ value: getRawId$3(String(v))
10881
10950
  };
10882
10951
  }
10883
10952
  });
@@ -11386,10 +11455,6 @@ var READ_VITAL_APPLICABLE = createAsyncThunk("vitalApplicableApiSlice/vitalsappl
11386
11455
  state,
11387
11456
  ccState,
11388
11457
  data,
11389
- rawList,
11390
- resVal,
11391
- firstKey,
11392
- innerVal,
11393
11458
  res,
11394
11459
  _args1 = arguments,
11395
11460
  _t1;
@@ -11408,28 +11473,7 @@ var READ_VITAL_APPLICABLE = createAsyncThunk("vitalApplicableApiSlice/vitalsappl
11408
11473
  }, __baseUrl__$1);
11409
11474
  case 2:
11410
11475
  data = _context1.v;
11411
- rawList = [];
11412
- if (Array.isArray(data)) {
11413
- rawList = data;
11414
- } else if (data) {
11415
- rawList = [data];
11416
- }
11417
- if (rawList.length > 0 && rawList[0]) {
11418
- if (rawList[0].result !== undefined) {
11419
- resVal = rawList[0].result;
11420
- rawList = Array.isArray(resVal) ? resVal : [resVal];
11421
- } else {
11422
- firstKey = Object.keys(rawList[0])[0];
11423
- if (firstKey && firstKey.startsWith("vitalsApplicable")) {
11424
- innerVal = rawList[0][firstKey];
11425
- rawList = Array.isArray(innerVal) ? innerVal : [innerVal];
11426
- }
11427
- }
11428
- }
11429
- if (Array.isArray(rawList[0])) {
11430
- rawList = rawList[0];
11431
- }
11432
- res = generateApplicableResJson(rawList, ccState);
11476
+ res = generateApplicableResJson(data, ccState);
11433
11477
  return _context1.a(2, _objectSpread2(_objectSpread2({}, defaultState.List), {}, {
11434
11478
  data: res
11435
11479
  }));
@@ -12933,10 +12977,10 @@ var vitalsMasterSectionActions = {
12933
12977
  var vitalsMasterSectionSlice$1 = vitalsMasterSectionSlice.reducer;
12934
12978
 
12935
12979
  var getActiveDbName$1 = function getActiveDbName() {
12936
- return dbName || _dbName || getBinderEnv("REACT_APP_DATABASE_NAME");
12980
+ return dbName || _dbName || getBinderEnv("REACT_APP_APPNAME");
12937
12981
  };
12938
12982
  var getActiveMetadataDbName$1 = function getActiveMetadataDbName() {
12939
- return metaDatadbName$1 || getBinderEnv("REACT_APP_METADATA_DB_NAME");
12983
+ return metaDatadbName$1 || getBinderEnv("REACT_APP_META_APP_NAME");
12940
12984
  };
12941
12985
  var getActiveMetadataId$1 = function getActiveMetadataId() {
12942
12986
  return metaDataId$1 || getBinderEnv("REACT_APP_METADATAID");
@@ -13019,14 +13063,15 @@ var queries$n = {
13019
13063
  metadata_dbname: getActiveMetadataDbName$1()
13020
13064
  }, doc)];
13021
13065
  },
13022
- locationtree: function locationtree(search, page, perPage) {
13066
+ locationtree: function locationtree(search, page, perPage, facilityid) {
13023
13067
  return {
13024
13068
  appcode: getActiveDbName$1(),
13025
13069
  requestid: query_ids.location_tree,
13026
13070
  filter: {
13027
13071
  search: search ? "%".concat(search, "%") : "",
13028
13072
  page: page,
13029
- perPage: perPage
13073
+ perPage: perPage,
13074
+ facilityid: facilityid || ""
13030
13075
  }
13031
13076
  };
13032
13077
  },
@@ -13397,6 +13442,8 @@ var LOCATION_TREE_READ = createAsyncThunk("locationApiSlice/locationtree", /*#__
13397
13442
  page,
13398
13443
  _payload$perPage,
13399
13444
  perPage,
13445
+ _payload$facilityid,
13446
+ facilityid,
13400
13447
  data,
13401
13448
  _args4 = arguments,
13402
13449
  _t4;
@@ -13406,16 +13453,17 @@ var LOCATION_TREE_READ = createAsyncThunk("locationApiSlice/locationtree", /*#__
13406
13453
  payload = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
13407
13454
  _ref8 = _args4.length > 1 ? _args4[1] : undefined, rejectWithValue = _ref8.rejectWithValue;
13408
13455
  _context4.p = 1;
13409
- _payload$search = payload.search, search = _payload$search === void 0 ? "" : _payload$search, _payload$page = payload.page, page = _payload$page === void 0 ? 0 : _payload$page, _payload$perPage = payload.perPage, perPage = _payload$perPage === void 0 ? 10 : _payload$perPage;
13456
+ _payload$search = payload.search, search = _payload$search === void 0 ? "" : _payload$search, _payload$page = payload.page, page = _payload$page === void 0 ? 0 : _payload$page, _payload$perPage = payload.perPage, perPage = _payload$perPage === void 0 ? 10 : _payload$perPage, _payload$facilityid = payload.facilityid, facilityid = _payload$facilityid === void 0 ? "" : _payload$facilityid;
13410
13457
  _context4.n = 2;
13411
13458
  return fetchData({
13412
- body: JSON.stringify(queries$n.locationtree(search, page, perPage))
13459
+ body: JSON.stringify(queries$n.locationtree(search, page, perPage, facilityid))
13413
13460
  }, __baseUrl__$1);
13414
13461
  case 2:
13415
13462
  data = _context4.v;
13416
13463
  return _context4.a(2, _objectSpread2(_objectSpread2({}, defaultState.List), {}, {
13417
13464
  data: data,
13418
- page: page
13465
+ page: page,
13466
+ facilityid: facilityid
13419
13467
  }));
13420
13468
  case 3:
13421
13469
  _context4.p = 3;
@@ -13493,10 +13541,19 @@ var locationSlice = createSlice({
13493
13541
  builder.addCase(LOCATION_TREE_READ.fulfilled, function (state, action) {
13494
13542
  state.location_tree.loading = false;
13495
13543
  state.location_tree.error = false;
13544
+ var facilityid = action.payload.facilityid;
13545
+ if (facilityid) {
13546
+ // Facility drill-down (triggered by expanding one node): the result
13547
+ // belongs to that one node only. It is consumed directly from this
13548
+ // thunk's resolved payload by whichever component requested it -
13549
+ // the shared top-level tree list is deliberately left untouched here,
13550
+ // so a single expand can never affect any other facility's data.
13551
+ return;
13552
+ }
13553
+ var currentData = state.location_tree.data || [];
13554
+ var newData = action.payload.data || [];
13496
13555
  var isLoadMore = action.payload.page > 0;
13497
13556
  if (isLoadMore) {
13498
- var currentData = state.location_tree.data || [];
13499
- var newData = action.payload.data || [];
13500
13557
  var mergedData = _toConsumableArray(currentData);
13501
13558
  newData.forEach(function (newOrgObj) {
13502
13559
  var orgName = Object.keys(newOrgObj)[0];
@@ -13504,7 +13561,18 @@ var locationSlice = createSlice({
13504
13561
  return Object.keys(org)[0] === orgName;
13505
13562
  });
13506
13563
  if (existingOrgIndex !== -1) {
13507
- mergedData[existingOrgIndex][orgName] = [].concat(_toConsumableArray(mergedData[existingOrgIndex][orgName]), _toConsumableArray(newOrgObj[orgName]));
13564
+ var existingItems = mergedData[existingOrgIndex][orgName];
13565
+ // De-duped by id: a later page re-returning an item already on
13566
+ // an earlier page (e.g. an off-by-one on the backend) must not
13567
+ // add a second copy of it here.
13568
+ var existingIds = new Set(existingItems.map(function (it) {
13569
+ return it._id || it._key || it.locationID;
13570
+ }));
13571
+ var newItems = (newOrgObj[orgName] || []).filter(function (it) {
13572
+ var id = it._id || it._key || it.locationID;
13573
+ return id === undefined || !existingIds.has(id);
13574
+ });
13575
+ mergedData[existingOrgIndex][orgName] = [].concat(_toConsumableArray(existingItems), _toConsumableArray(newItems));
13508
13576
  } else {
13509
13577
  mergedData.push(newOrgObj);
13510
13578
  }
@@ -13516,11 +13584,21 @@ var locationSlice = createSlice({
13516
13584
  state.location_tree = action.payload;
13517
13585
  }
13518
13586
  });
13519
- builder.addCase(LOCATION_TREE_READ.pending, function (state) {
13587
+ builder.addCase(LOCATION_TREE_READ.pending, function (state, action) {
13588
+ var _action$meta;
13589
+ // A per-facility drill-down (triggered by expanding one node) shows its
13590
+ // own local spinner in that node - it must not flip the whole-tree
13591
+ // loading flag, which would blank out the already-rendered list.
13592
+ if ((_action$meta = action.meta) !== null && _action$meta !== void 0 && (_action$meta = _action$meta.arg) !== null && _action$meta !== void 0 && _action$meta.facilityid) return;
13520
13593
  state.location_tree.loading = true;
13521
13594
  state.location_tree.error = false;
13522
13595
  });
13523
13596
  builder.addCase(LOCATION_TREE_READ.rejected, function (state, action) {
13597
+ var _action$meta2;
13598
+ // Same reasoning as .pending: a failed facility drill-down must not
13599
+ // wipe out the rest of the already-loaded tree. The component reads
13600
+ // the rejection off the dispatch promise itself to show a per-node error.
13601
+ if ((_action$meta2 = action.meta) !== null && _action$meta2 !== void 0 && (_action$meta2 = _action$meta2.arg) !== null && _action$meta2 !== void 0 && _action$meta2.facilityid) return;
13524
13602
  state.location_tree.loading = false;
13525
13603
  state.location_tree.error = true;
13526
13604
  state.location_tree = action.payload;
@@ -17766,7 +17844,7 @@ var queries$l = {
17766
17844
  return {
17767
17845
  appcode: dbName,
17768
17846
  requestid: "9d2753a8-4c3e-4b21-817a-5b4d1101e4a1",
17769
- request: {
17847
+ filter: {
17770
17848
  page: page,
17771
17849
  perPage: perPage,
17772
17850
  search: search,
@@ -18867,10 +18945,12 @@ var queries$j = {
18867
18945
  }
18868
18946
  };
18869
18947
  },
18870
- holiday_master: {
18871
- holiday_type: "{\n \"appcode\": \"".concat(_dbName, "\",\n \"requestid\": \"49d3a86e-226d-4d76-9160-0e93e56c9dea\",\n \"filter\": {\n \"type\": \"HOLIDAYTYPE\"\n } \n }"),
18872
- entity_name: "{\n \"appcode\":\"".concat(_dbName, "\",\n \"requestid\": \"79a77938-7200-48db-8f69-462c46ffd447\" \n }"),
18873
- 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
+ };
18874
18954
  },
18875
18955
  appointment_type_read: function appointment_type_read(page, perPage, search) {
18876
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}");
@@ -19259,17 +19339,18 @@ var HOLIDAY_SINGLE_READ_SELECTED_QDM = createAsyncThunk("holidaySlice/holidaySin
19259
19339
  var loopMasters$8 = function loopMasters() {
19260
19340
  return new es6Promise.Promise(/*#__PURE__*/function () {
19261
19341
  var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(resolve, reject) {
19262
- var calls;
19342
+ var masters, calls;
19263
19343
  return _regenerator().w(function (_context6) {
19264
19344
  while (1) switch (_context6.n) {
19265
19345
  case 0:
19266
- calls = Object.keys(queries$j.holiday_master).map(/*#__PURE__*/function () {
19346
+ masters = queries$j.holiday_master();
19347
+ calls = Object.keys(masters).map(/*#__PURE__*/function () {
19267
19348
  var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(val) {
19268
19349
  return _regenerator().w(function (_context5) {
19269
19350
  while (1) switch (_context5.n) {
19270
19351
  case 0:
19271
19352
  _context5.n = 1;
19272
- return fetchMaster$8(val, queries$j.holiday_master[val]);
19353
+ return fetchMaster$8(val, masters[val]);
19273
19354
  case 1:
19274
19355
  return _context5.a(2, _context5.v);
19275
19356
  }
@@ -19283,22 +19364,36 @@ var loopMasters$8 = function loopMasters() {
19283
19364
  var json = {};
19284
19365
  data.map(function (val) {
19285
19366
  var arr = [];
19286
- 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) {
19287
19382
  if (["entity_name"].indexOf(val.name) === 0) {
19288
19383
  arr.push(_objectSpread2({
19289
- label: value.name ? value.name : "",
19290
- value: value.OrgID ? value.OrgID : ""
19384
+ label: value.name ? value.name : value.display || "",
19385
+ value: value.OrgID ? value.OrgID : value._id || ""
19291
19386
  }, value));
19292
19387
  } else {
19293
19388
  arr.push(_objectSpread2({
19294
- label: value.coding ? value.coding[0] ? value.coding[0].display : "" : val,
19389
+ label: value.coding && value.coding[0] ? value.coding[0].display || "" : value.display || "",
19295
19390
  value: value._id
19296
19391
  }, value));
19297
19392
  }
19298
19393
  });
19299
19394
  json[val.name] = arr;
19300
- resolve(json);
19301
19395
  });
19396
+ resolve(json);
19302
19397
  })["catch"](function (err) {
19303
19398
  resolve([]);
19304
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.201",
3
+ "version": "0.1.203",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",