openchs-models 1.30.24 → 1.30.25
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/.github/add_to_project.yml +16 -0
- package/.github/workflows/add_to_project.yml +18 -0
- package/dist/EntityMetaData.js +2 -15
- package/dist/Individual.js +9 -37
- package/dist/index.js +9 -7
- package/dist/reports/DashboardFilterConfig.js +5 -1
- package/dist/utility/AgeUtil.js +59 -0
- package/dist/utility/DateTimeUtil.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
name: Add to Product board
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
add-to-project:
|
|
10
|
+
name: Add all issues created in this repository to the Avni product board
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/add-to-project@v0.5.0
|
|
14
|
+
with:
|
|
15
|
+
project-url: https://github.com/orgs/avniproject/projects/2
|
|
16
|
+
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Automatically add items to project
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
issues:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
add-to-project:
|
|
10
|
+
name: Add issue to project
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/add-to-project@v0.5.0
|
|
14
|
+
with:
|
|
15
|
+
# You can target a project in a different organization
|
|
16
|
+
# to the issue
|
|
17
|
+
project-url: https://github.com/orgs/avniproject/projects/2/
|
|
18
|
+
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}
|
package/dist/EntityMetaData.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _Concept = _interopRequireDefault(require("./Concept"));
|
|
9
9
|
|
|
@@ -490,11 +490,6 @@ const groupDashboard = refData(_GroupDashboard.default, {
|
|
|
490
490
|
res: "groupDashboard",
|
|
491
491
|
syncWeight: 0
|
|
492
492
|
});
|
|
493
|
-
const EntityApprovalStatusMetaData = txData(_EntityApprovalStatus.default, {
|
|
494
|
-
res: "entityApprovalStatus",
|
|
495
|
-
entityName: "EntityApprovalStatus"
|
|
496
|
-
});
|
|
497
|
-
exports.EntityApprovalStatusMetaData = EntityApprovalStatusMetaData;
|
|
498
493
|
const subjectEntityApprovalStatus = virtualTxData(_EntityApprovalStatus.default, {
|
|
499
494
|
res: "entityApprovalStatus",
|
|
500
495
|
resUrl: "entityApprovalStatus",
|
|
@@ -653,18 +648,10 @@ class EntityMetaData {
|
|
|
653
648
|
}
|
|
654
649
|
|
|
655
650
|
static findByName(entityName) {
|
|
656
|
-
return
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
static findByNameIn(entityName, modelCollection) {
|
|
660
|
-
return _lodash.default.find(modelCollection, //TODO check if this works
|
|
651
|
+
return _lodash.default.find(EntityMetaData.model(), //TODO check if this works
|
|
661
652
|
entityMetadata => entityMetadata.entityName === entityName);
|
|
662
653
|
}
|
|
663
654
|
|
|
664
|
-
static allModels() {
|
|
665
|
-
return _lodash.default.concat(EntityApprovalStatusMetaData, EntityMetaData.model());
|
|
666
|
-
}
|
|
667
|
-
|
|
668
655
|
}
|
|
669
656
|
|
|
670
657
|
var _default = EntityMetaData;
|
package/dist/Individual.js
CHANGED
|
@@ -51,6 +51,8 @@ var _ArrayHelper = _interopRequireDefault(require("./framework/ArrayHelper"));
|
|
|
51
51
|
|
|
52
52
|
var _MergeUtil = _interopRequireDefault(require("./utility/MergeUtil"));
|
|
53
53
|
|
|
54
|
+
var _AgeUtil = _interopRequireDefault(require("./utility/AgeUtil"));
|
|
55
|
+
|
|
54
56
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
57
|
|
|
56
58
|
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; }
|
|
@@ -403,28 +405,14 @@ class Individual extends _BaseEntity.default {
|
|
|
403
405
|
this.name = this.nameString;
|
|
404
406
|
}
|
|
405
407
|
|
|
406
|
-
getDisplayAge(i18n) {
|
|
407
|
-
//Keeping date of birth to be always entered and displayed as per the current date. It would be perhaps more error prone for users to put themselves in the past and enter age as of that date
|
|
408
|
-
const ageInYears = this.getAgeInYears();
|
|
409
|
-
|
|
410
|
-
if (ageInYears < 1) {
|
|
411
|
-
let ageInWeeks = (0, _moment.default)().diff(this.dateOfBirth, "weeks");
|
|
412
|
-
return ageInWeeks === 0 ? _Duration.default.inDay((0, _moment.default)().diff(this.dateOfBirth, "days")).toString(i18n) : _Duration.default.inWeek(ageInWeeks).toString(i18n);
|
|
413
|
-
} else if (ageInYears < 2) {
|
|
414
|
-
return _Duration.default.inMonth((0, _moment.default)().diff(this.dateOfBirth, "months")).toString(i18n);
|
|
415
|
-
} else {
|
|
416
|
-
return _Duration.default.inYear(ageInYears).toString(i18n);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
|
|
420
408
|
getAgeAndDateOfBirthDisplay(i18n) {
|
|
421
|
-
if (this.dateOfBirthVerified) return `${
|
|
422
|
-
return
|
|
409
|
+
if (this.dateOfBirthVerified) return `${_AgeUtil.default.getDisplayAge(this.dateOfBirth, i18n)} (${_General.default.toDisplayDate(this.dateOfBirth)})`;
|
|
410
|
+
return _AgeUtil.default.getDisplayAge(this.dateOfBirth, i18n);
|
|
423
411
|
}
|
|
424
412
|
|
|
425
413
|
getAge(asOnDate = (0, _moment.default)()) {
|
|
426
|
-
if (
|
|
427
|
-
if (
|
|
414
|
+
if (_AgeUtil.default.getAgeInYears(this.dateOfBirth, asOnDate) > 0) return _Duration.default.inYear(_AgeUtil.default.getAgeInYears(this.dateOfBirth));
|
|
415
|
+
if (_AgeUtil.default.getAgeInMonths(this.dateOfBirth, asOnDate) > 0) return _Duration.default.inMonth(asOnDate.diff(this.dateOfBirth, "months"));
|
|
428
416
|
return _Duration.default.inYear(0);
|
|
429
417
|
}
|
|
430
418
|
|
|
@@ -448,22 +436,6 @@ class Individual extends _BaseEntity.default {
|
|
|
448
436
|
}
|
|
449
437
|
}
|
|
450
438
|
|
|
451
|
-
getAgeIn(unit) {
|
|
452
|
-
return (asOnDate = (0, _moment.default)(), precise = false) => (0, _moment.default)(asOnDate).diff(this.dateOfBirth, unit, precise);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
getAgeInMonths(asOnDate = (0, _moment.default)(), precise = false) {
|
|
456
|
-
return this.getAgeIn("months")(asOnDate, precise);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
getAgeInWeeks(asOnDate, precise) {
|
|
460
|
-
return this.getAgeIn("weeks")(asOnDate, precise);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
getAgeInYears(asOnDate = (0, _moment.default)(), precise = false) {
|
|
464
|
-
return this.getAgeIn("years")(asOnDate, precise);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
439
|
toSummaryString() {
|
|
468
440
|
return `${this.name}, Age: ${this.getAge().toString()}, ${this.gender.name}`;
|
|
469
441
|
}
|
|
@@ -483,7 +455,7 @@ class Individual extends _BaseEntity.default {
|
|
|
483
455
|
return _ValidationResult.default.failure(Individual.validationKeys.DOB, "emptyValidationMessage");
|
|
484
456
|
} else if (!(0, _moment.default)(this.dateOfBirth).isValid()) {
|
|
485
457
|
return _ValidationResult.default.failure(Individual.validationKeys.DOB, "invalidDateFormat");
|
|
486
|
-
} else if (
|
|
458
|
+
} else if (_AgeUtil.default.getAgeInYears(this.dateOfBirth) > 120) {
|
|
487
459
|
return _ValidationResult.default.failure(Individual.validationKeys.DOB, "ageTooHigh");
|
|
488
460
|
} else if (this.isRegistrationBeforeDateOfBirth) {
|
|
489
461
|
return _ValidationResult.default.failure(Individual.validationKeys.DOB, "registrationBeforeDateOfBirth");
|
|
@@ -818,14 +790,14 @@ class Individual extends _BaseEntity.default {
|
|
|
818
790
|
}
|
|
819
791
|
|
|
820
792
|
userProfileSubtext2(i18n) {
|
|
821
|
-
return this.isPerson() ?
|
|
793
|
+
return this.isPerson() ? _AgeUtil.default.getDisplayAge(this.dateOfBirth, i18n) : "";
|
|
822
794
|
} //TODO these methods are slightly differece because of differece in UI on search result and my dashboard listing. Not taking the hit right now.
|
|
823
795
|
|
|
824
796
|
|
|
825
797
|
detail1(i18n) {
|
|
826
798
|
return this.isPerson() ? {
|
|
827
799
|
label: "Age",
|
|
828
|
-
value:
|
|
800
|
+
value: _AgeUtil.default.getDisplayAge(this.dateOfBirth, i18n)
|
|
829
801
|
} : {};
|
|
830
802
|
}
|
|
831
803
|
|
package/dist/index.js
CHANGED
|
@@ -105,12 +105,6 @@ Object.defineProperty(exports, "EntityMetaData", {
|
|
|
105
105
|
return _EntityMetaData.default;
|
|
106
106
|
}
|
|
107
107
|
});
|
|
108
|
-
Object.defineProperty(exports, "EntityApprovalStatusMetaData", {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
get: function () {
|
|
111
|
-
return _EntityMetaData.EntityApprovalStatusMetaData;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
108
|
Object.defineProperty(exports, "EntityQueue", {
|
|
115
109
|
enumerable: true,
|
|
116
110
|
get: function () {
|
|
@@ -795,6 +789,12 @@ Object.defineProperty(exports, "DateTimeUtil", {
|
|
|
795
789
|
return _DateTimeUtil.default;
|
|
796
790
|
}
|
|
797
791
|
});
|
|
792
|
+
Object.defineProperty(exports, "AgeUtil", {
|
|
793
|
+
enumerable: true,
|
|
794
|
+
get: function () {
|
|
795
|
+
return _AgeUtil.default;
|
|
796
|
+
}
|
|
797
|
+
});
|
|
798
798
|
|
|
799
799
|
var _AbstractEncounter = _interopRequireDefault(require("./AbstractEncounter"));
|
|
800
800
|
|
|
@@ -828,7 +828,7 @@ var _Encounter = _interopRequireDefault(require("./Encounter"));
|
|
|
828
828
|
|
|
829
829
|
var _EncounterType = _interopRequireDefault(require("./EncounterType"));
|
|
830
830
|
|
|
831
|
-
var _EntityMetaData =
|
|
831
|
+
var _EntityMetaData = _interopRequireDefault(require("./EntityMetaData"));
|
|
832
832
|
|
|
833
833
|
var _EntityQueue = _interopRequireDefault(require("./EntityQueue"));
|
|
834
834
|
|
|
@@ -1052,6 +1052,8 @@ var _ArrayUtil = _interopRequireDefault(require("./utility/ArrayUtil"));
|
|
|
1052
1052
|
|
|
1053
1053
|
var _DateTimeUtil = _interopRequireDefault(require("./utility/DateTimeUtil"));
|
|
1054
1054
|
|
|
1055
|
+
var _AgeUtil = _interopRequireDefault(require("./utility/AgeUtil"));
|
|
1056
|
+
|
|
1055
1057
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
1056
1058
|
|
|
1057
1059
|
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; }
|
|
@@ -186,10 +186,14 @@ class DashboardFilterConfig {
|
|
|
186
186
|
validate(filterValue) {
|
|
187
187
|
const inputDataType = this.getInputDataType();
|
|
188
188
|
|
|
189
|
-
if ([_Concept.default.dataType.Date, _Concept.default.dataType.DateTime
|
|
189
|
+
if ([_Concept.default.dataType.Date, _Concept.default.dataType.DateTime].includes(inputDataType) && this.widget === _CustomFilter.default.widget.Range) {
|
|
190
190
|
return _DateTimeUtil.default.validateDateRange(filterValue.minValue, filterValue.maxValue);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
if (_Concept.default.dataType.Time === inputDataType && this.widget === _CustomFilter.default.widget.Range) {
|
|
194
|
+
return _DateTimeUtil.default.validateTimeRange(filterValue.minValue, filterValue.maxValue);
|
|
195
|
+
}
|
|
196
|
+
|
|
193
197
|
return [true];
|
|
194
198
|
}
|
|
195
199
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _Duration = _interopRequireDefault(require("../Duration"));
|
|
9
|
+
|
|
10
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
11
|
+
|
|
12
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
class AgeUtil {
|
|
17
|
+
static getDisplayAge(dateOfBirth, i18n) {
|
|
18
|
+
//Keeping date of birth to be always entered and displayed as per the current date. It would be perhaps more error prone for users to put themselves in the past and enter age as of that date
|
|
19
|
+
const ageInYears = this.getAgeInYears(dateOfBirth);
|
|
20
|
+
|
|
21
|
+
if (ageInYears < 1) {
|
|
22
|
+
let ageInWeeks = this.getAgeInWeeks(dateOfBirth);
|
|
23
|
+
return ageInWeeks === 0 ? _Duration.default.inDay((0, _moment.default)().diff(dateOfBirth, "days")).toString(i18n) : _Duration.default.inWeek(ageInWeeks).toString(i18n);
|
|
24
|
+
} else if (ageInYears < 2) {
|
|
25
|
+
return _Duration.default.inMonth(this.getAgeInMonths(dateOfBirth)).toString(i18n);
|
|
26
|
+
} else if (ageInYears < 6) {
|
|
27
|
+
let ageInMonths = this.getAgeInMonths(dateOfBirth);
|
|
28
|
+
|
|
29
|
+
let noOfYears = _lodash.default.toInteger(ageInMonths / 12);
|
|
30
|
+
|
|
31
|
+
let noOfMonths = ageInMonths % 12;
|
|
32
|
+
let durationInYears = `${_Duration.default.inYear(noOfYears).toString(i18n)}`;
|
|
33
|
+
if (noOfMonths > 0) return `${durationInYears} ${_Duration.default.inMonth(noOfMonths).toString(i18n)}`;
|
|
34
|
+
return durationInYears;
|
|
35
|
+
} else {
|
|
36
|
+
return _Duration.default.inYear(ageInYears).toString(i18n);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static getAgeInYears(dateOfBirth, asOnDate = (0, _moment.default)(), precise = false) {
|
|
41
|
+
return this.getAgeIn(dateOfBirth, "years")(asOnDate, precise);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static getAgeInMonths(dateOfBirth, asOnDate = (0, _moment.default)(), precise = false) {
|
|
45
|
+
return this.getAgeIn(dateOfBirth, "months")(asOnDate, precise);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static getAgeInWeeks(dateOfBirth, asOnDate, precise) {
|
|
49
|
+
return this.getAgeIn(dateOfBirth, "weeks")(asOnDate, precise);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static getAgeIn(dateOfBirth, unit) {
|
|
53
|
+
return (asOnDate = (0, _moment.default)(), precise = false) => (0, _moment.default)(asOnDate).diff(dateOfBirth, unit, precise);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var _default = AgeUtil;
|
|
59
|
+
exports.default = _default;
|
|
@@ -19,6 +19,13 @@ class DateTimeUtil {
|
|
|
19
19
|
return [true];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
static validateTimeRange(fromTime, toTime) {
|
|
23
|
+
if (_lodash.default.isNil(toTime) && _lodash.default.isNil(fromTime)) return [true];
|
|
24
|
+
if (_lodash.default.isNil(toTime) || _lodash.default.isNil(fromTime)) return [false, 'bothTimeShouldBeSelectedError'];
|
|
25
|
+
if (!(0, _moment.default)(fromTime, 'HH:mm').isSameOrBefore((0, _moment.default)(toTime, 'HH:mm'))) return [false, 'startTimeGreaterThanEndError'];
|
|
26
|
+
return [true];
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
}
|
|
23
30
|
|
|
24
31
|
var _default = DateTimeUtil;
|