openchs-models 1.30.21 → 1.30.22

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.
@@ -412,6 +412,15 @@ class Individual extends _BaseEntity.default {
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
414
  return _Duration.default.inMonth((0, _moment.default)().diff(this.dateOfBirth, "months")).toString(i18n);
415
+ } else if (ageInYears < 6) {
416
+ let ageInMonths = (0, _moment.default)().diff(this.dateOfBirth, "months");
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.22",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",