diff --git a/lib/config/config.dart b/lib/config/config.dart index 36be5e92..8caead72 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 = @@ -345,8 +345,14 @@ const GET_MEDICATION_FOR_IN_PATIENT = "Services/DoctorApplication.svc/REST/Doctor_GetMedicationForInpatient"; const GET_EPISODE_FOR_INPATIENT = "/Services/DoctorApplication.svc/REST/DoctorApp_GetEpisodeForInpatient"; -const GET_OPERATION_REPORT = + + +///Operation Details Services + +const GET_RESERVATIONS = "Services/DoctorApplication.svc/REST/DoctorApp_GetReservationDetails"; +const GET_OPERATION_DETAILS = + "Services/DoctorApplication.svc/REST/DoctorApp_GetOperationDetails"; const UPDATE_OPERATION_REPORT = "Services/DoctorApplication.svc/REST/DoctorApp_CreateUpdateOperationReport"; diff --git a/lib/core/service/operation_report_servive.dart b/lib/core/service/operation_report_servive.dart index 16a6ccec..91f4f15c 100644 --- a/lib/core/service/operation_report_servive.dart +++ b/lib/core/service/operation_report_servive.dart @@ -1,28 +1,53 @@ 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'; -import 'package:doctor_app_flutter/models/operation_report/get_operation_report_request_model.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_operation_details_request_modle.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_operation_details_response_modle.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_reservations_response_model.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_reservations_request_model.dart'; class OperationReportService extends BaseService { - List _operationReportList = []; - List get operationReportList => _operationReportList; + List _reservationList = []; + List get reservationList => _reservationList; - Future getOperationReport( - {GetOperationReportRequestModel getOperationReportRequestModel, + List _operationDetailsList = []; + List get operationDetailsList => _operationDetailsList; + + Future getReservations( + {GetReservationsRequestModel getReservationsRequestModel, int patientId}) async { - getOperationReportRequestModel = - GetOperationReportRequestModel(patientID: patientId, doctorID: ""); + getReservationsRequestModel = + GetReservationsRequestModel(patientID: patientId, doctorID: ""); hasError = false; - await baseAppClient.post(GET_OPERATION_REPORT, + await baseAppClient.post(GET_RESERVATIONS, onSuccess: (dynamic response, int statusCode) { print("Success"); - _operationReportList.clear(); + _reservationList.clear(); response['List_OTReservationDetails'].forEach( (v) { - _operationReportList.add(GetOperationReportModel.fromJson(v)); + _reservationList.add(GetReservationsResponseModel.fromJson(v)); + }, + ); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: getReservationsRequestModel.toJson()); + } + + Future getOperationReportDetails( + {GetOperationDetailsRequestModel getOperationReportRequestModel, + }) async { + + hasError = false; + await baseAppClient.post(GET_OPERATION_DETAILS, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + _operationDetailsList.clear(); + response['List_OperationDetails'].forEach( + (v) { + _operationDetailsList.add(GetOperationDetailsResponseModel.fromJson(v)); }, ); }, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModel/base_view_model.dart b/lib/core/viewModel/base_view_model.dart index 03f6e84a..d50a8d5a 100644 --- a/lib/core/viewModel/base_view_model.dart +++ b/lib/core/viewModel/base_view_model.dart @@ -22,7 +22,7 @@ class BaseViewModel extends ChangeNotifier { void setState(ViewState viewState) { _state = viewState; - notifyListeners(); + notifyListeners(); } Future getDoctorProfile({bool isGetProfile = false}) async { diff --git a/lib/core/viewModel/operation_report_view_model.dart b/lib/core/viewModel/operation_report_view_model.dart index 77867d95..2bfdebce 100644 --- a/lib/core/viewModel/operation_report_view_model.dart +++ b/lib/core/viewModel/operation_report_view_model.dart @@ -3,20 +3,38 @@ 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'; -import 'package:doctor_app_flutter/models/operation_report/get_operation_report_model.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_operation_details_request_modle.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_operation_details_response_modle.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_reservations_response_model.dart'; class OperationReportViewModel extends BaseViewModel { bool hasError = false; OperationReportService _operationReportService = locator(); - List get operationReportList => - _operationReportService.operationReportList; + List get reservationList => + _operationReportService.reservationList; - Future getOperationReport(int patientId) async { + List get operationDetailsList => + _operationReportService.operationDetailsList; + + Future getReservations(int patientId) async { + hasError = false; + setState(ViewState.Busy); + await _operationReportService.getReservations(patientId: patientId); + if (_operationReportService.hasError) { + error = _operationReportService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + + Future getOperationReportDetails(GetReservationsResponseModel reservation) async { hasError = false; setState(ViewState.Busy); - await _operationReportService.getOperationReport(patientId: patientId); + GetOperationDetailsRequestModel getOperationReportRequestModel = GetOperationDetailsRequestModel(reservationNo:reservation.oTReservationID, patientID: reservation.patientID, setupID: "010266" ); + await _operationReportService.getOperationReportDetails(getOperationReportRequestModel:getOperationReportRequestModel); if (_operationReportService.hasError) { error = _operationReportService.error; setState(ViewState.ErrorLocal); diff --git a/lib/models/operation_report/get_operation_details_request_modle.dart b/lib/models/operation_report/get_operation_details_request_modle.dart new file mode 100644 index 00000000..7e23b503 --- /dev/null +++ b/lib/models/operation_report/get_operation_details_request_modle.dart @@ -0,0 +1,68 @@ +class GetOperationDetailsRequestModel { + bool isDentalAllowedBackend; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int deviceTypeID; + String tokenID; + int patientID; + int reservationNo; + String sessionID; + int projectID; + String setupID; + bool patientOutSA; + + GetOperationDetailsRequestModel( + {this.isDentalAllowedBackend = false, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.deviceTypeID, + this.tokenID, + this.patientID, + this.reservationNo, + this.sessionID, + this.projectID, + this.setupID, + this.patientOutSA}); + + GetOperationDetailsRequestModel.fromJson(Map json) { + isDentalAllowedBackend = json['isDentalAllowedBackend']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + deviceTypeID = json['DeviceTypeID']; + tokenID = json['TokenID']; + patientID = json['PatientID']; + reservationNo = json['reservationNo']; + sessionID = json['SessionID']; + projectID = json['ProjectID']; + setupID = json['SetupID']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['DeviceTypeID'] = this.deviceTypeID; + data['TokenID'] = this.tokenID; + data['PatientID'] = this.patientID; + data['reservationNo'] = this.reservationNo; + data['SessionID'] = this.sessionID; + data['ProjectID'] = this.projectID; + data['SetupID'] = this.setupID; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/models/operation_report/get_operation_details_response_modle.dart b/lib/models/operation_report/get_operation_details_response_modle.dart new file mode 100644 index 00000000..689f0ec1 --- /dev/null +++ b/lib/models/operation_report/get_operation_details_response_modle.dart @@ -0,0 +1,148 @@ +class GetOperationDetailsResponseModel { + String setupID; + int projectID; + int reservationNo; + int patientID; + int admissionID; + Null surgeryDate; + String preOpDiagnosis; + String postOpDiagnosis; + String surgeon; + String assistant; + String anasthetist; + String operation; + String inasion; + String finding; + String surgeryProcedure; + String postOpInstruction; + bool isActive; + int createdBy; + String createdName; + Null createdNameN; + String createdOn; + Null editedBy; + Null editedByName; + Null editedByNameN; + Null editedOn; + Null oRBookStatus; + String complicationDetail; + String bloodLossDetail; + String histopathSpecimen; + String microbiologySpecimen; + String otherSpecimen; + Null scrubNurse; + Null circulatingNurse; + Null bloodTransfusedDetail; + + GetOperationDetailsResponseModel( + {this.setupID, + this.projectID, + this.reservationNo, + this.patientID, + this.admissionID, + this.surgeryDate, + this.preOpDiagnosis, + this.postOpDiagnosis, + this.surgeon, + this.assistant, + this.anasthetist, + this.operation, + this.inasion, + this.finding, + this.surgeryProcedure, + this.postOpInstruction, + this.isActive, + this.createdBy, + this.createdName, + this.createdNameN, + this.createdOn, + this.editedBy, + this.editedByName, + this.editedByNameN, + this.editedOn, + this.oRBookStatus, + this.complicationDetail, + this.bloodLossDetail, + this.histopathSpecimen, + this.microbiologySpecimen, + this.otherSpecimen, + this.scrubNurse, + this.circulatingNurse, + this.bloodTransfusedDetail}); + + GetOperationDetailsResponseModel.fromJson(Map json) { + setupID = json['SetupID']; + projectID = json['ProjectID']; + reservationNo = json['ReservationNo']; + patientID = json['PatientID']; + admissionID = json['AdmissionID']; + surgeryDate = json['SurgeryDate']; + preOpDiagnosis = json['PreOpDiagnosis']; + postOpDiagnosis = json['PostOpDiagnosis']; + surgeon = json['Surgeon']; + assistant = json['Assistant']; + anasthetist = json['Anasthetist']; + operation = json['Operation']; + inasion = json['Inasion']; + finding = json['Finding']; + surgeryProcedure = json['SurgeryProcedure']; + postOpInstruction = json['PostOpInstruction']; + isActive = json['IsActive']; + createdBy = json['CreatedBy']; + createdName = json['CreatedName']; + createdNameN = json['CreatedNameN']; + createdOn = json['CreatedOn']; + editedBy = json['EditedBy']; + editedByName = json['EditedByName']; + editedByNameN = json['EditedByNameN']; + editedOn = json['EditedOn']; + oRBookStatus = json['ORBookStatus']; + complicationDetail = json['ComplicationDetail']; + 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['ProjectID'] = this.projectID; + data['ReservationNo'] = this.reservationNo; + data['PatientID'] = this.patientID; + data['AdmissionID'] = this.admissionID; + data['SurgeryDate'] = this.surgeryDate; + data['PreOpDiagnosis'] = this.preOpDiagnosis; + data['PostOpDiagnosis'] = this.postOpDiagnosis; + 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['IsActive'] = this.isActive; + data['CreatedBy'] = this.createdBy; + data['CreatedName'] = this.createdName; + data['CreatedNameN'] = this.createdNameN; + data['CreatedOn'] = this.createdOn; + data['EditedBy'] = this.editedBy; + data['EditedByName'] = this.editedByName; + data['EditedByNameN'] = this.editedByNameN; + data['EditedOn'] = this.editedOn; + data['ORBookStatus'] = this.oRBookStatus; + data['ComplicationDetail'] = this.complicationDetail; + 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/models/operation_report/get_operation_report_request_model.dart b/lib/models/operation_report/get_reservations_request_model.dart similarity index 91% rename from lib/models/operation_report/get_operation_report_request_model.dart rename to lib/models/operation_report/get_reservations_request_model.dart index 6fc969ee..06425254 100644 --- a/lib/models/operation_report/get_operation_report_request_model.dart +++ b/lib/models/operation_report/get_reservations_request_model.dart @@ -1,4 +1,4 @@ -class GetOperationReportRequestModel { +class GetReservationsRequestModel { int patientID; int projectID; String doctorID; @@ -13,7 +13,7 @@ class GetOperationReportRequestModel { String tokenID; String sessionID; - GetOperationReportRequestModel( + GetReservationsRequestModel( {this.patientID, this.projectID, this.doctorID, @@ -28,7 +28,7 @@ class GetOperationReportRequestModel { this.tokenID, this.sessionID}); - GetOperationReportRequestModel.fromJson(Map json) { + GetReservationsRequestModel.fromJson(Map json) { patientID = json['PatientID']; projectID = json['ProjectID']; doctorID = json['DoctorID']; diff --git a/lib/models/operation_report/get_operation_report_model.dart b/lib/models/operation_report/get_reservations_response_model.dart similarity index 97% rename from lib/models/operation_report/get_operation_report_model.dart rename to lib/models/operation_report/get_reservations_response_model.dart index 29a0158c..3bebdc8b 100644 --- a/lib/models/operation_report/get_operation_report_model.dart +++ b/lib/models/operation_report/get_reservations_response_model.dart @@ -1,4 +1,4 @@ -class GetOperationReportModel { +class GetReservationsResponseModel { String setupID; int projectID; int oTReservationID; @@ -35,7 +35,7 @@ class GetOperationReportModel { String clinicDescription; Null clinicDescriptionN; - GetOperationReportModel( + GetReservationsResponseModel( {this.setupID, this.projectID, this.oTReservationID, @@ -72,7 +72,7 @@ class GetOperationReportModel { this.clinicDescription, this.clinicDescriptionN}); - GetOperationReportModel.fromJson(Map json) { + GetReservationsResponseModel.fromJson(Map json) { setupID = json['SetupID']; projectID = json['ProjectID']; oTReservationID = json['OTReservationID']; diff --git a/lib/screens/patients/profile/operation_report/operation_report.dart b/lib/screens/patients/profile/operation_report/operation_report.dart index 0db74f42..a445309e 100644 --- a/lib/screens/patients/profile/operation_report/operation_report.dart +++ b/lib/screens/patients/profile/operation_report/operation_report.dart @@ -55,7 +55,7 @@ class _ProgressNoteState extends State { if (routeArgs.containsKey('isDischargedPatient')) isDischargedPatient = routeArgs['isDischargedPatient']; return BaseView( - onModelReady: (model) => model.getOperationReport(patient.patientMRN), + onModelReady: (model) => model.getReservations(patient.patientMRN), builder: (_, model, w) => AppScaffold( baseViewModel: model, backgroundColor: Theme.of(context).scaffoldBackgroundColor, @@ -68,14 +68,14 @@ class _ProgressNoteState extends State { color: Colors.grey[200], child: Column( children: [ - model.operationReportList == null || - model.operationReportList.length == 0 + model.reservationList == null || + model.reservationList.length == 0 ? DrAppEmbeddedError( error: TranslationBase.of(context).errorNoProgressNote) : Expanded( child: Container( child: ListView.builder( - itemCount: model.operationReportList.length, + itemCount: model.reservationList.length, itemBuilder: (BuildContext ctxt, int index) { return FractionallySizedBox( widthFactor: 0.95, @@ -119,7 +119,7 @@ class _ProgressNoteState extends State { Expanded( child: AppText( model - .operationReportList[ + .reservationList[ index] .doctorName ?? '', @@ -137,14 +137,14 @@ class _ProgressNoteState extends State { children: [ AppText( model - .operationReportList[ + .reservationList[ index] .createdOn != null ? AppDateUtils.getDayMonthYearDateFormatted( AppDateUtils .getDateTimeFromServerFormat(model - .operationReportList[ + .reservationList[ index] .createdOn), isArabic: @@ -162,14 +162,14 @@ class _ProgressNoteState extends State { ), AppText( model - .operationReportList[ + .reservationList[ index] .createdOn != null ? AppDateUtils.getHour( AppDateUtils .getDateTimeFromServerFormat(model - .operationReportList[ + .reservationList[ index] .createdOn)) : AppDateUtils.getHour( @@ -186,7 +186,25 @@ class _ProgressNoteState extends State { SizedBox( height: 8, ), - if (model.operationReportList[index] + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Reservation: ", + fontSize: 10, + ), + Expanded( + child: AppText( + model.reservationList[index].oTReservationID.toString(), + fontSize: 10, + ), + ) + ]), + SizedBox( + height: 8, + ), + if (model.reservationList[index] .operationDate != null) Row( @@ -202,7 +220,7 @@ class _ProgressNoteState extends State { AppDateUtils.getDayMonthYearDateFormatted( AppDateUtils .getDateTimeFromServerFormat(model - .operationReportList[ + .reservationList[ index] .operationDate), isArabic: @@ -213,7 +231,7 @@ class _ProgressNoteState extends State { ), ) ]), - if (model.operationReportList[index] + if (model.reservationList[index] .timeStart != null) Row( @@ -227,14 +245,14 @@ class _ProgressNoteState extends State { Expanded( child: AppText( model - .operationReportList[ + .reservationList[ index] .timeStart, fontSize: 10, ), ) ]), - if (model.operationReportList[index] + if (model.reservationList[index] .remarks != null) Row( @@ -248,7 +266,7 @@ class _ProgressNoteState extends State { Expanded( child: AppText( model - .operationReportList[ + .reservationList[ index] .remarks ?? '', @@ -290,11 +308,9 @@ class _ProgressNoteState extends State { MaterialPageRoute( builder: (context) => UpdateOperationReport( - operationReport: model - .operationReportList[ + reservation: model + .reservationList[ index], - operationReportViewModel: - model, patient: patient, isUpdate: true, )), 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 a60c0cab..ff924dd2 100644 --- a/lib/screens/patients/profile/operation_report/update_operation_report.dart +++ b/lib/screens/patients/profile/operation_report/update_operation_report.dart @@ -12,9 +12,11 @@ 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/operation_report/get_operation_report_model.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_operation_details_response_modle.dart'; +import 'package:doctor_app_flutter/models/operation_report/get_reservations_response_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/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; @@ -31,19 +33,19 @@ import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; class UpdateOperationReport extends StatefulWidget { - final GetOperationReportModel operationReport; - final OperationReportViewModel operationReportViewModel; + final GetReservationsResponseModel reservation; + // final OperationReportViewModel operationReportViewModel; final PatiantInformtion patient; final int visitType; final bool isUpdate; const UpdateOperationReport( {Key key, - this.operationReportViewModel, + // this.operationReportViewModel, this.patient, this.visitType, this.isUpdate, - this.operationReport}) + this.reservation}) : super(key: key); @override @@ -94,459 +96,529 @@ class _UpdateOperationReportState extends State { @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); - if(widget.isUpdate) - OTReservationID.text = widget.operationReport.oTReservationID.toString(); //TODO Elham* add translation to hints - return AppScaffold( - 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: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 10.0, - ), - SingleChildScrollView( - child: Center( - child: FractionallySizedBox( - widthFactor: 0.9, - child: Column( - children: [ - AppTextFieldCustom( - hintText: "Reservation No", - //TranslationBase.of(context).addoperationReports, - controller: OTReservationID, - maxLines: 1, - minLines: 1, - enabled: false, - hasBorder: true, - ), - SizedBox( - height: 4, - ), - 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).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: "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: - 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, - ), - ], - ), + + return BaseView( + onModelReady: (model) async { + await model + .getOperationReportDetails(widget.reservation); + OTReservationID.text = widget.reservation.oTReservationID.toString(); + + if (model.operationDetailsList.isNotEmpty) { + GetOperationDetailsResponseModel oldDetails = + model.operationDetailsList[0]; + + postOpDiagmosisNoteController.text = oldDetails.postOpInstruction; + preOpDiagmosisController.text = oldDetails.preOpDiagnosis; + surgeonController.text = oldDetails.surgeon; + assistantNoteController.text = oldDetails.assistant; + operationController.text = oldDetails.operation; + inasionController.text = oldDetails.inasion; + findingController.text = oldDetails.finding; + surgeryProcedureController.text = oldDetails.surgeryProcedure; + postOpInstructionController.text = oldDetails.postOpInstruction; + complicationDetailsController.text = oldDetails.complicationDetail; + bloodLossDetailController.text = oldDetails.bloodLossDetail; + histopathSpecimenController.text = oldDetails.histopathSpecimen; + microbiologySpecimenController.text = + oldDetails.microbiologySpecimen; + otherSpecimenController.text = oldDetails.otherSpecimen; + scrubNurseController.text = oldDetails.scrubNurse; + circulatingNurseController.text = oldDetails.circulatingNurse; + BloodTransfusedDetailController.text = + oldDetails.bloodTransfusedDetail; + anasthetistController.text = oldDetails.anasthetist; + } + }, + builder: (_, model, w) => AppScaffold( + isShowAppBar: true, + baseViewModel: model, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + appBar: BottomSheetTitle( + title: TranslationBase.of(context).operationReports, + ), + body: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 1.0, + child: Padding( + padding: EdgeInsets.all(0.0), + 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: "Reservation No", + //TranslationBase.of(context).addoperationReports, + controller: OTReservationID, + maxLines: 1, + minLines: 1, + enabled: false, + hasBorder: true, + ), + SizedBox( + height: 4, + ), + 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).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: "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: 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, + ), + ], + ), + ), + ), + ), + ], ), ), ), - ], + ), ), - ), - ), - ), - ), - bottomSheet: Container( - 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).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(); - - CreateUpdateOperationReportRequestModel - createUpdateOperationReportRequestModel = - CreateUpdateOperationReportRequestModel( - inasion: inasionController.text, - - /// TODO Elham* Add dynamic reservation - reservationNo:widget.operationReport.oTReservationID , - 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); - } - }, + bottomSheet: model.state == ViewState.Idle?Container(height: 0,): Container( + 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).operationReports, + color: Color(0xff359846), + // disabled: operationReportsController.text.isEmpty, + fontWeight: FontWeight.w700, + onPressed: () async { + setState(() { + isSubmitted = true; + }); + if (isFormValid()) { + GifLoaderDialogUtils.showMyDialog(context); + await model + .getDoctorProfile(); + + CreateUpdateOperationReportRequestModel + createUpdateOperationReportRequestModel = + CreateUpdateOperationReportRequestModel( + inasion: inasionController.text, + + /// TODO Elham* Add dynamic reservation + reservationNo: + widget.reservation.oTReservationID, + 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: model + .doctorProfile.doctorID, + setupID: SETUP_ID); + await model + .updateOperationReport( + createUpdateOperationReportRequestModel); + + if (model.state == + ViewState.ErrorLocal) { + Helpers.showErrorToast( + model.error); + } else { + // await model.( + // operationReportsRequest.toJson()); + + DrAppToastMsg.showSuccesToast( + "Your Order added Successfully"); + Navigator.of(context).pop(); + } + GifLoaderDialogUtils.hideDialog(context); + } + }, + ), + ), + ], + ), ), - ), - ], - ), - ), - ); + )); } isFormValid() {