From 158bea519e58e56021c6735559d6adfa6bbc52da Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 28 Jun 2021 17:20:29 +0300 Subject: [PATCH 1/2] medical report fix --- .../medical_report/PatientMedicalReportService.dart | 2 +- .../profile/medical_report/AddVerifyMedicalReport.dart | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart index 01a09592..2b0a1c38 100644 --- a/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart +++ b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart @@ -17,7 +17,7 @@ class PatientMedicalReportService extends BaseService { body['ProjectID'] = doctorProfile.projectID; await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_GET_LIST, onSuccess: (dynamic response, int statusCode) { - medicalReportList.clear(); + medicalReportList = []; if (response['DAPP_ListMedicalReportList'] != null) { response['DAPP_ListMedicalReportList'].forEach((v) { medicalReportList.add(MedicalReportModel.fromJson(v)); diff --git a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart index 4a6be6c8..b31bb9bb 100644 --- a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart +++ b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart @@ -43,7 +43,9 @@ class _AddVerifyMedicalReportState extends State { String txtOfMedicalReport; return BaseView( - onModelReady: (model) async {}, + onModelReady: (model) async { + model.getMedicalReportTemplate(); + }, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, From d19a881801dcaf92c5a02a2dcb3858aba46b5f72 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 5 Jul 2021 12:06:26 +0300 Subject: [PATCH 2/2] Sick Leave doctor app API --- lib/config/config.dart | 1 + .../sick_leave_doctor_request_model.dart | 28 ++ .../sick_leave/sick_leave_patient_model.dart | 22 +- .../sick_leave_patient_request_model.dart | 6 +- .../sick_leave/sickleave_service.dart | 40 ++- lib/core/viewModel/sick_leave_view_model.dart | 18 +- lib/screens/sick-leave/add-sickleave.dart | 177 +++++----- lib/screens/sick-leave/sick_leave.dart | 306 ++++++++---------- 8 files changed, 302 insertions(+), 296 deletions(-) create mode 100644 lib/core/model/sick_leave/sick_leave_doctor_request_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index d6836827..a0f1464e 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -231,6 +231,7 @@ const GET_SPECIAL_CLINICAL_CARE_MAPPING_LIST = "Services/DoctorApplication.svc/R const INSERT_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_InsertMedicalReport_New"; const UPDATE_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_UpdateMedicalReport"; +const GET_SICK_LEAVE_DOCTOR_APP = "Services/DoctorApplication.svc/REST/GetAllSickLeaves"; var selectedPatientType = 1; diff --git a/lib/core/model/sick_leave/sick_leave_doctor_request_model.dart b/lib/core/model/sick_leave/sick_leave_doctor_request_model.dart new file mode 100644 index 00000000..26bb76bd --- /dev/null +++ b/lib/core/model/sick_leave/sick_leave_doctor_request_model.dart @@ -0,0 +1,28 @@ +class GetSickLeaveDoctorRequestModel { + int patientMRN; + String appointmentNo; + int status; + String vidaAuthTokenID; + String vidaRefreshTokenID; + + GetSickLeaveDoctorRequestModel( + {this.patientMRN, this.appointmentNo, this.status, this.vidaAuthTokenID, this.vidaRefreshTokenID}); + + GetSickLeaveDoctorRequestModel.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + status = json['status']; + vidaAuthTokenID = json['VidaAuthTokenID']; + vidaRefreshTokenID = json['VidaRefreshTokenID']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['status'] = this.status; + data['VidaAuthTokenID'] = this.vidaAuthTokenID; + data['VidaRefreshTokenID'] = this.vidaRefreshTokenID; + return data; + } +} diff --git a/lib/core/model/sick_leave/sick_leave_patient_model.dart b/lib/core/model/sick_leave/sick_leave_patient_model.dart index 3c78f1ff..43dbdb05 100644 --- a/lib/core/model/sick_leave/sick_leave_patient_model.dart +++ b/lib/core/model/sick_leave/sick_leave_patient_model.dart @@ -36,6 +36,11 @@ class SickLeavePatientModel { String strRequestDate; String startDate; String endDate; + dynamic isExtendedLeave; + dynamic noOfDays; + dynamic patientMRN; + dynamic remarks; + dynamic status; SickLeavePatientModel( {this.setupID, @@ -72,10 +77,19 @@ class SickLeavePatientModel { // this.speciality, this.strRequestDate, this.startDate, - this.endDate}); + this.endDate, + this.isExtendedLeave, + this.noOfDays, + this.patientMRN, + this.remarks, + this.status}); SickLeavePatientModel.fromJson(Map json) { setupID = json['SetupID']; + isExtendedLeave = json['isExtendedLeave']; + noOfDays = json['noOfDays']; + patientMRN = json['patientMRN']; + status = json['status']; projectID = json['ProjectID']; patientID = json['PatientID']; @@ -109,13 +123,17 @@ class SickLeavePatientModel { qR = json['QR']; // speciality = json['Speciality'].cast(); strRequestDate = json['StrRequestDate']; - startDate = json['StartDate']; + startDate = json['StartDate'] ?? json['startDate']; endDate = json['EndDate']; } Map toJson() { final Map data = new Map(); data['SetupID'] = this.setupID; + data['status'] = this.status; + data['isExtendedLeave'] = this.isExtendedLeave; + data['noOfDays'] = this.noOfDays; + data['patientMRN'] = this.patientMRN; data['ProjectID'] = this.projectID; data['PatientID'] = this.patientID; diff --git a/lib/core/model/sick_leave/sick_leave_patient_request_model.dart b/lib/core/model/sick_leave/sick_leave_patient_request_model.dart index ec588316..69b18f41 100644 --- a/lib/core/model/sick_leave/sick_leave_patient_request_model.dart +++ b/lib/core/model/sick_leave/sick_leave_patient_request_model.dart @@ -10,6 +10,7 @@ class SickLeavePatientRequestModel { int patientTypeID; String tokenID; int patientID; + int patientMRN; String sessionID; SickLeavePatientRequestModel( @@ -24,10 +25,12 @@ class SickLeavePatientRequestModel { this.patientTypeID, this.tokenID, this.patientID, - this.sessionID}); + this.sessionID, + this.patientMRN}); SickLeavePatientRequestModel.fromJson(Map json) { versionID = json['VersionID']; + patientMRN = json['PatientMRN']; channel = json['Channel']; languageID = json['LanguageID']; iPAdress = json['IPAdress']; @@ -44,6 +47,7 @@ class SickLeavePatientRequestModel { Map toJson() { final Map data = new Map(); data['VersionID'] = this.versionID; + data['PatientMRN'] = this.patientMRN; data['Channel'] = this.channel; data['LanguageID'] = this.languageID; data['IPAdress'] = this.iPAdress; diff --git a/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart b/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart index 8113c9a7..e1fca881 100644 --- a/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart +++ b/lib/core/service/patient_medical_file/sick_leave/sickleave_service.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_doctor_request_model.dart'; import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart'; import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_request_model.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; @@ -21,8 +22,7 @@ class SickLeaveService extends BaseService { List get coveringDoctorsList => _coveringDoctors; List _coveringDoctors = []; - List get getAllRescheduleLeave => - _getReScheduleLeave; + List get getAllRescheduleLeave => _getReScheduleLeave; List _getReScheduleLeave = []; dynamic get postReschedule => _postReschedule; dynamic _postReschedule; @@ -31,9 +31,11 @@ class SickLeaveService extends BaseService { dynamic _sickLeaveResponse; List getAllSickLeavePatient = List(); + List getAllSickLeaveDoctor = List(); + //getAllSickLeavePatient.addAll(getAllSickLeaveDoctor); - SickLeavePatientRequestModel _sickLeavePatientRequestModel = - SickLeavePatientRequestModel(); + SickLeavePatientRequestModel _sickLeavePatientRequestModel = SickLeavePatientRequestModel(); + GetSickLeaveDoctorRequestModel _sickLeaveDoctorRequestModel = GetSickLeaveDoctorRequestModel(); Future getStatistics(appoNo, patientMRN) async { hasError = false; @@ -56,6 +58,7 @@ class SickLeaveService extends BaseService { // addSickLeaveRequest.appointmentNo = '2016054661'; // addSickLeaveRequest.patientMRN = '3120746'; hasError = false; + _sickLeaveResponse.clear(); await baseAppClient.post( ADD_SICK_LEAVE, onSuccess: (dynamic response, int statusCode) { @@ -73,8 +76,7 @@ class SickLeaveService extends BaseService { Future extendSickLeave(GetAllSickLeaveResponse request) async { var extendSickLeaveRequest = ExtendSickLeaveRequest(); - extendSickLeaveRequest.patientMRN = - request.patientMRN.toString(); //'3120746'; + extendSickLeaveRequest.patientMRN = request.patientMRN.toString(); //'3120746'; extendSickLeaveRequest.previousRequestNo = request.requestNo.toString(); extendSickLeaveRequest.noOfDays = request.noOfDays.toString(); extendSickLeaveRequest.remarks = request.remarks; @@ -114,8 +116,8 @@ class SickLeaveService extends BaseService { } Future getSickLeavePatient(patientMRN) async { - _sickLeavePatientRequestModel = SickLeavePatientRequestModel( - patientID: patientMRN, patientTypeID: 2, patientType: 1); + _sickLeavePatientRequestModel = + SickLeavePatientRequestModel(patientID: patientMRN, patientTypeID: 2, patientType: 1); hasError = false; getAllSickLeavePatient = []; getAllSickLeavePatient.clear(); @@ -136,6 +138,28 @@ class SickLeaveService extends BaseService { ); } + Future getSickLeaveDoctor(patientMRN) async { + _sickLeaveDoctorRequestModel = GetSickLeaveDoctorRequestModel(patientMRN: patientMRN); + hasError = false; + getAllSickLeaveDoctor = []; + getAllSickLeaveDoctor.clear(); + await baseAppClient.post( + GET_SICK_LEAVE_DOCTOR_APP, + onSuccess: (dynamic response, int statusCode) { + Future.value(response); + getAllSickLeaveDoctor.clear(); + response['SickLeavesList']['entityList'].forEach((v) { + getAllSickLeaveDoctor.add(SickLeavePatientModel.fromJson(v)); + }); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: _sickLeaveDoctorRequestModel.toJson(), + ); + } + Future getRescheduleLeave() async { hasError = false; await baseAppClient.post( diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index b768cc9d..e80318f6 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -10,13 +10,17 @@ class SickLeaveViewModel extends BaseViewModel { SickLeaveService _sickLeaveService = locator(); get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; get getAllSIckLeave => _sickLeaveService.getAllSickLeave; - get getAllSIckLeavePatient => _sickLeaveService.getAllSickLeavePatient; + //get getAllSIckLeavePatient => _sickLeaveService.getAllSickLeavePatient; + get sickleaveResponse => _sickLeaveService.sickLeaveResponse; + List get allOffTime => _sickLeaveService.getOffTimeList; List get allReasons => _sickLeaveService.getReasons; List get coveringDoctors => _sickLeaveService.coveringDoctorsList; + List get sickLeaveDoctor => _sickLeaveService.getAllSickLeaveDoctor; get getReschduleLeave => _sickLeaveService.getAllRescheduleLeave; get postSechedule => _sickLeaveService.postReschedule; - get sickleaveResponse => _sickLeaveService.sickLeaveResponse; + get getAllSIckLeavePatient => + [..._sickLeaveService.getAllSickLeavePatient, ..._sickLeaveService.getAllSickLeaveDoctor]; Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { setState(ViewState.Busy); await _sickLeaveService.addSickLeave(addSickLeaveRequest); @@ -67,6 +71,16 @@ class SickLeaveViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future getSickLeaveDoctor(patientMRN) async { + setState(ViewState.Busy); + await _sickLeaveService.getSickLeaveDoctor(patientMRN); + if (_sickLeaveService.hasError) { + error = _sickLeaveService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + Future getRescheduleLeave() async { setState(ViewState.Busy); await _sickLeaveService.getRescheduleLeave(); diff --git a/lib/screens/sick-leave/add-sickleave.dart b/lib/screens/sick-leave/add-sickleave.dart index 7b065321..61c81957 100644 --- a/lib/screens/sick-leave/add-sickleave.dart +++ b/lib/screens/sick-leave/add-sickleave.dart @@ -28,8 +28,10 @@ class AddSickLeavScreen extends StatelessWidget { patient = routeArgs['patient']; bool isInpatient = routeArgs['isInpatient']; return BaseView( - onModelReady: (model) => - model.getSickLeavePatient(patient.patientMRN ?? patient.patientId), + onModelReady: (model) async { + await model.getSickLeavePatient(patient.patientMRN ?? patient.patientId); + await model.getSickLeaveDoctor(patient.patientMRN ?? patient.patientId); + }, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, @@ -61,56 +63,59 @@ class AddSickLeavScreen extends StatelessWidget { ), ], )), - Container( - width: SizeConfig.screenWidth, - margin: EdgeInsets.only( - left: 20, right: 20, top: 10, bottom: 10), - padding: EdgeInsets.all(20), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: HexColor('#EAEAEA')), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Container( - child: Container( - decoration: BoxDecoration( - color: Colors.grey, - borderRadius: BorderRadius.circular(10)), - padding: EdgeInsets.all(3), - child: IconButton( + InkWell( + onTap: () { + openSickLeave( + context, + false, + ); + }, + child: Container( + width: SizeConfig.screenWidth, + margin: EdgeInsets.only(left: 20, right: 20, top: 10, bottom: 10), + padding: EdgeInsets.all(20), + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(10), color: HexColor('#EAEAEA')), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + child: Container( + decoration: + BoxDecoration(color: Colors.grey, borderRadius: BorderRadius.circular(10)), + padding: EdgeInsets.all(3), + child: IconButton( icon: Icon( Icons.add, size: 35, color: Colors.white, ), - onPressed: () { - openSickLeave( - context, - false, - ); - }), - )), - Padding( - child: AppText( - TranslationBase.of(context) - .noSickLeaveApplied, - fontWeight: FontWeight.bold, - fontFamily: 'Poppins', - fontSize: 16, - textAlign: TextAlign.center, - color: HexColor('#7E7E7E')), - padding: EdgeInsets.all(10), - ), - ], - )), + // onPressed: () { + // openSickLeave( + // context, + // false, + // ); + // }, + ), + )), + Padding( + child: AppText(TranslationBase.of(context).noSickLeaveApplied, + fontWeight: FontWeight.bold, + fontFamily: 'Poppins', + fontSize: 16, + textAlign: TextAlign.center, + color: HexColor('#7E7E7E')), + padding: EdgeInsets.all(10), + ), + ], + )), + ), ], ) : SizedBox(), model.getAllSIckLeavePatient.length > 0 ? Column( - children: model.getAllSIckLeavePatient - .map((SickLeavePatientModel item) { + children: model.getAllSIckLeavePatient.map((SickLeavePatientModel item) { return RoundedContainer( margin: EdgeInsets.all(10), child: Column( @@ -129,8 +134,7 @@ class AddSickLeavScreen extends StatelessWidget { // ))), padding: EdgeInsets.all(10), child: Row( - mainAxisAlignment: - MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ Expanded( flex: 4, @@ -139,13 +143,12 @@ class AddSickLeavScreen extends StatelessWidget { // MainAxisAlignment.start, children: [ Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( padding: EdgeInsets.all(3), child: AppText( - item.doctorName, + item.doctorName ?? "", // item.status == 1 // ? TranslationBase.of( // context) @@ -158,8 +161,7 @@ class AddSickLeavScreen extends StatelessWidget { // : TranslationBase // .of(context) // .all, - fontWeight: - FontWeight.bold, + fontWeight: FontWeight.bold, // color: item.status == 1 // ? Colors.yellow[800] // : item.status == 2 @@ -170,34 +172,25 @@ class AddSickLeavScreen extends StatelessWidget { ), Row( children: [ - AppText(TranslationBase - .of(context) - .daysSickleave + - ": "), + AppText(TranslationBase.of(context).daysSickleave + ": "), AppText( - item.sickLeaveDays - .toString(), - fontWeight: - FontWeight.bold, + item.sickLeaveDays ?? item.noOfDays.toString(), + fontWeight: FontWeight.bold, ), ], ), Row( children: [ AppText( - TranslationBase.of( - context) - .startDate + - ' ', + TranslationBase.of(context).startDate + ' ' ?? "", ), Flexible( child: AppText( AppDateUtils.getDayMonthYearDateFormatted( - AppDateUtils - .convertStringToDate( - item.startDate)), - fontWeight: - FontWeight.bold, + item.startDate.contains("/Date(") + ? AppDateUtils.convertStringToDate(item.startDate) + : DateTime.parse(item.startDate)), + fontWeight: FontWeight.bold, ), ) ], @@ -205,42 +198,21 @@ class AddSickLeavScreen extends StatelessWidget { Row( children: [ AppText( - TranslationBase.of(context) - .endDate + - ' ', + TranslationBase.of(context).endDate + ' ' ?? "", ), Flexible( child: AppText( - AppDateUtils - .getDayMonthYearDateFormatted( - AppDateUtils - .convertStringToDate( - item.endDate, - )), - fontWeight: - FontWeight.bold, + AppDateUtils.getDayMonthYearDateFormatted( + item.startDate.contains("/Date(") + ? AppDateUtils.convertStringToDate(item.endDate) + .add(Duration(days: item.noOfDays)) + : DateTime.parse(item.startDate) + .add(Duration(days: item.noOfDays))), + fontWeight: FontWeight.bold, ), ) ], ), - Row(children: [ - AppText(TranslationBase.of( - context) - .branch + - ": "), - AppText( - item.projectName ?? "", - ), - ]), - Row(children: [ - AppText(TranslationBase.of( - context) - .clinic + - ": "), - AppText( - item.clinicName ?? "", - ), - ]), ], ), SizedBox( @@ -266,8 +238,7 @@ class AddSickLeavScreen extends StatelessWidget { Image.asset('assets/images/no-data.png'), Padding( padding: const EdgeInsets.all(8.0), - child: AppText( - TranslationBase.of(context).noSickLeave), + child: AppText(TranslationBase.of(context).noSickLeave), ) ], ), @@ -276,8 +247,7 @@ class AddSickLeavScreen extends StatelessWidget { ])))); } - openSickLeave(BuildContext context, isExtend, - {GetAllSickLeaveResponse extendedData}) { + openSickLeave(BuildContext context, isExtend, {GetAllSickLeaveResponse extendedData}) { // showModalBottomSheet( // context: context, // builder: (context) { @@ -287,12 +257,9 @@ class AddSickLeavScreen extends StatelessWidget { context, FadePage( page: SickLeaveScreen( - appointmentNo: isExtend == true - ? extendedData.appointmentNo - : patient.appointmentNo, //extendedData.appointmentNo, - patientMRN: isExtend == true - ? extendedData.patientMRN - : patient.patientMRN, + appointmentNo: + isExtend == true ? extendedData.appointmentNo : patient.appointmentNo, //extendedData.appointmentNo, + patientMRN: isExtend == true ? extendedData.patientMRN : patient.patientMRN, isExtended: isExtend, extendedData: extendedData, patient: patient))); diff --git a/lib/screens/sick-leave/sick_leave.dart b/lib/screens/sick-leave/sick_leave.dart index 199a7c82..be8e38f1 100644 --- a/lib/screens/sick-leave/sick_leave.dart +++ b/lib/screens/sick-leave/sick_leave.dart @@ -1,12 +1,14 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart'; import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/sick-leave/add-sickleave.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -28,12 +30,7 @@ class SickLeaveScreen extends StatefulWidget { final appointmentNo; final patientMRN; final patient; - SickLeaveScreen( - {this.appointmentNo, - this.patientMRN, - this.isExtended = false, - this.extendedData, - this.patient}); + SickLeaveScreen({this.appointmentNo, this.patientMRN, this.isExtended = false, this.extendedData, this.patient}); @override _SickLeaveScreenState createState() => _SickLeaveScreenState(); } @@ -76,8 +73,7 @@ class _SickLeaveScreenState extends State { return BaseView( onModelReady: (model) => model.getClinicsList(), builder: (_, model, w) => BaseView( - onModelReady: (model2) => model2.preSickLeaveStatistics( - widget.appointmentNo, widget.patientMRN), + onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN), builder: (_, model2, w) => GestureDetector( onTap: () { FocusScope.of(context).requestFocus(new FocusNode()); @@ -108,46 +104,35 @@ class _SickLeaveScreenState extends State { Container( margin: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), + borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all( width: 1.0, color: HexColor("#CCCCCC"), ), color: Colors.white), padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Padding( - padding: EdgeInsets.only( - top: 5, left: 10, right: 10), - child: AppText( - TranslationBase.of(context) - .sickLeave + - ' ' + - TranslationBase.of(context) - .days)), - AppTextFormField( - borderColor: Colors.white, - onChanged: (value) { - addSickLeave.noOfDays = value; - if (widget.extendedData != null) { - widget.extendedData.noOfDays = - int.parse(value); - } - }, - hintText: widget.extendedData != null - ? widget.extendedData.noOfDays - .toString() - : '', - // validator: (value) { - // return TextValidator().validateName(value); - // }, - textInputType:TextInputType.number, - inputFormatter: ONLY_NUMBERS) - ]), + child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + Padding( + padding: EdgeInsets.only(top: 5, left: 10, right: 10), + child: AppText(TranslationBase.of(context).sickLeave + + ' ' + + TranslationBase.of(context).days)), + AppTextFormField( + borderColor: Colors.white, + onChanged: (value) { + addSickLeave.noOfDays = value; + if (widget.extendedData != null) { + widget.extendedData.noOfDays = int.parse(value); + } + }, + hintText: + widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '', + // validator: (value) { + // return TextValidator().validateName(value); + // }, + textInputType: TextInputType.number, + inputFormatter: ONLY_NUMBERS) + ]), ), SizedBox( height: 10, @@ -155,146 +140,107 @@ class _SickLeaveScreenState extends State { Container( margin: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC")), + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), color: Colors.white, ), padding: EdgeInsets.all(5), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.only( - top: 5, left: 10, right: 10), + padding: EdgeInsets.only(top: 5, left: 10, right: 10), child: AppText( - TranslationBase.of(context) - .sickLeaveDate, + TranslationBase.of(context).sickLeaveDate, )), AppTextFormField( - hintText: widget.extendedData != null - ? widget.extendedData.startDate - : '', + hintText: widget.extendedData != null ? widget.extendedData.startDate : '', borderColor: Colors.white, - prefix: IconButton( - icon: Icon(Icons.calendar_today)), + prefix: IconButton(icon: Icon(Icons.calendar_today)), textInputType: TextInputType.number, controller: _toDateController, onTap: () { - _presentDatePicker( - '_selectedToDate'); + _presentDatePicker('_selectedToDate'); }, inputFormatter: ONLY_DATE, onChanged: (value) { addSickLeave.startDate = value; if (widget.extendedData != null) { - widget.extendedData.startDate = - value; + widget.extendedData.startDate = value; } }), ], )), Container( - margin: EdgeInsets.only( - top: 10, left: 10, right: 10), + margin: EdgeInsets.only(top: 10, left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC")), + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), color: Colors.white, ), width: double.infinity, child: Padding( padding: EdgeInsets.only( top: SizeConfig.widthMultiplier * 0.9, - bottom: - SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, right: SizeConfig.widthMultiplier * 3, left: SizeConfig.widthMultiplier * 3), child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: EdgeInsets.only(top: 5), child: AppText( - TranslationBase.of(context) - .clinicName, + TranslationBase.of(context).clinicName, )), Row( mainAxisSize: MainAxisSize.max, children: [ Expanded( // add Expanded to have your dropdown button fill remaining space - child: - DropdownButtonHideUnderline( - child: new IgnorePointer( - ignoring: true, - child: DropdownButton( - isExpanded: true, - value: getClinicName( - model) ?? - "", - iconSize: 0, - elevation: 16, - selectedItemBuilder: - (BuildContext - context) { - return model - .getClinicNameList() - .map((item) { - return Row( - mainAxisSize: - MainAxisSize - .max, - children: < - Widget>[ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - color: Colors - .grey, - ), - ], - ); - }).toList(); - }, - onChanged: - (newValue) => - {}, - items: model - .getClinicNameList() - .map((item) { - return DropdownMenuItem( - value: item - .toString(), - child: Text( + child: DropdownButtonHideUnderline( + child: new IgnorePointer( + ignoring: true, + child: DropdownButton( + isExpanded: true, + value: getClinicName(model) ?? "", + iconSize: 0, + elevation: 16, + selectedItemBuilder: (BuildContext context) { + return model.getClinicNameList().map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( item, - textAlign: - TextAlign - .end, + fontSize: SizeConfig.textMultiplier * 2.1, + color: Colors.grey, ), - ); - }).toList(), - ))), + ], + ); + }).toList(); + }, + onChanged: (newValue) => {}, + items: model.getClinicNameList().map((item) { + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), + ); + }).toList(), + ))), ), ], ) ], ), )), - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'] != - null + model2.sickLeaveStatistics['recommendedSickLeaveDays'] != null ? Padding( child: AppText( - model2.sickLeaveStatistics[ - 'recommendedSickLeaveDays'], + model2.sickLeaveStatistics['recommendedSickLeaveDays'], fontWeight: FontWeight.bold, textAlign: TextAlign.start, ), @@ -306,10 +252,8 @@ class _SickLeaveScreenState extends State { Container( margin: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC")), + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), color: Colors.white, ), padding: EdgeInsets.all(5), @@ -317,11 +261,9 @@ class _SickLeaveScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.only( - top: 5, left: 10, right: 10), + padding: EdgeInsets.only(top: 5, left: 10, right: 10), child: AppText( - TranslationBase.of(context) - .doctorName, + TranslationBase.of(context).doctorName, )), new IgnorePointer( ignoring: true, @@ -343,10 +285,8 @@ class _SickLeaveScreenState extends State { Container( margin: EdgeInsets.only(left: 10, right: 10), decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(6.0)), - border: Border.all( - width: 1.0, color: HexColor("#CCCCCC")), + borderRadius: BorderRadius.all(Radius.circular(6.0)), + border: Border.all(width: 1.0, color: HexColor("#CCCCCC")), color: Colors.white, ), padding: EdgeInsets.all(5), @@ -354,8 +294,7 @@ class _SickLeaveScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.only( - top: 5, left: 10, right: 10), + padding: EdgeInsets.only(top: 5, left: 10, right: 10), child: AppText( TranslationBase.of(context).remarks, )), @@ -364,9 +303,7 @@ class _SickLeaveScreenState extends State { decoration: InputDecoration( contentPadding: EdgeInsets.all(20.0), border: InputBorder.none, - hintText: widget.extendedData != null - ? widget.extendedData.remarks - : ''), + hintText: widget.extendedData != null ? widget.extendedData.remarks : ''), onChanged: (value) { addSickLeave.remarks = value; if (widget.extendedData != null) { @@ -378,40 +315,60 @@ class _SickLeaveScreenState extends State { ), ), Container( - margin: EdgeInsets.all( - SizeConfig.widthMultiplier * 5), + margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Wrap( alignment: WrapAlignment.center, children: [ AppButton( title: widget.isExtended == true ? TranslationBase.of(context).extend - : TranslationBase.of(context) - .addSickLeaverequest, + : TranslationBase.of(context).addSickLeaverequest, color: Colors.green, onPressed: () async { if (widget.isExtended) { - await model2.extendSickLeave( - widget.extendedData); + await model2.extendSickLeave(widget.extendedData); DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse[ - 'ListSickLeavesToExtent'] - ['success']); - Navigator.of(context) - .popUntil((route) { - return route.settings.name == - PATIENTS_PROFILE; + model2.sickleaveResponse['ListSickLeavesToExtent']['success']); + Navigator.of(context).popUntil((route) { + return route.settings.name == PATIENTS_PROFILE; }); - Navigator.of(context).pushNamed( - ADD_SICKLEAVE, - arguments: { - 'patient': widget.patient - }); + Navigator.of(context) + .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); //print(value); //}); } else { - _validateInputs(model2); + try { + if (addSickLeave.noOfDays == null) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).pleaseEnterNoOfDays); + } else if (addSickLeave.remarks == null) { + DrAppToastMsg.showErrorToast( + TranslationBase.of(context).pleaseEnterRemarks); + } else if (addSickLeave.startDate == null) { + DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); + } else { + addSickLeave.patientMRN = widget.patient.patientMRN.toString(); + addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); + await model2.addSickLeave(addSickLeave); + + if (model2.sickleaveResponse['SickLeavesList']['success'] != null) + DrAppToastMsg.showSuccesToast( + model2.sickleaveResponse['SickLeavesList']['success']); + } + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => AddSickLeavScreen()), + // ); + + // Navigator.of(context).popUntil((route) { + // return route.settings.name == PATIENTS_PROFILE; + // }); + // Navigator.of(context) + // .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); + } catch (err) { + print(err); + } } }, ), @@ -437,26 +394,21 @@ class _SickLeaveScreenState extends State { void _validateInputs(model2) async { try { if (addSickLeave.noOfDays == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterNoOfDays); + DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterNoOfDays); } else if (addSickLeave.remarks == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterRemarks); + DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterRemarks); } else if (addSickLeave.startDate == null) { - DrAppToastMsg.showErrorToast( - TranslationBase.of(context).pleaseEnterDate); + DrAppToastMsg.showErrorToast(TranslationBase.of(context).pleaseEnterDate); } else { addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.appointmentNo = widget.patient.appointmentNo.toString(); await model2.addSickLeave(addSickLeave).then((value) => print(value)); - DrAppToastMsg.showSuccesToast( - model2.sickleaveResponse['ListSickLeavesToExtent']['success']); + DrAppToastMsg.showSuccesToast(model2.sickleaveResponse['ListSickLeavesToExtent']['success']); Navigator.of(context).popUntil((route) { return route.settings.name == PATIENTS_PROFILE; }); - Navigator.of(context) - .pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); + Navigator.of(context).pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient}); } } catch (err) { print(err); @@ -471,9 +423,7 @@ class _SickLeaveScreenState extends State { } getClinicName(model) { - var clinicInfo = model.clinicsList - .where((i) => i['ClinicID'] == this.profile['ClinicID']) - .toList(); + var clinicInfo = model.clinicsList.where((i) => i['ClinicID'] == this.profile['ClinicID']).toList(); return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : ""; } }