Add video call service

merge-requests/745/head
Mohammad Aljammal 3 years ago
parent 0868de7961
commit 746f44157e

@ -370,6 +370,8 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
}
isConnected = true
subscribeToStream(stream)
if (mConnectedHandler != null && mConnectedRunnable != null)
mConnectedHandler!!.removeCallbacks(mConnectedRunnable!!)
videoCallPresenter.callChangeCallStatus(ChangeCallStatusRequestModel(3, sessionStatusModel!!.doctorId, sessionStatusModel!!.generalid, token, sessionStatusModel!!.vcid))
}

@ -3,9 +3,15 @@ import 'package:flutter/material.dart';
class NavigationService {
final GlobalKey<NavigatorState> navigatorKey =
new GlobalKey<NavigatorState>();
Future<dynamic> navigateTo(String routeName) {
return navigatorKey.currentState.pushNamed(routeName);
Future<dynamic> navigateTo(String routeName,{Object arguments}) {
return navigatorKey.currentState.pushNamed(routeName,arguments: arguments);
}
Future<dynamic> pushReplacementNamed(String routeName,{Object arguments}) {
return navigatorKey.currentState.pushReplacementNamed(routeName,arguments: arguments);
}
Future<dynamic> pushNamedAndRemoveUntil(String routeName) {
return navigatorKey.currentState.pushNamedAndRemoveUntil(routeName,(asd)=>false);
}

@ -0,0 +1,88 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/core/service/patient/LiveCarePatientServices.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/livecare/end_call_req.dart';
import 'package:doctor_app_flutter/models/livecare/session_status_model.dart';
import 'package:doctor_app_flutter/models/livecare/start_call_res.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/util/VideoChannel.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import '../../locator.dart';
import '../../routes.dart';
import 'NavigationService.dart';
class VideoCallService extends BaseService{
StartCallRes startCallRes;
PatiantInformtion patient;
LiveCarePatientServices _liveCarePatientServices = locator<LiveCarePatientServices>();
openVideo(StartCallRes startModel,PatiantInformtion patientModel,VoidCallback onCallConnected, VoidCallback onCallDisconnected)async{
this.startCallRes = startModel;
this.patient = patientModel;
DoctorProfileModel doctorProfile = await getDoctorProfile(isGetProfile: true);
await VideoChannel.openVideoCallScreen(
kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGIyZDljOTY3YjFiNWU1YzUzNzFmMjIyNjJmNmEzY2Y5NzZjOTdlYzpzZXNzaW9uX2lkPTFfTVg0ME56STBOemsxTkg1LU1UWXlNekEyTlRRMU9EVXhObjVrVFRoMFlVdFJXaXRYTWpadFZGZHFhSGxZVGpOdE1UVi1mZyZjcmVhdGVfdGltZT0xNjIzMDY1NDk1Jm5vbmNlPTAuMjM2Mjk0NTIwMTkyOTA4OTcmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTYyNTY1NzQ5NCZpbml0aWFsX2xheW91dF9jbGFzc19saXN0PQ==",//startCallRes.openTokenID,
kSessionId: "1_MX40NzI0Nzk1NH5-MTYyMzA2NTQ1ODUxNn5kTTh0YUtRWitXMjZtVFdqaHlYTjNtMTV-fg",//startCallRes.openSessionID,
kApiKey: '47247954',//'46209962',
vcId: patient.vcId,
patientName: patient.fullName ?? (patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-"),
tokenID: await sharedPref.getString(TOKEN),
generalId: GENERAL_ID,
doctorId: doctorProfile.doctorID,
onFailure: (String error) {
DrAppToastMsg.showErrorToast(error);
},onCallConnected: onCallConnected,
onCallEnd: () {
WidgetsBinding.instance.addPostFrameCallback((_) async {
GifLoaderDialogUtils.showMyDialog(locator<NavigationService>().navigatorKey.currentContext);
endCall(patient.vcId, false,).then((value) {
GifLoaderDialogUtils.hideDialog(locator<NavigationService>().navigatorKey.currentContext);
if (hasError) {
DrAppToastMsg.showErrorToast(error);
}else
locator<NavigationService>().navigateTo(PATIENTS_END_Call,arguments: {
"patient": patient,
});
});
});
},
onCallNotRespond: (SessionStatusModel sessionStatusModel) {
WidgetsBinding.instance.addPostFrameCallback((_) {
GifLoaderDialogUtils.showMyDialog(locator<NavigationService>().navigatorKey.currentContext);
endCall(patient.vcId, sessionStatusModel.sessionStatus == 3,).then((value) {
GifLoaderDialogUtils.hideDialog(locator<NavigationService>().navigatorKey.currentContext);
if (hasError) {
DrAppToastMsg.showErrorToast(error);
} else {
locator<NavigationService>().navigateTo(PATIENTS_END_Call,arguments: {
"patient": patient,
});
}
});
});
});
}
Future endCall(int vCID, bool isPatient) async {
hasError = false;
// await getDoctorProfile(isGetProfile: true);
EndCallReq endCallReq = new EndCallReq();
endCallReq.doctorId = doctorProfile.doctorID;
endCallReq.generalid = 'Cs2020@2016\$2958';
endCallReq.vCID = vCID;
endCallReq.isDestroy = isPatient;
//await _liveCarePatientServices.endCall(endCallReq);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
}
}
}

@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/screens/home/home_screen.dart';
import 'package:doctor_app_flutter/screens/qr_reader/QR_reader_screen.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_drawer_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/bottom_nav_bar.dart';
import 'package:doctor_app_flutter/widgets/shared/user-guid/app_showcase_widget.dart';
import 'package:flutter/cupertino.dart';
@ -33,7 +34,7 @@ class _LandingPageState extends State<LandingPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
return AppScaffold(
appBar: currentTab != 0
? AppBar(
elevation: 0,

@ -11,6 +11,7 @@ import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
import 'package:get_it/get_it.dart';
import 'core/service/NavigationService.dart';
import 'core/service/VideoCallService.dart';
import 'core/service/home/dasboard_service.dart';
import 'core/service/home/doctor_reply_service.dart';
import 'core/service/home/schedule_service.dart';
@ -96,6 +97,7 @@ void setupLocator() {
locator.registerLazySingleton(() => NavigationService());
locator.registerLazySingleton(() => ScanQrService());
locator.registerLazySingleton(() => SpecialClinicsService());
locator.registerLazySingleton(() => VideoCallService());
/// View Model
locator.registerFactory(() => DoctorReplayViewModel());

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/root_page.dart';
import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart';
import 'package:doctor_app_flutter/screens/medical-file/health_summary_page.dart';
import 'package:doctor_app_flutter/screens/patients/ECGPage.dart';
import 'package:doctor_app_flutter/screens/patients/insurance_approval_screen_patient.dart';
@ -37,6 +38,7 @@ const String LOGIN = 'login';
const String VERIFICATION_METHODS = 'verification-methods';
const String PATIENTS = 'patients/patients';
const String PATIENTS_PROFILE = 'patients/patients-profile';
const String PATIENTS_END_Call = 'patients/patients-profile/endCall';
const String IN_PATIENTS_PROFILE = 'inpatients/patients-profile';
const String LAB_RESULT = 'patients/lab_result';
const String HEALTH_SUMMARY = 'patients/health-summary';
@ -88,6 +90,7 @@ var routes = {
PATIENT_MEDICAL_REPORT: (_) => MedicalReportPage(),
PATIENT_MEDICAL_REPORT_INSERT: (_) => AddVerifyMedicalReport(),
PATIENT_MEDICAL_REPORT_DETAIL: (_) => MedicalReportDetailPage(),
PATIENTS_END_Call: (_) => EndCallScreen(),
CREATE_EPISODE: (_) => UpdateSoapIndex(
isUpdate: true,
),

@ -23,9 +23,9 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:hexcolor/hexcolor.dart';
class EndCallScreen extends StatefulWidget {
final PatiantInformtion patient;
const EndCallScreen({Key key, this.patient}) : super(key: key);
const EndCallScreen({Key key,}) : super(key: key);
@override
_EndCallScreenState createState() => _EndCallScreenState();
@ -33,7 +33,7 @@ class EndCallScreen extends StatefulWidget {
class _EndCallScreenState extends State<EndCallScreen> {
bool isInpatient = false;
PatiantInformtion patient;
bool isDischargedPatient = false;
bool isSearchAndOut = false;
String patientType;
@ -43,6 +43,13 @@ class _EndCallScreenState extends State<EndCallScreen> {
LiveCarePatientViewModel liveCareModel;
@override
void didChangeDependencies() {
super.didChangeDependencies();
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
patient = routeArgs['patient'];
}
@override
Widget build(BuildContext context) {
final List<PatientProfileCardModel> cardsList = [
@ -53,7 +60,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
onTap: () async {
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel
.startCall(isReCall: false, vCID: widget.patient.vcId)
.startCall(isReCall: false, vCID: patient.vcId)
.then((value) async {
await liveCareModel.getDoctorProfile();
GifLoaderDialogUtils.hideDialog(context);
@ -64,8 +71,8 @@ class _EndCallScreenState extends State<EndCallScreen> {
kToken: liveCareModel.startCallRes.openTokenID,
kSessionId: liveCareModel.startCallRes.openSessionID,
kApiKey: '46209962',
vcId: widget.patient.vcId,
patientName: widget.patient.fullName ?? (widget.patient.firstName != null ? "${widget.patient.firstName} ${widget.patient.lastName}" : "-"),
vcId: patient.vcId,
patientName: patient.fullName ?? (patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-"),
tokenID: await liveCareModel.getToken(),
generalId: GENERAL_ID,
doctorId: liveCareModel.doctorProfile.doctorID,
@ -76,7 +83,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
GifLoaderDialogUtils.showMyDialog(context);
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.endCall(
widget.patient.vcId,
patient.vcId,
false,
);
GifLoaderDialogUtils.hideDialog(context);
@ -89,7 +96,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
GifLoaderDialogUtils.showMyDialog(context);
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.endCall(
widget.patient.vcId,
patient.vcId,
sessionStatusModel.sessionStatus == 3,
);
GifLoaderDialogUtils.hideDialog(context);
@ -116,14 +123,14 @@ class _EndCallScreenState extends State<EndCallScreen> {
() async {
Navigator.of(context).pop();
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.getAlternativeServices(widget.patient.vcId);
await liveCareModel.getAlternativeServices(patient.vcId);
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
} else {
showAlternativesDialog(context, liveCareModel, (bool isConfirmed) async {
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.endCallWithCharge(widget.patient.vcId, isConfirmed);
await liveCareModel.endCallWithCharge(patient.vcId, isConfirmed);
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
@ -147,7 +154,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
() async {
Navigator.of(context).pop();
GifLoaderDialogUtils.showMyDialog(context);
await liveCareModel.sendSMSInstruction(widget.patient.vcId);
await liveCareModel.sendSMSInstruction(patient.vcId);
GifLoaderDialogUtils.hideDialog(context);
if (liveCareModel.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(liveCareModel.error);
@ -169,7 +176,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
context,
MaterialPageRoute(
builder: (BuildContext context) =>
LivaCareTransferToAdmin(patient: widget.patient)));
LivaCareTransferToAdmin(patient: patient)));
},
isInPatient: isInpatient,
isDartIcon: true,
@ -186,10 +193,14 @@ class _EndCallScreenState extends State<EndCallScreen> {
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
isShowAppBar: true,
appBar: PatientProfileAppBar(
widget.patient,
patient,
onPressed: (){
Navigator.pop(context);
},
isInpatient: isInpatient,
height: (widget.patient.patientStatusType != null &&
widget.patient.patientStatusType == 43)
height: (patient.patientStatusType != null &&
patient.patientStatusType == 43)
? 210
: isDischargedPatient
? 240
@ -232,7 +243,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
staggeredTileBuilder: (int index) => StaggeredTile.fit(1),
itemBuilder: (BuildContext context, int index) =>
PatientProfileButton(
patient: widget.patient,
patient: patient,
patientType: patientType,
arrivalType: arrivalType,
from: from,
@ -331,6 +342,7 @@ class _EndCallScreenState extends State<EndCallScreen> {
),
AppButton(
onPressed: () {
Navigator.of(context).pop();
Navigator.of(context).pop();
okFunction(false);
},

@ -2,6 +2,7 @@ import 'dart:async';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/VideoCallService.dart';
import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart';
@ -25,6 +26,7 @@ import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:quiver/async.dart';
import '../../../../locator.dart';
import '../../../../routes.dart';
class PatientProfileScreen extends StatefulWidget {
@ -91,6 +93,9 @@ class _PatientProfileScreenState extends State<PatientProfileScreen>
if(routeArgs.containsKey("isFromLiveCare")) {
isFromLiveCare = routeArgs['isFromLiveCare'];
}
if(routeArgs.containsKey("isCallFinished")) {
isCallFinished = routeArgs['isCallFinished'];
}
if (isInpatient)
_activeTab = 0;
else
@ -333,9 +338,9 @@ class _PatientProfileScreenState extends State<PatientProfileScreen>
if(isCallFinished) {
Navigator.push(context, MaterialPageRoute(
builder: (BuildContext context) =>
EndCallScreen(patient:patient)));
// Navigator.push(context, MaterialPageRoute(
// builder: (BuildContext context) => EndCallScreen(patient:patient)));
var asd = "";
} else {
GifLoaderDialogUtils.showMyDialog(context);
// await model.startCall( isReCall : false, vCID: patient.vcId);
@ -349,49 +354,54 @@ class _PatientProfileScreenState extends State<PatientProfileScreen>
patient.episodeNo = 0;
GifLoaderDialogUtils.hideDialog(context);
await VideoChannel.openVideoCallScreen(
kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGIyZDljOTY3YjFiNWU1YzUzNzFmMjIyNjJmNmEzY2Y5NzZjOTdlYzpzZXNzaW9uX2lkPTFfTVg0ME56STBOemsxTkg1LU1UWXlNekEyTlRRMU9EVXhObjVrVFRoMFlVdFJXaXRYTWpadFZGZHFhSGxZVGpOdE1UVi1mZyZjcmVhdGVfdGltZT0xNjIzMDY1NDk1Jm5vbmNlPTAuMjM2Mjk0NTIwMTkyOTA4OTcmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTYyNTY1NzQ5NCZpbml0aWFsX2xheW91dF9jbGFzc19saXN0PQ==",//model.startCallRes.openTokenID,
kSessionId:"1_MX40NzI0Nzk1NH5-MTYyMzA2NTQ1ODUxNn5kTTh0YUtRWitXMjZtVFdqaHlYTjNtMTV-fg",// model.startCallRes.openSessionID,
kApiKey: '47247954',//46209962
vcId: patient.vcId,
patientName: patient.fullName ?? (patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-"),
tokenID: await model.getToken(),
generalId: GENERAL_ID,
doctorId: model.doctorProfile.doctorID,
onFailure: (String error) {
DrAppToastMsg.showErrorToast(error);
},onCallConnected: callConnected,
onCallEnd: () {
var asd="";
// WidgetsBinding.instance.addPostFrameCallback((_) {
// GifLoaderDialogUtils.showMyDialog(context);
// model.endCall(patient.vcId, false,).then((value) {
// GifLoaderDialogUtils.hideDialog(context);
// if (model.state == ViewState.ErrorLocal) {
// DrAppToastMsg.showErrorToast(model.error);
// }
// setState(() {
// isCallFinished = true;
// });
// });
// });
},
onCallNotRespond: (SessionStatusModel sessionStatusModel) {
var asd="";
// WidgetsBinding.instance.addPostFrameCallback((_) {
// GifLoaderDialogUtils.showMyDialog(context);
// model.endCall(patient.vcId, sessionStatusModel.sessionStatus == 3,).then((value) {
// GifLoaderDialogUtils.hideDialog(context);
// if (model.state == ViewState.ErrorLocal) {
// DrAppToastMsg.showErrorToast(model.error);
// }
// setState(() {
// isCallFinished = true;
// });
// });
//
// });
});
locator<VideoCallService>().openVideo(model.startCallRes, patient, callConnected, callDisconnected);
// await VideoChannel.openVideoCallScreen(
// kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGIyZDljOTY3YjFiNWU1YzUzNzFmMjIyNjJmNmEzY2Y5NzZjOTdlYzpzZXNzaW9uX2lkPTFfTVg0ME56STBOemsxTkg1LU1UWXlNekEyTlRRMU9EVXhObjVrVFRoMFlVdFJXaXRYTWpadFZGZHFhSGxZVGpOdE1UVi1mZyZjcmVhdGVfdGltZT0xNjIzMDY1NDk1Jm5vbmNlPTAuMjM2Mjk0NTIwMTkyOTA4OTcmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTYyNTY1NzQ5NCZpbml0aWFsX2xheW91dF9jbGFzc19saXN0PQ==",//model.startCallRes.openTokenID,
// kSessionId:"1_MX40NzI0Nzk1NH5-MTYyMzA2NTQ1ODUxNn5kTTh0YUtRWitXMjZtVFdqaHlYTjNtMTV-fg",// model.startCallRes.openSessionID,
// kApiKey: '47247954',//46209962
// vcId: patient.vcId,
// patientName: patient.fullName ?? (patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-"),
// tokenID: await model.getToken(),
// generalId: GENERAL_ID,
// doctorId: model.doctorProfile.doctorID,
// onFailure: (String error) {
// DrAppToastMsg.showErrorToast(error);
// },onCallConnected: callConnected,
// onCallEnd: () {
// var asd="";
// WidgetsBinding.instance.addPostFrameCallback((_) {
// GifLoaderDialogUtils.showMyDialog(context);
// model.endCall(patient.vcId, false,).then((value) {
// GifLoaderDialogUtils.hideDialog(context);
// if (model.state == ViewState.ErrorLocal) {
// DrAppToastMsg.showErrorToast(model.error);
// }
// setState(() {
// isCallFinished = true;
// });
// });
// });
// Navigator.push(context, MaterialPageRoute(
// builder: (BuildContext context) =>
// EndCallScreen(patient:patient)));
// },
// onCallNotRespond: (SessionStatusModel sessionStatusModel) {
// var asd="";
// // WidgetsBinding.instance.addPostFrameCallback((_) {
// // GifLoaderDialogUtils.showMyDialog(context);
// // model.endCall(patient.vcId, sessionStatusModel.sessionStatus == 3,).then((value) {
// // GifLoaderDialogUtils.hideDialog(context);
// // if (model.state == ViewState.ErrorLocal) {
// // DrAppToastMsg.showErrorToast(model.error);
// // }
// // setState(() {
// // isCallFinished = true;
// // });
// // });
// //
// // });
// });
}
}

@ -33,6 +33,7 @@ class PatientProfileAppBar extends StatelessWidget
final String clinic;
final bool isAppointmentHeader;
final bool isFromLabResult;
final VoidCallback onPressed;
PatientProfileAppBar(
this.patient,
@ -52,7 +53,7 @@ class PatientProfileAppBar extends StatelessWidget
this.episode,
this.visitDate,
this.isAppointmentHeader = false,
this.isFromLabResult = false});
this.isFromLabResult = false, this.onPressed});
@override
@ -93,7 +94,11 @@ class PatientProfileAppBar extends StatelessWidget
IconButton(
icon: Icon(Icons.arrow_back_ios),
color: Color(0xFF2B353E), //Colors.black,
onPressed: () => Navigator.pop(context),
onPressed: () {
if(onPressed!=null)
onPressed();
Navigator.pop(context);
},
),
Expanded(
child: AppText(

@ -19,8 +19,11 @@ class AppScaffold extends StatelessWidget {
final Widget bottomSheet;
final Color backgroundColor;
final Widget appBar;
final Widget drawer;
final Widget bottomNavigationBar;
final String subtitle;
final bool isHomeIcon;
final bool extendBody;
AppScaffold(
{this.appBarTitle = '',
this.body,
@ -30,7 +33,7 @@ class AppScaffold extends StatelessWidget {
this.bottomSheet,
this.backgroundColor,
this.isHomeIcon = true,
this.appBar, this.subtitle});
this.appBar, this.subtitle, this.drawer, this.extendBody = false, this.bottomNavigationBar});
@override
Widget build(BuildContext context) {
@ -42,6 +45,9 @@ class AppScaffold extends StatelessWidget {
},
child: Scaffold(
backgroundColor: backgroundColor ?? Colors.white,
drawer: drawer,
extendBody: extendBody,
bottomNavigationBar: bottomNavigationBar,
appBar: isShowAppBar
? appBar ??
AppBar(

Loading…
Cancel
Save