diff --git a/lib/core/service/patient_medical_file/soap/SOAP_service.dart b/lib/core/service/patient_medical_file/soap/SOAP_service.dart index 57a54ed0..ec127f8b 100644 --- a/lib/core/service/patient_medical_file/soap/SOAP_service.dart +++ b/lib/core/service/patient_medical_file/soap/SOAP_service.dart @@ -85,7 +85,7 @@ class SOAPService extends LookupService { print("Success"); }, onFailure: (String error, int statusCode) { hasError = true; - super.error = error; + super.error = super.error+ "\n"+error; }, body: postAllergyRequestModel.toJson()); } @@ -97,13 +97,14 @@ class SOAPService extends LookupService { print("Success"); }, onFailure: (String error, int statusCode) { hasError = true; - super.error = error; + super.error =super.error + "\n"+error; }, body: postHistoriesRequestModel.toJson()); } Future postChiefComplaint( PostChiefComplaintRequestModel postChiefComplaintRequestModel) async { hasError = false; + super.error =""; await baseAppClient.post(POST_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { print("Success"); @@ -157,7 +158,7 @@ class SOAPService extends LookupService { print("Success"); }, onFailure: (String error, int statusCode) { hasError = true; - super.error = error; + super.error = "\n"+error; }, body: patchAllergyRequestModel.toJson()); } @@ -169,13 +170,14 @@ class SOAPService extends LookupService { print("Success"); }, onFailure: (String error, int statusCode) { hasError = true; - super.error = error; + super.error = super.error +"\n"+error; }, body: patchHistoriesRequestModel.toJson()); } Future patchChiefComplaint( PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async { hasError = false; + super.error =""; await baseAppClient.post(PATCH_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { print("Success"); diff --git a/lib/core/viewModel/PatientSearchViewModel.dart b/lib/core/viewModel/PatientSearchViewModel.dart index 29bbc6aa..43d8b221 100644 --- a/lib/core/viewModel/PatientSearchViewModel.dart +++ b/lib/core/viewModel/PatientSearchViewModel.dart @@ -14,26 +14,39 @@ import 'base_view_model.dart'; class PatientSearchViewModel extends BaseViewModel { OutPatientService _outPatientService = locator(); - SpecialClinicsService _specialClinicsService = locator(); + SpecialClinicsService _specialClinicsService = + locator(); List get patientList => _outPatientService.patientList; - List get specialClinicalCareMappingList => - _specialClinicsService.specialClinicalCareMappingList; + + List + get specialClinicalCareMappingList => + _specialClinicsService.specialClinicalCareMappingList; List filterData = []; DateTime selectedFromDate; DateTime selectedToDate; + int firstSubsetIndex = 0; + int inPatientPageSize = 20; + int lastSubsetIndex = 19; + + List myInpatientClinicList = []; + searchData(String str) { var strExist = str.length > 0 ? true : false; if (strExist) { filterData = []; for (var i = 0; i < _outPatientService.patientList.length; i++) { - String firstName = _outPatientService.patientList[i].firstName.toUpperCase(); - String lastName = _outPatientService.patientList[i].lastName.toUpperCase(); - String mobile = _outPatientService.patientList[i].mobileNumber.toUpperCase(); - String patientID = _outPatientService.patientList[i].patientId.toString(); + String firstName = + _outPatientService.patientList[i].firstName.toUpperCase(); + String lastName = + _outPatientService.patientList[i].lastName.toUpperCase(); + String mobile = + _outPatientService.patientList[i].mobileNumber.toUpperCase(); + String patientID = + _outPatientService.patientList[i].patientId.toString(); if (firstName.contains(str.toUpperCase()) || lastName.contains(str.toUpperCase()) || @@ -49,7 +62,8 @@ class PatientSearchViewModel extends BaseViewModel { } } - getOutPatient(PatientSearchRequestModel patientSearchRequestModel, {bool isLocalBusy = false}) async { + getOutPatient(PatientSearchRequestModel patientSearchRequestModel, + {bool isLocalBusy = false}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else { @@ -81,9 +95,11 @@ class PatientSearchViewModel extends BaseViewModel { setState(ViewState.Idle); } - getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel, {bool isLocalBusy = false}) async { + getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel, + {bool isLocalBusy = false}) async { setState(ViewState.Busy); - await _outPatientService.getPatientFileInformation(patientSearchRequestModel); + await _outPatientService + .getPatientFileInformation(patientSearchRequestModel); if (_outPatientService.hasError) { error = _outPatientService.error; setState(ViewState.Error); @@ -102,21 +118,32 @@ class PatientSearchViewModel extends BaseViewModel { String dateTo; String dateFrom; if (OutPatientFilterType.Previous == outPatientFilterType) { - selectedFromDate = DateTime(DateTime.now().year, DateTime.now().month - 1, DateTime.now().day); - selectedToDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day - 1); + selectedFromDate = DateTime( + DateTime.now().year, DateTime.now().month - 1, DateTime.now().day); + selectedToDate = DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day - 1); dateTo = AppDateUtils.convertDateToFormat(selectedToDate, 'yyyy-MM-dd'); - dateFrom = AppDateUtils.convertDateToFormat(selectedFromDate, 'yyyy-MM-dd'); + dateFrom = + AppDateUtils.convertDateToFormat(selectedFromDate, 'yyyy-MM-dd'); } else if (OutPatientFilterType.NextWeek == outPatientFilterType) { dateTo = AppDateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 6), 'yyyy-MM-dd'); + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 6), + 'yyyy-MM-dd'); dateFrom = AppDateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day + 1), 'yyyy-MM-dd'); + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 1), + 'yyyy-MM-dd'); } else { dateFrom = AppDateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day), 'yyyy-MM-dd'); + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); dateTo = AppDateUtils.convertDateToFormat( - DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day), 'yyyy-MM-dd'); + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); } PatientSearchRequestModel currentModel = PatientSearchRequestModel(); currentModel.patientID = patientSearchRequestModel.patientID; @@ -130,11 +157,13 @@ class PatientSearchViewModel extends BaseViewModel { filterData = _outPatientService.patientList; } - PatientInPatientService _inPatientService = locator(); + PatientInPatientService _inPatientService = + locator(); List get inPatientList => _inPatientService.inPatientList; - List get myIinPatientList => _inPatientService.myInPatientList; + List get myIinPatientList => + _inPatientService.myInPatientList; List filteredInPatientItems = List(); @@ -146,7 +175,8 @@ class PatientSearchViewModel extends BaseViewModel { } else { setState(ViewState.Busy); } - if (inPatientList.length == 0) await _inPatientService.getInPatientList(requestModel, false); + if (inPatientList.length == 0) + await _inPatientService.getInPatientList(requestModel, false); if (_inPatientService.hasError) { error = _inPatientService.error; if (isLocalBusy) { @@ -156,6 +186,8 @@ class PatientSearchViewModel extends BaseViewModel { } } else { setDefaultInPatientList(); + + generateMyInpatientClinicList(); setState(ViewState.Idle); } } @@ -163,10 +195,12 @@ class PatientSearchViewModel extends BaseViewModel { sortInPatient({bool isDes = false}) { if (isDes) filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => - b.admissionDateWithDateTimeForm.compareTo(a.admissionDateWithDateTimeForm)); + b.admissionDateWithDateTimeForm + .compareTo(a.admissionDateWithDateTimeForm)); else filteredInPatientItems.sort((PatiantInformtion a, PatiantInformtion b) => - a.admissionDateWithDateTimeForm.compareTo(b.admissionDateWithDateTimeForm)); + a.admissionDateWithDateTimeForm + .compareTo(b.admissionDateWithDateTimeForm)); setState(ViewState.Idle); } @@ -174,10 +208,59 @@ class PatientSearchViewModel extends BaseViewModel { setState(ViewState.BusyLocal); await getDoctorProfile(); filteredInPatientItems.clear(); - if (inPatientList.length > 0) filteredInPatientItems.addAll(inPatientList); + firstSubsetIndex = 0; + lastSubsetIndex = inPatientPageSize - 1; + if (inPatientList.length > 0) + filteredInPatientItems + .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); setState(ViewState.Idle); } + generateMyInpatientClinicList() { + inPatientList.forEach((element) { + if(!myInpatientClinicList.contains(element.clinicDescription)) { + myInpatientClinicList.add(element.clinicDescription); + } + }); + } + + addOnFilteredList() { + if (lastSubsetIndex < inPatientList.length) { + firstSubsetIndex = firstSubsetIndex + + (inPatientList.length - lastSubsetIndex < inPatientPageSize - 1 + ? inPatientList.length - lastSubsetIndex + : inPatientPageSize - 1); + lastSubsetIndex = lastSubsetIndex + + (inPatientList.length - lastSubsetIndex < inPatientPageSize - 1 + ? inPatientList.length - lastSubsetIndex + : inPatientPageSize - 1); + filteredInPatientItems + .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); + setState(ViewState.Idle); + } + } + + + filterByHospital({ int hospitalId}) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + if (inPatientList[i].projectId == hospitalId) { + filteredInPatientItems.add(inPatientList[i]); + } + } + notifyListeners(); + } + + filterByClinic({ String clinicName}) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + if (inPatientList[i].clinicDescription == clinicName) { + filteredInPatientItems.add(inPatientList[i]); + } + } + notifyListeners(); + } + void clearPatientList() { _inPatientService.inPatientList = []; _inPatientService.myInPatientList = []; @@ -208,7 +291,8 @@ class PatientSearchViewModel extends BaseViewModel { } } - getSpecialClinicalCareMappingList(clinicId, {bool isLocalBusy = false}) async { + getSpecialClinicalCareMappingList(clinicId, + {bool isLocalBusy = false}) async { if (isLocalBusy) { setState(ViewState.BusyLocal); } else { diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 78c309ca..83cd43e3 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -28,7 +28,9 @@ import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_mode import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_examination.dart'; +import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_history.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/assessment/assessment_call_back.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/objective/objective_call_back.dart'; @@ -199,38 +201,6 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { - setState(ViewState.BusyLocal); - await _SOAPService.postAllergy(postAllergyRequestModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - - Future postHistories( - PostHistoriesRequestModel postHistoriesRequestModel) async { - setState(ViewState.BusyLocal); - await _SOAPService.postHistories(postHistoriesRequestModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - - Future postChiefComplaint( - PostChiefComplaintRequestModel postChiefComplaintRequestModel) async { - setState(ViewState.BusyLocal); - await _SOAPService.postChiefComplaint(postChiefComplaintRequestModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - Future postPhysicalExam( PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { setState(ViewState.BusyLocal); @@ -264,38 +234,6 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future patchAllergy(PostAllergyRequestModel patchAllergyRequestModel) async { - setState(ViewState.BusyLocal); - await _SOAPService.patchAllergy(patchAllergyRequestModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - - Future patchHistories( - PostHistoriesRequestModel patchHistoriesRequestModel) async { - setState(ViewState.BusyLocal); - await _SOAPService.patchHistories(patchHistoriesRequestModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - - Future patchChiefComplaint( - PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async { - setState(ViewState.BusyLocal); - await _SOAPService.patchChiefComplaint(patchChiefComplaintRequestModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); - } else - setState(ViewState.Idle); - } - Future patchPhysicalExam( PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async { setState(ViewState.BusyLocal); @@ -361,28 +299,6 @@ class SOAPViewModel extends BaseViewModel { return allergiesString; } - Future getPatientHistories(GetHistoryReqModel getHistoryReqModel, - {bool isFirst = false}) async { - setState(ViewState.Busy); - await _SOAPService.getPatientHistories(getHistoryReqModel, - isFirst: isFirst); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.Error); - } else - setState(ViewState.Idle); - } - - Future getPatientChiefComplaint( - GetChiefComplaintReqModel getChiefComplaintReqModel) async { - setState(ViewState.Busy); - await _SOAPService.getPatientChiefComplaint(getChiefComplaintReqModel); - if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.Error); - } else - setState(ViewState.Idle); - } Future getPatientPhysicalExam( PatiantInformtion patientInfo, @@ -742,20 +658,16 @@ class SOAPViewModel extends BaseViewModel { } } if (allMedicationList.length == 0) { - await getMedicationList(); if (services == null) { - services = [ - _prescriptionService.getMedicationList() - ]; + services = [_prescriptionService.getMedicationList()]; } else { - services.add( - _prescriptionService.getMedicationList()); + services.add(_prescriptionService.getMedicationList()); } } final results = await Future.wait(services ?? []); - if (_SOAPService.hasError ||_prescriptionService.hasError ) { + if (_SOAPService.hasError || _prescriptionService.hasError) { error = _SOAPService.error + _prescriptionService.error; setState(ViewState.ErrorLocal); } else @@ -763,8 +675,7 @@ class SOAPViewModel extends BaseViewModel { } callAddAssessmentLookupsServices({bool allowSetState = true}) async { - if(allowSetState) - setState(ViewState.Busy); + if (allowSetState) setState(ViewState.Busy); var services; if (listOfDiagnosisCondition.length == 0) { if (services == null) { @@ -782,59 +693,177 @@ class SOAPViewModel extends BaseViewModel { _SOAPService.getMasterLookup(MasterKeysService.DiagnosisType) ]; } else { - services.add(_SOAPService.getMasterLookup( - MasterKeysService.DiagnosisType)); + services + .add(_SOAPService.getMasterLookup(MasterKeysService.DiagnosisType)); } } if (listOfICD10.length == 0) { if (services == null) { - services = [ - _SOAPService.getMasterLookup(MasterKeysService.ICD10) - ]; + services = [_SOAPService.getMasterLookup(MasterKeysService.ICD10)]; } else { - services.add( - _SOAPService.getMasterLookup(MasterKeysService.ICD10)); + services.add(_SOAPService.getMasterLookup(MasterKeysService.ICD10)); } } final results = await Future.wait(services ?? []); - if(allowSetState) { + if (allowSetState) { if (_SOAPService.hasError) { error = _SOAPService.error; setState(ViewState.ErrorLocal); } else setState(ViewState.Idle); } - } onUpdateAssessmentStepStart(PatiantInformtion patientInfo) async { - GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( patientMRN: patientInfo.patientMRN, episodeID: patientInfo.episodeNo.toString(), editedBy: '', doctorID: '', - appointmentNo: - int.parse(patientInfo.appointmentNo.toString())); + appointmentNo: int.parse(patientInfo.appointmentNo.toString())); - var services = [ - _SOAPService.getPatientAssessment(getAssessmentReqModel) - ]; + var services = [_SOAPService.getPatientAssessment(getAssessmentReqModel)]; final results = await Future.wait(services); - if (patientAssessmentList.isNotEmpty) { await callAddAssessmentLookupsServices(allowSetState: false); } if (_SOAPService.hasError) { - error = _SOAPService.error; - setState(ViewState.ErrorLocal); + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + postSubjectServices( + {patientInfo, + String complaintsText, + String medicationText, + String illnessText, + List myHistoryList, + List myAllergiesList}) async { + var services; + + PostChiefComplaintRequestModel postChiefComplaintRequestModel = + createPostChiefComplaintRequestModel( + patientInfo: patientInfo, + illnessText: illnessText, + medicationText: medicationText, + complaintsText: complaintsText); + if (patientChiefComplaintList.isEmpty) { + postChiefComplaintRequestModel.editedBy = ''; + services = [ + _SOAPService.postChiefComplaint(postChiefComplaintRequestModel) + ]; + } else { + postChiefComplaintRequestModel.editedBy = ''; + services = [ + _SOAPService.patchChiefComplaint(postChiefComplaintRequestModel) + ]; + } + + if (myHistoryList.length != 0) { + PostHistoriesRequestModel postHistoriesRequestModel = + createPostHistoriesRequestModel( + patientInfo: patientInfo, myHistoryList: myHistoryList); + + if (patientHistoryList.isEmpty) { + services.add(_SOAPService.postHistories(postHistoriesRequestModel)); + } else { + services.add(_SOAPService.patchHistories(postHistoriesRequestModel)); + } + } + + if (myAllergiesList.length != 0) { + PostAllergyRequestModel postAllergyRequestModel =createPostAllergyRequestModel (myAllergiesList:myAllergiesList, patientInfo: patientInfo); + if (patientAllergiesList.isEmpty) { + services.add(_SOAPService.postAllergy(postAllergyRequestModel)); + } else { + services.add(_SOAPService.patchAllergy(postAllergyRequestModel)); + } + + } + + final results = await Future.wait(services); + + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); } else - setState(ViewState.Idle); + setState(ViewState.Idle); + } + + PostChiefComplaintRequestModel createPostChiefComplaintRequestModel( + {patientInfo, + String complaintsText, + String medicationText, + String illnessText}) { + return new PostChiefComplaintRequestModel( + admissionNo: patientInfo.admissionNo != null + ? int.parse(patientInfo.admissionNo) + : null, + patientMRN: patientInfo.patientMRN, + episodeID: patientInfo.episodeNo ?? 0, + appointmentNo: patientInfo.appointmentNo ?? 0, + chiefComplaint: complaintsText, + currentMedication: medicationText, + hopi: illnessText, + isLactation: false, + ispregnant: false, + doctorID: '', + numberOfWeeks: 0); + } + + PostHistoriesRequestModel createPostHistoriesRequestModel( + {patientInfo, List myHistoryList}) { + PostHistoriesRequestModel postHistoriesRequestModel = + new PostHistoriesRequestModel(doctorID: ''); + myHistoryList.forEach((history) { + if (postHistoriesRequestModel.listMedicalHistoryVM == null) + postHistoriesRequestModel.listMedicalHistoryVM = []; + postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM( + patientMRN: patientInfo.patientMRN, + episodeId: patientInfo.episodeNo, + appointmentNo: patientInfo.appointmentNo, + remarks: "", + historyId: history.selectedHistory.id, + historyType: history.selectedHistory.typeId, + isChecked: history.isChecked, + )); + }); + + return postHistoriesRequestModel; + } + + + PostAllergyRequestModel createPostAllergyRequestModel({myAllergiesList, patientInfo}){ + PostAllergyRequestModel postAllergyRequestModel = + new PostAllergyRequestModel(); + myAllergiesList.forEach((allergy) { + if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == + null) + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add( + ListHisProgNotePatientAllergyDiseaseVM( + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.typeId, + patientMRN: patientInfo.patientMRN, + episodeId: patientInfo.episodeNo, + appointmentNo: patientInfo.appointmentNo, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: allergy.createdBy ?? doctorProfile.doctorID, + createdOn: DateTime.now().toIso8601String(), + editedBy: doctorProfile.doctorID, + editedOn: DateTime.now().toIso8601String(), + isChecked: allergy.isChecked, + isUpdatedByNurse: false)); + }); + return postAllergyRequestModel; } } diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 32a842d3..93fe0a21 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -12,7 +12,7 @@ import 'package:doctor_app_flutter/screens/home/dashboard_swipe_widget.dart'; import 'package:doctor_app_flutter/screens/home/home_patient_card.dart'; import 'package:doctor_app_flutter/screens/live_care/live_care_patient_screen.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; -import 'package:doctor_app_flutter/screens/patients/PatientsInPatientScreen.dart'; +import 'package:doctor_app_flutter/screens/patients/In_patient/in_patient_screen.dart'; import 'package:doctor_app_flutter/screens/patients/out_patient/out_patient_screen.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/referral/patient_referral_screen.dart'; @@ -371,7 +371,7 @@ class _HomeScreenState extends State { Navigator.push( context, FadePage( - page: PatientInPatientScreen( + page: InPatientScreen( specialClinic: model.getSpecialClinic( clinicId ?? projectsProvider.doctorClinicsList[0].clinicID), ), diff --git a/lib/screens/patients/InPatientPage.dart b/lib/screens/patients/InPatientPage.dart index b5723c5e..e69de29b 100644 --- a/lib/screens/patients/InPatientPage.dart +++ b/lib/screens/patients/InPatientPage.dart @@ -1,248 +0,0 @@ -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.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/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/loader/gif_loader_container.dart'; -import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; -import 'package:flutter/material.dart'; -import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - -import '../../routes.dart'; - -class InPatientPage extends StatefulWidget { - final bool isMyInPatient; - final PatientSearchViewModel patientSearchViewModel; - - InPatientPage(this.isMyInPatient, this.patientSearchViewModel); - - @override - _InPatientPageState createState() => _InPatientPageState(); -} - -class _InPatientPageState extends State { - TextEditingController _searchController = TextEditingController(); - - bool isSortDes = false; - - @override - void dispose() { - _searchController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return AppScaffold( - baseViewModel: widget.patientSearchViewModel, - isShowAppBar: false, - body: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - height: MediaQuery.of(context).size.height * 0.070, - ), - Container( - margin: EdgeInsets.all(16.0), - child: Stack( - children: [ - AppTextFieldCustom( - hintText: TranslationBase.of(context).searchPatientName, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.black, - ), - onPressed: () {}, - ), - controller: _searchController, - onChanged: (value) { - widget.patientSearchViewModel.filterSearchResults(value); - }), - Positioned( - right: 35, - top: 5, - child: IconButton( - icon: Icon( - isSortDes - ? FontAwesomeIcons.sortAmountDown - : FontAwesomeIcons.sortAmountUp, - color: Colors.black, - ), - iconSize: 20, - // padding: EdgeInsets.only(bottom: 30), - onPressed: () { - GifLoaderDialogUtils.showMyDialog(context); - widget.patientSearchViewModel - .sortInPatient(isDes: isSortDes); - isSortDes = !isSortDes; - GifLoaderDialogUtils.hideDialog(context); - }, - ), - ) - ], - ), - ), - widget.patientSearchViewModel.state == ViewState.Idle - ? widget.patientSearchViewModel.filteredInPatientItems.length > 0 - ? (widget.isMyInPatient && - widget.patientSearchViewModel.myIinPatientList - .length == - 0) - ? NoData() - : Expanded( - child: Container( - margin: EdgeInsets.symmetric(horizontal: 16.0), - child: SingleChildScrollView( - child: Column( - // mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ListView.builder( - itemCount: widget.patientSearchViewModel - .filteredInPatientItems.length, - scrollDirection: Axis.vertical, - physics: ScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) { - if (!widget.isMyInPatient) - return PatientCard( - patientInfo: widget - .patientSearchViewModel - .filteredInPatientItems[index], - patientType: "1", - arrivalType: "1", - isInpatient: true, - isMyPatient: widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID, - onTap: () { - FocusScopeNode currentFocus = - FocusScope.of(context); - if (!currentFocus - .hasPrimaryFocus) { - currentFocus.unfocus(); - } - - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": widget - .patientSearchViewModel - .filteredInPatientItems[index], - "patientType": "1", - "from": "0", - "to": "0", - "isSearch": false, - "isInpatient": true, - "arrivalType": "1", - "isMyPatient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget - .patientSearchViewModel - .doctorProfile - .doctorID, - }); - }, - ); - else if (widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID && - widget.isMyInPatient) - return PatientCard( - patientInfo: widget - .patientSearchViewModel - .filteredInPatientItems[index], - patientType: "1", - arrivalType: "1", - isInpatient: true, - isMyPatient: widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget.patientSearchViewModel - .doctorProfile.doctorID, - onTap: () { - FocusScopeNode currentFocus = - FocusScope.of(context); - if (!currentFocus - .hasPrimaryFocus) { - currentFocus.unfocus(); - } - - Navigator.of(context).pushNamed( - PATIENTS_PROFILE, - arguments: { - "patient": widget - .patientSearchViewModel - .filteredInPatientItems[index], - "patientType": "1", - "from": "0", - "to": "0", - "isSearch": false, - "isInpatient": true, - "arrivalType": "1", - "isMyPatient": widget - .patientSearchViewModel - .filteredInPatientItems[ - index] - .doctorId == - widget - .patientSearchViewModel - .doctorProfile - .doctorID, - }); - }, - ); - else - return SizedBox(); - }), - SizedBox( - height: 15, - ) - ], - ), - ), - ), - ) - : NoData() - : NoData(), - ], - ), - ); - } -} - -class NoData extends StatelessWidget { - const NoData({ - Key key, - }) : super(key: key); - - @override - Widget build(BuildContext context) { - return Expanded( - child: SingleChildScrollView( - child: Container( - child: ErrorMessage( - error: TranslationBase.of(context).noDataAvailable)), - ), - ); - } -} diff --git a/lib/screens/patients/In_patient/in_patient_list_page.dart b/lib/screens/patients/In_patient/in_patient_list_page.dart new file mode 100644 index 00000000..80acb88d --- /dev/null +++ b/lib/screens/patients/In_patient/in_patient_list_page.dart @@ -0,0 +1,370 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.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/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/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_container.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +import '../../../routes.dart'; + +class InPatientListPage extends StatefulWidget { + final bool isMyInPatient; + final PatientSearchViewModel patientSearchViewModel; + + InPatientListPage(this.isMyInPatient, this.patientSearchViewModel); + + @override + _InPatientListPageState createState() => _InPatientListPageState(); +} + +class _InPatientListPageState extends State { + TextEditingController _searchController = TextEditingController(); + + bool isSortDes = false; + bool isAllClinic = true; + bool showBottomSheet = false; + String selectedClinicName; + + @override + void dispose() { + _searchController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + baseViewModel: widget.patientSearchViewModel, + isShowAppBar: false, + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // Container( + // height: MediaQuery.of(context).size.height * 0.070, + // ), + Container( + margin: EdgeInsets.symmetric(horizontal: 14.0, vertical: 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + InkWell( + child: Row( + children: [ + Radio( + value: 1, + groupValue: isAllClinic ? 1 : 2, + onChanged: (value) { + setState(() { + setState(() { + isAllClinic = true; + showBottomSheet = false; + }); + widget.patientSearchViewModel + .setDefaultInPatientList(); + }); + }, + activeColor: Colors.red, + ), + AppText("All Clinic", fontSize: 15,), + ], + ), + onTap: () { + setState(() { + isAllClinic = true; + showBottomSheet = false; + }); + widget.patientSearchViewModel.setDefaultInPatientList(); + }, + ), + InkWell( + onTap: () { + setState(() { + isAllClinic = false; + showBottomSheet = true; + }); + }, + child: Row( + children: [ + Radio( + value: 2, + groupValue: isAllClinic ? 1 : 2, + onChanged: (value) { + setState(() { + setState(() { + isAllClinic = false; + showBottomSheet = true; + }); + }); + }, + activeColor: Colors.red, + ), + AppText(selectedClinicName ?? "Select Clinic", fontSize: 15,), + Container( + margin: EdgeInsets.only(bottom: 10), + child: Icon(FontAwesomeIcons.sortDown)) + ], + )), + ], + ), + ), + Container( + margin: EdgeInsets.all(16.0), + child: Stack( + children: [ + AppTextFieldCustom( + hintText: TranslationBase.of(context).searchPatientName, + isTextFieldHasSuffix: true, + suffixIcon: IconButton( + icon: Icon( + Icons.search, + color: Colors.black, + ), + onPressed: () {}, + ), + controller: _searchController, + onChanged: (value) { + widget.patientSearchViewModel.filterSearchResults(value); + }), + Positioned( + right: 35, + top: 5, + child: IconButton( + icon: Icon( + isSortDes + ? FontAwesomeIcons.sortAmountDown + : FontAwesomeIcons.sortAmountUp, + color: Colors.black, + ), + iconSize: 20, + // padding: EdgeInsets.only(bottom: 30), + onPressed: () { + GifLoaderDialogUtils.showMyDialog(context); + widget.patientSearchViewModel + .sortInPatient(isDes: isSortDes); + isSortDes = !isSortDes; + GifLoaderDialogUtils.hideDialog(context); + }, + ), + ) + ], + ), + ), + widget.patientSearchViewModel.state == ViewState.Idle + ? widget.patientSearchViewModel.filteredInPatientItems.length > 0 + ? (widget.isMyInPatient && + widget.patientSearchViewModel.myIinPatientList + .length == + 0) + ? NoData() + : Expanded( + child: Container( + margin: EdgeInsets.symmetric(horizontal: 16.0), + child: NotificationListener( + child: ListView.builder( + itemCount: widget.patientSearchViewModel + .filteredInPatientItems.length, + scrollDirection: Axis.vertical, + // physics: ScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + if (!widget.isMyInPatient) + return PatientCard( + patientInfo: widget + .patientSearchViewModel + .filteredInPatientItems[index], + patientType: "1", + arrivalType: "1", + isInpatient: true, + isMyPatient: widget + .patientSearchViewModel + .filteredInPatientItems[index] + .doctorId == + widget.patientSearchViewModel + .doctorProfile.doctorID, + onTap: () { + FocusScopeNode currentFocus = + FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + + Navigator.of(context).pushNamed( + PATIENTS_PROFILE, + arguments: { + "patient": widget + .patientSearchViewModel + .filteredInPatientItems[ + index], + "patientType": "1", + "from": "0", + "to": "0", + "isSearch": false, + "isInpatient": true, + "arrivalType": "1", + "isMyPatient": widget + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == + widget + .patientSearchViewModel + .doctorProfile + .doctorID, + }); + }, + ); + else if (widget + .patientSearchViewModel + .filteredInPatientItems[index] + .doctorId == + widget.patientSearchViewModel + .doctorProfile.doctorID && + widget.isMyInPatient) + return PatientCard( + patientInfo: widget + .patientSearchViewModel + .filteredInPatientItems[index], + patientType: "1", + arrivalType: "1", + isInpatient: true, + isMyPatient: widget + .patientSearchViewModel + .filteredInPatientItems[index] + .doctorId == + widget.patientSearchViewModel + .doctorProfile.doctorID, + onTap: () { + FocusScopeNode currentFocus = + FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } + + Navigator.of(context).pushNamed( + PATIENTS_PROFILE, + arguments: { + "patient": widget + .patientSearchViewModel + .filteredInPatientItems[ + index], + "patientType": "1", + "from": "0", + "to": "0", + "isSearch": false, + "isInpatient": true, + "arrivalType": "1", + "isMyPatient": widget + .patientSearchViewModel + .filteredInPatientItems[ + index] + .doctorId == + widget + .patientSearchViewModel + .doctorProfile + .doctorID, + }); + }, + ); + else + return SizedBox(); + }), + onNotification: (t) { + if (isAllClinic) if (t + is ScrollUpdateNotification && + t.metrics.pixels >= + t.metrics.maxScrollExtent - 50) { + widget.patientSearchViewModel + .addOnFilteredList(); + } + return; + }, + ), + ), + ) + : NoData() + : Center( + child: Container( + height: 300, + width: 300, + ), + ), + ], + ), + bottomSheet: !showBottomSheet + ? Container( + height: 0, + ) + : Container( + height: 500, + color: Colors.white, + child: ListView.builder( + itemCount: widget + .patientSearchViewModel.myInpatientClinicList.length, + scrollDirection: Axis.vertical, + physics: ScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return InkWell( + onTap: () { + setState(() { + isAllClinic = false; + showBottomSheet = false; + selectedClinicName = widget.patientSearchViewModel + .myInpatientClinicList[index]; + }); + widget.patientSearchViewModel.filterByClinic( + clinicName: widget.patientSearchViewModel + .myInpatientClinicList[index]); + }, + child: Row( + children: [ + Radio( + value: widget.patientSearchViewModel + .myInpatientClinicList[index], + groupValue: selectedClinicName, + onChanged: (value) { + setState(() { + setState(() { + isAllClinic = false; + showBottomSheet = false; + }); + widget.patientSearchViewModel + .filterByClinic(clinicName: value); + }); + }, + activeColor: Colors.red, + ), + AppText(widget.patientSearchViewModel + .myInpatientClinicList[index]), + ], + )); + }), + ), + ); + } +} + +class NoData extends StatelessWidget { + const NoData({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded( + child: SingleChildScrollView( + child: Container( + child: ErrorMessage( + error: TranslationBase.of(context).noDataAvailable)), + ), + ); + } +} diff --git a/lib/screens/patients/PatientsInPatientScreen.dart b/lib/screens/patients/In_patient/in_patient_screen.dart similarity index 96% rename from lib/screens/patients/PatientsInPatientScreen.dart rename to lib/screens/patients/In_patient/in_patient_screen.dart index f094f71a..1a35ad53 100644 --- a/lib/screens/patients/PatientsInPatientScreen.dart +++ b/lib/screens/patients/In_patient/in_patient_screen.dart @@ -14,19 +14,19 @@ import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils. import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'DischargedPatientPage.dart'; -import 'InPatientPage.dart'; +import '../DischargedPatientPage.dart'; +import 'in_patient_list_page.dart'; -class PatientInPatientScreen extends StatefulWidget { +class InPatientScreen extends StatefulWidget { GetSpecialClinicalCareListResponseModel specialClinic; - PatientInPatientScreen({Key key, this.specialClinic}); + InPatientScreen({Key key, this.specialClinic}); @override - _PatientInPatientScreenState createState() => _PatientInPatientScreenState(); + _InPatientScreenState createState() => _InPatientScreenState(); } -class _PatientInPatientScreenState extends State +class _InPatientScreenState extends State with SingleTickerProviderStateMixin { TabController _tabController; int _activeTab = 0; @@ -221,7 +221,7 @@ class _PatientInPatientScreenState extends State ), Expanded( child: Scaffold( - extendBodyBehindAppBar: true, + extendBodyBehindAppBar: false, appBar: PreferredSize( preferredSize: Size.fromHeight( MediaQuery.of(context).size.height * 0.070), @@ -266,8 +266,8 @@ class _PatientInPatientScreenState extends State physics: BouncingScrollPhysics(), controller: _tabController, children: [ - InPatientPage(false, model), - InPatientPage(true,model), + InPatientListPage(false, model), + InPatientListPage(true,model), DischargedPatient(), ], ), diff --git a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart index a0cdb39c..53447743 100644 --- a/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart +++ b/lib/screens/patients/profile/soap_update/assessment/add_assessment_details.dart @@ -1,7 +1,6 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart index 51afcd1f..8d29150e 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_step_header.dart @@ -21,7 +21,7 @@ class SOAPStepHeader extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: SizeConfig.isHeightVeryShort?30: 15,), + SizedBox(height: SizeConfig.isHeightVeryShort?30:SizeConfig.isHeightShort?35: 15,), AppText( TranslationBase.of(context).createNew, fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge? 3: 4), 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 553c2f17..db31fb95 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 @@ -1,7 +1,6 @@ // ignore: must_be_immutable import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 72579790..fd5e6b45 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -1,16 +1,9 @@ -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; -import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart'; -import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_history.dart'; -import 'package:doctor_app_flutter/models/doctor/doctor_profile_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/screens/patients/profile/soap_update/soap_utils.dart'; @@ -33,13 +26,18 @@ class UpdateSubjectivePage extends StatefulWidget { final int currentIndex; UpdateSubjectivePage( - {Key key, this.changePageViewIndex, this.patientInfo, this.changeLoadingState, this.currentIndex}); + {Key key, + this.changePageViewIndex, + this.patientInfo, + this.changeLoadingState, + this.currentIndex}); @override _UpdateSubjectivePageState createState() => _UpdateSubjectivePageState(); } -class _UpdateSubjectivePageState extends State implements SubjectiveCallBack { +class _UpdateSubjectivePageState extends State + implements SubjectiveCallBack { bool isChiefExpand = false; bool isHistoryExpand = false; bool isAllergiesExpand = false; @@ -55,7 +53,8 @@ class _UpdateSubjectivePageState extends State implements widget.changeLoadingState(true); if (model.patientHistoryList.isNotEmpty) { model.patientHistoryList.forEach((element) { - if (element.historyType == MasterKeysService.HistoryFamily.getMasterKeyService()) { + if (element.historyType == + MasterKeysService.HistoryFamily.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistoryFamily, id: element.historyId, @@ -63,11 +62,15 @@ class _UpdateSubjectivePageState extends State implements if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); + history: history, + isChecked: element.isChecked, + remark: element.remarks, + isLocal: false); myHistoryList.add(mySelectedHistory); } } - if (element.historyType == MasterKeysService.HistoryMedical.getMasterKeyService()) { + if (element.historyType == + MasterKeysService.HistoryMedical.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistoryMedical, id: element.historyId, @@ -75,11 +78,15 @@ class _UpdateSubjectivePageState extends State implements if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); + history: history, + isChecked: element.isChecked, + remark: element.remarks, + isLocal: false); myHistoryList.add(mySelectedHistory); } } - if (element.historyType == MasterKeysService.HistorySports.getMasterKeyService()) { + if (element.historyType == + MasterKeysService.HistorySports.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistorySports, id: element.historyId, @@ -87,11 +94,15 @@ class _UpdateSubjectivePageState extends State implements if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); + history: history, + isChecked: element.isChecked, + remark: element.remarks, + isLocal: false); myHistoryList.add(mySelectedHistory); } } - if (element.historyType == MasterKeysService.HistorySurgical.getMasterKeyService()) { + if (element.historyType == + MasterKeysService.HistorySurgical.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistorySurgical, id: element.historyId, @@ -99,7 +110,10 @@ class _UpdateSubjectivePageState extends State implements if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); + history: history, + isChecked: element.isChecked, + remark: element.remarks, + isLocal: false); myHistoryList.add(mySelectedHistory); } } @@ -108,15 +122,19 @@ class _UpdateSubjectivePageState extends State implements } getAllergies(SOAPViewModel model) async { - if (model.patientAllergiesList.isNotEmpty) { model.patientAllergiesList.forEach((element) { MasterKeyModel selectedAllergy = model.getOneMasterKey( - masterKeys: MasterKeysService.Allergies, id: element.allergyDiseaseId, typeId: element.allergyDiseaseType); + masterKeys: MasterKeysService.Allergies, + id: element.allergyDiseaseId, + typeId: element.allergyDiseaseType); MasterKeyModel selectedAllergySeverity; if (element.severity == 0) { selectedAllergySeverity = MasterKeyModel( - id: 0, typeId: MasterKeysService.AllergySeverity.getMasterKeyService(), nameAr: '', nameEn: ''); + id: 0, + typeId: MasterKeysService.AllergySeverity.getMasterKeyService(), + nameAr: '', + nameEn: ''); } else { selectedAllergySeverity = model.getOneMasterKey( masterKeys: MasterKeysService.AllergySeverity, @@ -124,15 +142,17 @@ class _UpdateSubjectivePageState extends State implements ); } - MySelectedAllergy mySelectedAllergy = SoapUtils.generateMySelectedAllergy( - allergy: selectedAllergy, - isChecked: element.isChecked, - createdBy: element.createdBy, - remark: element.remarks, - isLocal: false, - allergySeverity: selectedAllergySeverity); + MySelectedAllergy mySelectedAllergy = + SoapUtils.generateMySelectedAllergy( + allergy: selectedAllergy, + isChecked: element.isChecked, + createdBy: element.createdBy, + remark: element.remarks, + isLocal: false, + allergySeverity: selectedAllergySeverity); - if (selectedAllergy != null && selectedAllergySeverity != null) myAllergiesList.add(mySelectedAllergy); + if (selectedAllergy != null && selectedAllergySeverity != null) + myAllergiesList.add(mySelectedAllergy); }); } } @@ -148,11 +168,14 @@ class _UpdateSubjectivePageState extends State implements if (model.patientChiefComplaintList.isNotEmpty) { isChiefExpand = true; - complaintsController.text = Helpers.parseHtmlString(model.patientChiefComplaintList[0].chiefComplaint); + complaintsController.text = Helpers.parseHtmlString( + model.patientChiefComplaintList[0].chiefComplaint); illnessController.text = model.patientChiefComplaintList[0].hopi; - medicationController.text = !(model.patientChiefComplaintList[0].currentMedication).isNotEmpty - ? model.patientChiefComplaintList[0].currentMedication + '\n \n' - : model.patientChiefComplaintList[0].currentMedication; + medicationController.text = + !(model.patientChiefComplaintList[0].currentMedication).isNotEmpty + ? model.patientChiefComplaintList[0].currentMedication + + '\n \n' + : model.patientChiefComplaintList[0].currentMedication; } if (widget.patientInfo.admissionNo == null) { await getHistory(model); @@ -200,7 +223,8 @@ class _UpdateSubjectivePageState extends State implements isExpanded: isChiefExpand, ), SizedBox( - height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 4 : 2), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 4 : 2), ), if (widget.patientInfo.admissionNo == null) ExpandableSOAPWidget( @@ -212,12 +236,15 @@ class _UpdateSubjectivePageState extends State implements }); }, child: Column( - children: [UpdateHistoryWidget(myHistoryList: myHistoryList)], + children: [ + UpdateHistoryWidget(myHistoryList: myHistoryList) + ], ), isExpanded: isHistoryExpand, ), SizedBox( - height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 4 : 2), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 4 : 2), ), if (widget.patientInfo.admissionNo == null) ExpandableSOAPWidget( @@ -241,7 +268,8 @@ class _UpdateSubjectivePageState extends State implements isExpanded: isAllergiesExpand, ), SizedBox( - height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 20 : 10), + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 20 : 10), ), ], ), @@ -253,7 +281,9 @@ class _UpdateSubjectivePageState extends State implements } addSubjectiveInfo( - {SOAPViewModel model, List myAllergiesList, List myHistoryList}) async { + {SOAPViewModel model, + List myAllergiesList, + List myHistoryList}) async { if (FocusScope.of(context).hasFocus) FocusScope.of(context).unfocus(); widget.changeLoadingState(true); formKey.currentState.save(); @@ -265,22 +295,15 @@ class _UpdateSubjectivePageState extends State implements if (complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length > 25) { - await postChiefComplaint(model: model); - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } - if (myHistoryList.length != 0) { - await postHistories(model: model, myHistoryList: myHistoryList); - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } - } - if (myAllergiesList.length != 0) { - await postAllergy(myAllergiesList: myAllergiesList, model: model); - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } - } + await model.postSubjectServices( + patientInfo: widget.patientInfo, + complaintsText: complaintsController.text, + medicationText: medicationController.text, + illnessText: illnessController.text, + myHistoryList: myHistoryList, + myAllergiesList: myAllergiesList, + ); + widget.changeLoadingState(true); widget.changePageViewIndex(1); @@ -311,112 +334,11 @@ class _UpdateSubjectivePageState extends State implements } } - postAllergy( - {List myAllergiesList, SOAPViewModel model}) async { - PostAllergyRequestModel postAllergyRequestModel = - new PostAllergyRequestModel(); - - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - myAllergiesList.forEach((allergy) { - if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == - null) - postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; - postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add( - ListHisProgNotePatientAllergyDiseaseVM( - allergyDiseaseId: allergy.selectedAllergy.id, - allergyDiseaseType: allergy.selectedAllergy.typeId, - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - severity: allergy.selectedAllergySeverity.id, - remarks: allergy.remark, - createdBy: allergy.createdBy ?? doctorProfile.doctorID, - createdOn: DateTime.now().toIso8601String(), - editedBy: doctorProfile.doctorID, - editedOn: DateTime.now().toIso8601String(), - isChecked: allergy.isChecked, - isUpdatedByNurse: false)); - }); - if (model.patientAllergiesList.isEmpty) { - await model.postAllergy(postAllergyRequestModel); - } else { - await model.patchAllergy(postAllergyRequestModel); - } - - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } - GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - doctorID: '', - editedBy: ''); - await model.getPatientAllergy(generalGetReqForSOAP, isLocalBusy: true); - - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } - } - - postHistories( - {List myHistoryList, SOAPViewModel model}) async { - PostHistoriesRequestModel postHistoriesRequestModel = - new PostHistoriesRequestModel(doctorID: ''); - myHistoryList.forEach((history) { - if (postHistoriesRequestModel.listMedicalHistoryVM == null) - postHistoriesRequestModel.listMedicalHistoryVM = []; - postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM( - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - remarks: "", - historyId: history.selectedHistory.id, - historyType: history.selectedHistory.typeId, - isChecked: history.isChecked, - )); - }); - - if (model.patientHistoryList.isEmpty) { - await model.postHistories(postHistoriesRequestModel); - } else { - await model.patchHistories(postHistoriesRequestModel); - } - - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(model.error); - } - } - - postChiefComplaint({SOAPViewModel model}) async { - formKey.currentState.save(); - if (formKey.currentState.validate()) { - PostChiefComplaintRequestModel postChiefComplaintRequestModel = new PostChiefComplaintRequestModel( - admissionNo: widget.patientInfo.admissionNo != null ? int.parse(widget.patientInfo.admissionNo) : null, - patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo ?? 0, - appointmentNo: widget.patientInfo.appointmentNo ?? 0, - chiefComplaint: complaintsController.text, - currentMedication: medicationController.text, - hopi: illnessController.text, - isLactation: false, - ispregnant: false, - doctorID: '', - numberOfWeeks: 0); - if (model.patientChiefComplaintList.isEmpty) { - postChiefComplaintRequestModel.editedBy = ''; - await model.postChiefComplaint(postChiefComplaintRequestModel); - } else { - postChiefComplaintRequestModel.editedBy = ''; - await model.patchChiefComplaint(postChiefComplaintRequestModel); - } - } - } - @override Function nextFunction(model) { - addSubjectiveInfo(model: model, myAllergiesList: myAllergiesList, myHistoryList: myHistoryList); + addSubjectiveInfo( + model: model, + myAllergiesList: myAllergiesList, + myHistoryList: myHistoryList); } }