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.
HMG_Patient_App/lib/pages/InPatientServices/inpatient_home.dart

261 lines
8.8 KiB
Dart

import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/InPatientServices/get_general_instructions_response_model.dart';
import 'package:diplomaticquarterapp/pages/InPatientServices/birth_notification.dart';
import 'package:diplomaticquarterapp/pages/InPatientServices/general_instructions.dart';
import 'package:diplomaticquarterapp/pages/InPatientServices/help_PRO.dart';
import 'package:diplomaticquarterapp/pages/InPatientServices/inpatient_advance_payment.dart';
import 'package:diplomaticquarterapp/pages/InPatientServices/meal_plan.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart';
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class InPatientServicesHome extends StatelessWidget {
ProjectViewModel projectViewModel;
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
List<Widget> inPatientServiceList = getInPatientServicesList(context);
return AppScaffold(
isShowAppBar: true,
isShowDecPage: false,
showNewAppBarTitle: true,
showNewAppBar: true,
appBarTitle: TranslationBase.of(context).InPatientServicesHeader,
body: Container(
margin: EdgeInsets.all(20.0),
child: Column(
children: [
Padding(
padding: EdgeInsets.only(left: 12, right: 12),
child: GridView.builder(
shrinkWrap: true,
primary: false,
physics: NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3, childAspectRatio: 2 / 2, crossAxisSpacing: 12, mainAxisSpacing: 12),
padding: EdgeInsets.zero,
itemCount: inPatientServiceList.length,
itemBuilder: (BuildContext context, int index) {
return inPatientServiceList[index];
},
),
),
],
),
),
);
}
List<Widget> getInPatientServicesList(BuildContext context) {
List<Widget> serviceList = List();
// serviceList.add(
// InkWell(
// onTap: () {
// // Navigator.push(context, FadePage(page: AdvancePaymentPage()));
// },
// child: MedicalProfileItem(
// title: TranslationBase.of(context).admissionGeneral,
// imagePath: 'admission.svg',
// subTitle: TranslationBase.of(context).consent,
// width: 50.0,
// height: 40.0,
// isInPatient: true,
// ),
// ),
// );
serviceList.add(
InkWell(
onTap: () {
openGeneralInstructions(context);
},
child: MedicalProfileItem(
title: TranslationBase.of(context).generalInstructionsTitle,
imagePath: 'general_instructions.svg',
subTitle: TranslationBase.of(context).generalInstructionsSubTitle,
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).medicalInstructionsTitle,
imagePath: 'medical_instructions.svg',
subTitle: TranslationBase.of(context).medicalInstructionsSubTitle,
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
serviceList.add(
InkWell(
onTap: () {
Navigator.push(context, FadePage(page: MealPlanPage()));
},
child: MedicalProfileItem(
title: TranslationBase.of(context).mealPlanTitle,
imagePath: 'meal_plan.svg',
subTitle: TranslationBase.of(context).mealPlanSubTitle,
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
serviceList.add(
InkWell(
onTap: () {
openBirthNotificationsPage(context);
},
child: MedicalProfileItem(
title: TranslationBase.of(context).birthNotificationTitle,
imagePath: 'birth_notification.svg',
subTitle: TranslationBase.of(context).birthNotificationSubTitle,
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
// serviceList.add(
// InkWell(
// onTap: () {
// // Navigator.push(context, FadePage(page: AdvancePaymentPage()));
// },
// child: MedicalProfileItem(
// title: TranslationBase.of(context).admissionNoticeTitle,
// imagePath: 'admission_notice.svg',
// subTitle: TranslationBase.of(context).admissionNoticeSubTitle,
// width: 50.0,
// height: 40.0,
// isInPatient: true,
// ),
// ),
// );
serviceList.add(
InkWell(
onTap: () {
Navigator.push(context, FadePage(page: InPatientAdvancePayment()));
},
child: MedicalProfileItem(
title: "Advance",
imagePath: 'advance_payment.svg',
subTitle: TranslationBase.of(context).payment,
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
serviceList.add(
InkWell(
onTap: () {
// Navigator.push(context, FadePage(page: AdvancePaymentPage()));
receivePrescriptionAPI(context);
},
child: MedicalProfileItem(
title: "Receive",
imagePath: 'receive_prescription.svg',
subTitle: TranslationBase.of(context).prescriptions,
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
serviceList.add(
InkWell(
onTap: () {
Navigator.push(context, FadePage(page: HelpPRO()));
},
child: MedicalProfileItem(
title: "Help",
imagePath: 'help_pro.svg',
subTitle: "PRO",
width: 50.0,
height: 40.0,
isInPatient: true,
),
),
);
return serviceList;
}
void receivePrescriptionAPI(BuildContext context) {
ConfirmDialog dialog = new ConfirmDialog(
context: context,
confirmMessage: TranslationBase.of(context).successSendReport,
okText: TranslationBase.of(context).ok,
cancelText: TranslationBase.of(context).cancel_nocaps,
okFunction: () {
Navigator.of(context).pop();
},
cancelFunction: () => {});
dialog.showAlertDialog(context);
}
void callReceivePrescriptionAPI(BuildContext context) {
ClinicListService service = new ClinicListService();
GifLoaderDialogUtils.showMyDialog(context);
service
.insertInPatientOrder(projectViewModel.getAdmissionInfoResponseModel, 2, (projectViewModel.user.firstName + " " + projectViewModel.user.lastName),
(projectViewModel.user.firstNameN + " " + projectViewModel.user.lastNameN), projectViewModel.user.mobileNumber, "I need my medicines", context)
.then((res) {
GifLoaderDialogUtils.hideDialog(context);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
});
}
void openBirthNotificationsPage(BuildContext context) {
ClinicListService service = new ClinicListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getBirthNotification(projectViewModel.user.patientID, context).then((res) {
GifLoaderDialogUtils.hideDialog(context);
print(res['birthNotification']);
Navigator.push(context, FadePage(page: BirthNotification()));
}).catchError((err) {
print(err);
});
}
void openGeneralInstructions(BuildContext context) {
ClinicListService service = new ClinicListService();
GifLoaderDialogUtils.showMyDialog(context);
service.getGeneralInstructions(projectViewModel.inPatientProjectID, context).then((res) {
List<GetGeneralInstructions> getGeneralInstructionsList = [];
res['generalInstructions'].forEach((v) {
getGeneralInstructionsList.add(new GetGeneralInstructions.fromJson(v));
});
GifLoaderDialogUtils.hideDialog(context);
print(res['generalInstructions']);
Navigator.push(context, FadePage(page: GeneralInstructions(getGeneralInstructionsList: getGeneralInstructionsList)));
}).catchError((err) {
print(err);
});
}
}