@medipass/utils 11.54.2-feat-tyro-terminal-refunds.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/.eslintrc +3 -0
- package/CHANGELOG.md +3218 -0
- package/babel.config.js +4 -0
- package/billable-items-01050ba2.js +27 -0
- package/build-validation-schema.js +1282 -0
- package/businesses-968c8afa.js +54 -0
- package/chart.js +45 -0
- package/claim-payment-status-formatted.js +12 -0
- package/claim-payment-status-icons.js +10 -0
- package/claim-payment-status-text-classes.js +10 -0
- package/constants.js +387 -0
- package/countries.js +1011 -0
- package/datetime.js +36 -0
- package/document-types-formatted.js +13 -0
- package/document-types-icons.js +10 -0
- package/document-types-text-classes.js +10 -0
- package/documents/workflow-state-formatted-text-classes.js +12 -0
- package/documents/workflow-state-formatted.js +15 -0
- package/documents/workflow-state-icons.js +10 -0
- package/form-applications/assign-values-to-sections.js +29 -0
- package/forms-f06ca97e.js +51 -0
- package/funders.js +104 -0
- package/get-env.js +196 -0
- package/get-select-options.js +65 -0
- package/get-staff-type-display-name.js +12 -0
- package/google-addresses.js +127 -0
- package/health-fund-accounts-3cd8650f.js +20 -0
- package/health-fund-settings-43327826.js +22 -0
- package/health-funds-300facef.js +194 -0
- package/i18n/index.js +59 -0
- package/i18n/translations.js +36 -0
- package/index.js +57 -0
- package/intercom.js +103 -0
- package/jest.config.js +6 -0
- package/jest.setup.js +0 -0
- package/members-cb4f73a9.js +53 -0
- package/modalities-b360d521.js +19 -0
- package/normalise-abn.js +22 -0
- package/package.json +53 -0
- package/parse-health-fund-card-fields.js +12 -0
- package/patients-2083dd9c.js +46 -0
- package/payment-methods-4fa2d01f.js +26 -0
- package/payment-options.js +52 -0
- package/practices-3faceeff.js +89 -0
- package/products-bd313cb4.js +83 -0
- package/products.js +31 -0
- package/professional-categories-e2e5284b.js +19 -0
- package/redux-actions.js +161 -0
- package/redux-reducer.js +112 -0
- package/sanitise-url.js +17 -0
- package/scroll.js +9 -0
- package/sensitive-keys.js +9 -0
- package/sentry.js +104 -0
- package/service-items.js +229 -0
- package/services-2e25cdac.js +127 -0
- package/specialties-7640b7e3.js +20 -0
- package/staff-c3ecf4e6.js +165 -0
- package/status-icons.js +10 -0
- package/status-text-classes.js +10 -0
- package/subscriptions-45c1321a.js +160 -0
- package/test-framework/fixtures/accounts.js +34 -0
- package/test-framework/fixtures/billable-items.js +9 -0
- package/test-framework/fixtures/businesses.js +9 -0
- package/test-framework/fixtures/documents.js +121 -0
- package/test-framework/fixtures/form-application-templates.js +74 -0
- package/test-framework/fixtures/form-applications.js +39 -0
- package/test-framework/fixtures/forms.js +9 -0
- package/test-framework/fixtures/health-fund-accounts.js +9 -0
- package/test-framework/fixtures/health-fund-settings.js +9 -0
- package/test-framework/fixtures/health-funds.js +10 -0
- package/test-framework/fixtures/index.js +45 -0
- package/test-framework/fixtures/members.js +9 -0
- package/test-framework/fixtures/message-mappings.js +61 -0
- package/test-framework/fixtures/modalities.js +9 -0
- package/test-framework/fixtures/patients.js +9 -0
- package/test-framework/fixtures/payment-methods.js +9 -0
- package/test-framework/fixtures/practices.js +11 -0
- package/test-framework/fixtures/products.js +10 -0
- package/test-framework/fixtures/professional-categories.js +9 -0
- package/test-framework/fixtures/services.js +11 -0
- package/test-framework/fixtures/specialties.js +9 -0
- package/test-framework/fixtures/staff.js +12 -0
- package/test-framework/fixtures/subscriptions.js +13 -0
- package/test-framework/fixtures/transaction-reports.js +69 -0
- package/test-framework/fixtures/transactions.js +22 -0
- package/test-framework/fixtures/workflow-exceptions.js +32 -0
- package/test-framework/react.js +38 -0
- package/transaction-status-formatted.js +13 -0
- package/transaction-status-helpers.js +77 -0
- package/transaction-status-icons.js +10 -0
- package/transaction-status-text-classes.js +10 -0
- package/transaction-status.js +42 -0
- package/transactions-6e5fd92d.js +1883 -0
- package/validate-form.js +368 -0
- package/validate.js +37 -0
- package/webpack-config.js +27 -0
- package/workflow-state-formatted-text-classes.js +12 -0
- package/workflow-state-formatted.js +13 -0
package/redux-reducer.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
|
|
8
|
+
require('@babel/runtime/regenerator');
|
|
9
|
+
require('@babel/runtime/helpers/asyncToGenerator');
|
|
10
|
+
require('lodash/get');
|
|
11
|
+
var _set = _interopDefault(require('lodash/set'));
|
|
12
|
+
var _pick = _interopDefault(require('lodash/pick'));
|
|
13
|
+
var reduxActions = require('./redux-actions.js');
|
|
14
|
+
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
|
|
17
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
18
|
+
var request = function request(state, _temp) {
|
|
19
|
+
var _objectSpread2;
|
|
20
|
+
|
|
21
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
22
|
+
_ref$isFetchingKey = _ref.isFetchingKey,
|
|
23
|
+
isFetchingKey = _ref$isFetchingKey === void 0 ? 'isFetching' : _ref$isFetchingKey,
|
|
24
|
+
_ref$hasFetchedKey = _ref.hasFetchedKey,
|
|
25
|
+
hasFetchedKey = _ref$hasFetchedKey === void 0 ? 'hasFetched' : _ref$hasFetchedKey,
|
|
26
|
+
_ref$persistState = _ref.persistState,
|
|
27
|
+
persistState = _ref$persistState === void 0 ? true : _ref$persistState;
|
|
28
|
+
|
|
29
|
+
return _objectSpread({}, persistState ? state : {}, (_objectSpread2 = {}, _objectSpread2[isFetchingKey] = true, _objectSpread2[hasFetchedKey] = false, _objectSpread2));
|
|
30
|
+
};
|
|
31
|
+
var oneSuccess = function oneSuccess(state, action, _temp2) {
|
|
32
|
+
var _objectSpread3;
|
|
33
|
+
|
|
34
|
+
var _ref2 = _temp2 === void 0 ? {} : _temp2,
|
|
35
|
+
_ref2$isFetchingKey = _ref2.isFetchingKey,
|
|
36
|
+
isFetchingKey = _ref2$isFetchingKey === void 0 ? 'isFetching' : _ref2$isFetchingKey,
|
|
37
|
+
_ref2$hasFetchedKey = _ref2.hasFetchedKey,
|
|
38
|
+
hasFetchedKey = _ref2$hasFetchedKey === void 0 ? 'hasFetched' : _ref2$hasFetchedKey,
|
|
39
|
+
_ref2$persistState = _ref2.persistState,
|
|
40
|
+
persistState = _ref2$persistState === void 0 ? false : _ref2$persistState;
|
|
41
|
+
|
|
42
|
+
return _objectSpread({}, persistState ? state : {}, (_objectSpread3 = {}, _objectSpread3[isFetchingKey] = false, _objectSpread3[hasFetchedKey] = true, _objectSpread3.data = action.payload, _objectSpread3));
|
|
43
|
+
};
|
|
44
|
+
var paginatedListSuccess = function paginatedListSuccess(state, action, _temp3) {
|
|
45
|
+
var _objectSpread4;
|
|
46
|
+
|
|
47
|
+
var _ref3 = _temp3 === void 0 ? {} : _temp3,
|
|
48
|
+
_ref3$isFetchingKey = _ref3.isFetchingKey,
|
|
49
|
+
isFetchingKey = _ref3$isFetchingKey === void 0 ? 'isFetching' : _ref3$isFetchingKey,
|
|
50
|
+
_ref3$hasFetchedKey = _ref3.hasFetchedKey,
|
|
51
|
+
hasFetchedKey = _ref3$hasFetchedKey === void 0 ? 'hasFetched' : _ref3$hasFetchedKey;
|
|
52
|
+
|
|
53
|
+
var payload = _objectSpread({}, action.payload);
|
|
54
|
+
|
|
55
|
+
if (payload.meta) {
|
|
56
|
+
payload.meta = _objectSpread({}, payload.meta, {
|
|
57
|
+
currentPage: action.currentPage || 1
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return _objectSpread({}, payload, (_objectSpread4 = {}, _objectSpread4[isFetchingKey] = false, _objectSpread4[hasFetchedKey] = true, _objectSpread4));
|
|
62
|
+
};
|
|
63
|
+
var failure = function failure(state, action, _temp4) {
|
|
64
|
+
var _objectSpread5;
|
|
65
|
+
|
|
66
|
+
var _ref4 = _temp4 === void 0 ? {} : _temp4,
|
|
67
|
+
_ref4$isFetchingKey = _ref4.isFetchingKey,
|
|
68
|
+
isFetchingKey = _ref4$isFetchingKey === void 0 ? 'isFetching' : _ref4$isFetchingKey,
|
|
69
|
+
_ref4$hasFetchedKey = _ref4.hasFetchedKey,
|
|
70
|
+
hasFetchedKey = _ref4$hasFetchedKey === void 0 ? 'hasFetched' : _ref4$hasFetchedKey,
|
|
71
|
+
_ref4$persistState = _ref4.persistState,
|
|
72
|
+
persistState = _ref4$persistState === void 0 ? false : _ref4$persistState;
|
|
73
|
+
|
|
74
|
+
return _objectSpread({}, persistState ? state : {}, (_objectSpread5 = {}, _objectSpread5[isFetchingKey] = false, _objectSpread5[hasFetchedKey] = false, _objectSpread5.error = action.payload, _objectSpread5));
|
|
75
|
+
};
|
|
76
|
+
var getRootReducer = function getRootReducer(appReducer, _temp5) {
|
|
77
|
+
var _ref5 = _temp5 === void 0 ? {
|
|
78
|
+
persistKeys: {}
|
|
79
|
+
} : _temp5,
|
|
80
|
+
persistKeys = _ref5.persistKeys;
|
|
81
|
+
|
|
82
|
+
return function (state, action) {
|
|
83
|
+
var newState = _objectSpread({}, state);
|
|
84
|
+
|
|
85
|
+
if (action.type === reduxActions.CLEAR_ALL_STATE) {
|
|
86
|
+
newState = _objectSpread({}, _pick(state, persistKeys));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (action.type === reduxActions.CLEAR_VALUE) {
|
|
90
|
+
action.keys.forEach(function (key) {
|
|
91
|
+
return _set(newState, key, {});
|
|
92
|
+
});
|
|
93
|
+
newState = _objectSpread({}, state, {}, newState);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (action.type === reduxActions.SET_VALUE) {
|
|
97
|
+
var _objectSpread6;
|
|
98
|
+
|
|
99
|
+
newState = _objectSpread({}, newState, (_objectSpread6 = {}, _objectSpread6[action.key] = action.value, _objectSpread6));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return appReducer(newState, action);
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
var reduxReducer = {};
|
|
106
|
+
|
|
107
|
+
exports.default = reduxReducer;
|
|
108
|
+
exports.failure = failure;
|
|
109
|
+
exports.getRootReducer = getRootReducer;
|
|
110
|
+
exports.oneSuccess = oneSuccess;
|
|
111
|
+
exports.paginatedListSuccess = paginatedListSuccess;
|
|
112
|
+
exports.request = request;
|
package/sanitise-url.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var escape = _interopDefault(require('escape-html'));
|
|
8
|
+
|
|
9
|
+
function sanitiseUrl(url) {
|
|
10
|
+
var escapedUrl = escape(url);
|
|
11
|
+
return {
|
|
12
|
+
hasChanged: url !== escapedUrl,
|
|
13
|
+
url: escapedUrl
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.default = sanitiseUrl;
|
package/scroll.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var scroll = (function (options) {
|
|
6
|
+
return document.getElementById('main-content') && document.getElementById('main-content').scroll && document.getElementById('main-content').scroll(options);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
exports.default = scroll;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var VERY_SENSITIVE_KEYS = ['password', 'mobile', 'mobileE164', 'dob', 'dobString', 'address', 'providerNumber', 'passcode', 'lnglat', 'membershipNumber', 'landline', 'fax'];
|
|
6
|
+
var sensitiveKeys = [].concat(VERY_SENSITIVE_KEYS, ['firstName', 'lastName', 'username', 'token', 'otkCode', 'email', 'Authorization']);
|
|
7
|
+
|
|
8
|
+
exports.VERY_SENSITIVE_KEYS = VERY_SENSITIVE_KEYS;
|
|
9
|
+
exports.default = sensitiveKeys;
|
package/sentry.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
var _get = _interopDefault(require('lodash/get'));
|
|
8
|
+
var Sentry = require('@sentry/browser');
|
|
9
|
+
var createSentryMiddleware = _interopDefault(require('redux-sentry-middleware'));
|
|
10
|
+
var masked = _interopDefault(require('masked'));
|
|
11
|
+
var _set = _interopDefault(require('lodash/set'));
|
|
12
|
+
var sensitiveKeys = require('./sensitive-keys.js');
|
|
13
|
+
|
|
14
|
+
var ERROR_CODES = {
|
|
15
|
+
INVALID_AUTHENTICATION: 10007
|
|
16
|
+
};
|
|
17
|
+
var ERROR_MESSAGES = {
|
|
18
|
+
NETWORK_ERROR: 'Network Error'
|
|
19
|
+
};
|
|
20
|
+
var STATUS_CODES = {
|
|
21
|
+
UNAUTHORIZED: 401,
|
|
22
|
+
SERVER_ERROR: 500
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var _ignore = function _ignore(error) {
|
|
26
|
+
return 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;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
var clearUserContext = function clearUserContext() {
|
|
30
|
+
return Sentry.setUser();
|
|
31
|
+
};
|
|
32
|
+
var createReduxMiddleware = function createReduxMiddleware() {
|
|
33
|
+
return createSentryMiddleware(Sentry, {
|
|
34
|
+
actionTransformer: function actionTransformer(action) {
|
|
35
|
+
return masked(action, sensitiveKeys.default);
|
|
36
|
+
},
|
|
37
|
+
stateTransformer: function stateTransformer(state) {
|
|
38
|
+
return masked(state, sensitiveKeys.default);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
var logError = function logError(_error, _temp) {
|
|
43
|
+
var _ref = _temp === void 0 ? {} : _temp,
|
|
44
|
+
name = _ref.name,
|
|
45
|
+
data = _ref.data;
|
|
46
|
+
|
|
47
|
+
var error = _error;
|
|
48
|
+
|
|
49
|
+
if (error instanceof Error) {
|
|
50
|
+
var _error2, _error2$config;
|
|
51
|
+
|
|
52
|
+
var errorHeaders = (_error2 = error) == null ? void 0 : (_error2$config = _error2.config) == null ? void 0 : _error2$config.headers;
|
|
53
|
+
var maskedErrorHeaders = masked(errorHeaders, ['Authorization']);
|
|
54
|
+
error = _set(error, 'config.headers', maskedErrorHeaders);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (_ignore(error)) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Sentry.withScope(function (scope) {
|
|
62
|
+
scope.setExtra('error', error);
|
|
63
|
+
scope.setExtra('data', masked(data, sensitiveKeys.default));
|
|
64
|
+
|
|
65
|
+
var message = _get(error, 'data.message', error.message);
|
|
66
|
+
|
|
67
|
+
var sentryError = error instanceof Error ? error : new Error(message);
|
|
68
|
+
|
|
69
|
+
if (name) {
|
|
70
|
+
sentryError.name = name || message;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
Sentry.captureException(sentryError);
|
|
74
|
+
});
|
|
75
|
+
console.error(error);
|
|
76
|
+
};
|
|
77
|
+
var setup = function setup(_ref2) {
|
|
78
|
+
var environment = _ref2.environment,
|
|
79
|
+
url = _ref2.url,
|
|
80
|
+
version = _ref2.version;
|
|
81
|
+
|
|
82
|
+
if (window.location.hostname !== 'localhost') {
|
|
83
|
+
Sentry.init({
|
|
84
|
+
dsn: url,
|
|
85
|
+
environment: environment,
|
|
86
|
+
release: version
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var setUserContext = function setUserContext(user) {
|
|
91
|
+
return Sentry.setUser(masked(user, sensitiveKeys.default));
|
|
92
|
+
};
|
|
93
|
+
var setTag = function setTag(key, value) {
|
|
94
|
+
return Sentry.setTag(key, value);
|
|
95
|
+
};
|
|
96
|
+
var sentry = {};
|
|
97
|
+
|
|
98
|
+
exports.clearUserContext = clearUserContext;
|
|
99
|
+
exports.createReduxMiddleware = createReduxMiddleware;
|
|
100
|
+
exports.default = sentry;
|
|
101
|
+
exports.logError = logError;
|
|
102
|
+
exports.setTag = setTag;
|
|
103
|
+
exports.setUserContext = setUserContext;
|
|
104
|
+
exports.setup = setup;
|
package/service-items.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
+
|
|
7
|
+
require('./constants.js');
|
|
8
|
+
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty'));
|
|
9
|
+
var _get = _interopDefault(require('lodash/get'));
|
|
10
|
+
var _isEmpty = _interopDefault(require('lodash/isEmpty'));
|
|
11
|
+
var funders = require('./funders.js');
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
+
function round(value, step) {
|
|
17
|
+
var inv = 1.0 / step;
|
|
18
|
+
return Math.round(value * inv) / inv;
|
|
19
|
+
}
|
|
20
|
+
var calculateTotalAmount = function calculateTotalAmount(serviceItems, opts) {
|
|
21
|
+
if (opts === void 0) {
|
|
22
|
+
opts = {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (_isEmpty(serviceItems)) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var total = serviceItems.reduce(function (total, item) {
|
|
30
|
+
var itemTotal = parseFloat(_get(item, 'feeAmount', '0'));
|
|
31
|
+
|
|
32
|
+
if (parseFloat(_get(item, 'initialGrossAmount', '0'))) {
|
|
33
|
+
itemTotal = parseFloat(_get(item, 'initialGrossAmount', '0'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var includeQuantity = _get(opts, 'includeQuantity');
|
|
37
|
+
|
|
38
|
+
if (funders.isIcare(_get(opts, 'funder.code')) && _get(item, 'unit') === 'minutes') {
|
|
39
|
+
includeQuantity = false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (includeQuantity && item.quantity && !item.isExtendedPrice) {
|
|
43
|
+
itemTotal = parseFloat((itemTotal * item.quantity).toFixed(6));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (opts.includeGST && item.isTaxable) {
|
|
47
|
+
if (opts.isSubTotal) {
|
|
48
|
+
if (item.isGross) {
|
|
49
|
+
itemTotal -= parseFloat((itemTotal / 11).toFixed(6));
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (!item.isGross) {
|
|
53
|
+
itemTotal = parseFloat((itemTotal * 1.1).toFixed(6));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (opts.includeDiscount && item.discountAmount) {
|
|
59
|
+
var discountAmount = parseFloat(_get(item, 'discountAmount', '0'));
|
|
60
|
+
itemTotal -= discountAmount;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return total + itemTotal;
|
|
64
|
+
}, 0);
|
|
65
|
+
return total;
|
|
66
|
+
};
|
|
67
|
+
var calculateTotalDiscountAmount = function calculateTotalDiscountAmount(serviceItems) {
|
|
68
|
+
return serviceItems.reduce(function (total, item) {
|
|
69
|
+
return total + parseFloat(_get(item, 'discountAmount', '0'));
|
|
70
|
+
}, 0);
|
|
71
|
+
};
|
|
72
|
+
var calculateTotalGSTAmount = function calculateTotalGSTAmount(serviceItems, opts) {
|
|
73
|
+
if (opts === void 0) {
|
|
74
|
+
opts = {};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return serviceItems.reduce(function (total, item) {
|
|
78
|
+
var includeQuantity = _get(opts, 'includeQuantity');
|
|
79
|
+
|
|
80
|
+
if (funders.isIcare(_get(opts, 'funder.code')) && _get(item, 'unit') === 'minutes') {
|
|
81
|
+
includeQuantity = false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (item.isTaxable) {
|
|
85
|
+
var itemTotal = parseFloat(_get(item, 'feeAmount', '0'));
|
|
86
|
+
|
|
87
|
+
if (parseFloat(_get(item, 'initialGrossAmount', '0'))) {
|
|
88
|
+
itemTotal = parseFloat(_get(item, 'initialGrossAmount', '0'));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (includeQuantity && item.quantity && !item.isExtendedPrice) {
|
|
92
|
+
itemTotal = parseFloat((itemTotal * item.quantity).toFixed(6));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (item.isGross) {
|
|
96
|
+
itemTotal = parseFloat((itemTotal / 11).toFixed(6));
|
|
97
|
+
} else {
|
|
98
|
+
itemTotal = parseFloat((itemTotal * 0.1).toFixed(6));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return total + itemTotal;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return total;
|
|
105
|
+
}, 0);
|
|
106
|
+
};
|
|
107
|
+
var applyDiscountToServiceItems = function applyDiscountToServiceItems(serviceItems, _ref) {
|
|
108
|
+
var discount = _ref.discount,
|
|
109
|
+
discountType = _ref.discountType;
|
|
110
|
+
|
|
111
|
+
if (serviceItems && discount) {
|
|
112
|
+
var totalAmount = calculateTotalAmount(serviceItems);
|
|
113
|
+
var percentage = parseFloat(discount) / totalAmount;
|
|
114
|
+
|
|
115
|
+
if (discountType === 'percentage') {
|
|
116
|
+
percentage = parseFloat(discount) / 100;
|
|
117
|
+
} // $FlowFixMe
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
return serviceItems.map(function (serviceItem) {
|
|
121
|
+
return _objectSpread({}, serviceItem, {
|
|
122
|
+
discountAmount: (serviceItem.feeAmount * percentage).toFixed(2)
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return serviceItems;
|
|
128
|
+
};
|
|
129
|
+
var getEarliestServiceDate = function getEarliestServiceDate(serviceItems, dateKey) {
|
|
130
|
+
if (dateKey === void 0) {
|
|
131
|
+
dateKey = 'serviceDateString';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return serviceItems.reduce(function (currentEarliestDate, serviceItem) {
|
|
135
|
+
if (!currentEarliestDate) {
|
|
136
|
+
return serviceItem[dateKey];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (Date.parse(serviceItem[dateKey]) < Date.parse(currentEarliestDate)) {
|
|
140
|
+
return serviceItem[dateKey];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return currentEarliestDate;
|
|
144
|
+
}, '');
|
|
145
|
+
};
|
|
146
|
+
var getChargeAmount = function getChargeAmount(serviceItems) {
|
|
147
|
+
return calculateTotalAmount(serviceItems, {
|
|
148
|
+
includeDiscount: true
|
|
149
|
+
}).toFixed(2);
|
|
150
|
+
};
|
|
151
|
+
var getDiscountAmount = function getDiscountAmount(discountType, currentServiceItems, currentDiscountValue) {
|
|
152
|
+
return discountType === 'price' ? parseFloat(currentDiscountValue).toFixed(2) : (calculateTotalAmount(currentServiceItems, {
|
|
153
|
+
includeDiscount: false
|
|
154
|
+
}) * (parseFloat(currentDiscountValue) / 100)).toFixed(2);
|
|
155
|
+
};
|
|
156
|
+
var getTotalAmount = function getTotalAmount(serviceItems) {
|
|
157
|
+
return calculateTotalAmount(serviceItems, {
|
|
158
|
+
includeDiscount: false
|
|
159
|
+
}).toFixed(2);
|
|
160
|
+
};
|
|
161
|
+
var getItemValue = function getItemValue(item, opts) {
|
|
162
|
+
var _ref2 = opts || {},
|
|
163
|
+
_ref2$useBenefitAsPri = _ref2.useBenefitAsPrice,
|
|
164
|
+
useBenefitAsPrice = _ref2$useBenefitAsPri === void 0 ? false : _ref2$useBenefitAsPri;
|
|
165
|
+
|
|
166
|
+
var benefit = _get(item, 'benefit', 0);
|
|
167
|
+
|
|
168
|
+
var benefitAmount = (benefit / 100).toFixed(2);
|
|
169
|
+
|
|
170
|
+
var price = _get(item, 'price');
|
|
171
|
+
|
|
172
|
+
var feeAmount = (price / 100).toFixed(2);
|
|
173
|
+
var option = {
|
|
174
|
+
label: item.displayName,
|
|
175
|
+
value: item
|
|
176
|
+
};
|
|
177
|
+
return _objectSpread({
|
|
178
|
+
service: option,
|
|
179
|
+
quantity: 1
|
|
180
|
+
}, item, {
|
|
181
|
+
benefitAmount: benefitAmount,
|
|
182
|
+
hasSeenPatientToday: 'no'
|
|
183
|
+
}, price ? {
|
|
184
|
+
feeAmount: feeAmount
|
|
185
|
+
} : {
|
|
186
|
+
feeAmount: undefined
|
|
187
|
+
}, {}, useBenefitAsPrice && benefit > 0 ? {
|
|
188
|
+
feeAmount: benefitAmount
|
|
189
|
+
} : {});
|
|
190
|
+
};
|
|
191
|
+
function mapItemsToClaimItems(transaction) {
|
|
192
|
+
var claimItems = _get(transaction, 'claims[0].claimItems', []);
|
|
193
|
+
|
|
194
|
+
var items = _get(transaction, 'items', []);
|
|
195
|
+
|
|
196
|
+
if (items.length === 0) {
|
|
197
|
+
return claimItems;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
var newItems = items.map(function (item) {
|
|
201
|
+
var claimItem = claimItems.find(function (claimItem) {
|
|
202
|
+
return claimItem.itemId === item.itemId;
|
|
203
|
+
}) || {};
|
|
204
|
+
|
|
205
|
+
var isNonClaimable = _isEmpty(claimItem);
|
|
206
|
+
|
|
207
|
+
return _objectSpread({}, item, {}, claimItem, {
|
|
208
|
+
displayName: _get(item, 'displayName') || _get(claimItem, 'displayName'),
|
|
209
|
+
itemCode: _get(claimItem, 'icare.itemCode') || _get(claimItem, 'itemCode'),
|
|
210
|
+
description: _get(item, 'customDescription') || _get(item, 'description') || _get(claimItem, 'icare.description') || _get(claimItem, 'description'),
|
|
211
|
+
notes: _get(item, 'description'),
|
|
212
|
+
serviceDateString: item.serviceDate,
|
|
213
|
+
isNonClaimable: isNonClaimable
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
return newItems;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
exports.applyDiscountToServiceItems = applyDiscountToServiceItems;
|
|
220
|
+
exports.calculateTotalAmount = calculateTotalAmount;
|
|
221
|
+
exports.calculateTotalDiscountAmount = calculateTotalDiscountAmount;
|
|
222
|
+
exports.calculateTotalGSTAmount = calculateTotalGSTAmount;
|
|
223
|
+
exports.getChargeAmount = getChargeAmount;
|
|
224
|
+
exports.getDiscountAmount = getDiscountAmount;
|
|
225
|
+
exports.getEarliestServiceDate = getEarliestServiceDate;
|
|
226
|
+
exports.getItemValue = getItemValue;
|
|
227
|
+
exports.getTotalAmount = getTotalAmount;
|
|
228
|
+
exports.mapItemsToClaimItems = mapItemsToClaimItems;
|
|
229
|
+
exports.round = round;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultService = {
|
|
4
|
+
_id: 'serviceDefaultId',
|
|
5
|
+
organisationId: 'organisationDefaultId',
|
|
6
|
+
businessId: 'businessDefaultId',
|
|
7
|
+
displayName: 'mockDisplayName',
|
|
8
|
+
fullName: 'mockFullName',
|
|
9
|
+
description: 'mockDescription',
|
|
10
|
+
duration: 60,
|
|
11
|
+
currencyCode: 'AUD',
|
|
12
|
+
modalityId: 'modalityDefaultId',
|
|
13
|
+
claimItems: [{
|
|
14
|
+
_id: 'claimItemDefaultId',
|
|
15
|
+
modalityId: 'modalityDefaultId',
|
|
16
|
+
itemCode: 'mockItemCode',
|
|
17
|
+
fullName: 'mockClaimItemFullName',
|
|
18
|
+
displayName: 'mockClaimItemDisplayName',
|
|
19
|
+
clinicalCodeSettings: {
|
|
20
|
+
enabled: true,
|
|
21
|
+
displayName: 'mockDisplayName'
|
|
22
|
+
},
|
|
23
|
+
price: 4000
|
|
24
|
+
}],
|
|
25
|
+
searchWords: ['mockdisplayname', 'mockfullname', 'mockitemcode', 'mockclaimitemfullname', 'mockclaimitemdisplayname'],
|
|
26
|
+
isPublic: true,
|
|
27
|
+
status: 'ACTIVE',
|
|
28
|
+
refId: 'serviceDefaultMockRefId',
|
|
29
|
+
refSource: 'serviceDefaultMockRefSource',
|
|
30
|
+
created: new Date('2015-01-01T00:00:00'),
|
|
31
|
+
modified: new Date('2015-01-02T00:00:00Z')
|
|
32
|
+
};
|
|
33
|
+
var serviceWithMultipleClaimItems = {
|
|
34
|
+
_id: 'serviceWithMultipleClaimItemsDefaultId',
|
|
35
|
+
organisationId: 'organisationDefaultId',
|
|
36
|
+
businessId: 'businessDefaultId',
|
|
37
|
+
displayName: 'mockDisplayName',
|
|
38
|
+
fullName: 'mockFullName',
|
|
39
|
+
description: 'mockDescription',
|
|
40
|
+
duration: 60,
|
|
41
|
+
currencyCode: 'AUD',
|
|
42
|
+
modalityId: 'modalityDefaultId',
|
|
43
|
+
claimItems: [{
|
|
44
|
+
_id: 'claimItemDefaultId',
|
|
45
|
+
modalityId: 'modalityDefaultId',
|
|
46
|
+
itemCode: 'mockItemCode',
|
|
47
|
+
fullName: 'mockClaimItemFullName',
|
|
48
|
+
displayName: 'mockClaimItemDisplayName',
|
|
49
|
+
clinicalCodeSettings: {
|
|
50
|
+
enabled: true,
|
|
51
|
+
displayName: 'mockDisplayName'
|
|
52
|
+
},
|
|
53
|
+
price: 1000
|
|
54
|
+
}, {
|
|
55
|
+
_id: 'claimItem2DefaultId',
|
|
56
|
+
modalityId: 'modalityDefaultId',
|
|
57
|
+
itemCode: 'mockItemCode2',
|
|
58
|
+
fullName: 'mockClaimItemFullName2',
|
|
59
|
+
displayName: 'mockClaimItemDisplayName2',
|
|
60
|
+
clinicalCodeSettings: {
|
|
61
|
+
enabled: true,
|
|
62
|
+
displayName: 'mockDisplayName'
|
|
63
|
+
},
|
|
64
|
+
healthFundOverrides: [{
|
|
65
|
+
healthFundId: 'healthFundDefaultId',
|
|
66
|
+
price: 3000
|
|
67
|
+
}],
|
|
68
|
+
price: 4000
|
|
69
|
+
}, {
|
|
70
|
+
_id: 'claimItem3DefaultId',
|
|
71
|
+
modalityId: 'modalityDefaultId',
|
|
72
|
+
itemCode: 'mockItemCode3',
|
|
73
|
+
fullName: 'mockClaimItemFullName3',
|
|
74
|
+
displayName: 'mockClaimItemDisplayName3',
|
|
75
|
+
clinicalCodeSettings: {
|
|
76
|
+
enabled: true,
|
|
77
|
+
displayName: 'mockDisplayName'
|
|
78
|
+
},
|
|
79
|
+
healthFundOverrides: [{
|
|
80
|
+
healthFundId: 'healthFundDefaultId',
|
|
81
|
+
price: 4000
|
|
82
|
+
}],
|
|
83
|
+
price: 2000
|
|
84
|
+
}],
|
|
85
|
+
searchWords: ['mockdisplayname', 'mockfullname', 'mockitemcode', 'mockclaimitemfullname', 'mockclaimitemdisplayname', 'mockitemcode2', 'mockclaimitemfullname2', 'mockclaimitemdisplayname2'],
|
|
86
|
+
status: 'ACTIVE',
|
|
87
|
+
isPublic: true,
|
|
88
|
+
refId: 'serviceWithMultipleClaimItemsDefaultMockRefId',
|
|
89
|
+
refSource: 'serviceWithMultipleClaimItemsDefaultMockRefSource',
|
|
90
|
+
created: new Date('2015-01-01T00:00:00'),
|
|
91
|
+
modified: new Date('2015-01-02T00:00:00Z')
|
|
92
|
+
};
|
|
93
|
+
var defaultServiceItems = [{
|
|
94
|
+
_id: 'claimItemDefaultId',
|
|
95
|
+
modalityId: 'modalityDefaultId',
|
|
96
|
+
itemCode: 'mockItemCode',
|
|
97
|
+
fullName: 'mockClaimItemFullName',
|
|
98
|
+
displayName: 'mockClaimItemDisplayName',
|
|
99
|
+
feeAmount: 1000
|
|
100
|
+
}, {
|
|
101
|
+
_id: 'claimItem2DefaultId',
|
|
102
|
+
modalityId: 'modalityDefaultId',
|
|
103
|
+
itemCode: 'mockItemCode2',
|
|
104
|
+
fullName: 'mockClaimItemFullName2',
|
|
105
|
+
displayName: 'mockClaimItemDisplayName2',
|
|
106
|
+
feeAmount: 4000,
|
|
107
|
+
discountAmount: 1000
|
|
108
|
+
}, {
|
|
109
|
+
_id: 'claimItem3DefaultId',
|
|
110
|
+
modalityId: 'modalityDefaultId',
|
|
111
|
+
itemCode: 'mockItemCode3',
|
|
112
|
+
fullName: 'mockClaimItemFullName3',
|
|
113
|
+
displayName: 'mockClaimItemDisplayName3',
|
|
114
|
+
feeAmount: 2000
|
|
115
|
+
}];
|
|
116
|
+
|
|
117
|
+
var services = /*#__PURE__*/Object.freeze({
|
|
118
|
+
__proto__: null,
|
|
119
|
+
defaultService: defaultService,
|
|
120
|
+
serviceWithMultipleClaimItems: serviceWithMultipleClaimItems,
|
|
121
|
+
defaultServiceItems: defaultServiceItems
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
exports.defaultService = defaultService;
|
|
125
|
+
exports.defaultServiceItems = defaultServiceItems;
|
|
126
|
+
exports.serviceWithMultipleClaimItems = serviceWithMultipleClaimItems;
|
|
127
|
+
exports.services = services;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var defaultSpecialty = {
|
|
4
|
+
_id: 'specialtyDefaultId',
|
|
5
|
+
professionalCategoryId: 'professionalCategoryDefaultId',
|
|
6
|
+
fullName: 'Chiropractor',
|
|
7
|
+
displayName: 'mockDisplayName',
|
|
8
|
+
description: 'mockDescription',
|
|
9
|
+
searchWords: ['chiropractor', 'mockdisplayname'],
|
|
10
|
+
created: new Date('2015-01-01T00:00:00Z'),
|
|
11
|
+
modified: new Date('2015-01-02T00:00:00Z')
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
var specialties = /*#__PURE__*/Object.freeze({
|
|
15
|
+
__proto__: null,
|
|
16
|
+
defaultSpecialty: defaultSpecialty
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
exports.defaultSpecialty = defaultSpecialty;
|
|
20
|
+
exports.specialties = specialties;
|