Merge branch 'medical-profile-services' into 'development'

Medical profile services

See merge request Cloud_Solution/doctor_app_flutter!689
merge-requests/690/merge
Mohammad Aljammal 5 years ago
commit b9831adeb2

@ -1,6 +1,7 @@
const Map<String, Map<String, String>> localizedValues = {
'dashboardScreenToolbarTitle': {'ar': 'الرئيسة', 'en': 'Home'},
'settings': {'en': 'Settings', 'ar': 'الاعدادات'},
'areYouSureYouWantTo': {'en': 'Are you sure you want to', 'ar': 'هل انت متاكد من انك تريد أن'},
'language': {'en': 'App Language', 'ar': 'لغة التطبيق'},
'lanEnglish': {'en': 'English', 'ar': 'English'},
'lanArabic': {'en': 'العربية', 'ar': 'العربية'},

@ -12,6 +12,7 @@ class LiveCarePatientServices extends BaseService{
bool get isFinished => _isFinished;
var endCallResponse = {};
var transferToAdminResponse = {};
Future getPendingPatientERForDoctorApp(PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async{
hasError = false;
@ -42,4 +43,39 @@ class LiveCarePatientServices extends BaseService{
}, body: endCallReq.toJson());
}
Future endCallWithCharge(int vcID) async{
hasError = false;
await baseAppClient.post(
END_CALL_WITH_CHARGE,
onSuccess: (dynamic response, int statusCode) {
endCallResponse = response;
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: {
"VC_ID": vcID,
},
);
}
Future transferToAdmin(int vcID, String notes) async{
hasError = false;
await baseAppClient.post(
TRANSFERT_TO_ADMIN,
onSuccess: (dynamic response, int statusCode) {
transferToAdminResponse = response;
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: {
"VC_ID": vcID,
"IsOutKsa": false,
"Notes": notes,
},
);
}
}

@ -11,8 +11,6 @@ class PatientMedicalReportService extends BaseService {
Future getMedicalReportList(PatiantInformtion patient) async {
hasError = false;
Map<String, dynamic> body = Map();
// body['TokenID'] = "@dm!n";
body['SetupID'] = "91877";
body['AdmissionNo'] = patient.admissionNo;
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_GET_LIST,

@ -57,6 +57,32 @@ class LiveCarePatientViewModel extends BaseViewModel {
}
}
Future endCallWithCharge(int vcID) async {
setState(ViewState.BusyLocal);
await _liveCarePatientServices
.endCallWithCharge(vcID);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
await getPendingPatientERForDoctorApp();
setState(ViewState.Idle);
}
}
Future transferToAdmin(int vcID, String notes) async {
setState(ViewState.BusyLocal);
await _liveCarePatientServices
.transferToAdmin(vcID, notes);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
await getPendingPatientERForDoctorApp();
setState(ViewState.Idle);
}
}
searchData(String str) {
var strExist= str.length > 0 ? true : false;
if (strExist) {

@ -1,12 +1,19 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.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/live_care/live-care_transfer_to_admin.dart';
import 'package:doctor_app_flutter/screens/patients/profile/profile_screen/PatientProfileCardModel.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/PatientProfileButton.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-header-new-design-app-bar.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/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:hexcolor/hexcolor.dart';
@ -30,23 +37,38 @@ class _EndCallScreenState extends State<EndCallScreen> {
String from;
String to;
LiveCarePatientViewModel liveCareModel;
@override
Widget build(BuildContext context) {
final List<PatientProfileCardModel> cardsList = [
PatientProfileCardModel(TranslationBase.of(context).resume,
TranslationBase.of(context).theCall, '', 'patient/vital_signs.png',
isInPatient: isInpatient, onTap: () {}, isDartIcon: true,
isInPatient: isInpatient,
onTap: () {},
isDartIcon: true,
dartIcon: DoctorApp.call),
PatientProfileCardModel(
TranslationBase.of(context).endLC,
TranslationBase.of(context).consultation,
'',
'patient/vital_signs.png',
isInPatient: isInpatient,
onTap: () {},
isDartIcon: true,
dartIcon: DoctorApp.end_consultaion
),
isInPatient: isInpatient, onTap: () {
Helpers.showConfirmationDialog(context,
"${TranslationBase.of(context).areYouSureYouWantTo} ${TranslationBase.of(context).endLC} ${TranslationBase.of(context).consultation} ?",
() async {
Navigator.of(context).pop();
GifLoaderDialogUtils.showMyDialog(context);
liveCareModel.endCallWithCharge(widget.patient.vcId);
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
} else {
Navigator.of(context).pop();
Navigator.of(context).pop();
}
});
}, isDartIcon: true, dartIcon: DoctorApp.end_consultaion),
PatientProfileCardModel(
TranslationBase.of(context).sendLC,
TranslationBase.of(context).instruction,
@ -55,128 +77,136 @@ class _EndCallScreenState extends State<EndCallScreen> {
onTap: () {},
isInPatient: isInpatient,
isDartIcon: true,
dartIcon: DoctorApp.send_instruction
),
PatientProfileCardModel(
TranslationBase.of(context).transferTo,
TranslationBase.of(context).admin,
'',
'patient/health_summary.png',
onTap: () {},
isInPatient: isInpatient,
isDartIcon: true,
dartIcon: DoctorApp.transfer_to_admin
),
dartIcon: DoctorApp.send_instruction),
PatientProfileCardModel(TranslationBase.of(context).transferTo,
TranslationBase.of(context).admin, '', 'patient/health_summary.png',
onTap: () {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) =>
LivaCareTransferToAdmin(patient:widget.patient)));
},
isInPatient: isInpatient,
isDartIcon: true,
dartIcon: DoctorApp.transfer_to_admin),
];
return AppScaffold(
appBarTitle: TranslationBase.of(context).patientProfile,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
isShowAppBar: true,
appBar: PatientProfileHeaderNewDesignAppBar(
widget.patient, arrivalType ?? '7', '1',
isInpatient: isInpatient,
height: (widget.patient.patientStatusType != null &&
widget.patient.patientStatusType == 43)
? 210
: isDischargedPatient
? 240
: 0,
isDischargedPatient: isDischargedPatient),
body: Container(
height: !isSearchAndOut
? isDischargedPatient
? MediaQuery.of(context).size.height * 0.64
: MediaQuery.of(context).size.height * 0.65
: MediaQuery.of(context).size.height * 0.69,
child: ListView(
children: [
Padding(
padding: const EdgeInsets.symmetric(
vertical: 15.0, horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
TranslationBase.of(context).patient,
fontSize: 14,
fontWeight: FontWeight.w500,
),
AppText(TranslationBase.of(context).endcall,
fontSize: 26,
fontWeight: FontWeight.bold,
),
SizedBox(height: 10,),
StaggeredGridView.countBuilder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
itemCount: cardsList.length,
staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
itemBuilder: (BuildContext context, int index) =>
PatientProfileButton(
patient: widget.patient,
patientType: patientType,
arrivalType: arrivalType,
from: from,
to: to,
nameLine1: cardsList[index].nameLine1,
nameLine2: cardsList[index].nameLine2,
route: cardsList[index].route,
icon: cardsList[index].icon,
isInPatient: cardsList[index].isInPatient,
isDischargedPatient: cardsList[index].isDischargedPatient,
isDisable: cardsList[index].isDisable,
onTap: cardsList[index].onTap,
isLoading: cardsList[index].isLoading,
isDartIcon: cardsList[index].isDartIcon,
dartIcon: cardsList[index].dartIcon,
return BaseView<LiveCarePatientViewModel>(
onModelReady: (model) {
liveCareModel = model;
},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
appBarTitle: TranslationBase.of(context).patientProfile,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
isShowAppBar: true,
appBar: PatientProfileHeaderNewDesignAppBar(
widget.patient, arrivalType ?? '7', '1',
isInpatient: isInpatient,
height: (widget.patient.patientStatusType != null &&
widget.patient.patientStatusType == 43)
? 210
: isDischargedPatient
? 240
: 0,
isDischargedPatient: isDischargedPatient),
body: Container(
height: !isSearchAndOut
? isDischargedPatient
? MediaQuery.of(context).size.height * 0.64
: MediaQuery.of(context).size.height * 0.65
: MediaQuery.of(context).size.height * 0.69,
child: ListView(
children: [
Padding(
padding:
const EdgeInsets.symmetric(vertical: 15.0, horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
TranslationBase.of(context).patient,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
],
AppText(
TranslationBase.of(context).endcall,
fontSize: 26,
fontWeight: FontWeight.bold,
),
SizedBox(
height: 10,
),
StaggeredGridView.countBuilder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
itemCount: cardsList.length,
staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
itemBuilder: (BuildContext context, int index) =>
PatientProfileButton(
patient: widget.patient,
patientType: patientType,
arrivalType: arrivalType,
from: from,
to: to,
nameLine1: cardsList[index].nameLine1,
nameLine2: cardsList[index].nameLine2,
route: cardsList[index].route,
icon: cardsList[index].icon,
isInPatient: cardsList[index].isInPatient,
isDischargedPatient:
cardsList[index].isDischargedPatient,
isDisable: cardsList[index].isDisable,
onTap: cardsList[index].onTap,
isLoading: cardsList[index].isLoading,
isDartIcon: cardsList[index].isDartIcon,
dartIcon: cardsList[index].dartIcon,
),
),
],
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
)
],
),
),
bottomSheet: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(0.0),
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
)
],
),
border: Border.all(color: HexColor('#707070'), width: 0),
),
height: MediaQuery.of(context).size.height * 0.1,
width: double.infinity,
child: Column(
children: [
SizedBox(
height: 10,
bottomSheet: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(0.0),
),
Container(
child: FractionallySizedBox(
widthFactor: .80,
child: Center(
child: AppButton(
fontWeight: FontWeight.w700,
color: Colors.red[600],
title: "Close", //TranslationBase.of(context).close,
onPressed: () async {},
border: Border.all(color: HexColor('#707070'), width: 0),
),
height: MediaQuery.of(context).size.height * 0.1,
width: double.infinity,
child: Column(
children: [
SizedBox(
height: 10,
),
Container(
child: FractionallySizedBox(
widthFactor: .80,
child: Center(
child: AppButton(
fontWeight: FontWeight.w700,
color: Colors.red[600],
title: "Close", //TranslationBase.of(context).close,
onPressed: () async {},
),
),
),
),
),
SizedBox(
height: 5,
),
],
SizedBox(
height: 5,
),
],
),
),
),
);

@ -0,0 +1,197 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/provider/robot_provider.dart';
import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.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/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/button_bottom_sheet.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/speech-text-popup.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt;
class LivaCareTransferToAdmin extends StatefulWidget {
final PatiantInformtion patient;
const LivaCareTransferToAdmin({Key key, this.patient}) : super(key: key);
@override
_LivaCareTransferToAdminState createState() =>
_LivaCareTransferToAdminState();
}
class _LivaCareTransferToAdminState extends State<LivaCareTransferToAdmin> {
stt.SpeechToText speech = stt.SpeechToText();
var reconizedWord;
var event = RobotProvider();
ProjectViewModel projectViewModel;
TextEditingController noteController = TextEditingController();
String noteError;
void initState() {
requestPermissions();
event.controller.stream.listen((p) {
if (p['startPopUp'] == 'true') {
if (this.mounted) {
initSpeechState().then((value) => {onVoiceText()});
}
}
});
super.initState();
}
@override
Widget build(BuildContext context) {
projectViewModel = Provider.of(context);
return BaseView<LiveCarePatientViewModel>(
onModelReady: (model) {},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
appBarTitle:
"${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin}",
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
isShowAppBar: true,
body: Container(
child: Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Container(
color: Colors.white,
margin: EdgeInsets.all(16),
child: Stack(
children: [
AppTextFieldCustom(
hintText: TranslationBase.of(context).notes,
//TranslationBase.of(context).addProgressNote,
controller: noteController,
maxLines: 35,
minLines: 25,
hasBorder: true,
validationError: noteError,
),
Positioned(
top: -2, //MediaQuery.of(context).size.height * 0,
right: projectViewModel.isArabic
? MediaQuery.of(context).size.width * 0.75
: 15,
child: Column(
children: [
IconButton(
icon: Icon(DoctorApp.speechtotext,
color: Colors.black, size: 35),
onPressed: () {
initSpeechState()
.then((value) => {onVoiceText()});
},
),
],
))
],
),
),
),
),
ButtonBottomSheet(
title:
"${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin}",
onPressed: () {
setState(() {
if (noteController.text.isEmpty) {
noteError = TranslationBase.of(context).emptyMessage;
} else {
noteError = null;
}
if (noteController.text.isNotEmpty) {
Helpers.showConfirmationDialog(context,
"${TranslationBase.of(context).areYouSureYouWantTo} ${TranslationBase.of(context).transferTo}${TranslationBase.of(context).admin} ?",
() async {
Navigator.of(context).pop();
GifLoaderDialogUtils.showMyDialog(context);
model.endCallWithCharge(widget.patient.vcId);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
} else {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
}
});
}
});
},
)
],
),
),
),
);
}
onVoiceText() async {
new SpeechToText(context: context).showAlertDialog(context);
var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode;
bool available = await speech.initialize(
onStatus: statusListener, onError: errorListener);
if (available) {
speech.listen(
onResult: resultListener,
listenMode: stt.ListenMode.confirmation,
localeId: lang == 'en' ? 'en-US' : 'ar-SA',
);
} else {
print("The user has denied the use of speech recognition.");
}
}
void errorListener(SpeechRecognitionError error) {
event.setValue({"searchText": 'null'});
//SpeechToText.closeAlertDialog(context);
print(error);
}
void statusListener(String status) {
reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....';
}
void requestPermissions() async {
Map<Permission, PermissionStatus> statuses = await [
Permission.microphone,
].request();
}
void resultListener(result) {
reconizedWord = result.recognizedWords;
event.setValue({"searchText": reconizedWord});
if (result.finalResult == true) {
setState(() {
SpeechToText.closeAlertDialog(context);
speech.stop();
noteController.text += reconizedWord + '\n';
});
} else {
print(result.finalResult);
}
}
Future<void> initSpeechState() async {
bool hasSpeech = await speech.initialize(
onError: errorListener, onStatus: statusListener);
print(hasSpeech);
if (!mounted) return;
}
}

@ -279,13 +279,13 @@ class _PatientProfileScreenState extends State<PatientProfileScreen>
.of(context)
.initiateCall,
onPressed: () async {
if(model.isFinished) {
// if(model.isFinished) {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) =>
EndCallScreen(patient:patient)));
} else {
// TODO Call initiateCall service
}
// } else {
// // TODO Call initiateCall service
// }
},
),

@ -8,6 +8,8 @@ import 'package:doctor_app_flutter/models/doctor/list_doctor_working_hours_table
import 'package:doctor_app_flutter/screens/auth/login_screen.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -24,7 +26,47 @@ class Helpers {
static int cupertinoPickerIndex = 0;
get currentLanguage => null;
static showCupertinoPicker(context, List<GetHospitalsResponseModel> items, decKey, onSelectFun, AuthenticationViewModel model) {
static showConfirmationDialog(
BuildContext context, String message, Function okFunction) {
return showDialog(
context: context,
barrierDismissible: false, // user must tap button!
builder: (_) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AlertDialog(
title: null,
content: Container(
child: AppText(message),
),
actions: [
AppButton(
onPressed: okFunction,
title: TranslationBase.of(context).noteConfirm,
fontColor: Colors.white,
color: Colors.green[600],
),
AppButton(
onPressed: (){
Navigator.of(context).pop();
},
title: TranslationBase.of(context).cancel,
fontColor: Colors.white,
color: Colors.red[600],
),
],
),
],
),
);
});
}
static showCupertinoPicker(context, List<GetHospitalsResponseModel> items,
decKey, onSelectFun, AuthenticationViewModel model) {
showModalBottomSheet(
isDismissible: false,
context: context,
@ -64,8 +106,8 @@ class Helpers {
Container(
height: SizeConfig.realScreenHeight * 0.3,
color: Color(0xfff7f7f7),
child:
buildPickerItems(context, items, decKey, onSelectFun, model))
child: buildPickerItems(
context, items, decKey, onSelectFun, model))
],
),
);
@ -75,7 +117,8 @@ class Helpers {
static TextStyle textStyle(context) =>
TextStyle(color: Theme.of(context).primaryColor);
static buildPickerItems(context, List<GetHospitalsResponseModel> items, decKey, onSelectFun, model) {
static buildPickerItems(context, List<GetHospitalsResponseModel> items,
decKey, onSelectFun, model) {
return CupertinoPicker(
magnification: 1.5,
scrollController:

@ -18,6 +18,8 @@ class TranslationBase {
String get settings => localizedValues['settings'][locale.languageCode];
String get areYouSureYouWantTo => localizedValues['areYouSureYouWantTo'][locale.languageCode];
String get language => localizedValues['language'][locale.languageCode];
String get lanEnglish => localizedValues['lanEnglish'][locale.languageCode];

@ -42,23 +42,27 @@ class ButtonBottomSheet extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: AppButton(
title: title,
onPressed: onPressed,
fontWeight: fontWeight,
color: color,
fontSize: fontSize,
padding: padding,
disabled: disabled,
radius: radius,
hasBorder: hasBorder,
fontColor: fontColor,
icon: icon,
iconData: iconData,
hPadding: hPadding,
vPadding: vPadding,
borderColor: borderColor,
loading: loading,
child: Column(
children: [
AppButton(
title: title,
onPressed: onPressed,
fontWeight: fontWeight,
color: color,
fontSize: fontSize,
padding: padding,
disabled: disabled,
radius: radius,
hasBorder: hasBorder,
fontColor: fontColor,
icon: icon,
iconData: iconData,
hPadding: hPadding,
vPadding: vPadding,
borderColor: borderColor,
loading: loading,
),
],
),
);
}

Loading…
Cancel
Save