From 7684b65e8a0526a3fb88c45370bad700e353a414 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 21 Oct 2021 16:08:28 +0300 Subject: [PATCH 1/3] first step from update_operation_report.dart --- lib/config/config.dart | 6 +- .../service/operation_report_servive.dart | 12 ++ .../operation_report_view_model.dart | 21 ++- ...update_operation_report_request_model.dart | 108 +++++++++++++ .../update_operation_report.dart | 149 +++++++----------- 5 files changed, 201 insertions(+), 95 deletions(-) create mode 100644 lib/models/operation_report/create_update_operation_report_request_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 98a8abd8..a8ff066a 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 = @@ -347,6 +347,8 @@ const GET_EPISODE_FOR_INPATIENT = "/Services/DoctorApplication.svc/REST/DoctorApp_GetEpisodeForInpatient"; const GET_OPERATION_REPORT = "/Services/DoctorApplication.svc/REST/DoctorApp_GetReservationDetails"; +const UPDATE_OPERATION_REPORT = + "/Services/DoctorApplication.svc/REST/DoctorApp_CreateUpdateOperationReport"; var selectedPatientType = 1; diff --git a/lib/core/service/operation_report_servive.dart b/lib/core/service/operation_report_servive.dart index ea61c0fa..24d006ce 100644 --- a/lib/core/service/operation_report_servive.dart +++ b/lib/core/service/operation_report_servive.dart @@ -1,6 +1,18 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/operation_report/create_update_operation_report_request_model.dart'; import 'package:doctor_app_flutter/models/operation_report/get_operation_report_model.dart'; class OperationReportService extends BaseService { List get operationReportList => List(); + + Future updateOperationReport(CreateUpdateOperationReportRequestModel createUpdateOperationReport) async { + await baseAppClient.post(UPDATE_OPERATION_REPORT, + onSuccess: (dynamic response, int statusCode) { + + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: createUpdateOperationReport.toJson(),isFallLanguage: true); + } } diff --git a/lib/core/viewModel/operation_report_view_model.dart b/lib/core/viewModel/operation_report_view_model.dart index a2ab680c..edc6ba3e 100644 --- a/lib/core/viewModel/operation_report_view_model.dart +++ b/lib/core/viewModel/operation_report_view_model.dart @@ -1,3 +1,22 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/operation_report_servive.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/models/operation_report/create_update_operation_report_request_model.dart'; -class OperationReportViewModel extends BaseViewModel {} +import '../../locator.dart'; + +class OperationReportViewModel extends BaseViewModel { + OperationReportService _operationReportService = + locator(); + + Future updateOperationReport( + CreateUpdateOperationReportRequestModel + createUpdateOperationReport) async { + setState(ViewState.BusyLocal); + if (_operationReportService.hasError) { + error = _operationReportService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/models/operation_report/create_update_operation_report_request_model.dart b/lib/models/operation_report/create_update_operation_report_request_model.dart new file mode 100644 index 00000000..f6d72b1b --- /dev/null +++ b/lib/models/operation_report/create_update_operation_report_request_model.dart @@ -0,0 +1,108 @@ +class CreateUpdateOperationReportRequestModel { + String setupID; + int patientID; + int reservationNo; + int admissionNo; + String preOpDiagmosis; + String postOpDiagmosis; + String surgeon; + String assistant; + String anasthetist; + String operation; + String inasion; + String finding; + String surgeryProcedure; + String postOpInstruction; + int createdBy; + int editedBy; + String complicationDetails; + String bloodLossDetail; + String histopathSpecimen; + String microbiologySpecimen; + String otherSpecimen; + String scrubNurse; + String circulatingNurse; + String bloodTransfusedDetail; + + CreateUpdateOperationReportRequestModel( + {this.setupID, + this.patientID, + this.reservationNo, + this.admissionNo, + this.preOpDiagmosis, + this.postOpDiagmosis, + this.surgeon, + this.assistant, + this.anasthetist, + this.operation, + this.inasion, + this.finding, + this.surgeryProcedure, + this.postOpInstruction, + this.createdBy, + this.editedBy, + this.complicationDetails, + this.bloodLossDetail, + this.histopathSpecimen, + this.microbiologySpecimen, + this.otherSpecimen, + this.scrubNurse, + this.circulatingNurse, + this.bloodTransfusedDetail}); + + CreateUpdateOperationReportRequestModel.fromJson(Map json) { + setupID = json['SetupID']; + patientID = json['PatientID']; + reservationNo = json['reservationNo']; + admissionNo = json['AdmissionNo']; + preOpDiagmosis = json['preOpDiagmosis']; + postOpDiagmosis = json['postOpDiagmosis']; + surgeon = json['surgeon']; + assistant = json['assistant']; + anasthetist = json['anasthetist']; + operation = json['operation']; + inasion = json['inasion']; + finding = json['finding']; + surgeryProcedure = json['surgeryProcedure']; + postOpInstruction = json['postOpInstruction']; + createdBy = json['CreatedBy']; + editedBy = json['EditedBy']; + complicationDetails = json['complicationDetails']; + bloodLossDetail = json['bloodLossDetail']; + histopathSpecimen = json['histopathSpecimen']; + microbiologySpecimen = json['microbiologySpecimen']; + otherSpecimen = json['otherSpecimen']; + scrubNurse = json['scrubNurse']; + circulatingNurse = json['circulatingNurse']; + bloodTransfusedDetail = json['BloodTransfusedDetail']; + } + + Map toJson() { + final Map data = new Map(); + data['SetupID'] = this.setupID; + data['PatientID'] = this.patientID; + data['reservationNo'] = this.reservationNo; + data['AdmissionNo'] = this.admissionNo; + data['preOpDiagmosis'] = this.preOpDiagmosis; + data['postOpDiagmosis'] = this.postOpDiagmosis; + data['surgeon'] = this.surgeon; + data['assistant'] = this.assistant; + data['anasthetist'] = this.anasthetist; + data['operation'] = this.operation; + data['inasion'] = this.inasion; + data['finding'] = this.finding; + data['surgeryProcedure'] = this.surgeryProcedure; + data['postOpInstruction'] = this.postOpInstruction; + data['CreatedBy'] = this.createdBy; + data['EditedBy'] = this.editedBy; + data['complicationDetails'] = this.complicationDetails; + data['bloodLossDetail'] = this.bloodLossDetail; + data['histopathSpecimen'] = this.histopathSpecimen; + data['microbiologySpecimen'] = this.microbiologySpecimen; + data['otherSpecimen'] = this.otherSpecimen; + data['scrubNurse'] = this.scrubNurse; + data['circulatingNurse'] = this.circulatingNurse; + data['BloodTransfusedDetail'] = this.bloodTransfusedDetail; + return data; + } +} diff --git a/lib/screens/patients/profile/operation_report/update_operation_report.dart b/lib/screens/patients/profile/operation_report/update_operation_report.dart index 768aaabf..d364291e 100644 --- a/lib/screens/patients/profile/operation_report/update_operation_report.dart +++ b/lib/screens/patients/profile/operation_report/update_operation_report.dart @@ -6,10 +6,12 @@ import 'package:doctor_app_flutter/core/model/note/CreateNoteModel.dart'; import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; +import 'package:doctor_app_flutter/core/viewModel/operation_report_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/models/operation_report/create_update_operation_report_request_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; @@ -27,27 +29,27 @@ import 'package:provider/provider.dart'; import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; -class UpdateOperatiomReport extends StatefulWidget { +class UpdateOperationReport extends StatefulWidget { final NoteModel note; - final PatientViewModel patientModel; + final OperationReportViewModel operationReportViewModel; final PatiantInformtion patient; final int visitType; final bool isUpdate; - const UpdateOperatiomReport( + const UpdateOperationReport( {Key key, this.note, - this.patientModel, + this.operationReportViewModel, this.patient, this.visitType, this.isUpdate}) : super(key: key); @override - _UpdateOperatiomReportState createState() => _UpdateOperatiomReportState(); + _UpdateOperationReportState createState() => _UpdateOperationReportState(); } -class _UpdateOperatiomReportState extends State { +class _UpdateOperationReportState extends State { int selectedType; bool isSubmitted = false; stt.SpeechToText speech = stt.SpeechToText(); @@ -55,7 +57,25 @@ class _UpdateOperatiomReportState extends State { var event = RobotProvider(); ProjectViewModel projectViewModel; - TextEditingController progressNoteController = TextEditingController(); + TextEditingController preOpDiagmosisController = TextEditingController(); + TextEditingController postOpDiagmosisNoteController = TextEditingController(); + TextEditingController surgeonController = TextEditingController(); + TextEditingController assistantNoteController = TextEditingController(); + TextEditingController operationController = TextEditingController(); + TextEditingController inasionController = TextEditingController(); + TextEditingController findingController = TextEditingController(); + TextEditingController surgeryProcedureController = TextEditingController(); + TextEditingController postOpInstructionController = TextEditingController(); + TextEditingController complicationDetailsController = TextEditingController(); + TextEditingController bloodLossDetailController = TextEditingController(); + TextEditingController histopathSpecimenController = TextEditingController(); + TextEditingController microbiologySpecimenController = + TextEditingController(); + TextEditingController otherSpecimenController = TextEditingController(); + TextEditingController scrubNurseController = TextEditingController(); + TextEditingController circulatingNurseController = TextEditingController(); + TextEditingController BloodTransfusedDetailController = + TextEditingController(); setSelectedType(int val) { setState(() { @@ -81,7 +101,7 @@ class _UpdateOperatiomReportState extends State { projectViewModel = Provider.of(context); if (widget.note != null) { - progressNoteController.text = widget.note.notes; + preOpDiagmosisController.text = widget.note.notes; } return AppScaffold( @@ -96,15 +116,10 @@ class _UpdateOperatiomReportState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ BottomSheetTitle( - title: widget.visitType == 3 - ? (widget.isUpdate - ? TranslationBase.of(context).noteUpdate - : TranslationBase.of(context).noteAdd) + - TranslationBase.of(context).orderSheet - : (widget.isUpdate - ? TranslationBase.of(context).noteUpdate - : TranslationBase.of(context).noteAdd) + - TranslationBase.of(context).progressNote, + title: (widget.isUpdate + ? TranslationBase.of(context).noteUpdate + : TranslationBase.of(context).noteAdd) + + TranslationBase.of(context).progressNote, ), SizedBox( height: 10.0, @@ -131,14 +146,14 @@ class _UpdateOperatiomReportState extends State { .noteAdd) + TranslationBase.of(context).progressNote, //TranslationBase.of(context).addProgressNote, - controller: progressNoteController, + controller: preOpDiagmosisController, maxLines: 35, minLines: 25, hasBorder: true, // isTextFieldHasSuffix: true, validationError: - progressNoteController.text.isEmpty && + preOpDiagmosisController.text.isEmpty && isSubmitted ? TranslationBase.of(context).emptyMessage : null, @@ -173,34 +188,17 @@ class _UpdateOperatiomReportState extends State { ), ), bottomSheet: Container( - height: progressNoteController.text.isNotEmpty ? 130 : 70, + height: preOpDiagmosisController.text.isNotEmpty ? 130 : 70, margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Column( children: [ - if (progressNoteController.text.isNotEmpty) - Container( - margin: EdgeInsets.all(5), - child: AppButton( - title: TranslationBase.of(context).clearText, - onPressed: () { - setState(() { - progressNoteController.text = ''; - }); - }, - ), - ), Container( margin: EdgeInsets.all(5), child: AppButton( - title: widget.visitType == 3 - ? (widget.isUpdate - ? TranslationBase.of(context).noteUpdate - : TranslationBase.of(context).noteAdd) + - TranslationBase.of(context).orderSheet - : (widget.isUpdate - ? TranslationBase.of(context).noteUpdate - : TranslationBase.of(context).noteAdd) + - TranslationBase.of(context).progressNote, + title: (widget.isUpdate + ? TranslationBase.of(context).noteUpdate + : TranslationBase.of(context).noteAdd) + + TranslationBase.of(context).progressNote, color: Color(0xff359846), // disabled: progressNoteController.text.isEmpty, fontWeight: FontWeight.w700, @@ -208,64 +206,31 @@ class _UpdateOperatiomReportState extends State { setState(() { isSubmitted = true; }); - if (progressNoteController.text.trim().isNotEmpty) { GifLoaderDialogUtils.showMyDialog(context); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - - DoctorProfileModel doctorProfile = - DoctorProfileModel.fromJson(profile); - if (widget.isUpdate) { - UpdateNoteReqModel reqModel = UpdateNoteReqModel( - admissionNo: int.parse(widget.patient.admissionNo), - cancelledNote: false, - lineItemNo: widget.note.lineItemNo, - createdBy: widget.note.createdBy, - notes: progressNoteController.text, - verifiedNote: false, - patientTypeID: widget.patient.patientType, - patientOutSA: false, - ); - await widget.patientModel - .updatePatientProgressNote(reqModel); - } else { - CreateNoteModel reqModel = CreateNoteModel( - admissionNo: - int.parse(widget.patient.admissionNo), - createdBy: doctorProfile.doctorID, - visitType: widget.visitType, - patientID: widget.patient.patientId, - nursingRemarks: ' ', - patientTypeID: widget.patient.patientType, - patientOutSA: false, - notes: progressNoteController.text); - - await widget.patientModel - .createPatientProgressNote(reqModel); + CreateUpdateOperationReportRequestModel + createUpdateOperationReportRequestModel = + CreateUpdateOperationReportRequestModel(); + await widget.operationReportViewModel + .updateOperationReport(createUpdateOperationReportRequestModel); } - if (widget.patientModel.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(widget.patientModel.error); + if (widget.operationReportViewModel.state == + ViewState.ErrorLocal) { + Helpers.showErrorToast( + widget.operationReportViewModel.error); } else { - ProgressNoteRequest progressNoteRequest = - ProgressNoteRequest( - visitType: widget.visitType, - // if equal 5 then this will return progress note - admissionNo: - int.parse(widget.patient.admissionNo), - projectID: widget.patient.projectId, - patientTypeID: widget.patient.patientType, - languageID: 2); - await widget.patientModel.getPatientProgressNote( - progressNoteRequest.toJson()); + // await widget.operationReportViewModel.( + // progressNoteRequest.toJson()); + + DrAppToastMsg.showSuccesToast( + "Your Order added Successfully"); + Navigator.of(context).pop(); } GifLoaderDialogUtils.hideDialog(context); - DrAppToastMsg.showSuccesToast( - "Your Order added Successfully"); - Navigator.of(context).pop(); - } else { - Helpers.showErrorToast("You cant add only spaces"); - } + + })), ], ), @@ -313,7 +278,7 @@ class _UpdateOperatiomReportState extends State { setState(() { SpeechToText.closeAlertDialog(context); speech.stop(); - progressNoteController.text += reconizedWord + '\n'; + preOpDiagmosisController.text += reconizedWord + '\n'; }); } else { print(result.finalResult); From fbf1cd29ee5fd5ea4fd5e67134e584bff5435c79 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 21 Oct 2021 16:21:47 +0300 Subject: [PATCH 2/3] add some fiels --- .../update_operation_report.dart | 128 +++++++++++------- 1 file changed, 80 insertions(+), 48 deletions(-) diff --git a/lib/screens/patients/profile/operation_report/update_operation_report.dart b/lib/screens/patients/profile/operation_report/update_operation_report.dart index d364291e..7b5ada79 100644 --- a/lib/screens/patients/profile/operation_report/update_operation_report.dart +++ b/lib/screens/patients/profile/operation_report/update_operation_report.dart @@ -76,6 +76,8 @@ class _UpdateOperationReportState extends State { TextEditingController circulatingNurseController = TextEditingController(); TextEditingController BloodTransfusedDetailController = TextEditingController(); + TextEditingController anasthetistController = + TextEditingController(); setSelectedType(int val) { setState(() { @@ -129,55 +131,66 @@ class _UpdateOperationReportState extends State { widthFactor: 0.9, child: Column( children: [ - Stack( - children: [ - AppTextFieldCustom( - hintText: widget.visitType == 3 - ? (widget.isUpdate - ? TranslationBase.of(context) - .noteUpdate - : TranslationBase.of(context) - .noteAdd) + - TranslationBase.of(context).orderSheet - : (widget.isUpdate - ? TranslationBase.of(context) - .noteUpdate - : TranslationBase.of(context) - .noteAdd) + - TranslationBase.of(context).progressNote, - //TranslationBase.of(context).addProgressNote, - controller: preOpDiagmosisController, - maxLines: 35, - minLines: 25, - hasBorder: true, + AppTextFieldCustom( + hintText: widget.visitType == 3 + ? (widget.isUpdate + ? TranslationBase.of(context) + .noteUpdate + : TranslationBase.of(context) + .noteAdd) + + TranslationBase.of(context).orderSheet + : (widget.isUpdate + ? TranslationBase.of(context) + .noteUpdate + : TranslationBase.of(context) + .noteAdd) + + TranslationBase.of(context).progressNote, + //TranslationBase.of(context).addProgressNote, + controller: preOpDiagmosisController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + preOpDiagmosisController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox(height: 4,), + AppTextFieldCustom( + hintText: "Post Op Diagmosis", + //TranslationBase.of(context).addProgressNote, + controller: postOpDiagmosisNoteController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + postOpDiagmosisNoteController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox(height: 4,), + AppTextFieldCustom( + hintText: "Post Op Diagmosis", + //TranslationBase.of(context).addProgressNote, + controller: postOpDiagmosisNoteController, + maxLines: 1, + minLines: 1, + hasBorder: true, - // isTextFieldHasSuffix: true, - validationError: - preOpDiagmosisController.text.isEmpty && - isSubmitted - ? TranslationBase.of(context).emptyMessage - : null, - ), - Positioned( - top: - -2, //MediaQuery.of(context).size.height * 0, - right: projectViewModel.isArabic - ? MediaQuery.of(context).size.width * 0.75 - : 15, - child: Column( - children: [ - IconButton( - icon: Icon(DoctorApp.speechtotext, - color: Colors.black, size: 35), - onPressed: () { - initSpeechState() - .then((value) => {onVoiceText()}); - }, - ), - ], - )) - ], + // isTextFieldHasSuffix: true, + validationError: + postOpDiagmosisNoteController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, ), + SizedBox(height: 4,), ], ), ), @@ -211,7 +224,26 @@ class _UpdateOperationReportState extends State { if (widget.isUpdate) { CreateUpdateOperationReportRequestModel createUpdateOperationReportRequestModel = - CreateUpdateOperationReportRequestModel(); + CreateUpdateOperationReportRequestModel( + inasion: inasionController.text, + preOpDiagmosis: preOpDiagmosisController.text, + postOpDiagmosis: postOpDiagmosisNoteController.text, + surgeon: surgeonController.text, + assistant: assistantNoteController.text, + anasthetist:assistantNoteController.text, + operation: operationController.text, + finding: findingController.text, + surgeryProcedure: surgeonController.text, + postOpInstruction: postOpInstructionController.text, + complicationDetails: complicationDetailsController.text, + bloodLossDetail: bloodLossDetailController.text, + histopathSpecimen: histopathSpecimenController.text, + microbiologySpecimen: microbiologySpecimenController.text, + otherSpecimen: otherSpecimenController.text, + scrubNurse: surgeonController.text, + circulatingNurse: circulatingNurseController.text, + bloodTransfusedDetail: bloodLossDetailController.text + ); await widget.operationReportViewModel .updateOperationReport(createUpdateOperationReportRequestModel); } From a44a2071168fb3b67518979a71c1a6c0ba696d96 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 24 Oct 2021 11:36:25 +0300 Subject: [PATCH 3/3] finish the operation Reports from our side --- lib/config/config.dart | 2 +- lib/config/localized_values.dart | 3 +- .../operation_report_view_model.dart | 2 + .../operation_report/operation_report.dart | 114 +--- .../update_operation_report.dart | 646 ++++++++++++------ lib/util/translations_delegate_base.dart | 1 + 6 files changed, 463 insertions(+), 305 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index a8ff066a..6332520f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -348,7 +348,7 @@ const GET_EPISODE_FOR_INPATIENT = const GET_OPERATION_REPORT = "/Services/DoctorApplication.svc/REST/DoctorApp_GetReservationDetails"; const UPDATE_OPERATION_REPORT = - "/Services/DoctorApplication.svc/REST/DoctorApp_CreateUpdateOperationReport"; + "Services/DoctorApplication.svc/REST/DoctorApp_CreateUpdateOperationReport"; var selectedPatientType = 1; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 9b91015f..b711124f 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -709,5 +709,6 @@ const Map> localizedValues = { "en":"Request Type", "ar":"نوع الطلب"}, "special": {"en": "Special", "ar": "خاص"}, - "allClinic": {"en": "All Clinics", "ar": "جميع العيادات"} + "allClinic": {"en": "All Clinics", "ar": "جميع العيادات"} , + "operationReports": {"en": "Operation Reports", "ar": "تقارير العملية"} }; diff --git a/lib/core/viewModel/operation_report_view_model.dart b/lib/core/viewModel/operation_report_view_model.dart index 6e472125..dc5d80d7 100644 --- a/lib/core/viewModel/operation_report_view_model.dart +++ b/lib/core/viewModel/operation_report_view_model.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/operation_report_servive.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; +import 'package:doctor_app_flutter/models/operation_report/create_update_operation_report_request_model.dart'; class OperationReportViewModel extends BaseViewModel { bool hasError = false; @@ -28,6 +29,7 @@ class OperationReportViewModel extends BaseViewModel { CreateUpdateOperationReportRequestModel createUpdateOperationReport) async { setState(ViewState.BusyLocal); + await _operationReportService.updateOperationReport(createUpdateOperationReport); if (_operationReportService.hasError) { error = _operationReportService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/patients/profile/operation_report/operation_report.dart b/lib/screens/patients/profile/operation_report/operation_report.dart index 427c6f7e..2caaf964 100644 --- a/lib/screens/patients/profile/operation_report/operation_report.dart +++ b/lib/screens/patients/profile/operation_report/operation_report.dart @@ -90,15 +90,11 @@ class _ProgressNoteState extends State { patient, isInpatient: true, ), - body: model.operationReportList == null || - model.operationReportList.length == 0 - ? DrAppEmbeddedError( - error: TranslationBase.of(context).errorNoProgressNote) - : Container( + body: + Container( color: Colors.grey[200], child: Column( children: [ - if (!isDischargedPatient) AddNewOrder( onTap: () async { await locator().logEvent( @@ -108,8 +104,8 @@ class _ProgressNoteState extends State { Navigator.push( context, MaterialPageRoute( - builder: (context) => UpdateOperatiomReport( - patientModel: model, + builder: (context) => UpdateOperationReport( + operationReportViewModel: model, patient: patient, visitType: widget.visitType, isUpdate: false, @@ -118,11 +114,12 @@ class _ProgressNoteState extends State { ), ); }, - label: widget.visitType == 3 - ? TranslationBase.of(context).addNewOrderSheet - : TranslationBase.of(context).addProgressNote, + label: TranslationBase.of(context).operationReports, ), - Expanded( + model.operationReportList == null || + model.operationReportList.length == 0 + ? DrAppEmbeddedError( + error: TranslationBase.of(context).errorNoProgressNote):Expanded( child: Container( child: ListView.builder( itemCount: model.operationReportList.length, @@ -558,97 +555,4 @@ class _ProgressNoteState extends State { ), ); } - - showMyDialog({BuildContext context, Function confirmFun, String actionName}) { - showDialog( - context: context, - builder: (ctx) => Center( - child: Container( - width: MediaQuery.of(context).size.width * 0.8, - height: 200, - child: AppScaffold( - isShowAppBar: false, - body: Container( - color: Colors.white, - child: Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - // SizedBox(height: 20,), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - TranslationBase.of(context).noteConfirm, - fontWeight: FontWeight.w600, - color: Colors.black, - fontSize: 16, - ), - ], - ), - SizedBox( - height: 10, - ), - DividerWithSpacesAround(), - SizedBox( - height: 12, - ), - - Container( - padding: EdgeInsets.all(20), - color: Colors.white, - child: AppText( - projectViewModel.isArabic - ? "هل أنت متأكد أنك تريد تنفيذ $actionName هذا الأمر؟" - : 'Are you sure you want $actionName this order?', - fontSize: 15, - textAlign: TextAlign.center, - ), - ), - - SizedBox( - height: 8, - ), - DividerWithSpacesAround(), - FractionallySizedBox( - widthFactor: 0.75, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - FlatButton( - child: AppText( - TranslationBase.of(context).cancel, - fontWeight: FontWeight.w600, - color: Colors.black, - fontSize: 16, - ), //Text("Cancel"), - onPressed: () { - Navigator.of(context).pop(); - }), - FlatButton( - child: AppText( - TranslationBase.of(context).noteConfirm, - fontWeight: FontWeight.w600, - color: Colors.red.shade700, - fontSize: 16, - ), //Text("Confirm", ), - onPressed: () async { - await confirmFun(); - Navigator.of(context).pop(); - }) - ], - ), - ) - ], - ), - ), - ), - ), - ), - )); - } } diff --git a/lib/screens/patients/profile/operation_report/update_operation_report.dart b/lib/screens/patients/profile/operation_report/update_operation_report.dart index 7b5ada79..dc64acb5 100644 --- a/lib/screens/patients/profile/operation_report/update_operation_report.dart +++ b/lib/screens/patients/profile/operation_report/update_operation_report.dart @@ -76,8 +76,7 @@ class _UpdateOperationReportState extends State { TextEditingController circulatingNurseController = TextEditingController(); TextEditingController BloodTransfusedDetailController = TextEditingController(); - TextEditingController anasthetistController = - TextEditingController(); + TextEditingController anasthetistController = TextEditingController(); setSelectedType(int val) { setState(() { @@ -87,240 +86,491 @@ class _UpdateOperationReportState extends State { @override void initState() { - requestPermissions(); - event.controller.stream.listen((p) { - if (p['startPopUp'] == 'true') { - if (this.mounted) { - initSpeechState().then((value) => {onVoiceText()}); - } - } - }); super.initState(); } @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); - - if (widget.note != null) { - preOpDiagmosisController.text = widget.note.notes; - } - + //TODO Elham* add translation to hints return AppScaffold( - isShowAppBar: false, + isShowAppBar: true, backgroundColor: Theme.of(context).scaffoldBackgroundColor, + appBar: BottomSheetTitle( + title: (widget.isUpdate + ? TranslationBase.of(context).noteUpdate + : TranslationBase.of(context).noteAdd) + + TranslationBase.of(context).operationReports, + ), body: SingleChildScrollView( child: Container( height: MediaQuery.of(context).size.height * 1.0, child: Padding( padding: EdgeInsets.all(0.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - BottomSheetTitle( - title: (widget.isUpdate - ? TranslationBase.of(context).noteUpdate - : TranslationBase.of(context).noteAdd) + - TranslationBase.of(context).progressNote, - ), - SizedBox( - height: 10.0, - ), - Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Column( - children: [ - AppTextFieldCustom( - hintText: widget.visitType == 3 - ? (widget.isUpdate - ? TranslationBase.of(context) - .noteUpdate - : TranslationBase.of(context) - .noteAdd) + - TranslationBase.of(context).orderSheet - : (widget.isUpdate - ? TranslationBase.of(context) - .noteUpdate - : TranslationBase.of(context) - .noteAdd) + - TranslationBase.of(context).progressNote, - //TranslationBase.of(context).addProgressNote, - controller: preOpDiagmosisController, - maxLines: 1, - minLines: 1, - hasBorder: true, + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10.0, + ), + SingleChildScrollView( + child: Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + children: [ + AppTextFieldCustom( + hintText: "Pre Op Diagmosis", + //TranslationBase.of(context).addoperationReports, + controller: preOpDiagmosisController, + maxLines: 1, + minLines: 1, + hasBorder: true, - // isTextFieldHasSuffix: true, - validationError: - preOpDiagmosisController.text.isEmpty && - isSubmitted - ? TranslationBase.of(context).emptyMessage - : null, - ), - SizedBox(height: 4,), - AppTextFieldCustom( - hintText: "Post Op Diagmosis", - //TranslationBase.of(context).addProgressNote, - controller: postOpDiagmosisNoteController, - maxLines: 1, - minLines: 1, - hasBorder: true, + // isTextFieldHasSuffix: true, + validationError: + preOpDiagmosisController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Post Op Diagmosis", + //TranslationBase.of(context).addoperationReports, + controller: postOpDiagmosisNoteController, + maxLines: 1, + minLines: 1, + hasBorder: true, - // isTextFieldHasSuffix: true, - validationError: - postOpDiagmosisNoteController.text.isEmpty && - isSubmitted - ? TranslationBase.of(context).emptyMessage - : null, - ), - SizedBox(height: 4,), - AppTextFieldCustom( - hintText: "Post Op Diagmosis", - //TranslationBase.of(context).addProgressNote, - controller: postOpDiagmosisNoteController, - maxLines: 1, - minLines: 1, - hasBorder: true, + // isTextFieldHasSuffix: true, + validationError: + postOpDiagmosisNoteController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Surgeon", + //TranslationBase.of(context).addoperationReports, + controller: surgeonController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + surgeonController.text.isEmpty && isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "assistant", + //TranslationBase.of(context).addoperationReports, + controller: assistantNoteController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + assistantNoteController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Operation", + //TranslationBase.of(context).addoperationReports, + controller: operationController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + operationController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "inasion", + //TranslationBase.of(context).addoperationReports, + controller: inasionController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + inasionController.text.isEmpty && isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "finding", + //TranslationBase.of(context).addoperationReports, + controller: findingController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + findingController.text.isEmpty && isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Surgery Procedure", + //TranslationBase.of(context).addoperationReports, + controller: surgeryProcedureController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + surgeryProcedureController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Post Op Instruction", + //TranslationBase.of(context).addoperationReports, + controller: postOpInstructionController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + postOpInstructionController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Complication Details", + //TranslationBase.of(context).addoperationReports, + controller: complicationDetailsController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + complicationDetailsController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Blood Loss Detail", + //TranslationBase.of(context).addoperationReports, + controller: bloodLossDetailController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + bloodLossDetailController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "histopal the Specimen", + //TranslationBase.of(context).addoperationReports, + controller: histopathSpecimenController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + histopathSpecimenController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "microbiology Specimen ", + //TranslationBase.of(context).addoperationReports, + controller: microbiologySpecimenController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + microbiologySpecimenController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "other Specimen", + //TranslationBase.of(context).addoperationReports, + controller: otherSpecimenController, + maxLines: 1, + minLines: 1, + hasBorder: true, - // isTextFieldHasSuffix: true, - validationError: - postOpDiagmosisNoteController.text.isEmpty && - isSubmitted - ? TranslationBase.of(context).emptyMessage - : null, + // isTextFieldHasSuffix: true, + validationError: + otherSpecimenController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "scrub Nurse", + //TranslationBase.of(context).addoperationReports, + controller: scrubNurseController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + scrubNurseController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "circulating Nurse", + //TranslationBase.of(context).addoperationReports, + controller: circulatingNurseController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + circulatingNurseController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Blood Transfused Detail", + //TranslationBase.of(context).addoperationReports, + controller: BloodTransfusedDetailController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: BloodTransfusedDetailController + .text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 4, + ), + AppTextFieldCustom( + hintText: "Anasthetist", + //TranslationBase.of(context).addoperationReports, + controller: anasthetistController, + maxLines: 1, + minLines: 1, + hasBorder: true, + + // isTextFieldHasSuffix: true, + validationError: + anasthetistController.text.isEmpty && + isSubmitted + ? TranslationBase.of(context).emptyMessage + : null, + ), + SizedBox( + height: 250, + ), + ], ), - SizedBox(height: 4,), - ], + ), ), ), - ), - ], + ], + ), ), ), ), ), bottomSheet: Container( - height: preOpDiagmosisController.text.isNotEmpty ? 130 : 70, + height: 70, margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), child: Column( children: [ Container( - margin: EdgeInsets.all(5), - child: AppButton( - title: (widget.isUpdate - ? TranslationBase.of(context).noteUpdate - : TranslationBase.of(context).noteAdd) + - TranslationBase.of(context).progressNote, - color: Color(0xff359846), - // disabled: progressNoteController.text.isEmpty, - fontWeight: FontWeight.w700, - onPressed: () async { - setState(() { - isSubmitted = true; - }); - GifLoaderDialogUtils.showMyDialog(context); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - if (widget.isUpdate) { - CreateUpdateOperationReportRequestModel - createUpdateOperationReportRequestModel = - CreateUpdateOperationReportRequestModel( - inasion: inasionController.text, - preOpDiagmosis: preOpDiagmosisController.text, - postOpDiagmosis: postOpDiagmosisNoteController.text, - surgeon: surgeonController.text, - assistant: assistantNoteController.text, - anasthetist:assistantNoteController.text, - operation: operationController.text, - finding: findingController.text, - surgeryProcedure: surgeonController.text, - postOpInstruction: postOpInstructionController.text, - complicationDetails: complicationDetailsController.text, - bloodLossDetail: bloodLossDetailController.text, - histopathSpecimen: histopathSpecimenController.text, - microbiologySpecimen: microbiologySpecimenController.text, - otherSpecimen: otherSpecimenController.text, - scrubNurse: surgeonController.text, - circulatingNurse: circulatingNurseController.text, - bloodTransfusedDetail: bloodLossDetailController.text - ); - await widget.operationReportViewModel - .updateOperationReport(createUpdateOperationReportRequestModel); - } - - if (widget.operationReportViewModel.state == - ViewState.ErrorLocal) { - Helpers.showErrorToast( - widget.operationReportViewModel.error); - } else { - // await widget.operationReportViewModel.( - // progressNoteRequest.toJson()); + margin: EdgeInsets.all(5), + child: AppButton( + title: (widget.isUpdate + ? TranslationBase.of(context).noteUpdate + : TranslationBase.of(context).noteAdd) + + TranslationBase.of(context).operationReports, + color: Color(0xff359846), + // disabled: operationReportsController.text.isEmpty, + fontWeight: FontWeight.w700, + onPressed: () async { + setState(() { + isSubmitted = true; + }); + if (isFormValid()) { + GifLoaderDialogUtils.showMyDialog(context); + await widget.operationReportViewModel.getDoctorProfile(); - DrAppToastMsg.showSuccesToast( - "Your Order added Successfully"); - Navigator.of(context).pop(); - } - GifLoaderDialogUtils.hideDialog(context); + CreateUpdateOperationReportRequestModel + createUpdateOperationReportRequestModel = + CreateUpdateOperationReportRequestModel( + inasion: inasionController.text, + /// TODO Elham* Add dynamic reservation + reservationNo: 0, + preOpDiagmosis: preOpDiagmosisController.text, + postOpDiagmosis: postOpDiagmosisNoteController.text, + surgeon: surgeonController.text, + assistant: assistantNoteController.text, + anasthetist: assistantNoteController.text, + operation: operationController.text, + finding: findingController.text, + surgeryProcedure: surgeonController.text, + postOpInstruction: postOpInstructionController.text, + complicationDetails: + complicationDetailsController.text, + bloodLossDetail: bloodLossDetailController.text, + histopathSpecimen: histopathSpecimenController.text, + microbiologySpecimen: + microbiologySpecimenController.text, + otherSpecimen: otherSpecimenController.text, + scrubNurse: surgeonController.text, + circulatingNurse: circulatingNurseController.text, + bloodTransfusedDetail: + bloodLossDetailController.text, + patientID: widget.patient.patientId, + admissionNo: int.parse(widget.patient.admissionNo), + createdBy: widget.operationReportViewModel.doctorProfile.doctorID, + setupID: SETUP_ID); + await widget.operationReportViewModel.updateOperationReport( + createUpdateOperationReportRequestModel); + if (widget.operationReportViewModel.state == + ViewState.ErrorLocal) { + Helpers.showErrorToast( + widget.operationReportViewModel.error); + } else { + // await widget.operationReportViewModel.( + // operationReportsRequest.toJson()); - })), + DrAppToastMsg.showSuccesToast( + "Your Order added Successfully"); + Navigator.of(context).pop(); + } + GifLoaderDialogUtils.hideDialog(context); + } + }, + ), + ), ], ), ), ); } - onVoiceText() async { - new SpeechToText(context: context).showAlertDialog(context); - var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speech.initialize( - onStatus: statusListener, onError: errorListener); - if (available) { - speech.listen( - onResult: resultListener, - listenMode: stt.ListenMode.confirmation, - localeId: lang == 'en' ? 'en-US' : 'ar-SA', - ); + isFormValid() { + if (preOpDiagmosisController.text != null && + preOpDiagmosisController.text.isNotEmpty && + postOpDiagmosisNoteController.text != null && + postOpDiagmosisNoteController.text.isNotEmpty && + surgeonController.text != null && + surgeonController.text.isNotEmpty && + assistantNoteController.text != null && + assistantNoteController.text.isNotEmpty && + operationController.text != null && + operationController.text.isNotEmpty && + inasionController.text != null && + inasionController.text.isNotEmpty && + findingController.text != null && + findingController.text.isNotEmpty && + surgeryProcedureController.text != null && + surgeryProcedureController.text.isNotEmpty && + postOpInstructionController.text != null && + postOpInstructionController.text.isNotEmpty && + complicationDetailsController.text != null && + complicationDetailsController.text.isNotEmpty && + bloodLossDetailController.text != null && + bloodLossDetailController.text.isNotEmpty && + histopathSpecimenController.text != null && + histopathSpecimenController.text.isNotEmpty && + microbiologySpecimenController.text != null && + microbiologySpecimenController.text.isNotEmpty && + otherSpecimenController.text != null && + otherSpecimenController.text.isNotEmpty && + scrubNurseController.text != null && + scrubNurseController.text.isNotEmpty && + circulatingNurseController.text != null && + circulatingNurseController.text.isNotEmpty && + BloodTransfusedDetailController.text != null && + BloodTransfusedDetailController.text.isNotEmpty && + anasthetistController.text != null && + anasthetistController.text.isNotEmpty) { + return true; } else { - print("The user has denied the use of speech recognition."); + return false; } } - - void errorListener(SpeechRecognitionError error) { - event.setValue({"searchText": 'null'}); - //SpeechToText.closeAlertDialog(context); - print(error); - } - - void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; - } - - void requestPermissions() async { - Map statuses = await [ - Permission.microphone, - ].request(); - } - - void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); - - if (result.finalResult == true) { - setState(() { - SpeechToText.closeAlertDialog(context); - speech.stop(); - preOpDiagmosisController.text += reconizedWord + '\n'; - }); - } else { - print(result.finalResult); - } - } - - Future initSpeechState() async { - bool hasSpeech = await speech.initialize( - onError: errorListener, onStatus: statusListener); - print(hasSpeech); - if (!mounted) return; - } } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 0297aa45..59f66811 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -212,6 +212,7 @@ class TranslationBase { String get replay => localizedValues['replay'][locale.languageCode]; String get progressNote => localizedValues['progressNote'][locale.languageCode]; + String get operationReports => localizedValues['operationReports'][locale.languageCode]; String get progress => localizedValues['progress'][locale.languageCode];