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
package/dist/oro-sdk.esm.js
CHANGED
@@ -740,8 +740,8 @@ function _filterTriggeredAnsweredWithKind() {
|
|
740
740
|
// Flattens the list of answered questions
|
741
741
|
flattenedAnswers = flattenSelectedAnswers(workflowData.selectedAnswers); // Generates a list of applicable questions
|
742
742
|
triggeredQuestionsWithKind = Object.fromEntries(workflowData.pages.map(function (a) {
|
743
|
-
return Object.entries(a.questions).filter(function (
|
744
|
-
var question =
|
743
|
+
return Object.entries(a.questions).filter(function (_ref2) {
|
744
|
+
var question = _ref2[1];
|
745
745
|
return isTriggered(question.triggers || [], flattenedAnswers) && question.kind === kind;
|
746
746
|
});
|
747
747
|
}).flat());
|
@@ -765,7 +765,8 @@ function getWorkflowDataByCategory(_x3, _x4) {
|
|
765
765
|
}
|
766
766
|
function _getWorkflowDataByCategory() {
|
767
767
|
_getWorkflowDataByCategory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(workflowData, category) {
|
768
|
-
var
|
768
|
+
var _workflowData$selecte;
|
769
|
+
var flattenedAnswers, triggeredQuestions, fields, answersPerPage;
|
769
770
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
770
771
|
while (1) switch (_context2.prev = _context2.next) {
|
771
772
|
case 0:
|
@@ -778,21 +779,40 @@ function _getWorkflowDataByCategory() {
|
|
778
779
|
// Flattens the list of answered questions
|
779
780
|
flattenedAnswers = flattenSelectedAnswers(workflowData.selectedAnswers); // Generates a list of applicable questions
|
780
781
|
triggeredQuestions = Object.fromEntries(workflowData.pages.map(function (a) {
|
781
|
-
return Object.entries(a.questions).filter(function (
|
782
|
-
var question =
|
782
|
+
return Object.entries(a.questions).filter(function (_ref3) {
|
783
|
+
var question = _ref3[1];
|
783
784
|
return isTriggered(question.triggers || [], flattenedAnswers);
|
784
785
|
});
|
785
786
|
}).flat());
|
786
|
-
fields = {};
|
787
|
-
|
788
|
-
return Object.entries(
|
789
|
-
|
790
|
-
|
787
|
+
fields = {};
|
788
|
+
answersPerPage = ((_workflowData$selecte = workflowData.selectedAnswers) != null ? _workflowData$selecte : []).map(function (pageAnswers, _) {
|
789
|
+
return Object.entries(pageAnswers).map(function (_ref4) {
|
790
|
+
var k = _ref4[0],
|
791
|
+
v = _ref4[1];
|
792
|
+
return [k, v, undefined];
|
793
|
+
});
|
794
|
+
});
|
795
|
+
if (workflowData.previousAnswers) {
|
796
|
+
// Since the selectedAnswers and previousAnswers should be a 1-1, we can map them together
|
797
|
+
answersPerPage = answersPerPage.map(function (pageAnswers, pageIndex) {
|
798
|
+
return pageAnswers.map(function (_ref5) {
|
799
|
+
var questionId = _ref5[0],
|
800
|
+
v = _ref5[1];
|
801
|
+
if (workflowData.previousAnswers && workflowData.previousAnswers[pageIndex][questionId]) return [questionId, v, workflowData.previousAnswers[pageIndex][questionId]];
|
802
|
+
return [questionId, v, undefined];
|
803
|
+
});
|
804
|
+
});
|
805
|
+
}
|
806
|
+
// Generates the answers of the specified category and adds the appropriate values if any are missing
|
807
|
+
return _context2.abrupt("return", Promise.all(answersPerPage.flat(1) // remove the pages, we want the answers all together
|
808
|
+
.filter(function (_ref6) {
|
809
|
+
var k = _ref6[0];
|
791
810
|
return triggeredQuestions[k] && triggeredQuestions[k]['metaCategory'] === category;
|
792
|
-
}).map(function (
|
793
|
-
var k =
|
794
|
-
v =
|
795
|
-
|
811
|
+
}).map(function (_ref7) {
|
812
|
+
var k = _ref7[0],
|
813
|
+
v = _ref7[1],
|
814
|
+
p = _ref7[2];
|
815
|
+
return populateWorkflowField(triggeredQuestions[k], v, p).then(function (populatedValue) {
|
796
816
|
fields[k] = populatedValue;
|
797
817
|
});
|
798
818
|
})).then(function () {
|
@@ -807,7 +827,7 @@ function _getWorkflowDataByCategory() {
|
|
807
827
|
console.error("Error while extracting " + category + " data from workflow", err);
|
808
828
|
throw err;
|
809
829
|
}));
|
810
|
-
case
|
830
|
+
case 8:
|
811
831
|
case "end":
|
812
832
|
return _context2.stop();
|
813
833
|
}
|
@@ -847,7 +867,7 @@ function _getImagesFromIndexDb() {
|
|
847
867
|
}));
|
848
868
|
return _getImagesFromIndexDb.apply(this, arguments);
|
849
869
|
}
|
850
|
-
function populateWorkflowField(_x6, _x7) {
|
870
|
+
function populateWorkflowField(_x6, _x7, _x8) {
|
851
871
|
return _populateWorkflowField.apply(this, arguments);
|
852
872
|
}
|
853
873
|
/**
|
@@ -897,7 +917,7 @@ function populateWorkflowField(_x6, _x7) {
|
|
897
917
|
* @throws an Error if triggers typing is wrong
|
898
918
|
*/
|
899
919
|
function _populateWorkflowField() {
|
900
|
-
_populateWorkflowField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(question, answerValue) {
|
920
|
+
_populateWorkflowField = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(question, answerValue, previousAnswer) {
|
901
921
|
var answer, displayedAnswer;
|
902
922
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
903
923
|
while (1) switch (_context4.prev = _context4.next) {
|
@@ -948,6 +968,7 @@ function _populateWorkflowField() {
|
|
948
968
|
return _context4.abrupt("return", Promise.resolve({
|
949
969
|
answer: answer,
|
950
970
|
displayedAnswer: displayedAnswer,
|
971
|
+
previousAnswer: previousAnswer,
|
951
972
|
kind: question.kind
|
952
973
|
}));
|
953
974
|
case 19:
|
@@ -1029,6 +1050,32 @@ function fillWorkflowFromPopulatedWorkflow(workflow, populatedWorkflow) {
|
|
1029
1050
|
});
|
1030
1051
|
return filledWorkflow;
|
1031
1052
|
}
|
1053
|
+
/**
|
1054
|
+
* Checks and toggles the changed status for every answer in the workflow
|
1055
|
+
* by comparing the previous answer with the selected answer of the same question
|
1056
|
+
*
|
1057
|
+
* @param workflow
|
1058
|
+
* @returns the workflow with the updated `changed` statuses
|
1059
|
+
*/
|
1060
|
+
function detectChangesInWorkflowAnswers(workflow) {
|
1061
|
+
return _extends({}, workflow, {
|
1062
|
+
previousAnswers: workflow.previousAnswers ? workflow.previousAnswers.map(function (pageAnswers, pageId) {
|
1063
|
+
return Object.fromEntries(Object.entries(pageAnswers).map(function (_ref) {
|
1064
|
+
var question = _ref[0],
|
1065
|
+
answer = _ref[1];
|
1066
|
+
var selectedAnswer = undefined;
|
1067
|
+
if (workflow.selectedAnswers && workflow.selectedAnswers[pageId][question]) selectedAnswer = workflow.selectedAnswers[pageId][question];
|
1068
|
+
var changed = !!selectedAnswer && !equalsAnswer(selectedAnswer, answer.previousAnswer);
|
1069
|
+
return [question, _extends({}, answer, {
|
1070
|
+
changed: changed
|
1071
|
+
})];
|
1072
|
+
}));
|
1073
|
+
}) : undefined
|
1074
|
+
});
|
1075
|
+
}
|
1076
|
+
function equalsAnswer(answer1, answer2) {
|
1077
|
+
return JSON.stringify(answer1) === JSON.stringify(answer2);
|
1078
|
+
}
|
1032
1079
|
|
1033
1080
|
/**
|
1034
1081
|
* Creates a consultation if one has not been created and fails to be retrieved by the payment intent
|
@@ -1121,6 +1168,8 @@ function _registerPatient() {
|
|
1121
1168
|
identity = undefined;
|
1122
1169
|
errorsThrown = [];
|
1123
1170
|
stepsTotalNum = 9;
|
1171
|
+
// toggle all changed statuses if this workflow has previous/revision data
|
1172
|
+
workflow = detectChangesInWorkflowAnswers(workflow);
|
1124
1173
|
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
1125
1174
|
var _consultIndex, _identity, _identity2, practitioners, grantPromises, consultIndex, consultIndexPromises;
|
1126
1175
|
return _regeneratorRuntime().wrap(function _loop$(_context3) {
|
@@ -1343,47 +1392,47 @@ function _registerPatient() {
|
|
1343
1392
|
}
|
1344
1393
|
}, _loop, null, [[0, 66]]);
|
1345
1394
|
});
|
1346
|
-
case
|
1395
|
+
case 10:
|
1347
1396
|
if (!(retry > 0)) {
|
1348
|
-
_context4.next =
|
1397
|
+
_context4.next = 20;
|
1349
1398
|
break;
|
1350
1399
|
}
|
1351
|
-
return _context4.delegateYield(_loop(), "t0",
|
1352
|
-
case
|
1400
|
+
return _context4.delegateYield(_loop(), "t0", 12);
|
1401
|
+
case 12:
|
1353
1402
|
_ret = _context4.t0;
|
1354
1403
|
if (!(_ret === "break")) {
|
1355
|
-
_context4.next =
|
1404
|
+
_context4.next = 15;
|
1356
1405
|
break;
|
1357
1406
|
}
|
1358
|
-
return _context4.abrupt("break",
|
1359
|
-
case
|
1407
|
+
return _context4.abrupt("break", 20);
|
1408
|
+
case 15:
|
1360
1409
|
if (!(_ret === "continue")) {
|
1361
|
-
_context4.next =
|
1410
|
+
_context4.next = 17;
|
1362
1411
|
break;
|
1363
1412
|
}
|
1364
|
-
return _context4.abrupt("continue",
|
1365
|
-
case
|
1413
|
+
return _context4.abrupt("continue", 17);
|
1414
|
+
case 17:
|
1366
1415
|
retry--;
|
1367
|
-
_context4.next =
|
1416
|
+
_context4.next = 10;
|
1368
1417
|
break;
|
1369
|
-
case
|
1418
|
+
case 20:
|
1370
1419
|
if (!(retry <= 0)) {
|
1371
|
-
_context4.next =
|
1420
|
+
_context4.next = 23;
|
1372
1421
|
break;
|
1373
1422
|
}
|
1374
1423
|
console.error('[SDK] registration failed: MAX_RETRIES reached');
|
1375
1424
|
throw 'RegistrationFailed';
|
1376
|
-
case
|
1425
|
+
case 23:
|
1377
1426
|
console.log('Successfully Registered');
|
1378
|
-
_context4.next =
|
1427
|
+
_context4.next = 26;
|
1379
1428
|
return oroClient.cleanIndex();
|
1380
|
-
case
|
1429
|
+
case 26:
|
1381
1430
|
return _context4.abrupt("return", {
|
1382
1431
|
masterKey: masterKey,
|
1383
1432
|
consultationId: consult.uuid,
|
1384
1433
|
lockboxUuid: lockboxUuid
|
1385
1434
|
});
|
1386
|
-
case
|
1435
|
+
case 27:
|
1387
1436
|
case "end":
|
1388
1437
|
return _context4.stop();
|
1389
1438
|
}
|
@@ -4751,5 +4800,5 @@ var init = function init(toolbox, tellerBaseURL, vaultBaseURL, guardBaseURL, sea
|
|
4751
4800
|
};
|
4752
4801
|
|
4753
4802
|
export default init;
|
4754
|
-
export { AssociatedLockboxNotFound, CliniaService, IncompleteAuthentication, MissingGrant, MissingGrantFilter, MissingLockbox, MissingLockboxOwner, OroClient, WorkflowAnswersMissingError, buildConsultSearchIndex, createRefill, decryptConsultLockboxGrants, decryptGrants, extractAndStorePersonalWorkflowData, extractISOLocalityForConsult, extractPersonalInfoFromWorkflowData, fillWorkflowFromPopulatedWorkflow, filterTriggeredAnsweredWithKind, flattenSelectedAnswers, getImagesFromIndexDb, getInitialisedSelectedAnswers, getRefillAnswersAsWorkflow, getWorkflowDataByCategory, identificationToPersonalInformations, isTriggered, registerPatient, sessionStorePrivateKeyName, toActualObject, updatePersonalIntoPopulatedWorkflowData, wasmPath };
|
4803
|
+
export { AssociatedLockboxNotFound, CliniaService, IncompleteAuthentication, MissingGrant, MissingGrantFilter, MissingLockbox, MissingLockboxOwner, OroClient, WorkflowAnswersMissingError, buildConsultSearchIndex, createRefill, decryptConsultLockboxGrants, decryptGrants, detectChangesInWorkflowAnswers, extractAndStorePersonalWorkflowData, extractISOLocalityForConsult, extractPersonalInfoFromWorkflowData, fillWorkflowFromPopulatedWorkflow, filterTriggeredAnsweredWithKind, flattenSelectedAnswers, getImagesFromIndexDb, getInitialisedSelectedAnswers, getRefillAnswersAsWorkflow, getWorkflowDataByCategory, identificationToPersonalInformations, isTriggered, registerPatient, sessionStorePrivateKeyName, toActualObject, updatePersonalIntoPopulatedWorkflowData, wasmPath };
|
4755
4804
|
//# sourceMappingURL=oro-sdk.esm.js.map
|