From 0db3617737dcbb786a617522d38fe3c53a039bd9 Mon Sep 17 00:00:00 2001 From: Aamir Date: Tue, 12 Dec 2023 17:04:20 +0300 Subject: [PATCH] Null Safety --- lib/client/base_app_client.dart | 1 - lib/config/config.dart | 2 +- .../radiology/radiology_service.dart | 10 +- lib/core/viewModel/SOAP_view_model.dart | 14 +- .../viewModel/authentication_view_model.dart | 22 +-- .../auth/verification_methods_screen.dart | 4 +- .../radiology/radiology_home_page.dart | 2 +- .../referred-patient-screen.dart | 159 ++++++++---------- .../objective/examination_item_card.dart | 14 +- .../shared_soap_widgets/SOAP_open_items.dart | 6 +- .../expandable_SOAP_widget.dart | 2 +- .../shared_soap_widgets/remove_button.dart | 6 +- .../subjective/medication/add_medication.dart | 15 +- .../subjective/update_subjective_page.dart | 8 +- .../procedures/add_procedure_page.dart | 2 - .../add_reschedule_leave.dart | 144 ++++++---------- .../reschedule_leaves/reschedule_leave.dart | 47 +++--- .../text_fields/app-textfield-custom.dart | 2 +- 18 files changed, 196 insertions(+), 264 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 2fe453ba..86704430 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -130,7 +130,6 @@ class BaseAppClient { onFailure(Utils.generateContactAdminMsg(), statusCode); } else { var parsed = json.decode(response.body.toString()); - print("Response : $parsed"); if (parsed['ErrorType'] == 4) { helpers.navigateToUpdatePage(parsed['ErrorEndUserMessage'], parsed['AndroidLink'], parsed['IOSLink']); } diff --git a/lib/config/config.dart b/lib/config/config.dart index 56335ddc..60021613 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -7,7 +7,7 @@ const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; const DOCTOR_ROTATION = 'https://doctorrota.hmg.com/'; // const BASE_URL_LIVE_CARE = 'https://livecareuat.hmg.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; +//const BASE_URL = 'https://hmgwebservices.com/'; const BASE_URL = 'https://uat.hmgwebservices.com/'; diff --git a/lib/core/service/patient_medical_file/radiology/radiology_service.dart b/lib/core/service/patient_medical_file/radiology/radiology_service.dart index bca644dc..f01089e5 100644 --- a/lib/core/service/patient_medical_file/radiology/radiology_service.dart +++ b/lib/core/service/patient_medical_file/radiology/radiology_service.dart @@ -32,7 +32,7 @@ class RadiologyService extends BaseService { url = GET_IN_PATIENT_ORDERS; body['ProjectID'] = patient.projectId; } - finalRadiologyList.clear(); + hasError = false; await baseAppClient.postPatient(url, patient: patient, onSuccess: (dynamic response, int statusCode) { finalRadiologyList = []; @@ -47,9 +47,11 @@ class RadiologyService extends BaseService { }); } else { isRadiologyVIDAPlus = true; - response['FinalRadiologyListAPI'].forEach((radiology) { - finalRadiologyList.add(FinalRadiology.fromJson(radiology)); - }); + if (response['FinalRadiologyListAPI'] != null) { + response['FinalRadiologyListAPI'].forEach((radiology) { + finalRadiologyList.add(FinalRadiology.fromJson(radiology)); + }); + } } // if (response[label] == null || response[label].length == 0) { // label = "FinalRadiologyList"; diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index a23752dd..e6820d72 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -521,44 +521,44 @@ class SOAPViewModel extends BaseViewModel { onAddMedicationStart() async { setState(ViewState.Busy); - var services; + List services = []; if (medicationStrengthList.length == 0) { - if (services == null) { + if (services.isEmpty) { services = [_SOAPService.getMasterLookup(MasterKeysService.MedicationStrength)]; } else { services.add(_SOAPService.getMasterLookup(MasterKeysService.MedicationStrength)); } } if (medicationFrequencyList.length == 0) { - if (services == null) { + if (services.isEmpty) { services = [_SOAPService.getMasterLookup(MasterKeysService.MedicationFrequency)]; } else { services.add(_SOAPService.getMasterLookup(MasterKeysService.MedicationFrequency)); } } if (medicationDoseTimeList.length == 0) { - if (services == null) { + if (services.isEmpty) { services = [_SOAPService.getMasterLookup(MasterKeysService.MedicationDoseTime)]; } else { services.add(_SOAPService.getMasterLookup(MasterKeysService.MedicationDoseTime)); } } if (medicationRouteList.length == 0) { - if (services == null) { + if (services.isEmpty) { services = [_SOAPService.getMasterLookup(MasterKeysService.MedicationRoute)]; } else { services.add(_SOAPService.getMasterLookup(MasterKeysService.MedicationRoute)); } } if (allMedicationList.length == 0) { - if (services == null) { + if (services.isEmpty) { services = [_prescriptionService.getMedicationList()]; } else { services.add(_prescriptionService.getMedicationList()); } } - final results = await Future.wait(services ?? []); + final results = services; if (_SOAPService.hasError || _prescriptionService.hasError) { error = _SOAPService.error! + _prescriptionService.error!; diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index 8411b443..7e21feb8 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -54,12 +54,12 @@ class AuthenticationViewModel extends BaseViewModel { List get vidaPlusProjectList => _hospitalsService.vidaPlusProjectListModel; - NewLoginInformationModel loggedUser = NewLoginInformationModel(); + NewLoginInformationModel? loggedUser; GetIMEIDetailsModel? user; UserModel userInfo = UserModel(); final LocalAuthentication auth = LocalAuthentication(); - List _availableBiometrics = []; + List? _availableBiometrics; final FirebaseMessaging _firebaseMessaging = FirebaseMessaging.instance; bool isLogin = false; @@ -100,7 +100,7 @@ class AuthenticationViewModel extends BaseViewModel { insertIMEIDetailsModel.vidaAuthTokenID = await sharedPref.getString(VIDA_AUTH_TOKEN_ID); insertIMEIDetailsModel.vidaRefreshTokenID = await sharedPref.getString(VIDA_REFRESH_TOKEN_ID); insertIMEIDetailsModel.password = userInfo.password; - insertIMEIDetailsModel.loginDoctorID = loggedUser != null ? loggedIn["List_MemberInformation"][0]["employeeID"] : int.parse(user!.editedBy.toString()); + insertIMEIDetailsModel.loginDoctorID = loggedUser != null ? loggedUser!.listMemberInformation![0].employeeID : user!.doctorID; await _authService.insertDeviceImei(insertIMEIDetailsModel); if (_authService.hasError) { @@ -157,11 +157,11 @@ class AuthenticationViewModel extends BaseViewModel { int projectID = await sharedPref.getInt(PROJECT_ID); ActivationCodeModel activationCodeModel = ActivationCodeModel( facilityId: projectID, - memberID: loggedUser.listMemberInformation![0].memberID, - loginDoctorID: loggedUser.listMemberInformation![0].employeeID, + memberID: loggedUser!.listMemberInformation![0].memberID, + loginDoctorID: loggedUser!.listMemberInformation![0].employeeID, otpSendType: authMethodType.getTypeIdService().toString(), ); - await sharedPref.setString(DOCTOR_ID, (loggedUser.listMemberInformation![0].employeeID).toString()); + await sharedPref.setString(DOCTOR_ID, (loggedUser!.listMemberInformation![0].employeeID).toString()); await _authService.sendActivationCodeForDoctorApp(activationCodeModel); if (_authService.hasError) { error = _authService.error; @@ -177,8 +177,8 @@ class AuthenticationViewModel extends BaseViewModel { setState(ViewState.BusyLocal); CheckActivationCodeRequestModel checkActivationCodeForDoctorApp = new CheckActivationCodeRequestModel( - zipCode: loggedUser != null ? loggedUser.zipCode : user!.zipCode, - mobileNumber: loggedUser != null ? loggedUser.mobileNumber : user!.mobile, + zipCode: loggedUser != null ? loggedUser!.zipCode : user!.zipCode, + mobileNumber: loggedUser != null ? loggedUser!.mobileNumber : user!.mobile, projectID: await sharedPref.getInt(PROJECT_ID) != null ? await sharedPref.getInt(PROJECT_ID) : user!.projectID, logInTokenID: await sharedPref.getString(TOKEN), activationCode: activationCode ?? '0000', @@ -187,7 +187,7 @@ class AuthenticationViewModel extends BaseViewModel { facilityId: userInfo.projectID != null ? userInfo.projectID.toString() : user!.projectID.toString(), oTPSendType: await sharedPref.getInt(OTP_TYPE), iMEI: localToken, - loginDoctorID: loggedUser != null ? loggedUser.listMemberInformation![0].employeeID : int.parse(user!.editedBy.toString()), + loginDoctorID: loggedUser != null ? loggedUser!.listMemberInformation![0].employeeID : int.parse(user!.editedBy.toString()), ///loggedUser.listMemberInformation[0].employeeID, // loggedUser.listMemberInformation[0].employeeID, @@ -305,8 +305,8 @@ class AuthenticationViewModel extends BaseViewModel { bool isAvailable = false; await _getAvailableBiometrics(); if (_availableBiometrics != null) { - for (var i = 0; i < _availableBiometrics.length; i++) { - if (biometricType == _availableBiometrics[i]) isAvailable = true; + for (var i = 0; i < _availableBiometrics!.length; i++) { + if (biometricType == _availableBiometrics![i]) isAvailable = true; } } return isAvailable; diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index b7dc8134..0183d691 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -93,7 +93,7 @@ class _VerificationMethodsScreenState extends State { letterSpacing: -0.72, ), AppText( - Utils.convertToTitleCase(authenticationViewModel.user!.doctorName!), + Utils.convertToTitleCase(authenticationViewModel.user!.doctorName), fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * 6, color: AppGlobal.appTextColor, fontWeight: FontWeight.bold, @@ -422,7 +422,7 @@ class _VerificationMethodsScreenState extends State { new SMSOTP( context, type, - authenticationViewModel.loggedUser != null ? authenticationViewModel.loggedUser.mobileNumber : authenticationViewModel.user!.mobile, + authenticationViewModel.loggedUser != null ? authenticationViewModel.loggedUser!.mobileNumber : authenticationViewModel.user!.mobile, (value) { showDialog( context: context, diff --git a/lib/screens/patients/profile/radiology/radiology_home_page.dart b/lib/screens/patients/profile/radiology/radiology_home_page.dart index 3a2f40ef..485ddcaf 100644 --- a/lib/screens/patients/profile/radiology/radiology_home_page.dart +++ b/lib/screens/patients/profile/radiology/radiology_home_page.dart @@ -113,7 +113,7 @@ class _RadiologyHomePageState extends State { height: 160, decoration: BoxDecoration( //Colors.red[900] Color(0xff404545) - color: model.radiologyList[index].isLiveCareAppodynamicment! + color: model.radiologyList[index].isLiveCareAppodynamicment ?? false ? Colors.red[900] : !model.radiologyList[index].isInOutPatient! ? Colors.black diff --git a/lib/screens/patients/profile/referral/refer_details/referred-patient-screen.dart b/lib/screens/patients/profile/referral/refer_details/referred-patient-screen.dart index 42e4637f..caeadca6 100644 --- a/lib/screens/patients/profile/referral/refer_details/referred-patient-screen.dart +++ b/lib/screens/patients/profile/referral/refer_details/referred-patient-screen.dart @@ -49,100 +49,80 @@ class _ReferredPatientScreenState extends State { }, ), ), - if (model.listMyReferredPatientModel == null || - model.listMyReferredPatientModel.length == 0) Center( - child: ErrorMessage( - error: TranslationBase.of(context).referralEmptyMsg, - )) else Expanded( - child: SingleChildScrollView( - // DoctorApplication.svc/REST/GtMyReferredPatient - child: Container( - - child: Column( - children: [ - ListView.builder( - itemCount: - model.listMyReferredPatientModel.length, - scrollDirection: Axis.vertical, - physics: ScrollPhysics(), - shrinkWrap: true, - itemBuilder: (context, index) { - return InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: ReferredPatientDetailScreen( - model.getReferredPatientItem(index), - this.patientType), - ), - ); - }, - child: PatientReferralItemWidget( - referralStatus: model - .getReferredPatientItem(index) - .referralStatusDesc!, - referralStatusCode: model - .getReferredPatientItem(index) - .referralStatus!, - patientName: "${model.getReferredPatientItem(index).firstName} ${model.getReferredPatientItem(index).middleName} ${model.getReferredPatientItem(index).lastName}", - - patientGender: model - .getReferredPatientItem(index) - .gender!, - referredDate: model.state == ViewState.BusyLocal ?"": - AppDateUtils.getDayMonthYearDateFormatted( - patientType == PatientType.IN_PATIENT? - AppDateUtils.getDateTimeFromServerFormat( - model.getReferredPatientItem(index).referralDate!, - ):AppDateUtils.getDateTimeFromString( - model.getReferredPatientItem(index).referralDate!, - ), - isMonthShort: true - ), - referredTime:model.state == ViewState.BusyLocal ?"":AppDateUtils.getHour( - patientType == PatientType.IN_PATIENT? - AppDateUtils.getDateTimeFromServerFormat( - model.getReferredPatientItem(index).referralDate!, - ):AppDateUtils.getDateTimeFromString( - model.getReferredPatientItem(index).referralDate!, - ), - // isMonthShort: true - ), - patientID: - "${model.getReferredPatientItem(index).patientID}", - isSameBranch: model - .getReferredPatientItem(index) - .isReferralDoctorSameBranch, - isReferral: false, - remark: model - .getReferredPatientItem(index) - .referringDoctorRemarks!, - nationality: model - .getReferredPatientItem(index) - .nationalityName!, - nationalityFlag: model - .getReferredPatientItem(index) - .nationalityFlagURL!, - doctorAvatar: model - .getReferredPatientItem(index) - .doctorImageURL!, - referralDoctorName: "${TranslationBase.of(context).dr} ${model.getReferredPatientItem(index).referralDoctorName}", - - clinicDescription: model - .getReferredPatientItem(index) - .referralClinicDescription!, - infoIcon: Icon(FontAwesomeIcons.arrowRight, - size: 25, color: Colors.black), + if (model.listMyReferredPatientModel == null || model.listMyReferredPatientModel.length == 0) + Center( + child: ErrorMessage( + error: TranslationBase.of(context).referralEmptyMsg, + )) + else + Expanded( + child: SingleChildScrollView( + // DoctorApplication.svc/REST/GtMyReferredPatient + child: Container( + child: Column( + children: [ + ListView.builder( + itemCount: model.listMyReferredPatientModel.length, + scrollDirection: Axis.vertical, + physics: ScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: ReferredPatientDetailScreen(model.getReferredPatientItem(index), this.patientType), ), ); }, - ), - ], + child: PatientReferralItemWidget( + referralStatus: model.getReferredPatientItem(index).referralStatusDesc!, + referralStatusCode: model.getReferredPatientItem(index).referralStatus!, + patientName: "${model.getReferredPatientItem(index).firstName} ${model.getReferredPatientItem(index).middleName} ${model.getReferredPatientItem(index).lastName}", + patientGender: model.getReferredPatientItem(index).gender!, + referredDate: model.state == ViewState.BusyLocal + ? "" + : AppDateUtils.getDayMonthYearDateFormatted( + patientType == PatientType.IN_PATIENT + ? AppDateUtils.getDateTimeFromServerFormat( + model.getReferredPatientItem(index).referralDate!, + ) + : AppDateUtils.getDateTimeFromString( + model.getReferredPatientItem(index).referralDate!, + ), + isMonthShort: true), + referredTime: model.state == ViewState.BusyLocal + ? "" + : AppDateUtils.getHour( + patientType == PatientType.IN_PATIENT + ? AppDateUtils.getDateTimeFromServerFormat( + model.getReferredPatientItem(index).referralDate!, + ) + : AppDateUtils.getDateTimeFromString( + model.getReferredPatientItem(index).referralDate!, + ), + // isMonthShort: true + ), + patientID: "${model.getReferredPatientItem(index).patientID}", + isSameBranch: model.getReferredPatientItem(index).isReferralDoctorSameBranch, + isReferral: false, + remark: model.getReferredPatientItem(index).referringDoctorRemarks!, + nationality: model.getReferredPatientItem(index).nationalityName ?? "", + nationalityFlag: model.getReferredPatientItem(index).nationalityFlagURL!, + doctorAvatar: model.getReferredPatientItem(index).doctorImageURL!, + referralDoctorName: "${TranslationBase.of(context).dr} ${model.getReferredPatientItem(index).referralDoctorName}", + clinicDescription: model.getReferredPatientItem(index).referralClinicDescription!, + infoIcon: Icon(FontAwesomeIcons.arrowRight, size: 25, color: Colors.black), + ), + ); + }, ), - ), + ], ), ), + ), + ), ], ), ), @@ -156,8 +136,7 @@ class PatientTypeRadioWidget extends StatefulWidget { PatientTypeRadioWidget(this.radioOnChange); @override - _PatientTypeRadioWidgetState createState() => - _PatientTypeRadioWidgetState(this.radioOnChange); + _PatientTypeRadioWidgetState createState() => _PatientTypeRadioWidgetState(this.radioOnChange); } class _PatientTypeRadioWidgetState extends State { diff --git a/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart index 9b0d752b..45b60709 100644 --- a/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart +++ b/lib/screens/patients/profile/soap_update/objective/examination_item_card.dart @@ -1,7 +1,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_examination.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/remark_text.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/remove_button.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; @@ -11,7 +11,7 @@ import 'package:provider/provider.dart'; class ExaminationItemCard extends StatelessWidget { final MySelectedExamination examination; - final Function removeExamination; + final Function() removeExamination; ExaminationItemCard(this.examination, this.removeExamination); @@ -32,8 +32,7 @@ class ExaminationItemCard extends StatelessWidget { child: Container( child: AppText( projectViewModel.isArabic - ? examination.selectedExamination!.nameAr != null && - examination.selectedExamination!.nameAr != "" + ? examination.selectedExamination!.nameAr != null && examination.selectedExamination!.nameAr != "" ? examination.selectedExamination!.nameAr! : examination.selectedExamination!.nameEn! : examination.selectedExamination!.nameEn!, @@ -65,9 +64,7 @@ class ExaminationItemCard extends StatelessWidget { ), if (!examination.notExamined) RemoveButton( - label: examination.isLocal - ? TranslationBase.of(context).remove - : TranslationBase.of(context).notExamined, + label: examination.isLocal ? TranslationBase.of(context).remove : TranslationBase.of(context).notExamined, onTap: removeExamination, ), ], @@ -75,8 +72,7 @@ class ExaminationItemCard extends StatelessWidget { SizedBox( height: 4, ), - if (examination.remark!.isNotEmpty) - RemarkText(remark: examination.remark!), + if (examination.remark!.isNotEmpty) RemarkText(remark: examination.remark!), ], ), ); diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_open_items.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_open_items.dart index 071d3fa3..3200d043 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_open_items.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_open_items.dart @@ -4,15 +4,15 @@ import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; class SOAPOpenItems extends StatelessWidget { - final Function? onTap; + final Function() onTap; final String label; - const SOAPOpenItems({Key? key, this.onTap, this.label = ''}) : super(key: key); + const SOAPOpenItems({Key? key, required this.onTap, this.label = ''}) : super(key: key); @override Widget build(BuildContext context) { return InkWell( - onTap: onTap!(), + onTap: onTap, child: Container( padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8.0), margin: EdgeInsets.symmetric(vertical: 8), diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/expandable_SOAP_widget.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/expandable_SOAP_widget.dart index 2f272a96..6b6e75d4 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/expandable_SOAP_widget.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/expandable_SOAP_widget.dart @@ -58,7 +58,7 @@ class ExpandableSOAPWidget extends StatelessWidget { ), ), InkWell( - onTap: onTap!(), + onTap: onTap, child: Icon(isExpanded ? EvaIcons.arrowIosUpwardOutline : EvaIcons.arrowIosDownwardOutline), ) ], diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/remove_button.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/remove_button.dart index 52bee25b..c970f62a 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/remove_button.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/remove_button.dart @@ -6,10 +6,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:hexcolor/hexcolor.dart'; class RemoveButton extends StatelessWidget { - final Function? onTap; + final Function() onTap; final String label; - const RemoveButton({Key? key, this.onTap, this.label = ''}) : super(key: key); + const RemoveButton({Key? key, required this.onTap, this.label = ''}) : super(key: key); @override Widget build(BuildContext context) { @@ -32,7 +32,7 @@ class RemoveButton extends StatelessWidget { ), ], ), - onTap: onTap!(), + onTap: onTap, ); } } 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 fd0991b0..dcf3ace5 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 @@ -3,6 +3,7 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/size_config.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_allergy.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'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; @@ -23,7 +24,7 @@ import '../../shared_soap_widgets/bottom_sheet_title.dart'; // ignore: must_be_immutable class AddMedication extends StatefulWidget { - final Function addMedicationFun; + final Function(MySelectedAllergy mySelectedAllergy) addMedicationFun; TextEditingController medicationController; AddMedication({Key? key, required this.addMedicationFun, required this.medicationController}) : super(key: key); @@ -42,7 +43,7 @@ class _AddMedicationState extends State { TextEditingController strengthController = TextEditingController(); TextEditingController routeController = TextEditingController(); TextEditingController frequencyController = TextEditingController(); - GetMedicationResponseModel _selectedMedication = GetMedicationResponseModel(); + GetMedicationResponseModel? _selectedMedication; GlobalKey> key = new GlobalKey>(); bool isFormSubmitted = false; @@ -52,8 +53,8 @@ class _AddMedicationState extends State { ProjectViewModel projectViewModel = Provider.of(context); return FractionallySizedBox( child: BaseView( - onModelReady: (model) async { - model.onAddMedicationStart(); + onModelReady: (model) { + if (!mounted) model.onAddMedicationStart(); }, builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -110,7 +111,7 @@ class _AddMedicationState extends State { : AppTextFieldCustom( height: Utils.getTextFieldHeight(), hintText: _selectedMedication != null - ? _selectedMedication.description! + (' (${_selectedMedication.genericName} )') + ? _selectedMedication!.description! + (' (${_selectedMedication!.genericName} )') : TranslationBase.of(context).searchMedicineNameHere, minLines: 1, maxLines: 1, @@ -137,7 +138,7 @@ class _AddMedicationState extends State { Container( width: MediaQuery.of(context).size.width * 0.7, child: AppText( - _selectedMedication.description! + (' (${_selectedMedication.genericName} )'), + _selectedMedication!.description! + (' (${_selectedMedication!.genericName} )'), color: Color(0xFF575757), fontSize: 10, fontWeight: FontWeight.w700, @@ -335,7 +336,7 @@ class _AddMedicationState extends State { _selectedMedicationRoute != null && _selectedMedicationFrequency != null) { widget.medicationController.text = widget.medicationController.text + - '${_selectedMedication.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; + '${_selectedMedication!.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; Navigator.of(context).pop(); } }, 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 fb2a18ee..68fbd6b1 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 @@ -160,11 +160,9 @@ class _UpdateSubjectivePageState extends State implements ExpandableSOAPWidget( headerTitle: TranslationBase.of(context).chiefComplaints, onTap: () { - if (mounted) { - setState(() { - isChiefExpand = !isChiefExpand; - }); - } + setState(() { + isChiefExpand = !isChiefExpand; + }); }, child: UpdateChiefComplaints( formKey: formKey, diff --git a/lib/screens/procedures/add_procedure_page.dart b/lib/screens/procedures/add_procedure_page.dart index 4c166b4b..ead503d6 100644 --- a/lib/screens/procedures/add_procedure_page.dart +++ b/lib/screens/procedures/add_procedure_page.dart @@ -153,8 +153,6 @@ class _AddProcedurePageState extends State { }, addSelectedHistories: () {}, selectedType: (val) { - print("------------"); - print(val); selectedType = val; }, isEntityListSelected: (master) => widget.model.isEntityListSelected(master, entityList), diff --git a/lib/screens/reschedule_leaves/add_reschedule_leave.dart b/lib/screens/reschedule_leaves/add_reschedule_leave.dart index 20dd05a6..b5d85e6f 100644 --- a/lib/screens/reschedule_leaves/add_reschedule_leave.dart +++ b/lib/screens/reschedule_leaves/add_reschedule_leave.dart @@ -24,8 +24,7 @@ class AddRescheduleLeaveScreen extends StatelessWidget { Widget build(BuildContext context) { projectsProvider = Provider.of(context); return BaseView( - onModelReady: (model) => - {model.getRescheduleLeave(), model.getCoveringDoctors()}, + onModelReady: (model) => {model.getRescheduleLeave(), model.getCoveringDoctors()}, builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, @@ -50,8 +49,7 @@ class AddRescheduleLeaveScreen extends StatelessWidget { ), ), Column( - children: model.getReschduleLeave - .map((GetRescheduleLeavesResponse item) { + children: model.getReschduleLeave.map((GetRescheduleLeavesResponse item) { return Padding( padding: const EdgeInsets.all(8.0), child: RoundedContainer( @@ -79,77 +77,53 @@ class AddRescheduleLeaveScreen extends StatelessWidget { child: Wrap( children: [ Column( - crossAxisAlignment: - CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Container( - padding: EdgeInsets.all(3), - margin: - EdgeInsets.only(top: 10), - child: AppText( - item.statusDescription!, - fontWeight: FontWeight.bold, - color: item.status == 10 - ? Colors.red[800]! - : item.status == 2 - ? HexColor( - '#CC9B14') - : item.status == 9 - ? AppGlobal - .appGreenColor - : Colors.red, - fontSize: 14, - ), - ), - Padding( - padding: EdgeInsets.only( - top: 10), - child: AppText( - AppDateUtils - .convertStringToDateFormat( - item.createdOn!, - 'yyyy-MM-dd HH:mm'), - fontWeight: - FontWeight.bold, - )) - ]), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Container( + padding: EdgeInsets.all(3), + margin: EdgeInsets.only(top: 10), + child: AppText( + item.statusDescription!, + fontWeight: FontWeight.bold, + color: item.status == 10 + ? Colors.red[800]! + : item.status == 2 + ? HexColor('#CC9B14') + : item.status == 9 + ? AppGlobal.appGreenColor + : Colors.red, + fontSize: 14, + ), + ), + Padding( + padding: EdgeInsets.only(top: 10), + child: AppText( + AppDateUtils.convertStringToDateFormat(item.createdOn!, 'yyyy-MM-dd HH:mm'), + fontWeight: FontWeight.bold, + )) + ]), SizedBox( height: 5, ), Container( child: AppText( item.requisitionType == 1 - ? TranslationBase.of(context) - .offTime + ? TranslationBase.of(context).offTime : item.requisitionType == 2 - ? TranslationBase.of( - context) - .holiday + ? TranslationBase.of(context).holiday : item.requisitionType == 3 - ? TranslationBase.of( - context) - .changeOfSchedule - : TranslationBase.of( - context) - .newSchedule, + ? TranslationBase.of(context).changeOfSchedule + : TranslationBase.of(context).newSchedule, fontWeight: FontWeight.bold, )), SizedBox( height: 5, ), Row(children: [ - AppText(TranslationBase.of(context) - .startDate), + AppText(TranslationBase.of(context).startDate), AppText( - AppDateUtils - .convertStringToDateFormat( - item.dateTimeFrom!, - 'yyyy-MM-dd HH:mm'), + AppDateUtils.convertStringToDateFormat(item.dateTimeFrom!, 'yyyy-MM-dd HH:mm'), fontWeight: FontWeight.bold, ) @@ -165,14 +139,9 @@ class AddRescheduleLeaveScreen extends StatelessWidget { ), Row( children: [ + AppText(TranslationBase.of(context).endDate), AppText( - TranslationBase.of(context) - .endDate), - AppText( - AppDateUtils - .convertStringToDateFormat( - item.dateTimeTo!, - 'yyyy-MM-dd HH:mm'), + AppDateUtils.convertStringToDateFormat(item.dateTimeTo!, 'yyyy-MM-dd HH:mm'), fontWeight: FontWeight.bold, ) ], @@ -184,42 +153,24 @@ class AddRescheduleLeaveScreen extends StatelessWidget { model.coveringDoctors.length > 0 ? Row(children: [ AppText( - TranslationBase.of(context) - .coveringDoctor, + TranslationBase.of(context).coveringDoctor, ), AppText( - getDoctor( - model.coveringDoctors, - item.coveringDoctorId), + getDoctor(model.coveringDoctors, item.coveringDoctorId), fontWeight: FontWeight.bold, ) ]) : SizedBox(), - Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Padding( - padding: EdgeInsets.only( - bottom: 5), - child: AppText(getReasons( - model.allReasons, - item.reasonId))), - (item.status == 2) - ? IconButton( - icon: Image.asset( - 'assets/images/edit.png'), - // color: AppGlobal.appGreenColor, //Colors.black, - onPressed: () => { - openLeave( - context, true, - extendedData: - item) - }, - ) - : SizedBox(), - ]), + Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Padding(padding: EdgeInsets.only(bottom: 5), child: AppText(getReasons(model.allReasons, item.reasonId))), + (item.status == 2) + ? IconButton( + icon: Image.asset('assets/images/edit.png'), + // color: AppGlobal.appGreenColor, //Colors.black, + onPressed: () => {openLeave(context, true, extendedData: item)}, + ) + : SizedBox(), + ]), ], ), SizedBox( @@ -241,7 +192,6 @@ class AddRescheduleLeaveScreen extends StatelessWidget { } openLeave(BuildContext context, isExtend, {extendedData}) { - Navigator.push( context, FadePage( diff --git a/lib/screens/reschedule_leaves/reschedule_leave.dart b/lib/screens/reschedule_leaves/reschedule_leave.dart index aa5ffaea..5169097b 100644 --- a/lib/screens/reschedule_leaves/reschedule_leave.dart +++ b/lib/screens/reschedule_leaves/reschedule_leave.dart @@ -41,7 +41,7 @@ class _RescheduleLeaveScreen extends State { late ProjectViewModel projectsProvider; late SickLeaveViewModel sickLeaveViewModel; Map profile = {}; - var offTime = '1'; + var offTime; var date; var doctorID; var reason; @@ -203,7 +203,7 @@ class _RescheduleLeaveScreen extends State { children: [ AppTextFormField( hintText: TranslationBase.of(context).fromDate, - borderColor: Colors.white, + borderColor: Colors.transparent, prefix: IconButton( icon: Icon(Icons.calendar_today), onPressed: () {}, @@ -229,19 +229,19 @@ class _RescheduleLeaveScreen extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - // DateTimePicker( - // timeHintText: TranslationBase.of(context).fromTime, - // type: DateTimePickerType.time, - // controller: _controller4, - // onChanged: (val) => fromTime = val, - // validator: (val) { - // print(val); - // // setState( - // // () => _valueToValidate4 = val); - // return null; - // }, - // onSaved: (val) => fromTime = val, - // ), + DateTimePicker( + timeHintText: TranslationBase.of(context).fromTime, + type: DateTimePickerType.time, + controller: _controller4, + onChanged: (val) => fromTime = val, + validator: (val) { + print(val); + // setState( + // () => _valueToValidate4 = val); + return null; + }, + onSaved: (val) => fromTime = val, + ), ], ), ), @@ -292,7 +292,7 @@ class _RescheduleLeaveScreen extends State { children: [ AppTextFormField( hintText: TranslationBase.of(context).fromDate, - borderColor: Colors.white, + borderColor: Colors.transparent, prefix: IconButton( icon: Icon(Icons.calendar_today), onPressed: () {}, @@ -321,7 +321,7 @@ class _RescheduleLeaveScreen extends State { AppTextFormField( hintText: TranslationBase.of(context).toDate, readOnly: true, - borderColor: Colors.white, + borderColor: Colors.transparent, prefix: IconButton( icon: Icon(Icons.calendar_today), onPressed: () {}, @@ -556,8 +556,17 @@ class _RescheduleLeaveScreen extends State { var fromDates = fromDate; var toDates = toDate; if (offTime == '1') { - fromDate = df.format(DateTime.parse(dateFormat.format(fromDates) + 'T' + fromTime! + ':' + DateTime.now().second.toString())); - toDate = df.format(DateTime.parse(dateFormat.format(fromDates) + 'T' + toTime! + ':' + DateTime.now().second.toString())); + print("-----"); + print(DateTime.now()); + print("-----"); + print(dateFormat.format(fromDates) + ' ' + fromTime! + ':' + DateTime.now().second.toString() + '.' + DateTime.now().microsecond.toString()); + print("-0-0-0-0"); + fromDate = df.format( + DateTime.parse( + dateFormat.format(fromDates) + ' ' + fromTime! + ':' + DateTime.now().second.toString(), + ), + ); + toDate = df.format(DateTime.parse(dateFormat.format(fromDates) + ' ' + toTime! + ':' + DateTime.now().second.toString())); } else { fromDate = df.format(fromDates); toDate = df.format(toDates); diff --git a/lib/widgets/shared/text_fields/app-textfield-custom.dart b/lib/widgets/shared/text_fields/app-textfield-custom.dart index d2a7c0de..b81867de 100644 --- a/lib/widgets/shared/text_fields/app-textfield-custom.dart +++ b/lib/widgets/shared/text_fields/app-textfield-custom.dart @@ -105,7 +105,7 @@ class _AppTextFieldCustomState extends State { : null, padding: EdgeInsets.only(top: 4.0, bottom: 0.0, left: 8.0, right: 8.0), child: InkWell( - onTap: widget.onClick ?? null, + onTap: widget.onClick, child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [