Meal Plan APIs implementation continued

merge-update-with-lab-changes
haroon amjad 3 years ago
parent 710e6274db
commit 77ab9373f8

@ -608,6 +608,8 @@ 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';
class AppGlobal {
static var context;

@ -0,0 +1,42 @@
class GetMealsScheduleResponseModel {
int scheduleID;
int mealID;
String description;
String descriptionN;
int weekID;
String weekDescription;
String weekDescriptionN;
String tAT;
int dietTypeID;
int dayID;
GetMealsScheduleResponseModel({this.scheduleID, this.mealID, this.description, this.descriptionN, this.weekID, this.weekDescription, this.weekDescriptionN, this.tAT, this.dietTypeID, this.dayID});
GetMealsScheduleResponseModel.fromJson(Map<String, dynamic> json) {
scheduleID = json['ScheduleID'];
mealID = json['MealID'];
description = json['Description'];
descriptionN = json['DescriptionN'];
weekID = json['WeekID'];
weekDescription = json['WeekDescription'];
weekDescriptionN = json['WeekDescriptionN'];
tAT = json['TAT'];
dietTypeID = json['DietTypeID'];
dayID = json['DayID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ScheduleID'] = this.scheduleID;
data['MealID'] = this.mealID;
data['Description'] = this.description;
data['DescriptionN'] = this.descriptionN;
data['WeekID'] = this.weekID;
data['WeekDescription'] = this.weekDescription;
data['WeekDescriptionN'] = this.weekDescriptionN;
data['TAT'] = this.tAT;
data['DietTypeID'] = this.dietTypeID;
data['DayID'] = this.dayID;
return data;
}
}

@ -1,6 +1,8 @@
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_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';
@ -19,6 +21,10 @@ class MealPlanPage extends StatefulWidget {
class _MealPlanPageState extends State<MealPlanPage> {
ProjectViewModel projectViewModel;
GetAdmittedPatientsResponseModel getAdmittedPatientsResponseModel;
List<GetMealsScheduleResponseModel> getMealsScheduleResponseModelList = [];
int currentDay = 0;
int currentWeek = 0;
@override
void initState() {
@ -115,12 +121,49 @@ class _MealPlanPageState extends State<MealPlanPage> {
GifLoaderDialogUtils.showMyDialog(context);
service.getAdmittedPatientDetails(projectViewModel.user.patientID, projectViewModel.inPatientProjectID, projectViewModel.getAdmissionInfoResponseModel.admissionNo, 0, 0, 0, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
print(res["List_MOP_AdmittedPatients"]);
getAdmittedPatientsResponseModel = new GetAdmittedPatientsResponseModel.fromJson(res["List_MOP_AdmittedPatients"][0]);
print(getAdmittedPatientsResponseModel.admissionNo);
// AppToast.showSuccessToast(message: TranslationBase.of(context).processDoneSuccessfully);
// Navigator.of(context).pop();
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");
}
}).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((cOC) {
getMealsScheduleResponseModelList.add(GetMealsScheduleResponseModel.fromJson(res["List_MOP_MealsOfScheduleID"]));
});
print(getMealsScheduleResponseModelList.length);
} else {
AppToast.showErrorToast(message: "No meal schedule found for admitted patient");
}
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}

@ -279,8 +279,8 @@ class ClinicListService extends BaseService {
Map<String, dynamic> request;
request = {
"ProjectID": projectID,
"PatientID" : 3649733,
"AdmissionNo": 2023000035,
"PatientID" : 3649746,
"AdmissionNo": 2023000036,
"BuildingID" : buildingID,
"FloorID" : floorID,
"NursingStationID": nursingStationID
@ -296,4 +296,37 @@ class ClinicListService extends BaseService {
return Future.value(localRes);
}
Future<Map> getCurrentWeekIDAndDay(BuildContext context) async {
dynamic localRes;
await baseAppClient.get(GET_CURRENT_WEEKID_WEEKDAY, isExternal: true, onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
});
return localRes;
}
Future<Map> getMealsOfScheduleID(int projectID, int admissionNo, int dietType, int weekID, int weekDay, context) async {
Map<String, dynamic> request;
request = {
"ProjectID": projectID,
"AdmissionNo": admissionNo,
"BuildingID" : 0,
"FloorID" : 0,
"NursingStationID": 0,
"DietType": dietType,
"WeekID": weekID,
"WeekDay": weekDay,
};
dynamic localRes;
await baseAppClient.post(GET_MEALS_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