pha-hermes 1.20.0 → 1.22.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/salesforce/apiClient.d.ts +3 -1
- package/dist/api/{expenses → salesforce/expenses}/expenseClient.d.ts +1 -1
- package/dist/api/salesforce/prices/priceClient.d.ts +7 -0
- package/dist/index.d.ts +2 -1
- package/dist/models/price.d.ts +18 -0
- package/dist/models/workorder.d.ts +3 -0
- package/dist/pha-hermes.cjs.development.js +78 -4
- 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 +78 -5
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/.env +5 -0
- package/src/api/salesforce/apiClient.ts +4 -1
- package/src/api/{expenses → salesforce/expenses}/expenseClient.ts +2 -2
- package/src/api/salesforce/prices/priceClient.ts +70 -0
- package/src/api/salesforce/workorder/workorderClient.ts +15 -3
- package/src/index.ts +2 -1
- package/src/models/price.ts +18 -0
- package/src/models/workorder.ts +3 -0
package/package.json
CHANGED
package/src/api/.env
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
I THINK THIS ONE IS WRONG
|
|
2
|
+
SF_CLIENT_ID=3MVG9TZvGM_0NqB09H2fPRxeiDEsovly3D10kwNjOYJNTwBhMc5JHQgCdaSM.2N1V04tb_Tuyj_qktBPNueQd
|
|
3
|
+
SF_CLIENT_SECRET=6F4D40003CF5B156A2AD2BFAD384E74AA9FFFD574E8753EAC485E3C478C50F9F
|
|
4
|
+
GRANT_TYPE=client_credentials
|
|
5
|
+
SALESFORCE_URL=https://do0000000d247eaa--phealth.sandbox.my.salesforce.com
|
|
@@ -5,7 +5,8 @@ import { SFPractitionerClient } from './practitioner/practitionerClient'
|
|
|
5
5
|
import { Role } from '../../models'
|
|
6
6
|
import { SFWorkorderClient } from './workorder/workorderClient'
|
|
7
7
|
import { SFPayPeriodClient } from './payperiod/payperiodClient'
|
|
8
|
-
import { SFExpenseClient } from '
|
|
8
|
+
import { SFExpenseClient } from './expenses/expenseClient'
|
|
9
|
+
import { SFPriceClient } from './prices/priceClient'
|
|
9
10
|
|
|
10
11
|
export const SF_API_VERSION: string = 'v57.0'
|
|
11
12
|
|
|
@@ -19,6 +20,7 @@ export class SFApiClient {
|
|
|
19
20
|
practitionerClient: SFPractitionerClient
|
|
20
21
|
payPeriodClient: SFPayPeriodClient
|
|
21
22
|
expenseClient: SFExpenseClient
|
|
23
|
+
priceClient: SFPriceClient
|
|
22
24
|
|
|
23
25
|
async init(
|
|
24
26
|
baseUrl: string,
|
|
@@ -34,6 +36,7 @@ export class SFApiClient {
|
|
|
34
36
|
this.practitionerClient = new SFPractitionerClient(this.axiosInstance)
|
|
35
37
|
this.payPeriodClient = new SFPayPeriodClient(this.axiosInstance)
|
|
36
38
|
this.expenseClient = new SFExpenseClient(this.axiosInstance)
|
|
39
|
+
this.priceClient = new SFPriceClient(this.axiosInstance)
|
|
37
40
|
// creates authenticator and adds token to axios instance
|
|
38
41
|
await this.authenticator.initializeAuth(sfClientId, sfClientSecret, onTokenRefresh)
|
|
39
42
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios'
|
|
2
|
-
import { Expense } from '
|
|
3
|
-
import { SF_API_VERSION } from '../
|
|
2
|
+
import { Expense } from '../../../models/expense'
|
|
3
|
+
import { SF_API_VERSION } from '../apiClient'
|
|
4
4
|
|
|
5
5
|
type FrontendExpense = {
|
|
6
6
|
workorderPeriodId: string
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios'
|
|
2
|
+
import { Price } from '../../../models/price'
|
|
3
|
+
import { SF_API_VERSION } from '../apiClient'
|
|
4
|
+
|
|
5
|
+
export class SFPriceClient {
|
|
6
|
+
private axiosInstance: AxiosInstance
|
|
7
|
+
|
|
8
|
+
constructor(axiosInstance: AxiosInstance) {
|
|
9
|
+
this.axiosInstance = axiosInstance
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getPriceListByWorkorderId(workorderId?: string): Promise<Price> {
|
|
13
|
+
try {
|
|
14
|
+
const url = `/services/data/${SF_API_VERSION}/query`
|
|
15
|
+
const query = `SELECT UnitPrice__r.Price__r.Id,
|
|
16
|
+
UnitPrice__r.Price__r.Name,
|
|
17
|
+
UnitPrice__r.Price__r.MileageBillingRate__c,
|
|
18
|
+
UnitPrice__r.Price__r.MileageWageRate__c,
|
|
19
|
+
UnitPrice__r.Price__r.BillingRate__c,
|
|
20
|
+
UnitPrice__r.Price__r.WageRate__c,
|
|
21
|
+
UnitPrice__r.Price__r.Overtime1BillingRate__c,
|
|
22
|
+
UnitPrice__r.Price__r.Overtime1WageRate__c,
|
|
23
|
+
UnitPrice__r.Price__r.Overtime2BillingRate__c,
|
|
24
|
+
UnitPrice__r.Price__r.Overtime2WageRate__c,
|
|
25
|
+
UnitPrice__r.Price__r.CallBackBillingRate__c,
|
|
26
|
+
UnitPrice__r.Price__r.CallBackWageRate__c,
|
|
27
|
+
UnitPrice__r.Price__r.OnCallBillingRate__c,
|
|
28
|
+
UnitPrice__r.Price__r.OnCallWageRate__c,
|
|
29
|
+
UnitPrice__r.Price__r.Additional_Billing_Information__c,
|
|
30
|
+
UnitPrice__r.Price__r.Additional_Wage_Information__c
|
|
31
|
+
FROM WorkOrder__c WHERE Id = '${workorderId}' `
|
|
32
|
+
|
|
33
|
+
return await this.axiosInstance
|
|
34
|
+
.get(url, {
|
|
35
|
+
params: { q: query }
|
|
36
|
+
})
|
|
37
|
+
.then(({ data: { records } }) => {
|
|
38
|
+
return records.map(
|
|
39
|
+
(record): Price => ({
|
|
40
|
+
id: record?.UnitPrice__r?.Price__r.Id,
|
|
41
|
+
name: record?.UnitPrice__r?.Price__r.Name,
|
|
42
|
+
mileageBillingRate:
|
|
43
|
+
record?.UnitPrice__r?.Price__r.MileageBillingRate__c,
|
|
44
|
+
mileageWageRate: record?.UnitPrice__r?.Price__r.MileageWageRate__c,
|
|
45
|
+
regularBillingRate: record?.UnitPrice__r?.Price__r.BillingRate__c,
|
|
46
|
+
regularWageRate: record?.UnitPrice__r?.Price__r.WageRate__c,
|
|
47
|
+
overtime1BillingRate:
|
|
48
|
+
record?.UnitPrice__r?.Price__r.Overtime1BillingRate__c,
|
|
49
|
+
overtime1WageRate: record?.UnitPrice__r?.Price__r.Overtime1WageRate__c,
|
|
50
|
+
overtime2BillingRate:
|
|
51
|
+
record?.UnitPrice__r?.Price__r.Overtime2BillingRate__c,
|
|
52
|
+
overtime2WageRate: record?.UnitPrice__r?.Price__r.Overtime2WageRate__c,
|
|
53
|
+
callbackBillingRate:
|
|
54
|
+
record?.UnitPrice__r?.Price__r.CallBackBillingRate__c,
|
|
55
|
+
callbackWageRate: record?.UnitPrice__r?.Price__r.CallBackWageRate__c,
|
|
56
|
+
onCallBillingRate: record?.UnitPrice__r?.Price__r.OnCallBillingRate__c,
|
|
57
|
+
onCallWageRate: record?.UnitPrice__r?.Price__r.OnCallWageRate__c,
|
|
58
|
+
additionalBillingInfo:
|
|
59
|
+
record?.UnitPrice__r?.Price__r.Additional_Billing_Information__c,
|
|
60
|
+
additionalWageInfo:
|
|
61
|
+
record?.UnitPrice__r?.Price__r.Additional_Wage_Information__c
|
|
62
|
+
})
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error fetching Price list: ', error.message)
|
|
67
|
+
throw error
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -45,7 +45,8 @@ export class SFWorkorderClient {
|
|
|
45
45
|
CreatedDate,
|
|
46
46
|
LastModifiedDate,
|
|
47
47
|
Unit__c,
|
|
48
|
-
HealthAuthority__c
|
|
48
|
+
HealthAuthority__c,
|
|
49
|
+
UnitPrice__r.Price__c
|
|
49
50
|
FROM WorkOrder__c ${whereClause}`
|
|
50
51
|
return await this.axiosInstance
|
|
51
52
|
.get(url, {
|
|
@@ -66,7 +67,10 @@ export class SFWorkorderClient {
|
|
|
66
67
|
createdAt: new Date(record.CreatedDate),
|
|
67
68
|
updatedAt: new Date(record.LastModifiedDate),
|
|
68
69
|
unit: formatString(record.Unit__c),
|
|
69
|
-
|
|
70
|
+
externalUnitId: formatId(record.Unit__c),
|
|
71
|
+
healthAuthority: formatString(record.HealthAuthority__c),
|
|
72
|
+
externalHealthAuthorityId: formatId(record.HealthAuthority__c),
|
|
73
|
+
price: record.UnitPrice__r.Price__c
|
|
70
74
|
})
|
|
71
75
|
)
|
|
72
76
|
)
|
|
@@ -77,4 +81,12 @@ export class SFWorkorderClient {
|
|
|
77
81
|
}
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
const formatString = (unformattedUnit: string) =>
|
|
84
|
+
const formatString = (unformattedUnit: string) =>
|
|
85
|
+
!unformattedUnit ? '' : unformattedUnit.replace(/<[^>]*>/g, '').trim()
|
|
86
|
+
|
|
87
|
+
const formatId = (htmlString: string): string => {
|
|
88
|
+
if (!htmlString) return ''
|
|
89
|
+
|
|
90
|
+
const hrefMatch = htmlString.match(/href="\/([^"]+)"/i)
|
|
91
|
+
return hrefMatch ? hrefMatch[1] : ''
|
|
92
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -3,12 +3,13 @@ export { SFApiClient } from './api/salesforce/apiClient'
|
|
|
3
3
|
export { SFPractitionerClient } from './api/salesforce/practitioner/practitionerClient'
|
|
4
4
|
export { SFTimesheetClient } from './api/salesforce/timesheet/timesheetClient'
|
|
5
5
|
export { SFAuthenticator } from './api/salesforce/auth/auth'
|
|
6
|
+
export { SFPriceClient } from './api/salesforce/prices/priceClient'
|
|
7
|
+
export { SFExpenseClient } from './api/salesforce/expenses/expenseClient'
|
|
6
8
|
|
|
7
9
|
// Liphe API
|
|
8
10
|
export { LipheApiClient } from './api/liphe_legacy/lipheApiClient'
|
|
9
11
|
export { LipheAuthenticator } from './api/liphe_legacy/auth/authClient'
|
|
10
12
|
export { LiphePractitionerClient } from './api/liphe_legacy/practitioner/practitionerClient'
|
|
11
|
-
export { SFExpenseClient } from './api/expenses/expenseClient'
|
|
12
13
|
|
|
13
14
|
// Common Models
|
|
14
15
|
export { Practitioner, Role, TimesheetDayEntry, Workorder, Agency, Period } from './models'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface Price {
|
|
2
|
+
id: string
|
|
3
|
+
name?: string
|
|
4
|
+
mileageBillingRate?: number
|
|
5
|
+
mileageWageRate?: number
|
|
6
|
+
regularBillingRate?: number
|
|
7
|
+
regularWageRate?: number
|
|
8
|
+
overtime1BillingRate?: number
|
|
9
|
+
overtime2BillingRate?: number
|
|
10
|
+
overtime1WageRate?: number
|
|
11
|
+
overtime2WageRate?: number
|
|
12
|
+
callbackBillingRate?: number
|
|
13
|
+
callbackWageRate?: number
|
|
14
|
+
onCallBillingRate?: number
|
|
15
|
+
onCallWageRate?: number
|
|
16
|
+
additionalBillingInfo?: string
|
|
17
|
+
additionalWageInfo?: string
|
|
18
|
+
}
|