oro-sdk 3.4.0 → 3.5.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/oro-sdk.cjs.development.js +15 -5
- package/dist/oro-sdk.cjs.development.js.map +1 -1
- package/dist/oro-sdk.cjs.production.min.js +1 -1
- package/dist/oro-sdk.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk.esm.js +15 -5
- package/dist/oro-sdk.esm.js.map +1 -1
- package/package.json +58 -58
- package/src/helpers/patient-registration.ts +65 -51
package/package.json
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
},
|
13
|
-
"scripts": {
|
14
|
-
"link:watch": "npm link && tsdx watch",
|
15
|
-
"link:watch:apis": "npm link oro-sdk-apis && npm link && tsdx watch",
|
16
|
-
"start": "tsdx watch",
|
17
|
-
"build": "tsdx build",
|
18
|
-
"test": "tsdx test",
|
19
|
-
"lint": "tsdx lint",
|
20
|
-
"prepare": "tsdx build",
|
21
|
-
"size": "size-limit",
|
22
|
-
"analyze": "size-limit --why",
|
23
|
-
"package": "tsdx build && npm publish",
|
24
|
-
"pretty": "prettier --config ../../.prettierrc.yaml --write './src/**/*.{ts,js,json,md}' && prettier --write './*.md'"
|
25
|
-
},
|
26
|
-
"name": "oro-sdk",
|
27
|
-
"author": "Antoine Jaouën <antoine@orohealth.me>",
|
28
|
-
"module": "dist/oro-sdk.esm.js",
|
29
|
-
"description": "This package is intended to be run in browser only. It contains everything needed to interact with backend services, especially the vault",
|
30
|
-
"size-limit": [
|
31
|
-
{
|
32
|
-
"path": "dist/oro-sdk.cjs.production.min.js",
|
33
|
-
"limit": "10 KB"
|
2
|
+
"version": "3.5.0",
|
3
|
+
"main": "dist/index.js",
|
4
|
+
"typings": "dist/index.d.ts",
|
5
|
+
"files": [
|
6
|
+
"dist",
|
7
|
+
"src"
|
8
|
+
],
|
9
|
+
"engines": {
|
10
|
+
"node": ">=10",
|
11
|
+
"npm": ">=6.14.13"
|
34
12
|
},
|
35
|
-
{
|
36
|
-
|
37
|
-
|
13
|
+
"scripts": {
|
14
|
+
"link:watch": "npm link && tsdx watch",
|
15
|
+
"link:watch:apis": "npm link oro-sdk-apis && npm link && tsdx watch",
|
16
|
+
"start": "tsdx watch",
|
17
|
+
"build": "tsdx build",
|
18
|
+
"test": "tsdx test",
|
19
|
+
"lint": "tsdx lint",
|
20
|
+
"prepare": "tsdx build",
|
21
|
+
"size": "size-limit",
|
22
|
+
"analyze": "size-limit --why",
|
23
|
+
"package": "tsdx build && npm publish",
|
24
|
+
"pretty": "prettier --config ../../.prettierrc.yaml --write './src/**/*.{ts,js,json,md}' && prettier --write './*.md'"
|
25
|
+
},
|
26
|
+
"name": "oro-sdk",
|
27
|
+
"author": "Antoine Jaouën <antoine@orohealth.me>",
|
28
|
+
"module": "dist/oro-sdk.esm.js",
|
29
|
+
"description": "This package is intended to be run in browser only. It contains everything needed to interact with backend services, especially the vault",
|
30
|
+
"size-limit": [
|
31
|
+
{
|
32
|
+
"path": "dist/oro-sdk.cjs.production.min.js",
|
33
|
+
"limit": "10 KB"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"path": "dist/oro-sdk.esm.js",
|
37
|
+
"limit": "10 KB"
|
38
|
+
}
|
39
|
+
],
|
40
|
+
"devDependencies": {
|
41
|
+
"@size-limit/preset-small-lib": "^4.10.2",
|
42
|
+
"@types/jest": "^27.4.1",
|
43
|
+
"@types/uuid": "^8.3.0",
|
44
|
+
"prettier": "^2.5.1",
|
45
|
+
"prettier-plugin-svelte": "^2.3.0",
|
46
|
+
"size-limit": "^4.10.2",
|
47
|
+
"tsdx": "^0.14.1",
|
48
|
+
"tslib": "^2.2.0",
|
49
|
+
"typescript": "^4.2.4"
|
50
|
+
},
|
51
|
+
"dependencies": {
|
52
|
+
"axios": "^0.21.4",
|
53
|
+
"axios-auth-refresh": "^3.2.1",
|
54
|
+
"form-data": "^4.0.0",
|
55
|
+
"formdata-node": "^4.3.1",
|
56
|
+
"idb-keyval": "^5.0.6",
|
57
|
+
"oro-sdk-apis": "1.40.0",
|
58
|
+
"oro-toolbox": "0.0.6",
|
59
|
+
"uuid": "^8.3.2"
|
38
60
|
}
|
39
|
-
|
40
|
-
"devDependencies": {
|
41
|
-
"@size-limit/preset-small-lib": "^4.10.2",
|
42
|
-
"@types/jest": "^27.4.1",
|
43
|
-
"@types/uuid": "^8.3.0",
|
44
|
-
"prettier": "^2.5.1",
|
45
|
-
"prettier-plugin-svelte": "^2.3.0",
|
46
|
-
"size-limit": "^4.10.2",
|
47
|
-
"tsdx": "^0.14.1",
|
48
|
-
"tslib": "^2.2.0",
|
49
|
-
"typescript": "^4.2.4"
|
50
|
-
},
|
51
|
-
"dependencies": {
|
52
|
-
"axios": "^0.21.4",
|
53
|
-
"axios-auth-refresh": "^3.2.1",
|
54
|
-
"form-data": "^4.0.0",
|
55
|
-
"formdata-node": "^4.3.1",
|
56
|
-
"idb-keyval": "^5.0.6",
|
57
|
-
"oro-sdk-apis": "1.40.0",
|
58
|
-
"oro-toolbox": "0.0.6",
|
59
|
-
"uuid": "^8.3.2"
|
60
|
-
}
|
61
|
-
}
|
61
|
+
}
|
@@ -27,7 +27,7 @@ import {
|
|
27
27
|
identificationToPersonalInformations,
|
28
28
|
OroClient,
|
29
29
|
RegisterPatientOutput,
|
30
|
-
toActualObject
|
30
|
+
toActualObject,
|
31
31
|
} from '..'
|
32
32
|
|
33
33
|
const MAX_RETRIES = 15
|
@@ -95,8 +95,7 @@ export async function registerPatient(
|
|
95
95
|
// Creating lockbox
|
96
96
|
if (!lockboxUuid) lockboxUuid = await getOrCreatePatientLockbox(oroClient)
|
97
97
|
|
98
|
-
if (!identity)
|
99
|
-
identity = await oroClient.guardClient.identityGet(patientUuid)
|
98
|
+
if (!identity) identity = await oroClient.guardClient.identityGet(patientUuid)
|
100
99
|
|
101
100
|
await oroClient.grantLockbox(practitionerAdmin, lockboxUuid).catch((err) => {
|
102
101
|
console.error(`Error while granting lockbox to practitioner admin ${practitionerAdmin}`, err)
|
@@ -131,14 +130,16 @@ export async function registerPatient(
|
|
131
130
|
// the index will identify in which lockbox a consultation resides
|
132
131
|
let consultIndexPromises = practitioners.map(async (practitioner) => {
|
133
132
|
return oroClient.vaultIndexAdd(consultIndex, practitioner.uuid).catch((err) => {
|
134
|
-
console.error(
|
133
|
+
console.error(
|
134
|
+
`[SDK: registration] Error while adding to the practitioner's index ${practitioner.uuid}`,
|
135
|
+
err
|
136
|
+
)
|
135
137
|
// Acceptable to continue as the index can be rebuilt, but we should still retry until the last retry remains
|
136
138
|
if (retry <= 1) return
|
137
139
|
else errorsThrown.push(err)
|
138
140
|
})
|
139
141
|
})
|
140
142
|
|
141
|
-
|
142
143
|
await storeImageAliases(consult.uuid, lockboxUuid, workflow, oroClient).catch((err) => {
|
143
144
|
console.error('[SDK: registration] Some errors happened during image upload', err)
|
144
145
|
// Acceptable to continue as images can be requested during the consultation, but we should still retry until the last retry remains
|
@@ -146,13 +147,19 @@ export async function registerPatient(
|
|
146
147
|
else errorsThrown.push(err)
|
147
148
|
})
|
148
149
|
|
149
|
-
await storePatientData(
|
150
|
+
await storePatientData(
|
151
|
+
consult.uuid,
|
152
|
+
consultRequest.isoLanguageRequired,
|
153
|
+
lockboxUuid,
|
154
|
+
workflow,
|
155
|
+
oroClient
|
156
|
+
).catch((err) => {
|
150
157
|
console.error('[SDK: registration] Some errors happened during patient data upload', err)
|
151
158
|
errorsThrown.push(err)
|
152
159
|
})
|
153
160
|
|
154
161
|
if (masterKey && !identity?.recoveryMasterKey) {
|
155
|
-
// generate and store recovery payload and updates the identity
|
162
|
+
// generate and store recovery payload and updates the identity
|
156
163
|
identity = await oroClient.updateMasterKey(patientUuid, masterKey, lockboxUuid).catch((err) => {
|
157
164
|
console.error(`[SDK: registration] Error while updating master key`, err)
|
158
165
|
/// it's acceptable to continue registration (return old identity)
|
@@ -166,7 +173,7 @@ export async function registerPatient(
|
|
166
173
|
}
|
167
174
|
|
168
175
|
if (recoveryQA && !identity?.recoverySecurityQuestions)
|
169
|
-
// Patient security question recovery threshold is 2 answers and updates the identity
|
176
|
+
// Patient security question recovery threshold is 2 answers and updates the identity
|
170
177
|
identity = await oroClient
|
171
178
|
.updateSecurityQuestions(
|
172
179
|
patientUuid,
|
@@ -184,15 +191,16 @@ export async function registerPatient(
|
|
184
191
|
|
185
192
|
await Promise.all([...grantPromises, ...consultIndexPromises])
|
186
193
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
194
|
+
await buildConsultSearchIndex(consult, workflow, oroClient).catch((err) => {
|
195
|
+
console.error(
|
196
|
+
'[SDK: registration] personal information not found or another error occured during search indexing',
|
197
|
+
err
|
198
|
+
)
|
199
|
+
if (retry <= 1) return // this statement is to avoid failing the registration due to the failure in search indexing the consult, this practically implements a soft retry
|
200
|
+
errorsThrown.push(err)
|
201
|
+
})
|
193
202
|
|
194
|
-
if (errorsThrown.length > 0)
|
195
|
-
throw errorsThrown
|
203
|
+
if (errorsThrown.length > 0) throw errorsThrown
|
196
204
|
|
197
205
|
// Deem the consultation as ready
|
198
206
|
await oroClient.consultClient.updateConsultByUUID(consult.uuid, {
|
@@ -417,14 +425,14 @@ export async function extractAndStorePersonalWorkflowData(
|
|
417
425
|
* @param workflow
|
418
426
|
*/
|
419
427
|
export async function extractPersonalInfoFromWorkflowData(workflow: WorkflowData): Promise<{
|
420
|
-
personalInfoPopulatedWfData: PopulatedWorkflowData
|
421
|
-
childPersonalInfoPopulatedWfData: PopulatedWorkflowData
|
422
|
-
otherPersonalInfoPopulatedWfData: PopulatedWorkflowData
|
428
|
+
personalInfoPopulatedWfData: PopulatedWorkflowData
|
429
|
+
childPersonalInfoPopulatedWfData: PopulatedWorkflowData
|
430
|
+
otherPersonalInfoPopulatedWfData: PopulatedWorkflowData
|
423
431
|
}> {
|
424
432
|
return Promise.all([
|
425
433
|
getWorkflowDataByCategory(workflow, MetadataCategory.Personal),
|
426
434
|
getWorkflowDataByCategory(workflow, MetadataCategory.ChildPersonal),
|
427
|
-
getWorkflowDataByCategory(workflow, MetadataCategory.OtherPersonal)
|
435
|
+
getWorkflowDataByCategory(workflow, MetadataCategory.OtherPersonal),
|
428
436
|
]).then(([personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData]) => {
|
429
437
|
return {
|
430
438
|
personalInfoPopulatedWfData,
|
@@ -442,17 +450,14 @@ export async function extractPersonalInfoFromWorkflowData(workflow: WorkflowData
|
|
442
450
|
*/
|
443
451
|
export async function buildConsultSearchIndex(consult: Consult, workflow: WorkflowData, oroClient: OroClient) {
|
444
452
|
let terms: Terms = [
|
445
|
-
<Term>
|
453
|
+
<Term>{
|
446
454
|
kind: 'consult-shortid',
|
447
|
-
value: consult.shortId
|
448
|
-
}
|
455
|
+
value: consult.shortId,
|
456
|
+
},
|
449
457
|
]
|
450
458
|
|
451
|
-
const {
|
452
|
-
|
453
|
-
childPersonalInfoPopulatedWfData,
|
454
|
-
otherPersonalInfoPopulatedWfData
|
455
|
-
} = await extractPersonalInfoFromWorkflowData(workflow)
|
459
|
+
const { personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData } =
|
460
|
+
await extractPersonalInfoFromWorkflowData(workflow)
|
456
461
|
|
457
462
|
const personalInfo = identificationToPersonalInformations(
|
458
463
|
toActualObject(personalInfoPopulatedWfData),
|
@@ -467,33 +472,42 @@ export async function buildConsultSearchIndex(consult: Consult, workflow: Workfl
|
|
467
472
|
MetadataCategory.OtherPersonal
|
468
473
|
)
|
469
474
|
|
470
|
-
terms.push(
|
471
|
-
|
472
|
-
value: personalInfo.firstname,
|
473
|
-
}, <Term> {
|
474
|
-
kind: 'last-name',
|
475
|
-
value: personalInfo.name
|
476
|
-
})
|
477
|
-
|
478
|
-
if(childPersonalInfo.firstname && childPersonalInfo.name) {
|
479
|
-
terms.push(<Term>{
|
475
|
+
terms.push(
|
476
|
+
<Term>{
|
480
477
|
kind: 'first-name',
|
481
|
-
value:
|
482
|
-
},
|
478
|
+
value: personalInfo.firstname,
|
479
|
+
},
|
480
|
+
<Term>{
|
483
481
|
kind: 'last-name',
|
484
|
-
value:
|
485
|
-
}
|
482
|
+
value: personalInfo.name,
|
483
|
+
}
|
484
|
+
)
|
485
|
+
|
486
|
+
if (childPersonalInfo.firstname && childPersonalInfo.name) {
|
487
|
+
terms.push(
|
488
|
+
<Term>{
|
489
|
+
kind: 'first-name',
|
490
|
+
value: childPersonalInfo.firstname,
|
491
|
+
},
|
492
|
+
<Term>{
|
493
|
+
kind: 'last-name',
|
494
|
+
value: childPersonalInfo.name,
|
495
|
+
}
|
496
|
+
)
|
486
497
|
}
|
487
498
|
|
488
|
-
if(otherPersonalInfo.firstname && otherPersonalInfo.name) {
|
489
|
-
terms.push(
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
499
|
+
if (otherPersonalInfo.firstname && otherPersonalInfo.name) {
|
500
|
+
terms.push(
|
501
|
+
<Term>{
|
502
|
+
kind: 'first-name',
|
503
|
+
value: otherPersonalInfo.firstname,
|
504
|
+
},
|
505
|
+
<Term>{
|
506
|
+
kind: 'last-name',
|
507
|
+
value: otherPersonalInfo.name,
|
508
|
+
}
|
509
|
+
)
|
496
510
|
}
|
497
511
|
|
498
512
|
await oroClient.searchClient.index(consult.uuid, terms)
|
499
|
-
}
|
513
|
+
}
|