primary_care_admin_binder 0.1.200 → 0.1.202

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 +196 -146
  2. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -8285,7 +8285,7 @@ var fetchData = /*#__PURE__*/function () {
8285
8285
  // in-memory AuthContext on login/refresh - this package can't import that
8286
8286
  // module directly, and the token is intentionally never persisted to
8287
8287
  // localStorage, so a plain window global is the bridge.
8288
- token = jwtToken || (typeof window !== "undefined" ? window.token : undefined);
8288
+ token = jwtToken || (typeof window !== "undefined" ? window.binderAuthToken : undefined);
8289
8289
  __options = {
8290
8290
  method: "POST",
8291
8291
  credentials: "include",
@@ -10463,7 +10463,7 @@ var query$a = {
10463
10463
  facilityid: "",
10464
10464
  lang: ""
10465
10465
  },
10466
- requestid: qdm_query_ids.gmLoadQuery
10466
+ requestid: query_ids.gmLoadQuery
10467
10467
  };
10468
10468
  },
10469
10469
  gender: function gender() {
@@ -10475,7 +10475,7 @@ var query$a = {
10475
10475
  facilityid: "",
10476
10476
  lang: ""
10477
10477
  },
10478
- requestid: qdm_query_ids.gmLoadQuery
10478
+ requestid: query_ids.gmLoadQuery
10479
10479
  };
10480
10480
  },
10481
10481
  specialityCodeOrgId: function specialityCodeOrgId(data) {
@@ -10487,7 +10487,7 @@ var query$a = {
10487
10487
  facilityid: "",
10488
10488
  lang: ""
10489
10489
  },
10490
- requestid: qdm_query_ids.gmLoadQuery
10490
+ requestid: query_ids.gmLoadQuery
10491
10491
  };
10492
10492
  },
10493
10493
  specialityCode: function specialityCode() {
@@ -10499,7 +10499,7 @@ var query$a = {
10499
10499
  facilityid: "",
10500
10500
  lang: ""
10501
10501
  },
10502
- requestid: qdm_query_ids.gmLoadQuery
10502
+ requestid: query_ids.gmLoadQuery
10503
10503
  };
10504
10504
  },
10505
10505
  diagnosis: function diagnosis() {
@@ -10551,13 +10551,10 @@ var query$a = {
10551
10551
  };
10552
10552
  },
10553
10553
  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
10554
  return {
10558
10555
  appcode: _dbName,
10559
10556
  filter: {
10560
- _id: key || id
10557
+ _id: id
10561
10558
  },
10562
10559
  requestid: query_ids.vitalsApplicableEdit
10563
10560
  };
@@ -10637,65 +10634,58 @@ var generateApplicableResJson = function generateApplicableResJson(data, state)
10637
10634
  return (a === null || a === void 0 ? void 0 : a.createddate) - (b === null || b === void 0 ? void 0 : b.createddate);
10638
10635
  });
10639
10636
  var list = TableData.map(function (val) {
10640
- // Look up gender from state if it is a raw ID string
10637
+ // ── gender ──────────────────────────────────────────────────────────────
10638
+ // API may return a fully-populated object OR a raw ID string.
10641
10639
  var genderVal = "";
10642
10640
  if (val.gender) {
10643
- if (typeof val.gender === "string") {
10641
+ if (_typeof(val.gender) === "object" && !Array.isArray(val.gender)) {
10642
+ // Populated object: { display, shortdesc, code, _id, … }
10643
+ genderVal = val.gender.display || val.gender.shortdesc || val.gender.code || "";
10644
+ } else if (Array.isArray(val.gender) && val.gender.length > 0) {
10645
+ var _g$coding;
10646
+ var g = val.gender[0];
10647
+ 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);
10648
+ } else if (typeof val.gender === "string") {
10644
10649
  var _state$gender;
10650
+ // Legacy: raw ID — look up label from state
10645
10651
  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
10652
  return String(val.gender).indexOf(String(sys.value)) > -1;
10647
10653
  });
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;
10654
+ genderVal = genderObj ? genderObj.label : val.gender;
10657
10655
  }
10658
10656
  }
10659
10657
 
10660
- // Look up specialty from state if it is a raw ID string
10658
+ // ── specialty ────────────────────────────────────────────────────────────
10661
10659
  var specialtyVal = "";
10662
10660
  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) || "";
10661
+ if (_typeof(val.spltycode) === "object" && !Array.isArray(val.spltycode)) {
10662
+ // Populated object: { display, shortdesc, _id, … }
10663
+ specialtyVal = val.spltycode.shortdesc || val.spltycode.display || "";
10675
10664
  }
10676
10665
  }
10677
10666
 
10678
- // Look up ageRange from state if it is a raw ID string
10667
+ // ── age range ────────────────────────────────────────────────────────────
10679
10668
  var ageRangeVal = "";
10680
10669
  if (val.agerangecode) {
10681
- if (typeof val.agerangecode === "string" || typeof val.agerangecode === "number") {
10670
+ if (_typeof(val.agerangecode) === "object" && !Array.isArray(val.agerangecode)) {
10671
+ // Populated object: { shortdesc, longdesc, agerangecode, _id, … }
10672
+ ageRangeVal = val.agerangecode.shortdesc || val.agerangecode.longdesc || val.agerangecode.agerangecode || "";
10673
+ } else if (typeof val.agerangecode === "string" || typeof val.agerangecode === "number") {
10682
10674
  var _state$ageranges_code;
10683
10675
  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
10676
  return String(val.agerangecode).indexOf(String(sys.value)) > -1;
10685
10677
  });
10686
10678
  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
10679
  }
10691
10680
  }
10692
10681
 
10693
- // Look up ageCategory from state if it is a raw ID string
10682
+ // ── age category ─────────────────────────────────────────────────────────
10694
10683
  var ageCategoryVal = "";
10695
10684
  if (val.agecategorycode && val.agecategorycode.length > 0) {
10696
10685
  var firstCat = val.agecategorycode[0];
10697
- if (_typeof(firstCat) === "object") {
10698
- ageCategoryVal = firstCat.code || firstCat.display || "";
10686
+ if (_typeof(firstCat) === "object" && firstCat !== null) {
10687
+ // Populated object: { description, code, _id, … }
10688
+ ageCategoryVal = firstCat.description || firstCat.code || firstCat._id || "";
10699
10689
  } else {
10700
10690
  ageCategoryVal = String(firstCat);
10701
10691
  }
@@ -10754,43 +10744,77 @@ var generateApplicableReadResJson = function generateApplicableReadResJson() {
10754
10744
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
10755
10745
  var state = arguments.length > 1 ? arguments[1] : undefined;
10756
10746
  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;
10747
+ // ── organization_id ───────────────────────────────────────────────────────
10748
+ // API may return a fully-populated object OR a raw ID string.
10749
+ var orgIdStr = "";
10750
+ var orgName = "";
10751
+ if (_typeof(v.organization_id) === "object" && v.organization_id !== null) {
10752
+ // Populated object: { name, _id, _key, … }
10753
+ orgIdStr = getRawId$3(v.organization_id._id || v.organization_id._key || "");
10754
+ orgName = v.organization_id.name || v.organization_id.label || orgIdStr;
10755
+ } else {
10756
+ var _state$entity_name;
10757
+ orgIdStr = getRawId$3(String(v.organization_id || ""));
10758
+ // Fallback: look up label from state dropdown
10759
+ 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) {
10760
+ return getRawId$3(sys.value) === orgIdStr || getRawId$3(sys._id) === orgIdStr;
10761
+ });
10762
+ orgName = (orgEntry === null || orgEntry === void 0 ? void 0 : orgEntry.label) || (orgEntry === null || orgEntry === void 0 ? void 0 : orgEntry.name) || orgIdStr;
10763
+ }
10766
10764
 
10767
- // orgentitytype: QDM returns lowercase "orgentitytype", value is a string ID like "10010"
10765
+ // ── orgEntityType ─────────────────────────────────────────────────────────
10768
10766
  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
10767
+ var entityTypeVal = null;
10768
+ if (_typeof(orgTypeRaw) === "object" && orgTypeRaw !== null) {
10769
+ var _state$entity_type;
10770
+ // Populated object: { display, shortdesc, _id, … }
10771
+ var orgTypeId = getRawId$3(orgTypeRaw._id || orgTypeRaw._key || "");
10772
+ var orgTypeLabel = orgTypeRaw.display || orgTypeRaw.shortdesc || orgTypeId;
10773
+ // Try to match against the state dropdown for a complete option object
10774
+ 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) {
10775
+ return getRawId$3(sys.value) === orgTypeId;
10776
+ })) || {
10777
+ _id: orgTypeId,
10778
+ value: orgTypeId,
10779
+ label: orgTypeLabel
10780
+ };
10781
+ } else if (orgTypeRaw) {
10782
+ var _state$entity_type2;
10783
+ var _orgTypeId = getRawId$3(String(orgTypeRaw));
10784
+ 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) {
10785
+ return getRawId$3(sys.value) === _orgTypeId;
10786
+ })) || {
10787
+ _id: _orgTypeId,
10788
+ value: _orgTypeId,
10789
+ label: _orgTypeId
10790
+ } : null;
10791
+ }
10792
+
10793
+ // ── specialty code ────────────────────────────────────────────────────────
10779
10794
  var specialCodeVal = null;
10780
10795
  var splyRaw = v.spltycodeId || v.spltycode;
10781
10796
  if (splyRaw) {
10782
10797
  var firstSply = Array.isArray(splyRaw) ? splyRaw[0] : splyRaw;
10783
10798
  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 || "")
10799
+ var _state$speciality_cod, _state$speciality_cod2;
10800
+ // Populated object: { display, shortdesc, _id, … }
10801
+ var spId = getRawId$3(firstSply._id || firstSply._key || "");
10802
+ var spLabel = firstSply.shortdesc || firstSply.display || firstSply.label || spId;
10803
+ 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) {
10804
+ return getRawId$3(sys.value) === spId;
10805
+ })) || (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) {
10806
+ return getRawId$3(sys.value) === spId;
10807
+ })) || {
10808
+ _id: spId,
10809
+ value: spId,
10810
+ label: spLabel
10788
10811
  };
10789
10812
  } 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) {
10813
+ var _state$speciality_cod3, _state$speciality_cod4;
10814
+ // Legacy: raw ID string
10815
+ 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
10816
  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) {
10817
+ })) || (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
10818
  return getRawId$3(sys.value) === getRawId$3(firstSply);
10795
10819
  }));
10796
10820
  specialCodeVal = foundSp || (firstSply ? {
@@ -10801,46 +10825,61 @@ var generateApplicableReadResJson = function generateApplicableReadResJson() {
10801
10825
  }
10802
10826
  }
10803
10827
 
10804
- // gender: QDM returns gender as a code (e.g. "ACS004"), genderId as the _id (e.g. "11189")
10828
+ // ── gender ────────────────────────────────────────────────────────────────
10829
+ // API may return a fully-populated object (with _id, code, display) or a raw
10830
+ // ID / code string. Match against the state dropdown for a consistent option.
10805
10831
  var genderVal = null;
10806
10832
  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) {
10833
+ if (rawGender) {
10834
+ var firstGender = Array.isArray(rawGender) ? rawGender[0] : _typeof(rawGender) === "object" ? rawGender : null;
10835
+ if (firstGender && _typeof(firstGender) === "object") {
10836
+ var _state$gender2;
10837
+ // Populated object — try matching by _id first, then by code
10838
+ var gId = getRawId$3(firstGender._id || firstGender._key || "");
10839
+ var gCode = (firstGender.code || "").toLowerCase();
10840
+ var gDisplay = (firstGender.display || firstGender.shortdesc || "").toLowerCase();
10841
+ 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) {
10842
+ return getRawId$3(sys.value) === gId || String(sys.code || "").toLowerCase() === gCode || String(sys.label || "").toLowerCase() === gDisplay;
10843
+ })) || {
10844
+ _id: gId,
10845
+ value: gId,
10846
+ label: firstGender.display || firstGender.shortdesc || gId
10847
+ };
10848
+ } else {
10818
10849
  var _state$gender3;
10819
- var gCodeStr = String(genderCodeStr).toLowerCase();
10850
+ // Legacy: raw ID / code string
10851
+ var gIdStr = String(rawGender).toLowerCase();
10820
10852
  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";
10853
+ return getRawId$3(sys.value).toLowerCase() === gIdStr || String(sys.code || "").toLowerCase() === gIdStr || String(sys.label || "").toLowerCase() === gIdStr;
10829
10854
  })) || null;
10830
10855
  }
10831
10856
  }
10832
10857
 
10833
- // ageRange: QDM returns agerangecode as a code (e.g. "AGEMONTHTEST"), agerangeId as the _id (e.g. "10004")
10858
+ // ── age range ─────────────────────────────────────────────────────────────
10834
10859
  var ageRangeIdRaw = v.agerangeId || v.agerangecode;
10835
10860
  var ageRangeVal = null;
10836
10861
  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) {
10862
+ var cleanAgeRangeId = "";
10863
+ if (_typeof(ageRangeIdRaw) === "object" && ageRangeIdRaw !== null) {
10840
10864
  var _state$ageranges_code2;
10865
+ // Populated object: { _id, agerangecode, shortdesc, … }
10866
+ cleanAgeRangeId = getRawId$3(ageRangeIdRaw._id || ageRangeIdRaw._key || ageRangeIdRaw.agerangecode || "");
10867
+ var arLabel = ageRangeIdRaw.shortdesc || ageRangeIdRaw.longdesc || ageRangeIdRaw.agerangecode || cleanAgeRangeId;
10841
10868
  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
10869
  return getRawId$3(sys.value) === cleanAgeRangeId;
10843
- })) || null;
10870
+ })) || {
10871
+ _id: cleanAgeRangeId,
10872
+ value: cleanAgeRangeId,
10873
+ label: arLabel
10874
+ };
10875
+ } else {
10876
+ cleanAgeRangeId = getRawId$3(String(ageRangeIdRaw));
10877
+ if (cleanAgeRangeId) {
10878
+ var _state$ageranges_code3;
10879
+ 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) {
10880
+ return getRawId$3(sys.value) === cleanAgeRangeId;
10881
+ })) || null;
10882
+ }
10844
10883
  }
10845
10884
  }
10846
10885
  return {
@@ -10870,14 +10909,15 @@ var getDiagGroup = function getDiagGroup(data) {
10870
10909
  var arrData = Array.isArray(data) ? data : [data];
10871
10910
  return arrData.map(function (v) {
10872
10911
  if (_typeof(v) === "object" && v !== null) {
10912
+ var cleanId = v._id ? getRawId$3(v._id) : "";
10873
10913
  return {
10874
10914
  label: String(v.icdname || v.label || v._id || v.value || ""),
10875
- value: v._id || v.value || ""
10915
+ value: cleanId
10876
10916
  };
10877
10917
  } else {
10878
10918
  return {
10879
10919
  label: String(v),
10880
- value: String(v)
10920
+ value: getRawId$3(String(v))
10881
10921
  };
10882
10922
  }
10883
10923
  });
@@ -11386,10 +11426,6 @@ var READ_VITAL_APPLICABLE = createAsyncThunk("vitalApplicableApiSlice/vitalsappl
11386
11426
  state,
11387
11427
  ccState,
11388
11428
  data,
11389
- rawList,
11390
- resVal,
11391
- firstKey,
11392
- innerVal,
11393
11429
  res,
11394
11430
  _args1 = arguments,
11395
11431
  _t1;
@@ -11408,28 +11444,7 @@ var READ_VITAL_APPLICABLE = createAsyncThunk("vitalApplicableApiSlice/vitalsappl
11408
11444
  }, __baseUrl__$1);
11409
11445
  case 2:
11410
11446
  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);
11447
+ res = generateApplicableResJson(data, ccState);
11433
11448
  return _context1.a(2, _objectSpread2(_objectSpread2({}, defaultState.List), {}, {
11434
11449
  data: res
11435
11450
  }));
@@ -12933,10 +12948,10 @@ var vitalsMasterSectionActions = {
12933
12948
  var vitalsMasterSectionSlice$1 = vitalsMasterSectionSlice.reducer;
12934
12949
 
12935
12950
  var getActiveDbName$1 = function getActiveDbName() {
12936
- return dbName || _dbName || getBinderEnv("REACT_APP_DATABASE_NAME");
12951
+ return dbName || _dbName || getBinderEnv("REACT_APP_APPNAME");
12937
12952
  };
12938
12953
  var getActiveMetadataDbName$1 = function getActiveMetadataDbName() {
12939
- return metaDatadbName$1 || getBinderEnv("REACT_APP_METADATA_DB_NAME");
12954
+ return metaDatadbName$1 || getBinderEnv("REACT_APP_META_APP_NAME");
12940
12955
  };
12941
12956
  var getActiveMetadataId$1 = function getActiveMetadataId() {
12942
12957
  return metaDataId$1 || getBinderEnv("REACT_APP_METADATAID");
@@ -13019,14 +13034,15 @@ var queries$n = {
13019
13034
  metadata_dbname: getActiveMetadataDbName$1()
13020
13035
  }, doc)];
13021
13036
  },
13022
- locationtree: function locationtree(search, offset, limit) {
13037
+ locationtree: function locationtree(search, page, perPage, facilityid) {
13023
13038
  return {
13024
13039
  appcode: getActiveDbName$1(),
13025
13040
  requestid: query_ids.location_tree,
13026
13041
  filter: {
13027
13042
  search: search ? "%".concat(search, "%") : "",
13028
- offset: offset,
13029
- limit: limit
13043
+ page: page,
13044
+ perPage: perPage,
13045
+ facilityid: facilityid || ""
13030
13046
  }
13031
13047
  };
13032
13048
  },
@@ -13393,10 +13409,12 @@ var LOCATION_TREE_READ = createAsyncThunk("locationApiSlice/locationtree", /*#__
13393
13409
  rejectWithValue,
13394
13410
  _payload$search,
13395
13411
  search,
13396
- _payload$offset,
13397
- offset,
13398
- _payload$limit,
13399
- limit,
13412
+ _payload$page,
13413
+ page,
13414
+ _payload$perPage,
13415
+ perPage,
13416
+ _payload$facilityid,
13417
+ facilityid,
13400
13418
  data,
13401
13419
  _args4 = arguments,
13402
13420
  _t4;
@@ -13406,16 +13424,17 @@ var LOCATION_TREE_READ = createAsyncThunk("locationApiSlice/locationtree", /*#__
13406
13424
  payload = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
13407
13425
  _ref8 = _args4.length > 1 ? _args4[1] : undefined, rejectWithValue = _ref8.rejectWithValue;
13408
13426
  _context4.p = 1;
13409
- _payload$search = payload.search, search = _payload$search === void 0 ? "" : _payload$search, _payload$offset = payload.offset, offset = _payload$offset === void 0 ? 0 : _payload$offset, _payload$limit = payload.limit, limit = _payload$limit === void 0 ? 10 : _payload$limit;
13427
+ _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
13428
  _context4.n = 2;
13411
13429
  return fetchData({
13412
- body: JSON.stringify(queries$n.locationtree(search, offset, limit))
13430
+ body: JSON.stringify(queries$n.locationtree(search, page, perPage, facilityid))
13413
13431
  }, __baseUrl__$1);
13414
13432
  case 2:
13415
13433
  data = _context4.v;
13416
13434
  return _context4.a(2, _objectSpread2(_objectSpread2({}, defaultState.List), {}, {
13417
13435
  data: data,
13418
- offset: offset
13436
+ page: page,
13437
+ facilityid: facilityid
13419
13438
  }));
13420
13439
  case 3:
13421
13440
  _context4.p = 3;
@@ -13493,10 +13512,19 @@ var locationSlice = createSlice({
13493
13512
  builder.addCase(LOCATION_TREE_READ.fulfilled, function (state, action) {
13494
13513
  state.location_tree.loading = false;
13495
13514
  state.location_tree.error = false;
13496
- var isLoadMore = action.payload.offset > 0;
13515
+ var facilityid = action.payload.facilityid;
13516
+ if (facilityid) {
13517
+ // Facility drill-down (triggered by expanding one node): the result
13518
+ // belongs to that one node only. It is consumed directly from this
13519
+ // thunk's resolved payload by whichever component requested it -
13520
+ // the shared top-level tree list is deliberately left untouched here,
13521
+ // so a single expand can never affect any other facility's data.
13522
+ return;
13523
+ }
13524
+ var currentData = state.location_tree.data || [];
13525
+ var newData = action.payload.data || [];
13526
+ var isLoadMore = action.payload.page > 0;
13497
13527
  if (isLoadMore) {
13498
- var currentData = state.location_tree.data || [];
13499
- var newData = action.payload.data || [];
13500
13528
  var mergedData = _toConsumableArray(currentData);
13501
13529
  newData.forEach(function (newOrgObj) {
13502
13530
  var orgName = Object.keys(newOrgObj)[0];
@@ -13504,7 +13532,18 @@ var locationSlice = createSlice({
13504
13532
  return Object.keys(org)[0] === orgName;
13505
13533
  });
13506
13534
  if (existingOrgIndex !== -1) {
13507
- mergedData[existingOrgIndex][orgName] = [].concat(_toConsumableArray(mergedData[existingOrgIndex][orgName]), _toConsumableArray(newOrgObj[orgName]));
13535
+ var existingItems = mergedData[existingOrgIndex][orgName];
13536
+ // De-duped by id: a later page re-returning an item already on
13537
+ // an earlier page (e.g. an off-by-one on the backend) must not
13538
+ // add a second copy of it here.
13539
+ var existingIds = new Set(existingItems.map(function (it) {
13540
+ return it._id || it._key || it.locationID;
13541
+ }));
13542
+ var newItems = (newOrgObj[orgName] || []).filter(function (it) {
13543
+ var id = it._id || it._key || it.locationID;
13544
+ return id === undefined || !existingIds.has(id);
13545
+ });
13546
+ mergedData[existingOrgIndex][orgName] = [].concat(_toConsumableArray(existingItems), _toConsumableArray(newItems));
13508
13547
  } else {
13509
13548
  mergedData.push(newOrgObj);
13510
13549
  }
@@ -13516,11 +13555,21 @@ var locationSlice = createSlice({
13516
13555
  state.location_tree = action.payload;
13517
13556
  }
13518
13557
  });
13519
- builder.addCase(LOCATION_TREE_READ.pending, function (state) {
13558
+ builder.addCase(LOCATION_TREE_READ.pending, function (state, action) {
13559
+ var _action$meta;
13560
+ // A per-facility drill-down (triggered by expanding one node) shows its
13561
+ // own local spinner in that node - it must not flip the whole-tree
13562
+ // loading flag, which would blank out the already-rendered list.
13563
+ 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
13564
  state.location_tree.loading = true;
13521
13565
  state.location_tree.error = false;
13522
13566
  });
13523
13567
  builder.addCase(LOCATION_TREE_READ.rejected, function (state, action) {
13568
+ var _action$meta2;
13569
+ // Same reasoning as .pending: a failed facility drill-down must not
13570
+ // wipe out the rest of the already-loaded tree. The component reads
13571
+ // the rejection off the dispatch promise itself to show a per-node error.
13572
+ 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
13573
  state.location_tree.loading = false;
13525
13574
  state.location_tree.error = true;
13526
13575
  state.location_tree = action.payload;
@@ -17766,7 +17815,7 @@ var queries$l = {
17766
17815
  return {
17767
17816
  appcode: dbName,
17768
17817
  requestid: "9d2753a8-4c3e-4b21-817a-5b4d1101e4a1",
17769
- request: {
17818
+ filter: {
17770
17819
  page: page,
17771
17820
  perPage: perPage,
17772
17821
  search: search,
@@ -42121,7 +42170,7 @@ var queries$3 = {
42121
42170
  appcode: dbName,
42122
42171
  requestid: query_ids.geoCountryRead,
42123
42172
  filter: {
42124
- Leveltype: "country",
42173
+ type: "country",
42125
42174
  activestatus: true
42126
42175
  }
42127
42176
  };
@@ -42161,8 +42210,8 @@ var queries$3 = {
42161
42210
  requestid: query_ids.geoMasterParentCode,
42162
42211
  filter: {
42163
42212
  activestatus: true,
42164
- Leveltype: rawId,
42165
- code: ""
42213
+ levelType: rawId,
42214
+ levelCode: ""
42166
42215
  }
42167
42216
  };
42168
42217
  },
@@ -42173,8 +42222,8 @@ var queries$3 = {
42173
42222
  appcode: dbName,
42174
42223
  requestid: query_ids.geoMasterParentCode,
42175
42224
  filter: {
42176
- Leveltype: levelType,
42177
- code: geoLevelCode,
42225
+ levelType: levelType,
42226
+ levelCode: geoLevelCode,
42178
42227
  activestatus: true
42179
42228
  }
42180
42229
  };
@@ -43275,7 +43324,8 @@ var GENERAL_MASTERS_READ = createAsyncThunk("generalMasterSlice/generalMastersRe
43275
43324
  body = {
43276
43325
  "appcode": dbName,
43277
43326
  "filter": {
43278
- "searchVal": (_payload$search = payload.search) !== null && _payload$search !== void 0 ? _payload$search : ""
43327
+ "searchVal": (_payload$search = payload.search) !== null && _payload$search !== void 0 ? _payload$search : "",
43328
+ "activestatus": true
43279
43329
  },
43280
43330
  "requestid": query_ids["generalMasterSearch"]
43281
43331
  }; // alert(JSON.stringify(queriesjson))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primary_care_admin_binder",
3
- "version": "0.1.200",
3
+ "version": "0.1.202",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",