Merge branch 'favourite_prescription' into 'development'

hot fix

See merge request Cloud_Solution/doctor_app_flutter!719
merge-requests/711/merge
Mohammad Aljammal 5 years ago
commit 6439bb9a90

@ -25,12 +25,10 @@ import 'package:speech_to_text/speech_to_text.dart' as stt;
class PatientMakeInPatientReferralScreen extends StatefulWidget { class PatientMakeInPatientReferralScreen extends StatefulWidget {
@override @override
_PatientMakeInPatientReferralScreenState createState() => _PatientMakeInPatientReferralScreenState createState() => _PatientMakeInPatientReferralScreenState();
_PatientMakeInPatientReferralScreenState();
} }
class _PatientMakeInPatientReferralScreenState class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatientReferralScreen> {
extends State<PatientMakeInPatientReferralScreen> {
PatiantInformtion patient; PatiantInformtion patient;
List<dynamic> referToList; List<dynamic> referToList;
dynamic _referTo; dynamic _referTo;
@ -68,8 +66,7 @@ class _PatientMakeInPatientReferralScreenState
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( bool available = await speech.initialize(onStatus: statusListener, onError: errorListener);
onStatus: statusListener, onError: errorListener);
if (available) { if (available) {
speech.listen( speech.listen(
onResult: resultListener, onResult: resultListener,
@ -113,8 +110,7 @@ class _PatientMakeInPatientReferralScreenState
} }
Future<void> initSpeechState() async { Future<void> initSpeechState() async {
bool hasSpeech = await speech.initialize( bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener);
onError: errorListener, onStatus: statusListener);
print(hasSpeech); print(hasSpeech);
if (!mounted) return; if (!mounted) return;
} }
@ -127,14 +123,8 @@ class _PatientMakeInPatientReferralScreenState
String arrivalType = routeArgs['arrivalType']; String arrivalType = routeArgs['arrivalType'];
bool isInpatient = routeArgs['isInpatient']; bool isInpatient = routeArgs['isInpatient'];
referToList = List(); referToList = List();
dynamic sameBranch = { dynamic sameBranch = {"id": 1, "name": TranslationBase.of(context).sameBranch};
"id": 1, dynamic otherBranch = {"id": 2, "name": TranslationBase.of(context).otherBranch};
"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);
@ -188,8 +178,7 @@ class _PatientMakeInPatientReferralScreenState
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: TranslationBase.of(context).branch, hintText: TranslationBase.of(context).branch,
dropDownText: dropDownText: _referTo != null ? _referTo['name'] : null,
_referTo != null ? _referTo['name'] : null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: branchError, validationError: branchError,
@ -206,23 +195,15 @@ class _PatientMakeInPatientReferralScreenState
_selectedBranch = null; _selectedBranch = null;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
model model.getDoctorBranch().then((value) async {
.getDoctorBranch()
.then((value) async {
_selectedBranch = value; _selectedBranch = value;
if (_referTo['id'] == 1) { if (_referTo['id'] == 1) {
GifLoaderDialogUtils.showMyDialog( GifLoaderDialogUtils.showMyDialog(context);
context);
await model await model
.getClinics(_selectedBranch[ .getClinics(_selectedBranch['facilityId'])
'facilityId']) .then((_) => GifLoaderDialogUtils.hideDialog(context));
.then((_) => if (model.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils DrAppToastMsg.showErrorToast(model.error);
.hideDialog(context));
if (model.state ==
ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(
model.error);
} }
} else { } else {
_selectedBranch = null; _selectedBranch = null;
@ -247,9 +228,7 @@ class _PatientMakeInPatientReferralScreenState
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 dropDownText: _selectedBranch != null ? _selectedBranch['facilityName'] : null,
? _selectedBranch['facilityName']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: hospitalError, validationError: hospitalError,
@ -268,17 +247,12 @@ class _PatientMakeInPatientReferralScreenState
_selectedBranch = selectedValue; _selectedBranch = selectedValue;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
GifLoaderDialogUtils.showMyDialog( GifLoaderDialogUtils.showMyDialog(context);
context);
await model await model
.getClinics( .getClinics(_selectedBranch['facilityId'])
_selectedBranch['facilityId']) .then((_) => GifLoaderDialogUtils.hideDialog(context));
.then((_) => GifLoaderDialogUtils if (model.state == ViewState.ErrorLocal) {
.hideDialog(context)); DrAppToastMsg.showErrorToast(model.error);
if (model.state ==
ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(
model.error);
} }
}); });
}, },
@ -299,9 +273,7 @@ class _PatientMakeInPatientReferralScreenState
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 dropDownText: _selectedClinic != null ? _selectedClinic['ClinicDescription'] : null,
? _selectedClinic['ClinicDescription']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: clinicError, validationError: clinicError,
@ -314,27 +286,19 @@ class _PatientMakeInPatientReferralScreenState
attributeName: 'ClinicDescription', attributeName: 'ClinicDescription',
attributeValueId: 'ClinicID', attributeValueId: 'ClinicID',
usingSearch: true, usingSearch: true,
hintSearchText: hintSearchText: TranslationBase.of(context).clinicSearch,
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( GifLoaderDialogUtils.showMyDialog(context);
context);
await model await model
.getClinicDoctors( .getClinicDoctors(
patient, patient, _selectedClinic['ClinicID'], _selectedBranch['facilityId'])
_selectedClinic['ClinicID'], .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);
} }
}); });
}, },
@ -355,49 +319,41 @@ class _PatientMakeInPatientReferralScreenState
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 dropDownText: _selectedDoctor != null ? _selectedDoctor['Name'] : null,
? _selectedDoctor['Name']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: doctorError, validationError: doctorError,
onClick: _selectedClinic != null && onClick:
model.doctorsList != null && _selectedClinic != null && model.doctorsList != null && model.doctorsList.length > 0
model.doctorsList.length > 0 ? () {
? () { ListSelectDialog dialog = ListSelectDialog(
ListSelectDialog dialog = ListSelectDialog( list: model.doctorsList,
list: model.doctorsList, attributeName: 'Name',
attributeName: 'Name', attributeValueId: 'DoctorID',
attributeValueId: 'DoctorID', usingSearch: true,
usingSearch: true, hintSearchText: TranslationBase.of(context).doctorSearch,
hintSearchText: okText: TranslationBase.of(context).ok,
TranslationBase.of(context) okFunction: (selectedValue) {
.doctorSearch, setState(() {
okText: TranslationBase.of(context).ok, _selectedDoctor = selectedValue;
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,
@ -425,11 +381,8 @@ class _PatientMakeInPatientReferralScreenState
), ),
AppTextFieldCustom( AppTextFieldCustom(
height: screenSize.height * 0.075, height: screenSize.height * 0.075,
hintText: hintText: TranslationBase.of(context).referralFrequency,
TranslationBase.of(context).referralFrequency, dropDownText: _selectedFrequency != null ? _selectedFrequency['Description'] : null,
dropDownText: _selectedFrequency != null
? _selectedFrequency['Description']
: null,
enabled: false, enabled: false,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: frequencyError, validationError: frequencyError,
@ -439,8 +392,7 @@ class _PatientMakeInPatientReferralScreenState
attributeName: 'Description', attributeName: 'Description',
attributeValueId: 'ParameterCode', attributeValueId: 'ParameterCode',
usingSearch: true, usingSearch: true,
hintSearchText: TranslationBase.of(context) hintSearchText: TranslationBase.of(context).selectReferralFrequency,
.selectReferralFrequency,
okText: TranslationBase.of(context).ok, okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) { okFunction: (selectedValue) {
setState(() { setState(() {
@ -478,8 +430,7 @@ class _PatientMakeInPatientReferralScreenState
maxLines: 6, maxLines: 6,
), ),
Positioned( Positioned(
top: top: 0, //MediaQuery.of(context).size.height * 0,
0, //MediaQuery.of(context).size.height * 0,
right: 15, right: 15,
child: IconButton( child: IconButton(
icon: Icon( icon: Icon(
@ -488,8 +439,7 @@ class _PatientMakeInPatientReferralScreenState
size: 35, size: 35,
), ),
onPressed: () { onPressed: () {
initSpeechState() initSpeechState().then((value) => {onVoiceText()});
.then((value) => {onVoiceText()});
}, },
), ),
), ),
@ -524,32 +474,27 @@ class _PatientMakeInPatientReferralScreenState
onPressed: () async { onPressed: () async {
setState(() { setState(() {
if (_referTo == null) { if (_referTo == null) {
branchError = branchError = TranslationBase.of(context).fieldRequired;
TranslationBase.of(context).fieldRequired;
} else { } else {
branchError = null; branchError = null;
} }
if (_selectedBranch == null) { if (_selectedBranch == null) {
hospitalError = hospitalError = TranslationBase.of(context).fieldRequired;
TranslationBase.of(context).fieldRequired;
} else { } else {
hospitalError = null; hospitalError = null;
} }
if (_selectedClinic == null) { if (_selectedClinic == null) {
clinicError = clinicError = TranslationBase.of(context).fieldRequired;
TranslationBase.of(context).fieldRequired;
} else { } else {
clinicError = null; clinicError = null;
} }
if (_selectedDoctor == null) { if (_selectedDoctor == null) {
doctorError = doctorError = TranslationBase.of(context).fieldRequired;
TranslationBase.of(context).fieldRequired;
} else { } else {
doctorError = null; doctorError = null;
} }
if (_selectedFrequency == null) { if (_selectedFrequency == null) {
frequencyError = frequencyError = TranslationBase.of(context).fieldRequired;
TranslationBase.of(context).fieldRequired;
} else { } else {
frequencyError = null; frequencyError = null;
} }
@ -566,8 +511,7 @@ class _PatientMakeInPatientReferralScreenState
projectID: _selectedBranch['facilityId'], projectID: _selectedBranch['facilityId'],
clinicID: _selectedClinic['ClinicID'], clinicID: _selectedClinic['ClinicID'],
doctorID: _selectedDoctor['DoctorID'], doctorID: _selectedDoctor['DoctorID'],
frequencyCode: frequencyCode: _selectedFrequency['ParameterCode'],
_selectedFrequency['ParameterCode'],
ext: _extController.text, ext: _extController.text,
remarks: _remarksController.text, remarks: _remarksController.text,
priority: _activePriority, priority: _activePriority,
@ -575,9 +519,7 @@ class _PatientMakeInPatientReferralScreenState
if (model.state == ViewState.ErrorLocal) if (model.state == ViewState.ErrorLocal)
DrAppToastMsg.showErrorToast(model.error); DrAppToastMsg.showErrorToast(model.error);
else { else {
DrAppToastMsg.showSuccesToast( DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsg);
TranslationBase.of(context)
.referralSuccessMsg);
Navigator.pop(context); Navigator.pop(context);
} }
} }
@ -602,8 +544,7 @@ class _PatientMakeInPatientReferralScreenState
]; ];
return Container( return Container(
height: screenSize.height * 0.070, height: screenSize.height * 0.070,
decoration: decoration: containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)),
containerBorderDecoration(Color(0Xffffffff), Color(0xFFCCCCCC)),
child: Row( child: Row(
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -615,16 +556,13 @@ class _PatientMakeInPatientReferralScreenState
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 color: _isActive ? Colors.white : Colors.black, //Colors.black,
? Colors.white
: Colors.black, //Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
@ -664,8 +602,7 @@ class _PatientMakeInPatientReferralScreenState
return time; return time;
} }
BoxDecoration containerBorderDecoration( BoxDecoration containerBorderDecoration(Color containerColor, Color borderColor) {
Color containerColor, Color borderColor) {
return BoxDecoration( return BoxDecoration(
color: containerColor, color: containerColor,
shape: BoxShape.rectangle, shape: BoxShape.rectangle,

@ -147,8 +147,16 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
@override @override
void initState() { void initState() {
super.initState(); requestPermissions();
event.controller.stream.listen((p) {
if (p['startPopUp'] == 'true') {
if (this.mounted) {
initSpeechState().then((value) => {onVoiceText()});
}
}
});
selectedType = 1; selectedType = 1;
super.initState();
} }
setSelectedType(int val) { setSelectedType(int val) {
@ -195,7 +203,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
setState(() { setState(() {
SpeechToText.closeAlertDialog(context); SpeechToText.closeAlertDialog(context);
speech.stop(); speech.stop();
indicationController.text += reconizedWord + '\n'; instructionController.text += reconizedWord + '\n';
}); });
} else { } else {
print(result.finalResult); print(result.finalResult);
@ -263,25 +271,6 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
SizedBox( SizedBox(
height: 60, height: 60,
), ),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(
TranslationBase.of(context).newPrescriptionOrder,
fontWeight: FontWeight.w700,
fontSize: 20,
),
InkWell(
child: Icon(
Icons.close,
size: 24.0,
),
onTap: () {
Navigator.pop(context);
},
)
],
),
], ],
), ),
SizedBox( SizedBox(
@ -635,9 +624,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
size: 35, size: 35,
), ),
onPressed: () { onPressed: () {
setState(() { initSpeechState().then((value) => {onVoiceText()});
initSpeechState().then((value) => {onVoiceText()});
});
}, },
), ),
), ),

@ -136,8 +136,16 @@ class _PrescriptionCheckOutScreenState extends State<PrescriptionCheckOutScreen>
@override @override
void initState() { void initState() {
super.initState(); requestPermissions();
event.controller.stream.listen((p) {
if (p['startPopUp'] == 'true') {
if (this.mounted) {
initSpeechState().then((value) => {onVoiceText()});
}
}
});
selectedType = 1; selectedType = 1;
super.initState();
} }
onVoiceText() async { onVoiceText() async {
@ -512,29 +520,7 @@ class _PrescriptionCheckOutScreenState extends State<PrescriptionCheckOutScreen>
}, },
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
// Container(
// color: Colors.white,
// child: AppTextFieldCustom(
// hintText: "UOM",
// isTextFieldHasSuffix: false,
// dropDownText: uom != null ? uom : null,
// enabled: false,
// ),
// ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
// Container(
// color: Colors.white,
// child: AppTextFieldCustom(
// hintText: TranslationBase.of(context).boxQuantity,
// isTextFieldHasSuffix: false,
// dropDownText: box != null
// ? TranslationBase.of(context).boxQuantity +
// ": " +
// model.boxQuintity.toString()
// : null,
// enabled: false,
// ),
// ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -559,9 +545,7 @@ class _PrescriptionCheckOutScreenState extends State<PrescriptionCheckOutScreen>
size: 35, size: 35,
), ),
onPressed: () { onPressed: () {
setState(() { initSpeechState().then((value) => {onVoiceText()});
initSpeechState().then((value) => {onVoiceText()});
});
}, },
), ),
), ),

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save