primarycare-binder 1.1.14 → 1.1.15

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 +325 -72
  2. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -8016,7 +8016,7 @@ var query_ids = {
8016
8016
  "db_name": dbName,
8017
8017
  "entity": "Schedule",
8018
8018
  "filter": "Schedule.start >= ".concat(start, " AND Schedule.end <= ").concat(end, " AND Schedule.activestatus == true AND DOCUMENT(Schedule.resourceCode).id == ").concat(id),
8019
- "return_fields": "MERGE(Schedule, {slots : (FOR slt IN Slot FILTER Schedule.id IN slt.ScheduleID AND slt.status!='blocked' AND slt.start >= ".concat(moment().unix(), " AND slt.activestatus==true sort slt._id asc RETURN slt)})")
8019
+ "return_fields": "MERGE(Schedule, {slots : (FOR slt IN Slot FILTER Schedule.id IN slt.ScheduleID AND slt.status!='blocked' AND slt.start >= ".concat(moment().unix(), " AND slt.activestatus==true sort slt._id asc RETURN merge(slt, {DayType: Document(slt.DayType)}))})")
8020
8020
  };
8021
8021
  } // query: ({ start, end, id }) => ({
8022
8022
  // "db_name": dbName,
@@ -9534,6 +9534,141 @@ var getImgUrl = function getImgUrl(fileId) {
9534
9534
  return fileId ? "".concat(__imgdownloadBaseUrl__).concat(fileId) : "";
9535
9535
  };
9536
9536
 
9537
+ var deg2rad = function deg2rad(deg) {
9538
+ return deg * (Math.PI / 180);
9539
+ };
9540
+
9541
+ var getDisctanceFromLatLonInKm = function getDisctanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
9542
+ var R = 6371; // Radius of the earth in km
9543
+
9544
+ var dLat = deg2rad(lat2 - lat1); // deg2rad below
9545
+
9546
+ var dLon = deg2rad(lon2 - lon1);
9547
+ var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2);
9548
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
9549
+ var d = R * c; // Distance in km
9550
+
9551
+ return parseFloat(d).toFixed(2);
9552
+ };
9553
+
9554
+ var getLocation = function getLocation() {
9555
+ return new es6Promise.Promise(function (resolve, reject) {
9556
+ navigator.geolocation.getCurrentPosition(function (position) {
9557
+ var lat = position.coords.latitude;
9558
+ var _long = position.coords.longitude;
9559
+ resolve([false, {
9560
+ lat: lat,
9561
+ "long": _long
9562
+ }]);
9563
+ }, function (error) {
9564
+ resolve([true, error]);
9565
+ });
9566
+ });
9567
+ };
9568
+
9569
+ var getCurrentPosition = /*#__PURE__*/function () {
9570
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
9571
+ var permission, lat, _long2, _yield$getLocation, _yield$getLocation2, err, currLocation;
9572
+
9573
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
9574
+ while (1) {
9575
+ switch (_context2.prev = _context2.next) {
9576
+ case 0:
9577
+ _context2.next = 2;
9578
+ return navigator.permissions.query({
9579
+ name: 'geolocation'
9580
+ })["catch"](function (err) {
9581
+ return {
9582
+ state: 'denied'
9583
+ };
9584
+ });
9585
+
9586
+ case 2:
9587
+ permission = _context2.sent;
9588
+
9589
+ if (!(permission.state !== 'denied')) {
9590
+ _context2.next = 11;
9591
+ break;
9592
+ }
9593
+
9594
+ _context2.next = 6;
9595
+ return getLocation();
9596
+
9597
+ case 6:
9598
+ _yield$getLocation = _context2.sent;
9599
+ _yield$getLocation2 = _slicedToArray(_yield$getLocation, 2);
9600
+ err = _yield$getLocation2[0];
9601
+ currLocation = _yield$getLocation2[1];
9602
+
9603
+ if (!err) {
9604
+ lat = currLocation.lat;
9605
+ _long2 = currLocation["long"];
9606
+ }
9607
+
9608
+ case 11:
9609
+ return _context2.abrupt("return", {
9610
+ lat: lat,
9611
+ "long": _long2
9612
+ });
9613
+
9614
+ case 12:
9615
+ case "end":
9616
+ return _context2.stop();
9617
+ }
9618
+ }
9619
+ }, _callee2);
9620
+ }));
9621
+
9622
+ return function getCurrentPosition() {
9623
+ return _ref4.apply(this, arguments);
9624
+ };
9625
+ }();
9626
+
9627
+ var getLatLong = /*#__PURE__*/function () {
9628
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(city) {
9629
+ var _resp$results, _resp$results$, _resp$results$$geomet, _resp$results$$geomet2, _resp$results2, _resp$results2$, _resp$results2$$geome, _resp$results2$$geome2;
9630
+
9631
+ var url, data, resp, lat, _long3, _resp$results3, _resp$results3$, _resp$results3$$geome, _resp$results3$$geome2, _resp$results4, _resp$results4$, _resp$results4$$geome, _resp$results4$$geome2;
9632
+
9633
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
9634
+ while (1) {
9635
+ switch (_context3.prev = _context3.next) {
9636
+ case 0:
9637
+ url = "https://maps.googleapis.com/maps/api/geocode/json?address=".concat(city, "&key=AIzaSyBqeACJgp12OLU6EkHeUtFgya2naH1LhrU");
9638
+ _context3.next = 3;
9639
+ return fetch(url);
9640
+
9641
+ case 3:
9642
+ data = _context3.sent;
9643
+ _context3.next = 6;
9644
+ return data.json();
9645
+
9646
+ case 6:
9647
+ resp = _context3.sent;
9648
+
9649
+ if ((resp === null || resp === void 0 ? void 0 : (_resp$results = resp.results) === null || _resp$results === void 0 ? void 0 : (_resp$results$ = _resp$results[0]) === null || _resp$results$ === void 0 ? void 0 : (_resp$results$$geomet = _resp$results$.geometry) === null || _resp$results$$geomet === void 0 ? void 0 : (_resp$results$$geomet2 = _resp$results$$geomet.location) === null || _resp$results$$geomet2 === void 0 ? void 0 : _resp$results$$geomet2.lat) && (resp === null || resp === void 0 ? void 0 : (_resp$results2 = resp.results) === null || _resp$results2 === void 0 ? void 0 : (_resp$results2$ = _resp$results2[0]) === null || _resp$results2$ === void 0 ? void 0 : (_resp$results2$$geome = _resp$results2$.geometry) === null || _resp$results2$$geome === void 0 ? void 0 : (_resp$results2$$geome2 = _resp$results2$$geome.location) === null || _resp$results2$$geome2 === void 0 ? void 0 : _resp$results2$$geome2.lng)) {
9650
+ lat = resp === null || resp === void 0 ? void 0 : (_resp$results3 = resp.results) === null || _resp$results3 === void 0 ? void 0 : (_resp$results3$ = _resp$results3[0]) === null || _resp$results3$ === void 0 ? void 0 : (_resp$results3$$geome = _resp$results3$.geometry) === null || _resp$results3$$geome === void 0 ? void 0 : (_resp$results3$$geome2 = _resp$results3$$geome.location) === null || _resp$results3$$geome2 === void 0 ? void 0 : _resp$results3$$geome2.lat;
9651
+ _long3 = resp === null || resp === void 0 ? void 0 : (_resp$results4 = resp.results) === null || _resp$results4 === void 0 ? void 0 : (_resp$results4$ = _resp$results4[0]) === null || _resp$results4$ === void 0 ? void 0 : (_resp$results4$$geome = _resp$results4$.geometry) === null || _resp$results4$$geome === void 0 ? void 0 : (_resp$results4$$geome2 = _resp$results4$$geome.location) === null || _resp$results4$$geome2 === void 0 ? void 0 : _resp$results4$$geome2.lng;
9652
+ }
9653
+
9654
+ return _context3.abrupt("return", {
9655
+ lat: lat,
9656
+ "long": _long3
9657
+ });
9658
+
9659
+ case 9:
9660
+ case "end":
9661
+ return _context3.stop();
9662
+ }
9663
+ }
9664
+ }, _callee3);
9665
+ }));
9666
+
9667
+ return function getLatLong(_x2) {
9668
+ return _ref5.apply(this, arguments);
9669
+ };
9670
+ }();
9671
+
9537
9672
  var _extraReducers$C;
9538
9673
  var __options$8 = {
9539
9674
  method: "POST",
@@ -10636,7 +10771,7 @@ var APPOINTMENT_UPDATE = createAsyncThunk("appointmentReducer/updateAppointment"
10636
10771
  break;
10637
10772
  }
10638
10773
 
10639
- throw new Error(data.error && (typeof data.error === "string" ? data.error : data.message));
10774
+ throw new Error(data.error && (typeof data.error === "string" ? data.error : data.message || data.errorMessage));
10640
10775
 
10641
10776
  case 9:
10642
10777
  return _context2.abrupt("return", _objectSpread2(_objectSpread2({}, defaultState.List), {}, {
@@ -13521,9 +13656,10 @@ var practitionerReducer$1 = practitionerReducer.reducer;
13521
13656
 
13522
13657
  var _extraReducers$x;
13523
13658
 
13524
- var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
13659
+
13660
+ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
13525
13661
  var payload,
13526
- _ref2,
13662
+ _ref3,
13527
13663
  rejectWithValue,
13528
13664
  date,
13529
13665
  startTime,
@@ -13538,15 +13674,16 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13538
13674
  data,
13539
13675
  returnData,
13540
13676
  allLangs,
13541
- _args = arguments;
13677
+ allCities,
13678
+ _args2 = arguments;
13542
13679
 
13543
- return regeneratorRuntime.wrap(function _callee$(_context) {
13680
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
13544
13681
  while (1) {
13545
- switch (_context.prev = _context.next) {
13682
+ switch (_context2.prev = _context2.next) {
13546
13683
  case 0:
13547
- payload = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
13548
- _ref2 = _args.length > 1 ? _args[1] : undefined, rejectWithValue = _ref2.rejectWithValue;
13549
- _context.prev = 2;
13684
+ payload = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
13685
+ _ref3 = _args2.length > 1 ? _args2[1] : undefined, rejectWithValue = _ref3.rejectWithValue;
13686
+ _context2.prev = 2;
13550
13687
  date = new Date();
13551
13688
 
13552
13689
  if (payload.date) {
@@ -13597,15 +13734,16 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13597
13734
  // }
13598
13735
 
13599
13736
 
13600
- _context.next = 12;
13737
+ _context2.next = 12;
13601
13738
  return fetchData$3({
13602
13739
  body: JSON.stringify(body)
13603
13740
  });
13604
13741
 
13605
13742
  case 12:
13606
- data = _context.sent;
13743
+ data = _context2.sent;
13607
13744
  returnData = [];
13608
13745
  allLangs = new Set();
13746
+ allCities = new Set();
13609
13747
 
13610
13748
  if (Array.isArray(data) && Array.isArray(data[0])) {
13611
13749
  data[0].forEach(function (record) {
@@ -13617,7 +13755,7 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13617
13755
  restData = _objectWithoutProperties(record, ["OrgType", "id", "_id", "displayresource"]);
13618
13756
 
13619
13757
  if (displayresource) {
13620
- var _OrgType$some, _restData$locationID, _restData$hospital2, _OrgType$, _restData$hospital3, _restData$hospital3$O, _restData$hospital4;
13758
+ var _OrgType$some, _restData$address, _restData$address$, _restData$hospital2, _restData$hospital2$a, _restData$hospital2$a2, _restData$locationID, _restData$hospital3, _OrgType$, _restData$hospital4, _restData$hospital4$O, _restData$hospital5;
13621
13759
 
13622
13760
  var resourceInfo = {
13623
13761
  resourcetype: "",
@@ -13669,6 +13807,8 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13669
13807
  // isClinic,
13670
13808
  // );
13671
13809
 
13810
+ var city = (restData === null || restData === void 0 ? void 0 : (_restData$address = restData.address) === null || _restData$address === void 0 ? void 0 : (_restData$address$ = _restData$address[0]) === null || _restData$address$ === void 0 ? void 0 : _restData$address$.city) || (restData === null || restData === void 0 ? void 0 : (_restData$hospital2 = restData.hospital) === null || _restData$hospital2 === void 0 ? void 0 : (_restData$hospital2$a = _restData$hospital2.address) === null || _restData$hospital2$a === void 0 ? void 0 : (_restData$hospital2$a2 = _restData$hospital2$a[0]) === null || _restData$hospital2$a2 === void 0 ? void 0 : _restData$hospital2$a2.city) || "";
13811
+ allCities.add(city);
13672
13812
  var info = {
13673
13813
  clinicId: (restData === null || restData === void 0 ? void 0 : (_restData$locationID = restData.locationID) === null || _restData$locationID === void 0 ? void 0 : _restData$locationID.id) || 0,
13674
13814
  id: id,
@@ -13683,6 +13823,7 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13683
13823
  hospitalName: "",
13684
13824
  hospitalLocation: "",
13685
13825
  kms: "0 Kms",
13826
+ city: city,
13686
13827
  weekCalendar: payload.date && payload.date * 1000 || Date.now(),
13687
13828
  isAllSession: isClinic,
13688
13829
  allSession: allSession,
@@ -13696,15 +13837,15 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13696
13837
  resourceInfo: resourceInfo,
13697
13838
  specialities: [],
13698
13839
  healthCareId: healthCareId,
13699
- orgId: isClinic ? id : restData === null || restData === void 0 ? void 0 : (_restData$hospital2 = restData.hospital) === null || _restData$hospital2 === void 0 ? void 0 : _restData$hospital2.id,
13700
- orgType: isClinic ? OrgType === null || OrgType === void 0 ? void 0 : (_OrgType$ = OrgType[0]) === null || _OrgType$ === void 0 ? void 0 : _OrgType$._id : restData === null || restData === void 0 ? void 0 : (_restData$hospital3 = restData.hospital) === null || _restData$hospital3 === void 0 ? void 0 : (_restData$hospital3$O = _restData$hospital3.OrgType) === null || _restData$hospital3$O === void 0 ? void 0 : _restData$hospital3$O[0],
13701
- org_Id: isClinic ? _id : restData === null || restData === void 0 ? void 0 : (_restData$hospital4 = restData.hospital) === null || _restData$hospital4 === void 0 ? void 0 : _restData$hospital4._id,
13840
+ orgId: isClinic ? id : restData === null || restData === void 0 ? void 0 : (_restData$hospital3 = restData.hospital) === null || _restData$hospital3 === void 0 ? void 0 : _restData$hospital3.id,
13841
+ orgType: isClinic ? OrgType === null || OrgType === void 0 ? void 0 : (_OrgType$ = OrgType[0]) === null || _OrgType$ === void 0 ? void 0 : _OrgType$._id : restData === null || restData === void 0 ? void 0 : (_restData$hospital4 = restData.hospital) === null || _restData$hospital4 === void 0 ? void 0 : (_restData$hospital4$O = _restData$hospital4.OrgType) === null || _restData$hospital4$O === void 0 ? void 0 : _restData$hospital4$O[0],
13842
+ org_Id: isClinic ? _id : restData === null || restData === void 0 ? void 0 : (_restData$hospital5 = restData.hospital) === null || _restData$hospital5 === void 0 ? void 0 : _restData$hospital5._id,
13702
13843
  _id: isClinic ? _id : restData === null || restData === void 0 ? void 0 : restData._id,
13703
13844
  _key: restData === null || restData === void 0 ? void 0 : restData._key
13704
13845
  };
13705
13846
 
13706
13847
  if (isClinic) {
13707
- var _restData$clinics5, _restData$clinics5$, _s$Type, _restData$locationID2, _restData$address, _restData$address$, _restData$address2, _restData$address2$, _restData$Practitione, _restData$address3, _restData$address3$, _restData$locationID3, _restData$locationID4, _restData$locationID5;
13848
+ var _restData$clinics5, _restData$clinics5$, _s$Type, _restData$locationID2, _restData$address2, _restData$address2$, _restData$address3, _restData$address3$, _restData$Practitione, _restData$address4, _restData$address4$, _restData$locationID3, _restData$locationID4, _restData$locationID5;
13708
13849
 
13709
13850
  var s = restData === null || restData === void 0 ? void 0 : (_restData$clinics5 = restData.clinics) === null || _restData$clinics5 === void 0 ? void 0 : (_restData$clinics5$ = _restData$clinics5[0]) === null || _restData$clinics5$ === void 0 ? void 0 : _restData$clinics5$.Specialties;
13710
13851
 
@@ -13725,8 +13866,8 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13725
13866
 
13726
13867
  info["name"] = (restData === null || restData === void 0 ? void 0 : (_restData$locationID2 = restData.locationID) === null || _restData$locationID2 === void 0 ? void 0 : _restData$locationID2.shortdesc) || "";
13727
13868
  info["hospitalName"] = (restData === null || restData === void 0 ? void 0 : restData.name) || "";
13728
- info["hospitalLocation"] = (restData === null || restData === void 0 ? void 0 : (_restData$address = restData.address) === null || _restData$address === void 0 ? void 0 : (_restData$address$ = _restData$address[0]) === null || _restData$address$ === void 0 ? void 0 : _restData$address$.line) || "";
13729
- info["title"] = (restData === null || restData === void 0 ? void 0 : (_restData$address2 = restData.address) === null || _restData$address2 === void 0 ? void 0 : (_restData$address2$ = _restData$address2[0]) === null || _restData$address2$ === void 0 ? void 0 : _restData$address2$.line) || "";
13869
+ info["hospitalLocation"] = (restData === null || restData === void 0 ? void 0 : (_restData$address2 = restData.address) === null || _restData$address2 === void 0 ? void 0 : (_restData$address2$ = _restData$address2[0]) === null || _restData$address2$ === void 0 ? void 0 : _restData$address2$.line) || "";
13870
+ info["title"] = (restData === null || restData === void 0 ? void 0 : (_restData$address3 = restData.address) === null || _restData$address3 === void 0 ? void 0 : (_restData$address3$ = _restData$address3[0]) === null || _restData$address3$ === void 0 ? void 0 : _restData$address3$.line) || "";
13730
13871
  info["gender"] = null;
13731
13872
  info["memberIncludes"] = restData === null || restData === void 0 ? void 0 : restData.member_count;
13732
13873
  info["memberIncludesImg"] = restData === null || restData === void 0 ? void 0 : (_restData$Practitione = restData.Practitioner) === null || _restData$Practitione === void 0 ? void 0 : _restData$Practitione.map(function (p) {
@@ -13738,11 +13879,11 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13738
13879
 
13739
13880
  return "";
13740
13881
  });
13741
- info["kms"] = (restData === null || restData === void 0 ? void 0 : (_restData$address3 = restData.address) === null || _restData$address3 === void 0 ? void 0 : (_restData$address3$ = _restData$address3[0]) === null || _restData$address3$ === void 0 ? void 0 : _restData$address3$.distance) ? "".concat(restData.address[0].distance) : "0";
13882
+ info["kms"] = (restData === null || restData === void 0 ? void 0 : (_restData$address4 = restData.address) === null || _restData$address4 === void 0 ? void 0 : (_restData$address4$ = _restData$address4[0]) === null || _restData$address4$ === void 0 ? void 0 : _restData$address4$.distance) ? "".concat(restData.address[0].distance) : "0";
13742
13883
  info["key"] = restData === null || restData === void 0 ? void 0 : restData._key;
13743
13884
  info["img"] = getImgUrl(restData === null || restData === void 0 ? void 0 : (_restData$locationID3 = restData.locationID) === null || _restData$locationID3 === void 0 ? void 0 : (_restData$locationID4 = _restData$locationID3.photo) === null || _restData$locationID4 === void 0 ? void 0 : (_restData$locationID5 = _restData$locationID4[0]) === null || _restData$locationID5 === void 0 ? void 0 : _restData$locationID5.fileid);
13744
13885
  } else {
13745
- var _restData$gender, _restData$gender$codi, _restData$gender$codi2, _restData$Specialties, _restData$communicati, _restData$hospital5, _restData$qualificati, _restData$qualificati2, _restData$qualificati3, _restData$hospital6, _restData$address4, _restData$address4$, _restData$name, _restData$photo, _restData$photo$, _restData$address5, _restData$address5$;
13886
+ var _restData$gender, _restData$gender$codi, _restData$gender$codi2, _restData$Specialties, _restData$communicati, _restData$hospital6, _restData$qualificati, _restData$qualificati2, _restData$qualificati3, _restData$hospital7, _restData$address5, _restData$address5$, _restData$name, _restData$photo, _restData$photo$, _restData$address6, _restData$address6$;
13746
13887
 
13747
13888
  var gender = (restData === null || restData === void 0 ? void 0 : (_restData$gender = restData.gender) === null || _restData$gender === void 0 ? void 0 : (_restData$gender$codi = _restData$gender.coding) === null || _restData$gender$codi === void 0 ? void 0 : (_restData$gender$codi2 = _restData$gender$codi[0]) === null || _restData$gender$codi2 === void 0 ? void 0 : _restData$gender$codi2.display) || "";
13748
13889
  var designation = "";
@@ -13782,17 +13923,17 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13782
13923
  });
13783
13924
  info["title"] = "".concat(gender).concat(gender && " | ").concat(designation);
13784
13925
  info["gender"] = gender;
13785
- info["hospId"] = restData === null || restData === void 0 ? void 0 : (_restData$hospital5 = restData.hospital) === null || _restData$hospital5 === void 0 ? void 0 : _restData$hospital5.id;
13926
+ info["hospId"] = restData === null || restData === void 0 ? void 0 : (_restData$hospital6 = restData.hospital) === null || _restData$hospital6 === void 0 ? void 0 : _restData$hospital6.id;
13786
13927
  info["subtext"] = (restData === null || restData === void 0 ? void 0 : (_restData$qualificati = restData.qualification) === null || _restData$qualificati === void 0 ? void 0 : (_restData$qualificati2 = _restData$qualificati.map) === null || _restData$qualificati2 === void 0 ? void 0 : (_restData$qualificati3 = _restData$qualificati2.call(_restData$qualificati, function (q) {
13787
13928
  return (q === null || q === void 0 ? void 0 : q.name) || "";
13788
13929
  })) === null || _restData$qualificati3 === void 0 ? void 0 : _restData$qualificati3.join(", ")) || "MBBS";
13789
13930
  info["language"] = languages.size > 0 ? _toConsumableArray(languages) : [];
13790
- info["hospitalName"] = (restData === null || restData === void 0 ? void 0 : (_restData$hospital6 = restData.hospital) === null || _restData$hospital6 === void 0 ? void 0 : _restData$hospital6.name) || "";
13791
- info["hospitalLocation"] = (restData === null || restData === void 0 ? void 0 : (_restData$address4 = restData.address) === null || _restData$address4 === void 0 ? void 0 : (_restData$address4$ = _restData$address4[0]) === null || _restData$address4$ === void 0 ? void 0 : _restData$address4$.line) || "";
13931
+ info["hospitalName"] = (restData === null || restData === void 0 ? void 0 : (_restData$hospital7 = restData.hospital) === null || _restData$hospital7 === void 0 ? void 0 : _restData$hospital7.name) || "";
13932
+ info["hospitalLocation"] = (restData === null || restData === void 0 ? void 0 : (_restData$address5 = restData.address) === null || _restData$address5 === void 0 ? void 0 : (_restData$address5$ = _restData$address5[0]) === null || _restData$address5$ === void 0 ? void 0 : _restData$address5$.line) || "";
13792
13933
  var nameObj = (restData === null || restData === void 0 ? void 0 : (_restData$name = restData.name) === null || _restData$name === void 0 ? void 0 : _restData$name[0]) || {};
13793
13934
  info["name"] = makeName(nameObj);
13794
13935
  info["img"] = getImgUrl(restData === null || restData === void 0 ? void 0 : (_restData$photo = restData.photo) === null || _restData$photo === void 0 ? void 0 : (_restData$photo$ = _restData$photo[0]) === null || _restData$photo$ === void 0 ? void 0 : _restData$photo$.fileid);
13795
- info["kms"] = (restData === null || restData === void 0 ? void 0 : (_restData$address5 = restData.address) === null || _restData$address5 === void 0 ? void 0 : (_restData$address5$ = _restData$address5[0]) === null || _restData$address5$ === void 0 ? void 0 : _restData$address5$.distance) ? "".concat(restData.address[0].distance) : "0";
13936
+ info["kms"] = (restData === null || restData === void 0 ? void 0 : (_restData$address6 = restData.address) === null || _restData$address6 === void 0 ? void 0 : (_restData$address6$ = _restData$address6[0]) === null || _restData$address6$ === void 0 ? void 0 : _restData$address6$.distance) ? "".concat(restData.address[0].distance) : "0";
13796
13937
  info["key"] = restData === null || restData === void 0 ? void 0 : restData._key;
13797
13938
  }
13798
13939
 
@@ -13800,27 +13941,39 @@ var DOCTER_LISTING = createAsyncThunk("docterListingReducer/docterListing", /*#_
13800
13941
  }
13801
13942
  }
13802
13943
  });
13803
- }
13944
+ } // const {
13945
+ // lat: myLat,
13946
+ // long: myLong,
13947
+ // } = getCurrentPosition();
13948
+ // const locationInfo = {};
13949
+ // if (myLat && myLong) {
13950
+ // const promArr = [...allCities].map(city => getLocationInfo({lat: myLat, long: myLong}, city, locationInfo));
13951
+ // await Promise.all(promArr);
13952
+ // returnData.forEach(d => {
13953
+ // d.kms = locationInfo[d.city] || "0 Kms";
13954
+ // })
13955
+ // }
13804
13956
 
13805
- return _context.abrupt("return", _objectSpread2(_objectSpread2({}, defaultState.Info), {}, {
13957
+
13958
+ return _context2.abrupt("return", _objectSpread2(_objectSpread2({}, defaultState.Info), {}, {
13806
13959
  data: returnData,
13807
13960
  allLangs: _toConsumableArray(allLangs)
13808
13961
  }));
13809
13962
 
13810
- case 19:
13811
- _context.prev = 19;
13812
- _context.t0 = _context["catch"](2);
13813
- console.log(_context.t0);
13814
- return _context.abrupt("return", rejectWithValue(_objectSpread2(_objectSpread2({}, defaultReject), {}, {
13815
- message: _context.t0.message
13963
+ case 20:
13964
+ _context2.prev = 20;
13965
+ _context2.t0 = _context2["catch"](2);
13966
+ console.log(_context2.t0);
13967
+ return _context2.abrupt("return", rejectWithValue(_objectSpread2(_objectSpread2({}, defaultReject), {}, {
13968
+ message: _context2.t0.message
13816
13969
  })));
13817
13970
 
13818
- case 23:
13971
+ case 24:
13819
13972
  case "end":
13820
- return _context.stop();
13973
+ return _context2.stop();
13821
13974
  }
13822
13975
  }
13823
- }, _callee, null, [[2, 19]]);
13976
+ }, _callee2, null, [[2, 20]]);
13824
13977
  }))); // end
13825
13978
  // FUZZY SEARCH CREATE INITIALSTATE
13826
13979
 
@@ -14105,6 +14258,9 @@ var GET_HOSPITALS_LOCALITY = createAsyncThunk("searhcApiSlice/getHospitals", /*#
14105
14258
  location,
14106
14259
  body,
14107
14260
  data,
14261
+ _yield$getCurrentPosi,
14262
+ lat,
14263
+ _long,
14108
14264
  returnData,
14109
14265
  _args4 = arguments;
14110
14266
 
@@ -14115,7 +14271,7 @@ var GET_HOSPITALS_LOCALITY = createAsyncThunk("searhcApiSlice/getHospitals", /*#
14115
14271
  payload = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
14116
14272
  _ref8 = _args4.length > 1 ? _args4[1] : undefined, rejectWithValue = _ref8.rejectWithValue;
14117
14273
  _context4.prev = 2;
14118
- _payload$city2 = payload.city, city = _payload$city2 === void 0 ? "" : _payload$city2, _payload$location = payload.location, location = _payload$location === void 0 ? "" : _payload$location;
14274
+ _payload$city2 = payload.city, city = _payload$city2 === void 0 ? "" : _payload$city2, _payload$location = payload.location, location = _payload$location === void 0 ? {} : _payload$location;
14119
14275
  body = {
14120
14276
  db_name: dbName,
14121
14277
  queryid: query_ids["searhcApiSlice/getHospitals"],
@@ -14133,6 +14289,13 @@ var GET_HOSPITALS_LOCALITY = createAsyncThunk("searhcApiSlice/getHospitals", /*#
14133
14289
 
14134
14290
  case 7:
14135
14291
  data = _context4.sent;
14292
+ _context4.next = 10;
14293
+ return getCurrentPosition();
14294
+
14295
+ case 10:
14296
+ _yield$getCurrentPosi = _context4.sent;
14297
+ lat = _yield$getCurrentPosi.lat;
14298
+ _long = _yield$getCurrentPosi["long"];
14136
14299
  returnData = [];
14137
14300
 
14138
14301
  if (Array.isArray(data)) {
@@ -14140,11 +14303,18 @@ var GET_HOSPITALS_LOCALITY = createAsyncThunk("searhcApiSlice/getHospitals", /*#
14140
14303
  if (hospInfo.id && hospInfo.name) {
14141
14304
  var _hospInfo$address, _hospInfo$address2;
14142
14305
 
14306
+ var distance = "";
14307
+
14308
+ if (lat && _long) {
14309
+ distance = getDisctanceFromLatLonInKm(lat, _long, location.latitude, location.longitude) + " KM";
14310
+ }
14311
+
14143
14312
  returnData.push({
14144
14313
  value: hospInfo.id,
14145
14314
  label: hospInfo.name,
14146
14315
  lat: hospInfo === null || hospInfo === void 0 ? void 0 : (_hospInfo$address = hospInfo.address) === null || _hospInfo$address === void 0 ? void 0 : _hospInfo$address.latitude,
14147
- "long": hospInfo === null || hospInfo === void 0 ? void 0 : (_hospInfo$address2 = hospInfo.address) === null || _hospInfo$address2 === void 0 ? void 0 : _hospInfo$address2.longitude
14316
+ "long": hospInfo === null || hospInfo === void 0 ? void 0 : (_hospInfo$address2 = hospInfo.address) === null || _hospInfo$address2 === void 0 ? void 0 : _hospInfo$address2.longitude,
14317
+ distance: distance
14148
14318
  });
14149
14319
  }
14150
14320
  });
@@ -14154,19 +14324,19 @@ var GET_HOSPITALS_LOCALITY = createAsyncThunk("searhcApiSlice/getHospitals", /*#
14154
14324
  data: returnData
14155
14325
  }));
14156
14326
 
14157
- case 13:
14158
- _context4.prev = 13;
14327
+ case 18:
14328
+ _context4.prev = 18;
14159
14329
  _context4.t0 = _context4["catch"](2);
14160
14330
  return _context4.abrupt("return", rejectWithValue(_objectSpread2(_objectSpread2({}, defaultReject), {}, {
14161
14331
  message: _context4.t0.message
14162
14332
  })));
14163
14333
 
14164
- case 16:
14334
+ case 21:
14165
14335
  case "end":
14166
14336
  return _context4.stop();
14167
14337
  }
14168
14338
  }
14169
- }, _callee4, null, [[2, 13]]);
14339
+ }, _callee4, null, [[2, 18]]);
14170
14340
  })));
14171
14341
  var GET_SYMPTOMS = createAsyncThunk("searhcApiSlice/getSymptoms", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
14172
14342
  var payload,
@@ -14552,26 +14722,82 @@ var SPECIALITY_AGAINST_PRACTITIONER = createAsyncThunk("searhcApiSlice/specialit
14552
14722
  }
14553
14723
  }, _callee10, null, [[2, 12]]);
14554
14724
  })));
14555
- var PRACTITIONER_AGAINST_ORGANIZATION = createAsyncThunk("searhcApiSlice/practitionerAgainstOrganization", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
14725
+
14726
+ var getLocationInfo = /*#__PURE__*/function () {
14727
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
14728
+ var _hospInfo$address3, _hospInfo$address3$, _hospInfo$address3$$c;
14729
+
14730
+ var hospInfo,
14731
+ obj,
14732
+ city,
14733
+ info,
14734
+ _args11 = arguments;
14735
+ return regeneratorRuntime.wrap(function _callee11$(_context11) {
14736
+ while (1) {
14737
+ switch (_context11.prev = _context11.next) {
14738
+ case 0:
14739
+ hospInfo = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
14740
+ obj = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
14741
+ city = hospInfo === null || hospInfo === void 0 ? void 0 : (_hospInfo$address3 = hospInfo.address) === null || _hospInfo$address3 === void 0 ? void 0 : (_hospInfo$address3$ = _hospInfo$address3[0]) === null || _hospInfo$address3$ === void 0 ? void 0 : (_hospInfo$address3$$c = _hospInfo$address3$.city) === null || _hospInfo$address3$$c === void 0 ? void 0 : _hospInfo$address3$$c.geogLevelName;
14742
+
14743
+ if (obj[city]) {
14744
+ _context11.next = 8;
14745
+ break;
14746
+ }
14747
+
14748
+ _context11.next = 6;
14749
+ return getLatLong(city);
14750
+
14751
+ case 6:
14752
+ info = _context11.sent;
14753
+ obj[city] = info;
14754
+
14755
+ case 8:
14756
+ case "end":
14757
+ return _context11.stop();
14758
+ }
14759
+ }
14760
+ }, _callee11);
14761
+ }));
14762
+
14763
+ return function getLocationInfo() {
14764
+ return _ref21.apply(this, arguments);
14765
+ };
14766
+ }();
14767
+
14768
+ var PRACTITIONER_AGAINST_ORGANIZATION = createAsyncThunk("searhcApiSlice/practitionerAgainstOrganization", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
14556
14769
  var payload,
14557
- _ref22,
14770
+ _ref23,
14558
14771
  rejectWithValue,
14559
14772
  _payload$practitioner,
14560
14773
  practitionerId,
14774
+ _yield$getCurrentPosi2,
14775
+ myLat,
14776
+ myLong,
14561
14777
  body,
14562
14778
  data,
14563
14779
  returnData,
14564
14780
  _data$result,
14565
- _args11 = arguments;
14781
+ _data$result2,
14782
+ cityMap,
14783
+ promArr,
14784
+ _args12 = arguments;
14566
14785
 
14567
- return regeneratorRuntime.wrap(function _callee11$(_context11) {
14786
+ return regeneratorRuntime.wrap(function _callee12$(_context12) {
14568
14787
  while (1) {
14569
- switch (_context11.prev = _context11.next) {
14788
+ switch (_context12.prev = _context12.next) {
14570
14789
  case 0:
14571
- payload = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
14572
- _ref22 = _args11.length > 1 ? _args11[1] : undefined, rejectWithValue = _ref22.rejectWithValue;
14573
- _context11.prev = 2;
14790
+ payload = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
14791
+ _ref23 = _args12.length > 1 ? _args12[1] : undefined, rejectWithValue = _ref23.rejectWithValue;
14792
+ _context12.prev = 2;
14574
14793
  _payload$practitioner = payload.practitionerId, practitionerId = _payload$practitioner === void 0 ? "" : _payload$practitioner;
14794
+ _context12.next = 6;
14795
+ return getCurrentPosition();
14796
+
14797
+ case 6:
14798
+ _yield$getCurrentPosi2 = _context12.sent;
14799
+ myLat = _yield$getCurrentPosi2.lat;
14800
+ myLong = _yield$getCurrentPosi2["long"];
14575
14801
  body = {
14576
14802
  db_name: dbName,
14577
14803
  entity: "Practitioner,Organization",
@@ -14579,45 +14805,72 @@ var PRACTITIONER_AGAINST_ORGANIZATION = createAsyncThunk("searhcApiSlice/practit
14579
14805
  Practitioner: "Practitioner.id==".concat(practitionerId),
14580
14806
  Organization: "document(Practitioner.practitioner_role)[*].OrgID any == Organization._id"
14581
14807
  },
14582
- return_fields: "{OrganizationName:Organization.name, OrgID:Organization.id}"
14808
+ return_fields: "{address: (let add = Document(Organization.address[0]) return merge(add, { city: Document(add.city) })), OrganizationName:Organization.name, OrgID:Organization.id}"
14583
14809
  };
14584
- _context11.next = 7;
14810
+ _context12.next = 12;
14585
14811
  return fetchData$3({
14586
14812
  body: JSON.stringify(body)
14587
14813
  }, __readDocumentUrl__);
14588
14814
 
14589
- case 7:
14590
- data = _context11.sent;
14815
+ case 12:
14816
+ data = _context12.sent;
14591
14817
  returnData = [];
14592
14818
 
14593
- if (Array.isArray(data === null || data === void 0 ? void 0 : data.result)) {
14594
- data === null || data === void 0 ? void 0 : (_data$result = data.result) === null || _data$result === void 0 ? void 0 : _data$result.forEach(function (hospInfo) {
14595
- returnData.push({
14596
- value: hospInfo.OrgID,
14597
- label: hospInfo.OrganizationName,
14598
- lat: 0,
14599
- "long": 0
14600
- });
14601
- });
14819
+ if (!Array.isArray(data === null || data === void 0 ? void 0 : data.result)) {
14820
+ _context12.next = 20;
14821
+ break;
14602
14822
  }
14603
14823
 
14604
- return _context11.abrupt("return", _objectSpread2(_objectSpread2({}, defaultState.Info), {}, {
14824
+ cityMap = {};
14825
+ promArr = data === null || data === void 0 ? void 0 : (_data$result = data.result) === null || _data$result === void 0 ? void 0 : _data$result.map(function (hospInfo) {
14826
+ return getLocationInfo(hospInfo, cityMap);
14827
+ });
14828
+ _context12.next = 19;
14829
+ return es6Promise.Promise.all(promArr);
14830
+
14831
+ case 19:
14832
+ data === null || data === void 0 ? void 0 : (_data$result2 = data.result) === null || _data$result2 === void 0 ? void 0 : _data$result2.forEach(function (hospInfo) {
14833
+ var _hospInfo$address4, _hospInfo$address4$, _hospInfo$address4$$c;
14834
+
14835
+ var city = hospInfo === null || hospInfo === void 0 ? void 0 : (_hospInfo$address4 = hospInfo.address) === null || _hospInfo$address4 === void 0 ? void 0 : (_hospInfo$address4$ = _hospInfo$address4[0]) === null || _hospInfo$address4$ === void 0 ? void 0 : (_hospInfo$address4$$c = _hospInfo$address4$.city) === null || _hospInfo$address4$$c === void 0 ? void 0 : _hospInfo$address4$$c.geogLevelName;
14836
+
14837
+ var _ref24 = cityMap[city] || {},
14838
+ lat = _ref24.lat,
14839
+ _long2 = _ref24["long"];
14840
+
14841
+ var distance = "";
14842
+
14843
+ if (myLat && myLong && lat && _long2) {
14844
+ distance = getDisctanceFromLatLonInKm(lat, _long2, myLat, myLong) + " KM";
14845
+ }
14846
+
14847
+ returnData.push({
14848
+ value: hospInfo.OrgID,
14849
+ label: hospInfo.OrganizationName,
14850
+ lat: 0,
14851
+ "long": 0,
14852
+ distance: distance
14853
+ });
14854
+ });
14855
+
14856
+ case 20:
14857
+ return _context12.abrupt("return", _objectSpread2(_objectSpread2({}, defaultState.Info), {}, {
14605
14858
  data: returnData
14606
14859
  }));
14607
14860
 
14608
- case 13:
14609
- _context11.prev = 13;
14610
- _context11.t0 = _context11["catch"](2);
14611
- return _context11.abrupt("return", rejectWithValue(_objectSpread2(_objectSpread2({}, defaultReject), {}, {
14612
- message: _context11.t0.message
14861
+ case 23:
14862
+ _context12.prev = 23;
14863
+ _context12.t0 = _context12["catch"](2);
14864
+ return _context12.abrupt("return", rejectWithValue(_objectSpread2(_objectSpread2({}, defaultReject), {}, {
14865
+ message: _context12.t0.message
14613
14866
  })));
14614
14867
 
14615
- case 16:
14868
+ case 26:
14616
14869
  case "end":
14617
- return _context11.stop();
14870
+ return _context12.stop();
14618
14871
  }
14619
14872
  }
14620
- }, _callee11, null, [[2, 13]]);
14873
+ }, _callee12, null, [[2, 23]]);
14621
14874
  })));
14622
14875
  var searhcApiSlice = createSlice({
14623
14876
  name: "searhcApiSlice",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primarycare-binder",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",