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,142 +0,0 @@
1
- export interface IndexedData<T> {
2
- [key: string]: T
3
- }
4
-
5
- export type SelectedAnswerData = string | string[]
6
- export type SelectedAnswersData = IndexedData<SelectedAnswerData>[]
7
-
8
- export interface ChoiceInputData {
9
- text: string
10
- className?: string
11
- order?: number
12
- }
13
-
14
- export interface RadioInputIconOptionsData {
15
- variant: 'icon'
16
- icon: string
17
- }
18
-
19
- export interface RadioInputData extends ChoiceInputData {
20
- options?: RadioInputIconOptionsData
21
- }
22
-
23
- export interface RadioCardInputData extends RadioInputData {
24
- bodyText: string
25
- }
26
- export interface EntryData {
27
- id?: number
28
- label?: string
29
- summaryLabel?: string
30
- summaryHidden?: boolean
31
- className?: string
32
- triggers?: string[]
33
- }
34
-
35
- export enum MetadataCategory { //these are generic metadata categories
36
- ChildPersonal = 'ChildPersonal',
37
- Consultation = 'Consultation',
38
- DataRetrieval = 'DataRetrieval',
39
- Followup = 'Followup',
40
- Recovery = 'Recovery',
41
- Medical = 'Medical',
42
- OtherPersonal = 'OtherPersonal',
43
- Personal = 'Personal',
44
- Preference = 'Preference',
45
- Prescription = 'Prescription',
46
- Raw = 'Raw',
47
- }
48
-
49
- export interface GenericQuestionData<T, A = IndexedData<ChoiceInputData>>
50
- extends EntryData {
51
- kind: T
52
- metaCategory: MetadataCategory
53
- answers?: A
54
- formValidation?: any[] // use yup-ast expressions
55
- placeholder?: string
56
- defaultValue?: any
57
- value?: string
58
- }
59
-
60
- export interface GroupedGenericQuestionData<
61
- T,
62
- A = IndexedData<ChoiceInputData>
63
- > extends GenericQuestionData<T, A> {
64
- inline?: boolean
65
- inlineLabel?: boolean
66
- order?: number
67
- }
68
-
69
- export type QuestionData =
70
- | GenericQuestionData<'title' | 'paragraph' | 'checkbox', void>
71
- | GenericQuestionData<
72
- | 'text'
73
- | 'date'
74
- | 'number'
75
- | 'images'
76
- | 'images-alias'
77
- | 'body-parts'
78
- | 'pharmacy-picker'
79
- | 'place-address'
80
- >
81
- | GenericQuestionData<
82
- 'checkbox-group' | 'select' | 'multiple',
83
- IndexedData<ChoiceInputData>
84
- >
85
- | GroupedGenericQuestionData<'radio', IndexedData<RadioInputData>>
86
- | GroupedGenericQuestionData<'radio-card', IndexedData<RadioCardInputData>>
87
-
88
- export interface FieldData {
89
- type: 'field'
90
- className?: string
91
- id: string
92
- }
93
-
94
- export interface FieldGroupData {
95
- type: 'field-group'
96
- className?: string
97
- fieldsAndGroups: (FieldData | FieldGroupData)[]
98
- name?: string
99
- inline?: boolean
100
- fullWidth?: boolean
101
- }
102
-
103
- export interface WorkflowPageData {
104
- className?: string
105
- groups?: FieldGroupData[]
106
- highlightMsg?: string
107
- questions: IndexedData<QuestionData>
108
- title?: string
109
- triggers?: string[]
110
- }
111
-
112
- export interface WorkflowData {
113
- createdAt: string
114
- culDeSacs: EntryData[]
115
- id: string
116
- locale?: string
117
- pages: WorkflowPageData[]
118
- summaryImageFieldName?: string // this field is used to show the consult summary image
119
- summarySymptomsFieldName?: string // this field is used to show the consult summary symptoms
120
- selectedAnswers?: SelectedAnswersData
121
- }
122
-
123
- /**
124
- * This interface describes a workflow prepared and ready to be sent to vault
125
- */
126
- export interface WorkflowUploadedImage {
127
- idbId?: string
128
- name: string
129
- imageData?: string
130
- }
131
- export interface PopulatedWorkflowField {
132
- answer: SelectedAnswerData | WorkflowUploadedImage[] // Actual answer from the workflow
133
- displayedAnswer?: any // This answer is to be used only when it's impossible to get data from workflow
134
- kind: string // If we don't store question. We will need that field to at least know the field type
135
- }
136
-
137
- export interface PopulatedWorkflowData {
138
- workflowId: string // The workflow id to refer
139
- workflowCreatedAt: string // The workflow version
140
- locale?: string
141
- fields: Record<string, PopulatedWorkflowField> // key corresponds to the QuestionData key in the workflow
142
- }
@@ -1,77 +0,0 @@
1
- import type { AxiosRequestConfig } from 'axios'
2
- import createAuthRefreshInterceptor from 'axios-auth-refresh'
3
- import { AuthRefreshFunc, Tokens } from '../models'
4
- import { AxiosService } from './axios'
5
- import { GuardRequestConfig } from './guard'
6
-
7
-
8
- export class APIService extends AxiosService {
9
- private authRefreshFn?: AuthRefreshFunc
10
-
11
- constructor(
12
- config?: AxiosRequestConfig,
13
- private tokenRefreshFailureCallback?: (err: Error) => void
14
- ) {
15
- super(config)
16
- const self = this
17
-
18
- this.axios.interceptors.request.use(
19
- config => {
20
- const token = (config as GuardRequestConfig).useRefreshToken
21
- ? self.getTokens().refreshToken
22
- : self.getTokens().accessToken
23
-
24
- config.headers = {
25
- ...config.headers,
26
- Authorization: `Bearer ${token}`,
27
- }
28
- return config;
29
- },
30
- error => {
31
- Promise.reject(error)
32
- }
33
- );
34
-
35
- createAuthRefreshInterceptor(this.axios, async function (failedRequest) {
36
- if (self.authRefreshFn) {
37
- try {
38
- let tokenResp = await self.authRefreshFn(self.getTokens().refreshToken)
39
- self.setTokens({
40
- accessToken: tokenResp.accessToken,
41
- refreshToken: tokenResp.refreshToken
42
- })
43
- failedRequest.response.config.headers['Authorization'] = `Bearer ${self.getTokens().accessToken}`
44
- return Promise.resolve()
45
-
46
- } catch (e) {
47
- console.error('an error occured while refreshing tokens (notifying callback)', e)
48
- if (self.tokenRefreshFailureCallback)
49
- self.tokenRefreshFailureCallback(failedRequest)
50
- return Promise.resolve() // We keep it like that. Otherwise, it seems to break the api service will it is not needed
51
- // return Promise.reject(e)
52
- }
53
- }
54
- console.error('The request could not refresh the token (authRefreshFn was not set)', failedRequest)
55
- return Promise.resolve() // We keep it like that. Otherwise, it seems to break the api service will it is not needed
56
- // return Promise.reject(failedRequest)
57
-
58
- }, { statusCodes: [401, 403] })
59
- }
60
-
61
- public setAuthRefreshFn(fn: AuthRefreshFunc) {
62
- this.authRefreshFn = fn
63
- }
64
-
65
- public setTokens(tokens: Tokens) {
66
- localStorage.setItem('tokens', JSON.stringify(tokens))
67
- }
68
-
69
- public getTokens(): Tokens {
70
- let tokens : Tokens = {}
71
- const item = localStorage.getItem('tokens')
72
- if (item) {
73
- tokens = JSON.parse(item)
74
- }
75
- return tokens
76
- }
77
- }
@@ -1,91 +0,0 @@
1
- import type { AxiosRequestConfig } from 'axios'
2
- import axios, { AxiosInstance } from 'axios'
3
-
4
-
5
- export class AxiosService {
6
- protected axios: AxiosInstance
7
-
8
- constructor(
9
- config?: AxiosRequestConfig
10
- ) {
11
- if (!config) config = {}
12
-
13
- this.axios = axios.create(config)
14
- }
15
-
16
- protected async apiRequest(config: AxiosRequestConfig, url: string, data?: any) {
17
- if (!config.headers) config.headers = {}
18
-
19
- config.headers['Content-Type'] = 'application/json'
20
-
21
- return this.axios({
22
- ...config,
23
- url,
24
- data: data,
25
- }).then((res) => {
26
- return res.data
27
- })
28
- }
29
-
30
- protected async apiRequestHeader(config: AxiosRequestConfig, url: string, headerToRetrieve?: string, data?: any,) {
31
- if (!config.headers) config.headers = {}
32
-
33
- config.headers['Content-Type'] = 'application/json'
34
-
35
- return this.axios({
36
- ...config,
37
- url,
38
- data: data,
39
- }).then((res) => {
40
- if (headerToRetrieve) {
41
- return res.headers[headerToRetrieve] ?? res.headers[headerToRetrieve.toLowerCase()]
42
- }
43
-
44
- return res.headers
45
- })
46
- }
47
-
48
- public get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T> {
49
- return this.apiRequest({ ...config, method: 'get' }, url)
50
- }
51
-
52
- public deleteRequest<T = any>(
53
- url: string,
54
- config?: AxiosRequestConfig
55
- ): Promise<T> {
56
- return this.apiRequest({ ...config, method: 'delete' }, url)
57
- }
58
-
59
- public post<T = any>(
60
- url: string,
61
- data?: any,
62
- config?: AxiosRequestConfig
63
- ): Promise<T> {
64
- return this.apiRequest({ ...config, method: 'post' }, url, data)
65
- }
66
-
67
- public put<T = any>(
68
- url: string,
69
- data: any,
70
- config?: AxiosRequestConfig
71
- ): Promise<T> {
72
- return this.apiRequest({ ...config, method: 'put' }, url, data)
73
- }
74
-
75
- public patch<T = any>(
76
- url: string,
77
- data: any,
78
- config?: AxiosRequestConfig
79
- ): Promise<T> {
80
- return this.apiRequest({ ...config, method: 'patch' }, url, data)
81
- }
82
-
83
- public head<T = any>(
84
- url: string,
85
- config?: AxiosRequestConfig,
86
- headerToRetrieve?: string,
87
- data?: any
88
- ): Promise<T> {
89
- return this.apiRequestHeader({ ...config, method: 'head' }, url, headerToRetrieve, data)
90
- }
91
- }
@@ -1,265 +0,0 @@
1
- import { APIService } from './api'
2
- import {
3
- Uuid,
4
- Consult,
5
- ConsultRequest,
6
- MedicalStatus,
7
- ConsultTransmission,
8
- TransmissionKind,
9
- TransmissionStatus,
10
- } from '../models'
11
- // import FormData from "form-data"
12
-
13
- export class ConsultService {
14
- constructor(private api: APIService, private baseURL: string) {}
15
-
16
- public consultCreate(c: ConsultRequest): Promise<Consult> {
17
- return this.api.post<Consult>(`${this.baseURL}/v1/consults`, c)
18
- }
19
-
20
- /**
21
- * This function returns the number of consults using parameters
22
- * @param uuidPractice the practice uuid
23
- * @param uuidRequester the requester uuid
24
- * @param statusesMedical an array containing MedicalStatus to include
25
- * @param statusesExclude an array containing MedicalStatus to exclude
26
- * @param shortId a shortId matcher (will match all consult with a shortId starting with this `shortId`)
27
- * @param columnToSortTo the list of columns separated by commas, to sort to (in order of sorting)
28
- * @param orderToSortTo the type of sorting to do ('asc' for ascending or 'desc' for descending)
29
- * @param perPage the number of item to retrieve per "page"
30
- * @param indexPage the actual index of the page to retrieve (0 based: 0 is the first items)
31
- * @param filterAssignedDoctor the uuid of the doctor for which to filter with
32
- * @param filterCurrentPractitioner the uuid of the current assistant assigned to filter with
33
- * @param filterIsoLocality the of isoLocality to filter with
34
- * @returns a number of consult
35
- */
36
- public countConsults(
37
- uuidPractice?: Uuid,
38
- uuidRequester?: Uuid,
39
- statusesMedical?: MedicalStatus[],
40
- statusesExclude?: MedicalStatus[],
41
- shortId?: string,
42
- columnToSortTo?: string[],
43
- orderToSortTo?: string[],
44
- perPage?: number,
45
- indexPage?: number,
46
- filterAssignedDoctor?: string,
47
- filterCurrentPractitioner?: string,
48
- filterIsoLocality?: string[]
49
- ): Promise<number> {
50
- return this.api
51
- .head<any>(
52
- `${this.baseURL}/v1/consults`,
53
- {
54
- params: {
55
- uuidPractice,
56
- uuidRequester,
57
- statusesMedical,
58
- statusesExclude,
59
- shortId,
60
- perPage,
61
- page: indexPage,
62
- sortColumns: columnToSortTo,
63
- orderColumns: orderToSortTo,
64
- filterAssignedDoctor,
65
- filterCurrentPractitioner,
66
- filterIsoLocality,
67
- },
68
- },
69
- 'Content-Range'
70
- )
71
- .then((resContentRange) => {
72
- if (
73
- !resContentRange ||
74
- (typeof resContentRange !== 'string' &&
75
- typeof resContentRange !== 'number')
76
- ) {
77
- return 0
78
- }
79
-
80
- if (typeof resContentRange === 'number') {
81
- return resContentRange
82
- }
83
-
84
- return parseInt(resContentRange)
85
- })
86
- }
87
-
88
- /**
89
- * This function get consults using parameters
90
- * @param uuidPractice the practice uuid
91
- * @param uuidRequester the requester uuid
92
- * @param statusesMedical an array containing MedicalStatus to include
93
- * @param statusesExclude an array containing MedicalStatus to exclude
94
- * @param shortId a shortId matcher (will match all consult with a shortId starting with this `shortId`)
95
- * @param columnToSortTo the list of columns separated by commas, to sort to (in order of sorting)
96
- * @param orderToSortTo the type of sorting to do ('asc' for ascending or 'desc' for descending)
97
- * @param perPage the number of item to retrieve per "page"
98
- * @param indexPage the actual index of the page to retrieve (0 based: 0 is the first items)
99
- * @param filterAssignedDoctor the uuid of the doctor for which to filter with
100
- * @param filterCurrentPractitioner the uuid of the current assistant assigned to filter with
101
- * @param filterIsoLocality the of isoLocality to filter with
102
- * @returns a list of consult
103
- */
104
- public getConsults(
105
- uuidPractice?: Uuid,
106
- uuidRequester?: Uuid,
107
- statusesMedical?: MedicalStatus[],
108
- statusesExclude?: MedicalStatus[],
109
- shortId?: string,
110
- columnToSortTo?: string[],
111
- orderToSortTo?: string[],
112
- perPage?: number,
113
- indexPage?: number,
114
- filterAssignedDoctor?: string,
115
- filterCurrentPractitioner?: string,
116
- filterIsoLocality?: string[]
117
- ): Promise<Consult[]> {
118
- return this.api.get<Consult[]>(`${this.baseURL}/v1/consults`, {
119
- params: {
120
- uuidPractice,
121
- uuidRequester,
122
- statusesMedical,
123
- statusesExclude,
124
- shortId,
125
- perPage,
126
- page: indexPage,
127
- sortColumns: columnToSortTo,
128
- orderColumns: orderToSortTo,
129
- filterAssignedDoctor,
130
- filterCurrentPractitioner,
131
- filterIsoLocality,
132
- },
133
- })
134
- }
135
-
136
- public getConsultByUUID(
137
- uuidConsult: Uuid,
138
- uuidPractice?: Uuid
139
- ): Promise<Consult> {
140
- return this.api.get<Consult>(
141
- `${this.baseURL}/v1/consults/${uuidConsult}`,
142
- { params: { uuidPractice } }
143
- )
144
- }
145
-
146
- public updateConsultByUUID(
147
- uuidConsult: Uuid,
148
- consult: {
149
- statusMedical?: MedicalStatus
150
- uuidAssignedDoctor?: Uuid
151
- neverExpires?: boolean
152
- },
153
- uuidPractice?: Uuid,
154
- uuidRequester?: Uuid
155
- ): Promise<Consult> {
156
- return this.api.put<Consult>(
157
- `${this.baseURL}/v1/consults/${uuidConsult}`,
158
- consult,
159
- {
160
- params: {
161
- uuidPractice,
162
- uuidRequester,
163
- },
164
- }
165
- )
166
- }
167
-
168
- public getConsultFaxStatuses(
169
- uuidConsult: string
170
- ): Promise<ConsultTransmission[]> {
171
- return this.api.get<ConsultTransmission[]>(
172
- `${this.baseURL}/v1/consults/${uuidConsult}/transmissions`,
173
- {
174
- params: {
175
- kind: TransmissionKind.Fax,
176
- },
177
- }
178
- )
179
- }
180
-
181
- public postConsultTransmission(
182
- uuidConsult: string,
183
- nameDriver: string = 'Documo',
184
- addressOrPhoneToSendTo?: string,
185
- file?: File,
186
- nameReceiver?: string,
187
- txtTransmissionTitle?: string,
188
- txtTransmissionNotes?: string
189
- // numTry ?: number,
190
- // delay ?: number,
191
- ): Promise<ConsultTransmission> {
192
- let data = new FormData()
193
-
194
- data.append('nameDriverReceiver', nameDriver)
195
- if (addressOrPhoneToSendTo) {
196
- data.append('addressReceiver', addressOrPhoneToSendTo)
197
- }
198
- if (file) {
199
- data.append('file', file)
200
- }
201
- if (nameReceiver) {
202
- data.append('nameReceiver', nameReceiver)
203
- }
204
- if (txtTransmissionTitle) {
205
- data.append('txtTransmissionTitle', txtTransmissionTitle)
206
- }
207
- if (txtTransmissionNotes) {
208
- data.append('txtTransmissionNotes', txtTransmissionNotes)
209
- }
210
-
211
- return this.api.post<ConsultTransmission>(
212
- `${this.baseURL}/v1/consults/${uuidConsult}/transmissions`,
213
- data,
214
- {
215
- headers: { 'Content-Type': 'multipart/form-data;' },
216
- }
217
- )
218
- }
219
-
220
- public postConsultFax(
221
- uuidConsult: string,
222
- addressReceiver: string,
223
- file: File
224
- ): Promise<ConsultTransmission> {
225
- return this.postConsultTransmission(
226
- uuidConsult,
227
- 'Documo',
228
- addressReceiver,
229
- file
230
- )
231
- }
232
-
233
- public postConsultEmail(
234
- uuidConsult: string,
235
- file: File
236
- ): Promise<ConsultTransmission> {
237
- return this.postConsultTransmission(
238
- uuidConsult,
239
- 'Pharmacierge',
240
- undefined,
241
- file
242
- )
243
- }
244
-
245
- public retryConsultFax(
246
- uuidConsult: string,
247
- transmissionId: string
248
- ): Promise<ConsultTransmission> {
249
- return this.api.put<ConsultTransmission>(
250
- `${this.baseURL}/v1/consults/${uuidConsult}/transmissions/${transmissionId}`,
251
- { status: TransmissionStatus.Retrying }
252
- )
253
- }
254
-
255
- public updateConsultTransmissionStatus(
256
- transmissionId: string,
257
- uuidConsult: string,
258
- newStatus: TransmissionStatus
259
- ): Promise<ConsultTransmission> {
260
- return this.api.put<ConsultTransmission>(
261
- `${this.baseURL}/v1/consults/${uuidConsult}/transmissions/${transmissionId}`,
262
- { status: newStatus }
263
- )
264
- }
265
- }