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.
@@ -1,4 +1,4 @@
1
- import { ConsultRequest, LocalizedData, MetadataCategory, PopulatedWorkflowData, Uuid, WorkflowData } from 'oro-sdk-apis';
1
+ import { Consult, ConsultRequest, MetadataCategory, PopulatedWorkflowData, Uuid, WorkflowData } from 'oro-sdk-apis';
2
2
  import { OroClient, RegisterPatientOutput } from '..';
3
3
  /**
4
4
  * Completes a registration for a user retrying the complete flow a maximum of 15 times
@@ -34,10 +34,19 @@ export declare function registerPatient(patientUuid: Uuid, consultRequest: Consu
34
34
  * @returns The data uuid
35
35
  */
36
36
  export declare function extractAndStorePersonalWorkflowData(workflow: WorkflowData, lockboxUuid: Uuid, consultationId: Uuid, category: MetadataCategory.Personal | MetadataCategory.ChildPersonal | MetadataCategory.OtherPersonal, oroClient: OroClient): Promise<Uuid | void>;
37
- export declare function extractPersonalInfoFromConsultId(consultUuid: string, oroClient: OroClient): Promise<{
38
- consultUuid: string;
39
- personalInformations: LocalizedData<PopulatedWorkflowData>;
40
- childPersonalInformations: LocalizedData<PopulatedWorkflowData>;
41
- otherPersonalInformations: LocalizedData<PopulatedWorkflowData>;
37
+ /**
38
+ * Given workflow data, it populates it with Personal, ChildPersonal, and OtherPersonal workflow data
39
+ * @param workflow
40
+ */
41
+ export declare function extractPersonalInfoFromWorkflowData(workflow: WorkflowData): Promise<{
42
+ personalInfoPopulatedWfData: PopulatedWorkflowData;
43
+ childPersonalInfoPopulatedWfData: PopulatedWorkflowData;
44
+ otherPersonalInfoPopulatedWfData: PopulatedWorkflowData;
42
45
  }>;
43
- export declare function searchIndexConsultation(consultUuid: string, oroClient: OroClient): Promise<void>;
46
+ /**
47
+ * Creates the search index for the first name, last name, and the short id of the given consultation
48
+ * @param consult the consultation to be search indexed
49
+ * @param workflow the workflow data
50
+ * @param oroClient
51
+ */
52
+ export declare function buildConsultSearchIndex(consult: Consult, workflow: WorkflowData, oroClient: OroClient): Promise<void>;
@@ -1808,24 +1808,27 @@ function _registerPatient() {
1808
1808
  return Promise.all([].concat(grantPromises, consultIndexPromises));
1809
1809
 
1810
1810
  case 43:
1811
+ _context3.next = 45;
1812
+ return buildConsultSearchIndex(consult, workflow, oroClient)["catch"](function (err) {
1813
+ console.error('[SDK: registration] personal information not found or another error occured during search indexing', err);
1814
+ 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
1815
+
1816
+ // this statement is to avoid failing the registration due to the failure in search indexing the consult, this practically implements a soft retry
1817
+ errorsThrown.push(err);
1818
+ });
1819
+
1820
+ case 45:
1811
1821
  if (!(errorsThrown.length > 0)) {
1812
- _context3.next = 45;
1822
+ _context3.next = 47;
1813
1823
  break;
1814
1824
  }
1815
1825
 
1816
1826
  throw errorsThrown;
1817
1827
 
1818
- case 45:
1819
- _context3.next = 47;
1820
- return oroClient.consultClient.updateConsultByUUID(consult.uuid, {
1821
- statusMedical: initApis.MedicalStatus.New
1822
- });
1823
-
1824
1828
  case 47:
1825
1829
  _context3.next = 49;
1826
- return searchIndexConsultation(consult.uuid, oroClient)["catch"](function (err) {
1827
- console.error('[SDK: registration] personal information not found or another error occured during search indexing', err);
1828
- errorsThrown.push(err);
1830
+ return oroClient.consultClient.updateConsultByUUID(consult.uuid, {
1831
+ statusMedical: initApis.MedicalStatus.New
1829
1832
  });
1830
1833
 
1831
1834
  case 49:
@@ -2115,6 +2118,10 @@ function _storeImageAliases() {
2115
2118
  function extractAndStorePersonalWorkflowData(_x19, _x20, _x21, _x22, _x23) {
2116
2119
  return _extractAndStorePersonalWorkflowData.apply(this, arguments);
2117
2120
  }
2121
+ /**
2122
+ * Given workflow data, it populates it with Personal, ChildPersonal, and OtherPersonal workflow data
2123
+ * @param workflow
2124
+ */
2118
2125
 
2119
2126
  function _extractAndStorePersonalWorkflowData() {
2120
2127
  _extractAndStorePersonalWorkflowData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(workflow, lockboxUuid, consultationId, category, oroClient) {
@@ -2141,55 +2148,30 @@ function _extractAndStorePersonalWorkflowData() {
2141
2148
  return _extractAndStorePersonalWorkflowData.apply(this, arguments);
2142
2149
  }
2143
2150
 
2144
- function extractPersonalInfoFromConsultId(_x24, _x25) {
2145
- return _extractPersonalInfoFromConsultId.apply(this, arguments);
2151
+ function extractPersonalInfoFromWorkflowData(_x24) {
2152
+ return _extractPersonalInfoFromWorkflowData.apply(this, arguments);
2146
2153
  }
2154
+ /**
2155
+ * Creates the search index for the first name, last name, and the short id of the given consultation
2156
+ * @param consult the consultation to be search indexed
2157
+ * @param workflow the workflow data
2158
+ * @param oroClient
2159
+ */
2147
2160
 
2148
- function _extractPersonalInfoFromConsultId() {
2149
- _extractPersonalInfoFromConsultId = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(consultUuid, oroClient) {
2161
+ function _extractPersonalInfoFromWorkflowData() {
2162
+ _extractPersonalInfoFromWorkflowData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(workflow) {
2150
2163
  return runtime_1.wrap(function _callee10$(_context10) {
2151
2164
  while (1) {
2152
2165
  switch (_context10.prev = _context10.next) {
2153
2166
  case 0:
2154
- return _context10.abrupt("return", Promise.all([// Retrieve MetadataCategory.Personal in any case
2155
- oroClient.getPersonalInformationsFromConsultId(consultUuid, initApis.MetadataCategory.Personal, true).then(function (personalInformations) {
2156
- if (!personalInformations[0]) {
2157
- console.error(initApis.MetadataCategory.Personal + " informations not found for consult:", consultUuid);
2158
- throw Error('No self personal information found');
2159
- }
2160
-
2161
- return personalInformations[0];
2162
- }), // Retrieve MetadataCategory.ChildPersonal in any case in parallel
2163
- oroClient.getPersonalInformationsFromConsultId(consultUuid, initApis.MetadataCategory.ChildPersonal, true).then(function (childInformations) {
2164
- if (!childInformations[0]) {
2165
- console.debug(initApis.MetadataCategory.ChildPersonal + " informations not found for consult:", consultUuid); // Retrieve MetadataCategory.OtherPersonal only if MetadataCategory.ChildPersonal does not exist
2166
-
2167
- // Retrieve MetadataCategory.OtherPersonal only if MetadataCategory.ChildPersonal does not exist
2168
- return oroClient.getPersonalInformationsFromConsultId(consultUuid, initApis.MetadataCategory.OtherPersonal, true).then(function (otherInformations) {
2169
- if (!otherInformations[0]) {
2170
- console.debug(initApis.MetadataCategory.OtherPersonal + " informations not found for consult:", consultUuid);
2171
- return {};
2172
- }
2173
-
2174
- return {
2175
- otherPersonalInformations: otherInformations[0]
2176
- };
2177
- });
2178
- }
2179
-
2167
+ return _context10.abrupt("return", Promise.all([getWorkflowDataByCategory(workflow, initApis.MetadataCategory.Personal), getWorkflowDataByCategory(workflow, initApis.MetadataCategory.ChildPersonal), getWorkflowDataByCategory(workflow, initApis.MetadataCategory.OtherPersonal)]).then(function (_ref3) {
2168
+ var personalInfoPopulatedWfData = _ref3[0],
2169
+ childPersonalInfoPopulatedWfData = _ref3[1],
2170
+ otherPersonalInfoPopulatedWfData = _ref3[2];
2180
2171
  return {
2181
- childPersonalInformations: childInformations[0]
2182
- };
2183
- })]).then(function (_ref3) {
2184
- var personalInformations = _ref3[0],
2185
- _ref3$ = _ref3[1],
2186
- childPersonalInformations = _ref3$.childPersonalInformations,
2187
- otherPersonalInformations = _ref3$.otherPersonalInformations;
2188
- return {
2189
- consultUuid: consultUuid,
2190
- personalInformations: personalInformations,
2191
- childPersonalInformations: childPersonalInformations,
2192
- otherPersonalInformations: otherPersonalInformations
2172
+ personalInfoPopulatedWfData: personalInfoPopulatedWfData,
2173
+ childPersonalInfoPopulatedWfData: childPersonalInfoPopulatedWfData,
2174
+ otherPersonalInfoPopulatedWfData: otherPersonalInfoPopulatedWfData
2193
2175
  };
2194
2176
  }));
2195
2177
 
@@ -2200,33 +2182,36 @@ function _extractPersonalInfoFromConsultId() {
2200
2182
  }
2201
2183
  }, _callee10);
2202
2184
  }));
2203
- return _extractPersonalInfoFromConsultId.apply(this, arguments);
2185
+ return _extractPersonalInfoFromWorkflowData.apply(this, arguments);
2204
2186
  }
2205
2187
 
2206
- function searchIndexConsultation(_x26, _x27) {
2207
- return _searchIndexConsultation.apply(this, arguments);
2188
+ function buildConsultSearchIndex(_x25, _x26, _x27) {
2189
+ return _buildConsultSearchIndex.apply(this, arguments);
2208
2190
  }
2209
2191
 
2210
- function _searchIndexConsultation() {
2211
- _searchIndexConsultation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(consultUuid, oroClient) {
2212
- var terms, _yield$extractPersona, personalInformations, childPersonalInformations, otherPersonalInformations, personalInfo, childPersonalInfo, otherPersonalInfo;
2192
+ function _buildConsultSearchIndex() {
2193
+ _buildConsultSearchIndex = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(consult, workflow, oroClient) {
2194
+ var terms, _yield$extractPersona, personalInfoPopulatedWfData, childPersonalInfoPopulatedWfData, otherPersonalInfoPopulatedWfData, personalInfo, childPersonalInfo, otherPersonalInfo;
2213
2195
 
2214
2196
  return runtime_1.wrap(function _callee11$(_context11) {
2215
2197
  while (1) {
2216
2198
  switch (_context11.prev = _context11.next) {
2217
2199
  case 0:
2218
- terms = [];
2219
- console.log('here');
2220
- _context11.next = 4;
2221
- return extractPersonalInfoFromConsultId(consultUuid, oroClient);
2200
+ terms = [{
2201
+ kind: 'consult-shortid',
2202
+ value: consult.shortId
2203
+ }];
2204
+ _context11.next = 3;
2205
+ return extractPersonalInfoFromWorkflowData(workflow);
2222
2206
 
2223
- case 4:
2207
+ case 3:
2224
2208
  _yield$extractPersona = _context11.sent;
2225
- personalInformations = _yield$extractPersona.personalInformations;
2226
- childPersonalInformations = _yield$extractPersona.childPersonalInformations;
2227
- otherPersonalInformations = _yield$extractPersona.otherPersonalInformations;
2228
- console.log('personal=', personalInformations, 'child=', childPersonalInformations, 'other=', otherPersonalInformations);
2229
- personalInfo = identificationToPersonalInformations(toActualObject(personalInformations.data), initApis.MetadataCategory.Personal);
2209
+ personalInfoPopulatedWfData = _yield$extractPersona.personalInfoPopulatedWfData;
2210
+ childPersonalInfoPopulatedWfData = _yield$extractPersona.childPersonalInfoPopulatedWfData;
2211
+ otherPersonalInfoPopulatedWfData = _yield$extractPersona.otherPersonalInfoPopulatedWfData;
2212
+ personalInfo = identificationToPersonalInformations(toActualObject(personalInfoPopulatedWfData), initApis.MetadataCategory.Personal);
2213
+ childPersonalInfo = identificationToPersonalInformations(toActualObject(childPersonalInfoPopulatedWfData), initApis.MetadataCategory.ChildPersonal);
2214
+ otherPersonalInfo = identificationToPersonalInformations(toActualObject(otherPersonalInfoPopulatedWfData), initApis.MetadataCategory.OtherPersonal);
2230
2215
  terms.push({
2231
2216
  kind: 'first-name',
2232
2217
  value: personalInfo.firstname
@@ -2235,8 +2220,7 @@ function _searchIndexConsultation() {
2235
2220
  value: personalInfo.name
2236
2221
  });
2237
2222
 
2238
- if (childPersonalInformations) {
2239
- childPersonalInfo = identificationToPersonalInformations(toActualObject(childPersonalInformations.data), initApis.MetadataCategory.ChildPersonal);
2223
+ if (childPersonalInfo.firstname && childPersonalInfo.name) {
2240
2224
  terms.push({
2241
2225
  kind: 'first-name',
2242
2226
  value: childPersonalInfo.firstname
@@ -2246,8 +2230,7 @@ function _searchIndexConsultation() {
2246
2230
  });
2247
2231
  }
2248
2232
 
2249
- if (otherPersonalInformations) {
2250
- otherPersonalInfo = identificationToPersonalInformations(toActualObject(otherPersonalInformations.data), initApis.MetadataCategory.OtherPersonal);
2233
+ if (otherPersonalInfo.firstname && otherPersonalInfo.name) {
2251
2234
  terms.push({
2252
2235
  kind: 'first-name',
2253
2236
  value: otherPersonalInfo.firstname
@@ -2258,7 +2241,7 @@ function _searchIndexConsultation() {
2258
2241
  }
2259
2242
 
2260
2243
  _context11.next = 15;
2261
- return oroClient.searchClient.index(consultUuid, terms);
2244
+ return oroClient.searchClient.index(consult.uuid, terms);
2262
2245
 
2263
2246
  case 15:
2264
2247
  case "end":
@@ -2267,7 +2250,7 @@ function _searchIndexConsultation() {
2267
2250
  }
2268
2251
  }, _callee11);
2269
2252
  }));
2270
- return _searchIndexConsultation.apply(this, arguments);
2253
+ return _buildConsultSearchIndex.apply(this, arguments);
2271
2254
  }
2272
2255
 
2273
2256
  /**
@@ -5757,12 +5740,13 @@ exports.MissingLockbox = MissingLockbox;
5757
5740
  exports.MissingLockboxOwner = MissingLockboxOwner;
5758
5741
  exports.OroClient = OroClient;
5759
5742
  exports.WorkflowAnswersMissingError = WorkflowAnswersMissingError;
5743
+ exports.buildConsultSearchIndex = buildConsultSearchIndex;
5760
5744
  exports.decryptConsultLockboxGrants = decryptConsultLockboxGrants;
5761
5745
  exports.decryptGrants = decryptGrants;
5762
5746
  exports.default = init;
5763
5747
  exports.extractAndStorePersonalWorkflowData = extractAndStorePersonalWorkflowData;
5764
5748
  exports.extractISOLocalityForConsult = extractISOLocalityForConsult;
5765
- exports.extractPersonalInfoFromConsultId = extractPersonalInfoFromConsultId;
5749
+ exports.extractPersonalInfoFromWorkflowData = extractPersonalInfoFromWorkflowData;
5766
5750
  exports.fillWorkflowFromPopulatedWorkflow = fillWorkflowFromPopulatedWorkflow;
5767
5751
  exports.filterTriggeredAnsweredWithKind = filterTriggeredAnsweredWithKind;
5768
5752
  exports.flattenSelectedAnswers = flattenSelectedAnswers;
@@ -5772,7 +5756,6 @@ exports.getWorkflowDataByCategory = getWorkflowDataByCategory;
5772
5756
  exports.identificationToPersonalInformations = identificationToPersonalInformations;
5773
5757
  exports.isTriggered = isTriggered;
5774
5758
  exports.registerPatient = registerPatient;
5775
- exports.searchIndexConsultation = searchIndexConsultation;
5776
5759
  exports.sessionStorePrivateKeyName = sessionStorePrivateKeyName;
5777
5760
  exports.toActualObject = toActualObject;
5778
5761
  exports.updatePersonalIntoPopulatedWorkflowData = updatePersonalIntoPopulatedWorkflowData;