diff --git a/lib/client/app_client.dart b/lib/client/app_client.dart index 68c4fb8b..89b62722 100644 --- a/lib/client/app_client.dart +++ b/lib/client/app_client.dart @@ -4,15 +4,14 @@ import 'package:http/http.dart'; // OWNER : Ibrahim albitar // DATE : 22-04-2020 -// DESCRIPTION : Custom App client to pin base url for all srvices +// DESCRIPTION : Custom App client to pin base url for all srvices class AppClient { - static Client client = HttpInterceptor().getClient(); - static Future post(dynamic path, {dynamic body}) async { + static Future post(dynamic path, {dynamic body}) async { String _fullUrl = BASE_URL + path; final response = await client.post(_fullUrl, body: body); return response; } -} \ No newline at end of file +} diff --git a/lib/config/config.dart b/lib/config/config.dart index af7633f3..e642e79d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -3,30 +3,35 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; //const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; -const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; -const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; +const BASE_URL = 'https://uat.hmgwebservices.com/'; +const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region"; +const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = - "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; + "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; const PATIENT_INSURANCE_APPROVALS_URL = - "DoctorApplication.svc/REST/GetApprovalStatusForInpatient"; + "Services/DoctorApplication.svc/REST/GetApprovalStatusForInpatient"; const PATIENT_ORDERS_URL = - "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; -const PATIENT_REFER_TO_DOCTOR_URL = "DoctorApplication.svc/REST/ReferToDoctor"; + "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; +const PATIENT_REFER_TO_DOCTOR_URL = + "Services/DoctorApplication.svc/REST/ReferToDoctor"; const PATIENT_GET_DOCTOR_BY_CLINIC_URL = - "DoctorApplication.svc/REST/GetDoctorsByClinicID"; + "Services/DoctorApplication.svc/REST/GetDoctorsByClinicID"; const PATIENT_GET_LIST_REFERAL_URL = - "Lists.svc/REST/GetList_STPReferralFrequency"; + "Services/Lists.svc/REST/GetList_STPReferralFrequency"; const PATIENT_GET_CLINIC_BY_PROJECT_URL = - "DoctorApplication.svc/REST/GetClinicsByProjectID"; + "Services/DoctorApplication.svc/REST/GetClinicsByProjectID"; -const GET_PROJECTS = 'Lists.svc/REST/GetProjectForDoctorAPP'; -const GET_PATIENT_VITAL_SIGN = 'Doctors.svc/REST/Doctor_GetPatientVitalSign'; +const GET_PROJECTS = 'Services/Lists.svc/REST/GetProjectForDoctorAPP'; +const GET_PATIENT_VITAL_SIGN = + 'Services/Doctors.svc/REST/Doctor_GetPatientVitalSign'; const GET_PATIENT_LAB_OREDERS = - 'DoctorApplication.svc/REST/GetPatientLabOreders'; -const GET_PRESCRIPTION = 'Patients.svc/REST/GetPrescriptionApptList'; -const GET_RADIOLOGY = 'DoctorApplication.svc/REST/GetPatientRadResult'; + 'Services/DoctorApplication.svc/REST/GetPatientLabOreders'; +const GET_PRESCRIPTION = 'Services/Patients.svc/REST/GetPrescriptionApptList'; +const GET_RADIOLOGY = 'Services/DoctorApplication.svc/REST/GetPatientRadResult'; +const GET_LIVECARE_PENDINGLIST = + 'Services/DoctorApplication.svc/REST/GetPendingPatientER'; +const START_LIVECARE_CALL = 'LiveCareApi/DoctorApp/CallPatient'; var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 133dbfef..2e046718 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -211,4 +211,5 @@ const Map> localizedValues = { 'en': 'You don\'t have any Orders', 'ar': 'لا يوجد لديك اي طلبات' }, + 'livecare': {'en': 'Live Care', 'ar': 'Live Care'} }; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index fc74bb99..bfd350f1 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -1,8 +1,9 @@ final TOKEN = 'token'; -final PROJECT_ID='projectID'; +final PROJECT_ID = 'projectID'; //===========amjad============ -final DOCTOR_ID='doctorID'; +final DOCTOR_ID = 'doctorID'; //======================= -final SLECTED_PATIENT_TYPE='slectedPatientType'; +final SLECTED_PATIENT_TYPE = 'slectedPatientType'; final APP_Language = 'language'; -final DOCTOR_PROFILE = 'doctorProfile'; \ No newline at end of file +final DOCTOR_PROFILE = 'doctorProfile'; +final LIVE_CARE_PATIENT = 'livecare-patient-profile'; diff --git a/lib/main.dart b/lib/main.dart index d5f65406..557eef69 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/providers/livecare_provider.dart'; import 'package:doctor_app_flutter/providers/project_provider.dart'; import 'package:doctor_app_flutter/providers/schedule_provider.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -26,39 +27,47 @@ class MyApp extends StatelessWidget { SizeConfig().init(constraints, orientation); return MultiProvider( providers: [ - ChangeNotifierProvider(create: (context) => PatientsProvider()), - ChangeNotifierProvider(create: (context) => AuthProvider()), - ChangeNotifierProvider(create: (context) => HospitalProvider()), - ChangeNotifierProvider(create: (context) => ProjectProvider(),), - ChangeNotifierProvider(create: (context) => ScheduleProvider(),) + ChangeNotifierProvider( + create: (context) => PatientsProvider()), + ChangeNotifierProvider( + create: (context) => AuthProvider()), + ChangeNotifierProvider( + create: (context) => HospitalProvider()), + ChangeNotifierProvider( + create: (context) => ProjectProvider(), + ), + ChangeNotifierProvider( + create: (context) => ScheduleProvider(), + ), + ChangeNotifierProvider( + create: (context) => LiveCareProvider(), + ) ], child: Consumer( - builder: (context,projectProvider,child) => MaterialApp( - showSemanticsDebugger: false, - title: 'Flutter Demo', - locale: projectProvider.appLocal, - localizationsDelegates: [ - TranslationBaseDelegate(), - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - ], - supportedLocales: [ - const Locale('ar', ''), // Arabic - const Locale('en', ''), // English - ], - theme: ThemeData( - primarySwatch: Colors.grey, - primaryColor: Colors.grey, - buttonColor: Hexcolor('#B8382C'), - fontFamily: 'WorkSans', - dividerColor: Colors.grey[350], - backgroundColor: Color.fromRGBO(255,255,255, 1) - ), - initialRoute: INIT_ROUTE, - routes: routes, - debugShowCheckedModeBanner: false, - ) - ), + builder: (context, projectProvider, child) => MaterialApp( + showSemanticsDebugger: false, + title: 'Flutter Demo', + locale: projectProvider.appLocal, + localizationsDelegates: [ + TranslationBaseDelegate(), + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + supportedLocales: [ + const Locale('ar', ''), // Arabic + const Locale('en', ''), // English + ], + theme: ThemeData( + primarySwatch: Colors.grey, + primaryColor: Colors.grey, + buttonColor: Hexcolor('#B8382C'), + fontFamily: 'WorkSans', + dividerColor: Colors.grey[350], + backgroundColor: Color.fromRGBO(255, 255, 255, 1)), + initialRoute: INIT_ROUTE, + routes: routes, + debugShowCheckedModeBanner: false, + )), ); }); }, diff --git a/lib/models/livecare/get_panding_req_list.dart b/lib/models/livecare/get_panding_req_list.dart new file mode 100644 index 00000000..719b9134 --- /dev/null +++ b/lib/models/livecare/get_panding_req_list.dart @@ -0,0 +1,49 @@ +class LiveCarePendingListRequest { + PatientData patientData; + int doctorID; + String sErServiceID; + int projectID; + int sourceID; + + LiveCarePendingListRequest( + {this.patientData, + this.doctorID, + this.sErServiceID, + this.projectID, + this.sourceID}); + + LiveCarePendingListRequest.fromJson(Map json) { + patientData = new PatientData.fromJson(json['PatientData']); + + doctorID = json['DoctorID']; + sErServiceID = json['SErServiceID']; + projectID = json['ProjectID']; + sourceID = json['SourceID']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientData'] = this.patientData.toJson(); + data['DoctorID'] = this.doctorID; + data['SErServiceID'] = this.sErServiceID; + data['ProjectID'] = this.projectID; + data['SourceID'] = this.sourceID; + return data; + } +} + +class PatientData { + bool isOutKSA; + + PatientData({this.isOutKSA}); + + PatientData.fromJson(Map json) { + isOutKSA = json['IsOutKSA']; + } + + Map toJson() { + final Map data = new Map(); + data['IsOutKSA'] = this.isOutKSA; + return data; + } +} diff --git a/lib/models/livecare/get_pending_res_list.dart b/lib/models/livecare/get_pending_res_list.dart new file mode 100644 index 00000000..22839f91 --- /dev/null +++ b/lib/models/livecare/get_pending_res_list.dart @@ -0,0 +1,168 @@ +class LiveCarePendingListResponse { + Null acceptedBy; + Null acceptedOn; + int age; + Null appointmentNo; + String arrivalTime; + String arrivalTimeD; + int callStatus; + String clientRequestID; + String clinicName; + Null consoltationEnd; + Null consultationNotes; + Null createdOn; + String dateOfBirth; + String deviceToken; + String deviceType; + Null doctorName; + String editOn; + String gender; + bool isFollowUP; + Null isFromVida; + int isLoginB; + bool isOutKSA; + int isRejected; + String language; + double latitude; + double longitude; + String mobileNumber; + Null openSession; + Null openTokenID; + String patientID; + String patientName; + int patientStatus; + String preferredLanguage; + int projectID; + int scoring; + int serviceID; + Null tokenID; + int vCID; + String voipToken; + + LiveCarePendingListResponse( + {this.acceptedBy, + this.acceptedOn, + this.age, + this.appointmentNo, + this.arrivalTime, + this.arrivalTimeD, + this.callStatus, + this.clientRequestID, + this.clinicName, + this.consoltationEnd, + this.consultationNotes, + this.createdOn, + this.dateOfBirth, + this.deviceToken, + this.deviceType, + this.doctorName, + this.editOn, + this.gender, + this.isFollowUP, + this.isFromVida, + this.isLoginB, + this.isOutKSA, + this.isRejected, + this.language, + this.latitude, + this.longitude, + this.mobileNumber, + this.openSession, + this.openTokenID, + this.patientID, + this.patientName, + this.patientStatus, + this.preferredLanguage, + this.projectID, + this.scoring, + this.serviceID, + this.tokenID, + this.vCID, + this.voipToken}); + + LiveCarePendingListResponse.fromJson(Map json) { + acceptedBy = json['AcceptedBy']; + acceptedOn = json['AcceptedOn']; + age = json['Age']; + appointmentNo = json['AppointmentNo']; + arrivalTime = json['ArrivalTime']; + arrivalTimeD = json['ArrivalTimeD']; + callStatus = json['CallStatus']; + clientRequestID = json['ClientRequestID']; + clinicName = json['ClinicName']; + consoltationEnd = json['ConsoltationEnd']; + consultationNotes = json['ConsultationNotes']; + createdOn = json['CreatedOn']; + dateOfBirth = json['DateOfBirth']; + deviceToken = json['DeviceToken']; + deviceType = json['DeviceType']; + doctorName = json['DoctorName']; + editOn = json['EditOn']; + gender = json['Gender']; + isFollowUP = json['IsFollowUP']; + isFromVida = json['IsFromVida']; + isLoginB = json['IsLoginB']; + isOutKSA = json['IsOutKSA']; + isRejected = json['IsRejected']; + language = json['Language']; + latitude = json['Latitude']; + longitude = json['Longitude']; + mobileNumber = json['MobileNumber']; + openSession = json['OpenSession']; + openTokenID = json['OpenTokenID']; + patientID = json['PatientID']; + patientName = json['PatientName']; + patientStatus = json['PatientStatus']; + preferredLanguage = json['PreferredLanguage']; + projectID = json['ProjectID']; + scoring = json['Scoring']; + serviceID = json['ServiceID']; + tokenID = json['TokenID']; + vCID = json['VC_ID']; + voipToken = json['VoipToken']; + } + + Map toJson() { + final Map data = new Map(); + data['AcceptedBy'] = this.acceptedBy; + data['AcceptedOn'] = this.acceptedOn; + data['Age'] = this.age; + data['AppointmentNo'] = this.appointmentNo; + data['ArrivalTime'] = this.arrivalTime; + data['ArrivalTimeD'] = this.arrivalTimeD; + data['CallStatus'] = this.callStatus; + data['ClientRequestID'] = this.clientRequestID; + data['ClinicName'] = this.clinicName; + data['ConsoltationEnd'] = this.consoltationEnd; + data['ConsultationNotes'] = this.consultationNotes; + data['CreatedOn'] = this.createdOn; + data['DateOfBirth'] = this.dateOfBirth; + data['DeviceToken'] = this.deviceToken; + data['DeviceType'] = this.deviceType; + data['DoctorName'] = this.doctorName; + data['EditOn'] = this.editOn; + data['Gender'] = this.gender; + data['IsFollowUP'] = this.isFollowUP; + data['IsFromVida'] = this.isFromVida; + data['IsLoginB'] = this.isLoginB; + data['IsOutKSA'] = this.isOutKSA; + data['IsRejected'] = this.isRejected; + data['Language'] = this.language; + data['Latitude'] = this.latitude; + data['Longitude'] = this.longitude; + data['MobileNumber'] = this.mobileNumber; + data['OpenSession'] = this.openSession; + data['OpenTokenID'] = this.openTokenID; + data['PatientID'] = this.patientID; + data['PatientName'] = this.patientName; + data['PatientStatus'] = this.patientStatus; + data['PreferredLanguage'] = this.preferredLanguage; + data['ProjectID'] = this.projectID; + data['Scoring'] = this.scoring; + data['ServiceID'] = this.serviceID; + data['TokenID'] = this.tokenID; + data['VC_ID'] = this.vCID; + data['VoipToken'] = this.voipToken; + return data; + } +} diff --git a/lib/models/livecare/start_call_req.dart b/lib/models/livecare/start_call_req.dart new file mode 100644 index 00000000..1ad04480 --- /dev/null +++ b/lib/models/livecare/start_call_req.dart @@ -0,0 +1,56 @@ +class StartCallReq { + int vCID; + bool isrecall; + String tokenID; + String generalid; + int doctorId; + bool isOutKsa; + String projectName; + String docotrName; + String clincName; + String docSpec; + int clinicId; + + StartCallReq( + {this.vCID, + this.isrecall, + this.tokenID, + this.generalid, + this.doctorId, + this.isOutKsa, + this.projectName, + this.docotrName, + this.clincName, + this.docSpec, + this.clinicId}); + + StartCallReq.fromJson(Map json) { + vCID = json['VC_ID']; + isrecall = json['isrecall']; + tokenID = json['TokenID']; + generalid = json['generalid']; + doctorId = json['DoctorId']; + isOutKsa = json['IsOutKsa']; + projectName = json['projectName']; + docotrName = json['DocotrName']; + clincName = json['clincName']; + docSpec = json['Doc_Spec']; + clinicId = json['ClinicId']; + } + + Map toJson() { + final Map data = new Map(); + data['VC_ID'] = this.vCID; + data['isrecall'] = this.isrecall; + data['TokenID'] = this.tokenID; + data['generalid'] = this.generalid; + data['DoctorId'] = this.doctorId; + data['IsOutKsa'] = this.isOutKsa; + data['projectName'] = this.projectName; + data['DocotrName'] = this.docotrName; + data['clincName'] = this.clincName; + data['Doc_Spec'] = this.docSpec; + data['ClinicId'] = this.clinicId; + return data; + } +} diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index 22bd80f6..5a3c9272 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -6,17 +6,18 @@ import 'package:flutter/cupertino.dart'; import '../models/doctor/user_model.dart'; -const LOGIN_URL = 'Sentry.svc/REST/MemberLogIN_New'; -const INSERT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; +const LOGIN_URL = 'Services/Sentry.svc/REST/MemberLogIN_New'; +const INSERT_DEVICE_IMEI = + 'Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; const SELECT_DEVICE_IMEI = - 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; + 'Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = - 'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; + 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; const MEMBER_CHECK_ACTIVATION_CODE_NEW = - 'Sentry.svc/REST/MemberCheckActivationCode_New'; -const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; + 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; +const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } @@ -137,7 +138,7 @@ class AuthProvider with ChangeNotifier { localRes = response; selectedClinicName = ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName; - notifyListeners(); + notifyListeners(); response['List_DoctorsClinic'].forEach((v) { doctorsClinicList.add(new ClinicModel.fromJson(v)); }); @@ -165,8 +166,9 @@ class AuthProvider with ChangeNotifier { onSuccess: (dynamic response, int statusCode) { localRes = response; //ClinicDescription - selectedClinicName = response['DoctorProfileList'][0]['ClinicDescription']; - notifyListeners(); + selectedClinicName = + response['DoctorProfileList'][0]['ClinicDescription']; + notifyListeners(); }, onFailure: (String error, int statusCode) { throw error; }, body: docInfo); diff --git a/lib/providers/livecare_provider.dart b/lib/providers/livecare_provider.dart new file mode 100644 index 00000000..31c012f8 --- /dev/null +++ b/lib/providers/livecare_provider.dart @@ -0,0 +1,78 @@ +import 'dart:convert'; + +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/livecare/get_panding_req_list.dart'; +import 'package:doctor_app_flutter/models/livecare/start_call_req.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; + +class LiveCareProvider with ChangeNotifier { + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + + var liveCarePendingList = []; + var inCallResponse = {}; + bool isFinished = true; + bool hasError = false; + String errorMsg = ''; + + LiveCarePendingListRequest _pendingRequestModel = + LiveCarePendingListRequest(); + + Future getpendingList() async { + var profile = await sharedPref.getObj(DOCTOR_PROFILE); + _pendingRequestModel.projectID = await sharedPref.getInt(PROJECT_ID); + _pendingRequestModel.doctorID = profile['DoctorID']; + _pendingRequestModel.sErServiceID = "1,3"; + _pendingRequestModel.sourceID = 1; + _pendingRequestModel.patientData = PatientData(isOutKSA: false); + resetDefaultValues(); + // dynamic localRes; + await BaseAppClient.post(GET_LIVECARE_PENDINGLIST, + onSuccess: (response, statusCode) async { + isFinished = true; + liveCarePendingList = response["List_PendingPatientList"]; + }, onFailure: (String error, int statusCode) { + isFinished = true; + throw error; + }, body: _pendingRequestModel.toJson()); + return Future.value(liveCarePendingList); + } + + Future startCall(request, bool isReCall) async { + var profile = await sharedPref.getObj(DOCTOR_PROFILE); + resetDefaultValues(); + /* the request model is not same hence added manually */ + var newRequest = new StartCallReq(); + newRequest.clinicId = profile["ClinicID"]; + newRequest.vCID = request["VC_ID"]; + newRequest.isrecall = isReCall; + newRequest.doctorId = profile["DoctorID"]; + newRequest.isOutKsa = request["IsOutKSA"]; + newRequest.projectName = profile["ProjectName"]; + newRequest.docotrName = profile["DoctorName"]; + newRequest.clincName = profile["ClinicDescription"]; + newRequest.clincName = profile["ClinicDescription"]; + newRequest.docSpec = profile["DoctorTitleForProfile"]; + newRequest.generalid = 'Cs2020@2016\$2958'; + isFinished = false; + await BaseAppClient.post(START_LIVECARE_CALL, + onSuccess: (response, statusCode) async { + isFinished = true; + inCallResponse = response; + }, onFailure: (String error, int statusCode) { + isFinished = true; + throw error; + }, body: newRequest.toJson()); + return Future.value(inCallResponse); + } + + resetDefaultValues() { + isFinished = false; + hasError = false; + errorMsg = ''; + notifyListeners(); + } +} diff --git a/lib/providers/project_provider.dart b/lib/providers/project_provider.dart index ae5bd759..6c867228 100644 --- a/lib/providers/project_provider.dart +++ b/lib/providers/project_provider.dart @@ -5,13 +5,12 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; - class ProjectProvider with ChangeNotifier { DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); Locale _appLocale; String currentLanguage = 'ar'; bool _isArabic = false; - bool isInternetConnection=true; + bool isInternetConnection = true; Locale get appLocal => _appLocale; diff --git a/lib/routes.dart b/lib/routes.dart index 89efd710..9280d95e 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -6,7 +6,7 @@ import 'package:doctor_app_flutter/screens/patients/profile/progress_note_screen import 'package:doctor_app_flutter/screens/patients/profile/refer_patient_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart'; -import 'package:doctor_app_flutter/screens/video_call/video_call.dart'; +import 'package:doctor_app_flutter/screens/live_care/video_call.dart'; import './screens/QR_reader_screen.dart'; import './screens/auth/change_password_screen.dart'; @@ -37,6 +37,7 @@ import './screens/profile_screen.dart'; import './screens/settings/settings_screen.dart'; import 'landing_page.dart'; import 'screens/doctor/doctor_reply_screen.dart'; +import 'screens/live_care/panding_list.dart'; const String INIT_ROUTE = ROOT; const String ROOT = 'root'; @@ -72,6 +73,7 @@ const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; const String BODY_MEASUREMENTS = 'patients/body-measurements'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; const String VIDEO_CALL = 'video-call'; +const String LIVECARE_PENDING_LIST = 'livecare-pendinglist'; var routes = { ROOT: (_) => RootPage(), HOME: (_) => LandingPage(), @@ -106,5 +108,6 @@ var routes = { VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen(), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), - VIDEO_CALL: (_) => VideoCallPage() + VIDEO_CALL: (_) => VideoCallPage(), + LIVECARE_PENDING_LIST: (_) => LiveCarePandingListScreen() }; diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index e68baf39..85eb5513 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -66,7 +66,7 @@ class _DashboardScreenState extends State { isLoading: isLoading, body: SingleChildScrollView( child: SizedBox( - height: MediaQuery.of(context).size.height * 1.09, + height: MediaQuery.of(context).size.height * 1.3, child: Column( children: [ Row( @@ -445,7 +445,9 @@ class _DashboardScreenState extends State { flex: 1, child: InkWell( onTap: () { - Navigator.of(context).pushNamed(VIDEO_CALL); + // Navigator.of(context).pushNamed(VIDEO_CALL); + Navigator.of(context) + .pushNamed(LIVECARE_PENDING_LIST); }, child: DashboardItemIconText( DoctorApp.referral, diff --git a/lib/screens/live_care/panding_list.dart b/lib/screens/live_care/panding_list.dart new file mode 100644 index 00000000..202fc774 --- /dev/null +++ b/lib/screens/live_care/panding_list.dart @@ -0,0 +1,294 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/providers/livecare_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/models/livecare/get_pending_res_list.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import '../../config/size_config.dart'; +import '../../config/size_config.dart'; +import '../../widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; +import '../../routes.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; + +DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); + +class LiveCarePandingListScreen extends StatefulWidget { + // In the constructor, require a item id. + LiveCarePandingListScreen({Key key}) : super(key: key); + + @override + _LiveCarePandingListState createState() => _LiveCarePandingListState(); +} + +class _LiveCarePandingListState extends State { + var _data = []; + Helpers helpers = new Helpers(); + LiveCareProvider _liveCareProvider; + @override + void didChangeDependencies() { + super.didChangeDependencies(); + _liveCareProvider = Provider.of(context); + if (_data.isEmpty) pendingList(); + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).livecare, + body: Container( + child: ListView(scrollDirection: Axis.vertical, + + // physics: const AlwaysScrollableScrollPhysics(), + children: [ + RoundedContainer( + child: !_liveCareProvider.isFinished + ? Container( + height: SizeConfig.screenHeight, + width: SizeConfig.screenWidth, + child: DrAppCircularProgressIndeicator()) + : _liveCareProvider.hasError + ? Center( + child: Text( + _liveCareProvider.errorMsg, + style: TextStyle( + color: Theme.of(context).errorColor), + ), + ) + : Column( + children: _data.map((item) { + return Container( + decoration: myBoxDecoration(), + child: InkWell( + child: CardWithBgWidgetNew( + //CardWithBgWidget( + widget: Column( + children: [ + Container( + // decoration: myBoxDecoration(), + child: Row( + children: [ + Column( + children: [ + Container( + decoration: + BoxDecoration( + gradient: + LinearGradient( + begin: + Alignment( + -1, + -1), + end: + Alignment( + 1, + 1), + colors: [ + Colors.grey[ + 100], + Colors.grey[ + 200], + ]), + boxShadow: [ + BoxShadow( + color: Color + .fromRGBO( + 0, + 0, + 0, + 0.08), + offset: + Offset( + 0.0, + 5.0), + blurRadius: + 16.0) + ], + borderRadius: + BorderRadius.all( + Radius.circular( + 50.0)), + ), + width: 80, + height: 80, + child: Icon( + item["Gender"] == + "1" + ? DoctorApp.male + : DoctorApp + .femaleicon, + size: 80, + )), + ], + ), + SizedBox( + width: 20, + ), + Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + AppText( + item["PatientName"], + fontSize: 2.0 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight.bold, + backGroundcolor: + Colors.white, + ), + SizedBox( + height: 8, + ), + AppText( + TranslationBase.of( + context) + .fileNo + + item["PatientID"] + .toString(), + fontSize: 2.0 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight.bold, + backGroundcolor: + Colors.white, + ), + + // SizedBox( + // height: 8, + // ), + AppText( + TranslationBase.of( + context) + .age + + ' ' + + item["Age"] + .toString(), + fontSize: 2.0 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight.bold, + backGroundcolor: + Colors.white, + ), + SizedBox( + height: 8, + ), + ], + ), + SizedBox( + width: 80, + ), + // Divider(color: Colors.grey + Expanded( + flex: 3, + child: IconButton( + icon: Icon( + Icons.video_call, + size: 40, + ), + color: Colors + .green, //Colors.black, + onPressed: () => { + sharedPref.setObj( + LIVE_CARE_PATIENT, + item), + Navigator.of(context) + .pushNamed( + VIDEO_CALL) + }, + ), + ) + ], + ), + ), + // Divider(color: Colors.grey) + ], + ), + ), + onTap: () {}, + ), + ); + }).toList(), + )) + ]), + )); + } + + Future pendingList() async { + _liveCareProvider.getpendingList().then((result) { + this.setState(() { + _data = _liveCareProvider.liveCarePendingList; + // _data = [ + // { + // "AcceptedBy": null, + // "AcceptedOn": null, + // "Age": 33, + // "AppointmentNo": null, + // "ArrivalTime": "2020-06-14 09:34", + // "ArrivalTimeD": "/Date(1592116471237+0300)/", + // "CallStatus": 1, + // "ClientRequestID": "2344670985-1231755-1584378710", + // "ClinicName": "ER Clinic", + // "ConsoltationEnd": null, + // "ConsultationNotes": null, + // "CreatedOn": null, + // "DateOfBirth": "1987-01-04", + // "DeviceToken": + // "fbxt2XpseU_DpO8Msqa1V6:APA91bHUxsfKpAewTt0DzGg_mSTN0T7KIQM92VpubUTobgTm0-DGcJMgcc3DmERbEiWbyTup3zGttU3_9RBaRBxZUKj9ju5wnTGSrIelEE-qxOK30YnIaDhbhs8fJixACbyzgr72HU8Y", + // "DeviceType": "iOS", + // "DoctorName": null, + // "EditOn": "/Date(1592116471237+0300)/", + // "Gender": "1", + // "IsFollowUP": false, + // "IsFromVida": null, + // "IsLoginB": 0, + // "IsOutKSA": false, + // "IsRejected": 0, + // "Language": "AR", + // "Latitude": 24.708879, + // "Longitude": 46.665827, + // "MobileNumber": "0537503378", + // "OpenSession": null, + // "OpenTokenID": null, + // "PatientID": "1231755", + // "PatientName": "TAMER FANASHEH", + // "PatientStatus": 1, + // "PreferredLanguage": "Ar", + // "ProjectID": 0, + // "Scoring": 0.00, + // "ServiceID": 1, + // "TokenID": null, + // "VC_ID": 2240, + // "VoipToken": + // "8dcc17e2365d4f3c4afadc6b5d625a88407398ee517f0e9beda7f663007e88b9" + // } + // ]; + }); + }); + return true; + } + + myBoxDecoration() { + return BoxDecoration( + border: Border( + bottom: BorderSide( + // <--- top side + color: Colors.grey, + width: 1.0, + ), + ), + ); + } +} diff --git a/lib/screens/video_call/video_call.dart b/lib/screens/live_care/video_call.dart similarity index 77% rename from lib/screens/video_call/video_call.dart rename to lib/screens/live_care/video_call.dart index e36f3f36..05b11e96 100644 --- a/lib/screens/video_call/video_call.dart +++ b/lib/screens/live_care/video_call.dart @@ -1,29 +1,43 @@ import 'dart:async'; +import 'package:doctor_app_flutter/providers/livecare_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/material.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:provider/provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; class VideoCallPage extends StatefulWidget { @override _VideoCallPageState createState() => _VideoCallPageState(); } +DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); + class _VideoCallPageState extends State { Timer _timmerInstance; int _start = 0; String _timmer = ''; + LiveCareProvider _liveCareProvider; + bool _isInit = true; + var patientData = {}; + //bool _isOutOfStuck = false; + Helpers helpers = new Helpers(); + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + _liveCareProvider = Provider.of(context); + startCall(); + } + _isInit = false; + } - void startTimmer() { - var oneSec = Duration(seconds: 1); - _timmerInstance = Timer.periodic( - oneSec, - (Timer timer) => setState(() { - if (_start < 0) { - _timmerInstance.cancel(); - } else { - _start = _start + 1; - _timmer = getTimerTime(_start); - } - })); + void connectOpenTok(tokenData) { + /* opentok functionalites need to be written */ + print(tokenData["OpenSessionID"]); + print(tokenData["OpenTokenID"]); } String getTimerTime(int start) { @@ -44,15 +58,22 @@ class _VideoCallPageState extends State { return sMinute + ':' + sSeconds; } - @override - void initState() { - super.initState(); - startTimmer(); + startCall() async { + patientData = await sharedPref.getObj(LIVE_CARE_PATIENT); + _liveCareProvider.startCall(patientData, false).then((result) { + connectOpenTok(result); + }).catchError((error) => + {helpers.showErrorToast(error), Navigator.of(context).pop()}); } + // @override + // void initState() { + // super.initState(); + + // } + @override void dispose() { - _timmerInstance.cancel(); super.dispose(); } @@ -86,7 +107,7 @@ class _VideoCallPageState extends State { height: MediaQuery.of(context).size.height * 0.02, ), Text( - 'A B Shaikh', + patientData["PatientName"], style: TextStyle( color: Colors.deepPurpleAccent, fontWeight: FontWeight.w900, @@ -95,13 +116,14 @@ class _VideoCallPageState extends State { SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), - Text( - _timmer, + Container( + child: Text( + _timmer == '' ? 'Connecting' : 'Connected', style: TextStyle( color: Colors.deepPurpleAccent, fontWeight: FontWeight.w300, fontSize: 15), - ), + )), SizedBox( height: MediaQuery.of(context).size.height * 0.02, ), @@ -142,7 +164,9 @@ class _VideoCallPageState extends State { height: MediaQuery.of(context).size.height * 0.1, ), FloatingActionButton( - onPressed: () {}, + onPressed: () { + Navigator.of(context).pop(); + }, elevation: 20.0, shape: CircleBorder(side: BorderSide(color: Colors.red)), mini: false, diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 33eadefb..bc06dd7a 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -230,6 +230,7 @@ class TranslationBase { localizedValues['prescriptionInfo'][locale.languageCode]; String get errorNoOrders => localizedValues['errorNoOrders'][locale.languageCode]; + String get livecare => localizedValues['livecare'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {