From 73f2abbea2679da1837e24b86c718fcb8264176a Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Thu, 17 Jun 2021 15:40:07 +0300 Subject: [PATCH] flutter 2 migration --- lib/config/config.dart | 4 +- .../admission-request_second-screen.dart | 6 +- .../profile/note/progress_note_screen.dart | 583 +++++++++--------- .../prescription/add_prescription_form.dart | 36 +- .../prescription/prescription_text_filed.dart | 8 +- 5 files changed, 329 insertions(+), 308 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index c8af8ad9..0283577e 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart b/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart index 42fafd8e..0c9ccb4e 100644 --- a/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart +++ b/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart @@ -38,7 +38,7 @@ class _AdmissionRequestSecondScreenState extends State { late List notesList; var filteredNotesList; bool isDischargedPatient = false; - AuthenticationViewModel? authenticationViewModel; - ProjectViewModel? projectViewModel; + late AuthenticationViewModel authenticationViewModel; + late ProjectViewModel projectViewModel; getProgressNoteList(BuildContext context, PatientViewModel model, {bool isLocalBusy = false}) async { final routeArgs = ModalRoute.of(context)!.settings.arguments as Map; @@ -65,8 +65,8 @@ class _ProgressNoteState extends State { @override Widget build(BuildContext context) { - // authenticationViewModel = Provider.of(context); - // projectViewModel = Provider.of(context); + authenticationViewModel = Provider.of(context); + projectViewModel = Provider.of(context); final routeArgs = ModalRoute.of(context)!.settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String arrivalType = routeArgs['arrivalType']; @@ -90,308 +90,313 @@ class _ProgressNoteState extends State { child: Column( children: [ if (!isDischargedPatient) - AddNewOrder( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => UpdateNoteOrder( - patientModel: model, - patient: patient, - visitType: widget.visitType, - isUpdate: false, - )), - ); - }, - label: widget.visitType == 3 - ? TranslationBase.of(context).addNewOrderSheet! - : TranslationBase.of(context).addProgressNote!, - ), - Expanded( - child: Container( - child: ListView.builder( - itemCount: model.patientProgressNoteList.length, - itemBuilder: (BuildContext ctxt, int index) { - return FractionallySizedBox( - widthFactor: 0.95, - child: CardWithBgWidget( - hasBorder: false, - bgColor: model.patientProgressNoteList[index].status == 1 && - authenticationViewModel!.doctorProfile!.doctorID != - model.patientProgressNoteList[index].createdBy - ? Color(0xFFCC9B14) - : model.patientProgressNoteList[index].status == 4 - ? Colors.red.shade700 - : model.patientProgressNoteList[index].status == 2 - ? Colors.green[600]! - : Color(0xFFCC9B14)!, - widget: Column( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (model.patientProgressNoteList[index].status == 1 && - authenticationViewModel!.doctorProfile!.doctorID != - model.patientProgressNoteList[index].createdBy) - AppText( - TranslationBase.of(context).notePending, - fontWeight: FontWeight.bold, - color: Color(0xFFCC9B14), - fontSize: 12, - ), - if (model.patientProgressNoteList[index].status == 4) - AppText( - TranslationBase.of(context).noteCanceled, - fontWeight: FontWeight.bold, - color: Colors.red.shade700, - fontSize: 12, - ), - if (model.patientProgressNoteList[index].status == 2) - AppText( - TranslationBase.of(context).noteVerified, - fontWeight: FontWeight.bold, - color: Colors.green[600], - fontSize: 12, - ), - if (model.patientProgressNoteList[index].status != 2 && - model.patientProgressNoteList[index].status != 4 && - authenticationViewModel!.doctorProfile!.doctorID == - model.patientProgressNoteList[index].createdBy) - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => UpdateNoteOrder( - note: model.patientProgressNoteList[index], - patientModel: model, - patient: patient, - visitType: widget.visitType, - isUpdate: true, - )), - ); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.grey[600], - borderRadius: BorderRadius.circular(10), - ), - // color:Colors.red[600], + // AddNewOrder( + // onTap: () { + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => UpdateNoteOrder( + // patientModel: model, + // patient: patient, + // visitType: widget.visitType, + // isUpdate: false, + // )), + // ); + // }, + // label: widget.visitType == 3 + // ? TranslationBase.of(context).addNewOrderSheet! + // : TranslationBase.of(context).addProgressNote!, + // ), + Expanded( + child: Container( + child: ListView.builder( + itemCount: model.patientProgressNoteList.length, + itemBuilder: (BuildContext ctxt, int index) { + return FractionallySizedBox( + widthFactor: 0.95, + child: CardWithBgWidget( + hasBorder: false, + bgColor: model.patientProgressNoteList[index].status == 1 && + authenticationViewModel!.doctorProfile!.doctorID != + model.patientProgressNoteList[index].createdBy + ? Color(0xFFCC9B14) + : model.patientProgressNoteList[index].status == 4 + ? Colors.red.shade700 + : model.patientProgressNoteList[index].status == 2 + ? Colors.green[600]! + : Color(0xFFCC9B14)!, + widget: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (model.patientProgressNoteList[index].status == 1 && + authenticationViewModel!.doctorProfile!.doctorID != + model.patientProgressNoteList[index].createdBy) + AppText( + TranslationBase.of(context).notePending, + fontWeight: FontWeight.bold, + color: Color(0xFFCC9B14), + fontSize: 12, + ), + if (model.patientProgressNoteList[index].status == 4) + AppText( + TranslationBase.of(context).noteCanceled, + fontWeight: FontWeight.bold, + color: Colors.red.shade700, + fontSize: 12, + ), + if (model.patientProgressNoteList[index].status == 2) + AppText( + TranslationBase.of(context).noteVerified, + fontWeight: FontWeight.bold, + color: Colors.green[600], + fontSize: 12, + ), + if (model.patientProgressNoteList[index].status != 2 && + model.patientProgressNoteList[index].status != 4 && + authenticationViewModel!.doctorProfile!.doctorID == + model.patientProgressNoteList[index].createdBy) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => UpdateNoteOrder( + note: model.patientProgressNoteList[index], + patientModel: model, + patient: patient, + visitType: widget.visitType, + isUpdate: true, + )), + ); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.grey[600], + borderRadius: BorderRadius.circular(10), + ), + // color:Colors.red[600], - child: Row( - children: [ - Icon( - DoctorApp.edit_1, - size: 12, - color: Colors.white, - ), - SizedBox( - width: 2, - ), - AppText( - TranslationBase.of(context).update, - fontSize: 10, - color: Colors.white, - ), - ], + child: Row( + children: [ + Icon( + DoctorApp.edit_1, + size: 12, + color: Colors.white, + ), + SizedBox( + width: 2, + ), + AppText( + TranslationBase.of(context).update, + fontSize: 10, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), ), - padding: EdgeInsets.all(6), ), - ), - SizedBox( - width: 10, - ), - InkWell( - onTap: () async { - showMyDialog( - context: context, - actionName: "verify", - confirmFun: () async { - GifLoaderDialogUtils.showMyDialog(context); - UpdateNoteReqModel reqModel = UpdateNoteReqModel( - admissionNo: int.parse(patient.admissionNo ?? ""), - cancelledNote: false, - lineItemNo: model.patientProgressNoteList[index].lineItemNo, - createdBy: model.patientProgressNoteList[index].createdBy, - notes: model.patientProgressNoteList[index].notes, - verifiedNote: true, - patientTypeID: patient.patientType, - patientOutSA: false, - ); - await model.updatePatientProgressNote(reqModel); - await getProgressNoteList(context, model, isLocalBusy: true); - GifLoaderDialogUtils.hideDialog(context); - }); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.green[600], - borderRadius: BorderRadius.circular(10), - ), - // color:Colors.red[600], + SizedBox( + width: 10, + ), + InkWell( + onTap: () async { + showMyDialog( + context: context, + actionName: "verify", + confirmFun: () async { + GifLoaderDialogUtils.showMyDialog(context); + UpdateNoteReqModel reqModel = UpdateNoteReqModel( + admissionNo: int.parse(patient.admissionNo ?? ""), + cancelledNote: false, + lineItemNo: + model.patientProgressNoteList[index].lineItemNo, + createdBy: model.patientProgressNoteList[index].createdBy, + notes: model.patientProgressNoteList[index].notes, + verifiedNote: true, + patientTypeID: patient.patientType, + patientOutSA: false, + ); + await model.updatePatientProgressNote(reqModel); + await getProgressNoteList(context, model, + isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.green[600], + borderRadius: BorderRadius.circular(10), + ), + // color:Colors.red[600], - child: Row( - children: [ - Icon( - FontAwesomeIcons.check, - size: 12, - color: Colors.white, - ), - SizedBox( - width: 2, - ), - AppText( - TranslationBase.of(context).noteVerify, - fontSize: 10, - color: Colors.white, - ), - ], + child: Row( + children: [ + Icon( + FontAwesomeIcons.check, + size: 12, + color: Colors.white, + ), + SizedBox( + width: 2, + ), + AppText( + TranslationBase.of(context).noteVerify, + fontSize: 10, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), ), - padding: EdgeInsets.all(6), ), - ), - SizedBox( - width: 10, - ), - InkWell( - onTap: () async { - showMyDialog( - context: context, - actionName: TranslationBase.of(context).cancel!, - confirmFun: () async { - GifLoaderDialogUtils.showMyDialog( - context, - ); - UpdateNoteReqModel reqModel = UpdateNoteReqModel( - admissionNo: int.parse(patient.admissionNo ?? ""), - cancelledNote: true, - lineItemNo: model.patientProgressNoteList[index].lineItemNo, - createdBy: model.patientProgressNoteList[index].createdBy, - notes: model.patientProgressNoteList[index].notes, - verifiedNote: false, - patientTypeID: patient.patientType, - patientOutSA: false, - ); - await model.updatePatientProgressNote(reqModel); - await getProgressNoteList(context, model, isLocalBusy: true); - GifLoaderDialogUtils.hideDialog(context); - }); - }, - child: Container( - decoration: BoxDecoration( - color: Colors.red[600], - borderRadius: BorderRadius.circular(10), - ), - // color:Colors.red[600], + SizedBox( + width: 10, + ), + InkWell( + onTap: () async { + showMyDialog( + context: context, + actionName: TranslationBase.of(context).cancel!, + confirmFun: () async { + GifLoaderDialogUtils.showMyDialog( + context, + ); + UpdateNoteReqModel reqModel = UpdateNoteReqModel( + admissionNo: int.parse(patient.admissionNo ?? ""), + cancelledNote: true, + lineItemNo: + model.patientProgressNoteList[index].lineItemNo, + createdBy: model.patientProgressNoteList[index].createdBy, + notes: model.patientProgressNoteList[index].notes, + verifiedNote: false, + patientTypeID: patient.patientType, + patientOutSA: false, + ); + await model.updatePatientProgressNote(reqModel); + await getProgressNoteList(context, model, + isLocalBusy: true); + GifLoaderDialogUtils.hideDialog(context); + }); + }, + child: Container( + decoration: BoxDecoration( + color: Colors.red[600], + borderRadius: BorderRadius.circular(10), + ), + // color:Colors.red[600], - child: Row( - children: [ - Icon( - FontAwesomeIcons.trash, - size: 12, - color: Colors.white, - ), - SizedBox( - width: 2, - ), - AppText( - 'Cancel', - fontSize: 10, - color: Colors.white, - ), - ], + child: Row( + children: [ + Icon( + FontAwesomeIcons.trash, + size: 12, + color: Colors.white, + ), + SizedBox( + width: 2, + ), + AppText( + 'Cancel', + fontSize: 10, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), ), - padding: EdgeInsets.all(6), ), - ), - SizedBox( - width: 10, - ) - ], + SizedBox( + width: 10, + ) + ], + ), + SizedBox( + height: 10, ), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: MediaQuery.of(context).size.width * 0.60, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - TranslationBase.of(context).createdBy, - fontSize: 10, - ), - Expanded( - child: AppText( - model.patientProgressNoteList[index].doctorName ?? '', - fontWeight: FontWeight.w600, - fontSize: 12, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width * 0.60, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).createdBy, + fontSize: 10, ), - ), - ], + Expanded( + child: AppText( + model.patientProgressNoteList[index].doctorName ?? '', + fontWeight: FontWeight.w600, + fontSize: 12, + ), + ), + ], + ), + ], + ), + ), + Column( + children: [ + AppText( + model.patientProgressNoteList[index].createdOn != null + ? AppDateUtils.getDayMonthYearDateFormatted( + AppDateUtils.getDateTimeFromServerFormat( + model.patientProgressNoteList[index].createdOn ?? ""), + isArabic: projectViewModel!.isArabic) + : AppDateUtils.getDayMonthYearDateFormatted(DateTime.now(), + isArabic: projectViewModel!.isArabic), + fontWeight: FontWeight.w600, + fontSize: 14, + ), + AppText( + model.patientProgressNoteList[index].createdOn != null + ? AppDateUtils.getHour( + AppDateUtils.getDateTimeFromServerFormat( + model.patientProgressNoteList[index].createdOn ?? "")) + : AppDateUtils.getHour(DateTime.now()), + fontWeight: FontWeight.w600, + fontSize: 14, ), ], + crossAxisAlignment: CrossAxisAlignment.end, + ) + ], + ), + SizedBox( + height: 8, + ), + Row(mainAxisAlignment: MainAxisAlignment.start, children: [ + Expanded( + child: AppText( + model.patientProgressNoteList[index].notes, + fontSize: 10, ), ), - Column( - children: [ - AppText( - model.patientProgressNoteList[index].createdOn != null - ? AppDateUtils.getDayMonthYearDateFormatted( - AppDateUtils.getDateTimeFromServerFormat( - model.patientProgressNoteList[index].createdOn ?? ""), - isArabic: projectViewModel!.isArabic) - : AppDateUtils.getDayMonthYearDateFormatted(DateTime.now(), - isArabic: projectViewModel!.isArabic), - fontWeight: FontWeight.w600, - fontSize: 14, - ), - AppText( - model.patientProgressNoteList[index].createdOn != null - ? AppDateUtils.getHour(AppDateUtils.getDateTimeFromServerFormat( - model.patientProgressNoteList[index].createdOn ?? "")) - : AppDateUtils.getHour(DateTime.now()), - fontWeight: FontWeight.w600, - fontSize: 14, - ), - ], - crossAxisAlignment: CrossAxisAlignment.end, - ) - ], - ), - SizedBox( - height: 8, - ), - Row(mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( - child: AppText( - model.patientProgressNoteList[index].notes, - fontSize: 10, - ), - ), - ]) - ], - ), - SizedBox( - height: 20, - ), - ], + ]) + ], + ), + SizedBox( + height: 20, + ), + ], + ), ), - ), - ); - }), + ); + }), + ), ), - ), ], ), ), diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index d83ea0ee..260baee4 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -84,7 +84,7 @@ postPrescription( postProcedureReqModel.prescriptionRequestModel = prescriptionList; await model!.postPrescription(postProcedureReqModel, patient.patientMRN!); - if (model.state == ViewState.ErrorLocal) { + if (model.state == ViewState.Error) { Helpers.showErrorToast(model.error); } else if (model.state == ViewState.Idle) { model.getPrescriptions(patient); @@ -112,6 +112,7 @@ class _PrescriptionFormWidgetState extends State { String? strengthError; late int selectedType; + bool isSubmitted = false; TextEditingController strengthController = TextEditingController(); TextEditingController indicationController = TextEditingController(); @@ -211,7 +212,6 @@ class _PrescriptionFormWidgetState extends State { @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) async { x = model.patientAssessmentList.map((element) { @@ -432,8 +432,11 @@ class _PrescriptionFormWidgetState extends State { width: 5.0, ), PrescriptionTextFiled( + isSubmitted: isSubmitted, width: MediaQuery.of(context).size.width * 0.560, - element: units, + element: model.itemMedicineListUnit.length == 1 + ? units = model.itemMedicineListUnit[0] + : units, elementError: unitError ?? "", keyName: 'description', keyId: 'parameterCode', @@ -451,8 +454,11 @@ class _PrescriptionFormWidgetState extends State { ), SizedBox(height: spaceBetweenTextFileds), PrescriptionTextFiled( + isSubmitted: isSubmitted, elementList: model.itemMedicineListRoute, - element: route, + element: model.itemMedicineListRoute.length == 1 + ? route = model.itemMedicineListRoute[0] + : route, elementError: routeError ?? "", keyId: 'parameterCode', keyName: 'description', @@ -466,9 +472,12 @@ class _PrescriptionFormWidgetState extends State { ), SizedBox(height: spaceBetweenTextFileds), PrescriptionTextFiled( + isSubmitted: isSubmitted, hintText: TranslationBase.of(context).frequency ?? "", elementError: frequencyError ?? "", - element: frequency, + element: model.itemMedicineList.length == 1 + ? frequency = model.itemMedicineList[0] + : frequency, elementList: model.itemMedicineList, keyId: 'parameterCode', keyName: 'description', @@ -492,6 +501,7 @@ class _PrescriptionFormWidgetState extends State { }), SizedBox(height: spaceBetweenTextFileds), PrescriptionTextFiled( + isSubmitted: isSubmitted, hintText: TranslationBase.of(context).doseTime ?? "", elementError: doseTimeError ?? "", element: doseTime, @@ -561,6 +571,7 @@ class _PrescriptionFormWidgetState extends State { ), SizedBox(height: spaceBetweenTextFileds), PrescriptionTextFiled( + isSubmitted: isSubmitted, element: duration, elementError: durationError ?? "", hintText: TranslationBase.of(context).duration ?? "", @@ -664,7 +675,7 @@ class _PrescriptionFormWidgetState extends State { if (_selectedMedication!.isNarcotic == true) { DrAppToastMsg.showErrorToast(TranslationBase.of(context) .narcoticMedicineCanOnlyBePrescribedFromVida); - Navigator.pop(context); + // Navigator.pop(context); return; } @@ -766,35 +777,36 @@ class _PrescriptionFormWidgetState extends State { } } else { setState(() { + isSubmitted = true; if (duration == null) { durationError = TranslationBase.of(context).fieldRequired; } else { - durationError = null; + durationError = ""; } if (doseTime == null) { doseTimeError = TranslationBase.of(context).fieldRequired; } else { - doseTimeError = null; + doseTimeError = ""; } if (route == null) { routeError = TranslationBase.of(context).fieldRequired; } else { - routeError = null; + routeError = ""; } if (frequency == null) { frequencyError = TranslationBase.of(context).fieldRequired; } else { - frequencyError = null; + frequencyError = ""; } if (units == null) { unitError = TranslationBase.of(context).fieldRequired; } else { - unitError = null; + unitError = ""; } if (strengthController.text == "") { strengthError = TranslationBase.of(context).fieldRequired; } else { - strengthError = null; + strengthError = ""; } }); } diff --git a/lib/screens/prescription/prescription_text_filed.dart b/lib/screens/prescription/prescription_text_filed.dart index 38b6f3c3..f9803789 100644 --- a/lib/screens/prescription/prescription_text_filed.dart +++ b/lib/screens/prescription/prescription_text_filed.dart @@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; class PrescriptionTextFiled extends StatefulWidget { dynamic element; final String elementError; + final bool? isSubmitted; final List elementList; final String keyName; final String keyId; @@ -25,7 +26,8 @@ class PrescriptionTextFiled extends StatefulWidget { required this.keyName, required this.keyId, required this.hintText, - required this.okFunction}) + required this.okFunction, + this.isSubmitted}) : super(key: key); @override @@ -65,7 +67,9 @@ class _PrescriptionTextFiledState extends State { ? widget.element['${widget.keyName}'] : null, isTextFieldHasSuffix: true, - validationError: widget.elementList.length != 1 ? widget.elementError : null, + validationError: widget.element == null && widget.isSubmitted == true && widget.elementList.length != 1 + ? widget.elementError + : null, enabled: false, ), ),