oro-sdk 2.1.4-dev1.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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/dist/client.d.ts +464 -0
  4. package/dist/helpers/client.d.ts +23 -0
  5. package/dist/helpers/index.d.ts +4 -0
  6. package/dist/helpers/patient-registration.d.ts +16 -0
  7. package/dist/helpers/vault-grants.d.ts +20 -0
  8. package/dist/helpers/workflow.d.ts +23 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +8 -0
  11. package/dist/models/client.d.ts +28 -0
  12. package/dist/models/consult.d.ts +102 -0
  13. package/dist/models/diagnosis.d.ts +122 -0
  14. package/dist/models/error.d.ts +26 -0
  15. package/dist/models/guard.d.ts +119 -0
  16. package/dist/models/index.d.ts +9 -0
  17. package/dist/models/practice.d.ts +353 -0
  18. package/dist/models/shared.d.ts +8 -0
  19. package/dist/models/vault.d.ts +124 -0
  20. package/dist/models/workflow.d.ts +106 -0
  21. package/dist/oro-sdk.cjs.development.js +7685 -0
  22. package/dist/oro-sdk.cjs.development.js.map +1 -0
  23. package/dist/oro-sdk.cjs.production.min.js +2 -0
  24. package/dist/oro-sdk.cjs.production.min.js.map +1 -0
  25. package/dist/oro-sdk.esm.js +7692 -0
  26. package/dist/oro-sdk.esm.js.map +1 -0
  27. package/dist/sdk-revision/client.d.ts +21 -0
  28. package/dist/sdk-revision/index.d.ts +1 -0
  29. package/dist/services/api.d.ts +11 -0
  30. package/dist/services/axios.d.ts +14 -0
  31. package/dist/services/consult.d.ts +54 -0
  32. package/dist/services/diagnosis.d.ts +44 -0
  33. package/dist/services/external/clinia.d.ts +82 -0
  34. package/dist/services/external/index.d.ts +1 -0
  35. package/dist/services/guard.d.ts +92 -0
  36. package/dist/services/index.d.ts +10 -0
  37. package/dist/services/practice.d.ts +100 -0
  38. package/dist/services/teller.d.ts +9 -0
  39. package/dist/services/vault.d.ts +54 -0
  40. package/dist/services/workflow.d.ts +21 -0
  41. package/package.json +63 -0
  42. package/src/client.ts +1843 -0
  43. package/src/helpers/client.ts +199 -0
  44. package/src/helpers/index.ts +4 -0
  45. package/src/helpers/patient-registration.ts +490 -0
  46. package/src/helpers/vault-grants.ts +51 -0
  47. package/src/helpers/workflow.ts +261 -0
  48. package/src/index.ts +61 -0
  49. package/src/models/client.ts +33 -0
  50. package/src/models/consult.ts +110 -0
  51. package/src/models/diagnosis.ts +141 -0
  52. package/src/models/error.ts +13 -0
  53. package/src/models/guard.ts +136 -0
  54. package/src/models/index.ts +9 -0
  55. package/src/models/practice.ts +411 -0
  56. package/src/models/shared.ts +6 -0
  57. package/src/models/vault.ts +158 -0
  58. package/src/models/workflow.ts +142 -0
  59. package/src/sdk-revision/client.ts +62 -0
  60. package/src/sdk-revision/index.ts +1 -0
  61. package/src/services/api.ts +77 -0
  62. package/src/services/axios.ts +91 -0
  63. package/src/services/consult.ts +265 -0
  64. package/src/services/diagnosis.ts +144 -0
  65. package/src/services/external/clinia.ts +133 -0
  66. package/src/services/external/index.ts +1 -0
  67. package/src/services/guard.ts +228 -0
  68. package/src/services/index.ts +10 -0
  69. package/src/services/practice.ts +537 -0
  70. package/src/services/teller.ts +39 -0
  71. package/src/services/vault.ts +178 -0
  72. package/src/services/workflow.ts +36 -0
@@ -0,0 +1,51 @@
1
+ import { CryptoRSA, uuidParse} from "oro-toolbox"
2
+ import { EncryptedIndexEntry, Grant, IndexConsultLockbox } from ".."
3
+
4
+ /**
5
+ * Decrypts and returns the encrypted grants
6
+ * If something went wrong during decryption, that grant will be removed from the list
7
+ *
8
+ * @param encryptedGrants: an array of encrypted grants
9
+ * @param rsaKey: the rsa key used to decrypt the encrypted grants
10
+ * @returns an array of grants
11
+ */
12
+ export function decryptGrants(encryptedGrants: Grant[], rsaKey: CryptoRSA): Grant[] {
13
+ return encryptedGrants
14
+ .map(grant => {
15
+ if (grant.encryptedLockbox && !grant.lockboxUuid) {
16
+ try {
17
+ grant.lockboxUuid = uuidParse(
18
+ rsaKey.base64DecryptToBytes(grant.encryptedLockbox)
19
+ )
20
+ } catch (e) {
21
+ console.error('[sdk:index] The grant could not be decrypted or was not a valid UUID: ', e)
22
+ }
23
+ }
24
+ return grant
25
+ })
26
+ .filter(grant => grant.lockboxUuid)
27
+ }
28
+
29
+ /**
30
+ * Decrypts the encrypted consult lockboxes and returns their grants
31
+ * If something went wrong during decryption, that grant will be removed from the list
32
+ *
33
+ * @param encryptedConsultLockboxes: an array of encrypted entries
34
+ * @param rsaKey: the rsa key used to decrypt the encrypted entries
35
+ * @returns an array of grants
36
+ */
37
+ export function decryptConsultLockboxGrants(encryptedConsultLockboxes: EncryptedIndexEntry[], rsaKey: CryptoRSA): Grant[] {
38
+ return encryptedConsultLockboxes
39
+ .map(encryptedConsultLockboxes => {
40
+ try {
41
+ return [true, (rsaKey.base64DecryptToJson(
42
+ encryptedConsultLockboxes.encryptedIndexEntry
43
+ ) as IndexConsultLockbox).grant]
44
+ } catch(e) {
45
+ console.error('[sdk:index] The consult lockbox grant could not be decrypted: ', e)
46
+ return [false, undefined] // if decryption fails, we want to ignore the grant but not fail the call
47
+ }
48
+ })
49
+ .filter(grantsTuple => grantsTuple[0])
50
+ .map(grantTuples => grantTuples[1] as Grant)
51
+ }
@@ -0,0 +1,261 @@
1
+ import { getMany } from 'idb-keyval'
2
+ import {
3
+ MetadataCategory,
4
+ PopulatedWorkflowData,
5
+ PopulatedWorkflowField,
6
+ QuestionData,
7
+ SelectedAnswerData,
8
+ SelectedAnswersData,
9
+ WorkflowAnswersMissingError,
10
+ WorkflowData,
11
+ WorkflowPageData,
12
+ WorkflowUploadedImage,
13
+ } from '../models'
14
+
15
+ export async function filterTriggeredAnsweredWithKind(
16
+ workflowData: WorkflowData,
17
+ kind:
18
+ | 'text'
19
+ | 'date'
20
+ | 'number'
21
+ | 'images'
22
+ | 'images-alias'
23
+ | 'body-parts'
24
+ | 'pharmacy-picker'
25
+ ): Promise<SelectedAnswerData[]> {
26
+ if (!workflowData.selectedAnswers) throw WorkflowAnswersMissingError
27
+
28
+ // Flattens the list of answered questions
29
+ let flattenedAnswers = flattenSelectedAnswers(workflowData.selectedAnswers)
30
+ // Generates a list of applicable questions
31
+ let triggeredQuestionsWithKind = Object.fromEntries(
32
+ workflowData.pages
33
+ .map((a) => {
34
+ return Object.entries(a.questions).filter(
35
+ ([_, question]) =>
36
+ isTriggered(
37
+ question.triggers || [],
38
+ flattenedAnswers
39
+ ) && question.kind === kind
40
+ )
41
+ })
42
+ .flat()
43
+ )
44
+
45
+ const samePageAnswers = workflowData.selectedAnswers.reduce((prev, cur) => {
46
+ return { ...prev, ...cur }
47
+ }, {})
48
+
49
+ const res = Object.keys(triggeredQuestionsWithKind).map(
50
+ (questionFieldName) => {
51
+ return samePageAnswers[questionFieldName]
52
+ }
53
+ )
54
+
55
+ return res
56
+ }
57
+
58
+ /**
59
+ * Filters and Populates the `selectedAnswers` from the workflow by
60
+ * Cross-referencing the `MetaCategory` of the answer's respective question
61
+ * Populates the fields labels and values that are of radio, dropdown and checkbox types
62
+ *
63
+ * @param workflowData
64
+ * @param category
65
+ * @returns An array of record key, value pairs
66
+ */
67
+ export async function getWorkflowDataByCategory(
68
+ workflowData: WorkflowData,
69
+ category: MetadataCategory
70
+ ): Promise<PopulatedWorkflowData> {
71
+ if (!workflowData.selectedAnswers) throw WorkflowAnswersMissingError
72
+
73
+ // Flattens the list of answered questions
74
+ let flattenedAnswers = flattenSelectedAnswers(workflowData.selectedAnswers)
75
+ // Generates a list of applicable questions
76
+ let triggeredQuestions = Object.fromEntries(
77
+ workflowData.pages
78
+ .map((a) => {
79
+ return Object.entries(a.questions).filter(([_, question]) =>
80
+ isTriggered(question.triggers || [], flattenedAnswers)
81
+ )
82
+ })
83
+ .flat()
84
+ )
85
+
86
+ const fields: Record<string, PopulatedWorkflowField> = {}
87
+
88
+ // Generates the answers of the specified category and adds the appropriate values if any are missing
89
+ return Promise.all(
90
+ workflowData.selectedAnswers
91
+ .map((e) => Object.entries(e))
92
+ .flat()
93
+ .filter(
94
+ ([k, v]) =>
95
+ triggeredQuestions[k] &&
96
+ triggeredQuestions[k]['metaCategory'] === category
97
+ )
98
+ .map(([k, v]) => {
99
+ return populateWorkflowField(triggeredQuestions[k], v).then(
100
+ (populatedValue) => {
101
+ fields[k] = populatedValue
102
+ }
103
+ )
104
+ })
105
+ )
106
+ .then(() => {
107
+ const ret: PopulatedWorkflowData = {
108
+ workflowCreatedAt: workflowData.createdAt,
109
+ workflowId: workflowData.id,
110
+ locale: workflowData.locale,
111
+ fields,
112
+ }
113
+ return ret
114
+ })
115
+ .catch((err) => {
116
+ console.error(
117
+ `Error while extracting ${category} data from workflow`,
118
+ err
119
+ )
120
+ throw err
121
+ })
122
+ }
123
+
124
+ export async function getImagesFromIndexDb(
125
+ answer: SelectedAnswerData
126
+ ): Promise<WorkflowUploadedImage[]> {
127
+ return await getMany<WorkflowUploadedImage>(
128
+ (answer as any[]).map((v) => v.id ?? v) as string[]
129
+ )
130
+ }
131
+
132
+ /**
133
+ * (If applicable) Based on the question kind, and the answer type this function will add and replace the appropriate fields to the
134
+ * field values if they are radio, dropdown and checkbox fields
135
+ *
136
+ *
137
+ * @param question
138
+ * @param answerValue
139
+ * @returns
140
+ */
141
+ async function populateWorkflowField(
142
+ question: QuestionData,
143
+ answerValue: SelectedAnswerData
144
+ ): Promise<PopulatedWorkflowField> {
145
+ let answer: any
146
+ let displayedAnswer: string | string[] | undefined = undefined
147
+
148
+ switch (question.kind) {
149
+ case 'radio':
150
+ case 'radio-card':
151
+ case 'select':
152
+ if (question.answers) {
153
+ displayedAnswer = question.answers[answerValue as string].text
154
+ }
155
+
156
+ answer = answerValue
157
+ break
158
+ case 'multiple':
159
+ case 'checkbox-group':
160
+ displayedAnswer = (answerValue as string[]).map((value) => {
161
+ if (question.answers) {
162
+ return question.answers[value].text
163
+ }
164
+
165
+ throw new WorkflowAnswersMissingError()
166
+ })
167
+
168
+ answer = answerValue
169
+ break
170
+ case 'images':
171
+ answer = await getImagesFromIndexDb(answerValue).then((images) =>
172
+ images.map((image) => {
173
+ const { name, imageData } = image
174
+
175
+ return { name, imageData }
176
+ })
177
+ )
178
+ break
179
+ default:
180
+ answer = answerValue
181
+ }
182
+
183
+ return Promise.resolve({
184
+ answer,
185
+ displayedAnswer,
186
+ kind: question.kind,
187
+ })
188
+ }
189
+
190
+ export function isTriggered(triggers: string[], answers: string[]): boolean {
191
+ for (let trigger of triggers) {
192
+ if (!answers.includes(trigger)) {
193
+ return false
194
+ }
195
+ }
196
+ return true
197
+ }
198
+
199
+ export function flattenSelectedAnswers(answers: SelectedAnswersData) {
200
+ const linearAnswers: SelectedAnswerData[] = []
201
+
202
+ for (const answer of answers) {
203
+ linearAnswers.push(...Object.values(answer))
204
+ }
205
+
206
+ return linearAnswers.flat(1)
207
+ }
208
+
209
+ /**
210
+ * This function helps you to get a valid workflow selectedAnswers structure
211
+ * @param workflow the workflow data to use to initialize selectedAnswers
212
+ * @param useDefault use workflow default values or not (this is used to avoid having unset values to appear in summaries)
213
+ * @returns a valid selectedAnswers structure
214
+ */
215
+ export function getInitialisedSelectedAnswers(
216
+ workflow: WorkflowData,
217
+ useDefault: boolean = true
218
+ ) {
219
+ return workflow.pages.map((page) => {
220
+ const ret: any = {}
221
+ for (const [id, question] of Object.entries(page.questions)) {
222
+ if (question.kind === 'body-parts') {
223
+ ret[id] = useDefault ? [] : undefined
224
+ } else {
225
+ ret[id] =
226
+ useDefault && question.defaultValue
227
+ ? question.defaultValue
228
+ : undefined
229
+ }
230
+ }
231
+ return ret
232
+ })
233
+ }
234
+
235
+ export function fillWorkflowFromPopulatedWorkflow(
236
+ workflow: WorkflowData,
237
+ populatedWorkflow: PopulatedWorkflowData
238
+ ) {
239
+ const filledWorkflow = JSON.parse(JSON.stringify(workflow))
240
+
241
+ if (!filledWorkflow.selectedAnswers) {
242
+ filledWorkflow.selectedAnswers = getInitialisedSelectedAnswers(
243
+ filledWorkflow,
244
+ false
245
+ )
246
+ }
247
+
248
+ filledWorkflow.pages.forEach((page: WorkflowPageData, pageIdx: number) => {
249
+ const ret: any = {}
250
+ for (const [id] of Object.entries(page.questions)) {
251
+ if (populatedWorkflow.fields[id]) {
252
+ if (filledWorkflow.selectedAnswers)
253
+ filledWorkflow.selectedAnswers[pageIdx][
254
+ id
255
+ ] = populatedWorkflow.fields[id].answer as string | string[]
256
+ }
257
+ }
258
+ })
259
+
260
+ return filledWorkflow
261
+ }
package/src/index.ts ADDED
@@ -0,0 +1,61 @@
1
+ import {
2
+ APIService,
3
+ TellerService,
4
+ VaultService,
5
+ GuardService,
6
+ PracticeService,
7
+ ConsultService,
8
+ WorkflowService,
9
+ DiagnosisService,
10
+ } from './services'
11
+ import { OroClient } from './client'
12
+ import * as OroToolboxNamespace from 'oro-toolbox'
13
+
14
+ export type OroToolbox = typeof OroToolboxNamespace
15
+
16
+ export let wasmPath = 'node_modules/oro-toolbox'
17
+
18
+ const init = (
19
+ toolbox: OroToolbox,
20
+ tellerBaseURL: string,
21
+ vaultBaseURL: string,
22
+ guardBaseURL: string,
23
+ practiceBaseURL: string,
24
+ consultBaseURL: string,
25
+ workflowBaseURL: string,
26
+ diagnosisBaseUrl: string,
27
+ authenticationCallback?: (err: Error) => void,
28
+ ) => {
29
+ const apiService = new APIService(undefined, authenticationCallback)
30
+ const tellerService = new TellerService(apiService, tellerBaseURL)
31
+ const practiceService = new PracticeService(
32
+ toolbox,
33
+ apiService,
34
+ practiceBaseURL
35
+ )
36
+ const consultService = new ConsultService(apiService, consultBaseURL)
37
+ const vaultService = new VaultService(apiService, vaultBaseURL)
38
+ const guardService = new GuardService(apiService, guardBaseURL)
39
+ const workflowService = new WorkflowService(apiService, workflowBaseURL)
40
+ const diagnosisService = new DiagnosisService(apiService, diagnosisBaseUrl)
41
+ const client = new OroClient(
42
+ toolbox,
43
+ tellerService,
44
+ vaultService,
45
+ guardService,
46
+ practiceService,
47
+ consultService,
48
+ workflowService,
49
+ diagnosisService,
50
+ authenticationCallback
51
+ )
52
+
53
+ return client
54
+ }
55
+
56
+ export { OroClient } from './client'
57
+ export * from './models'
58
+ export * from './helpers'
59
+ export * from './services'
60
+ export { OroToolboxNamespace }
61
+ export default init
@@ -0,0 +1,33 @@
1
+ import { PlaceData } from '../services/external/clinia'
2
+ import { Uuid } from './shared'
3
+
4
+ export interface PersonalInformations {
5
+ birthday?: string
6
+ firstname?: string
7
+ gender?: string
8
+ name?: string
9
+ phone?: string
10
+ zip?: string
11
+ hid?: string // Social Insurance Number
12
+ pharmacy?: PlaceData
13
+ address?: string
14
+ }
15
+
16
+ export interface UserPreference {
17
+ isoLanguage: string // Should comply to ISO 639-3 https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
18
+ }
19
+
20
+ export interface RegisterPatientOutput {
21
+ masterKey?: Uuid
22
+ consultationId: Uuid
23
+ lockboxUuid: Uuid
24
+ }
25
+
26
+ export interface RecoveryData {
27
+ masterKey: string // The master key used to decrypt the recoveryMasterKey from IdentityResponse
28
+ }
29
+
30
+ export interface LocalEncryptedData {
31
+ encryptedKey: string
32
+ encryptedData: string
33
+ }
@@ -0,0 +1,110 @@
1
+ export enum AssistantType {
2
+ MedicalSecretary = 'MedicalSecretary',
3
+ Nurse = 'Nurse',
4
+ Specialist = 'Specialist',
5
+ Administrative = 'Administrative',
6
+ Other = 'Other',
7
+ }
8
+
9
+ export interface ConsultAssignedAssistant {
10
+ id?: number ///optional for insertion
11
+ uuidConsult: string
12
+ uuidAssistant: string
13
+ type: AssistantType
14
+ tagSpecialty?: string
15
+ duuidCurrentTaskDescription?: string
16
+ }
17
+
18
+ export enum TransmissionKind {
19
+ Fax = 'Fax',
20
+ Email = 'Email',
21
+ SMS = 'SMS',
22
+ EncryptedEmail = 'EncryptedEmail',
23
+ Logs = 'Logs',
24
+ API = 'API',
25
+ Other = 'Other',
26
+ }
27
+
28
+ export enum TransmissionStatus {
29
+ Preparing = 'Preparing',
30
+ Sending = 'Sending',
31
+ Sent = 'Sent',
32
+ Retrying = 'Retrying',
33
+ Failed = 'Failed',
34
+ DriverError = 'DriverError',
35
+ TimedOut = 'TimedOut',
36
+ ReceiverNotExist = 'ReceiverNotExist',
37
+ ReceiverNotAnswering = 'ReceiverNotAnswering',
38
+ ReceiverIncompatible = 'ReceiverIncompatible',
39
+ }
40
+
41
+ export interface ConsultTransmission {
42
+ id: number
43
+ uuidConsult: string
44
+ kind: TransmissionKind
45
+ status: TransmissionStatus
46
+ nameDriverReceiver: string
47
+ addressReceiver: string
48
+ idDriverForTransmission: string
49
+ txtLastDriverMessage: string
50
+ numTry: number
51
+ numTryLeft: number
52
+ delay: number
53
+ tsFirstTry: string
54
+ tsLastStatusUpdate: string
55
+ keyWebhookSecret: string
56
+ }
57
+
58
+ export enum FeeStatus {
59
+ NoFee = 'NoFee',
60
+ Pending = 'Pending',
61
+ Paid = 'Paid',
62
+ Reimbursed = 'Reimbursed',
63
+ Cancelled = 'Cancelled',
64
+ Contested = 'Contested',
65
+ }
66
+
67
+ export enum MedicalStatus {
68
+ Creating = 'Creating',
69
+ New = 'New',
70
+ ToAnswer = 'ToAnswer',
71
+ Answered = 'Answered',
72
+ Closed = 'Closed',
73
+ Reopened = 'Reopened',
74
+ Archived = 'Archived',
75
+ }
76
+
77
+ export enum TaskStatus {
78
+ None = 'None',
79
+ ToDo = 'ToDo',
80
+ InProgress = 'InProgress',
81
+ Blocked = 'Blocked',
82
+ Done = 'Done',
83
+ }
84
+
85
+ export interface ConsultRequest {
86
+ uuidPractice: string
87
+ tagSpecialtyRequired: string
88
+ idStripeInvoiceOrPaymentIntent: string
89
+ isoLocalityRequired?: string
90
+ isoLanguageRequired: string
91
+ }
92
+ export interface Consult {
93
+ uuid: string
94
+ uuidPracticeAdmin: string
95
+ uuidPractice: string
96
+ tagSpecialtyRequired: string
97
+ isoLanguageRequired: string
98
+ idPracticePayment: number
99
+ statusFee?: FeeStatus
100
+ isoLocalityRequired: string
101
+ statusMedical?: MedicalStatus
102
+ uuidAssignedDoctor: string
103
+ uuidCurrentAssigned: string
104
+ statusTask?: TaskStatus
105
+ hasTransmissions?: boolean
106
+ assignedAssistant?: ConsultAssignedAssistant[]
107
+ shortId?: string
108
+ createdAt?: string
109
+ expiresAt?: string
110
+ }
@@ -0,0 +1,141 @@
1
+ export enum DiagnosisType {
2
+ Generic = 'Generic',
3
+ Private = 'Private',
4
+ Instance = 'Instance',
5
+ }
6
+
7
+ export interface DiagnosisRequest {
8
+ uuid?: string
9
+ name: string
10
+ description: string
11
+ type: DiagnosisType
12
+ parentUuid?: string
13
+ language: string
14
+ tags?: string[]
15
+ urlMultimedia?: string
16
+ }
17
+
18
+ export interface Diagnosis extends DiagnosisRequest {
19
+ uuid: string
20
+ uuidPractice: string
21
+ uuidPractitioner?: string
22
+ createdAt: string
23
+ }
24
+
25
+ export interface TreatmentRequest {
26
+ uuid?: string
27
+ uuidDiagnosis?: string
28
+ name: string
29
+ description: string
30
+ urlMultimedia?: string
31
+ }
32
+
33
+ export interface Treatment extends TreatmentRequest {
34
+ uuid: string
35
+ uuidDiagnosis: string
36
+ createdAt: string
37
+ }
38
+
39
+ export enum DrugType {
40
+ Generic = 'Generic',
41
+ Instance = 'Instance',
42
+ }
43
+
44
+ export interface DrugRequest {
45
+ name: string // name of the drug
46
+ description: string // Description of the drug
47
+ type: DrugType // Entry type
48
+ language: string // drug locale
49
+ sideEffects: string // Side effects of the drug
50
+ imageUrl?: string // Image URL to the drug
51
+ parentUuid?: string // (optional) parent uuid of the drug. In case of DrugType.Instance
52
+ uuid?: string // uuid of the drug (will be used as parentUuid in case of creation of new drug)
53
+ }
54
+
55
+ export interface Drug extends DrugRequest {
56
+ uuid: string
57
+ uuidPractice: string
58
+ uuidPractitioner?: string
59
+ createdAt: string
60
+ }
61
+
62
+ export interface PrescriptionRequest {
63
+ uuid?: string
64
+ uuidTreatment?: string
65
+ uuidDrug?: string
66
+ quantity: string
67
+ sig: string
68
+ renewal: string
69
+ }
70
+
71
+ export interface Prescription extends PrescriptionRequest {
72
+ uuid: string
73
+ uuidTreatment: string
74
+ createdAt: string
75
+ }
76
+
77
+ export enum PlanStatus {
78
+ Pending = 'Pending',
79
+ Accepted = 'Accepted',
80
+ Rejected = 'Rejected',
81
+ }
82
+
83
+ export interface TreatmentPlan {
84
+ uuid: string
85
+ uuidConsult: string
86
+ uuidDiagnosis: string
87
+ uuidTreatment?: string
88
+ status: PlanStatus
89
+ }
90
+
91
+ export interface DrugPrescription {
92
+ prescription: Prescription
93
+ drug: Drug
94
+ }
95
+
96
+ export interface TreatmentAndDrugPrescription {
97
+ treatment?: Treatment
98
+ prescriptionsAndDrugs?: DrugPrescription[]
99
+ status: PlanStatus
100
+ uuidTreatmentPlan: string
101
+ }
102
+ export interface TreatmentPlans {
103
+ uuidConsult: string
104
+ diagnosis: Diagnosis
105
+ plans?: TreatmentAndDrugPrescription[]
106
+ }
107
+
108
+ export interface DrugPrescriptionRequest {
109
+ prescription: PrescriptionRequest
110
+ drug: DrugRequest
111
+ }
112
+
113
+ export interface TreatmentAndDrugPrescriptionRequest {
114
+ trackingId: string
115
+ treatment: TreatmentRequest
116
+ prescriptionsAndDrugs?: DrugPrescriptionRequest[]
117
+ }
118
+
119
+ export interface TreatmentPlansRequest {
120
+ uuidConsult: string
121
+ diagnosis: DiagnosisRequest
122
+ plans?: TreatmentAndDrugPrescriptionRequest[]
123
+ }
124
+
125
+ export interface TreatmentAndDrugPrescriptionUpdateRequest {
126
+ treatment: Treatment
127
+ prescriptionsAndDrugs?: DrugPrescriptionRequest[]
128
+ }
129
+
130
+ export interface TreatmentPlanUpdateRequest extends TreatmentPlansRequest {
131
+ uuidConsult: string
132
+ diagnosis: DiagnosisRequest
133
+ plan: TreatmentAndDrugPrescriptionUpdateRequest
134
+ }
135
+
136
+ export interface TreatmentPlansResponseEntry {
137
+ trackingId?: string // can be undefined if treatmentPlan does not contain a treatment
138
+ treatmentPlan: TreatmentPlan
139
+ }
140
+
141
+ export interface TreatmentPlansResponse extends Array<TreatmentPlansResponseEntry> {}
@@ -0,0 +1,13 @@
1
+ export class IncompleteAuthentication extends Error { }
2
+ export class MissingGrant extends Error { }
3
+ export class MissingLockbox extends Error { }
4
+ export class MissingLockboxOwner extends Error { }
5
+ export class IndexBuildError extends Error { }
6
+ export class AssociatedLockboxNotFound extends Error { }
7
+ export class WorkflowAnswersMissingError extends Error { }
8
+ export class AuthenticationFailed extends Error { }
9
+ export class AuthenticationBadRequest extends Error { }
10
+ export class AuthenticationServerError extends Error { }
11
+ export class IdentityCreationFailed extends Error { }
12
+ export class IdentityCreationBadRequest extends Error { }
13
+ export class IdentityCreationConflict extends Error { }