pha-hermes 1.23.0 → 1.24.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.
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Practitioner } from '../../../models';
2
+ import { Practitioner, Role } from '../../../models';
3
3
  export declare class SFPractitionerClient {
4
4
  private axiosInstance;
5
5
  constructor(axiosInstance: AxiosInstance);
@@ -8,4 +8,5 @@ export declare class SFPractitionerClient {
8
8
  limit?: number;
9
9
  }): Promise<Practitioner[]>;
10
10
  fetchPractitionerByEmail(email: string): Promise<Practitioner | null>;
11
+ fetchRoles(): Promise<Role[]>;
11
12
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare const SF_API_VERSION: string;
1
2
  export { SFApiClient } from './api/salesforce/apiClient';
2
3
  export { SFPractitionerClient } from './api/salesforce/practitioner/practitionerClient';
3
4
  export { SFTimesheetClient } from './api/salesforce/timesheet/timesheetClient';
@@ -531,7 +531,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
531
531
  while (1) switch (_context.prev = _context.next) {
532
532
  case 0:
533
533
  _context.prev = 0;
534
- url = "/services/data/" + SF_API_VERSION + "/sobjects/TimeSheetHour__c/" + timesheetHourId;
534
+ url = "/services/data/" + SF_API_VERSION$1 + "/sobjects/TimeSheetHour__c/" + timesheetHourId;
535
535
  _context.next = 4;
536
536
  return this.axiosInstance.patch(url, {
537
537
  Date__c: timesheet.date,
@@ -583,7 +583,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
583
583
  while (1) switch (_context2.prev = _context2.next) {
584
584
  case 0:
585
585
  // Find all timesheet Ids that belong to this WO
586
- url = "/services/data/" + SF_API_VERSION + "/query";
586
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
587
587
  query = "SELECT Id\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderId + "'";
588
588
  try {
589
589
  if (periodStartDate && periodEndDate) {
@@ -621,7 +621,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
621
621
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
622
622
  while (1) switch (_context3.prev = _context3.next) {
623
623
  case 0:
624
- url = "/services/data/" + SF_API_VERSION + "/query";
624
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
625
625
  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 + "')";
626
626
  _context3.next = 4;
627
627
  return this.axiosInstance.get(url, {
@@ -663,7 +663,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
663
663
  case 2:
664
664
  timesheetIds = _context4.sent;
665
665
  allHours = [];
666
- url = "/services/data/" + SF_API_VERSION + "/query";
666
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
667
667
  _iterator2 = _createForOfIteratorHelperLoose(timesheetIds);
668
668
  case 6:
669
669
  if ((_step2 = _iterator2()).done) {
@@ -673,7 +673,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
673
673
  timesheetId = _step2.value;
674
674
  query = "\n SELECT " + ((fields == null ? void 0 : fields.join(',')) || 'FIELDS(STANDARD)') + "\n FROM TimesheetHour__c\n WHERE Timesheet__c = '" + timesheetId + "'";
675
675
  _context4.prev = 9;
676
- if (fields != null && fields.length) {
676
+ if (fields != null && fields.length && periodStartDate && periodEndDate) {
677
677
  query += "\n AND Date__c >= " + new Date(periodStartDate).toISOString().substring(0, 10) + "\n AND Date__c <= " + new Date(periodEndDate).toISOString().substring(0, 10);
678
678
  }
679
679
  _context4.next = 13;
@@ -714,7 +714,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
714
714
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
715
715
  while (1) switch (_context5.prev = _context5.next) {
716
716
  case 0:
717
- url = "/services/data/" + SF_API_VERSION + "/query";
717
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
718
718
  query = "SELECT Name,\n StartDate__c,\n EndDate__c\n FROM PayPeriod__c";
719
719
  _context5.next = 4;
720
720
  return this.axiosInstance.get(url, {
@@ -764,14 +764,14 @@ var SFTimesheetClient = /*#__PURE__*/function () {
764
764
  contentType: 'application/octet-stream'
765
765
  });
766
766
  _context6.next = 6;
767
- return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentVersion", form, {
767
+ return this.axiosInstance.post("/services/data/" + SF_API_VERSION$1 + "/sobjects/ContentVersion", form, {
768
768
  headers: form.getHeaders()
769
769
  });
770
770
  case 6:
771
771
  uploadRes = _context6.sent;
772
772
  versionId = uploadRes.data.id; //get ContentDocumentId
773
773
  _context6.next = 10;
774
- return this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/query", {
774
+ return this.axiosInstance.get("/services/data/" + SF_API_VERSION$1 + "/query", {
775
775
  params: {
776
776
  q: "SELECT ContentDocumentId FROM ContentVersion WHERE Id = '" + versionId + "'"
777
777
  }
@@ -781,7 +781,7 @@ var SFTimesheetClient = /*#__PURE__*/function () {
781
781
  data = _yield$this$axiosInst3.data;
782
782
  contentDocumentId = data.records[0].ContentDocumentId;
783
783
  _context6.next = 15;
784
- return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentDocumentLink", {
784
+ return this.axiosInstance.post("/services/data/" + SF_API_VERSION$1 + "/sobjects/ContentDocumentLink", {
785
785
  ContentDocumentId: contentDocumentId,
786
786
  LinkedEntityId: timesheetId,
787
787
  ShareType: 'V',
@@ -849,7 +849,7 @@ var SFPractitionerClient = /*#__PURE__*/function () {
849
849
  }
850
850
  whereClause = conditions.length ? "WHERE " + conditions.join(' AND ') : '';
851
851
  limitClause = typeof (options == null ? void 0 : options.limit) === 'number' && options.limit > 0 ? "LIMIT " + Math.floor(options.limit) : '';
852
- url = "/services/data/" + SF_API_VERSION + "/query";
852
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
853
853
  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 ";
854
854
  _context.next = 9;
855
855
  return this.axiosInstance.get(url, {
@@ -884,7 +884,7 @@ var SFPractitionerClient = /*#__PURE__*/function () {
884
884
  while (1) switch (_context2.prev = _context2.next) {
885
885
  case 0:
886
886
  _context2.prev = 0;
887
- url = "/services/data/" + SF_API_VERSION + "/query";
887
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
888
888
  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 ";
889
889
  _context2.next = 5;
890
890
  return this.axiosInstance.get(url, {
@@ -918,6 +918,47 @@ var SFPractitionerClient = /*#__PURE__*/function () {
918
918
  }
919
919
  return fetchPractitionerByEmail;
920
920
  }();
921
+ _proto.fetchRoles = /*#__PURE__*/function () {
922
+ var _fetchRoles = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
923
+ var url, query;
924
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
925
+ while (1) switch (_context3.prev = _context3.next) {
926
+ case 0:
927
+ _context3.prev = 0;
928
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
929
+ query = "SELECT Label, Value FROM PicklistValueInfo WHERE EntityParticle.EntityDefinition.QualifiedApiName = 'WorkOrder__c' AND EntityParticle.QualifiedApiName = 'ProfessionalDesignation__c' AND isActive = true";
930
+ return _context3.abrupt("return", this.axiosInstance.get(url, {
931
+ params: {
932
+ q: query
933
+ }
934
+ }).then(function (_ref) {
935
+ var records = _ref.data.records;
936
+ return records.map(function (record) {
937
+ return {
938
+ label: record.Label,
939
+ value: record.Value
940
+ };
941
+ });
942
+ })["catch"](function (error) {
943
+ console.error('Error fetching roles: ', error.message);
944
+ throw error;
945
+ }));
946
+ case 6:
947
+ _context3.prev = 6;
948
+ _context3.t0 = _context3["catch"](0);
949
+ console.error('Error fetching roles: ', _context3.t0.message);
950
+ throw _context3.t0;
951
+ case 10:
952
+ case "end":
953
+ return _context3.stop();
954
+ }
955
+ }, _callee3, this, [[0, 6]]);
956
+ }));
957
+ function fetchRoles() {
958
+ return _fetchRoles.apply(this, arguments);
959
+ }
960
+ return fetchRoles;
961
+ }();
921
962
  return SFPractitionerClient;
922
963
  }();
923
964
  function toPractitioner(raw) {
@@ -927,7 +968,7 @@ function toPractitioner(raw) {
927
968
  lastName: raw.LastName__c,
928
969
  email: raw.Email__c,
929
970
  staffId: raw.StaffID__c,
930
- createdAt: raw.CreatedDate.replace(/\+0000$/, 'Z')
971
+ createdAt: raw.CreatedDate ? raw.CreatedDate.replace(/\+0000$/, 'Z') : undefined
931
972
  };
932
973
  }
933
974
 
@@ -962,7 +1003,7 @@ var SFWorkorderClient = /*#__PURE__*/function () {
962
1003
  filters.push("Region__c IN (" + provincesList + ")");
963
1004
  }
964
1005
  whereClause = filters.length ? "WHERE " + filters.join(' AND ') : '';
965
- url = "/services/data/" + SF_API_VERSION + "/query";
1006
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
966
1007
  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;
967
1008
  _context.next = 11;
968
1009
  return this.axiosInstance.get(url, {
@@ -1034,7 +1075,7 @@ var SFPayPeriodClient = /*#__PURE__*/function () {
1034
1075
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1035
1076
  while (1) switch (_context.prev = _context.next) {
1036
1077
  case 0:
1037
- url = "/services/data/" + SF_API_VERSION + "/query";
1078
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
1038
1079
  query = "SELECT PayPeriod__c, ID\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderID + "'";
1039
1080
  _context.next = 4;
1040
1081
  return this.axiosInstance.get(url, {
@@ -1070,7 +1111,7 @@ var SFPayPeriodClient = /*#__PURE__*/function () {
1070
1111
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1071
1112
  while (1) switch (_context2.prev = _context2.next) {
1072
1113
  case 0:
1073
- url = "/services/data/" + SF_API_VERSION + "/query";
1114
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
1074
1115
  query = "SELECT ID, StartDate__c, EndDate__c\n FROM PayPeriod__c\n WHERE id IN " + listOfIdsForQuery(payPeriodIDs);
1075
1116
  _context2.next = 4;
1076
1117
  return this.axiosInstance.get(url, {
@@ -1104,7 +1145,7 @@ var SFPayPeriodClient = /*#__PURE__*/function () {
1104
1145
  return SFPayPeriodClient;
1105
1146
  }();
1106
1147
  var listOfIdsForQuery = function listOfIdsForQuery(payPeriodIDs) {
1107
- return "('" + payPeriodIDs.join('\', \'') + "')";
1148
+ return "('" + payPeriodIDs.join("', '") + "')";
1108
1149
  };
1109
1150
 
1110
1151
  var EXPENSE_FIELD_MAP = {
@@ -1125,7 +1166,7 @@ var SFExpenseClient = /*#__PURE__*/function () {
1125
1166
  while (1) switch (_context.prev = _context.next) {
1126
1167
  case 0:
1127
1168
  _context.prev = 0;
1128
- url = "/services/data/" + SF_API_VERSION + "/sobjects/Timesheet__c/" + timesheetId;
1169
+ url = "/services/data/" + SF_API_VERSION$1 + "/sobjects/Timesheet__c/" + timesheetId;
1129
1170
  _context.next = 4;
1130
1171
  return this.axiosInstance.get(url, {
1131
1172
  params: {
@@ -1164,7 +1205,7 @@ var SFExpenseClient = /*#__PURE__*/function () {
1164
1205
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1165
1206
  while (1) switch (_context2.prev = _context2.next) {
1166
1207
  case 0:
1167
- url = "/services/data/" + SF_API_VERSION + "/sobjects/Timesheet__c/" + timesheetId;
1208
+ url = "/services/data/" + SF_API_VERSION$1 + "/sobjects/Timesheet__c/" + timesheetId;
1168
1209
  _context2.next = 3;
1169
1210
  return this.axiosInstance.patch(url, body);
1170
1211
  case 3:
@@ -1238,7 +1279,7 @@ var SFPriceClient = /*#__PURE__*/function () {
1238
1279
  while (1) switch (_context.prev = _context.next) {
1239
1280
  case 0:
1240
1281
  _context.prev = 0;
1241
- url = "/services/data/" + SF_API_VERSION + "/query";
1282
+ url = "/services/data/" + SF_API_VERSION$1 + "/query";
1242
1283
  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 + "' ";
1243
1284
  _context.next = 5;
1244
1285
  return this.axiosInstance.get(url, {
@@ -1841,6 +1882,8 @@ var LipheApiClient = /*#__PURE__*/function () {
1841
1882
  Agency["SSI"] = "99";
1842
1883
  })(exports.Agency || (exports.Agency = {}));
1843
1884
 
1885
+ var SF_API_VERSION$1 = 'v57.0';
1886
+
1844
1887
  exports.LipheApiClient = LipheApiClient;
1845
1888
  exports.LipheAuthenticator = LipheAuthenticator;
1846
1889
  exports.LiphePractitionerClient = LiphePractitionerClient;
@@ -1850,4 +1893,5 @@ exports.SFExpenseClient = SFExpenseClient;
1850
1893
  exports.SFPractitionerClient = SFPractitionerClient;
1851
1894
  exports.SFPriceClient = SFPriceClient;
1852
1895
  exports.SFTimesheetClient = SFTimesheetClient;
1896
+ exports.SF_API_VERSION = SF_API_VERSION$1;
1853
1897
  //# sourceMappingURL=pha-hermes.cjs.development.js.map