pha-hermes 1.23.0 → 1.25.0

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.
@@ -49,6 +49,15 @@ function _createForOfIteratorHelperLoose(r, e) {
49
49
  }
50
50
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
51
  }
52
+ function _extends() {
53
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
54
+ for (var e = 1; e < arguments.length; e++) {
55
+ var t = arguments[e];
56
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
57
+ }
58
+ return n;
59
+ }, _extends.apply(null, arguments);
60
+ }
52
61
  function _regeneratorRuntime() {
53
62
  _regeneratorRuntime = function () {
54
63
  return e;
@@ -525,7 +534,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
525
534
  while (1) switch (_context.prev = _context.next) {
526
535
  case 0:
527
536
  _context.prev = 0;
528
- url = "/services/data/" + SF_API_VERSION + "/sobjects/TimeSheetHour__c/" + timesheetHourId;
537
+ url = "/services/data/" + SF_API_VERSION$1 + "/sobjects/TimeSheetHour__c/" + timesheetHourId;
529
538
  _context.next = 4;
530
539
  return this.axiosInstance.patch(url, {
531
540
  Date__c: timesheet.date,
@@ -577,7 +586,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
577
586
  while (1) switch (_context2.prev = _context2.next) {
578
587
  case 0:
579
588
  // Find all timesheet Ids that belong to this WO
580
- url = "/services/data/" + SF_API_VERSION + "/query";
589
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
581
590
  query = "SELECT Id\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderId + "'";
582
591
  try {
583
592
  if (periodStartDate && periodEndDate) {
@@ -615,7 +624,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
615
624
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
616
625
  while (1) switch (_context3.prev = _context3.next) {
617
626
  case 0:
618
- url = "/services/data/" + SF_API_VERSION + "/query";
627
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
619
628
  query = "SELECT FIELDS(STANDARD), WorkOrder__c\n FROM TimeSheet__c\n WHERE WorkOrder__c IN (SELECT Id\n FROM WorkOrder__c\n WHERE Personnel__c = '" + personnelID + "')";
620
629
  _context3.next = 4;
621
630
  return this.axiosInstance.get(url, {
@@ -657,7 +666,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
657
666
  case 2:
658
667
  timesheetIds = _context4.sent;
659
668
  allHours = [];
660
- url = "/services/data/" + SF_API_VERSION + "/query";
669
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
661
670
  _iterator2 = _createForOfIteratorHelperLoose(timesheetIds);
662
671
  case 6:
663
672
  if ((_step2 = _iterator2()).done) {
@@ -667,7 +676,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
667
676
  timesheetId = _step2.value;
668
677
  query = "\n SELECT " + ((fields == null ? void 0 : fields.join(',')) || 'FIELDS(STANDARD)') + "\n FROM TimesheetHour__c\n WHERE Timesheet__c = '" + timesheetId + "'";
669
678
  _context4.prev = 9;
670
- if (fields != null && fields.length) {
679
+ if (fields != null && fields.length && periodStartDate && periodEndDate) {
671
680
  query += "\n AND Date__c >= " + new Date(periodStartDate).toISOString().substring(0, 10) + "\n AND Date__c <= " + new Date(periodEndDate).toISOString().substring(0, 10);
672
681
  }
673
682
  _context4.next = 13;
@@ -708,7 +717,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
708
717
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
709
718
  while (1) switch (_context5.prev = _context5.next) {
710
719
  case 0:
711
- url = "/services/data/" + SF_API_VERSION + "/query";
720
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
712
721
  query = "SELECT Name,\n StartDate__c,\n EndDate__c\n FROM PayPeriod__c";
713
722
  _context5.next = 4;
714
723
  return this.axiosInstance.get(url, {
@@ -758,14 +767,14 @@ var SFTimesheetClient = /*#__PURE__*/function () {
758
767
  contentType: 'application/octet-stream'
759
768
  });
760
769
  _context6.next = 6;
761
- return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentVersion", form, {
770
+ return this.axiosInstance.post("/services/data/" + SF_API_VERSION$1 + "/sobjects/ContentVersion", form, {
762
771
  headers: form.getHeaders()
763
772
  });
764
773
  case 6:
765
774
  uploadRes = _context6.sent;
766
775
  versionId = uploadRes.data.id; //get ContentDocumentId
767
776
  _context6.next = 10;
768
- return this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/query", {
777
+ return this.axiosInstance.get("/services/data/" + SF_API_VERSION$1 + "/query", {
769
778
  params: {
770
779
  q: "SELECT ContentDocumentId FROM ContentVersion WHERE Id = '" + versionId + "'"
771
780
  }
@@ -775,7 +784,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
775
784
  data = _yield$this$axiosInst3.data;
776
785
  contentDocumentId = data.records[0].ContentDocumentId;
777
786
  _context6.next = 15;
778
- return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentDocumentLink", {
787
+ return this.axiosInstance.post("/services/data/" + SF_API_VERSION$1 + "/sobjects/ContentDocumentLink", {
779
788
  ContentDocumentId: contentDocumentId,
780
789
  LinkedEntityId: timesheetId,
781
790
  ShareType: 'V',
@@ -827,12 +836,16 @@ function toTimesheetDayEntry(raw) {
827
836
 
828
837
  var SFPractitionerClient = /*#__PURE__*/function () {
829
838
  function SFPractitionerClient(axiosInstance) {
839
+ this.PRACTITIONER_FIELDS = {
840
+ "default": ['Id', 'FirstName__c', 'LastName__c', 'Email__c', 'StaffID__c', 'CreatedDate'],
841
+ "export": ['Id', 'FirstName__c', 'LastName__c', 'Email__c', 'StaffID__c', 'CreatedDate', 'DaytimePhone__c', 'Status__c', 'ProfessionalDesignation__c', 'CANSocialInsuranceNumber__c', 'Date_of_Hire__c', 'DateApplied__c', 'Birthdate__c', 'MailingStreetAddress__c', 'MailingCity__c', 'MailingStateProvince__c', 'MailingZipPostalCode__c']
842
+ };
830
843
  this.axiosInstance = axiosInstance;
831
844
  }
832
845
  var _proto = SFPractitionerClient.prototype;
833
846
  _proto.fetchPractitioners = /*#__PURE__*/function () {
834
847
  var _fetchPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
835
- var conditions, whereClause, limitClause, url, query, _yield$this$axiosInst, records;
848
+ var conditions, whereClause, limitClause, url, fields, query, _yield$this$axiosInst, records;
836
849
  return _regeneratorRuntime().wrap(function _callee$(_context) {
837
850
  while (1) switch (_context.prev = _context.next) {
838
851
  case 0:
@@ -843,28 +856,29 @@ var SFPractitionerClient = /*#__PURE__*/function () {
843
856
  }
844
857
  whereClause = conditions.length ? "WHERE " + conditions.join(' AND ') : '';
845
858
  limitClause = typeof (options == null ? void 0 : options.limit) === 'number' && options.limit > 0 ? "LIMIT " + Math.floor(options.limit) : '';
846
- url = "/services/data/" + SF_API_VERSION + "/query";
847
- query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c, CreatedDate\n FROM Personnel__c\n " + whereClause + "\n ORDER BY CreatedDate ASC, StaffID__c ASC\n " + limitClause + "\n ";
848
- _context.next = 9;
859
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
860
+ fields = (options != null && options.forExport ? this.PRACTITIONER_FIELDS["export"] : this.PRACTITIONER_FIELDS["default"]).join(', ');
861
+ query = "\n SELECT " + fields + "\n FROM Personnel__c\n " + whereClause + "\n ORDER BY CreatedDate ASC, StaffID__c ASC\n " + limitClause + "\n ";
862
+ _context.next = 10;
849
863
  return this.axiosInstance.get(url, {
850
864
  params: {
851
865
  q: query
852
866
  }
853
867
  });
854
- case 9:
868
+ case 10:
855
869
  _yield$this$axiosInst = _context.sent;
856
870
  records = _yield$this$axiosInst.data.records;
857
- return _context.abrupt("return", records.map(toPractitioner));
858
- case 14:
859
- _context.prev = 14;
871
+ return _context.abrupt("return", options != null && options.forExport ? records.map(toPractitionerExport) : records.map(toPractitioner));
872
+ case 15:
873
+ _context.prev = 15;
860
874
  _context.t0 = _context["catch"](0);
861
875
  console.error('Error fetching practitioners: ', _context.t0.message);
862
876
  throw _context.t0;
863
- case 18:
877
+ case 19:
864
878
  case "end":
865
879
  return _context.stop();
866
880
  }
867
- }, _callee, this, [[0, 14]]);
881
+ }, _callee, this, [[0, 15]]);
868
882
  }));
869
883
  function fetchPractitioners(_x) {
870
884
  return _fetchPractitioners.apply(this, arguments);
@@ -878,7 +892,7 @@ var SFPractitionerClient = /*#__PURE__*/function () {
878
892
  while (1) switch (_context2.prev = _context2.next) {
879
893
  case 0:
880
894
  _context2.prev = 0;
881
- url = "/services/data/" + SF_API_VERSION + "/query";
895
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
882
896
  query = "\n SELECT Id, FirstName__c, LastName__c, Email__c, StaffID__c, CreatedDate\n FROM Personnel__c\n WHERE Status__c = 'Active' AND Email__c = '" + email + "'\n ";
883
897
  _context2.next = 5;
884
898
  return this.axiosInstance.get(url, {
@@ -912,6 +926,47 @@ var SFPractitionerClient = /*#__PURE__*/function () {
912
926
  }
913
927
  return fetchPractitionerByEmail;
914
928
  }();
929
+ _proto.fetchRoles = /*#__PURE__*/function () {
930
+ var _fetchRoles = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
931
+ var url, query;
932
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
933
+ while (1) switch (_context3.prev = _context3.next) {
934
+ case 0:
935
+ _context3.prev = 0;
936
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
937
+ query = "SELECT Label, Value FROM PicklistValueInfo WHERE EntityParticle.EntityDefinition.QualifiedApiName = 'WorkOrder__c' AND EntityParticle.QualifiedApiName = 'ProfessionalDesignation__c' AND isActive = true";
938
+ return _context3.abrupt("return", this.axiosInstance.get(url, {
939
+ params: {
940
+ q: query
941
+ }
942
+ }).then(function (_ref) {
943
+ var records = _ref.data.records;
944
+ return records.map(function (record) {
945
+ return {
946
+ label: record.Label,
947
+ value: record.Value
948
+ };
949
+ });
950
+ })["catch"](function (error) {
951
+ console.error('Error fetching roles: ', error.message);
952
+ throw error;
953
+ }));
954
+ case 6:
955
+ _context3.prev = 6;
956
+ _context3.t0 = _context3["catch"](0);
957
+ console.error('Error fetching roles: ', _context3.t0.message);
958
+ throw _context3.t0;
959
+ case 10:
960
+ case "end":
961
+ return _context3.stop();
962
+ }
963
+ }, _callee3, this, [[0, 6]]);
964
+ }));
965
+ function fetchRoles() {
966
+ return _fetchRoles.apply(this, arguments);
967
+ }
968
+ return fetchRoles;
969
+ }();
915
970
  return SFPractitionerClient;
916
971
  }();
917
972
  function toPractitioner(raw) {
@@ -921,9 +976,24 @@ function toPractitioner(raw) {
921
976
  lastName: raw.LastName__c,
922
977
  email: raw.Email__c,
923
978
  staffId: raw.StaffID__c,
924
- createdAt: raw.CreatedDate.replace(/\+0000$/, 'Z')
979
+ createdAt: raw.CreatedDate ? raw.CreatedDate.replace(/\+0000$/, 'Z') : undefined
925
980
  };
926
981
  }
982
+ function toPractitionerExport(raw) {
983
+ return _extends({}, toPractitioner(raw), {
984
+ phone: raw.DaytimePhone__c,
985
+ status: raw.Status__c,
986
+ professionalDesignation: raw.ProfessionalDesignation__c,
987
+ SIN: raw.CANSocialInsuranceNumber__c,
988
+ hiringDate: raw.Date_of_Hire__c,
989
+ dateApplied: raw.DateApplied__c,
990
+ birthdate: raw.Birthdate__c,
991
+ mailingStreetAddress: raw.MailingStreetAddress__c,
992
+ mailingCity: raw.MailingCity__c,
993
+ mailingProvince: raw.MailingStateProvince__c,
994
+ mailingZip: raw.MailingZipPostalCode__c
995
+ });
996
+ }
927
997
 
928
998
  var SFWorkorderClient = /*#__PURE__*/function () {
929
999
  function SFWorkorderClient(axiosInstance) {
@@ -956,7 +1026,7 @@ var SFWorkorderClient = /*#__PURE__*/function () {
956
1026
  filters.push("Region__c IN (" + provincesList + ")");
957
1027
  }
958
1028
  whereClause = filters.length ? "WHERE " + filters.join(' AND ') : '';
959
- url = "/services/data/" + SF_API_VERSION + "/query";
1029
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
960
1030
  query = "SELECT Id,\n Region__c,\n Name,\n HospitalID__c,\n HospitalName__c,\n ProfessionalDesignation__c,\n Personnel__c,\n startdate__c,\n EndDate__c,\n CreatedDate,\n LastModifiedDate,\n Unit__c,\n HealthAuthority__c,\n UnitPrice__r.Price__c,\n TravelDate__c,\n ReturnDate__c\n FROM WorkOrder__c " + whereClause;
961
1031
  _context.next = 11;
962
1032
  return this.axiosInstance.get(url, {
@@ -1028,7 +1098,7 @@ var SFPayPeriodClient = /*#__PURE__*/function () {
1028
1098
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1029
1099
  while (1) switch (_context.prev = _context.next) {
1030
1100
  case 0:
1031
- url = "/services/data/" + SF_API_VERSION + "/query";
1101
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
1032
1102
  query = "SELECT PayPeriod__c, ID\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderID + "'";
1033
1103
  _context.next = 4;
1034
1104
  return this.axiosInstance.get(url, {
@@ -1064,7 +1134,7 @@ var SFPayPeriodClient = /*#__PURE__*/function () {
1064
1134
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1065
1135
  while (1) switch (_context2.prev = _context2.next) {
1066
1136
  case 0:
1067
- url = "/services/data/" + SF_API_VERSION + "/query";
1137
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
1068
1138
  query = "SELECT ID, StartDate__c, EndDate__c\n FROM PayPeriod__c\n WHERE id IN " + listOfIdsForQuery(payPeriodIDs);
1069
1139
  _context2.next = 4;
1070
1140
  return this.axiosInstance.get(url, {
@@ -1098,7 +1168,7 @@ var SFPayPeriodClient = /*#__PURE__*/function () {
1098
1168
  return SFPayPeriodClient;
1099
1169
  }();
1100
1170
  var listOfIdsForQuery = function listOfIdsForQuery(payPeriodIDs) {
1101
- return "('" + payPeriodIDs.join('\', \'') + "')";
1171
+ return "('" + payPeriodIDs.join("', '") + "')";
1102
1172
  };
1103
1173
 
1104
1174
  var EXPENSE_FIELD_MAP = {
@@ -1119,7 +1189,7 @@ var SFExpenseClient = /*#__PURE__*/function () {
1119
1189
  while (1) switch (_context.prev = _context.next) {
1120
1190
  case 0:
1121
1191
  _context.prev = 0;
1122
- url = "/services/data/" + SF_API_VERSION + "/sobjects/Timesheet__c/" + timesheetId;
1192
+ url = "/services/data/" + SF_API_VERSION$1 + "/sobjects/Timesheet__c/" + timesheetId;
1123
1193
  _context.next = 4;
1124
1194
  return this.axiosInstance.get(url, {
1125
1195
  params: {
@@ -1158,7 +1228,7 @@ var SFExpenseClient = /*#__PURE__*/function () {
1158
1228
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1159
1229
  while (1) switch (_context2.prev = _context2.next) {
1160
1230
  case 0:
1161
- url = "/services/data/" + SF_API_VERSION + "/sobjects/Timesheet__c/" + timesheetId;
1231
+ url = "/services/data/" + SF_API_VERSION$1 + "/sobjects/Timesheet__c/" + timesheetId;
1162
1232
  _context2.next = 3;
1163
1233
  return this.axiosInstance.patch(url, body);
1164
1234
  case 3:
@@ -1232,7 +1302,7 @@ var SFPriceClient = /*#__PURE__*/function () {
1232
1302
  while (1) switch (_context.prev = _context.next) {
1233
1303
  case 0:
1234
1304
  _context.prev = 0;
1235
- url = "/services/data/" + SF_API_VERSION + "/query";
1305
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
1236
1306
  query = "SELECT UnitPrice__r.Price__r.Id,\n UnitPrice__r.Price__r.Name,\n UnitPrice__r.Price__r.MileageBillingRate__c,\n UnitPrice__r.Price__r.MileageWageRate__c,\n UnitPrice__r.Price__r.BillingRate__c,\n UnitPrice__r.Price__r.WageRate__c,\n UnitPrice__r.Price__r.Overtime1BillingRate__c,\n UnitPrice__r.Price__r.Overtime1WageRate__c,\n UnitPrice__r.Price__r.Overtime2BillingRate__c,\n UnitPrice__r.Price__r.Overtime2WageRate__c,\n UnitPrice__r.Price__r.CallBackBillingRate__c,\n UnitPrice__r.Price__r.CallBackWageRate__c,\n UnitPrice__r.Price__r.OnCallBillingRate__c,\n UnitPrice__r.Price__r.OnCallWageRate__c,\n UnitPrice__r.Price__r.Additional_Billing_Information__c,\n UnitPrice__r.Price__r.Additional_Wage_Information__c\n FROM WorkOrder__c WHERE Id = '" + workorderId + "' ";
1237
1307
  _context.next = 5;
1238
1308
  return this.axiosInstance.get(url, {
@@ -1836,5 +1906,7 @@ var Agency;
1836
1906
  Agency["SSI"] = "99";
1837
1907
  })(Agency || (Agency = {}));
1838
1908
 
1839
- export { Agency, LipheApiClient, LipheAuthenticator, LiphePractitionerClient, SFApiClient, SFAuthenticator, SFExpenseClient, SFPractitionerClient, SFPriceClient, SFTimesheetClient };
1909
+ var SF_API_VERSION$1 = 'v57.0';
1910
+
1911
+ export { Agency, LipheApiClient, LipheAuthenticator, LiphePractitionerClient, SFApiClient, SFAuthenticator, SFExpenseClient, SFPractitionerClient, SFPriceClient, SFTimesheetClient, SF_API_VERSION$1 as SF_API_VERSION };
1840
1912
  //# sourceMappingURL=pha-hermes.esm.js.map