You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
healthcare-doctor/lib/models/sugar_history_model.dart

62 lines
2.0 KiB

import 'package:flutter/material.dart';
import 'package:doctor/common/settings.dart';
import 'package:intl/intl.dart';
class SugarHistoryModel {
String sugartText = '';
String sugarValue = '';
String fasting= '';
String postPrandial= '';
String date= '';
String displayDate='';
String actualDate='';
String sugarInfoId='';
DateTime dateForFilter=new DateTime.now();
Color sugarValueColor=Colors.black;
SugarHistoryModel();
factory SugarHistoryModel.fromJson(Map<String, dynamic> json){
SugarHistoryModel rtvm = new SugarHistoryModel();
rtvm.sugartText = json['sugarCategory'].toString() ?? '';
rtvm.sugarValue = json['sugarValue'].toString() ?? '';
rtvm.fasting = json['fasting'].toString() ?? '';
rtvm.postPrandial = json['postPrandial'].toString() ?? '';
rtvm.date = json['createdAt'].toString() ?? '';
rtvm.actualDate = json['date'].toString() ?? '';
rtvm.sugarInfoId = json['sugarinfoid'].toString() ?? '';
if(rtvm.sugartText.toUpperCase().toUpperCase()=='VERY HIGH BLOOD SUGAR'){
rtvm.sugarValueColor=Colors.red;
}
else if(rtvm.sugartText.toUpperCase().toUpperCase()=='HIGH BLOOD SUGAR'){
rtvm.sugarValueColor=Colors.red;
}
else if(rtvm.sugartText.toUpperCase().toUpperCase()=='PREDIABETES (IMPAIRED FASTING GLUCOSE)'){
rtvm.sugarValueColor=Colors.red;
}
else if(rtvm.sugartText.toUpperCase().toUpperCase()=='VERY LOW BLOOD SUGAR'){
rtvm.sugarValueColor=Colors.red;
}
else if(rtvm.sugartText.toUpperCase().toUpperCase()=='LOW BLOOD SUGAR'){
rtvm.sugarValueColor=Colors.red;
}
else if(rtvm.sugartText.toUpperCase().toUpperCase()=='NORMAL BLOOD SUGAR (HEALTHY RANGE)'){
rtvm.sugarValueColor=buttonColors;
}
else{
rtvm.sugarValueColor=Colors.black;
}
//DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(rtvm.date);
rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.actualDate);
return rtvm;
}
}