oro-sdk 6.0.2 → 6.2.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/workflow.d.ts +8 -0
- package/dist/oro-sdk.cjs.development.js +84 -34
- 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 +84 -35
- package/dist/oro-sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/patient-registration.ts +12 -8
- package/src/helpers/workflow.ts +52 -7
@@ -67,3 +67,11 @@ export declare function flattenSelectedAnswers(answers: SelectedAnswersData): st
|
|
67
67
|
*/
|
68
68
|
export declare function getInitialisedSelectedAnswers(workflow: WorkflowData, useDefault?: boolean): any[];
|
69
69
|
export declare function fillWorkflowFromPopulatedWorkflow(workflow: WorkflowData, populatedWorkflow: PopulatedWorkflowData): any;
|
70
|
+
/**
|
71
|
+
* Checks and toggles the changed status for every answer in the workflow
|
72
|
+
* by comparing the previous answer with the selected answer of the same question
|
73
|
+
*
|
74
|
+
* @param workflow
|
75
|
+
* @returns the workflow with the updated `changed` statuses
|
76
|
+
*/
|
77
|
+
export declare function detectChangesInWorkflowAnswers(workflow: WorkflowData): WorkflowData;
|
@@ -744,8 +744,8 @@ function _filterTriggeredAnsweredWithKind() {
|
|
744
744
|
// Flattens the list of answered questions
|
745
745
|
flattenedAnswers = flattenSelectedAnswers(workflowData.selectedAnswers); // Generates a list of applicable questions
|
746
746
|
triggeredQuestionsWithKind = Object.fromEntries(workflowData.pages.map(function (a) {
|
747
|
-
return Object.entries(a.questions).filter(function (
|
748
|
-
var question =
|
747
|
+
return Object.entries(a.questions).filter(function (_ref2) {
|
748
|
+
var question = _ref2[1];
|
749
749
|
return isTriggered(question.triggers || [], flattenedAnswers) && question.kind === kind;
|
750
750
|
});
|
751
751
|
}).flat());
|
@@ -769,7 +769,8 @@ function getWorkflowDataByCategory(_x3, _x4) {
|
|
769
769
|
}
|
770
770
|
function _getWorkflowDataByCategory() {
|
771
771
|
_getWorkflowDataByCategory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(workflowData, category) {
|
772
|
-
var
|
772
|
+
var _workflowData$selecte;
|
773
|
+
var flattenedAnswers, triggeredQuestions, fields, answersPerPage;
|
773
774
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
774
775
|
while (1) switch (_context2.prev = _context2.next) {
|
775
776
|
case 0:
|
@@ -782,21 +783,40 @@ function _getWorkflowDataByCategory() {
|
|
782
783
|
// Flattens the list of answered questions
|
783
784
|
flattenedAnswers = flattenSelectedAnswers(workflowData.selectedAnswers); // Generates a list of applicable questions
|
784
785
|
triggeredQuestions = Object.fromEntries(workflowData.pages.map(function (a) {
|
785
|
-
return Object.entries(a.questions).filter(function (
|
786
|
-
var question =
|
786
|
+
return Object.entries(a.questions).filter(function (_ref3) {
|
787
|
+
var question = _ref3[1];
|
787
788
|
return isTriggered(question.triggers || [], flattenedAnswers);
|
788
789
|
});
|
789
790
|
}).flat());
|
790
|
-
fields = {};
|
791
|
-
|
792
|
-
return Object.entries(
|
793
|
-
|
794
|
-
|
791
|
+
fields = {};
|
792
|
+
answersPerPage = ((_workflowData$selecte = workflowData.selectedAnswers) != null ? _workflowData$selecte : []).map(function (pageAnswers, _) {
|
793
|
+
return Object.entries(pageAnswers).map(function (_ref4) {
|
794
|
+
var k = _ref4[0],
|
795
|
+
v = _ref4[1];
|
796
|
+
return [k, v, undefined];
|
797
|
+
});
|
798
|
+
});
|
799
|
+
if (workflowData.previousAnswers) {
|
800
|
+
// Since the selectedAnswers and previousAnswers should be a 1-1, we can map them together
|
801
|
+
answersPerPage = answersPerPage.map(function (pageAnswers, pageIndex) {
|
802
|
+
return pageAnswers.map(function (_ref5) {
|
803
|
+
var questionId = _ref5[0],
|
804
|
+
v = _ref5[1];
|
805
|
+
if (workflowData.previousAnswers && workflowData.previousAnswers[pageIndex][questionId]) return [questionId, v, workflowData.previousAnswers[pageIndex][questionId]];
|
806
|
+
return [questionId, v, undefined];
|
807
|
+
});
|
808
|
+
});
|
809
|
+
}
|
810
|
+
// Generates the answers of the specified category and adds the appropriate values if any are missing
|
811
|
+
return _context2.abrupt("return", Promise.all(answersPerPage.flat(1) // remove the pages, we want the answers all together
|
812
|
+
.filter(function (_ref6) {
|
813
|
+
var k = _ref6[0];
|
795
814
|
return triggeredQuestions[k] && triggeredQuestions[k]['metaCategory'] === category;
|
796
|
-
}).map(function (
|
797
|
-
var k =
|
798
|
-
v =
|
799
|
-
|
815
|
+
}).map(function (_ref7) {
|
816
|
+
var k = _ref7[0],
|
817
|
+
v = _ref7[1],
|
818
|
+
p = _ref7[2];
|
819
|
+
return populateWorkflowField(triggeredQuestions[k], v, p).then(function (populatedValue) {
|
800
820
|
fields[k] = populatedValue;
|
801
821
|
});
|
802
822
|
})).then(function () {
|
@@ -811,7 +831,7 @@ function _getWorkflowDataByCategory() {
|
|
811
831
|
console.error("Error while extracting " + category + " data from workflow", err);
|
812
832
|
throw err;
|
813
833
|
}));
|
814
|
-
case
|
834
|
+
case 8:
|
815
835
|
case "end":
|
816
836
|
return _context2.stop();
|
817
837
|
}
|
@@ -851,7 +871,7 @@ function _getImagesFromIndexDb() {
|
|
851
871
|
}));
|
852
872
|
return _getImagesFromIndexDb.apply(this, arguments);
|
853
873
|
}
|
854
|
-
function populateWorkflowField(_x6, _x7) {
|
874
|
+
function populateWorkflowField(_x6, _x7, _x8) {
|
855
875
|
return _populateWorkflowField.apply(this, arguments);
|
856
876
|
}
|
857
877
|
/**
|
@@ -901,7 +921,7 @@ function populateWorkflowField(_x6, _x7) {
|
|
901
921
|
* @throws an Error if triggers typing is wrong
|
902
922
|
*/
|
903
923
|
function _populateWorkflowField() {
|
904
|
-
_populateWorkflowField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(question, answerValue) {
|
924
|
+
_populateWorkflowField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(question, answerValue, previousAnswer) {
|
905
925
|
var answer, displayedAnswer;
|
906
926
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
907
927
|
while (1) switch (_context4.prev = _context4.next) {
|
@@ -952,6 +972,7 @@ function _populateWorkflowField() {
|
|
952
972
|
return _context4.abrupt("return", Promise.resolve({
|
953
973
|
answer: answer,
|
954
974
|
displayedAnswer: displayedAnswer,
|
975
|
+
previousAnswer: previousAnswer,
|
955
976
|
kind: question.kind
|
956
977
|
}));
|
957
978
|
case 19:
|
@@ -1033,6 +1054,32 @@ function fillWorkflowFromPopulatedWorkflow(workflow, populatedWorkflow) {
|
|
1033
1054
|
});
|
1034
1055
|
return filledWorkflow;
|
1035
1056
|
}
|
1057
|
+
/**
|
1058
|
+
* Checks and toggles the changed status for every answer in the workflow
|
1059
|
+
* by comparing the previous answer with the selected answer of the same question
|
1060
|
+
*
|
1061
|
+
* @param workflow
|
1062
|
+
* @returns the workflow with the updated `changed` statuses
|
1063
|
+
*/
|
1064
|
+
function detectChangesInWorkflowAnswers(workflow) {
|
1065
|
+
return _extends({}, workflow, {
|
1066
|
+
previousAnswers: workflow.previousAnswers ? workflow.previousAnswers.map(function (pageAnswers, pageId) {
|
1067
|
+
return Object.fromEntries(Object.entries(pageAnswers).map(function (_ref) {
|
1068
|
+
var question = _ref[0],
|
1069
|
+
answer = _ref[1];
|
1070
|
+
var selectedAnswer = undefined;
|
1071
|
+
if (workflow.selectedAnswers && workflow.selectedAnswers[pageId][question]) selectedAnswer = workflow.selectedAnswers[pageId][question];
|
1072
|
+
var changed = !!selectedAnswer && !equalsAnswer(selectedAnswer, answer.previousAnswer);
|
1073
|
+
return [question, _extends({}, answer, {
|
1074
|
+
changed: changed
|
1075
|
+
})];
|
1076
|
+
}));
|
1077
|
+
}) : undefined
|
1078
|
+
});
|
1079
|
+
}
|
1080
|
+
function equalsAnswer(answer1, answer2) {
|
1081
|
+
return JSON.stringify(answer1) === JSON.stringify(answer2);
|
1082
|
+
}
|
1036
1083
|
|
1037
1084
|
/**
|
1038
1085
|
* Creates a consultation if one has not been created and fails to be retrieved by the payment intent
|
@@ -1125,6 +1172,8 @@ function _registerPatient() {
|
|
1125
1172
|
identity = undefined;
|
1126
1173
|
errorsThrown = [];
|
1127
1174
|
stepsTotalNum = 9;
|
1175
|
+
// toggle all changed statuses if this workflow has previous/revision data
|
1176
|
+
workflow = detectChangesInWorkflowAnswers(workflow);
|
1128
1177
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
1129
1178
|
var _consultIndex, _identity, _identity2, practitioners, grantPromises, consultIndex, consultIndexPromises;
|
1130
1179
|
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
@@ -1347,47 +1396,47 @@ function _registerPatient() {
|
|
1347
1396
|
}
|
1348
1397
|
}, _loop, null, [[0, 66]]);
|
1349
1398
|
});
|
1350
|
-
case
|
1399
|
+
case 10:
|
1351
1400
|
if (!(retry > 0)) {
|
1352
|
-
_context4.next =
|
1401
|
+
_context4.next = 20;
|
1353
1402
|
break;
|
1354
1403
|
}
|
1355
|
-
return _context4.delegateYield(_loop(), "t0",
|
1356
|
-
case
|
1404
|
+
return _context4.delegateYield(_loop(), "t0", 12);
|
1405
|
+
case 12:
|
1357
1406
|
_ret = _context4.t0;
|
1358
1407
|
if (!(_ret === "break")) {
|
1359
|
-
_context4.next =
|
1408
|
+
_context4.next = 15;
|
1360
1409
|
break;
|
1361
1410
|
}
|
1362
|
-
return _context4.abrupt("break",
|
1363
|
-
case
|
1411
|
+
return _context4.abrupt("break", 20);
|
1412
|
+
case 15:
|
1364
1413
|
if (!(_ret === "continue")) {
|
1365
|
-
_context4.next =
|
1414
|
+
_context4.next = 17;
|
1366
1415
|
break;
|
1367
1416
|
}
|
1368
|
-
return _context4.abrupt("continue",
|
1369
|
-
case
|
1417
|
+
return _context4.abrupt("continue", 17);
|
1418
|
+
case 17:
|
1370
1419
|
retry--;
|
1371
|
-
_context4.next =
|
1420
|
+
_context4.next = 10;
|
1372
1421
|
break;
|
1373
|
-
case
|
1422
|
+
case 20:
|
1374
1423
|
if (!(retry <= 0)) {
|
1375
|
-
_context4.next =
|
1424
|
+
_context4.next = 23;
|
1376
1425
|
break;
|
1377
1426
|
}
|
1378
1427
|
console.error('[SDK] registration failed: MAX_RETRIES reached');
|
1379
1428
|
throw 'RegistrationFailed';
|
1380
|
-
case
|
1429
|
+
case 23:
|
1381
1430
|
console.log('Successfully Registered');
|
1382
|
-
_context4.next =
|
1431
|
+
_context4.next = 26;
|
1383
1432
|
return oroClient.cleanIndex();
|
1384
|
-
case
|
1433
|
+
case 26:
|
1385
1434
|
return _context4.abrupt("return", {
|
1386
1435
|
masterKey: masterKey,
|
1387
1436
|
consultationId: consult.uuid,
|
1388
1437
|
lockboxUuid: lockboxUuid
|
1389
1438
|
});
|
1390
|
-
case
|
1439
|
+
case 27:
|
1391
1440
|
case "end":
|
1392
1441
|
return _context4.stop();
|
1393
1442
|
}
|
@@ -4777,6 +4826,7 @@ exports.createRefill = createRefill;
|
|
4777
4826
|
exports.decryptConsultLockboxGrants = decryptConsultLockboxGrants;
|
4778
4827
|
exports.decryptGrants = decryptGrants;
|
4779
4828
|
exports.default = init;
|
4829
|
+
exports.detectChangesInWorkflowAnswers = detectChangesInWorkflowAnswers;
|
4780
4830
|
exports.extractAndStorePersonalWorkflowData = extractAndStorePersonalWorkflowData;
|
4781
4831
|
exports.extractISOLocalityForConsult = extractISOLocalityForConsult;
|
4782
4832
|
exports.extractPersonalInfoFromWorkflowData = extractPersonalInfoFromWorkflowData;
|