diff --git a/lib/config/config.dart b/lib/config/config.dart index 63ff8954..47bb9809 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -186,6 +186,13 @@ const GET_PAtIENTS_INSURANCE_APPROVALS = "Services/Patients.svc/REST/GetApprovalStatus"; const SEARCH_BOT = 'HabibiChatBotApi/BotInterface/GetVoiceCommandResponse'; +const GET_VACCINATIONS_ITEMS = "/Services/ERP.svc/REST/GET_VACCINATIONS_ITEMS"; +const GET_VACCINATION_ONHAND = "/Services/ERP.svc/REST/GET_VACCINATION_ONHAND"; + +const GET_PATIENT_SICK_LEAVE = 'Services/Patients.svc/REST/GetPatientSickLeave'; + +const SendSickLeaveEmail = 'Services/Notifications.svc/REST/SendSickLeaveEmail'; + class AppGlobal { static var context; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 196ce6cd..9e399464 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -227,6 +227,10 @@ const Map> localizedValues = { 'ar': 'مسح فوق رمز الاستجابة السريعة للتحقق في الجهاز في المستشفى' }, "sendEmail": {"en": "Send Email", "ar": "ارسال نسخة"}, + "EmailSentSuccessfully": { + "en": "Email Sent Successfully", + "ar": "تم إرسال البريد الإلكتروني بنجاح" + }, "close": {"en": "Close", "ar": "مغلق"}, "booked": {"en": "Booked", "ar": "محجوز"}, "confirmed": {"en": "Confirmed", "ar": "مؤكد"}, @@ -491,4 +495,12 @@ const Map> localizedValues = { "Save": {"en": "Save", "ar": "حفظ "}, "UserAgreement": {"en": "User Agreement", "ar": "اتفاقية الخصوصية "}, "UpdateSuccessfully": {"en": "Update Successfully", "ar": "تم التحديث بنجاح"}, + "CHECK_VACCINE_AVAILABILITY": { + "en": "CHECK VACCINE AVAILABILITY", + "ar": "تحقق من توافر اللقاح" + }, + "MyVaccinesAvailability": { + "en": "MyVaccinesAvailability", + "ar": "توفر لقاحي" + }, }; diff --git a/lib/core/model/sick_leave/sick_leave.dart b/lib/core/model/sick_leave/sick_leave.dart new file mode 100644 index 00000000..d5e6e76c --- /dev/null +++ b/lib/core/model/sick_leave/sick_leave.dart @@ -0,0 +1,138 @@ +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; + +class SickLeave { + String setupID; + int projectID; + int patientID; + int patientType; + int clinicID; + int doctorID; + int requestNo; + DateTime requestDate; + int sickLeaveDays; + int appointmentNo; + int admissionNo; + int actualDoctorRate; + String appointmentDate; + String clinicName; + String doctorImageURL; + String doctorName; + int doctorRate; + String doctorTitle; + int gender; + String genderDescription; + bool isActiveDoctorProfile; + bool isDoctorAllowVedioCall; + bool isExecludeDoctor; + bool isInOutPatient; + String isInOutPatientDescription; + String isInOutPatientDescriptionN; + int noOfPatientsRate; + Null patientName; + String projectName; + String qR; + List speciality; + + SickLeave( + {this.setupID, + this.projectID, + this.patientID, + this.patientType, + this.clinicID, + this.doctorID, + this.requestNo, + this.requestDate, + this.sickLeaveDays, + this.appointmentNo, + this.admissionNo, + this.actualDoctorRate, + this.appointmentDate, + this.clinicName, + this.doctorImageURL, + this.doctorName, + this.doctorRate, + this.doctorTitle, + this.gender, + this.genderDescription, + this.isActiveDoctorProfile, + this.isDoctorAllowVedioCall, + this.isExecludeDoctor, + this.isInOutPatient, + this.isInOutPatientDescription, + this.isInOutPatientDescriptionN, + this.noOfPatientsRate, + this.patientName, + this.projectName, + this.qR, + this.speciality}); + + SickLeave.fromJson(Map json) { + setupID = json['SetupID']; + projectID = json['ProjectID']; + patientID = json['PatientID']; + patientType = json['PatientType']; + clinicID = json['ClinicID']; + doctorID = json['DoctorID']; + requestNo = json['RequestNo']; + requestDate = DateUtil.convertStringToDate(json['RequestDate']); + sickLeaveDays = json['SickLeaveDays']; + appointmentNo = json['AppointmentNo']; + admissionNo = json['AdmissionNo']; + actualDoctorRate = json['ActualDoctorRate']; + appointmentDate = json['AppointmentDate']; + clinicName = json['ClinicName']; + doctorImageURL = json['DoctorImageURL']; + doctorName = json['DoctorName']; + doctorRate = json['DoctorRate']; + doctorTitle = json['DoctorTitle']; + gender = json['Gender']; + genderDescription = json['GenderDescription']; + isActiveDoctorProfile = json['IsActiveDoctorProfile']; + isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall']; + isExecludeDoctor = json['IsExecludeDoctor']; + isInOutPatient = json['IsInOutPatient']; + isInOutPatientDescription = json['IsInOutPatientDescription']; + isInOutPatientDescriptionN = json['IsInOutPatientDescriptionN']; + noOfPatientsRate = json['NoOfPatientsRate']; + patientName = json['PatientName']; + projectName = json['ProjectName']; + qR = json['QR']; + speciality = json['Speciality'].cast(); + } + + Map toJson() { + final Map data = new Map(); + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['PatientID'] = this.patientID; + data['PatientType'] = this.patientType; + data['ClinicID'] = this.clinicID; + data['DoctorID'] = this.doctorID; + data['RequestNo'] = this.requestNo; + data['RequestDate'] = DateUtil.convertDateToString(requestDate); + data['SickLeaveDays'] = this.sickLeaveDays; + data['AppointmentNo'] = this.appointmentNo; + data['AdmissionNo'] = this.admissionNo; + data['ActualDoctorRate'] = this.actualDoctorRate; + data['AppointmentDate'] = this.appointmentDate; + data['ClinicName'] = this.clinicName; + data['DoctorImageURL'] = this.doctorImageURL; + data['DoctorName'] = this.doctorName; + data['DoctorRate'] = this.doctorRate; + data['DoctorTitle'] = this.doctorTitle; + data['Gender'] = this.gender; + data['GenderDescription'] = this.genderDescription; + data['IsActiveDoctorProfile'] = this.isActiveDoctorProfile; + data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall; + data['IsExecludeDoctor'] = this.isExecludeDoctor; + data['IsInOutPatient'] = this.isInOutPatient; + data['IsInOutPatientDescription'] = this.isInOutPatientDescription; + data['IsInOutPatientDescriptionN'] = this.isInOutPatientDescriptionN; + data['NoOfPatientsRate'] = this.noOfPatientsRate; + data['PatientName'] = this.patientName; + data['ProjectName'] = this.projectName; + data['QR'] = this.qR; + data['Speciality'] = this.speciality; + return data; + } +} diff --git a/lib/core/model/vaccine/vaccination_item.dart b/lib/core/model/vaccine/vaccination_item.dart new file mode 100644 index 00000000..0009ea7d --- /dev/null +++ b/lib/core/model/vaccine/vaccination_item.dart @@ -0,0 +1,18 @@ +class VaccinationItem { + String dESCRIPTION; + String iTEMCODE; + + VaccinationItem({this.dESCRIPTION, this.iTEMCODE}); + + VaccinationItem.fromJson(Map json) { + dESCRIPTION = json['DESCRIPTION']; + iTEMCODE = json['ITEM_CODE']; + } + + Map toJson() { + final Map data = new Map(); + data['DESCRIPTION'] = this.dESCRIPTION; + data['ITEM_CODE'] = this.iTEMCODE; + return data; + } +} diff --git a/lib/core/model/vaccine/vaccination_on_hand.dart b/lib/core/model/vaccine/vaccination_on_hand.dart new file mode 100644 index 00000000..daf3e886 --- /dev/null +++ b/lib/core/model/vaccine/vaccination_on_hand.dart @@ -0,0 +1,44 @@ +class VaccinationOnHand { + int distanceInKilometers; + int iTEMONHAND; + bool isThereItems; + String oRGANIZATIONCODE; + String oRGANIZATIONNAME; + String projectAlias; + int projectID; + String projectName; + + VaccinationOnHand( + {this.distanceInKilometers, + this.iTEMONHAND, + this.isThereItems, + this.oRGANIZATIONCODE, + this.oRGANIZATIONNAME, + this.projectAlias, + this.projectID, + this.projectName}); + + VaccinationOnHand.fromJson(Map json) { + distanceInKilometers = json['DistanceInKilometers']; + iTEMONHAND = json['ITEM_ONHAND']; + isThereItems = json['IsThereItems']; + oRGANIZATIONCODE = json['ORGANIZATION_CODE']; + oRGANIZATIONNAME = json['ORGANIZATION_NAME']; + projectAlias = json['ProjectAlias']; + projectID = json['ProjectID']; + projectName = json['ProjectName']; + } + + Map toJson() { + final Map data = new Map(); + data['DistanceInKilometers'] = this.distanceInKilometers; + data['ITEM_ONHAND'] = this.iTEMONHAND; + data['IsThereItems'] = this.isThereItems; + data['ORGANIZATION_CODE'] = this.oRGANIZATIONCODE; + data['ORGANIZATION_NAME'] = this.oRGANIZATIONNAME; + data['ProjectAlias'] = this.projectAlias; + data['ProjectID'] = this.projectID; + data['ProjectName'] = this.projectName; + return data; + } +} diff --git a/lib/core/service/medical/PatientSickLeaveService.dart b/lib/core/service/medical/PatientSickLeaveService.dart new file mode 100644 index 00000000..b2bb16ef --- /dev/null +++ b/lib/core/service/medical/PatientSickLeaveService.dart @@ -0,0 +1,45 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/sick_leave/sick_leave.dart'; +import 'package:diplomaticquarterapp/core/service/base_service.dart'; + +class PatientSickLeaveService extends BaseService { + List sickLeaveList = List(); + + getSickLeave() async { + hasError = false; + super.error = ""; + await baseAppClient.post(GET_PATIENT_SICK_LEAVE, + onSuccess: (response, statusCode) async { + sickLeaveList.clear(); + response['List_SickLeave'].forEach((sickLeave) { + sickLeaveList.add(SickLeave.fromJson(sickLeave)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: Map()); + } + + sendSickLeaveEmail( + {int requestNo, String projectName, String doctorName, int projectID,String setupID}) async { + hasError = false; + super.error = ""; + Map body = Map(); + body['RequestNo'] = requestNo; + body['To'] = user.emailAddress; + body['DateofBirth'] = user.dateofBirth; + body['PatientIditificationNum'] = user.patientIdentificationNo; + body['PatientMobileNumber'] = user.mobileNumber; + body['PatientName'] = user.firstName + " " + user.firstName; + body['ProjectName'] = projectName; + body['DoctorName'] = doctorName; + body['ProjectID'] = 12; + body['SetupID'] = 12; + await baseAppClient + .post(SendSickLeaveEmail, onSuccess: (response, statusCode) async {}, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } +} diff --git a/lib/core/service/vaccine_service.dart b/lib/core/service/vaccine_service.dart index 9904b838..297909a4 100644 --- a/lib/core/service/vaccine_service.dart +++ b/lib/core/service/vaccine_service.dart @@ -1,9 +1,13 @@ import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_item.dart'; +import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_on_hand.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/model/vaccine/my_vaccine.dart'; class VaccineService extends BaseService { List _vaccineList = List(); + List vaccinationItemList = List(); + List vaccinationOnHandList = List(); List get vaccineList => _vaccineList; @@ -25,24 +29,47 @@ class VaccineService extends BaseService { } Future sendEmail() async { - Map body = Map(); body['ListVaccines'] = vaccineList.map((v) => v.toJson()).toList(); - body['ListVaccines'] = user.emailAddress; + body['To'] = user.emailAddress; body['DateofBirth'] = user.dateofBirth; body['PatientIditificationNum'] = user.patientIdentificationNo; body['PatientMobileNumber'] = user.mobileNumber; - body['PatientName'] = user.firstName + " "+ user.lastName; + body['PatientName'] = user.firstName + " " + user.lastName; hasError = false; - await baseAppClient.post(GET_VACCINES, - onSuccess: (dynamic response, int statusCode) { + await baseAppClient.post(GET_VACCINES_EMAIL, + onSuccess: (dynamic response, int statusCode) {}, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: body); + Future getMyVaccinationItem() async { + await baseAppClient.post(GET_VACCINATIONS_ITEMS, + onSuccess: (dynamic response, int statusCode) { + response['GetVaccinationsList'].forEach((item) { + vaccinationItemList.add(VaccinationItem.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: Map()); + } + Future getMyVaccinationOnHand({String pItemCode}) async { + Map body = Map(); + body['P_ITEM_CODE'] = pItemCode; + await baseAppClient.post(GET_VACCINATION_ONHAND, + onSuccess: (dynamic response, int statusCode) { + response['GetVaccinationOnHandList'].forEach((item) { + vaccinationOnHandList.add(VaccinationOnHand.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); } } diff --git a/lib/core/viewModels/medical/patient_sick_leave_view_model.dart b/lib/core/viewModels/medical/patient_sick_leave_view_model.dart new file mode 100644 index 00000000..6addf833 --- /dev/null +++ b/lib/core/viewModels/medical/patient_sick_leave_view_model.dart @@ -0,0 +1,42 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/sick_leave/sick_leave.dart'; +import 'package:diplomaticquarterapp/core/service/medical/PatientSickLeaveService.dart'; +import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; + +class PatientSickLeaveViewMode extends BaseViewModel { + PatientSickLeaveService _patientSickLeaveService = + locator(); + + List get sickLeaveList => _patientSickLeaveService.sickLeaveList; + + getSickLeave() async { + setState(ViewState.Busy); + await _patientSickLeaveService.getSickLeave(); + if (_patientSickLeaveService.hasError) { + error = _patientSickLeaveService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + Future sendSickLeaveEmail( + {String message, + int requestNo, + String projectName, + String doctorName,int projectID,String setupID}) async { + setState(ViewState.Busy); + await _patientSickLeaveService.sendSickLeaveEmail( + requestNo: requestNo, projectName: projectName, doctorName: doctorName,projectID: projectID,setupID: setupID); + if (_patientSickLeaveService.hasError) { + error = _patientSickLeaveService.error; + setState(ViewState.ErrorLocal); + AppToast.showErrorToast(message: error); + } else { + AppToast.showSuccessToast(message: message); + setState(ViewState.Idle); + } + } +} diff --git a/lib/core/viewModels/vaccine_view_model.dart b/lib/core/viewModels/vaccine_view_model.dart index 233a945f..9f8dfecf 100644 --- a/lib/core/viewModels/vaccine_view_model.dart +++ b/lib/core/viewModels/vaccine_view_model.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_item.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'base_view_model.dart'; @@ -12,10 +13,11 @@ class VaccineViewModel extends BaseViewModel { VaccineService _vaccineService = locator(); List get vaccineList => _vaccineService.vaccineList; + List get vaccinationItemList => _vaccineService.vaccinationItemList; + Future getVaccine() async { hasError = false; - //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); await _vaccineService.getMyVaccine(); if (_vaccineService.hasError) { @@ -25,6 +27,28 @@ class VaccineViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future getMyVaccinationItem() async { + hasError = false; + setState(ViewState.Busy); + await _vaccineService.getMyVaccinationItem(); + if (_vaccineService.hasError) { + error = _vaccineService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMyVaccinationOnHand({String pItemCode}) async { + hasError = false; + setState(ViewState.Busy); + await _vaccineService.getMyVaccinationOnHand(pItemCode: pItemCode); + if (_vaccineService.hasError) { + error = _vaccineService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + Future sendEmail({String message}) async { hasError = false; setState(ViewState.BusyLocal); diff --git a/lib/locator.dart b/lib/locator.dart index f676717d..8f347f42 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -8,6 +8,7 @@ import 'core/service/dashboard_service.dart'; import 'core/service/er/er_service.dart'; import 'core/service/feedback/feedback_service.dart'; import 'core/service/hospital_service.dart'; +import 'core/service/medical/PatientSickLeaveService.dart'; import 'core/service/medical/labs_service.dart'; import 'core/service/medical/medical_service.dart'; import 'core/service/medical/my_doctor_service.dart'; @@ -23,6 +24,7 @@ import 'core/viewModels/hospital_view_model.dart'; import 'core/viewModels/medical/labs_view_model.dart'; import 'core/viewModels/medical/medical_view_model.dart'; import 'core/viewModels/medical/my_doctor_view_model.dart'; +import 'core/viewModels/medical/patient_sick_leave_view_model.dart'; import 'core/viewModels/medical/prescriptions_view_model.dart'; import 'core/viewModels/medical/radiology_view_model.dart'; import 'core/viewModels/medical/reports_monthly_view_model.dart'; @@ -59,6 +61,7 @@ void setupLocator() { locator.registerFactory(() => VaccineService()); locator.registerLazySingleton(() => ReportsMonthlyService()); locator.registerLazySingleton(() => ErService()); + locator.registerLazySingleton(() => PatientSickLeaveService()); /// View Model locator.registerFactory(() => HospitalViewModel()); @@ -78,5 +81,6 @@ void setupLocator() { locator.registerFactory(() => QrViewModel()); locator.registerFactory(() => ReportsMonthlyViewModel()); locator.registerFactory(() => NearHospitalViewModel()); + locator.registerFactory(() => PatientSickLeaveViewMode()); } diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index e78e18a9..7abd724d 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model. import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/patient_sick_leave_page.dart'; import 'package:diplomaticquarterapp/pages/medical/reports/monthly_reports.dart'; import 'package:diplomaticquarterapp/pages/vaccine/my_vaccines_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; @@ -331,12 +332,13 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap: (){ + onTap: () { Navigator.push(context, FadePage(page: MonthlyReportsPage())); }, child: MedicalProfileItem( - title: TranslationBase.of(context).monthly, + title: + TranslationBase.of(context).monthly, imagePath: 'medical_history_icon.png', subTitle: TranslationBase.of(context) .monthlySubtitle, @@ -349,10 +351,12 @@ class _MedicalProfilePageState extends State { flex: 1, child: InkWell( //TODO -// onTap: () { -// Navigator.push( -// context, FadePage(page: DoctorHomePage())); -// }, + onTap: () { + Navigator.push( + context, + FadePage( + page: PatientSickLeavePage())); + }, child: MedicalProfileItem( title: TranslationBase.of(context).sick, imagePath: 'insurance_card_icon.png', diff --git a/lib/pages/medical/patient_sick_leave_page.dart b/lib/pages/medical/patient_sick_leave_page.dart new file mode 100644 index 00000000..dab3d6cf --- /dev/null +++ b/lib/pages/medical/patient_sick_leave_page.dart @@ -0,0 +1,51 @@ +import 'package:diplomaticquarterapp/core/viewModels/medical/patient_sick_leave_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; + +class PatientSickLeavePage extends StatefulWidget { + @override + _PatientSickLeavePageState createState() => _PatientSickLeavePageState(); +} + +class _PatientSickLeavePageState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getSickLeave(), + builder: (_, model, w) => AppScaffold( + isShowAppBar: true, + appBarTitle: 'Sick Leave', + baseViewModel: model, + body: Container( + margin: EdgeInsets.all(12), + child: ListView.builder( + itemCount: model.sickLeaveList.length, + itemBuilder: (context, index) => DoctorCard( + name: model.sickLeaveList[index].doctorName, + date: DateUtil.getMonthDayYearDateFormatted( + model.sickLeaveList[index].requestDate), + profileUrl: model.sickLeaveList[index].doctorImageURL, + rat: model.sickLeaveList[index].actualDoctorRate.toDouble(), + subName: model.sickLeaveList[index].projectName, + isInOutPatientDescription: + model.sickLeaveList[index].isInOutPatientDescription, + onEmailTap: () { + model.sendSickLeaveEmail( + message: TranslationBase.of(context).emailSentSuccessfully, + requestNo: model.sickLeaveList[index].requestNo, + doctorName: model.sickLeaveList[index].doctorName, + projectName: model.sickLeaveList[index].projectName, + setupID: model.sickLeaveList[index].setupID, + projectID: model.sickLeaveList[index].projectID); + }, + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/vaccine/my_vaccines_item_screen.dart b/lib/pages/vaccine/my_vaccines_item_screen.dart new file mode 100644 index 00000000..33ef5975 --- /dev/null +++ b/lib/pages/vaccine/my_vaccines_item_screen.dart @@ -0,0 +1,78 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:provider/provider.dart'; +import '../base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/core/viewModels/vaccine_view_model.dart'; +import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart'; +import 'package:popup_box/popup_box.dart'; + +class MyVaccinesItemPage extends StatefulWidget { + @override + _MyVaccinesItemPageState createState() => _MyVaccinesItemPageState(); +} + +class _MyVaccinesItemPageState extends State { + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) => model.getMyVaccinationItem(), + builder: (BuildContext context, VaccineViewModel model, Widget child) => + AppScaffold( + isShowAppBar: true, + appBarTitle: TranslationBase.of(context).myVaccinesAvailability, + baseViewModel: model, + body: Container( + margin: EdgeInsets.only( + left: SizeConfig.screenWidth * 0.004, + right: SizeConfig.screenWidth * 0.004, + top: SizeConfig.screenWidth * 0.04, + ), + child: ListView.builder( + itemCount: model.vaccinationItemList.length, + itemBuilder: (context, index) => InkWell( + onTap: () async { + await model.getMyVaccinationOnHand( + pItemCode: model.vaccinationItemList[index].iTEMCODE); + if (model.hasError) { + AppToast.showErrorToast(message: model.error); + } else { + //TODO show dialog + + } + }, + child: Container( + margin: EdgeInsets.all(5), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(7), + color: Colors.white, + ), + child: Row( + children: [ + Expanded( + child: Texts( + model.vaccinationItemList[index].dESCRIPTION)), + Icon(projectViewModel.isArabic + ? Icons.arrow_forward_ios + : Icons.arrow_back_ios) + ], + ), + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/pages/vaccine/my_vaccines_screen.dart b/lib/pages/vaccine/my_vaccines_screen.dart index c825884c..02d67cac 100644 --- a/lib/pages/vaccine/my_vaccines_screen.dart +++ b/lib/pages/vaccine/my_vaccines_screen.dart @@ -1,5 +1,8 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:flutter/cupertino.dart'; @@ -9,6 +12,8 @@ import 'package:diplomaticquarterapp/core/viewModels/vaccine_view_model.dart'; import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart'; import 'package:popup_box/popup_box.dart'; +import 'my_vaccines_item_screen.dart'; + class MyVaccines extends StatefulWidget { @override _MyVaccinesState createState() => _MyVaccinesState(); @@ -21,193 +26,174 @@ class _MyVaccinesState extends State { onModelReady: (model) => model.getVaccine(), builder: (BuildContext context, VaccineViewModel model, Widget child) => AppScaffold( - isShowAppBar: true, - appBarTitle: 'My Vaccines', - baseViewModel: model, - body: Container( - margin: EdgeInsets.only( - left: SizeConfig.screenWidth * 0.004, - right: SizeConfig.screenWidth * 0.004, - top: SizeConfig.screenWidth * 0.04, - ), - child: Column( - children: [ - RoundedContainer( - backgroundColor: Colors.white, - child: ExpansionTile( - title: Container( - height: 65.0, - child: Text('2018'), - ), - children: [ - Container( - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model.vaccineList == null - ? 0 - : model.vaccineList.length, - itemBuilder: (BuildContext context, int index) { - return Column( - children: [ - RoundedContainer( - child: Column( + isShowAppBar: true, + appBarTitle: TranslationBase.of(context).myVaccines, + baseViewModel: model, + body: Container( + margin: EdgeInsets.only( + left: SizeConfig.screenWidth * 0.004, + right: SizeConfig.screenWidth * 0.004, + top: SizeConfig.screenWidth * 0.04, + ), + child: Column( + children: [ + RoundedContainer( + backgroundColor: Colors.white, + child: ExpansionTile( + title: Container( + height: 65.0, + child: Text('2018'), + ), + children: [ + Container( + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.vaccineList == null + ? 0 + : model.vaccineList.length, + itemBuilder: (BuildContext context, int index) { + return Column( + children: [ + RoundedContainer( + child: Column( + children: [ + Row( children: [ - Row( - children: [ - Expanded( - child: Column( - children: [ - Padding( - padding: EdgeInsets.symmetric( - horizontal: 20.0, - vertical: 20.0), - child: Image.network( - model.vaccineList[index] - .doctorImageURL, - height: SizeConfig + Expanded( + child: Column( + children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 20.0, + vertical: 20.0), + child: Image.network( + model.vaccineList[index] + .doctorImageURL, + height: SizeConfig .imageSizeMultiplier * - 23, - width: SizeConfig + 23, + width: SizeConfig .imageSizeMultiplier * - 20, - fit: BoxFit.fill, - ), - ), - ], + 20, + fit: BoxFit.fill, + ), ), - flex: 2, - ), - Expanded( - child: Container( - child: Column( - crossAxisAlignment: + ], + ), + flex: 2, + ), + Expanded( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - model.vaccineList[index] + children: [ + Text( + model.vaccineList[index] .doctorTitle + - model.vaccineList[index] - .doctorName, - style: TextStyle( - fontWeight: FontWeight.w900, - fontSize: 16.6, - ), - ), - SpaceBetweenTexts(space: 7.0), - Text( model.vaccineList[index] - .projectName, - style: TextStyle( - fontSize: 17.0, - letterSpacing: 0.5, - ), - ), - SpaceBetweenTexts(space: 7.0), - Text( - model.vaccineList[index] - .vaccineName, - style: TextStyle( - fontSize: 17.0, - ), - ), - SpaceBetweenTexts(space: 7.0), - Text( - 'Date Taken ' + - convertDateFormat(model - .vaccineList[index] - .invoiceDate), - style: - TextStyle(fontSize: 17.0), - ), - ], + .doctorName, + style: TextStyle( + fontWeight: + FontWeight.w900, + fontSize: 16.6, + ), ), - ), - flex: 5, + SizedBox(height: 7.0), + Text( + model.vaccineList[index] + .projectName, + style: TextStyle( + fontSize: 17.0, + letterSpacing: 0.5, + ), + ), + SizedBox(height: 7.0), + Text( + model.vaccineList[index] + .vaccineName, + style: TextStyle( + fontSize: 17.0, + ), + ), + SizedBox(height: 7.0), + Text( + 'Date Taken ' + + convertDateFormat(model + .vaccineList[index] + .invoiceDate), + style: TextStyle( + fontSize: 17.0), + ), + ], ), - ], + ), + flex: 5, ), ], ), - ), - ], - ); - }), - ) - ], - ), - ), - // SpaceBetweenTexts(space: 165.0), - - ], - ), - - ), - bottomSheet: Container( - color: Theme.of(context).scaffoldBackgroundColor, - padding: EdgeInsets.all(12), - height: MediaQuery.of(context).size.height *0.25, - width: double.infinity, - child: Column( - children: [ - Divider(height: 2,thickness: 1,), - SizedBox(height: 6,), - Container( - width: double.infinity, - // height: 80.0, - child: Button( - label: 'CHECK VACCINE AVAILABILITY', - backgroundColor: Color(0xff9EA3A4), - ), - ), - Container( - width: double.infinity, - // height: 80.0, - child: SecondaryButton( - label: 'SEND EMAIL', - color: Color(0xffF62426), - textColor: Colors.white, - disabled: model.vaccineList.length==0, - onTap: () async { - await PopupBox.showPopupBox( - context: context, - button: MaterialButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(3), - ), - color: Colors.white, - child: Text( - 'CANCEL', - style: TextStyle(fontSize: 16.5), - ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - willDisplayWidget: Column( - children: [ - Text( - 'Conform \nSend a copy of this report to the email' + - model.vaccineList[0].doctorName, - style: TextStyle( - fontSize: 20, - color: Colors.black26, - fontWeight: FontWeight.w900), - ), - SizedBox( - height: 30.0, + ], + ), ), ], - )); - }, - ), - ), - ], + ); + }), + ) + ], + ), + ), + // SpaceBetweenTexts(space: 165.0), + ], + ), + ), + bottomSheet: Container( + color: Theme.of(context).scaffoldBackgroundColor, + padding: EdgeInsets.all(12), + height: MediaQuery.of(context).size.height * 0.25, + width: double.infinity, + child: Column( + children: [ + Divider( + height: 2, + thickness: 1, + ), + SizedBox( + height: 6, + ), + Container( + width: double.infinity, + // height: 80.0, + child: Button( + label: TranslationBase.of(context).checkVaccineAvailability, + backgroundColor: Color(0xff9EA3A4), + onTap: () => + Navigator.push(context, FadePage(page: MyVaccinesItemPage())), + ), + ), + Container( + width: double.infinity, + // height: 80.0, + child: SecondaryButton( + label: TranslationBase.of(context).sendEmail, + color: Color(0xffF62426), + textColor: Colors.white, + disabled: model.vaccineList.length == 0, + loading: model.state == ViewState.BusyLocal, + onTap: () async { + model.sendEmail( + message: + TranslationBase.of(context).emailSentSuccessfully); + }, + ), ), - ), + ], ), + ), + ), ); } + convertDateFormat(String Date) { const start = "/Date("; const end = "+0300)"; @@ -225,18 +211,4 @@ class _MyVaccinesState extends State { return newDate.toString(); } - - -} - -class SpaceBetweenTexts extends StatelessWidget { - final double space; - SpaceBetweenTexts({this.space}); - - @override - Widget build(BuildContext context) { - return SizedBox( - height: space, - ); - } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index b8f572e6..3a4d8bc1 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -581,6 +581,12 @@ class TranslationBase { localizedValues['UserAgreement'][locale.languageCode]; String get updateSuccessfully => localizedValues['UpdateSuccessfully'][locale.languageCode]; + String get emailSentSuccessfully => + localizedValues['EmailSentSuccessfully'][locale.languageCode]; + String get checkVaccineAvailability => + localizedValues['CHECK_VACCINE_AVAILABILITY'][locale.languageCode]; + String get myVaccinesAvailability => + localizedValues['MyVaccinesAvailability'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/data_display/medical/doctor_card.dart b/lib/widgets/data_display/medical/doctor_card.dart index 47095cf7..0432dc90 100644 --- a/lib/widgets/data_display/medical/doctor_card.dart +++ b/lib/widgets/data_display/medical/doctor_card.dart @@ -14,6 +14,9 @@ class DoctorCard extends StatelessWidget { final String profileUrl; final String billNo; final Function onTap; + final Function onEmailTap; + + final String isInOutPatientDescription; DoctorCard( {this.name, @@ -22,7 +25,9 @@ class DoctorCard extends StatelessWidget { this.date, this.profileUrl, this.billNo, - this.onTap}); + this.onTap, + this.onEmailTap, + this.isInOutPatientDescription}); @override Widget build(BuildContext context) { @@ -56,7 +61,7 @@ class DoctorCard extends StatelessWidget { quarterTurns: 3, child: Center( child: Text( - "Calendar", + isInOutPatientDescription ?? "Calendar", style: TextStyle(color: Colors.white), ), )), @@ -111,6 +116,13 @@ class DoctorCard extends StatelessWidget { ), ), ), + InkWell( + onTap: onEmailTap, + child: Icon( + Icons.email, + color: Colors.red, + ), + ) ], ), ),