openchs-models 1.30.21 → 1.30.23

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.
Files changed (2) hide show
  1. package/dist/Individual.js +11 -2
  2. package/package.json +1 -1
@@ -408,10 +408,19 @@ class Individual extends _BaseEntity.default {
408
408
  const ageInYears = this.getAgeInYears();
409
409
 
410
410
  if (ageInYears < 1) {
411
- let ageInWeeks = (0, _moment.default)().diff(this.dateOfBirth, "weeks");
411
+ let ageInWeeks = this.getAgeInWeeks();
412
412
  return ageInWeeks === 0 ? _Duration.default.inDay((0, _moment.default)().diff(this.dateOfBirth, "days")).toString(i18n) : _Duration.default.inWeek(ageInWeeks).toString(i18n);
413
413
  } else if (ageInYears < 2) {
414
- return _Duration.default.inMonth((0, _moment.default)().diff(this.dateOfBirth, "months")).toString(i18n);
414
+ return _Duration.default.inMonth(this.getAgeInMonths()).toString(i18n);
415
+ } else if (ageInYears < 6) {
416
+ let ageInMonths = this.getAgeInMonths();
417
+
418
+ let noOfYears = _lodash.default.toInteger(ageInMonths / 12);
419
+
420
+ let noOfMonths = ageInMonths % 12;
421
+ let durationInYears = `${_Duration.default.inYear(noOfYears).toString(i18n)}`;
422
+ if (noOfMonths > 0) return `${durationInYears} ${_Duration.default.inMonth(noOfMonths).toString(i18n)}`;
423
+ return durationInYears;
415
424
  } else {
416
425
  return _Duration.default.inYear(ageInYears).toString(i18n);
417
426
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openchs-models",
3
3
  "description": "OpenCHS data model to be used by front end clients",
4
- "version": "1.30.21",
4
+ "version": "1.30.23",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",