|
|
|
|
@ -18,23 +18,7 @@ import './profile_medical_info_widget.dart';
|
|
|
|
|
class PatientProfileWidget extends StatelessWidget {
|
|
|
|
|
PatiantInformtion patient;
|
|
|
|
|
|
|
|
|
|
String getPatientAge(dynamic birthday){
|
|
|
|
|
// https://leechy.dev/calculate-dates-diff-in-dart
|
|
|
|
|
DateTime birthDate = DateUtils.getDateTimeFromServerFormat(birthday);
|
|
|
|
|
final now = DateTime.now();
|
|
|
|
|
int years = now.year - birthDate .year;
|
|
|
|
|
int months = now.month - birthDate.month;
|
|
|
|
|
int days = now.day - birthDate.day;
|
|
|
|
|
if (months < 0 || (months == 0 && days < 0)) {
|
|
|
|
|
years--;
|
|
|
|
|
months += (days < 0 ? 11 : 12);
|
|
|
|
|
}
|
|
|
|
|
if (days < 0) {
|
|
|
|
|
final monthAgo = new DateTime(now.year, now.month - 1, birthDate.day);
|
|
|
|
|
days = now.difference(monthAgo).inDays + 1;
|
|
|
|
|
}
|
|
|
|
|
return "$years Yr $months Mnth $days Day";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -133,7 +117,7 @@ class PatientProfileWidget extends StatelessWidget {
|
|
|
|
|
height: 4,
|
|
|
|
|
),
|
|
|
|
|
AppText(
|
|
|
|
|
"${DateUtils.convertDateFromServerFormat(patient.dateofBirth, 'dd-MM-yyyy')} / ${getPatientAge(patient.dateofBirth)/*patient.age*/}",
|
|
|
|
|
"${DateUtils.convertDateFromServerFormat(patient.dateofBirth, 'dd-MM-yyyy')} / ${DateUtils.getAgeByBirthday(patient.dateofBirth)/*patient.age*/}",
|
|
|
|
|
fontWeight: FontWeight.normal,
|
|
|
|
|
fontSize: 1.6 * SizeConfig.textMultiplier,
|
|
|
|
|
),
|
|
|
|
|
|