oro-sdk 2.10.1 → 2.12.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.
@@ -1537,112 +1537,139 @@ function fillWorkflowFromPopulatedWorkflow(workflow, populatedWorkflow) {
1537
1537
  }
1538
1538
 
1539
1539
  var MAX_RETRIES = 15;
1540
+ /**
1541
+ * Completes a registration for a user retrying the complete flow a maximum of 15 times
1542
+ *
1543
+ * @description The order of importance when registering:
1544
+ * Creates a consultation if none exist
1545
+ * Retrieves or create's a lockbox if none exist
1546
+ * Grants the lockbox (if new) to all practitioners in the practice
1547
+ * Stores or fetches the patient data (without images)
1548
+ * Indexes the lockbox to the consult for all practitioners (done after inserting since index can be rebuilt from grants)
1549
+ * Stores the image data - done last since the majority of failure cases occur here
1550
+ * Creates the recovery payloads if they don't exist
1551
+ *
1552
+ * @param patientUuid
1553
+ * @param consultRequest
1554
+ * @param workflow
1555
+ * @param oroClient
1556
+ * @param masterKey
1557
+ * @param recoveryQA
1558
+ * @returns the successful registration
1559
+ */
1560
+
1540
1561
  function registerPatient(_x, _x2, _x3, _x4, _x5, _x6) {
1541
1562
  return _registerPatient.apply(this, arguments);
1542
1563
  }
1543
1564
  /**
1544
- * Returns whether the consultation creation is for an existing patient (ignores data from the current consultation)
1545
- *
1546
- * @param currentConsultation
1565
+ * Creates a consultation if one has not been created and fails to be retrieved by the payment intent
1566
+ * @param consult
1567
+ * @param oroClient
1568
+ * @returns the consult Uuid
1547
1569
  */
1548
1570
 
1549
1571
  function _registerPatient() {
1550
- _registerPatient = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(patientUuid, consultRequest, workflow, oroClient, masterKey, recoveryQA) {
1551
- var consult, lockboxUuid, practitionerAdmin, retry, isExistingPatient, _ret;
1572
+ _registerPatient = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(patientUuid, consultRequest, workflow, oroClient, masterKey, recoveryQA) {
1573
+ var consult, lockboxUuid, practitionerAdmin, retry, identity, errorsThrown, _ret;
1552
1574
 
1553
- return runtime_1.wrap(function _callee5$(_context5) {
1575
+ return runtime_1.wrap(function _callee4$(_context4) {
1554
1576
  while (1) {
1555
- switch (_context5.prev = _context5.next) {
1577
+ switch (_context4.prev = _context4.next) {
1556
1578
  case 0:
1557
1579
  consult = undefined;
1558
1580
  lockboxUuid = undefined;
1559
1581
  practitionerAdmin = undefined;
1560
1582
  retry = MAX_RETRIES;
1561
- isExistingPatient = false;
1583
+ identity = undefined;
1584
+ errorsThrown = [];
1562
1585
 
1563
- case 5:
1586
+ case 6:
1564
1587
  if (!(retry > 0)) {
1565
- _context5.next = 20;
1588
+ _context4.next = 22;
1566
1589
  break;
1567
1590
  }
1568
1591
 
1569
- _context5.prev = 6;
1570
- return _context5.delegateYield( /*#__PURE__*/runtime_1.mark(function _callee4() {
1571
- var _consultIndex, _deprecatedConsultInd;
1592
+ _context4.prev = 7;
1593
+ return _context4.delegateYield( /*#__PURE__*/runtime_1.mark(function _callee3() {
1594
+ var _consultIndex, _identity, _identity2;
1572
1595
 
1573
- var practitioners, grantPromises, consultIndex, consultIndexPromises, deprecatedConsultIndex, deprecatedConsultIndexPromises;
1574
- return runtime_1.wrap(function _callee4$(_context4) {
1596
+ var practitioners, grantPromises, consultIndex, consultIndexPromises;
1597
+ return runtime_1.wrap(function _callee3$(_context3) {
1575
1598
  while (1) {
1576
- switch (_context4.prev = _context4.next) {
1599
+ switch (_context3.prev = _context3.next) {
1577
1600
  case 0:
1578
- _context4.next = 2;
1601
+ _context3.next = 2;
1579
1602
  return new Promise(function (resolve) {
1580
1603
  return setTimeout(resolve, 2000);
1581
1604
  });
1582
1605
 
1583
1606
  case 2:
1584
1607
  if (practitionerAdmin) {
1585
- _context4.next = 6;
1608
+ _context3.next = 6;
1586
1609
  break;
1587
1610
  }
1588
1611
 
1589
- _context4.next = 5;
1612
+ _context3.next = 5;
1590
1613
  return oroClient.practiceClient.practiceGetFromUuid(consultRequest.uuidPractice);
1591
1614
 
1592
1615
  case 5:
1593
- practitionerAdmin = _context4.sent.uuidAdmin;
1616
+ practitionerAdmin = _context3.sent.uuidAdmin;
1594
1617
 
1595
1618
  case 6:
1596
- _context4.next = 8;
1619
+ _context3.next = 8;
1597
1620
  return oroClient.practiceClient.practiceGetPractitioners(consultRequest.uuidPractice)["catch"](function (err) {
1598
1621
  console.log("Error retrieving practitioners", err);
1599
1622
  return [];
1600
1623
  });
1601
1624
 
1602
1625
  case 8:
1603
- practitioners = _context4.sent;
1626
+ practitioners = _context3.sent;
1604
1627
 
1605
1628
  if (consult) {
1606
- _context4.next = 13;
1629
+ _context3.next = 13;
1607
1630
  break;
1608
1631
  }
1609
1632
 
1610
- _context4.next = 12;
1633
+ _context3.next = 12;
1611
1634
  return getOrCreatePatientConsultationUuid(consultRequest, oroClient);
1612
1635
 
1613
1636
  case 12:
1614
- consult = _context4.sent;
1637
+ consult = _context3.sent;
1615
1638
 
1616
1639
  case 13:
1617
1640
  if (lockboxUuid) {
1618
- _context4.next = 17;
1641
+ _context3.next = 17;
1619
1642
  break;
1620
1643
  }
1621
1644
 
1622
- _context4.next = 16;
1645
+ _context3.next = 16;
1623
1646
  return getOrCreatePatientLockbox(oroClient);
1624
1647
 
1625
1648
  case 16:
1626
- lockboxUuid = _context4.sent;
1649
+ lockboxUuid = _context3.sent;
1627
1650
 
1628
1651
  case 17:
1629
- _context4.next = 19;
1630
- return patientConsultExists(consult, lockboxUuid, oroClient)["catch"](function (err) {
1631
- console.error("Error when retrieving existing consults " + err);
1632
- return false;
1633
- });
1652
+ if (identity) {
1653
+ _context3.next = 21;
1654
+ break;
1655
+ }
1656
+
1657
+ _context3.next = 20;
1658
+ return oroClient.guardClient.identityGet(patientUuid);
1634
1659
 
1635
- case 19:
1636
- isExistingPatient = _context4.sent;
1637
- _context4.next = 22;
1660
+ case 20:
1661
+ identity = _context3.sent;
1662
+
1663
+ case 21:
1664
+ _context3.next = 23;
1638
1665
  return oroClient.grantLockbox(practitionerAdmin, lockboxUuid)["catch"](function (err) {
1639
1666
  console.error("Error while granting lockbox to practitioner admin " + practitionerAdmin, err); // if we cannot grant to the admin, then the registration will fail
1640
1667
 
1641
1668
  // if we cannot grant to the admin, then the registration will fail
1642
- throw err;
1669
+ errorsThrown.push(err);
1643
1670
  });
1644
1671
 
1645
- case 22:
1672
+ case 23:
1646
1673
  // Patient Grant to practice
1647
1674
  grantPromises = practitioners.filter(function (practitioner) {
1648
1675
  return practitioner.uuid !== practitionerAdmin;
@@ -1653,10 +1680,11 @@ function _registerPatient() {
1653
1680
  switch (_context.prev = _context.next) {
1654
1681
  case 0:
1655
1682
  return _context.abrupt("return", oroClient.grantLockbox(practitioner.uuid, lockboxUuid)["catch"](function (err) {
1656
- console.error("Error while granting lockbox to practitioner", err); // Acceptable to continue as admin has already been granted, but we should still try to retry
1683
+ console.error("Error while granting lockbox to practitioner", err); // Acceptable to continue as admin has already been granted, but we should still retry until the last retry remains
1657
1684
 
1658
- // Acceptable to continue as admin has already been granted, but we should still try to retry
1659
- if (retry <= 1) return;else throw err;
1685
+ // Acceptable to continue as admin has already been granted, but we should still retry until the last retry remains
1686
+ if (retry <= 1) return;
1687
+ errorsThrown.push(err);
1660
1688
  }));
1661
1689
 
1662
1690
  case 1:
@@ -1667,22 +1695,18 @@ function _registerPatient() {
1667
1695
  }, _callee);
1668
1696
  }));
1669
1697
 
1670
- return function (_x27) {
1698
+ return function (_x24) {
1671
1699
  return _ref.apply(this, arguments);
1672
1700
  };
1673
1701
  }());
1674
- _context4.next = 25;
1675
- return storePatientData(consult.uuid, consultRequest.isoLanguageRequired, lockboxUuid, workflow, oroClient);
1676
-
1677
- case 25:
1678
- // the index will identify in which lockbox a consultation live
1679
1702
  consultIndex = (_consultIndex = {}, _consultIndex[IndexKey.ConsultationLockbox] = [{
1680
1703
  grant: {
1681
1704
  lockboxUuid: lockboxUuid,
1682
1705
  lockboxOwnerUuid: patientUuid
1683
1706
  },
1684
1707
  consultationId: consult.uuid
1685
- }], _consultIndex);
1708
+ }], _consultIndex); // the index will identify in which lockbox a consultation resides
1709
+
1686
1710
  consultIndexPromises = practitioners.map( /*#__PURE__*/function () {
1687
1711
  var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(practitioner) {
1688
1712
  return runtime_1.wrap(function _callee2$(_context2) {
@@ -1690,10 +1714,10 @@ function _registerPatient() {
1690
1714
  switch (_context2.prev = _context2.next) {
1691
1715
  case 0:
1692
1716
  return _context2.abrupt("return", oroClient.vaultIndexAdd(consultIndex, practitioner.uuid)["catch"](function (err) {
1693
- console.error("Error while adding to the practitioner's index " + practitioner.uuid, err); /// it's acceptable to continue registration
1717
+ console.error("[SDK: registration] Error while adding to the practitioner's index " + practitioner.uuid, err); // Acceptable to continue as the index can be rebuilt, but we should still retry until the last retry remains
1694
1718
 
1695
- /// it's acceptable to continue registration
1696
- return;
1719
+ // Acceptable to continue as the index can be rebuilt, but we should still retry until the last retry remains
1720
+ if (retry <= 1) return;else errorsThrown.push(err);
1697
1721
  }));
1698
1722
 
1699
1723
  case 1:
@@ -1704,198 +1728,156 @@ function _registerPatient() {
1704
1728
  }, _callee2);
1705
1729
  }));
1706
1730
 
1707
- return function (_x28) {
1731
+ return function (_x25) {
1708
1732
  return _ref2.apply(this, arguments);
1709
1733
  };
1710
- }()); //DEPRECATED: REMOVE ME : BEGIN /////////////////////////////////////////
1711
-
1712
- deprecatedConsultIndex = (_deprecatedConsultInd = {}, _deprecatedConsultInd[IndexKey.Consultation] = [{
1713
- grant: {
1714
- lockboxUuid: lockboxUuid,
1715
- lockboxOwnerUuid: patientUuid
1716
- },
1717
- consultationId: consult.uuid
1718
- }], _deprecatedConsultInd);
1719
- deprecatedConsultIndexPromises = practitioners.map( /*#__PURE__*/function () {
1720
- var _ref3 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(practitioner) {
1721
- return runtime_1.wrap(function _callee3$(_context3) {
1722
- while (1) {
1723
- switch (_context3.prev = _context3.next) {
1724
- case 0:
1725
- return _context3.abrupt("return", oroClient.vaultIndexAdd(deprecatedConsultIndex, practitioner.uuid)["catch"](function (err) {
1726
- console.error("Error while adding to the practitioner's index " + practitioner.uuid, err); /// it's acceptable to continue registration
1727
-
1728
- /// it's acceptable to continue registration
1729
- return;
1730
- }));
1734
+ }());
1735
+ _context3.next = 28;
1736
+ return storeImageAliases(consult.uuid, lockboxUuid, workflow, oroClient)["catch"](function (err) {
1737
+ console.error('[SDK: registration] Some errors happened during image upload', err); // Acceptable to continue as images can be requested during the consultation, but we should still retry until the last retry remains
1731
1738
 
1732
- case 1:
1733
- case "end":
1734
- return _context3.stop();
1735
- }
1736
- }
1737
- }, _callee3);
1738
- }));
1739
+ // Acceptable to continue as images can be requested during the consultation, but we should still retry until the last retry remains
1740
+ if (retry <= 1) return;else errorsThrown.push(err);
1741
+ });
1739
1742
 
1740
- return function (_x29) {
1741
- return _ref3.apply(this, arguments);
1742
- };
1743
- }()); //DEPRECATED: REMOVE ME : END /////////////////////////////////////////
1743
+ case 28:
1744
+ _context3.next = 30;
1745
+ return storePatientData(consult.uuid, consultRequest.isoLanguageRequired, lockboxUuid, workflow, oroClient)["catch"](function (err) {
1746
+ console.error('[SDK: registration] Some errors happened during patient data upload', err);
1747
+ errorsThrown.push(err);
1748
+ });
1744
1749
 
1745
- if (!(masterKey && !isExistingPatient)) {
1746
- _context4.next = 34;
1750
+ case 30:
1751
+ if (!(masterKey && !((_identity = identity) != null && _identity.recoveryMasterKey))) {
1752
+ _context3.next = 36;
1747
1753
  break;
1748
1754
  }
1749
1755
 
1750
- _context4.next = 32;
1756
+ _context3.next = 33;
1751
1757
  return oroClient.updateMasterKey(patientUuid, masterKey, lockboxUuid)["catch"](function (err) {
1752
- console.error("Error while updating master key", err); /// it's acceptable to continue registration
1758
+ console.error("[SDK: registration] Error while updating master key", err); /// it's acceptable to continue registration (return old identity)
1753
1759
 
1754
- /// it's acceptable to continue registration
1755
- return;
1760
+ /// it's acceptable to continue registration (return old identity)
1761
+ if (retry <= 1) return;
1762
+ errorsThrown.push(err);
1763
+ return identity;
1756
1764
  });
1757
1765
 
1758
- case 32:
1759
- _context4.next = 35;
1766
+ case 33:
1767
+ identity = _context3.sent;
1768
+ _context3.next = 37;
1760
1769
  break;
1761
1770
 
1762
- case 34:
1771
+ case 36:
1763
1772
  // we did not set the master key so we do not return it
1764
1773
  masterKey = undefined;
1765
1774
 
1766
- case 35:
1767
- if (!(recoveryQA && !isExistingPatient)) {
1768
- _context4.next = 38;
1775
+ case 37:
1776
+ if (!(recoveryQA && !((_identity2 = identity) != null && _identity2.recoverySecurityQuestions))) {
1777
+ _context3.next = 41;
1769
1778
  break;
1770
1779
  }
1771
1780
 
1772
- _context4.next = 38;
1781
+ _context3.next = 40;
1773
1782
  return oroClient.updateSecurityQuestions(patientUuid, recoveryQA.recoverySecurityQuestions, recoveryQA.recoverySecurityAnswers, 2)["catch"](function (err) {
1774
- console.error("Error while updating security questions", err); /// it's acceptable to continue registration
1783
+ console.error("[SDK: registration] Error while updating security questions", err); /// it's acceptable to continue registration (return old identity)
1775
1784
 
1776
- /// it's acceptable to continue registration
1777
- return;
1785
+ /// it's acceptable to continue registration (return old identity)
1786
+ if (retry <= 1) return;
1787
+ errorsThrown.push(err);
1788
+ return identity;
1778
1789
  });
1779
1790
 
1780
- case 38:
1781
- _context4.next = 40;
1782
- return Promise.all([].concat(grantPromises, consultIndexPromises, deprecatedConsultIndexPromises));
1783
-
1784
1791
  case 40:
1785
- _context4.next = 42;
1792
+ identity = _context3.sent;
1793
+
1794
+ case 41:
1795
+ _context3.next = 43;
1796
+ return Promise.all([].concat(grantPromises, consultIndexPromises));
1797
+
1798
+ case 43:
1799
+ if (!(errorsThrown.length > 0)) {
1800
+ _context3.next = 45;
1801
+ break;
1802
+ }
1803
+
1804
+ throw errorsThrown;
1805
+
1806
+ case 45:
1807
+ _context3.next = 47;
1786
1808
  return oroClient.consultClient.updateConsultByUUID(consult.uuid, {
1787
1809
  statusMedical: MedicalStatus.New
1788
1810
  });
1789
1811
 
1790
- case 42:
1791
- return _context4.abrupt("return", "break");
1812
+ case 47:
1813
+ return _context3.abrupt("return", "break");
1792
1814
 
1793
- case 43:
1815
+ case 48:
1794
1816
  case "end":
1795
- return _context4.stop();
1817
+ return _context3.stop();
1796
1818
  }
1797
1819
  }
1798
- }, _callee4);
1799
- })(), "t0", 8);
1820
+ }, _callee3);
1821
+ })(), "t0", 9);
1800
1822
 
1801
- case 8:
1802
- _ret = _context5.t0;
1823
+ case 9:
1824
+ _ret = _context4.t0;
1803
1825
 
1804
1826
  if (!(_ret === "break")) {
1805
- _context5.next = 11;
1827
+ _context4.next = 12;
1806
1828
  break;
1807
1829
  }
1808
1830
 
1809
- return _context5.abrupt("break", 20);
1831
+ return _context4.abrupt("break", 22);
1810
1832
 
1811
- case 11:
1812
- _context5.next = 17;
1833
+ case 12:
1834
+ _context4.next = 19;
1813
1835
  break;
1814
1836
 
1815
- case 13:
1816
- _context5.prev = 13;
1817
- _context5.t1 = _context5["catch"](6);
1818
- console.error("Error occured during registration, retrying... Retries remaining: " + retry);
1819
- return _context5.abrupt("continue", 17);
1837
+ case 14:
1838
+ _context4.prev = 14;
1839
+ _context4.t1 = _context4["catch"](7);
1840
+ console.error("[SDK] Error occured during registration: " + _context4.t1 + ", retrying... Retries remaining: " + retry);
1841
+ errorsThrown = [];
1842
+ return _context4.abrupt("continue", 19);
1820
1843
 
1821
- case 17:
1844
+ case 19:
1822
1845
  retry--;
1823
- _context5.next = 5;
1846
+ _context4.next = 6;
1824
1847
  break;
1825
1848
 
1826
- case 20:
1849
+ case 22:
1827
1850
  if (!(retry <= 0)) {
1828
- _context5.next = 23;
1851
+ _context4.next = 25;
1829
1852
  break;
1830
1853
  }
1831
1854
 
1832
- console.error('registration failed: MAX_RETRIES reached');
1855
+ console.error('[SDK] registration failed: MAX_RETRIES reached');
1833
1856
  throw 'RegistrationFailed';
1834
1857
 
1835
- case 23:
1858
+ case 25:
1836
1859
  console.log('Successfully Registered');
1837
- _context5.next = 26;
1860
+ _context4.next = 28;
1838
1861
  return oroClient.cleanIndex();
1839
1862
 
1840
- case 26:
1841
- return _context5.abrupt("return", {
1863
+ case 28:
1864
+ return _context4.abrupt("return", {
1842
1865
  masterKey: masterKey,
1843
1866
  consultationId: consult.uuid,
1844
1867
  lockboxUuid: lockboxUuid
1845
1868
  });
1846
1869
 
1847
- case 27:
1870
+ case 29:
1848
1871
  case "end":
1849
- return _context5.stop();
1872
+ return _context4.stop();
1850
1873
  }
1851
1874
  }
1852
- }, _callee5, null, [[6, 13]]);
1875
+ }, _callee4, null, [[7, 14]]);
1853
1876
  }));
1854
1877
  return _registerPatient.apply(this, arguments);
1855
1878
  }
1856
1879
 
1857
- function patientConsultExists(_x7, _x8, _x9) {
1858
- return _patientConsultExists.apply(this, arguments);
1859
- }
1860
- /**
1861
- * Creates a consultation if one has not been created and fails to be retrieved by the payment intent
1862
- * @param consult
1863
- * @param oroClient
1864
- * @returns the consult Uuid
1865
- */
1866
-
1867
-
1868
- function _patientConsultExists() {
1869
- _patientConsultExists = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(currentConsultation, lockboxUuid, oroClient) {
1870
- var publicMetadata, manifest;
1871
- return runtime_1.wrap(function _callee6$(_context6) {
1872
- while (1) {
1873
- switch (_context6.prev = _context6.next) {
1874
- case 0:
1875
- publicMetadata = {
1876
- category: MetadataCategory.Consultation,
1877
- documentType: DocumentType.PopulatedWorkflowData
1878
- };
1879
- _context6.next = 3;
1880
- return oroClient.vaultClient.lockboxMetadataGet(lockboxUuid, ['consultationId'], [], publicMetadata);
1881
-
1882
- case 3:
1883
- manifest = _context6.sent;
1884
- return _context6.abrupt("return", manifest[0].findIndex(function (v) {
1885
- return v.consultationId != null && v.consultationId !== currentConsultation.uuid;
1886
- }) !== -1);
1887
-
1888
- case 5:
1889
- case "end":
1890
- return _context6.stop();
1891
- }
1892
- }
1893
- }, _callee6);
1894
- }));
1895
- return _patientConsultExists.apply(this, arguments);
1896
- }
1897
-
1898
- function getOrCreatePatientConsultationUuid(_x10, _x11) {
1880
+ function getOrCreatePatientConsultationUuid(_x7, _x8) {
1899
1881
  return _getOrCreatePatientConsultationUuid.apply(this, arguments);
1900
1882
  }
1901
1883
  /**
@@ -1906,49 +1888,49 @@ function getOrCreatePatientConsultationUuid(_x10, _x11) {
1906
1888
 
1907
1889
 
1908
1890
  function _getOrCreatePatientConsultationUuid() {
1909
- _getOrCreatePatientConsultationUuid = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(consult, oroClient) {
1891
+ _getOrCreatePatientConsultationUuid = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(consult, oroClient) {
1910
1892
  var payment;
1911
- return runtime_1.wrap(function _callee7$(_context7) {
1893
+ return runtime_1.wrap(function _callee5$(_context5) {
1912
1894
  while (1) {
1913
- switch (_context7.prev = _context7.next) {
1895
+ switch (_context5.prev = _context5.next) {
1914
1896
  case 0:
1915
- _context7.next = 2;
1897
+ _context5.next = 2;
1916
1898
  return oroClient.practiceClient.practiceGetPayment(consult.uuidPractice, consult.idStripeInvoiceOrPaymentIntent);
1917
1899
 
1918
1900
  case 2:
1919
- payment = _context7.sent;
1901
+ payment = _context5.sent;
1920
1902
 
1921
1903
  if (!(payment && payment.uuidConsult)) {
1922
- _context7.next = 7;
1904
+ _context5.next = 7;
1923
1905
  break;
1924
1906
  }
1925
1907
 
1926
- return _context7.abrupt("return", oroClient.consultClient.getConsultByUUID(payment.uuidConsult)["catch"](function (err) {
1908
+ return _context5.abrupt("return", oroClient.consultClient.getConsultByUUID(payment.uuidConsult)["catch"](function (err) {
1927
1909
  console.error('Error while retrieving consult', err);
1928
1910
  throw err;
1929
1911
  }));
1930
1912
 
1931
1913
  case 7:
1932
- _context7.next = 9;
1914
+ _context5.next = 9;
1933
1915
  return oroClient.consultClient.consultCreate(consult)["catch"](function (err) {
1934
1916
  console.error('Error while creating consult', err);
1935
1917
  throw err;
1936
1918
  });
1937
1919
 
1938
1920
  case 9:
1939
- return _context7.abrupt("return", _context7.sent);
1921
+ return _context5.abrupt("return", _context5.sent);
1940
1922
 
1941
1923
  case 10:
1942
1924
  case "end":
1943
- return _context7.stop();
1925
+ return _context5.stop();
1944
1926
  }
1945
1927
  }
1946
- }, _callee7);
1928
+ }, _callee5);
1947
1929
  }));
1948
1930
  return _getOrCreatePatientConsultationUuid.apply(this, arguments);
1949
1931
  }
1950
1932
 
1951
- function getOrCreatePatientLockbox(_x12) {
1933
+ function getOrCreatePatientLockbox(_x9) {
1952
1934
  return _getOrCreatePatientLockbox.apply(this, arguments);
1953
1935
  }
1954
1936
  /**
@@ -1963,59 +1945,57 @@ function getOrCreatePatientLockbox(_x12) {
1963
1945
 
1964
1946
 
1965
1947
  function _getOrCreatePatientLockbox() {
1966
- _getOrCreatePatientLockbox = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(oroClient) {
1948
+ _getOrCreatePatientLockbox = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(oroClient) {
1967
1949
  var grants;
1968
- return runtime_1.wrap(function _callee8$(_context8) {
1950
+ return runtime_1.wrap(function _callee6$(_context6) {
1969
1951
  while (1) {
1970
- switch (_context8.prev = _context8.next) {
1952
+ switch (_context6.prev = _context6.next) {
1971
1953
  case 0:
1972
- _context8.next = 2;
1954
+ _context6.next = 2;
1973
1955
  return oroClient.getGrants(undefined, true);
1974
1956
 
1975
1957
  case 2:
1976
- grants = _context8.sent;
1958
+ grants = _context6.sent;
1977
1959
 
1978
1960
  if (!(grants.length > 0)) {
1979
- _context8.next = 8;
1961
+ _context6.next = 8;
1980
1962
  break;
1981
1963
  }
1982
1964
 
1983
1965
  console.log('The grant has already been created, skipping lockbox create step');
1984
- return _context8.abrupt("return", grants[0].lockboxUuid);
1966
+ return _context6.abrupt("return", grants[0].lockboxUuid);
1985
1967
 
1986
1968
  case 8:
1987
- _context8.next = 10;
1969
+ _context6.next = 10;
1988
1970
  return oroClient.vaultClient.lockboxCreate()["catch"](function (err) {
1989
1971
  console.error('Error while creating lockbox', err);
1990
1972
  throw err;
1991
1973
  });
1992
1974
 
1993
1975
  case 10:
1994
- return _context8.abrupt("return", _context8.sent.lockboxUuid);
1976
+ return _context6.abrupt("return", _context6.sent.lockboxUuid);
1995
1977
 
1996
1978
  case 11:
1997
1979
  case "end":
1998
- return _context8.stop();
1980
+ return _context6.stop();
1999
1981
  }
2000
1982
  }
2001
- }, _callee8);
1983
+ }, _callee6);
2002
1984
  }));
2003
1985
  return _getOrCreatePatientLockbox.apply(this, arguments);
2004
1986
  }
2005
1987
 
2006
- function storePatientData(_x13, _x14, _x15, _x16, _x17) {
1988
+ function storePatientData(_x10, _x11, _x12, _x13, _x14) {
2007
1989
  return _storePatientData.apply(this, arguments);
2008
1990
  }
2009
1991
 
2010
1992
  function _storePatientData() {
2011
- _storePatientData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(consultationId, isoLanguage, lockboxUuid, workflow, oroClient) {
2012
- return runtime_1.wrap(function _callee9$(_context9) {
1993
+ _storePatientData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(consultationId, isoLanguage, lockboxUuid, workflow, oroClient) {
1994
+ return runtime_1.wrap(function _callee7$(_context7) {
2013
1995
  while (1) {
2014
- switch (_context9.prev = _context9.next) {
1996
+ switch (_context7.prev = _context7.next) {
2015
1997
  case 0:
2016
- return _context9.abrupt("return", Promise.all([storeImageAliases(consultationId, lockboxUuid, workflow, oroClient)["catch"](function (err) {
2017
- console.error('[SDK] Some errors happened during image upload', err);
2018
- }), // Storing Raw data first
1998
+ return _context7.abrupt("return", Promise.all([// Storing Raw data first
2019
1999
  oroClient.getOrInsertJsonData(lockboxUuid, workflow, {
2020
2000
  category: MetadataCategory.Raw,
2021
2001
  contentType: 'application/json',
@@ -2045,15 +2025,15 @@ function _storePatientData() {
2045
2025
 
2046
2026
  case 1:
2047
2027
  case "end":
2048
- return _context9.stop();
2028
+ return _context7.stop();
2049
2029
  }
2050
2030
  }
2051
- }, _callee9);
2031
+ }, _callee7);
2052
2032
  }));
2053
2033
  return _storePatientData.apply(this, arguments);
2054
2034
  }
2055
2035
 
2056
- function storeImageAliases(_x18, _x19, _x20, _x21) {
2036
+ function storeImageAliases(_x15, _x16, _x17, _x18) {
2057
2037
  return _storeImageAliases.apply(this, arguments);
2058
2038
  }
2059
2039
  /**
@@ -2068,23 +2048,23 @@ function storeImageAliases(_x18, _x19, _x20, _x21) {
2068
2048
 
2069
2049
 
2070
2050
  function _storeImageAliases() {
2071
- _storeImageAliases = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(consultationId, lockboxUuid, workflow, oroClient) {
2051
+ _storeImageAliases = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(consultationId, lockboxUuid, workflow, oroClient) {
2072
2052
  var images, nonNullImages, promises;
2073
- return runtime_1.wrap(function _callee10$(_context10) {
2053
+ return runtime_1.wrap(function _callee8$(_context8) {
2074
2054
  while (1) {
2075
- switch (_context10.prev = _context10.next) {
2055
+ switch (_context8.prev = _context8.next) {
2076
2056
  case 0:
2077
- _context10.t0 = getImagesFromIndexDb;
2078
- _context10.next = 3;
2057
+ _context8.t0 = getImagesFromIndexDb;
2058
+ _context8.next = 3;
2079
2059
  return filterTriggeredAnsweredWithKind(workflow, 'images-alias');
2080
2060
 
2081
2061
  case 3:
2082
- _context10.t1 = _context10.sent.flat();
2083
- _context10.next = 6;
2084
- return (0, _context10.t0)(_context10.t1);
2062
+ _context8.t1 = _context8.sent.flat();
2063
+ _context8.next = 6;
2064
+ return (0, _context8.t0)(_context8.t1);
2085
2065
 
2086
2066
  case 6:
2087
- images = _context10.sent;
2067
+ images = _context8.sent;
2088
2068
  nonNullImages = images.filter(function (img) {
2089
2069
  return !!img;
2090
2070
  });
@@ -2101,29 +2081,29 @@ function _storeImageAliases() {
2101
2081
  idbId: image.idbId
2102
2082
  }, {});
2103
2083
  });
2104
- return _context10.abrupt("return", Promise.all(promises));
2084
+ return _context8.abrupt("return", Promise.all(promises));
2105
2085
 
2106
2086
  case 11:
2107
2087
  case "end":
2108
- return _context10.stop();
2088
+ return _context8.stop();
2109
2089
  }
2110
2090
  }
2111
- }, _callee10);
2091
+ }, _callee8);
2112
2092
  }));
2113
2093
  return _storeImageAliases.apply(this, arguments);
2114
2094
  }
2115
2095
 
2116
- function extractAndStorePersonalWorkflowData(_x22, _x23, _x24, _x25, _x26) {
2096
+ function extractAndStorePersonalWorkflowData(_x19, _x20, _x21, _x22, _x23) {
2117
2097
  return _extractAndStorePersonalWorkflowData.apply(this, arguments);
2118
2098
  }
2119
2099
 
2120
2100
  function _extractAndStorePersonalWorkflowData() {
2121
- _extractAndStorePersonalWorkflowData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee11(workflow, lockboxUuid, consultationId, category, oroClient) {
2122
- return runtime_1.wrap(function _callee11$(_context11) {
2101
+ _extractAndStorePersonalWorkflowData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(workflow, lockboxUuid, consultationId, category, oroClient) {
2102
+ return runtime_1.wrap(function _callee9$(_context9) {
2123
2103
  while (1) {
2124
- switch (_context11.prev = _context11.next) {
2104
+ switch (_context9.prev = _context9.next) {
2125
2105
  case 0:
2126
- return _context11.abrupt("return", getWorkflowDataByCategory(workflow, category).then(function (data) {
2106
+ return _context9.abrupt("return", getWorkflowDataByCategory(workflow, category).then(function (data) {
2127
2107
  if (Object.keys(data.fields).length === 0) return;
2128
2108
  return oroClient.getOrInsertJsonData(lockboxUuid, data, {
2129
2109
  category: category,
@@ -2134,10 +2114,10 @@ function _extractAndStorePersonalWorkflowData() {
2134
2114
 
2135
2115
  case 1:
2136
2116
  case "end":
2137
- return _context11.stop();
2117
+ return _context9.stop();
2138
2118
  }
2139
2119
  }
2140
- }, _callee11);
2120
+ }, _callee9);
2141
2121
  }));
2142
2122
  return _extractAndStorePersonalWorkflowData.apply(this, arguments);
2143
2123
  }