openchs-models 1.30.0 → 1.30.2
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.
|
@@ -258,10 +258,11 @@ class ObservationsHolder {
|
|
|
258
258
|
|
|
259
259
|
const {
|
|
260
260
|
value,
|
|
261
|
-
questionGroupIndex
|
|
261
|
+
questionGroupIndex,
|
|
262
|
+
initializedWithNullValueOnPurpose
|
|
262
263
|
} = formElementStatus;
|
|
263
264
|
|
|
264
|
-
if (!_lodash.default.isNil(value)) {
|
|
265
|
+
if (!_lodash.default.isNil(value) || !!initializedWithNullValueOnPurpose) {
|
|
265
266
|
const concept = fe.concept;
|
|
266
267
|
|
|
267
268
|
if (fe.isQuestionGroup()) {
|
|
@@ -270,7 +271,7 @@ class ObservationsHolder {
|
|
|
270
271
|
}) => fe.groupUuid === uuid);
|
|
271
272
|
|
|
272
273
|
updateQuestionGroupObs(parentFormElement, questionGroupIndex, fe, value);
|
|
273
|
-
} else if (concept.isQuestionGroup() && _lodash.default.isArray(value)) {
|
|
274
|
+
} else if (concept.isQuestionGroup() && !_lodash.default.isNil(value) && _lodash.default.isArray(value)) {
|
|
274
275
|
const observation = this.findObservation(concept);
|
|
275
276
|
const questionGroup = observation && observation.getValueWrapper();
|
|
276
277
|
const size = questionGroup ? questionGroup.size() : 0;
|
|
@@ -391,9 +392,11 @@ class ObservationsHolder {
|
|
|
391
392
|
observation = _Observation.default.create(childConcept, isSingleSelect ? new _SingleCodedValue.default(value) : new _MultipleCodedValues.default().push(value));
|
|
392
393
|
childObservations.addObservation(observation);
|
|
393
394
|
} else {
|
|
394
|
-
|
|
395
|
+
if (!_lodash.default.isNil(value)) {
|
|
396
|
+
isSingleSelect ? observation.toggleSingleSelectAnswer(value) : observation.toggleMultiSelectAnswer(value);
|
|
397
|
+
}
|
|
395
398
|
|
|
396
|
-
if (observation.hasNoAnswer()) {
|
|
399
|
+
if (observation.hasNoAnswer() || _lodash.default.isNil(value)) {
|
|
397
400
|
childObservations.removeExistingObs(childConcept);
|
|
398
401
|
}
|
|
399
402
|
}
|
|
@@ -5,14 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
8
12
|
class FormElementStatus {
|
|
9
|
-
constructor(uuid, visibility, value, answersToSkip = [], validationErrors = [], answersToShow = []) {
|
|
13
|
+
constructor(uuid, visibility, value, answersToSkip = [], validationErrors = [], answersToShow = [], initializedWithNullValueOnPurpose = false) {
|
|
10
14
|
this.uuid = uuid;
|
|
11
15
|
this.visibility = visibility;
|
|
12
16
|
this.value = value;
|
|
13
17
|
this.answersToSkip = answersToSkip;
|
|
14
18
|
this.validationErrors = validationErrors;
|
|
15
19
|
this.answersToShow = answersToShow;
|
|
20
|
+
this.initializedWithNullValueOnPurpose = initializedWithNullValueOnPurpose;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static _resetIfValueIsNull(uuid, visibility, value, answersToSkip = [], validationErrors = [], answersToShow = []) {
|
|
24
|
+
return new FormElementStatus(uuid, visibility, value, answersToSkip, validationErrors, answersToShow, _lodash.default.isNil(value));
|
|
16
25
|
}
|
|
17
26
|
|
|
18
27
|
_bool(formElementStatus, op) {
|
|
@@ -24,6 +33,7 @@ class FormElementStatus {
|
|
|
24
33
|
oredFormElementStatus.validationErrors = this.validationErrors;
|
|
25
34
|
oredFormElementStatus.answersToShow = this.answersToShow;
|
|
26
35
|
oredFormElementStatus.questionGroupIndex = this.questionGroupIndex;
|
|
36
|
+
oredFormElementStatus.initializedWithNullValueOnPurpose = this.initializedWithNullValueOnPurpose;
|
|
27
37
|
return oredFormElementStatus;
|
|
28
38
|
}
|
|
29
39
|
|
package/dist/index.js
CHANGED
|
@@ -783,6 +783,12 @@ Object.defineProperty(exports, "ArrayUtil", {
|
|
|
783
783
|
return _ArrayUtil.default;
|
|
784
784
|
}
|
|
785
785
|
});
|
|
786
|
+
Object.defineProperty(exports, "DateTimeUtil", {
|
|
787
|
+
enumerable: true,
|
|
788
|
+
get: function () {
|
|
789
|
+
return _DateTimeUtil.default;
|
|
790
|
+
}
|
|
791
|
+
});
|
|
786
792
|
|
|
787
793
|
var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
|
|
788
794
|
|
|
@@ -1038,6 +1044,8 @@ var _MetaDataService = _interopRequireDefault(require("./service/MetaDataService
|
|
|
1038
1044
|
|
|
1039
1045
|
var _ArrayUtil = _interopRequireDefault(require("./utility/ArrayUtil"));
|
|
1040
1046
|
|
|
1047
|
+
var _DateTimeUtil = _interopRequireDefault(require("./utility/DateTimeUtil"));
|
|
1048
|
+
|
|
1041
1049
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
1042
1050
|
|
|
1043
1051
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -11,6 +11,8 @@ var _Concept = _interopRequireDefault(require("../Concept"));
|
|
|
11
11
|
|
|
12
12
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
13
|
|
|
14
|
+
var _DateTimeUtil = _interopRequireDefault(require("../utility/DateTimeUtil"));
|
|
15
|
+
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
17
|
|
|
16
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -197,6 +199,16 @@ class DashboardFilterConfig {
|
|
|
197
199
|
return this.isConceptTypeFilter() && this.observationBasedFilter.willObservationBeInScopeOfEncounter();
|
|
198
200
|
}
|
|
199
201
|
|
|
202
|
+
validate(filterValue) {
|
|
203
|
+
const inputDataType = this.getInputDataType();
|
|
204
|
+
|
|
205
|
+
if ([_Concept.default.dataType.Date, _Concept.default.dataType.DateTime, _Concept.default.dataType.Time].includes(inputDataType) && this.widget === _CustomFilter.default.widget.Range) {
|
|
206
|
+
return _DateTimeUtil.default.validateDateRange(filterValue.minValue, filterValue.maxValue);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return [true];
|
|
210
|
+
}
|
|
211
|
+
|
|
200
212
|
clone() {
|
|
201
213
|
const clone = new DashboardFilterConfig();
|
|
202
214
|
clone.type = this.type;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
|
|
10
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
class DateTimeUtil {
|
|
15
|
+
static validateDateRange(fromDate, toDate) {
|
|
16
|
+
if (_lodash.default.isNil(toDate) && _lodash.default.isNil(fromDate)) return [true];
|
|
17
|
+
if (_lodash.default.isNil(toDate) || _lodash.default.isNil(fromDate)) return [false, 'bothDateShouldBeSelectedError'];
|
|
18
|
+
if (!(0, _moment.default)(fromDate).isSameOrBefore(toDate)) return [false, 'startDateGreaterThanEndError'];
|
|
19
|
+
return [true];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var _default = DateTimeUtil;
|
|
25
|
+
exports.default = _default;
|
package/dist/utility/General.js
CHANGED
|
@@ -285,6 +285,16 @@ class General {
|
|
|
285
285
|
return !isNaN(parseFloat(str)) && isFinite(str);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
static isDeepEmpty(x) {
|
|
289
|
+
if (_lodash.default.isEmpty(x)) return true;
|
|
290
|
+
|
|
291
|
+
if (!_lodash.default.isArray(x)) {
|
|
292
|
+
return _lodash.default.reduce(Object.values(x), (isEmpty, v) => _lodash.default.isNil(v) && isEmpty, true);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
|
|
288
298
|
}
|
|
289
299
|
|
|
290
300
|
_defineProperty(General, "LogLevel", {
|