Meal Plan development continued

Dev_3.3_InPatient_CR
haroon amjad 2 years ago
parent d073eb9d5f
commit 38648df897

@ -609,7 +609,7 @@ var SAVE_BIRTH_NOTIFICATION = 'Services/INPs.svc/REST/SaveBirthNotification';
//Meal Plan APIs
var GET_ADMITTED_PATIENTS = 'Services/MOP.svc/REST/GetAdmittedPatients';
var GET_CURRENT_WEEKID_WEEKDAY = 'Services/MOP.svc/REST/GetCurrentWeekAndDayHMGMP';
var GET_MEALS_OF_SCHEDULE_ID = 'Services/MOP.svc/REST/GetMealsOfScheduleID';
var GET_MEALS_OF_SCHEDULE_ID = 'Services/MOP.svc/REST/GetMealsOfScheduleID_Mobile';
var GET_MEAL_ITEMS_OF_SCHEDULE_ID = 'Services/MOP.svc/REST/GetDefaultItemsOfScheduleID';
class AppGlobal {

@ -152,6 +152,10 @@ class BaseAppClient {
// body['PatientID'] = 3649542; //3844083
// body['TokenID'] = "@dm!n";
body['PatientID'] = 3649238; //3844083
body['AdmissionNo'] = 2023000038; //3844083
body['TokenID'] = "@dm!n";
// Patient ID: 3027574
// Mobile no.: 0502303285
// ID: 119116817

@ -58,3 +58,12 @@ class GetMealItemsScheduleResponseModel {
return data;
}
}
class GetMealItemsScheduleResponseModelList {
String filterName = "";
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelList = [];
GetMealItemsScheduleResponseModelList({this.filterName, GetMealItemsScheduleResponseModel getMealItemsScheduleResponseModel}) {
getMealItemsScheduleResponseModelList.add(getMealItemsScheduleResponseModel);
}
}

@ -9,8 +9,22 @@ class GetMealsScheduleResponseModel {
String tAT;
int dietTypeID;
int dayID;
bool isShow;
String tATTime;
GetMealsScheduleResponseModel({this.scheduleID, this.mealID, this.description, this.descriptionN, this.weekID, this.weekDescription, this.weekDescriptionN, this.tAT, this.dietTypeID, this.dayID});
GetMealsScheduleResponseModel(
{this.scheduleID,
this.mealID,
this.description,
this.descriptionN,
this.weekID,
this.weekDescription,
this.weekDescriptionN,
this.tAT,
this.dietTypeID,
this.dayID,
this.isShow,
this.tATTime});
GetMealsScheduleResponseModel.fromJson(Map<String, dynamic> json) {
scheduleID = json['ScheduleID'];
@ -23,6 +37,8 @@ class GetMealsScheduleResponseModel {
tAT = json['TAT'];
dietTypeID = json['DietTypeID'];
dayID = json['DayID'];
isShow = json['IsShow'];
tATTime = json['TATTime'];
}
Map<String, dynamic> toJson() {
@ -37,6 +53,8 @@ class GetMealsScheduleResponseModel {
data['TAT'] = this.tAT;
data['DietTypeID'] = this.dietTypeID;
data['DayID'] = this.dayID;
data['IsShow'] = this.isShow;
data['TATTime'] = this.tATTime;
return data;
}
}

@ -4,9 +4,12 @@ import 'package:diplomaticquarterapp/models/InPatientServices/get_meal_items_sch
import 'package:diplomaticquarterapp/models/InPatientServices/get_meals_schedule_response_model.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart';
import 'package:diplomaticquarterapp/widgets/my_rich_text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
@ -28,6 +31,10 @@ class _MealPlanPageState extends State<MealPlanPage> {
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelLunch = [];
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelDinner = [];
List<GetMealItemsScheduleResponseModelList> _getMealItemsScheduleResponseModelBreakfast = [];
List<GetMealItemsScheduleResponseModelList> _getMealItemsScheduleResponseModelLunch = [];
List<GetMealItemsScheduleResponseModelList> _getMealItemsScheduleResponseModelDinner = [];
int currentDay = 0;
int currentWeek = 0;
@ -56,15 +63,64 @@ class _MealPlanPageState extends State<MealPlanPage> {
Container(
decoration: containerRadius(Colors.white, 12),
child: AppExpandableNotifier(
title: "Breakfast TAT: 10:00 AM",
title: "Breakfast TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[0].tATTime),
isTitleSingleLine: false,
widgetColor: Colors.transparent,
bodyWidget: Column(
children: [
getDivider(),
Container(
height: 200.0,
),
ListView.separated(
physics: BouncingScrollPhysics(),
padding: EdgeInsets.only(top: 12),
shrinkWrap: true,
itemBuilder: (context, index) {
return Container(
padding: EdgeInsets.all(21.0),
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
LargeAvatar(
name: getMealItemsScheduleResponseModelBreakfast[index].description,
url: "https://www.pumpkinnspice.com/wp-content/uploads/2016/03/easy-breakfast-quesadillas-11-683x1024.jpg",
width: 60,
height: 60,
),
SizedBox(width: 11),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
MyRichText(
"",
projectViewModel.isArabic ? _getMealItemsScheduleResponseModelBreakfast[index].filterName : _getMealItemsScheduleResponseModelBreakfast[index].filterName,
projectViewModel.isArabic),
// MyRichText(
// "",
// projectViewModel.isArabic
// ? getMealItemsScheduleResponseModelBreakfast[index].categoryDescriptionN
// : getMealItemsScheduleResponseModelBreakfast[index].categoryDescription ?? "",
// projectViewModel.isArabic),
],
),
),
],
),
);
},
separatorBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: Divider(
height: 1.5,
thickness: 1.0,
color: Colors.grey.shade200,
),
);
},
itemCount: _getMealItemsScheduleResponseModelBreakfast.length),
],
),
),
@ -73,7 +129,7 @@ class _MealPlanPageState extends State<MealPlanPage> {
Container(
decoration: containerRadius(Colors.white, 12),
child: AppExpandableNotifier(
title: "Lunch TAT: 04:00 PM",
title: "Lunch TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[1].tATTime),
isTitleSingleLine: false,
widgetColor: Colors.transparent,
bodyWidget: Column(
@ -90,7 +146,7 @@ class _MealPlanPageState extends State<MealPlanPage> {
Container(
decoration: containerRadius(Colors.white, 12),
child: AppExpandableNotifier(
title: "Dinner TAT: 12:00 AM",
title: "Dinner TAT: " + DateUtil.convertTime(getMealsScheduleResponseModelList[2].tATTime),
isTitleSingleLine: false,
widgetColor: Colors.transparent,
bodyWidget: Column(
@ -133,7 +189,6 @@ class _MealPlanPageState extends State<MealPlanPage> {
getCurrentWeekIDAndDay(getAdmittedPatientsResponseModel.dietType);
} else {
AppToast.showErrorToast(message: "No data found for admitted patient");
getCurrentWeekIDAndDay(1);
}
}).catchError((err) {
@ -161,8 +216,8 @@ class _MealPlanPageState extends State<MealPlanPage> {
GifLoaderDialogUtils.showMyDialog(context);
service.getMealsOfScheduleID(projectViewModel.inPatientProjectID, projectViewModel.getAdmissionInfoResponseModel.admissionNo, dietType, currentWeek, currentDay, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
if (res["List_MOP_MealsOfScheduleID"] != null && res["List_MOP_MealsOfScheduleID"].length != 0) {
res['List_MOP_MealsOfScheduleID'].forEach((scheduleItem) {
if (res["List_MOP_MealsOfScheduleID_Mobile"] != null && res["List_MOP_MealsOfScheduleID_Mobile"].length != 0) {
res['List_MOP_MealsOfScheduleID_Mobile'].forEach((scheduleItem) {
getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(scheduleItem));
});
getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[0].scheduleID, 1);
@ -187,23 +242,63 @@ class _MealPlanPageState extends State<MealPlanPage> {
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
getMealItemsScheduleResponseModelBreakfast.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
});
sortMealsByCategoryBreakfast();
}
if (mealType == 2) {
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
getMealItemsScheduleResponseModelLunch.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
});
sortMealsByCategoryLunch();
}
if (mealType == 3) {
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
getMealItemsScheduleResponseModelDinner.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
});
sortMealsByCategoryDinner();
}
} else {
AppToast.showErrorToast(message: "No meal items found for admitted patient");
}
setState(() {});
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
void sortMealsByCategoryBreakfast() {
getMealItemsScheduleResponseModelBreakfast.forEach((element) {
List<GetMealItemsScheduleResponseModelList> breakfastMealItems =
_getMealItemsScheduleResponseModelBreakfast.where((elementClinic) => elementClinic.filterName == element.categoryDescription).toList();
if (breakfastMealItems.length != 0) {
_getMealItemsScheduleResponseModelBreakfast[_getMealItemsScheduleResponseModelBreakfast.indexOf(breakfastMealItems[0])].getMealItemsScheduleResponseModelList.add(element);
} else {
_getMealItemsScheduleResponseModelBreakfast.add(GetMealItemsScheduleResponseModelList(filterName: element.categoryDescription, getMealItemsScheduleResponseModel: element));
}
});
}
void sortMealsByCategoryLunch() {
getMealItemsScheduleResponseModelLunch.forEach((element) {
List<GetMealItemsScheduleResponseModelList> breakfastMealItems =
_getMealItemsScheduleResponseModelLunch.where((elementClinic) => elementClinic.filterName == element.categoryDescription).toList();
if (breakfastMealItems.length != 0) {
_getMealItemsScheduleResponseModelLunch[_getMealItemsScheduleResponseModelLunch.indexOf(breakfastMealItems[0])].getMealItemsScheduleResponseModelList.add(element);
} else {
_getMealItemsScheduleResponseModelLunch.add(GetMealItemsScheduleResponseModelList(filterName: element.categoryDescription, getMealItemsScheduleResponseModel: element));
}
});
}
void sortMealsByCategoryDinner() {
getMealItemsScheduleResponseModelDinner.forEach((element) {
List<GetMealItemsScheduleResponseModelList> breakfastMealItems =
_getMealItemsScheduleResponseModelDinner.where((elementClinic) => elementClinic.filterName == element.categoryDescription).toList();
if (breakfastMealItems.length != 0) {
_getMealItemsScheduleResponseModelDinner[_getMealItemsScheduleResponseModelDinner.indexOf(breakfastMealItems[0])].getMealItemsScheduleResponseModelList.add(element);
} else {
_getMealItemsScheduleResponseModelDinner.add(GetMealItemsScheduleResponseModelList(filterName: element.categoryDescription, getMealItemsScheduleResponseModel: element));
}
});
}
}

@ -378,7 +378,9 @@ class _MyAppointmentsState extends State<MyAppointments> with SingleTickerProvid
date: DateUtil.convertStringToDate(_appointmentResult.appointmentDate),
isSortByClinic: _isSortByClinic,
rating: _appointmentResult.actualDoctorRate + 0.0,
appointmentTime: _appointmentResult.isLiveCareAppointment ? DateUtil.convertStringToDate(_appointmentResult.appointmentDate).toString().split(" ")[1].substring(0, 5) : _appointmentResult.startTime.substring(0, 5),
appointmentTime: _appointmentResult.isLiveCareAppointment
? DateUtil.convertStringToDate(_appointmentResult.appointmentDate).toString().split(" ")[1].substring(0, 5)
: _appointmentResult.startTime.substring(0, 5),
// appointmentTime: _appointmentResult.startTime.substring(0, 5),
remainingTimeInMinutes: (_appointmentResult.patientStatusType == AppointmentType.BOOKED || _appointmentResult.patientStatusType == AppointmentType.CONFIRMED)
? _appointmentResult.remaniningHoursTocanPay

@ -279,8 +279,8 @@ class ClinicListService extends BaseService {
Map<String, dynamic> request;
request = {
"ProjectID": projectID,
"PatientID" : 3649746,
"AdmissionNo": 2023000036,
"PatientID" : patientID,
"AdmissionNo": admissionNo,
"BuildingID" : buildingID,
"FloorID" : floorID,
"NursingStationID": nursingStationID

@ -1,4 +1,5 @@
import 'package:device_calendar/device_calendar.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class DateUtil {
@ -90,6 +91,17 @@ class DateUtil {
return start + "$milliseconds" + end;
}
static String convertTime(String timeStr) {
TimeOfDay time = TimeOfDay(hour: num.parse(timeStr.split(":")[0]), minute: num.parse(timeStr.split(":")[1])); // 24-hour format time
int hour = time.hourOfPeriod; // get hour in 12-hour format
String meridiem = time.period == DayPeriod.am ? "AM" : "PM"; // get AM/PM
String convertedTime = '$hour:${time.minute == 0 ? "00" : time.minute} $meridiem'; // create the new time string
return convertedTime;
}
static String formatDateToDate(DateTime date, bool isArabic) {
return DateFormat('dd MMM yyy', isArabic ? "ar_SA" : "en_US").format(date);
}

@ -64,7 +64,6 @@ class LargeAvatar extends StatelessWidget {
onTap: disableProfileView
? null
: isAppointmentAvatar ? onTap : () {
print("ssssss " + url.trim());
showZoomImageDialog(context, url.trim() ?? "");
},
child: Container(

Loading…
Cancel
Save