diff --git a/lib/config/config.dart b/lib/config/config.dart index 63ff8954..355e58eb 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -186,6 +186,10 @@ const GET_PAtIENTS_INSURANCE_APPROVALS = "Services/Patients.svc/REST/GetApprovalStatus"; const SEARCH_BOT = 'HabibiChatBotApi/BotInterface/GetVoiceCommandResponse'; +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/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/service/medical/PatientSickLeaveService.dart b/lib/core/service/medical/PatientSickLeaveService.dart new file mode 100644 index 00000000..4801d8b0 --- /dev/null +++ b/lib/core/service/medical/PatientSickLeaveService.dart @@ -0,0 +1,43 @@ +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}) 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; + 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/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..9ed25b01 --- /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}) async { + setState(ViewState.BusyLocal); + await _patientSickLeaveService.sendSickLeaveEmail( + requestNo: requestNo, projectName: projectName, doctorName: doctorName); + 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/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/patient_sick_leave_page.dart b/lib/pages/medical/patient_sick_leave_page.dart new file mode 100644 index 00000000..06604c99 --- /dev/null +++ b/lib/pages/medical/patient_sick_leave_page.dart @@ -0,0 +1,44 @@ +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/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: SingleChildScrollView( + child: 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].doctorRate.toDouble(), + subName: model.sickLeaveList[index].projectName, + isInOutPatientDescription: model.sickLeaveList[index].isInOutPatientDescription, + onEmailTap: (){ + model.sendSickLeaveEmail(); + }, + ), + ), + ), + ), + ), + ); + } +} 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, + ), + ) ], ), ),