From 6192d9a84fb45e0191d894d859b928e68f37aa06 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 17 May 2021 15:05:08 +0300 Subject: [PATCH] working on medical-profile --- lib/client/base_app_client.dart | 26 +- lib/config/config.dart | 7 +- lib/config/localized_values.dart | 4 + .../PatientMedicalReportService.dart | 65 ++++ .../PatientMedicalReportViewModel.dart | 43 +++ lib/locator.dart | 4 + .../MedicalReport/MeidcalReportModel.dart | 60 +++ lib/routes.dart | 9 + .../admission-request_second-screen.dart | 2 +- .../AddVerifyMedicalReport.dart | 357 ++++++++++++++---- .../medical_report/MedicalReportPage.dart | 201 +++++----- .../profile_gird_for_InPatient.dart | 4 +- lib/util/translations_delegate_base.dart | 4 + 13 files changed, 601 insertions(+), 185 deletions(-) create mode 100644 lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart create mode 100644 lib/core/viewModel/PatientMedicalReportViewModel.dart create mode 100644 lib/models/patient/MedicalReport/MeidcalReportModel.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index bd4b0cd4..718a3839 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -67,11 +67,11 @@ class BaseAppClient { await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); } - int projectID = await sharedPref.getInt(PROJECT_ID); - if(projectID ==2 || projectID == 3) - body['PatientOutSA'] = true; - else - body['PatientOutSA'] = false; + int projectID = await sharedPref.getInt(PROJECT_ID); + if (projectID == 2 || projectID == 3) + body['PatientOutSA'] = true; + else + body['PatientOutSA'] = false; body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; print("URL : $url"); @@ -140,13 +140,11 @@ class BaseAppClient { String token = await sharedPref.getString(TOKEN); var languageID = await sharedPref.getStringWithDefaultValue(APP_Language, 'en'); - if (body.containsKey('SetupID')) { - body['SetupID'] = body.containsKey('SetupID') - ? body['SetupID'] != null - ? body['SetupID'] - : SETUP_ID - : SETUP_ID; - } + body['SetupID'] = body.containsKey('SetupID') + ? body['SetupID'] != null + ? body['SetupID'] + : SETUP_ID + : SETUP_ID; body['VersionID'] = VERSION_ID; body['Channel'] = CHANNEL; @@ -187,7 +185,7 @@ class BaseAppClient { : PATIENT_TYPE_ID : PATIENT_TYPE_ID; - body['TokenID'] = token; + body['TokenID'] = body.containsKey('TokenID') ? body['TokenID'] : token; body['PatientID'] = body['PatientID'] != null ? body['PatientID'] : patient.patientId ?? patient.patientMRN; @@ -196,7 +194,7 @@ class BaseAppClient { body['SessionID'] = SESSION_ID; //getSe int projectID = await sharedPref.getInt(PROJECT_ID); - if(projectID ==2 || projectID == 3) + if (projectID == 2 || projectID == 3) body['PatientOutSA'] = true; else body['PatientOutSA'] = false; diff --git a/lib/config/config.dart b/lib/config/config.dart index ec8efe26..3e8bbcb5 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -283,6 +283,11 @@ const GET_SICK_LEAVE_PATIENT = "Services/Patients.svc/REST/GetPatientSickLeave"; const GET_MY_OUT_PATIENT = "Services/DoctorApplication.svc/REST/GetMyOutPatient"; + +const PATIENT_MEDICAL_REPORT_GET_LIST = "Services/Patients.svc/REST/DAPP_ListMedicalReport"; +const PATIENT_MEDICAL_REPORT_INSERT = "Services/Patients.svc/REST/DAPP_InsertMedicalReport"; +const PATIENT_MEDICAL_REPORT_VERIFIED = "Services/Patients.svc/REST/DAPP_VerifiedMedicalReport"; + var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ @@ -337,7 +342,7 @@ const TRANSACTION_NO = 0; const LANGUAGE_ID = 2; const STAMP = '2020-04-27T12:17:17.721Z'; const IP_ADDRESS = '9.9.9.9'; -const VERSION_ID = 6.0; +const VERSION_ID = 6.1; const CHANNEL = 9; const SESSION_ID = 'BlUSkYymTt'; const IS_LOGIN_FOR_DOCTOR_APP = true; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 7591bfda..d22358b1 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -977,4 +977,8 @@ const Map> localizedValues = { "medicalReportAdd": {"en": "Add Medical Report", "ar": "إضافة تقرير طبي"}, "medicalReportVerify": {"en": "Verify Medical Report", "ar": "تحقق من التقرير الطبي"}, "comments": {"en": "Comments", "ar": "تعليقات"}, + "createNewMedicalReport": {"en": "Create New Medical Report", "ar": "إنشاء تقرير طبي جديد"}, + "historyPhysicalFinding": {"en": "History and Physical Finding", "ar": "التاريخ والاكتشاف المادي"}, + "laboratoryPhysicalData": {"en": "Laboratory and Physical Data", "ar": "المعامل والبيانات الفيزيائية"}, + "impressionRecommendation": {"en": "Impression and Recommendation", "ar": "الانطباع والتوصية"}, }; diff --git a/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart new file mode 100644 index 00000000..64cce97a --- /dev/null +++ b/lib/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart @@ -0,0 +1,65 @@ +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/patient/MedicalReport/MeidcalReportModel.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; + +class PatientMedicalReportService extends BaseService { + List medicalReportList = []; + + Future getMedicalReportList(PatiantInformtion patient) async { + hasError = false; + Map body = Map(); + body['TokenID'] = "@dm!n"; + body['SetupID'] = "91877"; + body['AdmissionNo'] = patient.admissionNo; + + await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_GET_LIST, + onSuccess: (dynamic response, int statusCode) { + + medicalReportList.clear(); + if (response['DAPP_ListMedicalReportList'] != null) { + response['DAPP_ListMedicalReportList'].forEach((v) { + medicalReportList.add(MedicalReportModel.fromJson(v)); + }); + } + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error.toString(); + }, body: body, patient: patient); + } + + Future insertMedicalReport(PatiantInformtion patient, String htmlText) async { + hasError = false; + Map body = Map(); + body['TokenID'] = "@dm!n"; + body['SetupID'] = "91877"; + body['AdmissionNo'] = patient.admissionNo; + body['MedicalReportHTML'] = htmlText; + + await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_INSERT, + onSuccess: (dynamic response, int statusCode) { + + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error.toString(); + }, body: body, patient: patient); + } + + Future verifyMedicalReport(PatiantInformtion patient, MedicalReportModel medicalReport) async { + hasError = false; + Map body = Map(); + body['TokenID'] = "@dm!n"; + body['SetupID'] = "91877"; + body['AdmissionNo'] = patient.admissionNo; + body['InvoiceNo'] = medicalReport.invoiceNo; + body['LineItemNo'] = medicalReport.lineItemNo; + + await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_VERIFIED, + onSuccess: (dynamic response, int statusCode) { + + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error.toString(); + }, body: body, patient: patient); + } +} diff --git a/lib/core/viewModel/PatientMedicalReportViewModel.dart b/lib/core/viewModel/PatientMedicalReportViewModel.dart new file mode 100644 index 00000000..8d7b5c63 --- /dev/null +++ b/lib/core/viewModel/PatientMedicalReportViewModel.dart @@ -0,0 +1,43 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart'; +import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/models/patient/MedicalReport/MeidcalReportModel.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; + +import '../../locator.dart'; + +class PatientMedicalReportViewModel extends BaseViewModel { + PatientMedicalReportService _service = locator(); + + List get medicalReportList => _service.medicalReportList; + + Future getMedicalReportList(PatiantInformtion patient) async { + setState(ViewState.Busy); + await _service.getMedicalReportList(patient); + if (_service.hasError) { + error = _service.error; + setState(ViewState.ErrorLocal); // ViewState.Error + } else + setState(ViewState.Idle); + } + + Future insertMedicalReport(PatiantInformtion patient, String htmlText)async { + setState(ViewState.Busy); + await _service.insertMedicalReport(patient, htmlText); + if (_service.hasError) { + error = _service.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future verifyMedicalReport(PatiantInformtion patient, MedicalReportModel medicalReport) async { + setState(ViewState.Busy); + await _service.verifyMedicalReport(patient, medicalReport); + if (_service.hasError) { + error = _service.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/locator.dart b/lib/locator.dart index 321b3ffa..f885d4c4 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -15,6 +15,7 @@ import 'core/service/patient_medical_file/insurance/InsuranceCardService.dart'; import 'core/service/patient/MyReferralPatientService.dart'; import 'core/service/patient/PatientMuseService.dart'; import 'core/service/patient/ReferralService.dart'; +import 'core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart'; import 'core/service/patient_medical_file/medical_report/medical_file_service.dart'; import 'core/service/patient_medical_file/prescription/prescription_service.dart'; import 'core/service/patient_medical_file/procedure/procedure_service.dart'; @@ -36,6 +37,7 @@ import 'core/service/patient/referred_patient_service.dart'; import 'core/service/home/schedule_service.dart'; import 'core/viewModel/DischargedPatientViewModel.dart'; import 'core/viewModel/InsuranceViewModel.dart'; +import 'core/viewModel/PatientMedicalReportViewModel.dart'; import 'core/viewModel/PatientMuseViewModel.dart'; import 'core/viewModel/PatientSearchViewModel.dart'; import 'core/viewModel/SOAP_view_model.dart'; @@ -84,6 +86,7 @@ void setupLocator() { locator.registerLazySingleton(() => DischargedPatientService()); locator.registerLazySingleton(() => PatientInPatientService()); locator.registerLazySingleton(() => OutPatientService()); + locator.registerLazySingleton(() => PatientMedicalReportService()); /// View Model locator.registerFactory(() => DoctorReplayViewModel()); @@ -110,4 +113,5 @@ void setupLocator() { locator.registerFactory(() => PrescriptionsViewModel()); locator.registerFactory(() => DischargedPatientViewModel()); locator.registerFactory(() => PatientSearchViewModel()); + locator.registerFactory(() => PatientMedicalReportViewModel()); } diff --git a/lib/models/patient/MedicalReport/MeidcalReportModel.dart b/lib/models/patient/MedicalReport/MeidcalReportModel.dart new file mode 100644 index 00000000..450b93f6 --- /dev/null +++ b/lib/models/patient/MedicalReport/MeidcalReportModel.dart @@ -0,0 +1,60 @@ +class MedicalReportModel { + String reportData; + String setupID; + int projectID; + int patientID; + String invoiceNo; + int status; + String verifiedOn; + int verifiedBy; + String editedOn; + int editedBy; + int lineItemNo; + String reportDataHtml; + + MedicalReportModel( + {this.reportData, + this.setupID, + this.projectID, + this.patientID, + this.invoiceNo, + this.status, + this.verifiedOn, + this.verifiedBy, + this.editedOn, + this.editedBy, + this.lineItemNo, + this.reportDataHtml}); + + MedicalReportModel.fromJson(Map json) { + reportData = json['ReportData']; + setupID = json['SetupID']; + projectID = json['ProjectID']; + patientID = json['PatientID']; + invoiceNo = json['InvoiceNo']; + status = json['Status']; + verifiedOn = json['VerifiedOn']; + verifiedBy = json['VerifiedBy']; + editedOn = json['EditedOn']; + editedBy = json['EditedBy']; + lineItemNo = json['LineItemNo']; + reportDataHtml = json['ReportDataHtml']; + } + + Map toJson() { + final Map data = new Map(); + data['ReportData'] = this.reportData; + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['PatientID'] = this.patientID; + data['InvoiceNo'] = this.invoiceNo; + data['Status'] = this.status; + data['VerifiedOn'] = this.verifiedOn; + data['VerifiedBy'] = this.verifiedBy; + data['EditedOn'] = this.editedOn; + data['EditedBy'] = this.editedBy; + data['LineItemNo'] = this.lineItemNo; + data['ReportDataHtml'] = this.reportDataHtml; + return data; + } +} diff --git a/lib/routes.dart b/lib/routes.dart index 2684cd82..c0168762 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -5,6 +5,9 @@ import 'package:doctor_app_flutter/screens/patients/insurance_approval_screen_pa import 'package:doctor_app_flutter/screens/patients/profile/UCAF/UCAF-detail-screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/UCAF/UCAF-input-screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/labs_home_page.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/medical_report/MedicalReportDetailPage.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/medical_report/MedicalReportPage.dart'; import 'package:doctor_app_flutter/screens/patients/profile/note/progress_note_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/radiology/radiology_home_page.dart'; @@ -51,6 +54,9 @@ const String UPDATE_EPISODE = 'patients/update-episode'; const String PATIENT_ADMISSION_REQUEST = 'patients/admission-request'; const String PATIENT_ADMISSION_REQUEST_2 = 'patients/admission-request-second'; const String PATIENT_ADMISSION_REQUEST_3 = 'patients/admission-request-third'; +const String PATIENT_MEDICAL_REPORT = 'patients/medical-report'; +const String PATIENT_MEDICAL_REPORT_INSERT = 'patients/medical-report-insert'; +const String PATIENT_MEDICAL_REPORT_DETAIL = 'patients/medical-report-detail'; const String PATIENT_UCAF_REQUEST = 'patients/ucaf'; const String PATIENT_UCAF_DETAIL = 'patients/ucaf/detail'; const String PATIENT_ECG = 'patients/ecg'; @@ -79,6 +85,9 @@ var routes = { PATIENT_ADMISSION_REQUEST: (_) => AdmissionRequestFirstScreen(), PATIENT_ADMISSION_REQUEST_2: (_) => AdmissionRequestSecondScreen(), PATIENT_ADMISSION_REQUEST_3: (_) => AdmissionRequestThirdScreen(), + PATIENT_MEDICAL_REPORT: (_) => MedicalReportPage(), + PATIENT_MEDICAL_REPORT_INSERT: (_) => AddVerifyMedicalReport(), + PATIENT_MEDICAL_REPORT_DETAIL: (_) => MedicalReportDetailPage(), CREATE_EPISODE: (_) => UpdateSoapIndex( isUpdate: true, ), diff --git a/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart b/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart index 8627d224..bea487f7 100644 --- a/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart +++ b/lib/screens/patients/profile/admission-request/admission-request_second-screen.dart @@ -477,7 +477,7 @@ class _AdmissionRequestSecondScreenState Expanded( child: AppButton( title: TranslationBase.of(context).previous, - color: HexColor("#EAEAEA"), + color: Color(0xffEAEAEA), fontColor: Colors.black, onPressed: () { Navigator.pop(context); diff --git a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart index 1b33aecb..f562f7b2 100644 --- a/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart +++ b/lib/screens/patients/profile/medical_report/AddVerifyMedicalReport.dart @@ -1,8 +1,9 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/provider/robot_provider.dart'; -import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientMedicalReportViewModel.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/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -16,21 +17,25 @@ import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_to_text.dart' as stt; class AddVerifyMedicalReport extends StatefulWidget { - final MedicalReportStatus status; - - AddVerifyMedicalReport(this.status); - @override _AddVerifyMedicalReportState createState() => _AddVerifyMedicalReportState(); } class _AddVerifyMedicalReportState extends State { - stt.SpeechToText speech = stt.SpeechToText(); - var reconizedWord; + stt.SpeechToText speechHistoryFinding = stt.SpeechToText(); + stt.SpeechToText speechLaboratoryData = stt.SpeechToText(); + stt.SpeechToText speechRecommendation = stt.SpeechToText(); + var recognizedWord1; + var recognizedWord2; + var recognizedWord3; var event = RobotProvider(); - TextEditingController commentController = TextEditingController(); + TextEditingController historyFindingController = TextEditingController(); + TextEditingController laboratoryDataController = TextEditingController(); + TextEditingController recommendationController = TextEditingController(); String commentsError; + String comments2Error; + String comments3Error; @override void initState() { @@ -38,7 +43,15 @@ class _AddVerifyMedicalReportState extends State { event.controller.stream.listen((p) { if (p['startPopUp'] == 'true') { if (this.mounted) { - initSpeechState().then((value) => {onVoiceText()}); + initSpeechState().then((value) { + onVoiceText(); + }); + initSpeechState2().then((value) { + onVoiceText2(); + }); + initSpeechState3().then((value) { + onVoiceText3(); + }); } } }); @@ -48,79 +61,201 @@ class _AddVerifyMedicalReportState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + MedicalReportStatus status = routeArgs['status']; - return BaseView( + return BaseView( builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, - appBarTitle: widget.status == MedicalReportStatus.ADD + appBarTitle: status == MedicalReportStatus.ADD ? TranslationBase.of(context).medicalReportAdd : TranslationBase.of(context).medicalReportVerify, backgroundColor: Theme.of(context).scaffoldBackgroundColor, body: Column( children: [ Expanded( - child: SingleChildScrollView( - child: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - AppTextFieldCustom( - hintText: TranslationBase.of(context) - .sickLeaveComments, - controller: commentController, - maxLines: 30, - minLines: 20, - hasBorder: true, - validationError: commentsError, - ), - Positioned( - top: -2, - //MediaQuery.of(context).size.height * 0, - right: projectViewModel.isArabic - ? MediaQuery.of(context).size.width * - 0.75 - : 15, - child: Column( + child: Container( + margin: EdgeInsets.all(16), + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + AppTextFieldCustom( + hintText: TranslationBase.of(context) + .historyPhysicalFinding, + controller: historyFindingController, + maxLines: 15, + minLines: 10, + hasBorder: true, + validationError: commentsError, + ), + 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()}); + }, + ), + ], + )), + ], + ), + Stack( + children: [ + AppTextFieldCustom( + hintText: TranslationBase.of(context) + .laboratoryPhysicalData, + controller: laboratoryDataController, + maxLines: 15, + minLines: 10, + hasBorder: true, + validationError: comments2Error, + ), + 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: () { + initSpeechState2().then( + (value) => + {onVoiceText2()}); + }, + ), + ], + )), + ], + ), + Stack( children: [ - IconButton( - icon: Icon(DoctorApp.speechtotext, - color: Colors.black, size: 35), - onPressed: () { - initSpeechState().then( - (value) => {onVoiceText()}); - }, + AppTextFieldCustom( + hintText: TranslationBase.of(context) + .impressionRecommendation, + controller: recommendationController, + maxLines: 15, + minLines: 10, + hasBorder: true, + validationError: comments3Error, ), + 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: () { + initSpeechState3().then( + (value) => + {onVoiceText3()}); + }, + ), + ], + )), ], - )), - ], + ), + ], + ), + ), ), - ], - ), + ), + ], ), ), ), Container( - margin: EdgeInsets.all(16.0), - child: AppButton( - title: widget.status == MedicalReportStatus.ADD - ? TranslationBase.of(context).medicalReportAdd - : TranslationBase.of(context).medicalReportVerify, - color: Color(0xff359846), - // disabled: progressNoteController.text.isEmpty, - fontWeight: FontWeight.w700, - onPressed: () { - setState(() { - if (commentController.text == "") { - commentsError = - TranslationBase.of(context).fieldRequired; - } else { - commentsError = null; - } - }); - }, + padding: EdgeInsets.all(16.0), + color: Colors.white, + child: Row( + children: [ + Expanded( + child: AppButton( + title: status == MedicalReportStatus.ADD + ? TranslationBase.of(context).save + : TranslationBase.of(context).save, + color: Color(0xffEAEAEA), + fontColor: Colors.black, + // disabled: progressNoteController.text.isEmpty, + fontWeight: FontWeight.w700, + onPressed: () { + setState(() { + if (historyFindingController.text == "") { + commentsError = + TranslationBase.of(context).fieldRequired; + } else { + commentsError = null; + } + }); + }, + ), + ), + SizedBox( + width: 8, + ), + Expanded( + child: AppButton( + title: status == MedicalReportStatus.ADD + ? TranslationBase.of(context).add + : TranslationBase.of(context).verify, + color: Color(0xff359846), + // disabled: progressNoteController.text.isEmpty, + fontWeight: FontWeight.w700, + onPressed: () { + setState(() { + if (historyFindingController.text == "") { + commentsError = + TranslationBase.of(context).fieldRequired; + } else { + commentsError = null; + } + }); + }, + ), + ), + ], ), ), ], @@ -131,10 +266,10 @@ class _AddVerifyMedicalReportState extends State { onVoiceText() async { new SpeechToText(context: context).showAlertDialog(context); var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; - bool available = await speech.initialize( + bool available = await speechHistoryFinding.initialize( onStatus: statusListener, onError: errorListener); if (available) { - speech.listen( + speechHistoryFinding.listen( onResult: resultListener, listenMode: stt.ListenMode.confirmation, localeId: lang == 'en' ? 'en-US' : 'ar-SA', @@ -144,6 +279,38 @@ class _AddVerifyMedicalReportState extends State { } } + onVoiceText2() async { + new SpeechToText(context: context).showAlertDialog(context); + var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; + bool available = await speechLaboratoryData.initialize( + onStatus: statusListener, onError: errorListener); + if (available) { + speechLaboratoryData.listen( + onResult: resultListener2, + listenMode: stt.ListenMode.confirmation, + localeId: lang == 'en' ? 'en-US' : 'ar-SA', + ); + } else { + print("The user has denied the use of speech recognition."); + } + } + + onVoiceText3() async { + new SpeechToText(context: context).showAlertDialog(context); + var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; + bool available = await speechRecommendation.initialize( + onStatus: statusListener, onError: errorListener); + if (available) { + speechRecommendation.listen( + onResult: resultListener3, + listenMode: stt.ListenMode.confirmation, + localeId: lang == 'en' ? 'en-US' : 'ar-SA', + ); + } else { + print("The user has denied the use of speech recognition."); + } + } + void errorListener(SpeechRecognitionError error) { event.setValue({"searchText": 'null'}); //SpeechToText.closeAlertDialog(context); @@ -151,7 +318,9 @@ class _AddVerifyMedicalReportState extends State { } void statusListener(String status) { - reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord1 = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord2 = status == 'listening' ? 'Lisening...' : 'Sorry....'; + recognizedWord3 = status == 'listening' ? 'Lisening...' : 'Sorry....'; } void requestPermissions() async { @@ -161,14 +330,44 @@ class _AddVerifyMedicalReportState extends State { } void resultListener(result) { - reconizedWord = result.recognizedWords; - event.setValue({"searchText": reconizedWord}); + recognizedWord1 = result.recognizedWords; + event.setValue({"searchText": recognizedWord1}); + + if (result.finalResult == true) { + setState(() { + SpeechToText.closeAlertDialog(context); + speechHistoryFinding.stop(); + historyFindingController.text += recognizedWord1 + '\n'; + }); + } else { + print(result.finalResult); + } + } + + void resultListener2(result) { + recognizedWord2 = result.recognizedWords; + event.setValue({"searchText": recognizedWord2}); + + if (result.finalResult == true) { + setState(() { + SpeechToText.closeAlertDialog(context); + speechLaboratoryData.stop(); + laboratoryDataController.text += recognizedWord2 + '\n'; + }); + } else { + print(result.finalResult); + } + } + + void resultListener3(result) { + recognizedWord3 = result.recognizedWords; + event.setValue({"searchText": recognizedWord3}); if (result.finalResult == true) { setState(() { SpeechToText.closeAlertDialog(context); - speech.stop(); - commentController.text += reconizedWord + '\n'; + speechRecommendation.stop(); + recommendationController.text += recognizedWord3 + '\n'; }); } else { print(result.finalResult); @@ -176,7 +375,21 @@ class _AddVerifyMedicalReportState extends State { } Future initSpeechState() async { - bool hasSpeech = await speech.initialize( + bool hasSpeech = await speechHistoryFinding.initialize( + onError: errorListener, onStatus: statusListener); + print(hasSpeech); + if (!mounted) return; + } + + Future initSpeechState2() async { + bool hasSpeech = await speechLaboratoryData.initialize( + onError: errorListener, onStatus: statusListener); + print(hasSpeech); + if (!mounted) return; + } + + Future initSpeechState3() async { + bool hasSpeech = await speechRecommendation.initialize( onError: errorListener, onStatus: statusListener); print(hasSpeech); if (!mounted) return; diff --git a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart index 8dad1bc4..1701feac 100644 --- a/lib/screens/patients/profile/medical_report/MedicalReportPage.dart +++ b/lib/screens/patients/profile/medical_report/MedicalReportPage.dart @@ -1,6 +1,10 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientMedicalReportViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design-app-bar.dart'; @@ -12,118 +16,125 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../../../routes.dart'; +import 'AddVerifyMedicalReport.dart'; + class MedicalReportPage extends StatelessWidget { @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String patientType = routeArgs['patientType']; - bool isInpatient = routeArgs['isInpatient']; + String arrivalType = routeArgs['arrivalType']; ProjectViewModel projectViewModel = Provider.of(context); - //TODO Jammal - return AppScaffold( - appBar: PatientProfileHeaderNewDesignAppBar( - patient, - patient.patientType.toString() ?? '0', - patientType, - isInpatient: isInpatient, - ), - body: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: Column( - children: [ - SizedBox( - height: 12, - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - "Medical", - style: "caption2", - color: Colors.black, - fontSize: 13, - ), - AppText( - "Report", - bold: true, - fontSize: 22, - ), - ], - ), - ), - AddNewOrder( - onTap: () { - }, - label: "Create New Medical Report", - ), - ...List.generate( - /*model.patientLabOrdersList.length,*/1, - (index) => CardWithBgWidget( - hasBorder: false, - bgColor: 0==0? Colors.red[700]:Colors.green[700], - widget: Column( - children: [ - Row( - children: [ - Expanded( + return BaseView( + onModelReady: (model) => model.getMedicalReportList(patient), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + appBar: PatientProfileHeaderNewDesignAppBar(patient, patientType, arrivalType,), + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "${TranslationBase.of(context).medical}", + fontSize: SizeConfig.textMultiplier * 1.6, + fontWeight: FontWeight.w700, + color: Color(0xFF2E303A), + ), + AppText( + TranslationBase.of(context).report, + fontSize: SizeConfig.textMultiplier * 3, + fontWeight: FontWeight.bold, + color: Color(0xFF2E303A), + ) + ], + ), + ), + AddNewOrder( + onTap: () { + Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_INSERT, arguments: { + 'patient': patient, + 'patientType': patientType, + 'arrivalType': arrivalType, + 'type': MedicalReportStatus.ADD + }); + }, + label: TranslationBase.of(context).createNewMedicalReport, + ), + ...List.generate( + /*model.patientLabOrdersList.length,*/1, + (index) => CardWithBgWidget( + hasBorder: false, + bgColor: 0==0? Colors.red[700]:Colors.green[700], + widget: Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText('On Hold',color: Colors.red,), + AppText( + "Jammal" ?? "", + fontSize: 15, + bold: true, + ), + ], + )), + Expanded( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.end, children: [ - AppText('On Hold',color: Colors.red,), AppText( - "Jammal" ?? "", - fontSize: 15, - bold: true, - ), - ], - )), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - AppText( - '${AppDateUtils.getDayMonthYearDateFormatted(DateTime.now(), isArabic: projectViewModel.isArabic)}', - color: Colors.black, - fontWeight: FontWeight.w600, - fontSize: 14, - ), - AppText( - '${AppDateUtils.getHour(DateTime.now())}', + '${AppDateUtils.getDayMonthYearDateFormatted(DateTime.now(), isArabic: projectViewModel.isArabic)}', + color: Colors.black, fontWeight: FontWeight.w600, - color: Colors.grey[700], fontSize: 14, ), - ], + AppText( + '${AppDateUtils.getHour(DateTime.now())}', + fontWeight: FontWeight.w600, + color: Colors.grey[700], + fontSize: 14, + ), + ], + ), ), - ), - ], - ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - child: LargeAvatar( - name: "Jammal", - url: null, + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + child: LargeAvatar( + name: "Jammal", + url: null, + ), + width: 55, + height: 55, ), - width: 55, - height: 55, - ), - Expanded(child: AppText("")), - Icon( - EvaIcons.eye, - ) - ], - ), - ], + Expanded(child: AppText("")), + Icon( + EvaIcons.eye, + ) + ], + ), + ], + ), ), - ), - ) - ], + ) + ], + ), ), ), ); diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart index 1df7d236..49fa8012 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart @@ -88,10 +88,10 @@ class ProfileGridForInPatient extends StatelessWidget { PatientProfileCardModel( TranslationBase.of(context).medical, TranslationBase.of(context).report, - HEALTH_SUMMARY, + PATIENT_MEDICAL_REPORT, 'patient/health_summary.png', isInPatient: isInpatient, - isDisable: true), + isDisable: false), PatientProfileCardModel( TranslationBase.of(context).referral, TranslationBase.of(context).patient, diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 8c2bf15b..b9c64c17 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1332,6 +1332,10 @@ class TranslationBase { String get medicalReportAdd => localizedValues['medicalReportAdd'][locale.languageCode]; String get medicalReportVerify => localizedValues['medicalReportVerify'][locale.languageCode]; String get comments => localizedValues['comments'][locale.languageCode]; + String get createNewMedicalReport => localizedValues['createNewMedicalReport'][locale.languageCode]; + String get historyPhysicalFinding => localizedValues['historyPhysicalFinding'][locale.languageCode]; + String get laboratoryPhysicalData => localizedValues['laboratoryPhysicalData'][locale.languageCode]; + String get impressionRecommendation => localizedValues['impressionRecommendation'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {