refer inpatient hot fix

merge-requests/856/head
mosazaid 5 years ago
parent 7436cdb5be
commit bb8ffbf63b

@ -25,10 +25,12 @@ import 'package:speech_to_text/speech_to_text.dart' as stt;
class PatientMakeInPatientReferralScreen extends StatefulWidget { class PatientMakeInPatientReferralScreen extends StatefulWidget {
@override @override
_PatientMakeInPatientReferralScreenState createState() => _PatientMakeInPatientReferralScreenState(); _PatientMakeInPatientReferralScreenState createState() =>
_PatientMakeInPatientReferralScreenState();
} }
class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatientReferralScreen> { class _PatientMakeInPatientReferralScreenState
extends State<PatientMakeInPatientReferralScreen> {
PatiantInformtion patient; PatiantInformtion patient;
List<dynamic> referToList; List<dynamic> referToList;
dynamic _referTo; dynamic _referTo;
@ -66,7 +68,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
onVoiceText() async { onVoiceText() async {
new SpeechToText(context: context).showAlertDialog(context); new SpeechToText(context: context).showAlertDialog(context);
var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode; var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode;
bool available = await speech.initialize(onStatus: statusListener, onError: errorListener); bool available = await speech.initialize(
onStatus: statusListener, onError: errorListener);
if (available) { if (available) {
speech.listen( speech.listen(
onResult: resultListener, onResult: resultListener,
@ -110,7 +113,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
} }
Future<void> initSpeechState() async { Future<void> initSpeechState() async {
bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener); bool hasSpeech = await speech.initialize(
onError: errorListener, onStatus: statusListener);
print(hasSpeech); print(hasSpeech);
if (!mounted) return; if (!mounted) return;
} }
@ -123,8 +127,14 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
String arrivalType = routeArgs['arrivalType']; String arrivalType = routeArgs['arrivalType'];
bool isInpatient = routeArgs['isInpatient']; bool isInpatient = routeArgs['isInpatient'];
referToList = List(); referToList = List();
dynamic sameBranch = {"id": 1, "name": TranslationBase.of(context).sameBranch}; dynamic sameBranch = {
dynamic otherBranch = {"id": 2, "name": TranslationBase.of(context).otherBranch}; "id": 1,
"name": TranslationBase.of(context).sameBranch
};
dynamic otherBranch = {
"id": 2,
"name": TranslationBase.of(context).otherBranch
};
referToList.add(sameBranch); referToList.add(sameBranch);
referToList.add(otherBranch); referToList.add(otherBranch);
@ -176,7 +186,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: TranslationBase.of(context).branch, hintText: TranslationBase.of(context).branch,
dropDownText: _referTo != null ? _referTo['name'] : null, dropDownText:
_referTo != null ? _referTo['name'] : null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: branchError, validationError: branchError,
@ -193,15 +204,23 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
_selectedBranch = null; _selectedBranch = null;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
model.getDoctorBranch().then((value) async { model
.getDoctorBranch()
.then((value) async {
_selectedBranch = value; _selectedBranch = value;
if (_referTo['id'] == 1) { if (_referTo['id'] == 1) {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(
context);
await model await model
.getClinics(_selectedBranch['facilityId']) .getClinics(_selectedBranch[
.then((_) => GifLoaderDialogUtils.hideDialog(context)); 'facilityId'])
if (model.state == ViewState.ErrorLocal) { .then((_) =>
DrAppToastMsg.showErrorToast(model.error); GifLoaderDialogUtils
.hideDialog(context));
if (model.state ==
ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(
model.error);
} }
} else { } else {
_selectedBranch = null; _selectedBranch = null;
@ -226,7 +245,9 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: TranslationBase.of(context).hospital, hintText: TranslationBase.of(context).hospital,
dropDownText: _selectedBranch != null ? _selectedBranch['facilityName'] : null, dropDownText: _selectedBranch != null
? _selectedBranch['facilityName']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: hospitalError, validationError: hospitalError,
@ -245,12 +266,17 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
_selectedBranch = selectedValue; _selectedBranch = selectedValue;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(
context);
await model await model
.getClinics(_selectedBranch['facilityId']) .getClinics(
.then((_) => GifLoaderDialogUtils.hideDialog(context)); _selectedBranch['facilityId'])
if (model.state == ViewState.ErrorLocal) { .then((_) => GifLoaderDialogUtils
DrAppToastMsg.showErrorToast(model.error); .hideDialog(context));
if (model.state ==
ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(
model.error);
} }
}); });
}, },
@ -271,7 +297,9 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: TranslationBase.of(context).clinic, hintText: TranslationBase.of(context).clinic,
dropDownText: _selectedClinic != null ? _selectedClinic['ClinicDescription'] : null, dropDownText: _selectedClinic != null
? _selectedClinic['ClinicDescription']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: clinicError, validationError: clinicError,
@ -284,19 +312,27 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
attributeName: 'ClinicDescription', attributeName: 'ClinicDescription',
attributeValueId: 'ClinicID', attributeValueId: 'ClinicID',
usingSearch: true, usingSearch: true,
hintSearchText: TranslationBase.of(context).clinicSearch, hintSearchText:
TranslationBase.of(context)
.clinicSearch,
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() async { setState(() async {
_selectedDoctor = null; _selectedDoctor = null;
_selectedClinic = selectedValue; _selectedClinic = selectedValue;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(
context);
await model await model
.getClinicDoctors( .getClinicDoctors(
patient, _selectedClinic['ClinicID'], _selectedBranch['facilityId']) patient,
.then((_) => GifLoaderDialogUtils.hideDialog(context)); _selectedClinic['ClinicID'],
if (model.state == ViewState.ErrorLocal) { _selectedBranch['facilityId'])
DrAppToastMsg.showErrorToast(model.error); .then((_) => GifLoaderDialogUtils
.hideDialog(context));
if (model.state ==
ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(
model.error);
} }
}); });
}, },
@ -317,41 +353,49 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: TranslationBase.of(context).doctor, hintText: TranslationBase.of(context).doctor,
dropDownText: _selectedDoctor != null ? _selectedDoctor['Name'] : null, dropDownText: _selectedDoctor != null
? _selectedDoctor['Name']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: doctorError, validationError: doctorError,
onClick: onClick: _selectedClinic != null &&
_selectedClinic != null && model.doctorsList != null && model.doctorsList.length > 0 model.doctorsList != null &&
? () { model.doctorsList.length > 0
ListSelectDialog dialog = ListSelectDialog( ? () {
list: model.doctorsList, ListSelectDialog dialog = ListSelectDialog(
attributeName: 'Name', list: model.doctorsList,
attributeValueId: 'DoctorID', attributeName: 'Name',
usingSearch: true, attributeValueId: 'DoctorID',
hintSearchText: TranslationBase.of(context).doctorSearch, usingSearch: true,
okText: TranslationBase.of(context).ok, hintSearchText:
okFunction: (selectedValue) { TranslationBase.of(context)
setState(() { .doctorSearch,
_selectedDoctor = selectedValue; 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");
}
}, },
);
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( SizedBox(
height: 10, height: 10,
@ -379,8 +423,11 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
), ),
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: TranslationBase.of(context).referralFrequency, hintText:
dropDownText: _selectedFrequency != null ? _selectedFrequency['Description'] : null, TranslationBase.of(context).referralFrequency,
dropDownText: _selectedFrequency != null
? _selectedFrequency['Description']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: frequencyError, validationError: frequencyError,
@ -390,7 +437,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
attributeName: 'Description', attributeName: 'Description',
attributeValueId: 'ParameterCode', attributeValueId: 'ParameterCode',
usingSearch: true, usingSearch: true,
hintSearchText: TranslationBase.of(context).selectReferralFrequency, hintSearchText: TranslationBase.of(context)
.selectReferralFrequency,
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
@ -428,7 +476,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
maxLines: 6, maxLines: 6,
), ),
Positioned( Positioned(
top: 0, //MediaQuery.of(context).size.height * 0, top: 0,
//MediaQuery.of(context).size.height * 0,
right: 15, right: 15,
child: IconButton( child: IconButton(
icon: Icon( icon: Icon(
@ -437,7 +486,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
size: 35, size: 35,
), ),
onPressed: () { onPressed: () {
initSpeechState().then((value) => {onVoiceText()}); initSpeechState()
.then((value) => {onVoiceText()});
}, },
), ),
), ),
@ -454,15 +504,14 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
? SizedBox() ? SizedBox()
: Container( : Container(
margin: EdgeInsets.all(5), margin: EdgeInsets.all(5),
child: Expanded( child: AppButton(
child: AppButton(
title: TranslationBase.of(context).clearText, title: TranslationBase.of(context).clearText,
onPressed: () { onPressed: () {
setState(() { setState(() {
_remarksController.text = ''; _remarksController.text = '';
}); });
}, },
))), )),
Container( Container(
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: AppButton( child: AppButton(
@ -472,27 +521,32 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
onPressed: () async { onPressed: () async {
setState(() { setState(() {
if (_referTo == null) { if (_referTo == null) {
branchError = TranslationBase.of(context).fieldRequired; branchError =
TranslationBase.of(context).fieldRequired;
} else { } else {
branchError = null; branchError = null;
} }
if (_selectedBranch == null) { if (_selectedBranch == null) {
hospitalError = TranslationBase.of(context).fieldRequired; hospitalError =
TranslationBase.of(context).fieldRequired;
} else { } else {
hospitalError = null; hospitalError = null;
} }
if (_selectedClinic == null) { if (_selectedClinic == null) {
clinicError = TranslationBase.of(context).fieldRequired; clinicError =
TranslationBase.of(context).fieldRequired;
} else { } else {
clinicError = null; clinicError = null;
} }
if (_selectedDoctor == null) { if (_selectedDoctor == null) {
doctorError = TranslationBase.of(context).fieldRequired; doctorError =
TranslationBase.of(context).fieldRequired;
} else { } else {
doctorError = null; doctorError = null;
} }
if (_selectedFrequency == null) { if (_selectedFrequency == null) {
frequencyError = TranslationBase.of(context).fieldRequired; frequencyError =
TranslationBase.of(context).fieldRequired;
} else { } else {
frequencyError = null; frequencyError = null;
} }
@ -509,7 +563,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
projectID: _selectedBranch['facilityId'], projectID: _selectedBranch['facilityId'],
clinicID: _selectedClinic['ClinicID'], clinicID: _selectedClinic['ClinicID'],
doctorID: _selectedDoctor['DoctorID'], doctorID: _selectedDoctor['DoctorID'],
frequencyCode: _selectedFrequency['ParameterCode'], frequencyCode:
_selectedFrequency['ParameterCode'],
ext: _extController.text, ext: _extController.text,
remarks: _remarksController.text, remarks: _remarksController.text,
priority: _activePriority, priority: _activePriority,
@ -517,7 +572,9 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
if (model.state == ViewState.ErrorLocal) if (model.state == ViewState.ErrorLocal)
DrAppToastMsg.showErrorToast(model.error); DrAppToastMsg.showErrorToast(model.error);
else { else {
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsg); DrAppToastMsg.showSuccesToast(
TranslationBase.of(context)
.referralSuccessMsg);
Navigator.pop(context); Navigator.pop(context);
} }
} }
@ -542,7 +599,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
]; ];
return Container( return Container(
height: screenSize.height * 0.070, height: screenSize.height * 0.070,
decoration: containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)), decoration:
containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)),
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -554,13 +612,15 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
child: Container( child: Container(
height: screenSize.height * 0.070, height: screenSize.height * 0.070,
decoration: containerBorderDecoration( decoration: containerBorderDecoration(
_isActive ? Color(0XFFB8382B) : Colors.white, _isActive ? Color(0XFFB8382B) : Colors.white), _isActive ? Color(0XFFB8382B) : Colors.white,
_isActive ? Color(0XFFB8382B) : Colors.white),
child: Center( child: Center(
child: Text( child: Text(
item, item,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: _isActive ? Colors.white : Colors.black, //Colors.black, color: _isActive ? Colors.white : Colors.black,
//Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@ -600,7 +660,8 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
return time; return time;
} }
BoxDecoration containerBorderDecoration(Color containerColor, Color borderColor) { BoxDecoration containerBorderDecoration(
Color containerColor, Color borderColor) {
return BoxDecoration( return BoxDecoration(
color: containerColor, color: containerColor,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,

Loading…
Cancel
Save