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.
@@ -1804,24 +1804,27 @@ function _registerPatient() {
1804
1804
  return Promise.all([].concat(grantPromises, consultIndexPromises));
1805
1805
 
1806
1806
  case 43:
1807
+ _context3.next = 45;
1808
+ return buildConsultSearchIndex(consult, workflow, oroClient)["catch"](function (err) {
1809
+ console.error('[SDK: registration] personal information not found or another error occured during search indexing', err);
1810
+ 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
1811
+
1812
+ // this statement is to avoid failing the registration due to the failure in search indexing the consult, this practically implements a soft retry
1813
+ errorsThrown.push(err);
1814
+ });
1815
+
1816
+ case 45:
1807
1817
  if (!(errorsThrown.length > 0)) {
1808
- _context3.next = 45;
1818
+ _context3.next = 47;
1809
1819
  break;
1810
1820
  }
1811
1821
 
1812
1822
  throw errorsThrown;
1813
1823
 
1814
- case 45:
1815
- _context3.next = 47;
1816
- return oroClient.consultClient.updateConsultByUUID(consult.uuid, {
1817
- statusMedical: MedicalStatus.New
1818
- });
1819
-
1820
1824
  case 47:
1821
1825
  _context3.next = 49;
1822
- return searchIndexConsultation(consult.uuid, oroClient)["catch"](function (err) {
1823
- console.error('[SDK: registration] personal information not found or another error occured during search indexing', err);
1824
- errorsThrown.push(err);
1826
+ return oroClient.consultClient.updateConsultByUUID(consult.uuid, {
1827
+ statusMedical: MedicalStatus.New
1825
1828
  });
1826
1829
 
1827
1830
  case 49:
@@ -2111,6 +2114,10 @@ function _storeImageAliases() {
2111
2114
  function extractAndStorePersonalWorkflowData(_x19, _x20, _x21, _x22, _x23) {
2112
2115
  return _extractAndStorePersonalWorkflowData.apply(this, arguments);
2113
2116
  }
2117
+ /**
2118
+ * Given workflow data, it populates it with Personal, ChildPersonal, and OtherPersonal workflow data
2119
+ * @param workflow
2120
+ */
2114
2121
 
2115
2122
  function _extractAndStorePersonalWorkflowData() {
2116
2123
  _extractAndStorePersonalWorkflowData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(workflow, lockboxUuid, consultationId, category, oroClient) {
@@ -2137,55 +2144,30 @@ function _extractAndStorePersonalWorkflowData() {
2137
2144
  return _extractAndStorePersonalWorkflowData.apply(this, arguments);
2138
2145
  }
2139
2146
 
2140
- function extractPersonalInfoFromConsultId(_x24, _x25) {
2141
- return _extractPersonalInfoFromConsultId.apply(this, arguments);
2147
+ function extractPersonalInfoFromWorkflowData(_x24) {
2148
+ return _extractPersonalInfoFromWorkflowData.apply(this, arguments);
2142
2149
  }
2150
+ /**
2151
+ * Creates the search index for the first name, last name, and the short id of the given consultation
2152
+ * @param consult the consultation to be search indexed
2153
+ * @param workflow the workflow data
2154
+ * @param oroClient
2155
+ */
2143
2156
 
2144
- function _extractPersonalInfoFromConsultId() {
2145
- _extractPersonalInfoFromConsultId = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(consultUuid, oroClient) {
2157
+ function _extractPersonalInfoFromWorkflowData() {
2158
+ _extractPersonalInfoFromWorkflowData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(workflow) {
2146
2159
  return runtime_1.wrap(function _callee10$(_context10) {
2147
2160
  while (1) {
2148
2161
  switch (_context10.prev = _context10.next) {
2149
2162
  case 0:
2150
- return _context10.abrupt("return", Promise.all([// Retrieve MetadataCategory.Personal in any case
2151
- oroClient.getPersonalInformationsFromConsultId(consultUuid, MetadataCategory.Personal, true).then(function (personalInformations) {
2152
- if (!personalInformations[0]) {
2153
- console.error(MetadataCategory.Personal + " informations not found for consult:", consultUuid);
2154
- throw Error('No self personal information found');
2155
- }
2156
-
2157
- return personalInformations[0];
2158
- }), // Retrieve MetadataCategory.ChildPersonal in any case in parallel
2159
- oroClient.getPersonalInformationsFromConsultId(consultUuid, MetadataCategory.ChildPersonal, true).then(function (childInformations) {
2160
- if (!childInformations[0]) {
2161
- console.debug(MetadataCategory.ChildPersonal + " informations not found for consult:", consultUuid); // Retrieve MetadataCategory.OtherPersonal only if MetadataCategory.ChildPersonal does not exist
2162
-
2163
- // Retrieve MetadataCategory.OtherPersonal only if MetadataCategory.ChildPersonal does not exist
2164
- return oroClient.getPersonalInformationsFromConsultId(consultUuid, MetadataCategory.OtherPersonal, true).then(function (otherInformations) {
2165
- if (!otherInformations[0]) {
2166
- console.debug(MetadataCategory.OtherPersonal + " informations not found for consult:", consultUuid);
2167
- return {};
2168
- }
2169
-
2170
- return {
2171
- otherPersonalInformations: otherInformations[0]
2172
- };
2173
- });
2174
- }
2175
-
2163
+ return _context10.abrupt("return", Promise.all([getWorkflowDataByCategory(workflow, MetadataCategory.Personal), getWorkflowDataByCategory(workflow, MetadataCategory.ChildPersonal), getWorkflowDataByCategory(workflow, MetadataCategory.OtherPersonal)]).then(function (_ref3) {
2164
+ var personalInfoPopulatedWfData = _ref3[0],
2165
+ childPersonalInfoPopulatedWfData = _ref3[1],
2166
+ otherPersonalInfoPopulatedWfData = _ref3[2];
2176
2167
  return {
2177
- childPersonalInformations: childInformations[0]
2178
- };
2179
- })]).then(function (_ref3) {
2180
- var personalInformations = _ref3[0],
2181
- _ref3$ = _ref3[1],
2182
- childPersonalInformations = _ref3$.childPersonalInformations,
2183
- otherPersonalInformations = _ref3$.otherPersonalInformations;
2184
- return {
2185
- consultUuid: consultUuid,
2186
- personalInformations: personalInformations,
2187
- childPersonalInformations: childPersonalInformations,
2188
- otherPersonalInformations: otherPersonalInformations
2168
+ personalInfoPopulatedWfData: personalInfoPopulatedWfData,
2169
+ childPersonalInfoPopulatedWfData: childPersonalInfoPopulatedWfData,
2170
+ otherPersonalInfoPopulatedWfData: otherPersonalInfoPopulatedWfData
2189
2171
  };
2190
2172
  }));
2191
2173
 
@@ -2196,33 +2178,36 @@ function _extractPersonalInfoFromConsultId() {
2196
2178
  }
2197
2179
  }, _callee10);
2198
2180
  }));
2199
- return _extractPersonalInfoFromConsultId.apply(this, arguments);
2181
+ return _extractPersonalInfoFromWorkflowData.apply(this, arguments);
2200
2182
  }
2201
2183
 
2202
- function searchIndexConsultation(_x26, _x27) {
2203
- return _searchIndexConsultation.apply(this, arguments);
2184
+ function buildConsultSearchIndex(_x25, _x26, _x27) {
2185
+ return _buildConsultSearchIndex.apply(this, arguments);
2204
2186
  }
2205
2187
 
2206
- function _searchIndexConsultation() {
2207
- _searchIndexConsultation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(consultUuid, oroClient) {
2208
- var terms, _yield$extractPersona, personalInformations, childPersonalInformations, otherPersonalInformations, personalInfo, childPersonalInfo, otherPersonalInfo;
2188
+ function _buildConsultSearchIndex() {
2189
+ _buildConsultSearchIndex = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(consult, workflow, oroClient) {
2190
+ var terms, _yield$extractPersona, personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData, personalInfo, childPersonalInfo, otherPersonalInfo;
2209
2191
 
2210
2192
  return runtime_1.wrap(function _callee11$(_context11) {
2211
2193
  while (1) {
2212
2194
  switch (_context11.prev = _context11.next) {
2213
2195
  case 0:
2214
- terms = [];
2215
- console.log('here');
2216
- _context11.next = 4;
2217
- return extractPersonalInfoFromConsultId(consultUuid, oroClient);
2196
+ terms = [{
2197
+ kind: 'consult-shortid',
2198
+ value: consult.shortId
2199
+ }];
2200
+ _context11.next = 3;
2201
+ return extractPersonalInfoFromWorkflowData(workflow);
2218
2202
 
2219
- case 4:
2203
+ case 3:
2220
2204
  _yield$extractPersona = _context11.sent;
2221
- personalInformations = _yield$extractPersona.personalInformations;
2222
- childPersonalInformations = _yield$extractPersona.childPersonalInformations;
2223
- otherPersonalInformations = _yield$extractPersona.otherPersonalInformations;
2224
- console.log('personal=', personalInformations, 'child=', childPersonalInformations, 'other=', otherPersonalInformations);
2225
- personalInfo = identificationToPersonalInformations(toActualObject(personalInformations.data), MetadataCategory.Personal);
2205
+ personalInfoPopulatedWfData = _yield$extractPersona.personalInfoPopulatedWfData;
2206
+ childPersonalInfoPopulatedWfData = _yield$extractPersona.childPersonalInfoPopulatedWfData;
2207
+ otherPersonalInfoPopulatedWfData = _yield$extractPersona.otherPersonalInfoPopulatedWfData;
2208
+ personalInfo = identificationToPersonalInformations(toActualObject(personalInfoPopulatedWfData), MetadataCategory.Personal);
2209
+ childPersonalInfo = identificationToPersonalInformations(toActualObject(childPersonalInfoPopulatedWfData), MetadataCategory.ChildPersonal);
2210
+ otherPersonalInfo = identificationToPersonalInformations(toActualObject(otherPersonalInfoPopulatedWfData), MetadataCategory.OtherPersonal);
2226
2211
  terms.push({
2227
2212
  kind: 'first-name',
2228
2213
  value: personalInfo.firstname
@@ -2231,8 +2216,7 @@ function _searchIndexConsultation() {
2231
2216
  value: personalInfo.name
2232
2217
  });
2233
2218
 
2234
- if (childPersonalInformations) {
2235
- childPersonalInfo = identificationToPersonalInformations(toActualObject(childPersonalInformations.data), MetadataCategory.ChildPersonal);
2219
+ if (childPersonalInfo.firstname && childPersonalInfo.name) {
2236
2220
  terms.push({
2237
2221
  kind: 'first-name',
2238
2222
  value: childPersonalInfo.firstname
@@ -2242,8 +2226,7 @@ function _searchIndexConsultation() {
2242
2226
  });
2243
2227
  }
2244
2228
 
2245
- if (otherPersonalInformations) {
2246
- otherPersonalInfo = identificationToPersonalInformations(toActualObject(otherPersonalInformations.data), MetadataCategory.OtherPersonal);
2229
+ if (otherPersonalInfo.firstname && otherPersonalInfo.name) {
2247
2230
  terms.push({
2248
2231
  kind: 'first-name',
2249
2232
  value: otherPersonalInfo.firstname
@@ -2254,7 +2237,7 @@ function _searchIndexConsultation() {
2254
2237
  }
2255
2238
 
2256
2239
  _context11.next = 15;
2257
- return oroClient.searchClient.index(consultUuid, terms);
2240
+ return oroClient.searchClient.index(consult.uuid, terms);
2258
2241
 
2259
2242
  case 15:
2260
2243
  case "end":
@@ -2263,7 +2246,7 @@ function _searchIndexConsultation() {
2263
2246
  }
2264
2247
  }, _callee11);
2265
2248
  }));
2266
- return _searchIndexConsultation.apply(this, arguments);
2249
+ return _buildConsultSearchIndex.apply(this, arguments);
2267
2250
  }
2268
2251
 
2269
2252
  /**
@@ -5737,5 +5720,5 @@ var init = function init(toolbox, tellerBaseURL, vaultBaseURL, guardBaseURL, sea
5737
5720
  };
5738
5721
 
5739
5722
  export default init;
5740
- export { AssociatedLockboxNotFound, CliniaService, IncompleteAuthentication, MissingGrant, MissingLockbox, MissingLockboxOwner, OroClient, WorkflowAnswersMissingError, decryptConsultLockboxGrants, decryptGrants, extractAndStorePersonalWorkflowData, extractISOLocalityForConsult, extractPersonalInfoFromConsultId, fillWorkflowFromPopulatedWorkflow, filterTriggeredAnsweredWithKind, flattenSelectedAnswers, getImagesFromIndexDb, getInitialisedSelectedAnswers, getWorkflowDataByCategory, identificationToPersonalInformations, isTriggered, registerPatient, searchIndexConsultation, sessionStorePrivateKeyName, toActualObject, updatePersonalIntoPopulatedWorkflowData, wasmPath };
5723
+ export { AssociatedLockboxNotFound, CliniaService, IncompleteAuthentication, MissingGrant, MissingLockbox, MissingLockboxOwner, OroClient, WorkflowAnswersMissingError, buildConsultSearchIndex, decryptConsultLockboxGrants, decryptGrants, extractAndStorePersonalWorkflowData, extractISOLocalityForConsult, extractPersonalInfoFromWorkflowData, fillWorkflowFromPopulatedWorkflow, filterTriggeredAnsweredWithKind, flattenSelectedAnswers, getImagesFromIndexDb, getInitialisedSelectedAnswers, getWorkflowDataByCategory, identificationToPersonalInformations, isTriggered, registerPatient, sessionStorePrivateKeyName, toActualObject, updatePersonalIntoPopulatedWorkflowData, wasmPath };
5741
5724
  //# sourceMappingURL=oro-sdk.esm.js.map