pha-hermes 1.13.0 → 1.14.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.
- package/dist/api/liphe1.0/auth/authClient.d.ts +13 -0
- package/dist/api/liphe1.0/practitioner/practitionerClient.d.ts +13 -0
- package/dist/api/lipheApiClient.d.ts +13 -0
- package/dist/api/timesheet/timesheetClient.d.ts +24 -4
- package/dist/api/workorder/workorderClient.d.ts +5 -1
- package/dist/index.d.ts +3 -0
- package/dist/pha-hermes.cjs.development.js +340 -155
- package/dist/pha-hermes.cjs.development.js.map +1 -1
- package/dist/pha-hermes.cjs.production.min.js +1 -1
- package/dist/pha-hermes.cjs.production.min.js.map +1 -1
- package/dist/pha-hermes.esm.js +338 -156
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/liphe1.0/auth/authClient.ts +76 -0
- package/src/api/liphe1.0/practitioner/practitionerClient.ts +49 -0
- package/src/api/lipheApiClient.ts +38 -0
- package/src/api/timesheet/timesheetClient.ts +54 -50
- package/src/api/workorder/workorderClient.ts +24 -6
- package/src/index.ts +3 -0
|
@@ -575,37 +575,44 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
575
575
|
}
|
|
576
576
|
return updateTimesheetHour;
|
|
577
577
|
}();
|
|
578
|
-
_proto.
|
|
579
|
-
var
|
|
578
|
+
_proto.getTimesheetIds = /*#__PURE__*/function () {
|
|
579
|
+
var _getTimesheetIds = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(workorderId, periodStartDate, periodEndDate) {
|
|
580
580
|
var url, query, _yield$this$axiosInst, records;
|
|
581
581
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
582
582
|
while (1) switch (_context2.prev = _context2.next) {
|
|
583
583
|
case 0:
|
|
584
584
|
// Find all timesheet Ids that belong to this WO
|
|
585
585
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
586
|
-
query = "SELECT Id\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderId + "'
|
|
587
|
-
|
|
586
|
+
query = "SELECT Id\n FROM Timesheet__c\n WHERE WorkOrder__c = '" + workorderId + "'";
|
|
587
|
+
try {
|
|
588
|
+
if (periodStartDate && periodEndDate) {
|
|
589
|
+
query += "\n AND PayPeriodStartDate__c <= " + new Date(periodStartDate).toISOString().substring(0, 10) + "\n AND PayPeriodEndDate__c >= " + new Date(periodEndDate).toISOString().substring(0, 10) + "\n ";
|
|
590
|
+
}
|
|
591
|
+
} catch (error) {
|
|
592
|
+
console.error('Invalid period dates', error);
|
|
593
|
+
}
|
|
594
|
+
_context2.next = 5;
|
|
588
595
|
return this.axiosInstance.get(url, {
|
|
589
596
|
params: {
|
|
590
597
|
q: query
|
|
591
598
|
}
|
|
592
599
|
});
|
|
593
|
-
case
|
|
600
|
+
case 5:
|
|
594
601
|
_yield$this$axiosInst = _context2.sent;
|
|
595
602
|
records = _yield$this$axiosInst.data.records;
|
|
596
603
|
return _context2.abrupt("return", records.map(function (record) {
|
|
597
604
|
return record.Id;
|
|
598
605
|
}));
|
|
599
|
-
case
|
|
606
|
+
case 8:
|
|
600
607
|
case "end":
|
|
601
608
|
return _context2.stop();
|
|
602
609
|
}
|
|
603
610
|
}, _callee2, this);
|
|
604
611
|
}));
|
|
605
|
-
function
|
|
606
|
-
return
|
|
612
|
+
function getTimesheetIds(_x3, _x4, _x5) {
|
|
613
|
+
return _getTimesheetIds.apply(this, arguments);
|
|
607
614
|
}
|
|
608
|
-
return
|
|
615
|
+
return getTimesheetIds;
|
|
609
616
|
}();
|
|
610
617
|
_proto.getTimesheetsForPractitioner = /*#__PURE__*/function () {
|
|
611
618
|
var _getTimesheetsForPractitioner = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(personnelID) {
|
|
@@ -639,162 +646,83 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
639
646
|
}
|
|
640
647
|
}, _callee3, this);
|
|
641
648
|
}));
|
|
642
|
-
function getTimesheetsForPractitioner(
|
|
649
|
+
function getTimesheetsForPractitioner(_x6) {
|
|
643
650
|
return _getTimesheetsForPractitioner.apply(this, arguments);
|
|
644
651
|
}
|
|
645
652
|
return getTimesheetsForPractitioner;
|
|
646
653
|
}();
|
|
647
|
-
_proto.
|
|
648
|
-
var
|
|
649
|
-
var timesheetIds,
|
|
654
|
+
_proto.getTimesheetHours = /*#__PURE__*/function () {
|
|
655
|
+
var _getTimesheetHours = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(workorderId, fields, periodStartDate, periodEndDate) {
|
|
656
|
+
var timesheetIds, allHours, url, _iterator2, _step2, timesheetId, query, _yield$this$axiosInst2, records;
|
|
650
657
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
651
658
|
while (1) switch (_context4.prev = _context4.next) {
|
|
652
659
|
case 0:
|
|
653
660
|
_context4.next = 2;
|
|
654
|
-
return this.
|
|
661
|
+
return this.getTimesheetIds(workorderId, periodStartDate, periodEndDate);
|
|
655
662
|
case 2:
|
|
656
663
|
timesheetIds = _context4.sent;
|
|
657
|
-
|
|
658
|
-
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
659
|
-
query = "SELECT Id\n FROM TimesheetHour__c\n WHERE Timesheet__c = '" + timesheetId + "'";
|
|
660
|
-
_context4.next = 8;
|
|
661
|
-
return this.axiosInstance.get(url, {
|
|
662
|
-
params: {
|
|
663
|
-
q: query
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
case 8:
|
|
667
|
-
_yield$this$axiosInst2 = _context4.sent;
|
|
668
|
-
records = _yield$this$axiosInst2.data.records;
|
|
669
|
-
return _context4.abrupt("return", records.map(function (_ref) {
|
|
670
|
-
var Id = _ref.Id;
|
|
671
|
-
return Id;
|
|
672
|
-
}));
|
|
673
|
-
case 11:
|
|
674
|
-
case "end":
|
|
675
|
-
return _context4.stop();
|
|
676
|
-
}
|
|
677
|
-
}, _callee4, this);
|
|
678
|
-
}));
|
|
679
|
-
function getTimesheetHoursIds(_x5) {
|
|
680
|
-
return _getTimesheetHoursIds.apply(this, arguments);
|
|
681
|
-
}
|
|
682
|
-
return getTimesheetHoursIds;
|
|
683
|
-
}();
|
|
684
|
-
_proto.getTimesheetHoursId = /*#__PURE__*/function () {
|
|
685
|
-
var _getTimesheetHoursId = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(workorderId, timesheetDate) {
|
|
686
|
-
var timesheetIds, formattedDate, allHourIds, url, _iterator2, _step2, timesheetId, query, _yield$this$axiosInst3, records, ids;
|
|
687
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
688
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
689
|
-
case 0:
|
|
690
|
-
_context5.next = 2;
|
|
691
|
-
return this.getTimesheetId(workorderId);
|
|
692
|
-
case 2:
|
|
693
|
-
timesheetIds = _context5.sent;
|
|
694
|
-
formattedDate = timesheetDate.toISOString().split('T')[0];
|
|
695
|
-
allHourIds = [];
|
|
664
|
+
allHours = [];
|
|
696
665
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
697
666
|
_iterator2 = _createForOfIteratorHelperLoose(timesheetIds);
|
|
698
|
-
case
|
|
667
|
+
case 6:
|
|
699
668
|
if ((_step2 = _iterator2()).done) {
|
|
700
|
-
|
|
669
|
+
_context4.next = 23;
|
|
701
670
|
break;
|
|
702
671
|
}
|
|
703
672
|
timesheetId = _step2.value;
|
|
704
|
-
query = "\n
|
|
705
|
-
|
|
706
|
-
|
|
673
|
+
query = "\n SELECT " + ((fields == null ? void 0 : fields.join(',')) || 'FIELDS(STANDARD)') + "\n FROM TimesheetHour__c\n WHERE Timesheet__c = '" + timesheetId + "'";
|
|
674
|
+
_context4.prev = 9;
|
|
675
|
+
if (fields != null && fields.length) {
|
|
676
|
+
query += "\n AND Date__c >= " + new Date(periodStartDate).toISOString().substring(0, 10) + "\n AND Date__c <= " + new Date(periodEndDate).toISOString().substring(0, 10);
|
|
677
|
+
}
|
|
678
|
+
_context4.next = 13;
|
|
707
679
|
return this.axiosInstance.get(url, {
|
|
708
680
|
params: {
|
|
709
681
|
q: query
|
|
710
682
|
}
|
|
711
683
|
});
|
|
712
684
|
case 13:
|
|
713
|
-
_yield$this$
|
|
714
|
-
records = _yield$this$
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
});
|
|
718
|
-
allHourIds.push.apply(allHourIds, ids);
|
|
719
|
-
_context5.next = 23;
|
|
685
|
+
_yield$this$axiosInst2 = _context4.sent;
|
|
686
|
+
records = _yield$this$axiosInst2.data.records;
|
|
687
|
+
allHours.push.apply(allHours, records);
|
|
688
|
+
_context4.next = 21;
|
|
720
689
|
break;
|
|
721
|
-
case
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
console.error("Failed to fetch",
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
_context5.next = 7;
|
|
690
|
+
case 18:
|
|
691
|
+
_context4.prev = 18;
|
|
692
|
+
_context4.t0 = _context4["catch"](9);
|
|
693
|
+
console.error("Failed to fetch", _context4.t0);
|
|
694
|
+
case 21:
|
|
695
|
+
_context4.next = 6;
|
|
728
696
|
break;
|
|
729
|
-
case
|
|
730
|
-
return
|
|
731
|
-
case
|
|
732
|
-
case "end":
|
|
733
|
-
return _context5.stop();
|
|
734
|
-
}
|
|
735
|
-
}, _callee5, this, [[10, 19]]);
|
|
736
|
-
}));
|
|
737
|
-
function getTimesheetHoursId(_x6, _x7) {
|
|
738
|
-
return _getTimesheetHoursId.apply(this, arguments);
|
|
739
|
-
}
|
|
740
|
-
return getTimesheetHoursId;
|
|
741
|
-
}();
|
|
742
|
-
_proto.getTimesheetHours = /*#__PURE__*/function () {
|
|
743
|
-
var _getTimesheetHours = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(workorderId) {
|
|
744
|
-
var _this = this;
|
|
745
|
-
var timesheetHourIds;
|
|
746
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
747
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
748
|
-
case 0:
|
|
749
|
-
_context7.next = 2;
|
|
750
|
-
return this.getTimesheetHoursIds(workorderId);
|
|
751
|
-
case 2:
|
|
752
|
-
timesheetHourIds = _context7.sent;
|
|
753
|
-
return _context7.abrupt("return", Promise.all(timesheetHourIds.map(/*#__PURE__*/function () {
|
|
754
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
755
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
756
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
757
|
-
case 0:
|
|
758
|
-
return _context6.abrupt("return", _this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/sobjects/TimeSheetHour__c/" + id).then(function (res) {
|
|
759
|
-
return res.data;
|
|
760
|
-
}).then(toTimesheetDayEntry));
|
|
761
|
-
case 1:
|
|
762
|
-
case "end":
|
|
763
|
-
return _context6.stop();
|
|
764
|
-
}
|
|
765
|
-
}, _callee6);
|
|
766
|
-
}));
|
|
767
|
-
return function (_x9) {
|
|
768
|
-
return _ref2.apply(this, arguments);
|
|
769
|
-
};
|
|
770
|
-
}())));
|
|
771
|
-
case 4:
|
|
697
|
+
case 23:
|
|
698
|
+
return _context4.abrupt("return", allHours.map(toTimesheetDayEntry));
|
|
699
|
+
case 24:
|
|
772
700
|
case "end":
|
|
773
|
-
return
|
|
701
|
+
return _context4.stop();
|
|
774
702
|
}
|
|
775
|
-
},
|
|
703
|
+
}, _callee4, this, [[9, 18]]);
|
|
776
704
|
}));
|
|
777
|
-
function getTimesheetHours(_x8) {
|
|
705
|
+
function getTimesheetHours(_x7, _x8, _x9, _x10) {
|
|
778
706
|
return _getTimesheetHours.apply(this, arguments);
|
|
779
707
|
}
|
|
780
708
|
return getTimesheetHours;
|
|
781
709
|
}();
|
|
782
710
|
_proto.getPayPeriods = /*#__PURE__*/function () {
|
|
783
|
-
var _getPayPeriods = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
711
|
+
var _getPayPeriods = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
784
712
|
var url, query, data, payPeriods, _iterator3, _step3, payPeriod;
|
|
785
|
-
return _regeneratorRuntime().wrap(function
|
|
786
|
-
while (1) switch (
|
|
713
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
714
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
787
715
|
case 0:
|
|
788
716
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
789
717
|
query = "SELECT Name,\n StartDate__c,\n EndDate__c\n FROM PayPeriod__c";
|
|
790
|
-
|
|
718
|
+
_context5.next = 4;
|
|
791
719
|
return this.axiosInstance.get(url, {
|
|
792
720
|
params: {
|
|
793
721
|
q: query
|
|
794
722
|
}
|
|
795
723
|
});
|
|
796
724
|
case 4:
|
|
797
|
-
data =
|
|
725
|
+
data = _context5.sent;
|
|
798
726
|
payPeriods = [];
|
|
799
727
|
for (_iterator3 = _createForOfIteratorHelperLoose(data.data.records); !(_step3 = _iterator3()).done;) {
|
|
800
728
|
payPeriod = _step3.value;
|
|
@@ -804,12 +732,12 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
804
732
|
endDate: payPeriod.EndDate__c
|
|
805
733
|
});
|
|
806
734
|
}
|
|
807
|
-
return
|
|
735
|
+
return _context5.abrupt("return", payPeriods);
|
|
808
736
|
case 8:
|
|
809
737
|
case "end":
|
|
810
|
-
return
|
|
738
|
+
return _context5.stop();
|
|
811
739
|
}
|
|
812
|
-
},
|
|
740
|
+
}, _callee5, this);
|
|
813
741
|
}));
|
|
814
742
|
function getPayPeriods() {
|
|
815
743
|
return _getPayPeriods.apply(this, arguments);
|
|
@@ -817,12 +745,12 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
817
745
|
return getPayPeriods;
|
|
818
746
|
}();
|
|
819
747
|
_proto.uploadImageToTimesheet = /*#__PURE__*/function () {
|
|
820
|
-
var _uploadImageToTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
821
|
-
var form, uploadRes, versionId, _yield$this$
|
|
822
|
-
return _regeneratorRuntime().wrap(function
|
|
823
|
-
while (1) switch (
|
|
748
|
+
var _uploadImageToTimesheet = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(file, filename, timesheetId) {
|
|
749
|
+
var form, uploadRes, versionId, _yield$this$axiosInst3, data, contentDocumentId, _err$response;
|
|
750
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
751
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
824
752
|
case 0:
|
|
825
|
-
|
|
753
|
+
_context6.prev = 0;
|
|
826
754
|
form = new FormData();
|
|
827
755
|
form.append('entity_content', JSON.stringify({
|
|
828
756
|
Title: filename,
|
|
@@ -834,24 +762,24 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
834
762
|
filename: filename,
|
|
835
763
|
contentType: 'application/octet-stream'
|
|
836
764
|
});
|
|
837
|
-
|
|
765
|
+
_context6.next = 6;
|
|
838
766
|
return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentVersion", form, {
|
|
839
767
|
headers: form.getHeaders()
|
|
840
768
|
});
|
|
841
769
|
case 6:
|
|
842
|
-
uploadRes =
|
|
770
|
+
uploadRes = _context6.sent;
|
|
843
771
|
versionId = uploadRes.data.id; //get ContentDocumentId
|
|
844
|
-
|
|
772
|
+
_context6.next = 10;
|
|
845
773
|
return this.axiosInstance.get("/services/data/" + SF_API_VERSION + "/query", {
|
|
846
774
|
params: {
|
|
847
775
|
q: "SELECT ContentDocumentId FROM ContentVersion WHERE Id = '" + versionId + "'"
|
|
848
776
|
}
|
|
849
777
|
});
|
|
850
778
|
case 10:
|
|
851
|
-
_yield$this$
|
|
852
|
-
data = _yield$this$
|
|
779
|
+
_yield$this$axiosInst3 = _context6.sent;
|
|
780
|
+
data = _yield$this$axiosInst3.data;
|
|
853
781
|
contentDocumentId = data.records[0].ContentDocumentId;
|
|
854
|
-
|
|
782
|
+
_context6.next = 15;
|
|
855
783
|
return this.axiosInstance.post("/services/data/" + SF_API_VERSION + "/sobjects/ContentDocumentLink", {
|
|
856
784
|
ContentDocumentId: contentDocumentId,
|
|
857
785
|
LinkedEntityId: timesheetId,
|
|
@@ -859,20 +787,20 @@ var SFTimesheetClient = /*#__PURE__*/function () {
|
|
|
859
787
|
Visibility: 'AllUsers'
|
|
860
788
|
});
|
|
861
789
|
case 15:
|
|
862
|
-
|
|
790
|
+
_context6.next = 21;
|
|
863
791
|
break;
|
|
864
792
|
case 17:
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
console.error('Salesforce error response:',
|
|
868
|
-
console.error('Error uploading and linking image:',
|
|
793
|
+
_context6.prev = 17;
|
|
794
|
+
_context6.t0 = _context6["catch"](0);
|
|
795
|
+
console.error('Salesforce error response:', _context6.t0 == null || (_err$response = _context6.t0.response) == null ? void 0 : _err$response.data);
|
|
796
|
+
console.error('Error uploading and linking image:', _context6.t0 == null ? void 0 : _context6.t0.message);
|
|
869
797
|
case 21:
|
|
870
798
|
case "end":
|
|
871
|
-
return
|
|
799
|
+
return _context6.stop();
|
|
872
800
|
}
|
|
873
|
-
},
|
|
801
|
+
}, _callee6, this, [[0, 17]]);
|
|
874
802
|
}));
|
|
875
|
-
function uploadImageToTimesheet(
|
|
803
|
+
function uploadImageToTimesheet(_x11, _x12, _x13) {
|
|
876
804
|
return _uploadImageToTimesheet.apply(this, arguments);
|
|
877
805
|
}
|
|
878
806
|
return uploadImageToTimesheet;
|
|
@@ -1001,15 +929,34 @@ var SFWorkorderClient = /*#__PURE__*/function () {
|
|
|
1001
929
|
}
|
|
1002
930
|
var _proto = SFWorkorderClient.prototype;
|
|
1003
931
|
_proto.getWorkordersForPractitioner = /*#__PURE__*/function () {
|
|
1004
|
-
var _getWorkordersForPractitioner = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(practitionerId) {
|
|
1005
|
-
var url, query;
|
|
932
|
+
var _getWorkordersForPractitioner = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(practitionerId, options) {
|
|
933
|
+
var _options$provinces, filters, isoStart, isoEnd, _options$provinces2, provincesList, whereClause, url, query;
|
|
1006
934
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1007
935
|
while (1) switch (_context.prev = _context.next) {
|
|
1008
936
|
case 0:
|
|
1009
937
|
_context.prev = 0;
|
|
938
|
+
filters = [];
|
|
939
|
+
if (practitionerId) {
|
|
940
|
+
filters.push("Personnel__c = '" + practitionerId + "'");
|
|
941
|
+
}
|
|
942
|
+
if (options != null && options.startDate) {
|
|
943
|
+
isoStart = options.startDate.toISOString().split('T')[0];
|
|
944
|
+
filters.push("EndDate__c >= " + isoStart);
|
|
945
|
+
}
|
|
946
|
+
if (options != null && options.endDate) {
|
|
947
|
+
isoEnd = options.endDate.toISOString().split('T')[0];
|
|
948
|
+
filters.push("startdate__c <= " + isoEnd);
|
|
949
|
+
}
|
|
950
|
+
if (options != null && (_options$provinces = options.provinces) != null && _options$provinces.length) {
|
|
951
|
+
provincesList = options == null || (_options$provinces2 = options.provinces) == null ? void 0 : _options$provinces2.map(function (p) {
|
|
952
|
+
return "'" + p + "'";
|
|
953
|
+
}).join(', ');
|
|
954
|
+
filters.push("Region__c IN (" + provincesList + ")");
|
|
955
|
+
}
|
|
956
|
+
whereClause = filters.length ? "WHERE " + filters.join(' AND ') : '';
|
|
1010
957
|
url = "/services/data/" + SF_API_VERSION + "/query";
|
|
1011
|
-
query =
|
|
1012
|
-
_context.next =
|
|
958
|
+
query = "SELECT Id, Region__c, Name, HospitalID__c, HospitalName__c, ProfessionalDesignation__c, Personnel__c, startdate__c, EndDate__c, CreatedDate, LastModifiedDate FROM WorkOrder__c " + whereClause;
|
|
959
|
+
_context.next = 11;
|
|
1013
960
|
return this.axiosInstance.get(url, {
|
|
1014
961
|
params: {
|
|
1015
962
|
q: query
|
|
@@ -1032,20 +979,20 @@ var SFWorkorderClient = /*#__PURE__*/function () {
|
|
|
1032
979
|
};
|
|
1033
980
|
});
|
|
1034
981
|
});
|
|
1035
|
-
case
|
|
982
|
+
case 11:
|
|
1036
983
|
return _context.abrupt("return", _context.sent);
|
|
1037
|
-
case
|
|
1038
|
-
_context.prev =
|
|
984
|
+
case 14:
|
|
985
|
+
_context.prev = 14;
|
|
1039
986
|
_context.t0 = _context["catch"](0);
|
|
1040
987
|
console.error('Error fetching work orders: ', _context.t0.message);
|
|
1041
988
|
throw _context.t0;
|
|
1042
|
-
case
|
|
989
|
+
case 18:
|
|
1043
990
|
case "end":
|
|
1044
991
|
return _context.stop();
|
|
1045
992
|
}
|
|
1046
|
-
}, _callee, this, [[0,
|
|
993
|
+
}, _callee, this, [[0, 14]]);
|
|
1047
994
|
}));
|
|
1048
|
-
function getWorkordersForPractitioner(_x) {
|
|
995
|
+
function getWorkordersForPractitioner(_x, _x2) {
|
|
1049
996
|
return _getWorkordersForPractitioner.apply(this, arguments);
|
|
1050
997
|
}
|
|
1051
998
|
return getWorkordersForPractitioner;
|
|
@@ -1216,6 +1163,244 @@ var SFApiClient = /*#__PURE__*/function () {
|
|
|
1216
1163
|
return SFApiClient;
|
|
1217
1164
|
}();
|
|
1218
1165
|
|
|
1166
|
+
var LipheAuthenticator = /*#__PURE__*/function () {
|
|
1167
|
+
function LipheAuthenticator(authenticatedAxiosInstance, baseUrl, email, password, type) {
|
|
1168
|
+
if (type === void 0) {
|
|
1169
|
+
type = 'user';
|
|
1170
|
+
}
|
|
1171
|
+
this.axiosTokenInstance = axios.create();
|
|
1172
|
+
this.token = undefined;
|
|
1173
|
+
this.tokenRefreshPromise = null;
|
|
1174
|
+
this.authenticatedAxiosInstance = authenticatedAxiosInstance;
|
|
1175
|
+
this.email = email;
|
|
1176
|
+
this.password = password;
|
|
1177
|
+
this.type = type;
|
|
1178
|
+
this.axiosTokenInstance.defaults.baseURL = baseUrl;
|
|
1179
|
+
}
|
|
1180
|
+
var _proto = LipheAuthenticator.prototype;
|
|
1181
|
+
_proto.initializeAuth = /*#__PURE__*/function () {
|
|
1182
|
+
var _initializeAuth = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1183
|
+
var _this = this;
|
|
1184
|
+
var token;
|
|
1185
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1186
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1187
|
+
case 0:
|
|
1188
|
+
_context2.next = 2;
|
|
1189
|
+
return this.login();
|
|
1190
|
+
case 2:
|
|
1191
|
+
token = _context2.sent;
|
|
1192
|
+
this.authenticatedAxiosInstance.defaults.headers.common['X-Auth-Token'] = token;
|
|
1193
|
+
this.authenticatedAxiosInstance.interceptors.response.use(function (response) {
|
|
1194
|
+
return response;
|
|
1195
|
+
}, /*#__PURE__*/function () {
|
|
1196
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(error) {
|
|
1197
|
+
var _error$response;
|
|
1198
|
+
var originalRequest, newToken;
|
|
1199
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1200
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1201
|
+
case 0:
|
|
1202
|
+
originalRequest = error.config;
|
|
1203
|
+
originalRequest._retryCount = originalRequest._retryCount || 0;
|
|
1204
|
+
if (!(((_error$response = error.response) == null ? void 0 : _error$response.status) === 401 && originalRequest._retryCount < 1)) {
|
|
1205
|
+
_context.next = 20;
|
|
1206
|
+
break;
|
|
1207
|
+
}
|
|
1208
|
+
originalRequest._retryCount++;
|
|
1209
|
+
_context.prev = 4;
|
|
1210
|
+
if (!_this.tokenRefreshPromise) {
|
|
1211
|
+
_this.tokenRefreshPromise = _this.login();
|
|
1212
|
+
}
|
|
1213
|
+
_context.next = 8;
|
|
1214
|
+
return _this.tokenRefreshPromise;
|
|
1215
|
+
case 8:
|
|
1216
|
+
newToken = _context.sent;
|
|
1217
|
+
_this.tokenRefreshPromise = null;
|
|
1218
|
+
_this.authenticatedAxiosInstance.defaults.headers.common['X-Auth-Token'] = newToken;
|
|
1219
|
+
_context.next = 13;
|
|
1220
|
+
return _this.authenticatedAxiosInstance(originalRequest);
|
|
1221
|
+
case 13:
|
|
1222
|
+
return _context.abrupt("return", _context.sent);
|
|
1223
|
+
case 16:
|
|
1224
|
+
_context.prev = 16;
|
|
1225
|
+
_context.t0 = _context["catch"](4);
|
|
1226
|
+
_this.tokenRefreshPromise = null;
|
|
1227
|
+
return _context.abrupt("return", Promise.reject(_context.t0));
|
|
1228
|
+
case 20:
|
|
1229
|
+
return _context.abrupt("return", Promise.reject(error));
|
|
1230
|
+
case 21:
|
|
1231
|
+
case "end":
|
|
1232
|
+
return _context.stop();
|
|
1233
|
+
}
|
|
1234
|
+
}, _callee, null, [[4, 16]]);
|
|
1235
|
+
}));
|
|
1236
|
+
return function (_x) {
|
|
1237
|
+
return _ref.apply(this, arguments);
|
|
1238
|
+
};
|
|
1239
|
+
}());
|
|
1240
|
+
case 5:
|
|
1241
|
+
case "end":
|
|
1242
|
+
return _context2.stop();
|
|
1243
|
+
}
|
|
1244
|
+
}, _callee2, this);
|
|
1245
|
+
}));
|
|
1246
|
+
function initializeAuth() {
|
|
1247
|
+
return _initializeAuth.apply(this, arguments);
|
|
1248
|
+
}
|
|
1249
|
+
return initializeAuth;
|
|
1250
|
+
}();
|
|
1251
|
+
_proto.login = /*#__PURE__*/function () {
|
|
1252
|
+
var _login = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
1253
|
+
var _response$data;
|
|
1254
|
+
var form, response, token;
|
|
1255
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1256
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1257
|
+
case 0:
|
|
1258
|
+
form = new FormData();
|
|
1259
|
+
form.append('email', this.email);
|
|
1260
|
+
form.append('password', this.password);
|
|
1261
|
+
form.append('type', this.type);
|
|
1262
|
+
_context3.next = 6;
|
|
1263
|
+
return this.axiosTokenInstance.post('/v2/signin', form, {
|
|
1264
|
+
headers: form.getHeaders()
|
|
1265
|
+
});
|
|
1266
|
+
case 6:
|
|
1267
|
+
response = _context3.sent;
|
|
1268
|
+
token = response == null || (_response$data = response.data) == null || (_response$data = _response$data.data) == null ? void 0 : _response$data.token;
|
|
1269
|
+
if (token) {
|
|
1270
|
+
_context3.next = 10;
|
|
1271
|
+
break;
|
|
1272
|
+
}
|
|
1273
|
+
throw new Error('Authentication failed: no token return');
|
|
1274
|
+
case 10:
|
|
1275
|
+
this.token = token;
|
|
1276
|
+
return _context3.abrupt("return", token);
|
|
1277
|
+
case 12:
|
|
1278
|
+
case "end":
|
|
1279
|
+
return _context3.stop();
|
|
1280
|
+
}
|
|
1281
|
+
}, _callee3, this);
|
|
1282
|
+
}));
|
|
1283
|
+
function login() {
|
|
1284
|
+
return _login.apply(this, arguments);
|
|
1285
|
+
}
|
|
1286
|
+
return login;
|
|
1287
|
+
}();
|
|
1288
|
+
return LipheAuthenticator;
|
|
1289
|
+
}();
|
|
1290
|
+
|
|
1291
|
+
var LiphePractitionerClient = /*#__PURE__*/function () {
|
|
1292
|
+
function LiphePractitionerClient(axiosInstance) {
|
|
1293
|
+
this.axios = axiosInstance;
|
|
1294
|
+
}
|
|
1295
|
+
var _proto = LiphePractitionerClient.prototype;
|
|
1296
|
+
_proto.fetchAllPractitioners = /*#__PURE__*/function () {
|
|
1297
|
+
var _fetchAllPractitioners = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(agencyId) {
|
|
1298
|
+
var practitioners, page, nextPage, _response$data, response, data, pagePractitioners;
|
|
1299
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1300
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1301
|
+
case 0:
|
|
1302
|
+
if (agencyId === void 0) {
|
|
1303
|
+
agencyId = 1;
|
|
1304
|
+
}
|
|
1305
|
+
practitioners = [];
|
|
1306
|
+
page = 1;
|
|
1307
|
+
nextPage = true;
|
|
1308
|
+
case 4:
|
|
1309
|
+
if (!nextPage) {
|
|
1310
|
+
_context.next = 17;
|
|
1311
|
+
break;
|
|
1312
|
+
}
|
|
1313
|
+
_context.next = 7;
|
|
1314
|
+
return this.axios.get('/v2/employees', {
|
|
1315
|
+
params: {
|
|
1316
|
+
agency_id: agencyId,
|
|
1317
|
+
page: page
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
case 7:
|
|
1321
|
+
response = _context.sent;
|
|
1322
|
+
data = response == null || (_response$data = response.data) == null ? void 0 : _response$data.data;
|
|
1323
|
+
if (!(!(data != null && data.data) || !Array.isArray(data.data))) {
|
|
1324
|
+
_context.next = 11;
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
throw new Error('Unexpected responses.');
|
|
1328
|
+
case 11:
|
|
1329
|
+
pagePractitioners = data.data.map(function (p) {
|
|
1330
|
+
return {
|
|
1331
|
+
id: p.id,
|
|
1332
|
+
firstname: p.firstname,
|
|
1333
|
+
lastname: p.lastname,
|
|
1334
|
+
email: p.email,
|
|
1335
|
+
communicationMode: p.communicationMode
|
|
1336
|
+
};
|
|
1337
|
+
});
|
|
1338
|
+
practitioners.push.apply(practitioners, pagePractitioners);
|
|
1339
|
+
nextPage = Boolean(data.next_page_url);
|
|
1340
|
+
page++;
|
|
1341
|
+
_context.next = 4;
|
|
1342
|
+
break;
|
|
1343
|
+
case 17:
|
|
1344
|
+
return _context.abrupt("return", practitioners);
|
|
1345
|
+
case 18:
|
|
1346
|
+
case "end":
|
|
1347
|
+
return _context.stop();
|
|
1348
|
+
}
|
|
1349
|
+
}, _callee, this);
|
|
1350
|
+
}));
|
|
1351
|
+
function fetchAllPractitioners(_x) {
|
|
1352
|
+
return _fetchAllPractitioners.apply(this, arguments);
|
|
1353
|
+
}
|
|
1354
|
+
return fetchAllPractitioners;
|
|
1355
|
+
}();
|
|
1356
|
+
return LiphePractitionerClient;
|
|
1357
|
+
}();
|
|
1358
|
+
|
|
1359
|
+
var LipheApiClient = /*#__PURE__*/function () {
|
|
1360
|
+
function LipheApiClient(baseUrl, email, password, type) {
|
|
1361
|
+
if (type === void 0) {
|
|
1362
|
+
type = 'user';
|
|
1363
|
+
}
|
|
1364
|
+
this.instance = undefined;
|
|
1365
|
+
this.axiosInstance = axios.create();
|
|
1366
|
+
this.axiosInstance.defaults.baseURL = baseUrl;
|
|
1367
|
+
this.authenticator = new LipheAuthenticator(this.axiosInstance, baseUrl, email, password, type);
|
|
1368
|
+
this.practitionerClient = new LiphePractitionerClient(this.axiosInstance);
|
|
1369
|
+
}
|
|
1370
|
+
var _proto = LipheApiClient.prototype;
|
|
1371
|
+
_proto.init = /*#__PURE__*/function () {
|
|
1372
|
+
var _init = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1373
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1374
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1375
|
+
case 0:
|
|
1376
|
+
_context.next = 2;
|
|
1377
|
+
return this.authenticator.initializeAuth();
|
|
1378
|
+
case 2:
|
|
1379
|
+
case "end":
|
|
1380
|
+
return _context.stop();
|
|
1381
|
+
}
|
|
1382
|
+
}, _callee, this);
|
|
1383
|
+
}));
|
|
1384
|
+
function init() {
|
|
1385
|
+
return _init.apply(this, arguments);
|
|
1386
|
+
}
|
|
1387
|
+
return init;
|
|
1388
|
+
}();
|
|
1389
|
+
_proto.setInstance = function setInstance(instance) {
|
|
1390
|
+
this.instance = instance;
|
|
1391
|
+
};
|
|
1392
|
+
_proto.getInstance = function getInstance() {
|
|
1393
|
+
return this.instance;
|
|
1394
|
+
};
|
|
1395
|
+
_proto.getAxiosInstance = function getAxiosInstance() {
|
|
1396
|
+
return this.axiosInstance;
|
|
1397
|
+
};
|
|
1398
|
+
return LipheApiClient;
|
|
1399
|
+
}();
|
|
1400
|
+
|
|
1401
|
+
exports.LipheApiClient = LipheApiClient;
|
|
1402
|
+
exports.LipheAuthenticator = LipheAuthenticator;
|
|
1403
|
+
exports.LiphePractitionerClient = LiphePractitionerClient;
|
|
1219
1404
|
exports.SFApiClient = SFApiClient;
|
|
1220
1405
|
exports.SFAuthenticator = SFAuthenticator;
|
|
1221
1406
|
exports.SFPractitionerClient = SFPractitionerClient;
|