diff --git a/lib/core/service/patient/patient_service.dart b/lib/core/service/patient/patient_service.dart index 1c458251..27dcd080 100644 --- a/lib/core/service/patient/patient_service.dart +++ b/lib/core/service/patient/patient_service.dart @@ -11,7 +11,6 @@ import 'package:doctor_app_flutter/core/model/note/GetNursingProgressNoteRequest import 'package:doctor_app_flutter/core/model/note/GetNursingProgressNoteResposeModel.dart'; import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/stp_master_list_req_model.dart'; -import 'package:doctor_app_flutter/core/model/note/stp_master_list_res_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/model/patient/get_clinic_by_project_id_request.dart'; import 'package:doctor_app_flutter/core/model/patient/get_doctor_by_clinic_id_request.dart'; @@ -39,15 +38,12 @@ class PatientService extends BaseService { List _patientLabResultOrdersList = []; - List get patientLabResultOrdersList => - _patientLabResultOrdersList; + List get patientLabResultOrdersList => _patientLabResultOrdersList; - List get patientPrescriptionsList => - _patientPrescriptionsList; + List get patientPrescriptionsList => _patientPrescriptionsList; List _patientPrescriptionsList = []; - List get prescriptionReportForInPatientList => - _prescriptionReportForInPatientList; + List get prescriptionReportForInPatientList => _prescriptionReportForInPatientList; List _prescriptionReportForInPatientList = []; List _patientRadiologyList = []; @@ -68,17 +64,14 @@ class PatientService extends BaseService { List _patientNursingProgressNoteList = []; - List get patientNursingProgressNoteList => - _patientNursingProgressNoteList; + List get patientNursingProgressNoteList => _patientNursingProgressNoteList; List _diagnosisForInPatientList = []; - List get diagnosisForInPatientList => - _diagnosisForInPatientList; + List get diagnosisForInPatientList => _diagnosisForInPatientList; List _diabeticChartValuesList = []; - List get diabeticChartValuesList => - _diabeticChartValuesList; + List get diabeticChartValuesList => _diabeticChartValuesList; List stpMasterList = []; @@ -106,12 +99,9 @@ class PatientService extends BaseService { get referalFrequancyList => _referalFrequancyList; - DoctorsByClinicIdRequest _doctorsByClinicIdRequest = - DoctorsByClinicIdRequest(); - STPReferralFrequencyRequest _referralFrequencyRequest = - STPReferralFrequencyRequest(); - ClinicByProjectIdRequest _clinicByProjectIdRequest = - ClinicByProjectIdRequest(); + DoctorsByClinicIdRequest _doctorsByClinicIdRequest = DoctorsByClinicIdRequest(); + STPReferralFrequencyRequest _referralFrequencyRequest = STPReferralFrequencyRequest(); + ClinicByProjectIdRequest _clinicByProjectIdRequest = ClinicByProjectIdRequest(); ReferToDoctorRequest? _referToDoctorRequest; Future getPatientList(patient, patientType, {isView}) async { @@ -165,8 +155,7 @@ class PatientService extends BaseService { return Future.value(localRes); } - Future getInPatient( - PatientSearchRequestModel requestModel, bool isMyInpatient) async { + Future getInPatient(PatientSearchRequestModel requestModel, bool isMyInpatient) async { hasError = false; await getDoctorProfile(); @@ -206,7 +195,7 @@ class PatientService extends BaseService { onSuccess: (dynamic response, int statusCode) { _patientLabResultOrdersList = []; response['List_GetLabOreders'].forEach((v) { - _patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); + _patientLabResultOrdersList.add(LabOrdersResModel.fromJson(v)); }); }, onFailure: (String error, int statusCode) { @@ -242,8 +231,7 @@ class PatientService extends BaseService { onSuccess: (dynamic response, int statusCode) { _prescriptionReportForInPatientList = []; response['List_PrescriptionReportForInPatient'].forEach((v) { - prescriptionReportForInPatientList - .add(PrescriptionReportForInPatient.fromJson(v)); + prescriptionReportForInPatientList.add(PrescriptionReportForInPatient.fromJson(v)); }); }, onFailure: (String error, int statusCode) { @@ -498,9 +486,7 @@ class PatientService extends BaseService { ); } - Future getNursingProgressNote( - GetNursingProgressNoteRequestModel - getNursingProgressNoteRequestModel) async { + Future getNursingProgressNote(GetNursingProgressNoteRequestModel getNursingProgressNoteRequestModel) async { hasError = false; await baseAppClient.post( @@ -508,8 +494,7 @@ class PatientService extends BaseService { onSuccess: (dynamic response, int statusCode) { _patientNursingProgressNoteList = []; response['List_NursingProgressNote'].forEach((v) { - _patientNursingProgressNoteList - .add(GetNursingProgressNoteResposeModel.fromJson(v)); + _patientNursingProgressNoteList.add(GetNursingProgressNoteResposeModel.fromJson(v)); }); }, onFailure: (String error, int statusCode) { @@ -520,9 +505,7 @@ class PatientService extends BaseService { ); } - Future getDiagnosisForInPatient( - GetDiagnosisForInPatientRequestModel - getDiagnosisForInPatientRequestModel) async { + Future getDiagnosisForInPatient(GetDiagnosisForInPatientRequestModel getDiagnosisForInPatientRequestModel) async { hasError = false; await baseAppClient.post( @@ -530,8 +513,7 @@ class PatientService extends BaseService { onSuccess: (dynamic response, int statusCode) { _diagnosisForInPatientList = []; response['List_DiagnosisForInPatient'].forEach((v) { - _diagnosisForInPatientList - .add(GetDiagnosisForInPatientResponseModel.fromJson(v)); + _diagnosisForInPatientList.add(GetDiagnosisForInPatientResponseModel.fromJson(v)); }); }, onFailure: (String error, int statusCode) { @@ -542,9 +524,7 @@ class PatientService extends BaseService { ); } - Future getDiabeticChartValues( - GetDiabeticChartValuesRequestModel - getDiabeticChartValuesRequestModel) async { + Future getDiabeticChartValues(GetDiabeticChartValuesRequestModel getDiabeticChartValuesRequestModel) async { hasError = false; await baseAppClient.post( @@ -552,8 +532,7 @@ class PatientService extends BaseService { onSuccess: (dynamic response, int statusCode) { _diabeticChartValuesList = []; response['List_DiabeticChartValues'].forEach((v) { - _diabeticChartValuesList - .add(GetDiabeticChartValuesResponseModel.fromJson(v)); + _diabeticChartValuesList.add(GetDiabeticChartValuesResponseModel.fromJson(v)); }); }, onFailure: (String error, int statusCode) { @@ -564,8 +543,7 @@ class PatientService extends BaseService { ); } - Future getStpMasterList( - StpMasterListRequestModel stpMasterListRequestModel) async { + Future getStpMasterList(StpMasterListRequestModel stpMasterListRequestModel) async { hasError = false; await baseAppClient.post( diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 35358ad0..85b68b85 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -142,10 +142,6 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Busy); } else setState(ViewState.Busy); - - //else - // setState(ViewState.Busy); - await _SOAPService.getMasterLookup(masterKeys, searchKey: searchKey); if (_SOAPService.hasError) { error = _SOAPService.error; @@ -259,7 +255,7 @@ class SOAPViewModel extends BaseViewModel { return allergiesString; } - Future getPatientPhysicalExam(PatiantInformtion patientInfo, {required bool allowSetState}) async { + Future getPatientPhysicalExam(PatiantInformtion patientInfo) async { GetPhysicalExamReqModel getPhysicalExamReqModel = GetPhysicalExamReqModel( patientMRN: patientInfo.patientMRN, episodeID: patientInfo.episodeNo == null ? "0" : patientInfo.episodeNo.toString(), @@ -273,12 +269,13 @@ class SOAPViewModel extends BaseViewModel { getPhysicalExamReqModel.admissionNo = int.parse(patientInfo.admissionNo!); else getPhysicalExamReqModel.admissionNo = 0; - if (allowSetState) setState(ViewState.Busy); + setState(ViewState.Busy); await _SOAPService.getPatientPhysicalExam(getPhysicalExamReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; - if (allowSetState) setState(ViewState.Error); - } else if (allowSetState) setState(ViewState.Idle); + setState(ViewState.Error); + } else + setState(ViewState.Idle); } Future getPatientProgressNote(GetProgressNoteReqModel getGetProgressNoteReqModel) async { @@ -520,8 +517,8 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future onAddMedicationStart({required bool allowSetState}) async { - if (allowSetState) setState(ViewState.Busy); + Future onAddMedicationStart() async { + setState(ViewState.Busy); List services = []; if (medicationStrengthList.length == 0) { if (services.isEmpty) { @@ -563,8 +560,12 @@ class SOAPViewModel extends BaseViewModel { if (_SOAPService.hasError || _prescriptionService.hasError) { error = _SOAPService.error.toString() + _prescriptionService.error.toString(); - if (allowSetState) setState(ViewState.ErrorLocal); - } else if (allowSetState) setState(ViewState.Idle); + setState(ViewState.ErrorLocal); + } else { + setState( + ViewState.Idle, + ); + } } callAddAssessmentLookupsServices({String searchKey = "", bool allowSetState = true}) async { diff --git a/lib/screens/live_care/live_care_patient_screen.dart b/lib/screens/live_care/live_care_patient_screen.dart index 827cec7e..a46121e0 100644 --- a/lib/screens/live_care/live_care_patient_screen.dart +++ b/lib/screens/live_care/live_care_patient_screen.dart @@ -7,9 +7,11 @@ import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_field_custom_serach.dart'; import 'package:flutter/material.dart'; diff --git a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart index 64d8caf8..7be4b062 100644 --- a/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/add_examination_page.dart @@ -1,5 +1,4 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; -import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; @@ -29,7 +28,7 @@ class _AddExaminationPageState extends State { @override initState() { super.initState(); - mySelectedExaminationLocal = [...?widget.mySelectedExamination]; + mySelectedExaminationLocal = widget.mySelectedExamination!; } @override @@ -37,9 +36,11 @@ class _AddExaminationPageState extends State { return BaseView( onModelReady: (model) async { if (model.physicalExaminationList.length == 0) { - await model.getMasterLookup( - MasterKeysService.PhysicalExamination, - ); + WidgetsBinding.instance.addPostFrameCallback((_) async { + await model.getMasterLookup( + MasterKeysService.PhysicalExamination, + ); + }); } }, builder: (_, model, w) => AppScaffold( @@ -71,7 +72,7 @@ class _AddExaminationPageState extends State { child: Column( children: [ ExaminationsListSearchWidget( - mySelectedExamination: widget.mySelectedExamination!, + mySelectedExamination: widget.mySelectedExamination, masterList: model.physicalExaminationList, isServiceSelected: (master) => isServiceSelected(master), removeExamination: (selectedExamination) { @@ -93,23 +94,27 @@ class _AddExaminationPageState extends State { ), ], ), - bottomSheet: model.state != ViewState.Idle - ? Container( - height: 0, - ) - : CustomBottomSheetContainer( - label: "${TranslationBase.of(context).addExamination}", - onTap: () { - widget.addSelectedExamination(mySelectedExaminationLocal); - }, - ), + bottomSheet: + + // model.state != ViewState.Idle + // ? Container( + // height: 10, + // color: Colors.red, + // ) + // : + + CustomBottomSheetContainer( + label: "${TranslationBase.of(context).addExamination}", + onTap: () { + widget.addSelectedExamination(mySelectedExaminationLocal); + }, + ), )); } isServiceSelected(MasterKeyModel masterKey) { Iterable exam = mySelectedExaminationLocal.where((element) => masterKey.id == element.selectedExamination!.id && masterKey.typeId == element.selectedExamination!.typeId); if (exam.length > 0) { - print("--------------"); return true; } return false; diff --git a/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart b/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart index c27eefb2..988a0d71 100644 --- a/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart +++ b/lib/screens/patients/profile/soap_update/objective/examinations_list_search_widget.dart @@ -23,12 +23,12 @@ class ExaminationsListSearchWidget extends StatefulWidget { class _ExaminationsListSearchWidgetState extends State { int expandedIndex = -1; - List items = []; + List? items = []; TextEditingController filteredSearchController = TextEditingController(); @override void initState() { - items.addAll(widget.masterList as Iterable); + items!.addAll(widget.masterList!); super.initState(); } @@ -58,7 +58,7 @@ class _ExaminationsListSearchWidgetState extends State); + items!.clear(); + items!.addAll(widget.masterList as Iterable); }); } } diff --git a/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart b/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart index 2ecb873c..b44c35db 100644 --- a/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart +++ b/lib/screens/patients/profile/soap_update/objective/update_objective_page.dart @@ -60,7 +60,7 @@ class _UpdateObjectivePageState extends State implements Ob model.setObjectiveCallBack(this); mySelectedExamination.clear(); model.isAddExamInProgress = true; - await model.getPatientPhysicalExam(widget.patientInfo, allowSetState: false); + await model.getPatientPhysicalExam(widget.patientInfo); if (model.patientPhysicalExamList.isNotEmpty) { if (model.physicalExaminationList.length == 0) { await model.getMasterLookup(MasterKeysService.PhysicalExamination); @@ -273,28 +273,25 @@ class _UpdateObjectivePageState extends State implements Ob page: AddExaminationPage( mySelectedExamination: mySelectedExamination, addSelectedExamination: (List mySelectedExaminationLocal) { - setState(() { - { - mySelectedExaminationLocal.forEach((element) { - if ((mySelectedExamination.singleWhere((it) => it.selectedExamination!.id == element.selectedExamination!.id, orElse: () => MySelectedExamination())) == null) { - mySelectedExamination.insert(0, element); - } - }); - - /// remove items. - List removedList = []; - mySelectedExamination.forEach((element) { - if ((mySelectedExaminationLocal.singleWhere((it) => it.selectedExamination!.id == element.selectedExamination!.id, orElse: () => MySelectedExamination())) == null) { - removedList.add(element); - } - }); + mySelectedExaminationLocal.forEach((element) { + if (mySelectedExamination.singleWhere((it) => it.selectedExamination!.id == element.selectedExamination!.id, orElse: () => MySelectedExamination()) == MySelectedExamination()) { + mySelectedExamination.insert(0, element); + } + }); - removedList.forEach((element) { - removeExamination(element.selectedExamination!); - }); - Navigator.of(context).pop(); + /// remove items. + List removedList = []; + mySelectedExamination.forEach((element) { + if (mySelectedExaminationLocal.singleWhere((it) => it.selectedExamination!.id == element.selectedExamination!.id, orElse: () => MySelectedExamination()) == MySelectedExamination()) { + removedList.add(element); } }); + + removedList.forEach((element) { + removeExamination(element.selectedExamination!); + }); + Navigator.of(context).pop(); + setState(() {}); }, removeExamination: (masterKey) => removeExamination(masterKey)), ), diff --git a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart index 62f764e6..e503d5f5 100644 --- a/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update/subjective/medication/add_medication.dart @@ -54,7 +54,7 @@ class _AddMedicationState extends State { return FractionallySizedBox( child: BaseView( onModelReady: (model) async { - model.onAddMedicationStart(allowSetState: false).whenComplete(() {}); + model.onAddMedicationStart(); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, diff --git a/lib/widgets/patients/patient_card/ShowTimer.dart b/lib/widgets/patients/patient_card/ShowTimer.dart index f8631072..8ed72425 100644 --- a/lib/widgets/patients/patient_card/ShowTimer.dart +++ b/lib/widgets/patients/patient_card/ShowTimer.dart @@ -49,9 +49,7 @@ class _ShowTimerState extends State { generateShowTimerString() { DateTime now = DateTime.now(); DateTime liveCareDate = DateTime.parse(widget.patientInfo.arrivalTime!); - String timer = AppDateUtils.differenceBetweenDateAndCurrent( - liveCareDate, context, - isShowSecond: true, isShowDays: false); + String timer = AppDateUtils.differenceBetweenDateAndCurrent(liveCareDate, context, isShowSecond: true, isShowDays: false); return timer; } diff --git a/lib/widgets/shared/expandable-widget-header-body.dart b/lib/widgets/shared/expandable-widget-header-body.dart index 4d6864d9..6f05e76a 100644 --- a/lib/widgets/shared/expandable-widget-header-body.dart +++ b/lib/widgets/shared/expandable-widget-header-body.dart @@ -3,22 +3,19 @@ import 'package:flutter/material.dart'; class HeaderBodyExpandableNotifier extends StatefulWidget { final Widget? headerWidget; - final Widget? bodyWidget; + final Widget bodyWidget; final Widget? collapsed; final bool isExpand; bool expandFlag = false; - var controller = new ExpandableController(); + var controller = ExpandableController(); - HeaderBodyExpandableNotifier( - {this.headerWidget, this.bodyWidget, this.collapsed, this.isExpand = false}); + HeaderBodyExpandableNotifier({this.headerWidget, required this.bodyWidget, this.collapsed, this.isExpand = false}); @override - _HeaderBodyExpandableNotifierState createState() => - _HeaderBodyExpandableNotifierState(); + _HeaderBodyExpandableNotifierState createState() => _HeaderBodyExpandableNotifierState(); } -class _HeaderBodyExpandableNotifierState - extends State { +class _HeaderBodyExpandableNotifierState extends State { @override void initState() { super.initState(); @@ -50,7 +47,7 @@ class _HeaderBodyExpandableNotifierState ), // header: widget.headerWidget, collapsed: Container(), - expanded: widget.bodyWidget!, + expanded: widget.bodyWidget, builder: (_, collapsed, expanded) { return Padding( padding: EdgeInsets.only(left: 0, right: 0, bottom: 0),