oro-sdk 2.1.4-dev1.0 → 2.2.1

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.
Files changed (63) hide show
  1. package/README.md +26 -34
  2. package/dist/client.d.ts +4 -4
  3. package/dist/helpers/client.d.ts +1 -1
  4. package/dist/helpers/patient-registration.d.ts +1 -1
  5. package/dist/helpers/vault-grants.d.ts +1 -1
  6. package/dist/helpers/workflow.d.ts +1 -1
  7. package/dist/index.d.ts +15 -1
  8. package/dist/models/client.d.ts +1 -1
  9. package/dist/models/error.d.ts +0 -14
  10. package/dist/models/index.d.ts +0 -7
  11. package/dist/oro-sdk.cjs.development.js +313 -2367
  12. package/dist/oro-sdk.cjs.development.js.map +1 -1
  13. package/dist/oro-sdk.cjs.production.min.js +1 -1
  14. package/dist/oro-sdk.cjs.production.min.js.map +1 -1
  15. package/dist/oro-sdk.esm.js +246 -2344
  16. package/dist/oro-sdk.esm.js.map +1 -1
  17. package/dist/sdk-revision/client.d.ts +2 -2
  18. package/dist/services/index.d.ts +0 -9
  19. package/package.json +4 -1
  20. package/src/client.ts +161 -435
  21. package/src/helpers/client.ts +1 -1
  22. package/src/helpers/patient-registration.ts +85 -166
  23. package/src/helpers/vault-grants.ts +1 -1
  24. package/src/helpers/workflow.ts +21 -59
  25. package/src/index.ts +42 -28
  26. package/src/models/client.ts +1 -1
  27. package/src/models/error.ts +6 -13
  28. package/src/models/index.ts +0 -7
  29. package/src/sdk-revision/client.ts +25 -20
  30. package/src/services/external/clinia.ts +1 -1
  31. package/src/services/index.ts +0 -9
  32. package/dist/models/consult.d.ts +0 -102
  33. package/dist/models/diagnosis.d.ts +0 -122
  34. package/dist/models/guard.d.ts +0 -119
  35. package/dist/models/practice.d.ts +0 -353
  36. package/dist/models/shared.d.ts +0 -8
  37. package/dist/models/vault.d.ts +0 -124
  38. package/dist/models/workflow.d.ts +0 -106
  39. package/dist/services/api.d.ts +0 -11
  40. package/dist/services/axios.d.ts +0 -14
  41. package/dist/services/consult.d.ts +0 -54
  42. package/dist/services/diagnosis.d.ts +0 -44
  43. package/dist/services/guard.d.ts +0 -92
  44. package/dist/services/practice.d.ts +0 -100
  45. package/dist/services/teller.d.ts +0 -9
  46. package/dist/services/vault.d.ts +0 -54
  47. package/dist/services/workflow.d.ts +0 -21
  48. package/src/models/consult.ts +0 -110
  49. package/src/models/diagnosis.ts +0 -141
  50. package/src/models/guard.ts +0 -136
  51. package/src/models/practice.ts +0 -411
  52. package/src/models/shared.ts +0 -6
  53. package/src/models/vault.ts +0 -158
  54. package/src/models/workflow.ts +0 -142
  55. package/src/services/api.ts +0 -77
  56. package/src/services/axios.ts +0 -91
  57. package/src/services/consult.ts +0 -265
  58. package/src/services/diagnosis.ts +0 -144
  59. package/src/services/guard.ts +0 -228
  60. package/src/services/practice.ts +0 -537
  61. package/src/services/teller.ts +0 -39
  62. package/src/services/vault.ts +0 -178
  63. package/src/services/workflow.ts +0 -36
@@ -1,144 +0,0 @@
1
- import {
2
- Drug,
3
- TreatmentPlan,
4
- TreatmentPlans,
5
- TreatmentPlansRequest,
6
- TreatmentPlansResponse,
7
- Uuid,
8
- } from '..'
9
- import { Diagnosis, Treatment, DiagnosisRequest, TreatmentRequest, TreatmentAndDrugPrescriptionUpdateRequest } from '../models/diagnosis'
10
- import { APIService } from './api'
11
-
12
- export class DiagnosisService {
13
- constructor(private api: APIService, private baseURL: string) {}
14
-
15
- public getDiagnoses(): Promise<Diagnosis[]> {
16
- return this.api.get<Diagnosis[]>(`${this.baseURL}/v1/diagnoses`)
17
- }
18
-
19
- /**
20
- * Get a diagnosis by uuid that belongs to your practice
21
- * @param uuidDiagnosis the uuid of the diagnosis
22
- * @returns a diagnosis
23
- */
24
- public getDiagnosisByUuid(uuidDiagnosis: Uuid): Promise<Diagnosis> {
25
- return this.api.get<Diagnosis>(
26
- `${this.baseURL}/v1/diagnoses/${uuidDiagnosis}`
27
- )
28
- }
29
-
30
- public createDiagnosis(diagnosis: DiagnosisRequest): Promise<Diagnosis> {
31
- return this.api.post<Diagnosis>(
32
- `${this.baseURL}/v1/diagnoses`,
33
- diagnosis
34
- )
35
- }
36
-
37
- public updateDiagnosis(
38
- uuid: string,
39
- diagnosis: DiagnosisRequest
40
- ): Promise<Diagnosis> {
41
- return this.api.put<Diagnosis>(
42
- `${this.baseURL}/v1/diagnoses/${uuid}`,
43
- diagnosis
44
- )
45
- }
46
-
47
- public getTreatmentsFromDiagnosisUuid(
48
- diagnosisUuid: Uuid
49
- ): Promise<Treatment[]> {
50
- return this.api.get<Treatment[]>(
51
- `${this.baseURL}/v1/diagnoses/${diagnosisUuid}/treatments`
52
- )
53
- }
54
-
55
- /**
56
- * This function returns treatment plans associated to a consult
57
- * @param uuidConsult the consult uuid to fetch
58
- * @returns an array of TreatmentPlan
59
- */
60
- public getTreatmentPlansFromConsultUuid(
61
- uuidConsult: Uuid
62
- ): Promise<TreatmentPlan[]> {
63
- return this.api.get<TreatmentPlan[]>(
64
- `${this.baseURL}/v1/treatment-plans/`,
65
- { params: { uuidConsult } }
66
- )
67
- }
68
-
69
- /**
70
- * creates a new treatment for the diagnosis specified
71
- * @param diagnosisUuid uuid of the diagnosis that is linked to the treatment
72
- * @param treatmentRequest the treatment to be inserted
73
- */
74
- public createTreatment(diagnosisUuid: string, treatmentRequest: TreatmentRequest) {
75
- return this.api.post<Treatment>(
76
- `${this.baseURL}/v1/diagnoses/${diagnosisUuid}/treatments`,
77
- treatmentRequest
78
- )
79
- }
80
-
81
- /**
82
- * This function returns populated treatment plans associated to a consult
83
- * @param uuidConsult the consult uuid to fetch
84
- * @returns a TreatmentPlans object
85
- */
86
- public getTreatmentPlansPopulatedFromConsultUuid(
87
- uuidConsult: Uuid
88
- ): Promise<TreatmentPlans> {
89
- return this.api.get<TreatmentPlans>(
90
- `${this.baseURL}/v1/treatment-plans/`,
91
- { params: { uuidConsult, populated: true } }
92
- )
93
- }
94
-
95
- public postPlans(
96
- plans: TreatmentPlansRequest
97
- ): Promise<TreatmentPlansResponse> {
98
- return this.api.post<TreatmentPlansResponse>(
99
- `${this.baseURL}/v1/treatment-plans`,
100
- plans
101
- )
102
- }
103
-
104
- public updateTreatmentPlan(
105
- uuidPlan: string,
106
- uuidConsult: string,
107
- diagnosisRequest: DiagnosisRequest,
108
- plan: TreatmentAndDrugPrescriptionUpdateRequest
109
- ): Promise<TreatmentPlan> {
110
- return this.api.put<TreatmentPlan>(
111
- `${this.baseURL}/v1/treatment-plans/${uuidPlan}`,
112
- {
113
- uuidConsult,
114
- diagnosis: diagnosisRequest,
115
- plan
116
- }
117
- )
118
- }
119
-
120
- public acceptTreatmentPlan(
121
- uuidPlan: string,
122
- uuidConsult: string
123
- ): Promise<TreatmentPlan> {
124
- return this.api.put<TreatmentPlan>(
125
- `${this.baseURL}/v1/treatment-plans/${uuidPlan}/accept`,
126
- { uuidConsult }
127
- )
128
- }
129
-
130
- /**
131
- * retrieves all the drugs of the specified practice
132
- * @param uuidPractice
133
- */
134
- public async getAllDrugs(
135
- uuidPractice: string
136
- ): Promise<Drug[] | undefined> {
137
- const res = await this.api.get<{foundDrugs: Drug[]}>(
138
- `${this.baseURL}/v1/drugs/practice/${uuidPractice}`,
139
- )
140
- if(res && res.foundDrugs)
141
- return res.foundDrugs
142
- return undefined
143
- }
144
- }
@@ -1,228 +0,0 @@
1
- import { APIService } from './api'
2
- import type { AxiosAuthRefreshRequestConfig } from 'axios-auth-refresh'
3
- import {
4
- AuthTokenRequest,
5
- AuthTokenResponse,
6
- AuthRecoverRequest,
7
- IdentityCreateRequest,
8
- IdentityUpdateRequest,
9
- IdentityResponse,
10
- QRCodeRequest,
11
- QRCodeResponse,
12
- Uuid,
13
- WhoAmIResponse,
14
- Base64String,
15
- AuthenticationFailed,
16
- IdentityCreationFailed,
17
- AuthenticationBadRequest,
18
- AuthenticationServerError,
19
- IdentityCreationBadRequest,
20
- IdentityCreationConflict,
21
- Tokens
22
- } from '../models'
23
- import { AxiosError } from 'axios'
24
-
25
- export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig {
26
- useRefreshToken : boolean
27
- }
28
- export class GuardService {
29
- private identityCache: Record<string, IdentityResponse>
30
- private whoAmICache: Record<string, WhoAmIResponse>
31
-
32
- constructor(private api: APIService, private baseURL: string) {
33
- this.api.setAuthRefreshFn(this.authRefresh.bind(this))
34
- this.identityCache = {}
35
- this.whoAmICache = {}
36
- }
37
-
38
- /**
39
- * Will replace access and refresh tokens with `tokens`
40
- *
41
- * Note:
42
- * ```typescript
43
- * setTokens({accessToken: undefined, refreshToken: 'aTokenValue'}) // will erase accessToken and set refreshToken with 'aTokenValue'
44
- * setTokens({refreshToken: 'aTokenValue'}) // will keep actual value of accessToken and set refreshToken with 'aTokenValue'
45
- *
46
- * ```
47
- * @param tokens
48
- */
49
- public setTokens(tokens: Tokens) {
50
- this.api.setTokens({...this.api.getTokens() , ...tokens })
51
- }
52
-
53
- /**
54
- * Allow to retrieve an access token and a refresh token in order
55
- * to do authenticated request afterward
56
- *
57
- * @param req The credentials required to get an access token
58
- * @returns AuthTokenResponse
59
- */
60
- public async authToken(req: AuthTokenRequest): Promise<AuthTokenResponse> {
61
- let resp : AuthTokenResponse
62
-
63
- try {
64
- let config: AxiosAuthRefreshRequestConfig = {
65
- skipAuthRefresh: true
66
- }
67
-
68
- resp = await this.api.post<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, req, config)
69
-
70
- this.api.setTokens({
71
- accessToken: resp.accessToken,
72
- refreshToken: resp.refreshToken
73
- })
74
- } catch(e) {
75
- if((e as any).isAxiosError){
76
- const code = (e as AxiosError).response?.status
77
- switch (code) {
78
- case 400:
79
- throw new AuthenticationBadRequest()
80
- case 500:
81
- throw new AuthenticationServerError()
82
- case 401:
83
- default:
84
- throw new AuthenticationFailed()
85
- }
86
- }
87
- throw new AuthenticationFailed()
88
-
89
- }
90
- return resp
91
- }
92
-
93
- /**
94
- * Get new access and refresh token
95
- *
96
- * @returns AuthTokenResponse
97
- */
98
- public async authRefresh(refreshToken?: string): Promise<AuthTokenResponse> {
99
- let config: GuardRequestConfig = {
100
- skipAuthRefresh: true,
101
- useRefreshToken: true
102
- }
103
- return this.api.put<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, null, config)
104
- }
105
-
106
-
107
- /**
108
- * Call guard to overwrite existing refresh token cookie
109
- *
110
- * @returns void
111
- */
112
- public async authLogout(): Promise<void> {
113
- return this.api.get<void>(`${this.baseURL}/v1/auth/logout`)
114
- }
115
-
116
-
117
- /**
118
- * Call guard to attempt account recovery
119
- *
120
- * @param req The email address / practice of the account to recover
121
- * @returns void
122
- */
123
- public async authRecover(req: AuthRecoverRequest): Promise<void> {
124
- return this.api.post<void>(`${this.baseURL}/v1/auth/recover`, req)
125
- }
126
-
127
-
128
- /**
129
- * Allow to create a new identity. The identity will then need to be confirmed
130
- * via an email link
131
- *
132
- * @param req the information about the new identity to create
133
- * @returns IdentityResponse
134
- */
135
- public async identityCreate(req: IdentityCreateRequest): Promise<IdentityResponse> {
136
- let resp : IdentityResponse
137
-
138
- try {
139
- resp = await this.api.post<IdentityResponse>(`${this.baseURL}/v1/identities`, req)
140
- this.api.setTokens({
141
- refreshToken: resp.refreshToken
142
- })
143
- } catch (e) {
144
- if((e as any).isAxiosError){
145
- const code = (e as AxiosError).response?.status
146
- switch (code) {
147
- case 400:
148
- throw new IdentityCreationBadRequest()
149
- case 409:
150
- throw new IdentityCreationConflict()
151
- case 500:
152
- default:
153
- throw new IdentityCreationFailed()
154
- }
155
- }
156
- throw new IdentityCreationFailed()
157
- }
158
- return resp
159
- }
160
-
161
-
162
- /**
163
- * Retrieve an identity. Will return public fields only when requested
164
- * without authentication
165
- *
166
- * @param identityID Unique id of the identity to retrieve
167
- * @returns IdentityResponse
168
- */
169
- public async identityGet(
170
- identityID: Uuid
171
- ): Promise<IdentityResponse> {
172
- const tokens = this.api.getTokens()
173
- const cacheKey = (tokens.accessToken ?? '') + (tokens.refreshToken ?? '') + identityID
174
-
175
- if (!tokens.accessToken || !this.identityCache[cacheKey]) {
176
- this.identityCache[cacheKey] = await this.api.get<IdentityResponse>(
177
- `${this.baseURL}/v1/identities/${identityID}`
178
- )
179
- }
180
- return this.identityCache[cacheKey]
181
- }
182
-
183
-
184
- /**
185
- * Get information about the current authenticated user
186
- *
187
- * @param refreshCache if true it will refresh the whoAmI cache (default: false)
188
- * @returns WhoAmIResponse
189
- */
190
- public async whoAmI(refreshCache: boolean = false): Promise<WhoAmIResponse> {
191
- const cacheKey = this.api.getTokens().accessToken ?? ''
192
- if (!this.whoAmICache[cacheKey] || refreshCache) {
193
- this.whoAmICache[cacheKey] = await this.api.get<WhoAmIResponse>(`${this.baseURL}/v1/auth/whoami`)
194
- }
195
- return this.whoAmICache[cacheKey]
196
- }
197
-
198
- /**
199
- * Update an existing identity
200
- *
201
- * @param identityID unique id of identity to update
202
- * @param req update request
203
- * @returns IdentityResponse
204
- */
205
- public async identityUpdate(
206
- identityID: Uuid,
207
- req: IdentityUpdateRequest
208
- ): Promise<IdentityResponse> {
209
- return this.api.put<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`, req)
210
- }
211
-
212
- /**
213
- * Return base64 data representing a QR code that the
214
- * current identity need in order to use MFA
215
- *
216
- * @param identityID unique id of the identity
217
- * @param password the identity password (already hashed and in base64)
218
- * @returns QRCodeResponse
219
- */
220
- public async identityMFAQRCode(
221
- identityID: Uuid,
222
- password: Base64String
223
- ): Promise<QRCodeResponse> {
224
- const req: QRCodeRequest = { password }
225
- return this.api.post<QRCodeResponse>(`${this.baseURL}/v1/identities/${identityID}/mfa`, req, { headers: { 'Accept': 'application/json' } })
226
- }
227
- }
228
-