MealPlan implementation continued

merge-update-with-lab-changes
haroon amjad 2 years ago
parent 77ab9373f8
commit d073eb9d5f

@ -610,6 +610,7 @@ var SAVE_BIRTH_NOTIFICATION = 'Services/INPs.svc/REST/SaveBirthNotification';
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_MEAL_ITEMS_OF_SCHEDULE_ID = 'Services/MOP.svc/REST/GetDefaultItemsOfScheduleID';
class AppGlobal {
static var context;

@ -0,0 +1,60 @@
class GetMealItemsScheduleResponseModel {
int itemID;
String description;
String descriptionN;
dynamic comment;
dynamic commentN;
String imageURL;
bool isDefault;
int categoryID;
String categoryDescription;
String categoryDescriptionN;
int scheduleID;
int cal;
GetMealItemsScheduleResponseModel(
{this.itemID,
this.description,
this.descriptionN,
this.comment,
this.commentN,
this.imageURL,
this.isDefault,
this.categoryID,
this.categoryDescription,
this.categoryDescriptionN,
this.scheduleID,
this.cal});
GetMealItemsScheduleResponseModel.fromJson(Map<String, dynamic> json) {
itemID = json['ItemID'];
description = json['Description'];
descriptionN = json['DescriptionN'];
comment = json['Comment'];
commentN = json['CommentN'];
imageURL = json['ImageURL'];
isDefault = json['IsDefault'];
categoryID = json['CategoryID'];
categoryDescription = json['CategoryDescription'];
categoryDescriptionN = json['CategoryDescriptionN'];
scheduleID = json['ScheduleID'];
cal = json['cal'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ItemID'] = this.itemID;
data['Description'] = this.description;
data['DescriptionN'] = this.descriptionN;
data['Comment'] = this.comment;
data['CommentN'] = this.commentN;
data['ImageURL'] = this.imageURL;
data['IsDefault'] = this.isDefault;
data['CategoryID'] = this.categoryID;
data['CategoryDescription'] = this.categoryDescription;
data['CategoryDescriptionN'] = this.categoryDescriptionN;
data['ScheduleID'] = this.scheduleID;
data['cal'] = this.cal;
return data;
}
}

@ -1,5 +1,6 @@
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';
@ -23,6 +24,10 @@ class _MealPlanPageState extends State<MealPlanPage> {
GetAdmittedPatientsResponseModel getAdmittedPatientsResponseModel;
List<GetMealsScheduleResponseModel> getMealsScheduleResponseModelList = [];
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelBreakfast = [];
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelLunch = [];
List<GetMealItemsScheduleResponseModel> getMealItemsScheduleResponseModelDinner = [];
int currentDay = 0;
int currentWeek = 0;
@ -128,6 +133,8 @@ class _MealPlanPageState extends State<MealPlanPage> {
getCurrentWeekIDAndDay(getAdmittedPatientsResponseModel.dietType);
} else {
AppToast.showErrorToast(message: "No data found for admitted patient");
getCurrentWeekIDAndDay(1);
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
@ -155,10 +162,12 @@ class _MealPlanPageState extends State<MealPlanPage> {
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((cOC) {
getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(res["List_MOP_MealsOfScheduleID"]));
res['List_MOP_MealsOfScheduleID'].forEach((scheduleItem) {
getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(scheduleItem));
});
print(getMealsScheduleResponseModelList.length);
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");
}
@ -167,4 +176,34 @@ class _MealPlanPageState extends State<MealPlanPage> {
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);
});
}
}

@ -298,7 +298,7 @@ class ClinicListService extends BaseService {
Future<Map> getCurrentWeekIDAndDay(BuildContext context) async {
dynamic localRes;
await baseAppClient.get(GET_CURRENT_WEEKID_WEEKDAY, isExternal: true, onSuccess: (response, statusCode) async {
await baseAppClient.get(GET_CURRENT_WEEKID_WEEKDAY, isExternal: false, isRCService: false, onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
@ -329,4 +329,21 @@ class ClinicListService extends BaseService {
return Future.value(localRes);
}
Future<Map> getDefaultItemsOfScheduleID(int projectID, int scheduleID, context) async {
Map<String, dynamic> request;
request = {
"ProjectID": projectID,
"MealScheduleID": scheduleID,
};
dynamic localRes;
await baseAppClient.post(GET_MEAL_ITEMS_OF_SCHEDULE_ID, onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request, isAllowAny: true);
return Future.value(localRes);
}
}

Loading…
Cancel
Save