@medipass/utils 11.73.2 → 11.73.3-chore-update-react-18.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/abn.js +40 -45
- package/{billable-items-f8291b1e.js → billable-items-5e559447.js} +1 -1
- package/build-validation-schema.js +81 -123
- package/{businesses-2633ab9b.js → businesses-94ec0280.js} +1 -1
- package/chart.js +7 -14
- package/claim-payment-status-formatted.js +5 -2
- package/claim-payment-status-icons.js +13 -2
- package/claim-payment-status-text-classes.js +14 -2
- package/constants.js +82 -69
- package/countries.js +6 -8
- package/datetime.js +6 -13
- package/document-types-formatted.js +8 -3
- package/document-types-icons.js +4 -2
- package/document-types-text-classes.js +5 -2
- package/documents/workflow-state-formatted-text-classes.js +13 -4
- package/documents/workflow-state-formatted.js +13 -4
- package/documents/workflow-state-icons.js +11 -2
- package/form-applications/assign-values-to-sections.js +10 -16
- package/{forms-e1c51a53.js → forms-646810f2.js} +1 -1
- package/funders.js +21 -56
- package/get-env.js +38 -75
- package/get-select-options.js +21 -40
- package/get-staff-type-display-name.js +2 -4
- package/google-addresses.js +46 -91
- package/{health-fund-accounts-88eac93c.js → health-fund-accounts-8eda8621.js} +1 -1
- package/{health-fund-settings-e7a0f2ec.js → health-fund-settings-6d803913.js} +1 -1
- package/{health-funds-7fea63a0.js → health-funds-5e838942.js} +2 -2
- package/i18n/index.js +15 -18
- package/i18n/translations.js +1 -1
- package/index.js +1 -3
- package/intercom.js +24 -69
- package/{members-8eb8d8d0.js → members-e1797829.js} +1 -1
- package/{modalities-2dfbea63.js → modalities-d9979fa4.js} +1 -1
- package/package.json +4 -4
- package/parse-health-fund-card-fields.js +4 -6
- package/{patients-dd3709c1.js → patients-aba388c0.js} +1 -1
- package/{payment-methods-d36bc018.js → payment-methods-4010f9e5.js} +1 -1
- package/payment-options.js +11 -33
- package/{practices-d6c480f1.js → practices-17c06e6c.js} +3 -3
- package/{products-0a392564.js → products-7054c705.js} +2 -2
- package/products.js +5 -12
- package/{professional-categories-157d1767.js → professional-categories-0927144e.js} +1 -1
- package/redux-actions.js +69 -108
- package/redux-reducer.js +53 -69
- package/sanitise-url.js +1 -1
- package/scroll.js +1 -3
- package/sensitive-keys.js +2 -2
- package/sentry.js +35 -59
- package/service-items.js +70 -111
- package/{services-f8480eba.js → services-a81b505c.js} +3 -3
- package/{specialties-25fbb171.js → specialties-c29f2f67.js} +1 -1
- package/{staff-646053b7.js → staff-fedb5a08.js} +4 -4
- package/status-icons.js +12 -2
- package/status-text-classes.js +12 -2
- package/{subscriptions-aef302aa.js → subscriptions-25d86dab.js} +5 -5
- package/test-framework/fixtures/accounts.js +1 -1
- package/test-framework/fixtures/billable-items.js +1 -1
- package/test-framework/fixtures/businesses.js +1 -1
- package/test-framework/fixtures/documents.js +3 -3
- package/test-framework/fixtures/form-application-templates.js +1 -1
- package/test-framework/fixtures/form-applications.js +1 -1
- package/test-framework/fixtures/forms.js +1 -1
- package/test-framework/fixtures/health-fund-accounts.js +1 -1
- package/test-framework/fixtures/health-fund-settings.js +1 -1
- package/test-framework/fixtures/health-funds.js +1 -1
- package/test-framework/fixtures/index.js +18 -18
- package/test-framework/fixtures/members.js +1 -1
- package/test-framework/fixtures/message-mappings.js +1 -1
- package/test-framework/fixtures/modalities.js +1 -1
- package/test-framework/fixtures/patients.js +1 -1
- package/test-framework/fixtures/payment-methods.js +1 -1
- package/test-framework/fixtures/practices.js +1 -1
- package/test-framework/fixtures/products.js +1 -1
- package/test-framework/fixtures/professional-categories.js +1 -1
- package/test-framework/fixtures/services.js +1 -1
- package/test-framework/fixtures/specialties.js +1 -1
- package/test-framework/fixtures/staff.js +1 -1
- package/test-framework/fixtures/subscriptions.js +1 -1
- package/test-framework/fixtures/transaction-reports.js +6 -6
- package/test-framework/fixtures/transactions.js +1 -1
- package/test-framework/fixtures/workflow-exceptions.js +2 -2
- package/test-framework/react.js +10 -12
- package/transaction-details-by-funder.js +20 -21
- package/transaction-status-formatted.js +13 -3
- package/transaction-status-helpers.js +21 -27
- package/transaction-status-icons.js +9 -2
- package/transaction-status-text-classes.js +16 -2
- package/transaction-status.js +7 -15
- package/{transactions-4a08e450.js → transactions-de63fd15.js} +14 -14
- package/validate-form.js +79 -269
- package/validate.js +16 -28
- package/webpack-config.js +6 -13
- package/workflow-state-formatted-text-classes.js +12 -4
- package/workflow-state-formatted.js +11 -2
package/redux-reducer.js
CHANGED
|
@@ -5,101 +5,85 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
7
|
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
|
|
8
|
-
require('@babel/runtime/regenerator');
|
|
9
|
-
require('@babel/runtime/helpers/asyncToGenerator');
|
|
10
8
|
require('lodash/get');
|
|
11
9
|
var _set = _interopDefault(require('lodash/set'));
|
|
12
10
|
var _pick = _interopDefault(require('lodash/pick'));
|
|
13
11
|
var reduxActions = require('./redux-actions.js');
|
|
14
12
|
|
|
15
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
-
|
|
17
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return _objectSpread({}, persistState ? state : {}, (_objectSpread2 = {}, _objectSpread2[isFetchingKey] = true, _objectSpread2[hasFetchedKey] = false, _objectSpread2));
|
|
15
|
+
const request = function (state, _temp) {
|
|
16
|
+
let {
|
|
17
|
+
isFetchingKey = 'isFetching',
|
|
18
|
+
hasFetchedKey = 'hasFetched',
|
|
19
|
+
persistState = true
|
|
20
|
+
} = _temp === void 0 ? {} : _temp;
|
|
21
|
+
return _objectSpread({}, persistState ? state : {}, {
|
|
22
|
+
[isFetchingKey]: true,
|
|
23
|
+
[hasFetchedKey]: false
|
|
24
|
+
});
|
|
30
25
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return _objectSpread({}, persistState ? state : {}, (_objectSpread3 = {}, _objectSpread3[isFetchingKey] = false, _objectSpread3[hasFetchedKey] = true, _objectSpread3.data = action.payload, _objectSpread3));
|
|
26
|
+
const oneSuccess = function (state, action, _temp2) {
|
|
27
|
+
let {
|
|
28
|
+
isFetchingKey = 'isFetching',
|
|
29
|
+
hasFetchedKey = 'hasFetched',
|
|
30
|
+
persistState = false
|
|
31
|
+
} = _temp2 === void 0 ? {} : _temp2;
|
|
32
|
+
return _objectSpread({}, persistState ? state : {}, {
|
|
33
|
+
[isFetchingKey]: false,
|
|
34
|
+
[hasFetchedKey]: true,
|
|
35
|
+
data: action.payload
|
|
36
|
+
});
|
|
43
37
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_ref3$hasFetchedKey = _ref3.hasFetchedKey,
|
|
51
|
-
hasFetchedKey = _ref3$hasFetchedKey === void 0 ? 'hasFetched' : _ref3$hasFetchedKey;
|
|
52
|
-
|
|
53
|
-
var payload = _objectSpread({}, action.payload);
|
|
54
|
-
|
|
38
|
+
const paginatedListSuccess = function (state, action, _temp3) {
|
|
39
|
+
let {
|
|
40
|
+
isFetchingKey = 'isFetching',
|
|
41
|
+
hasFetchedKey = 'hasFetched'
|
|
42
|
+
} = _temp3 === void 0 ? {} : _temp3;
|
|
43
|
+
const payload = _objectSpread({}, action.payload);
|
|
55
44
|
if (payload.meta) {
|
|
56
45
|
payload.meta = _objectSpread({}, payload.meta, {
|
|
57
46
|
currentPage: action.currentPage || 1
|
|
58
47
|
});
|
|
59
48
|
}
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
return _objectSpread({}, payload, {
|
|
50
|
+
[isFetchingKey]: false,
|
|
51
|
+
[hasFetchedKey]: true
|
|
52
|
+
});
|
|
62
53
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return _objectSpread({}, persistState ? state : {}, (_objectSpread5 = {}, _objectSpread5[isFetchingKey] = false, _objectSpread5[hasFetchedKey] = false, _objectSpread5.error = action.payload, _objectSpread5));
|
|
54
|
+
const failure = function (state, action, _temp4) {
|
|
55
|
+
let {
|
|
56
|
+
isFetchingKey = 'isFetching',
|
|
57
|
+
hasFetchedKey = 'hasFetched',
|
|
58
|
+
persistState = false
|
|
59
|
+
} = _temp4 === void 0 ? {} : _temp4;
|
|
60
|
+
return _objectSpread({}, persistState ? state : {}, {
|
|
61
|
+
[isFetchingKey]: false,
|
|
62
|
+
[hasFetchedKey]: false,
|
|
63
|
+
error: action.payload
|
|
64
|
+
});
|
|
75
65
|
};
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
const getRootReducer = function (appReducer, _temp5) {
|
|
67
|
+
let {
|
|
68
|
+
persistKeys
|
|
69
|
+
} = _temp5 === void 0 ? {
|
|
78
70
|
persistKeys: {}
|
|
79
|
-
} : _temp5
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return function (state, action) {
|
|
83
|
-
var newState = _objectSpread({}, state);
|
|
84
|
-
|
|
71
|
+
} : _temp5;
|
|
72
|
+
return (state, action) => {
|
|
73
|
+
let newState = _objectSpread({}, state);
|
|
85
74
|
if (action.type === reduxActions.CLEAR_ALL_STATE) {
|
|
86
75
|
// @ts-expect-error TS(2769): No overload matches this call.
|
|
87
76
|
newState = _objectSpread({}, _pick(state, persistKeys));
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
if (action.type === reduxActions.CLEAR_VALUE) {
|
|
91
|
-
action.keys.forEach(
|
|
92
|
-
return _set(newState, key, {});
|
|
93
|
-
});
|
|
79
|
+
action.keys.forEach(key => _set(newState, key, {}));
|
|
94
80
|
newState = _objectSpread({}, state, {}, newState);
|
|
95
81
|
}
|
|
96
|
-
|
|
97
82
|
if (action.type === reduxActions.SET_VALUE) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
83
|
+
newState = _objectSpread({}, newState, {
|
|
84
|
+
[action.key]: action.value
|
|
85
|
+
});
|
|
101
86
|
}
|
|
102
|
-
|
|
103
87
|
return appReducer(newState, action);
|
|
104
88
|
};
|
|
105
89
|
};
|
package/sanitise-url.js
CHANGED
|
@@ -7,7 +7,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
7
7
|
var escape = _interopDefault(require('escape-html'));
|
|
8
8
|
|
|
9
9
|
function sanitiseUrl(url) {
|
|
10
|
-
|
|
10
|
+
const escapedUrl = escape(url);
|
|
11
11
|
return {
|
|
12
12
|
hasChanged: url !== escapedUrl,
|
|
13
13
|
url: escapedUrl
|
package/scroll.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var scroll = (
|
|
6
|
-
return document.getElementById('main-content') && document.getElementById('main-content').scroll && document.getElementById('main-content').scroll(options);
|
|
7
|
-
});
|
|
5
|
+
var scroll = (options => document.getElementById('main-content') && document.getElementById('main-content').scroll && document.getElementById('main-content').scroll(options));
|
|
8
6
|
|
|
9
7
|
exports.default = scroll;
|
package/sensitive-keys.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const VERY_SENSITIVE_KEYS = ['password', 'mobile', 'mobileE164', 'dob', 'dobString', 'address', 'providerNumber', 'passcode', 'lnglat', 'membershipNumber', 'landline', 'fax'];
|
|
6
|
+
const SENSITIVE_KEYS = [...VERY_SENSITIVE_KEYS, 'firstName', 'lastName', 'username', 'token', 'otkCode', 'email', 'Authorization'];
|
|
7
7
|
|
|
8
8
|
exports.VERY_SENSITIVE_KEYS = VERY_SENSITIVE_KEYS;
|
|
9
9
|
exports.default = SENSITIVE_KEYS;
|
package/sentry.js
CHANGED
|
@@ -11,98 +11,74 @@ var masked = _interopDefault(require('masked'));
|
|
|
11
11
|
var _set = _interopDefault(require('lodash/set'));
|
|
12
12
|
var sensitiveKeys = require('./sensitive-keys.js');
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const ERROR_CODES = {
|
|
15
15
|
INVALID_AUTHENTICATION: 10007
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
const ERROR_MESSAGES = {
|
|
18
18
|
NETWORK_ERROR: 'Network Error'
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
const STATUS_CODES = {
|
|
21
21
|
UNAUTHORIZED: 401,
|
|
22
22
|
SERVER_ERROR: 500
|
|
23
23
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
var logError = function logError(_error, _temp) {
|
|
44
|
-
var _ref = _temp === void 0 ? {} : _temp,
|
|
45
|
-
name = _ref.name,
|
|
46
|
-
data = _ref.data;
|
|
47
|
-
|
|
48
|
-
var error = _error;
|
|
49
|
-
|
|
24
|
+
const _ignore = error => process.env.NODE_ENV === 'test' || error.message === ERROR_MESSAGES.NETWORK_ERROR || _get(error, 'data.statusCode') === STATUS_CODES.UNAUTHORIZED || _get(error, 'data.statusCode') >= STATUS_CODES.SERVER_ERROR || _get(error, 'data.errorCode') === ERROR_CODES.INVALID_AUTHENTICATION;
|
|
25
|
+
|
|
26
|
+
// @ts-expect-error TS(2554): Expected 1 arguments, but got 0.
|
|
27
|
+
const clearUserContext = () => Sentry.setUser();
|
|
28
|
+
const createReduxMiddleware = () => createSentryMiddleware(Sentry, {
|
|
29
|
+
actionTransformer: action => masked(action, sensitiveKeys.default),
|
|
30
|
+
stateTransformer: state => masked(state, sensitiveKeys.default)
|
|
31
|
+
});
|
|
32
|
+
const logError = function (_error, _temp) {
|
|
33
|
+
let {
|
|
34
|
+
// @ts-expect-error TS(2525): Initializer provides no value for this binding ele... Remove this comment to see the full error message
|
|
35
|
+
name,
|
|
36
|
+
// @ts-expect-error TS(2525): Initializer provides no value for this binding ele... Remove this comment to see the full error message
|
|
37
|
+
data
|
|
38
|
+
} = _temp === void 0 ? {} : _temp;
|
|
39
|
+
let error = _error;
|
|
50
40
|
if (error instanceof Error) {
|
|
51
|
-
var _error2, _error2$config;
|
|
52
|
-
|
|
53
41
|
// @ts-expect-error TS(2339): Property 'config' does not exist on type 'Error'.
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
const errorHeaders = error?.config?.headers;
|
|
43
|
+
const maskedErrorHeaders = masked(errorHeaders, ['Authorization']);
|
|
56
44
|
error = _set(error, 'config.headers', maskedErrorHeaders);
|
|
57
|
-
|
|
58
45
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var errorData = (_error3 = error) == null ? void 0 : (_error3$config = _error3.config) == null ? void 0 : _error3$config.data;
|
|
62
|
-
var maskedErrorData = masked(JSON.parse(errorData), sensitiveKeys.default);
|
|
46
|
+
const errorData = error?.config?.data;
|
|
47
|
+
const maskedErrorData = masked(JSON.parse(errorData), sensitiveKeys.default);
|
|
63
48
|
error = _set(error, 'config.data', JSON.stringify(maskedErrorData));
|
|
64
49
|
} catch (err) {}
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
if (_ignore(error)) {
|
|
68
52
|
return null;
|
|
69
53
|
}
|
|
70
|
-
|
|
71
|
-
Sentry.withScope(function (scope) {
|
|
54
|
+
Sentry.withScope(scope => {
|
|
72
55
|
scope.setExtra('error', error);
|
|
73
56
|
scope.setExtra('data', masked(data, sensitiveKeys.default));
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var sentryError = error instanceof Error ? error : new Error(message);
|
|
78
|
-
|
|
57
|
+
const message = _get(error, 'data.message', error.message);
|
|
58
|
+
const sentryError = error instanceof Error ? error : new Error(message);
|
|
79
59
|
if (name) {
|
|
80
60
|
sentryError.name = name || message;
|
|
81
61
|
}
|
|
82
|
-
|
|
83
62
|
Sentry.captureException(sentryError);
|
|
84
63
|
});
|
|
85
64
|
console.error(error);
|
|
86
65
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
66
|
+
const setup = _ref => {
|
|
67
|
+
let {
|
|
68
|
+
environment,
|
|
69
|
+
url,
|
|
70
|
+
version
|
|
71
|
+
} = _ref;
|
|
92
72
|
if (window.location.hostname !== 'localhost') {
|
|
93
73
|
Sentry.init({
|
|
94
74
|
dsn: url,
|
|
95
|
-
environment
|
|
75
|
+
environment,
|
|
96
76
|
release: version
|
|
97
77
|
});
|
|
98
78
|
}
|
|
99
79
|
};
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
var setTag = function setTag(key, value) {
|
|
104
|
-
return Sentry.setTag(key, value);
|
|
105
|
-
};
|
|
80
|
+
const setUserContext = user => Sentry.setUser(masked(user, sensitiveKeys.default));
|
|
81
|
+
const setTag = (key, value) => Sentry.setTag(key, value);
|
|
106
82
|
var sentry = {};
|
|
107
83
|
|
|
108
84
|
exports.clearUserContext = clearUserContext;
|
package/service-items.js
CHANGED
|
@@ -10,119 +10,95 @@ var _isEmpty = _interopDefault(require('lodash/isEmpty'));
|
|
|
10
10
|
var _difference = _interopDefault(require('lodash/difference'));
|
|
11
11
|
|
|
12
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
14
|
function round(value, step) {
|
|
16
|
-
|
|
15
|
+
const inv = 1.0 / step;
|
|
17
16
|
return Math.round(value * inv) / inv;
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
const calculateTotalAmount = function (serviceItems, opts) {
|
|
20
19
|
if (opts === void 0) {
|
|
21
20
|
opts = {};
|
|
22
21
|
}
|
|
23
|
-
|
|
24
22
|
if (_isEmpty(serviceItems)) {
|
|
25
23
|
return 0;
|
|
26
24
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var itemTotal = undefined;
|
|
31
|
-
|
|
25
|
+
const total = serviceItems.reduce((total, item) => {
|
|
26
|
+
const prices = calculateAmounts(item?.grossAmount ? parseFloat(item?.grossAmount || 0) : parseFloat(item?.feeAmount || 0), Boolean(opts.includeGST && item.isTaxable));
|
|
27
|
+
let itemTotal = undefined;
|
|
32
28
|
if (opts.isSubTotal) {
|
|
33
|
-
itemTotal = prices
|
|
29
|
+
itemTotal = prices?.feeAmount;
|
|
34
30
|
} else {
|
|
35
|
-
itemTotal = prices
|
|
31
|
+
itemTotal = prices?.grossAmount;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
if (opts.includeDiscount && item.discountAmount) {
|
|
39
|
-
|
|
34
|
+
const discountAmount = parseFloat(_get(item, 'discountAmount', '0'));
|
|
40
35
|
itemTotal -= discountAmount;
|
|
41
36
|
}
|
|
42
|
-
|
|
43
37
|
return total + itemTotal;
|
|
44
38
|
}, 0);
|
|
45
39
|
return total;
|
|
46
40
|
};
|
|
47
|
-
|
|
48
|
-
return serviceItems.reduce(
|
|
41
|
+
const calculateTotalDiscountAmount = serviceItems => {
|
|
42
|
+
return serviceItems.reduce((total, item) => {
|
|
49
43
|
return total + parseFloat(_get(item, 'discountAmount', '0'));
|
|
50
44
|
}, 0);
|
|
51
45
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var gstAmount = prices == null ? void 0 : prices.taxAmount;
|
|
46
|
+
const calculateTotalGSTAmount = function (serviceItems, opts) {
|
|
47
|
+
return serviceItems.reduce((total, item) => {
|
|
48
|
+
const prices = calculateAmounts(parseFloat(item?.grossAmount || 0), item.isTaxable);
|
|
49
|
+
const gstAmount = prices?.taxAmount;
|
|
57
50
|
return total + gstAmount;
|
|
58
51
|
}, 0);
|
|
59
52
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
const applyDiscountToServiceItems = (serviceItems, _ref) => {
|
|
54
|
+
let {
|
|
55
|
+
discount,
|
|
56
|
+
discountType
|
|
57
|
+
} = _ref;
|
|
64
58
|
if (serviceItems && discount) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
const totalAmount = calculateTotalAmount(serviceItems);
|
|
60
|
+
let percentage = parseFloat(discount) / totalAmount;
|
|
68
61
|
if (discountType === 'percentage') {
|
|
69
62
|
percentage = parseFloat(discount) / 100;
|
|
70
63
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
discountAmount: (serviceItem.feeAmount * percentage).toFixed(2)
|
|
75
|
-
});
|
|
76
|
-
});
|
|
64
|
+
return serviceItems.map(serviceItem => _objectSpread({}, serviceItem, {
|
|
65
|
+
discountAmount: (serviceItem.feeAmount * percentage).toFixed(2)
|
|
66
|
+
}));
|
|
77
67
|
}
|
|
78
|
-
|
|
79
68
|
return serviceItems;
|
|
80
69
|
};
|
|
81
|
-
|
|
70
|
+
const getEarliestServiceDate = function (serviceItems, dateKey) {
|
|
82
71
|
if (dateKey === void 0) {
|
|
83
72
|
dateKey = 'serviceDateString';
|
|
84
73
|
}
|
|
85
|
-
|
|
86
|
-
return serviceItems.reduce(function (currentEarliestDate, serviceItem) {
|
|
74
|
+
return serviceItems.reduce((currentEarliestDate, serviceItem) => {
|
|
87
75
|
if (!currentEarliestDate) {
|
|
88
76
|
return serviceItem[dateKey];
|
|
89
77
|
}
|
|
90
|
-
|
|
91
78
|
if (Date.parse(serviceItem[dateKey]) < Date.parse(currentEarliestDate)) {
|
|
92
79
|
return serviceItem[dateKey];
|
|
93
80
|
}
|
|
94
|
-
|
|
95
81
|
return currentEarliestDate;
|
|
96
82
|
}, '');
|
|
97
83
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
useBenefitAsPrice = _ref2$useBenefitAsPri === void 0 ? false : _ref2$useBenefitAsPri;
|
|
117
|
-
|
|
118
|
-
var benefit = _get(item, 'benefit', 0);
|
|
119
|
-
|
|
120
|
-
var benefitAmount = (benefit / 100).toFixed(2);
|
|
121
|
-
|
|
122
|
-
var price = _get(item, 'price');
|
|
123
|
-
|
|
124
|
-
var feeAmount = (price / 100).toFixed(2);
|
|
125
|
-
var option = {
|
|
84
|
+
const getChargeAmount = serviceItems => calculateTotalAmount(serviceItems, {
|
|
85
|
+
includeDiscount: true
|
|
86
|
+
}).toFixed(2);
|
|
87
|
+
const getDiscountAmount = (discountType, currentServiceItems, currentDiscountValue) => discountType === 'price' ? parseFloat(currentDiscountValue).toFixed(2) : (calculateTotalAmount(currentServiceItems, {
|
|
88
|
+
includeDiscount: false
|
|
89
|
+
}) * (parseFloat(currentDiscountValue) / 100)).toFixed(2);
|
|
90
|
+
const getTotalAmount = serviceItems => calculateTotalAmount(serviceItems, {
|
|
91
|
+
includeDiscount: false
|
|
92
|
+
}).toFixed(2);
|
|
93
|
+
const getItemValue = (item, opts) => {
|
|
94
|
+
const {
|
|
95
|
+
useBenefitAsPrice = false
|
|
96
|
+
} = opts || {};
|
|
97
|
+
const benefit = _get(item, 'benefit', 0);
|
|
98
|
+
const benefitAmount = (benefit / 100).toFixed(2);
|
|
99
|
+
const price = _get(item, 'price');
|
|
100
|
+
const feeAmount = (price / 100).toFixed(2);
|
|
101
|
+
const option = {
|
|
126
102
|
label: item.displayName,
|
|
127
103
|
value: item
|
|
128
104
|
};
|
|
@@ -130,10 +106,10 @@ var getItemValue = function getItemValue(item, opts) {
|
|
|
130
106
|
service: option,
|
|
131
107
|
quantity: 1
|
|
132
108
|
}, item, {
|
|
133
|
-
benefitAmount
|
|
109
|
+
benefitAmount,
|
|
134
110
|
hasSeenPatientToday: 'no'
|
|
135
111
|
}, price ? {
|
|
136
|
-
feeAmount
|
|
112
|
+
feeAmount
|
|
137
113
|
} : {
|
|
138
114
|
feeAmount: undefined
|
|
139
115
|
}, {}, useBenefitAsPrice && benefit > 0 ? {
|
|
@@ -141,73 +117,56 @@ var getItemValue = function getItemValue(item, opts) {
|
|
|
141
117
|
} : {});
|
|
142
118
|
};
|
|
143
119
|
function mapItemsToClaimItems(transaction) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var items = _get(transaction, 'items', []);
|
|
147
|
-
|
|
120
|
+
const claimItems = _get(transaction, 'claims[0].claimItems', []);
|
|
121
|
+
const items = _get(transaction, 'items', []);
|
|
148
122
|
if (items.length === 0) {
|
|
149
123
|
return claimItems;
|
|
150
124
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return claimItem.itemId === item.itemId;
|
|
155
|
-
}) || {};
|
|
156
|
-
|
|
157
|
-
var isNonClaimable = _isEmpty(claimItem);
|
|
158
|
-
|
|
125
|
+
const newItems = items.map(item => {
|
|
126
|
+
const claimItem = claimItems.find(claimItem => claimItem.itemId === item.itemId) || {};
|
|
127
|
+
const isNonClaimable = _isEmpty(claimItem);
|
|
159
128
|
return _objectSpread({}, item, {}, claimItem, {
|
|
160
129
|
displayName: _get(item, 'displayName') || _get(claimItem, 'displayName'),
|
|
161
130
|
itemCode: _get(claimItem, 'icare.itemCode') || _get(claimItem, 'itemCode'),
|
|
162
131
|
description: _get(item, 'customDescription') || _get(item, 'description') || _get(claimItem, 'icare.description') || _get(claimItem, 'description'),
|
|
163
132
|
notes: _get(item, 'description'),
|
|
164
|
-
serviceDateString:
|
|
165
|
-
isNonClaimable
|
|
133
|
+
serviceDateString: item?.serviceDateString || item.serviceDate,
|
|
134
|
+
isNonClaimable
|
|
166
135
|
});
|
|
167
136
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var extraItemIds = _difference(claimItemIds, newItemIds) || [];
|
|
175
|
-
var extraItems = extraItemIds.map(function (extraItemId) {
|
|
176
|
-
var claimItem = claimItems.find(function (claimItem) {
|
|
177
|
-
return claimItem.claimItemId === extraItemId;
|
|
178
|
-
});
|
|
179
|
-
var item = items.find(function (item) {
|
|
180
|
-
return item.itemId === claimItem.itemId;
|
|
181
|
-
});
|
|
137
|
+
const claimItemIds = claimItems.map(claimItem => claimItem.claimItemId);
|
|
138
|
+
const newItemIds = newItems.map(newItem => newItem.claimItemId);
|
|
139
|
+
const extraItemIds = _difference(claimItemIds, newItemIds) || [];
|
|
140
|
+
const extraItems = extraItemIds.map(extraItemId => {
|
|
141
|
+
const claimItem = claimItems.find(claimItem => claimItem.claimItemId === extraItemId);
|
|
142
|
+
const item = items.find(item => item.itemId === claimItem.itemId);
|
|
182
143
|
return _objectSpread({}, item, {}, claimItem, {
|
|
183
144
|
displayName: _get(claimItem, 'displayName'),
|
|
184
145
|
itemCode: _get(claimItem, 'icare.itemCode') || _get(claimItem, 'itemCode'),
|
|
185
146
|
description: undefined,
|
|
186
147
|
notes: undefined,
|
|
187
|
-
serviceDateString:
|
|
148
|
+
serviceDateString: item?.serviceDateString || item.serviceDate,
|
|
188
149
|
isExtraItem: true
|
|
189
150
|
});
|
|
190
151
|
});
|
|
191
|
-
return [
|
|
152
|
+
return [...newItems, ...extraItems];
|
|
192
153
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
154
|
+
const calculateAmounts = (grossAmount, isTaxable) => {
|
|
155
|
+
let feeAmount = grossAmount;
|
|
156
|
+
let taxAmount = 0;
|
|
197
157
|
if (!isTaxable) {
|
|
198
158
|
return {
|
|
199
|
-
taxAmount
|
|
200
|
-
feeAmount
|
|
201
|
-
grossAmount
|
|
159
|
+
taxAmount,
|
|
160
|
+
feeAmount,
|
|
161
|
+
grossAmount
|
|
202
162
|
};
|
|
203
163
|
}
|
|
204
|
-
|
|
205
164
|
feeAmount = feeAmount - feeAmount / 11;
|
|
206
165
|
taxAmount = parseFloat((feeAmount * 1.1).toFixed(6)) - feeAmount;
|
|
207
166
|
return {
|
|
208
|
-
taxAmount
|
|
209
|
-
feeAmount
|
|
210
|
-
grossAmount
|
|
167
|
+
taxAmount,
|
|
168
|
+
feeAmount,
|
|
169
|
+
grossAmount
|
|
211
170
|
};
|
|
212
171
|
};
|
|
213
172
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const defaultService = {
|
|
4
4
|
_id: 'serviceDefaultId',
|
|
5
5
|
organisationId: 'organisationDefaultId',
|
|
6
6
|
businessId: 'businessDefaultId',
|
|
@@ -30,7 +30,7 @@ var defaultService = {
|
|
|
30
30
|
created: new Date('2015-01-01T00:00:00'),
|
|
31
31
|
modified: new Date('2015-01-02T00:00:00Z')
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
const serviceWithMultipleClaimItems = {
|
|
34
34
|
_id: 'serviceWithMultipleClaimItemsDefaultId',
|
|
35
35
|
organisationId: 'organisationDefaultId',
|
|
36
36
|
businessId: 'businessDefaultId',
|
|
@@ -90,7 +90,7 @@ var serviceWithMultipleClaimItems = {
|
|
|
90
90
|
created: new Date('2015-01-01T00:00:00'),
|
|
91
91
|
modified: new Date('2015-01-02T00:00:00Z')
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
const defaultServiceItems = [{
|
|
94
94
|
_id: 'claimItemDefaultId',
|
|
95
95
|
modalityId: 'modalityDefaultId',
|
|
96
96
|
itemCode: 'mockItemCode',
|