Skip to content

Commit

Permalink
Merge pull request #184 from codeforpakistan/long-Range
Browse files Browse the repository at this point in the history
  • Loading branch information
sohail0992 authored Dec 8, 2023
2 parents 66f7800 + a8be4c9 commit 3c2968e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/hcai_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@ class _HcaiFormPageState extends State<HcaiFormPage> {
if (setDate['calculatedKey'] == 'dateofCautiEvent') {
this._values['infectionWindowPeriod'] =
Helper.rangeInText(this._values);
this._values['repeatInfectionTimeframe'] =
Helper.longRange(this._values);
this._values['secondaryBloodAttributionPeriod'] =
Helper.longRange(this._values);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions lib/utils/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,20 @@ class Helper {
}
}

static String longRange(_values) {
try {
var dateToConsider = _values['dateofCautiEvent'];
if (isNullOrEmpty(dateToConsider)) return '';
dateToConsider = DateTime.parse(dateToConsider);
DateTime startDate = dateToConsider;
DateTime endDate = dateToConsider.add(Duration(days: 13));
return '${DateFormat('MMMM d').format(startDate)} - ${DateFormat('d').format(endDate)}';
} catch (e) {
print(e);
return '';
}
}

static greaterThanDate(dateList, criteria, _values) {
try {
if (criteria == 'smallest') {}
Expand Down

0 comments on commit 3c2968e

Please sign in to comment.