You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
210 lines
8.2 KiB
Dart
210 lines
8.2 KiB
Dart
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:diplomaticquarterapp/models/InPatientServices/get_admitted_patient_response_model.dart';
|
|
import 'package:diplomaticquarterapp/models/InPatientServices/get_meal_items_schedule_response_model.dart';
|
|
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/gif_loader_dialog_utils.dart';
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
|
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class MealPlanPage extends StatefulWidget {
|
|
const MealPlanPage({Key key}) : super(key: key);
|
|
|
|
@override
|
|
State<MealPlanPage> createState() => _MealPlanPageState();
|
|
}
|
|
|
|
class _MealPlanPageState extends State<MealPlanPage> {
|
|
ProjectViewModel projectViewModel;
|
|
GetAdmittedPatientsResponseModel getAdmittedPatientsResponseModel;
|
|
List<GetMealsScheduleResponseModel> getMealsScheduleResponseModelList = [];
|
|
|
|
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelBreakfast = [];
|
|
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelLunch = [];
|
|
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelDinner = [];
|
|
|
|
int currentDay = 0;
|
|
int currentWeek = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
getAdmittedPatientDetails();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectViewModel = Provider.of(context);
|
|
return AppScaffold(
|
|
isShowAppBar: true,
|
|
isShowDecPage: false,
|
|
showNewAppBarTitle: true,
|
|
showNewAppBar: true,
|
|
appBarTitle: TranslationBase.of(context).mealPlanTitle,
|
|
body: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(21.0),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
decoration: containerRadius(Colors.white, 12),
|
|
child: AppExpandableNotifier(
|
|
title: "Breakfast TAT: 10:00 AM",
|
|
isTitleSingleLine: false,
|
|
widgetColor: Colors.transparent,
|
|
bodyWidget: Column(
|
|
children: [
|
|
getDivider(),
|
|
Container(
|
|
height: 200.0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
mHeight(21),
|
|
Container(
|
|
decoration: containerRadius(Colors.white, 12),
|
|
child: AppExpandableNotifier(
|
|
title: "Lunch TAT: 04:00 PM",
|
|
isTitleSingleLine: false,
|
|
widgetColor: Colors.transparent,
|
|
bodyWidget: Column(
|
|
children: [
|
|
getDivider(),
|
|
Container(
|
|
height: 200.0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
mHeight(21),
|
|
Container(
|
|
decoration: containerRadius(Colors.white, 12),
|
|
child: AppExpandableNotifier(
|
|
title: "Dinner TAT: 12:00 AM",
|
|
isTitleSingleLine: false,
|
|
widgetColor: Colors.transparent,
|
|
bodyWidget: Column(
|
|
children: [
|
|
getDivider(),
|
|
Container(
|
|
height: 200.0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget getDivider() {
|
|
return Padding(
|
|
padding: EdgeInsets.only(left: 15, right: 15),
|
|
child: Divider(
|
|
height: 1.5,
|
|
thickness: 2.0,
|
|
color: Colors.black,
|
|
),
|
|
);
|
|
}
|
|
|
|
void getAdmittedPatientDetails() {
|
|
ClinicListService service = new ClinicListService();
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
service.getAdmittedPatientDetails(projectViewModel.user.patientID, projectViewModel.inPatientProjectID, projectViewModel.getAdmissionInfoResponseModel.admissionNo, 0, 0, 0, context).then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
if (res["List_MOP_AdmittedPatients"] != null && res["List_MOP_AdmittedPatients"].length != 0) {
|
|
print(res["List_MOP_AdmittedPatients"]);
|
|
getAdmittedPatientsResponseModel = new GetAdmittedPatientsResponseModel.fromJson(res["List_MOP_AdmittedPatients"][0]);
|
|
print(getAdmittedPatientsResponseModel.dietType);
|
|
getCurrentWeekIDAndDay(getAdmittedPatientsResponseModel.dietType);
|
|
} else {
|
|
AppToast.showErrorToast(message: "No data found for admitted patient");
|
|
|
|
getCurrentWeekIDAndDay(1);
|
|
}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
|
|
void getCurrentWeekIDAndDay(int dietType) {
|
|
ClinicListService service = new ClinicListService();
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
service.getCurrentWeekIDAndDay(context).then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
currentDay = res["CurrentDay"];
|
|
currentWeek = res["CurrentWeek"];
|
|
getMealsOfScheduleID(dietType);
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
|
|
void getMealsOfScheduleID(int dietType) {
|
|
ClinicListService service = new ClinicListService();
|
|
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) {
|
|
getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(scheduleItem));
|
|
});
|
|
getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[0].scheduleID, 1);
|
|
getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[1].scheduleID, 2);
|
|
getDefaultItemsOfScheduleID(getMealsScheduleResponseModelList[2].scheduleID, 3);
|
|
} else {
|
|
AppToast.showErrorToast(message: "No meal schedule found for admitted patient");
|
|
}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
|
|
void getDefaultItemsOfScheduleID(int scheduleID, int mealType) {
|
|
ClinicListService service = new ClinicListService();
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
service.getDefaultItemsOfScheduleID(projectViewModel.inPatientProjectID, scheduleID, context).then((res) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
if (res["List_MOP_DefaultItemsOfMealModel"] != null && res["List_MOP_DefaultItemsOfMealModel"].length != 0) {
|
|
if (mealType == 1) {
|
|
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
|
|
getMealItemsScheduleResponseModelBreakfast.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
|
|
});
|
|
}
|
|
if (mealType == 2) {
|
|
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
|
|
getMealItemsScheduleResponseModelLunch.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
|
|
});
|
|
}
|
|
if (mealType == 3) {
|
|
res['List_MOP_DefaultItemsOfMealModel'].forEach((scheduleItem) {
|
|
getMealItemsScheduleResponseModelDinner.add(GetMealItemsScheduleResponseModel.fromJson(scheduleItem));
|
|
});
|
|
}
|
|
} else {
|
|
AppToast.showErrorToast(message: "No meal items found for admitted patient");
|
|
}
|
|
}).catchError((err) {
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
print(err);
|
|
});
|
|
}
|
|
}
|