pha-hermes 1.15.0 → 1.16.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/liphe_legacy/assignment/assignmentClient.d.ts +28 -0
- package/dist/api/{liphe1.0 → liphe_legacy}/auth/authClient.d.ts +1 -1
- package/dist/api/liphe_legacy/contract_request/contractRequestClient.d.ts +80 -0
- package/dist/api/liphe_legacy/contract_request_period/contractRequestPeriodClient.d.ts +47 -0
- package/dist/api/{lipheApiClient.d.ts → liphe_legacy/lipheApiClient.d.ts} +4 -2
- package/dist/api/liphe_legacy/practitioner/practitionerClient.d.ts +7 -0
- package/dist/api/{apiClient.d.ts → salesforce/apiClient.d.ts} +2 -2
- package/dist/api/{payperiod → salesforce/payperiod}/payperiodClient.d.ts +1 -7
- package/dist/api/{practitioner → salesforce/practitioner}/practitionerClient.d.ts +1 -1
- package/dist/api/{timesheet → salesforce/timesheet}/timesheetClient.d.ts +1 -1
- package/dist/api/{workorder → salesforce/workorder}/workorderClient.d.ts +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/models/index.d.ts +13 -17
- package/dist/models/{practitioner.d.ts → user.d.ts} +4 -0
- package/dist/models/workorder.d.ts +20 -0
- package/dist/pha-hermes.cjs.development.js +235 -3
- 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 +237 -4
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/api/expenses/expenseClient.ts +1 -1
- package/src/api/liphe_legacy/assignment/assignmentClient.ts +67 -0
- package/src/api/{liphe1.0 → liphe_legacy}/auth/authClient.ts +11 -2
- package/src/api/liphe_legacy/contract_request/contractRequestClient.ts +128 -0
- package/src/api/liphe_legacy/contract_request_period/contractRequestPeriodClient.ts +233 -0
- package/src/api/{lipheApiClient.ts → liphe_legacy/lipheApiClient.ts} +23 -3
- package/src/api/{liphe1.0 → liphe_legacy}/practitioner/practitionerClient.ts +12 -4
- package/src/api/{apiClient.ts → salesforce/apiClient.ts} +2 -2
- package/src/api/{payperiod → salesforce/payperiod}/payperiodClient.ts +1 -8
- package/src/api/{practitioner → salesforce/practitioner}/practitionerClient.ts +1 -1
- package/src/api/{timesheet → salesforce/timesheet}/timesheetClient.ts +1 -1
- package/src/api/{workorder → salesforce/workorder}/workorderClient.ts +1 -1
- package/src/index.ts +13 -8
- package/src/models/index.ts +13 -18
- package/src/models/{practitioner.ts → user.ts} +5 -0
- package/src/models/workorder.ts +21 -0
- package/dist/api/liphe1.0/practitioner/practitionerClient.d.ts +0 -13
- package/src/api/.env +0 -5
- /package/dist/api/{auth → salesforce/auth}/auth.d.ts +0 -0
- /package/src/api/{auth → salesforce/auth}/auth.ts +0 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios'
|
|
2
|
+
import { Workorder } from '../../../models'
|
|
3
|
+
|
|
4
|
+
export interface LipheContractRequest {
|
|
5
|
+
id: number
|
|
6
|
+
name: string
|
|
7
|
+
po_number: string | null
|
|
8
|
+
level: string
|
|
9
|
+
deadline: string
|
|
10
|
+
from: string
|
|
11
|
+
by: string
|
|
12
|
+
by_value: string
|
|
13
|
+
date: Date
|
|
14
|
+
email_request: string
|
|
15
|
+
type_of_request: string
|
|
16
|
+
status: string
|
|
17
|
+
is_deleted: number
|
|
18
|
+
created_at: Date
|
|
19
|
+
updated_at: Date
|
|
20
|
+
created_by: string
|
|
21
|
+
updated_by: string
|
|
22
|
+
community_id: number
|
|
23
|
+
agency_id: number
|
|
24
|
+
contract_id: number
|
|
25
|
+
job_id: number
|
|
26
|
+
start_date: Date
|
|
27
|
+
end_date: Date
|
|
28
|
+
department_id: number | null
|
|
29
|
+
job: LipheJob
|
|
30
|
+
community: LipheCommunity
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface LipheJob {
|
|
34
|
+
id: number
|
|
35
|
+
code_nethris: number
|
|
36
|
+
translations: LipheJobTranslation[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface LipheJobTranslation {
|
|
40
|
+
id: number
|
|
41
|
+
translatable_type: string
|
|
42
|
+
translatable_id: number
|
|
43
|
+
column: string
|
|
44
|
+
content: string
|
|
45
|
+
locale: string
|
|
46
|
+
created_at: Date
|
|
47
|
+
updated_at: Date
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface LipheCommunity {
|
|
51
|
+
id: number
|
|
52
|
+
name: string
|
|
53
|
+
region: LipheRegion
|
|
54
|
+
contact: LipheContact
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface LipheRegion {
|
|
58
|
+
id: number
|
|
59
|
+
translations: LipheRegionTranslation[]
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface LipheRegionTranslation {
|
|
63
|
+
id: number
|
|
64
|
+
translatable_type: string
|
|
65
|
+
translatable_id: number
|
|
66
|
+
column: string
|
|
67
|
+
content: string
|
|
68
|
+
locale: string
|
|
69
|
+
created_at: Date
|
|
70
|
+
updated_at: Date
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface LipheContact {
|
|
74
|
+
id: number
|
|
75
|
+
address: string
|
|
76
|
+
address_city: string
|
|
77
|
+
address_zip: string
|
|
78
|
+
address_country: string
|
|
79
|
+
address_state: string
|
|
80
|
+
phone: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export class ContractRequestClient {
|
|
84
|
+
private axiosInstance: AxiosInstance
|
|
85
|
+
|
|
86
|
+
constructor(axiosInstance: AxiosInstance) {
|
|
87
|
+
this.axiosInstance = axiosInstance
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async fetchAllContractRequests(
|
|
91
|
+
agencyId: number,
|
|
92
|
+
from?: Date,
|
|
93
|
+
to?: Date,
|
|
94
|
+
page: number = 1,
|
|
95
|
+
page_size: number = 10
|
|
96
|
+
): Promise<Workorder[]> {
|
|
97
|
+
const url = `v2/contract-request/agency/${agencyId}`
|
|
98
|
+
const params = new URLSearchParams()
|
|
99
|
+
|
|
100
|
+
if (from) {
|
|
101
|
+
params.append('from', from.toISOString().split('T')[0] + ' 00:00:00')
|
|
102
|
+
}
|
|
103
|
+
if (to) {
|
|
104
|
+
params.append('to', to.toISOString().split('T')[0] + ' 23:59:59')
|
|
105
|
+
}
|
|
106
|
+
params.append('page', page.toString())
|
|
107
|
+
params.append('page_size', page_size.toString())
|
|
108
|
+
|
|
109
|
+
const response = await this.axiosInstance.get<LipheContractRequest[]>(url, { params })
|
|
110
|
+
|
|
111
|
+
const workorders: Workorder[] = []
|
|
112
|
+
|
|
113
|
+
for (const request of response.data) {
|
|
114
|
+
workorders.push({
|
|
115
|
+
id: request.id.toString(),
|
|
116
|
+
name: request.name,
|
|
117
|
+
region: request.community.region.translations[0].content,
|
|
118
|
+
establishmentName: request.community.name,
|
|
119
|
+
establishmentId: request.community.id.toString(),
|
|
120
|
+
role: request.job.translations.map(t => t.content).join(' / '),
|
|
121
|
+
startDate: request.start_date,
|
|
122
|
+
endDate: request.end_date
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return workorders
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios'
|
|
2
|
+
import { Agency, Period, Workorder } from '../../../models'
|
|
3
|
+
import { LipheContractRequest } from '../contract_request/contractRequestClient'
|
|
4
|
+
import { LipheAssignment } from '../assignment/assignmentClient'
|
|
5
|
+
interface LipheContractRequestPeriods {
|
|
6
|
+
message: string
|
|
7
|
+
status: boolean
|
|
8
|
+
data: LipheContractRequestPeriodData[]
|
|
9
|
+
meta: {
|
|
10
|
+
current_page: number
|
|
11
|
+
from: number
|
|
12
|
+
last_page: number
|
|
13
|
+
path: string
|
|
14
|
+
per_page: number
|
|
15
|
+
to: number
|
|
16
|
+
total: number
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface LipheContractRequestPeriod {
|
|
21
|
+
message: string
|
|
22
|
+
status: boolean
|
|
23
|
+
data: LipheContractRequestPeriodData
|
|
24
|
+
meta: {
|
|
25
|
+
current_page: number
|
|
26
|
+
from: number
|
|
27
|
+
last_page: number
|
|
28
|
+
path: string
|
|
29
|
+
per_page: number
|
|
30
|
+
to: number
|
|
31
|
+
total: number
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface LipheContractRequestPeriodData {
|
|
36
|
+
id: number
|
|
37
|
+
contract_request_id: number
|
|
38
|
+
start_date: Date
|
|
39
|
+
end_date: Date
|
|
40
|
+
shift: 'morning' | 'afternoon' | 'evening' | 'night'
|
|
41
|
+
start_time: Date
|
|
42
|
+
end_time: Date
|
|
43
|
+
departement_id: number
|
|
44
|
+
note: string
|
|
45
|
+
assignment_id: number
|
|
46
|
+
assignment_parent_id: number | null
|
|
47
|
+
created_at: Date
|
|
48
|
+
updated_at: Date
|
|
49
|
+
contract_request: LipheContractRequest
|
|
50
|
+
department: string | null
|
|
51
|
+
assignment: LipheAssignment
|
|
52
|
+
assigned_employee_details: UserDetails
|
|
53
|
+
assignment_employee: any
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface UserDetails {
|
|
57
|
+
id: number
|
|
58
|
+
name: string
|
|
59
|
+
email: string | null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class ContractRequestPeriodClient {
|
|
63
|
+
private axiosInstance: AxiosInstance
|
|
64
|
+
|
|
65
|
+
constructor(axiosInstance: AxiosInstance) {
|
|
66
|
+
this.axiosInstance = axiosInstance
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async fetchAllContractRequestPeriods(
|
|
70
|
+
agencyId: Agency,
|
|
71
|
+
from?: Date,
|
|
72
|
+
to?: Date,
|
|
73
|
+
page: number = 1,
|
|
74
|
+
activeAssignationsOnly: boolean = true,
|
|
75
|
+
assignedPractitionerId?: string
|
|
76
|
+
): Promise<Workorder[]> {
|
|
77
|
+
const url = `v2/contract-request-periods/agency/${agencyId}`
|
|
78
|
+
const params = new URLSearchParams()
|
|
79
|
+
const periods: Workorder[] = []
|
|
80
|
+
let nextPage = true
|
|
81
|
+
|
|
82
|
+
if (from) {
|
|
83
|
+
params.append('from', from.toISOString().split('T')[0] + ' 00:00:00')
|
|
84
|
+
}
|
|
85
|
+
if (to) {
|
|
86
|
+
params.append('to', to.toISOString().split('T')[0] + ' 23:59:59')
|
|
87
|
+
}
|
|
88
|
+
if (page) {
|
|
89
|
+
params.append('page', page.toString())
|
|
90
|
+
}
|
|
91
|
+
if (activeAssignationsOnly) {
|
|
92
|
+
params.append('active_assignations_only', activeAssignationsOnly ? '1' : '0')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (assignedPractitionerId) {
|
|
96
|
+
params.append('assigned_employee_id', assignedPractitionerId)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
while (nextPage) {
|
|
100
|
+
params.set('page', page.toString())
|
|
101
|
+
|
|
102
|
+
const response = await this.axiosInstance.get<LipheContractRequestPeriods>(url, {
|
|
103
|
+
params
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
for (const period of response.data.data) {
|
|
107
|
+
periods.push({
|
|
108
|
+
id: period.id.toString(),
|
|
109
|
+
name: period.id.toString(),
|
|
110
|
+
establishmentId: period.contract_request.community.id.toString(),
|
|
111
|
+
region: period.contract_request.community.contact.address_state,
|
|
112
|
+
establishmentName: period.contract_request.community.name,
|
|
113
|
+
role: this.getRole(period),
|
|
114
|
+
practitionerId: period.assignment.selected_client.id,
|
|
115
|
+
startDate: new Date(period.start_date),
|
|
116
|
+
endDate: new Date(period.end_date),
|
|
117
|
+
createdAt: new Date(period.created_at),
|
|
118
|
+
updatedAt: new Date(period.updated_at)
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
nextPage = page < response.data.meta.last_page
|
|
123
|
+
page++
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return periods
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async fetchContractRequestPeriod(workorderId: string) {
|
|
130
|
+
const url = `v2/contract-request-periods/${workorderId}`
|
|
131
|
+
const params = new URLSearchParams()
|
|
132
|
+
const response = await this.axiosInstance.get<LipheContractRequestPeriod>(url, { params })
|
|
133
|
+
|
|
134
|
+
return response.data.data
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async getPayPeriodDatesForPayPeriodId(payPeriodId: string): Promise<Period[]> {
|
|
138
|
+
const period = await this.fetchContractRequestPeriod(payPeriodId)
|
|
139
|
+
const payPeriods: {
|
|
140
|
+
payPeriodId: string
|
|
141
|
+
startDate: string
|
|
142
|
+
endDate: string
|
|
143
|
+
workorderId: string
|
|
144
|
+
}[] = []
|
|
145
|
+
|
|
146
|
+
const firstPayPeriodDate = this.getPayPeriodDayBeforeStartDate(
|
|
147
|
+
new Date(period.assignment.selected_client.agency.date_first_periode_paie),
|
|
148
|
+
new Date(period.start_date)
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
const lastPayPeriodDate = this.getLastDayOfPayPeriod(
|
|
152
|
+
new Date(firstPayPeriodDate),
|
|
153
|
+
new Date(period.end_date)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
// Calculate the number of weeks between lastPayPeriodDate and firstPayPeriodDate
|
|
157
|
+
const weeksBetween = this.calculateWeeksBetween(firstPayPeriodDate, lastPayPeriodDate)
|
|
158
|
+
|
|
159
|
+
for (let i = 0; i < weeksBetween; i++) {
|
|
160
|
+
const tempDate = new Date(firstPayPeriodDate)
|
|
161
|
+
|
|
162
|
+
const startDate = new Date(tempDate.setDate(tempDate.getDate() + 7 * i))
|
|
163
|
+
const endDate = new Date(tempDate.setDate(tempDate.getDate() + 6))
|
|
164
|
+
|
|
165
|
+
payPeriods.push({
|
|
166
|
+
payPeriodId: '',
|
|
167
|
+
startDate: startDate.toISOString().split('T')[0],
|
|
168
|
+
endDate: endDate.toISOString().split('T')[0],
|
|
169
|
+
workorderId: payPeriodId
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return payPeriods as unknown as Period[]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private getRole(period: LipheContractRequestPeriodData) {
|
|
177
|
+
if (period.contract_request.job.translations.length === 0) {
|
|
178
|
+
return ''
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (period.contract_request.job.translations.length > 1) {
|
|
182
|
+
const roleTranslation = period.contract_request.job.translations.find(
|
|
183
|
+
(translation: any) => translation.locale === 'en'
|
|
184
|
+
)
|
|
185
|
+
return roleTranslation?.content
|
|
186
|
+
} else {
|
|
187
|
+
return period.contract_request.job.translations[0].content
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Calculates the pay period day of week that comes before the start date
|
|
193
|
+
* @param firstPayPeriodDate The first pay period date from the agency
|
|
194
|
+
* @param startDate The start date to find the pay period before
|
|
195
|
+
* @returns The day of week (0-6, where 0 is Sunday) of the pay period before start_date
|
|
196
|
+
*/
|
|
197
|
+
private getPayPeriodDayBeforeStartDate(firstPayPeriodDate: Date, startDate: Date): Date {
|
|
198
|
+
const payPeriodDayOfWeek = firstPayPeriodDate.getDay()
|
|
199
|
+
|
|
200
|
+
// Calculate the most recent pay period date that falls before start_date
|
|
201
|
+
const tempDate = new Date(startDate)
|
|
202
|
+
|
|
203
|
+
// Go back one week at a time until we find a date that matches the pay period day of week
|
|
204
|
+
while (tempDate.getDay() !== payPeriodDayOfWeek) {
|
|
205
|
+
tempDate.setDate(tempDate.getDate() - 1)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// If the calculated date is not before start_date, go back another week
|
|
209
|
+
if (tempDate >= startDate) {
|
|
210
|
+
tempDate.setDate(tempDate.getDate() - 7)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return tempDate
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private getLastDayOfPayPeriod(firstPayPeriodDate: Date, endDate: Date): Date {
|
|
217
|
+
const tempDate = new Date(firstPayPeriodDate)
|
|
218
|
+
|
|
219
|
+
// Go back one week at a time until we find a date that matches the pay period day of week
|
|
220
|
+
while (endDate > tempDate) {
|
|
221
|
+
tempDate.setDate(tempDate.getDate() + 7)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return tempDate
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
private calculateWeeksBetween(startDate: Date, endDate: Date): number {
|
|
228
|
+
const diffTime = Math.abs(endDate.getTime() - startDate.getTime())
|
|
229
|
+
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
|
|
230
|
+
const weeks = Math.floor(diffDays / 7)
|
|
231
|
+
return weeks
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from 'axios'
|
|
2
|
-
import { LipheAuthenticator } from './
|
|
3
|
-
import { LiphePractitionerClient } from './
|
|
2
|
+
import { LipheAuthenticator } from './auth/authClient'
|
|
3
|
+
import { LiphePractitionerClient } from './practitioner/practitionerClient'
|
|
4
|
+
import { ContractRequestPeriodClient } from './contract_request_period/contractRequestPeriodClient'
|
|
5
|
+
import axiosRetry from 'axios-retry'
|
|
4
6
|
|
|
5
7
|
export class LipheApiClient {
|
|
6
8
|
private instance: LipheApiClient | undefined = undefined
|
|
7
9
|
private axiosInstance: AxiosInstance = axios.create()
|
|
8
10
|
private authenticator: LipheAuthenticator
|
|
9
11
|
public practitionerClient: LiphePractitionerClient
|
|
12
|
+
public contractRequestPeriodClient: ContractRequestPeriodClient
|
|
10
13
|
|
|
11
|
-
constructor(
|
|
14
|
+
constructor(
|
|
15
|
+
baseUrl: string,
|
|
16
|
+
email: string,
|
|
17
|
+
password: string,
|
|
18
|
+
type: 'user' | 'client' = 'user'
|
|
19
|
+
) {
|
|
12
20
|
this.axiosInstance.defaults.baseURL = baseUrl
|
|
13
21
|
|
|
14
22
|
this.authenticator = new LipheAuthenticator(
|
|
@@ -18,7 +26,19 @@ export class LipheApiClient {
|
|
|
18
26
|
password,
|
|
19
27
|
type
|
|
20
28
|
)
|
|
29
|
+
|
|
30
|
+
axiosRetry(this.axiosInstance, {
|
|
31
|
+
retries: 10,
|
|
32
|
+
retryDelay: retryCount => {
|
|
33
|
+
return Math.min(1000 * Math.pow(2, retryCount - 1), 30000)
|
|
34
|
+
},
|
|
35
|
+
onRetry: (retryCount, error) => {
|
|
36
|
+
console.log(`Retry attempt ${retryCount} failed: ${error.message}`)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
21
40
|
this.practitionerClient = new LiphePractitionerClient(this.axiosInstance)
|
|
41
|
+
this.contractRequestPeriodClient = new ContractRequestPeriodClient(this.axiosInstance)
|
|
22
42
|
}
|
|
23
43
|
async init() {
|
|
24
44
|
await this.authenticator.initializeAuth()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AxiosInstance } from 'axios'
|
|
2
|
+
import { Practitioner } from '../../../models'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
interface LiphePractitioner {
|
|
4
5
|
id: number
|
|
5
6
|
firstname: string
|
|
6
7
|
lastname: string
|
|
@@ -14,13 +15,13 @@ export class LiphePractitionerClient {
|
|
|
14
15
|
constructor(axiosInstance: AxiosInstance) {
|
|
15
16
|
this.axios = axiosInstance
|
|
16
17
|
}
|
|
17
|
-
async fetchAllPractitioners(agencyId: number = 1): Promise<
|
|
18
|
+
async fetchAllPractitioners(agencyId: number = 1): Promise<Practitioner[]> {
|
|
18
19
|
let practitioners: LiphePractitioner[] = []
|
|
19
20
|
let page = 1
|
|
20
21
|
let nextPage = true
|
|
21
22
|
|
|
22
23
|
while (nextPage) {
|
|
23
|
-
const response = await this.axios.get('
|
|
24
|
+
const response = await this.axios.get('v2/employees', {
|
|
24
25
|
params: {
|
|
25
26
|
agency_id: agencyId,
|
|
26
27
|
page
|
|
@@ -30,6 +31,7 @@ export class LiphePractitionerClient {
|
|
|
30
31
|
if (!data?.data || !Array.isArray(data.data)) {
|
|
31
32
|
throw new Error('Unexpected responses.')
|
|
32
33
|
}
|
|
34
|
+
|
|
33
35
|
const pagePractitioners = data.data.map(
|
|
34
36
|
(p: any): LiphePractitioner => ({
|
|
35
37
|
id: p.id,
|
|
@@ -44,6 +46,12 @@ export class LiphePractitionerClient {
|
|
|
44
46
|
nextPage = Boolean(data.next_page_url)
|
|
45
47
|
page++
|
|
46
48
|
}
|
|
47
|
-
return practitioners
|
|
49
|
+
return practitioners.map(p => ({
|
|
50
|
+
id: String(p.id),
|
|
51
|
+
firstName: p.firstname,
|
|
52
|
+
lastName: p.lastname,
|
|
53
|
+
email: p.email,
|
|
54
|
+
staffId: String(p.id)
|
|
55
|
+
}))
|
|
48
56
|
}
|
|
49
57
|
}
|
|
@@ -2,10 +2,10 @@ import axios, { AxiosInstance } from 'axios'
|
|
|
2
2
|
import { SFAuthenticator } from './auth/auth'
|
|
3
3
|
import { SFTimesheetClient } from './timesheet/timesheetClient'
|
|
4
4
|
import { SFPractitionerClient } from './practitioner/practitionerClient'
|
|
5
|
-
import { Role } from '
|
|
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
9
|
|
|
10
10
|
export const SF_API_VERSION: string = 'v57.0'
|
|
11
11
|
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios'
|
|
2
2
|
import { SF_API_VERSION } from '../apiClient'
|
|
3
|
-
|
|
4
|
-
export interface Period {
|
|
5
|
-
payPeriodId: string
|
|
6
|
-
startDate: Date
|
|
7
|
-
endDate: Date
|
|
8
|
-
timesheetId?: string
|
|
9
|
-
workorderId?: string
|
|
10
|
-
}
|
|
3
|
+
import { Period } from '../../../models'
|
|
11
4
|
|
|
12
5
|
export class SFPayPeriodClient {
|
|
13
6
|
private axiosInstance: AxiosInstance
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export {
|
|
1
|
+
// Salesforce API
|
|
2
|
+
export { SFApiClient } from './api/salesforce/apiClient'
|
|
3
|
+
export { SFPractitionerClient } from './api/salesforce/practitioner/practitionerClient'
|
|
4
|
+
export { SFTimesheetClient } from './api/salesforce/timesheet/timesheetClient'
|
|
5
|
+
export { SFAuthenticator } from './api/salesforce/auth/auth'
|
|
6
|
+
|
|
7
|
+
// Liphe API
|
|
8
|
+
export { LipheApiClient } from './api/liphe_legacy/lipheApiClient'
|
|
9
|
+
export { LipheAuthenticator } from './api/liphe_legacy/auth/authClient'
|
|
10
|
+
export { LiphePractitionerClient } from './api/liphe_legacy/practitioner/practitionerClient'
|
|
9
11
|
export { SFExpenseClient } from './api/expenses/expenseClient'
|
|
12
|
+
|
|
13
|
+
// Common Models
|
|
14
|
+
export { Practitioner, Role, TimesheetDayEntry, Workorder, Agency, Period } from './models'
|
package/src/models/index.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
role: string
|
|
13
|
-
practitionerId: string
|
|
14
|
-
startDate: Date
|
|
15
|
-
endDate: Date
|
|
16
|
-
createdAt: Date
|
|
17
|
-
updatedAt: Date
|
|
1
|
+
export enum Agency {
|
|
2
|
+
CHCA = "7",
|
|
3
|
+
CodeBleu = "5",
|
|
4
|
+
NordikOntario = "6",
|
|
5
|
+
PHA = "8",
|
|
6
|
+
PremierSoin = "1",
|
|
7
|
+
PremierSoinNordik = "3",
|
|
8
|
+
SolutionNursing = "4",
|
|
9
|
+
SolutionsStaffing = "9",
|
|
10
|
+
Transport = "2",
|
|
11
|
+
SSI = "99"
|
|
18
12
|
}
|
|
19
13
|
|
|
20
14
|
export * from './timesheet'
|
|
21
|
-
export * from './
|
|
15
|
+
export * from './user'
|
|
16
|
+
export * from './workorder'
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface Period {
|
|
2
|
+
payPeriodId: string
|
|
3
|
+
startDate: Date
|
|
4
|
+
endDate: Date
|
|
5
|
+
timesheetId?: string
|
|
6
|
+
workorderId?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Workorder {
|
|
10
|
+
id: string
|
|
11
|
+
name: string
|
|
12
|
+
region: string
|
|
13
|
+
establishmentName: string
|
|
14
|
+
establishmentId: string
|
|
15
|
+
role: string
|
|
16
|
+
practitionerId?: string
|
|
17
|
+
startDate: Date
|
|
18
|
+
endDate: Date
|
|
19
|
+
createdAt?: Date
|
|
20
|
+
updatedAt?: Date
|
|
21
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AxiosInstance } from 'axios';
|
|
2
|
-
export interface LiphePractitioner {
|
|
3
|
-
id: number;
|
|
4
|
-
firstname: string;
|
|
5
|
-
lastname: string;
|
|
6
|
-
email: string;
|
|
7
|
-
communicationMode?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare class LiphePractitionerClient {
|
|
10
|
-
private axios;
|
|
11
|
-
constructor(axiosInstance: AxiosInstance);
|
|
12
|
-
fetchAllPractitioners(agencyId?: number): Promise<LiphePractitioner[]>;
|
|
13
|
-
}
|
package/src/api/.env
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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
|
|
File without changes
|
|
File without changes
|