oro-sdk 3.1.2-dev2.1 → 3.3.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/helpers/patient-registration.d.ts +16 -7
- package/dist/oro-sdk.cjs.development.js +59 -76
- 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 +58 -75
- package/dist/oro-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/patient-registration.ts +61 -90
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "3.
|
2
|
+
"version": "3.3.0",
|
3
3
|
"main": "dist/index.js",
|
4
4
|
"typings": "dist/index.d.ts",
|
5
5
|
"files": [
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"form-data": "^4.0.0",
|
55
55
|
"formdata-node": "^4.3.1",
|
56
56
|
"idb-keyval": "^5.0.6",
|
57
|
-
"oro-sdk-apis": "1.
|
57
|
+
"oro-sdk-apis": "1.39.1",
|
58
58
|
"oro-toolbox": "0.0.6",
|
59
59
|
"uuid": "^8.3.2"
|
60
60
|
}
|
@@ -5,14 +5,17 @@ import {
|
|
5
5
|
ConsultRequest,
|
6
6
|
DocumentType,
|
7
7
|
IdentityResponse,
|
8
|
-
IndexKey,
|
8
|
+
IndexKey,
|
9
9
|
MedicalMeta,
|
10
10
|
MedicalStatus,
|
11
11
|
MetadataCategory,
|
12
|
-
PersonalMeta,
|
12
|
+
PersonalMeta,
|
13
|
+
PopulatedWorkflowData,
|
13
14
|
Practitioner,
|
14
15
|
PreferenceMeta,
|
15
|
-
RawConsultationMeta,
|
16
|
+
RawConsultationMeta,
|
17
|
+
Term,
|
18
|
+
Terms,
|
16
19
|
Uuid,
|
17
20
|
VaultIndex,
|
18
21
|
WorkflowData,
|
@@ -20,9 +23,11 @@ import {
|
|
20
23
|
import {
|
21
24
|
filterTriggeredAnsweredWithKind,
|
22
25
|
getImagesFromIndexDb,
|
23
|
-
getWorkflowDataByCategory,
|
26
|
+
getWorkflowDataByCategory,
|
27
|
+
identificationToPersonalInformations,
|
24
28
|
OroClient,
|
25
|
-
RegisterPatientOutput,
|
29
|
+
RegisterPatientOutput,
|
30
|
+
toActualObject
|
26
31
|
} from '..'
|
27
32
|
|
28
33
|
const MAX_RETRIES = 15
|
@@ -179,6 +184,12 @@ export async function registerPatient(
|
|
179
184
|
|
180
185
|
await Promise.all([...grantPromises, ...consultIndexPromises])
|
181
186
|
|
187
|
+
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
|
190
|
+
errorsThrown.push(err)
|
191
|
+
})
|
192
|
+
|
182
193
|
if (errorsThrown.length > 0)
|
183
194
|
throw errorsThrown
|
184
195
|
|
@@ -187,11 +198,6 @@ export async function registerPatient(
|
|
187
198
|
statusMedical: MedicalStatus.New,
|
188
199
|
})
|
189
200
|
|
190
|
-
await searchIndexConsultation(consult.uuid, oroClient).catch((err) => {
|
191
|
-
console.error('[SDK: registration] personal information not found or another error occured during search indexing', err)
|
192
|
-
errorsThrown.push(err)
|
193
|
-
})
|
194
|
-
|
195
201
|
// if we got through the complete flow, the registration succeeded
|
196
202
|
break
|
197
203
|
} catch (err) {
|
@@ -405,88 +411,61 @@ export async function extractAndStorePersonalWorkflowData(
|
|
405
411
|
})
|
406
412
|
}
|
407
413
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
414
|
+
/**
|
415
|
+
* Given workflow data, it populates it with Personal, ChildPersonal, and OtherPersonal workflow data
|
416
|
+
* @param workflow
|
417
|
+
*/
|
418
|
+
export async function extractPersonalInfoFromWorkflowData(workflow: WorkflowData): Promise<{
|
419
|
+
personalInfoPopulatedWfData: PopulatedWorkflowData,
|
420
|
+
childPersonalInfoPopulatedWfData: PopulatedWorkflowData,
|
421
|
+
otherPersonalInfoPopulatedWfData: PopulatedWorkflowData,
|
413
422
|
}> {
|
414
423
|
return Promise.all([
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
if (!personalInformations[0]) {
|
420
|
-
console.error(
|
421
|
-
`${MetadataCategory.Personal} informations not found for consult:`,
|
422
|
-
consultUuid
|
423
|
-
)
|
424
|
-
|
425
|
-
throw Error('No self personal information found')
|
426
|
-
}
|
427
|
-
|
428
|
-
return personalInformations[0]
|
429
|
-
}),
|
430
|
-
// Retrieve MetadataCategory.ChildPersonal in any case in parallel
|
431
|
-
oroClient
|
432
|
-
.getPersonalInformationsFromConsultId(consultUuid, MetadataCategory.ChildPersonal, true)
|
433
|
-
.then((childInformations): any => {
|
434
|
-
if (!childInformations[0]) {
|
435
|
-
console.debug(
|
436
|
-
`${MetadataCategory.ChildPersonal} informations not found for consult:`,
|
437
|
-
consultUuid
|
438
|
-
)
|
439
|
-
|
440
|
-
// Retrieve MetadataCategory.OtherPersonal only if MetadataCategory.ChildPersonal does not exist
|
441
|
-
return oroClient
|
442
|
-
.getPersonalInformationsFromConsultId(
|
443
|
-
consultUuid,
|
444
|
-
MetadataCategory.OtherPersonal,
|
445
|
-
true
|
446
|
-
)
|
447
|
-
.then((otherInformations) => {
|
448
|
-
if (!otherInformations[0]) {
|
449
|
-
console.debug(
|
450
|
-
`${MetadataCategory.OtherPersonal} informations not found for consult:`,
|
451
|
-
consultUuid
|
452
|
-
)
|
453
|
-
|
454
|
-
return {}
|
455
|
-
}
|
456
|
-
|
457
|
-
return { otherPersonalInformations: otherInformations[0] }
|
458
|
-
})
|
459
|
-
}
|
460
|
-
|
461
|
-
return { childPersonalInformations: childInformations[0] }
|
462
|
-
}),
|
463
|
-
]).then(([personalInformations, { childPersonalInformations, otherPersonalInformations }]) => {
|
424
|
+
getWorkflowDataByCategory(workflow, MetadataCategory.Personal),
|
425
|
+
getWorkflowDataByCategory(workflow, MetadataCategory.ChildPersonal),
|
426
|
+
getWorkflowDataByCategory(workflow, MetadataCategory.OtherPersonal)
|
427
|
+
]).then(([personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData]) => {
|
464
428
|
return {
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
otherPersonalInformations,
|
429
|
+
personalInfoPopulatedWfData,
|
430
|
+
childPersonalInfoPopulatedWfData,
|
431
|
+
otherPersonalInfoPopulatedWfData,
|
469
432
|
}
|
470
433
|
})
|
471
434
|
}
|
472
435
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
436
|
+
/**
|
437
|
+
* Creates the search index for the first name, last name, and the short id of the given consultation
|
438
|
+
* @param consult the consultation to be search indexed
|
439
|
+
* @param workflow the workflow data
|
440
|
+
* @param oroClient
|
441
|
+
*/
|
442
|
+
export async function buildConsultSearchIndex(consult: Consult, workflow: WorkflowData, oroClient: OroClient) {
|
443
|
+
let terms: Terms = [
|
444
|
+
<Term> {
|
445
|
+
kind: 'consult-shortid',
|
446
|
+
value: consult.shortId
|
447
|
+
}
|
448
|
+
]
|
477
449
|
|
478
450
|
const {
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
} = await
|
483
|
-
|
484
|
-
console.log('personal=', personalInformations, 'child=', childPersonalInformations, 'other=', otherPersonalInformations)
|
451
|
+
personalInfoPopulatedWfData,
|
452
|
+
childPersonalInfoPopulatedWfData,
|
453
|
+
otherPersonalInfoPopulatedWfData
|
454
|
+
} = await extractPersonalInfoFromWorkflowData(workflow)
|
485
455
|
|
486
456
|
const personalInfo = identificationToPersonalInformations(
|
487
|
-
toActualObject(
|
457
|
+
toActualObject(personalInfoPopulatedWfData),
|
488
458
|
MetadataCategory.Personal
|
489
459
|
)
|
460
|
+
const childPersonalInfo = identificationToPersonalInformations(
|
461
|
+
toActualObject(childPersonalInfoPopulatedWfData),
|
462
|
+
MetadataCategory.ChildPersonal
|
463
|
+
)
|
464
|
+
const otherPersonalInfo = identificationToPersonalInformations(
|
465
|
+
toActualObject(otherPersonalInfoPopulatedWfData),
|
466
|
+
MetadataCategory.OtherPersonal
|
467
|
+
)
|
468
|
+
|
490
469
|
terms.push(<Term>{
|
491
470
|
kind: 'first-name',
|
492
471
|
value: personalInfo.firstname,
|
@@ -495,11 +474,7 @@ export async function searchIndexConsultation(consultUuid: string, oroClient: Or
|
|
495
474
|
value: personalInfo.name
|
496
475
|
})
|
497
476
|
|
498
|
-
if(
|
499
|
-
const childPersonalInfo = identificationToPersonalInformations(
|
500
|
-
toActualObject(childPersonalInformations.data),
|
501
|
-
MetadataCategory.ChildPersonal
|
502
|
-
)
|
477
|
+
if(childPersonalInfo.firstname && childPersonalInfo.name) {
|
503
478
|
terms.push(<Term>{
|
504
479
|
kind: 'first-name',
|
505
480
|
value: childPersonalInfo.firstname,
|
@@ -509,11 +484,7 @@ export async function searchIndexConsultation(consultUuid: string, oroClient: Or
|
|
509
484
|
})
|
510
485
|
}
|
511
486
|
|
512
|
-
if(
|
513
|
-
const otherPersonalInfo = identificationToPersonalInformations(
|
514
|
-
toActualObject(otherPersonalInformations.data),
|
515
|
-
MetadataCategory.OtherPersonal
|
516
|
-
)
|
487
|
+
if(otherPersonalInfo.firstname && otherPersonalInfo.name) {
|
517
488
|
terms.push(<Term>{
|
518
489
|
kind: 'first-name',
|
519
490
|
value: otherPersonalInfo.firstname,
|
@@ -523,5 +494,5 @@ export async function searchIndexConsultation(consultUuid: string, oroClient: Or
|
|
523
494
|
})
|
524
495
|
}
|
525
496
|
|
526
|
-
await oroClient.searchClient.index(
|
497
|
+
await oroClient.searchClient.index(consult.uuid, terms)
|
527
498
|
}
|