diff --git a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart index 66fd22fd..41686ead 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen-in-patient.dart @@ -25,10 +25,12 @@ import 'package:speech_to_text/speech_to_text.dart' as stt; class PatientMakeInPatientReferralScreen extends StatefulWidget { @override - _PatientMakeInPatientReferralScreenState createState() => _PatientMakeInPatientReferralScreenState(); + _PatientMakeInPatientReferralScreenState createState() => + _PatientMakeInPatientReferralScreenState(); } -class _PatientMakeInPatientReferralScreenState extends State { +class _PatientMakeInPatientReferralScreenState + extends State { PatiantInformtion patient; List referToList; dynamic _referTo; @@ -66,7 +68,8 @@ class _PatientMakeInPatientReferralScreenState extends State initSpeechState() async { - bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); + bool hasSpeech = await speech.initialize( + onError: errorListener, onStatus: statusListener); print(hasSpeech); if (!mounted) return; } @@ -123,8 +127,14 @@ class _PatientMakeInPatientReferralScreenState extends State GifLoaderDialogUtils.hideDialog(context)); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); + .getClinics(_selectedBranch[ + 'facilityId']) + .then((_) => + GifLoaderDialogUtils + .hideDialog(context)); + if (model.state == + ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast( + model.error); } } else { _selectedBranch = null; @@ -226,7 +245,9 @@ class _PatientMakeInPatientReferralScreenState extends State GifLoaderDialogUtils.hideDialog(context)); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); + .getClinics( + _selectedBranch['facilityId']) + .then((_) => GifLoaderDialogUtils + .hideDialog(context)); + if (model.state == + ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast( + model.error); } }); }, @@ -271,7 +297,9 @@ class _PatientMakeInPatientReferralScreenState extends State GifLoaderDialogUtils.hideDialog(context)); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); + patient, + _selectedClinic['ClinicID'], + _selectedBranch['facilityId']) + .then((_) => GifLoaderDialogUtils + .hideDialog(context)); + if (model.state == + ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast( + model.error); } }); }, @@ -317,41 +353,49 @@ class _PatientMakeInPatientReferralScreenState extends State 0 - ? () { - ListSelectDialog dialog = ListSelectDialog( - list: model.doctorsList, - attributeName: 'Name', - attributeValueId: 'DoctorID', - usingSearch: true, - hintSearchText: TranslationBase.of(context).doctorSearch, - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedDoctor = selectedValue; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : () { - if (_selectedClinic == null) { - DrAppToastMsg.showErrorToast("You need to select a clinic first"); - } else if (model.doctorsList == null || model.doctorsList.length == 0) { - DrAppToastMsg.showErrorToast("There is no doctors for this clinic"); - } + onClick: _selectedClinic != null && + model.doctorsList != null && + model.doctorsList.length > 0 + ? () { + ListSelectDialog dialog = ListSelectDialog( + list: model.doctorsList, + attributeName: 'Name', + attributeValueId: 'DoctorID', + usingSearch: true, + hintSearchText: + TranslationBase.of(context) + .doctorSearch, + okText: TranslationBase.of(context).ok, + okFunction: (selectedValue) { + setState(() { + _selectedDoctor = selectedValue; + }); }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : () { + if (_selectedClinic == null) { + DrAppToastMsg.showErrorToast( + "You need to select a clinic first"); + } else if (model.doctorsList == null || + model.doctorsList.length == 0) { + DrAppToastMsg.showErrorToast( + "There is no doctors for this clinic"); + } + }, ), SizedBox( height: 10, @@ -379,8 +423,11 @@ class _PatientMakeInPatientReferralScreenState extends State {onVoiceText()}); + initSpeechState() + .then((value) => {onVoiceText()}); }, ), ), @@ -454,15 +504,14 @@ class _PatientMakeInPatientReferralScreenState extends State