|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class BmiHistoryModel {
|
|
|
|
String bmiValue = '';
|
|
|
|
String height= '';
|
|
|
|
String weight= '';
|
|
|
|
String date= '';
|
|
|
|
String actualDate= '';
|
|
|
|
String displayDate='';
|
|
|
|
DateTime dateForFilter=new DateTime.now();
|
|
|
|
String bmiInfoId = '';
|
|
|
|
String bmiText = '';
|
|
|
|
|
|
|
|
var number1;
|
|
|
|
var number2;
|
|
|
|
|
|
|
|
BmiHistoryModel();
|
|
|
|
|
|
|
|
factory BmiHistoryModel.fromJson(Map<String, dynamic> json){
|
|
|
|
BmiHistoryModel rtvm = new BmiHistoryModel();
|
|
|
|
/*"heightUnit": "feet",
|
|
|
|
"weightUnit": "kg",oh
|
|
|
|
"_id": "6493fe48eca67b71b8444e24",
|
|
|
|
"bmiinfoid": "BMI1687420488845468",
|
|
|
|
"customerId": "AHSUSNE2",
|
|
|
|
"height": "164.592",
|
|
|
|
"weight": "50",
|
|
|
|
"age": 27,
|
|
|
|
"bmivalue": 18.46,
|
|
|
|
"createdAt": "2023-06-22T07:54:48.847Z",
|
|
|
|
"updatedAt": "2023-06-22T07:54:48.847Z",*/
|
|
|
|
|
|
|
|
rtvm.bmiValue = json['bmivalue'].toString() ?? '';
|
|
|
|
rtvm.bmiInfoId = json['bmiinfoid'].toString() ?? '';
|
|
|
|
rtvm.height = json['height'].toString() ?? '';
|
|
|
|
rtvm.weight = json['weight'].toString() ?? '';
|
|
|
|
rtvm.number1 = double.parse( rtvm.bmiValue);
|
|
|
|
rtvm.number2 = double.parse( rtvm.bmiValue);
|
|
|
|
rtvm.date = json['createdAt'].toString() ?? '';
|
|
|
|
rtvm.actualDate = json['date'].toString() ?? '';
|
|
|
|
rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.actualDate);
|
|
|
|
if(double.parse(rtvm.bmiValue)<18.5){
|
|
|
|
rtvm.bmiText='Underweight';
|
|
|
|
}
|
|
|
|
else if(double.parse(rtvm.bmiValue)>=18.5&&double.parse(rtvm.bmiValue)<=24.9){
|
|
|
|
rtvm.bmiText='Normal weight';
|
|
|
|
}
|
|
|
|
else if(double.parse(rtvm.bmiValue)>=25&&double.parse(rtvm.bmiValue)<=29.9){
|
|
|
|
rtvm.bmiText='Overweight';
|
|
|
|
}
|
|
|
|
else if(double.parse(rtvm.bmiValue)>=30){
|
|
|
|
rtvm.bmiText='Obesity';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return rtvm;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|