pha-hermes 1.24.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.
- package/dist/api/salesforce/practitioner/practitionerClient.d.ts +8 -1
- package/dist/models/user.d.ts +13 -0
- package/dist/pha-hermes.cjs.development.js +38 -9
- 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 +38 -9
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/salesforce/practitioner/practitionerClient.ts +65 -4
- package/src/models/user.ts +14 -0
|
@@ -1,18 +1,54 @@
|
|
|
1
1
|
import { AxiosInstance } from 'axios'
|
|
2
|
-
import { Practitioner, Role } from '../../../models'
|
|
2
|
+
import { Practitioner, PractitionerExport, Role } from '../../../models'
|
|
3
3
|
import { SF_API_VERSION } from '../../../index'
|
|
4
4
|
|
|
5
5
|
export class SFPractitionerClient {
|
|
6
|
+
private PRACTITIONER_FIELDS = {
|
|
7
|
+
default: ['Id', 'FirstName__c', 'LastName__c', 'Email__c', 'StaffID__c', 'CreatedDate'],
|
|
8
|
+
export: [
|
|
9
|
+
'Id',
|
|
10
|
+
'FirstName__c',
|
|
11
|
+
'LastName__c',
|
|
12
|
+
'Email__c',
|
|
13
|
+
'StaffID__c',
|
|
14
|
+
'CreatedDate',
|
|
15
|
+
'DaytimePhone__c',
|
|
16
|
+
'Status__c',
|
|
17
|
+
'ProfessionalDesignation__c',
|
|
18
|
+
'CANSocialInsuranceNumber__c',
|
|
19
|
+
'Date_of_Hire__c',
|
|
20
|
+
'DateApplied__c',
|
|
21
|
+
'Birthdate__c',
|
|
22
|
+
'MailingStreetAddress__c',
|
|
23
|
+
'MailingCity__c',
|
|
24
|
+
'MailingStateProvince__c',
|
|
25
|
+
'MailingZipPostalCode__c'
|
|
26
|
+
]
|
|
27
|
+
} as const
|
|
28
|
+
|
|
6
29
|
private axiosInstance: AxiosInstance
|
|
7
30
|
|
|
8
31
|
constructor(axiosInstance: AxiosInstance) {
|
|
9
32
|
this.axiosInstance = axiosInstance
|
|
10
33
|
}
|
|
11
34
|
|
|
35
|
+
async fetchPractitioners(options: {
|
|
36
|
+
createdAt?: string
|
|
37
|
+
limit?: number
|
|
38
|
+
forExport: true
|
|
39
|
+
}): Promise<PractitionerExport[]>
|
|
40
|
+
|
|
41
|
+
async fetchPractitioners(options?: {
|
|
42
|
+
createdAt?: string
|
|
43
|
+
limit?: number
|
|
44
|
+
forExport?: false | undefined
|
|
45
|
+
}): Promise<Practitioner[]>
|
|
46
|
+
|
|
12
47
|
async fetchPractitioners(options?: {
|
|
13
48
|
createdAt?: string
|
|
14
49
|
limit?: number
|
|
15
|
-
|
|
50
|
+
forExport?: boolean
|
|
51
|
+
}): Promise<Practitioner[] | PractitionerExport[]> {
|
|
16
52
|
try {
|
|
17
53
|
const conditions: string[] = [`Status__c = 'Active'`]
|
|
18
54
|
if (options?.createdAt) {
|
|
@@ -24,8 +60,14 @@ export class SFPractitionerClient {
|
|
|
24
60
|
? `LIMIT ${Math.floor(options.limit)}`
|
|
25
61
|
: ''
|
|
26
62
|
const url = `/services/data/${SF_API_VERSION}/query`
|
|
63
|
+
const fields = (
|
|
64
|
+
options?.forExport
|
|
65
|
+
? this.PRACTITIONER_FIELDS.export
|
|
66
|
+
: this.PRACTITIONER_FIELDS.default
|
|
67
|
+
).join(', ')
|
|
68
|
+
|
|
27
69
|
const query = `
|
|
28
|
-
SELECT
|
|
70
|
+
SELECT ${fields}
|
|
29
71
|
FROM Personnel__c
|
|
30
72
|
${whereClause}
|
|
31
73
|
ORDER BY CreatedDate ASC, StaffID__c ASC
|
|
@@ -37,7 +79,9 @@ export class SFPractitionerClient {
|
|
|
37
79
|
params: { q: query }
|
|
38
80
|
})
|
|
39
81
|
|
|
40
|
-
return
|
|
82
|
+
return options?.forExport
|
|
83
|
+
? records.map(toPractitionerExport)
|
|
84
|
+
: records.map(toPractitioner)
|
|
41
85
|
} catch (error) {
|
|
42
86
|
console.error('Error fetching practitioners: ', error.message)
|
|
43
87
|
throw error
|
|
@@ -107,3 +151,20 @@ function toPractitioner(raw: any): Practitioner {
|
|
|
107
151
|
createdAt: raw.CreatedDate ? raw.CreatedDate.replace(/\+0000$/, 'Z') : undefined
|
|
108
152
|
}
|
|
109
153
|
}
|
|
154
|
+
|
|
155
|
+
function toPractitionerExport(raw: any): PractitionerExport {
|
|
156
|
+
return {
|
|
157
|
+
...toPractitioner(raw),
|
|
158
|
+
phone: raw.DaytimePhone__c,
|
|
159
|
+
status: raw.Status__c,
|
|
160
|
+
professionalDesignation: raw.ProfessionalDesignation__c,
|
|
161
|
+
SIN: raw.CANSocialInsuranceNumber__c,
|
|
162
|
+
hiringDate: raw.Date_of_Hire__c,
|
|
163
|
+
dateApplied: raw.DateApplied__c,
|
|
164
|
+
birthdate: raw.Birthdate__c,
|
|
165
|
+
mailingStreetAddress: raw.MailingStreetAddress__c,
|
|
166
|
+
mailingCity: raw.MailingCity__c,
|
|
167
|
+
mailingProvince: raw.MailingStateProvince__c,
|
|
168
|
+
mailingZip: raw.MailingZipPostalCode__c
|
|
169
|
+
}
|
|
170
|
+
}
|
package/src/models/user.ts
CHANGED
|
@@ -7,6 +7,20 @@ export interface Practitioner {
|
|
|
7
7
|
createdAt?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface PractitionerExport extends Practitioner {
|
|
11
|
+
phone: string | null
|
|
12
|
+
status: string | null
|
|
13
|
+
professionalDesignation: string | null
|
|
14
|
+
SIN: string | null
|
|
15
|
+
hiringDate: string | null
|
|
16
|
+
dateApplied: string | null
|
|
17
|
+
birthdate: string | null
|
|
18
|
+
mailingStreetAddress: string | null
|
|
19
|
+
mailingCity: string | null
|
|
20
|
+
mailingProvince: string | null
|
|
21
|
+
mailingZip: string | null
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
export interface Role {
|
|
11
25
|
label: string
|
|
12
26
|
value: string
|