oro-sdk 3.3.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,61 +1,61 @@
1
1
  {
2
- "version": "3.3.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"
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
- "path": "dist/oro-sdk.esm.js",
37
- "limit": "10 KB"
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.39.1",
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(`[SDK: registration] Error while adding to the practitioner's index ${practitioner.uuid}`, err)
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(consult.uuid, consultRequest.isoLanguageRequired, lockboxUuid, workflow, oroClient).catch((err) => {
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,
@@ -185,13 +192,15 @@ export async function registerPatient(
185
192
  await Promise.all([...grantPromises, ...consultIndexPromises])
186
193
 
187
194
  await buildConsultSearchIndex(consult, workflow, oroClient).catch((err) => {
188
- console.error('[SDK: registration] personal information not found or another error occured during search indexing', err)
189
- 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
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
190
200
  errorsThrown.push(err)
191
201
  })
192
202
 
193
- if (errorsThrown.length > 0)
194
- throw errorsThrown
203
+ if (errorsThrown.length > 0) throw errorsThrown
195
204
 
196
205
  // Deem the consultation as ready
197
206
  await oroClient.consultClient.updateConsultByUUID(consult.uuid, {
@@ -416,14 +425,14 @@ export async function extractAndStorePersonalWorkflowData(
416
425
  * @param workflow
417
426
  */
418
427
  export async function extractPersonalInfoFromWorkflowData(workflow: WorkflowData): Promise<{
419
- personalInfoPopulatedWfData: PopulatedWorkflowData,
420
- childPersonalInfoPopulatedWfData: PopulatedWorkflowData,
421
- otherPersonalInfoPopulatedWfData: PopulatedWorkflowData,
428
+ personalInfoPopulatedWfData: PopulatedWorkflowData
429
+ childPersonalInfoPopulatedWfData: PopulatedWorkflowData
430
+ otherPersonalInfoPopulatedWfData: PopulatedWorkflowData
422
431
  }> {
423
432
  return Promise.all([
424
433
  getWorkflowDataByCategory(workflow, MetadataCategory.Personal),
425
434
  getWorkflowDataByCategory(workflow, MetadataCategory.ChildPersonal),
426
- getWorkflowDataByCategory(workflow, MetadataCategory.OtherPersonal)
435
+ getWorkflowDataByCategory(workflow, MetadataCategory.OtherPersonal),
427
436
  ]).then(([personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData]) => {
428
437
  return {
429
438
  personalInfoPopulatedWfData,
@@ -441,17 +450,14 @@ export async function extractPersonalInfoFromWorkflowData(workflow: WorkflowData
441
450
  */
442
451
  export async function buildConsultSearchIndex(consult: Consult, workflow: WorkflowData, oroClient: OroClient) {
443
452
  let terms: Terms = [
444
- <Term> {
453
+ <Term>{
445
454
  kind: 'consult-shortid',
446
- value: consult.shortId
447
- }
455
+ value: consult.shortId,
456
+ },
448
457
  ]
449
458
 
450
- const {
451
- personalInfoPopulatedWfData,
452
- childPersonalInfoPopulatedWfData,
453
- otherPersonalInfoPopulatedWfData
454
- } = await extractPersonalInfoFromWorkflowData(workflow)
459
+ const { personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData } =
460
+ await extractPersonalInfoFromWorkflowData(workflow)
455
461
 
456
462
  const personalInfo = identificationToPersonalInformations(
457
463
  toActualObject(personalInfoPopulatedWfData),
@@ -466,33 +472,42 @@ export async function buildConsultSearchIndex(consult: Consult, workflow: Workfl
466
472
  MetadataCategory.OtherPersonal
467
473
  )
468
474
 
469
- terms.push(<Term>{
470
- kind: 'first-name',
471
- value: personalInfo.firstname,
472
- }, <Term> {
473
- kind: 'last-name',
474
- value: personalInfo.name
475
- })
476
-
477
- if(childPersonalInfo.firstname && childPersonalInfo.name) {
478
- terms.push(<Term>{
475
+ terms.push(
476
+ <Term>{
479
477
  kind: 'first-name',
480
- value: childPersonalInfo.firstname,
481
- }, <Term> {
478
+ value: personalInfo.firstname,
479
+ },
480
+ <Term>{
482
481
  kind: 'last-name',
483
- value: childPersonalInfo.name
484
- })
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
+ )
485
497
  }
486
498
 
487
- if(otherPersonalInfo.firstname && otherPersonalInfo.name) {
488
- terms.push(<Term>{
489
- kind: 'first-name',
490
- value: otherPersonalInfo.firstname,
491
- }, <Term> {
492
- kind: 'last-name',
493
- value: otherPersonalInfo.name
494
- })
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
+ )
495
510
  }
496
511
 
497
512
  await oroClient.searchClient.index(consult.uuid, terms)
498
- }
513
+ }