diff --git a/lib/config/config.dart b/lib/config/config.dart index 85e57b6c..5c02d229 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -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 { diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 3151bb41..69a55ddf 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -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 diff --git a/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart b/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart index 3d8cfc30..57ba4cb8 100644 --- a/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart +++ b/lib/models/InPatientServices/get_meal_items_schedule_response_model.dart @@ -58,3 +58,12 @@ class GetMealItemsScheduleResponseModel { return data; } } + +class GetMealItemsScheduleResponseModelList { + String filterName = ""; + List getMealItemsScheduleResponseModelList = []; + + GetMealItemsScheduleResponseModelList({this.filterName, GetMealItemsScheduleResponseModel getMealItemsScheduleResponseModel}) { + getMealItemsScheduleResponseModelList.add(getMealItemsScheduleResponseModel); + } +} diff --git a/lib/models/InPatientServices/get_meals_schedule_response_model.dart b/lib/models/InPatientServices/get_meals_schedule_response_model.dart index 599534a4..178ba426 100644 --- a/lib/models/InPatientServices/get_meals_schedule_response_model.dart +++ b/lib/models/InPatientServices/get_meals_schedule_response_model.dart @@ -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 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 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; } } diff --git a/lib/pages/InPatientServices/meal_plan.dart b/lib/pages/InPatientServices/meal_plan.dart index 0c16ad88..0f9e5b90 100644 --- a/lib/pages/InPatientServices/meal_plan.dart +++ b/lib/pages/InPatientServices/meal_plan.dart @@ -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 { List getMealItemsScheduleResponseModelLunch = []; List getMealItemsScheduleResponseModelDinner = []; + List _getMealItemsScheduleResponseModelBreakfast = []; + List _getMealItemsScheduleResponseModelLunch = []; + List _getMealItemsScheduleResponseModelDinner = []; + int currentDay = 0; int currentWeek = 0; @@ -56,15 +63,64 @@ class _MealPlanPageState extends State { 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: [ + 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: [ + 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 { 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 { 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 { 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 { 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 { 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 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 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 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)); + } + }); + } } diff --git a/lib/pages/MyAppointments/MyAppointments.dart b/lib/pages/MyAppointments/MyAppointments.dart index cccff881..61bb1f56 100644 --- a/lib/pages/MyAppointments/MyAppointments.dart +++ b/lib/pages/MyAppointments/MyAppointments.dart @@ -378,7 +378,9 @@ class _MyAppointmentsState extends State 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 diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index be556ea2..5339662a 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -279,8 +279,8 @@ class ClinicListService extends BaseService { Map request; request = { "ProjectID": projectID, - "PatientID" : 3649746, - "AdmissionNo": 2023000036, + "PatientID" : patientID, + "AdmissionNo": admissionNo, "BuildingID" : buildingID, "FloorID" : floorID, "NursingStationID": nursingStationID diff --git a/lib/uitl/date_uitl.dart b/lib/uitl/date_uitl.dart index cac6a07d..064ad274 100644 --- a/lib/uitl/date_uitl.dart +++ b/lib/uitl/date_uitl.dart @@ -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); } diff --git a/lib/widgets/avatar/large_avatar.dart b/lib/widgets/avatar/large_avatar.dart index 131a2820..39a341bf 100644 --- a/lib/widgets/avatar/large_avatar.dart +++ b/lib/widgets/avatar/large_avatar.dart @@ -64,7 +64,6 @@ class LargeAvatar extends StatelessWidget { onTap: disableProfileView ? null : isAppointmentAvatar ? onTap : () { - print("ssssss " + url.trim()); showZoomImageDialog(context, url.trim() ?? ""); }, child: Container(