add patient to doctor list in live care

merge-requests/771/head
hussam al-habibeh 5 years ago
parent d19a881801
commit ef8db07875

@ -232,6 +232,8 @@ const INSERT_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_InsertMedicalRepo
const UPDATE_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_UpdateMedicalReport"; const UPDATE_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_UpdateMedicalReport";
const GET_SICK_LEAVE_DOCTOR_APP = "Services/DoctorApplication.svc/REST/GetAllSickLeaves"; const GET_SICK_LEAVE_DOCTOR_APP = "Services/DoctorApplication.svc/REST/GetAllSickLeaves";
const ADD_PATIENT_TO_DOCTOR = "LiveCareApi/DoctorApp/AssignPatientToDoctor";
const REMOVE_PATIENT_FROM_DOCTOR = "LiveCareApi/DoctorApp/BackPatientToQueue";
var selectedPatientType = 1; var selectedPatientType = 1;

@ -0,0 +1,27 @@
class AddPatientToDoctorListRequestModel {
int vCID;
String tokenID;
String generalid;
int doctorId;
bool isOutKsa;
AddPatientToDoctorListRequestModel({this.vCID, this.tokenID, this.generalid, this.doctorId, this.isOutKsa});
AddPatientToDoctorListRequestModel.fromJson(Map<String, dynamic> json) {
vCID = json['VC_ID'];
tokenID = json['TokenID'];
generalid = json['generalid'];
doctorId = json['DoctorId'];
isOutKsa = json['IsOutKsa'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['VC_ID'] = this.vCID;
data['TokenID'] = this.tokenID;
data['generalid'] = this.generalid;
data['DoctorId'] = this.doctorId;
data['IsOutKsa'] = this.isOutKsa;
return data;
}
}

@ -1,7 +1,7 @@
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart'; import 'package:doctor_app_flutter/core/model/live_care/AlternativeServicesList.dart';
import 'package:doctor_app_flutter/core/model/live_care/PendingPatientERForDoctorAppRequestModel.dart'; import 'package:doctor_app_flutter/core/model/live_care/PendingPatientERForDoctorAppRequestModel.dart';
import 'package:doctor_app_flutter/core/model/live_care/add_patient_to_doctor_list_request_model.dart';
import 'package:doctor_app_flutter/core/model/live_care/live_care_login_reguest_model.dart'; import 'package:doctor_app_flutter/core/model/live_care/live_care_login_reguest_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/livecare/end_call_req.dart'; import 'package:doctor_app_flutter/models/livecare/end_call_req.dart';
@ -35,14 +35,12 @@ class LiveCarePatientServices extends BaseService {
StartCallRes get startCallRes => _startCallRes; StartCallRes get startCallRes => _startCallRes;
Future getPendingPatientERForDoctorApp( Future getPendingPatientERForDoctorApp(
PendingPatientERForDoctorAppRequestModel PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async {
pendingPatientERForDoctorAppRequestModel) async {
hasError = false; hasError = false;
await baseAppClient.post( await baseAppClient.post(
GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP, GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
List<PatiantInformtion> localPatientList = [];
List<PatiantInformtion> localPatientList= [];
response['List_PendingPatientList'].forEach((v) { response['List_PendingPatientList'].forEach((v) {
localPatientList.add(PatiantInformtion.fromJson(v)); localPatientList.add(PatiantInformtion.fromJson(v));
@ -50,22 +48,19 @@ class LiveCarePatientServices extends BaseService {
/// add new items. /// add new items.
localPatientList.forEach((element) { localPatientList.forEach((element) {
if ((_patientList.singleWhere((it) => it.patientId == element.patientId, if ((_patientList.singleWhere((it) => it.patientId == element.patientId, orElse: () => null)) == null) {
orElse: () => null)) == null) {
_patientList.add(element); _patientList.add(element);
} }
}); });
/// remove items. /// remove items.
List<PatiantInformtion> removedPatientList= []; List<PatiantInformtion> removedPatientList = [];
_patientList.forEach((element) { _patientList.forEach((element) {
if ((localPatientList.singleWhere((it) => it.patientId == element.patientId, if ((localPatientList.singleWhere((it) => it.patientId == element.patientId, orElse: () => null)) == null) {
orElse: () => null)) == null) {
removedPatientList.add(element); removedPatientList.add(element);
} }
}); });
removedPatientList.forEach((element) { removedPatientList.forEach((element) {
_patientList.remove(element); _patientList.remove(element);
}); });
@ -105,11 +100,7 @@ class LiveCarePatientServices extends BaseService {
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: { }, body: {"VC_ID": vcID, "AltServiceList": altServiceList, "generalid": GENERAL_ID}, isLiveCare: _isLive);
"VC_ID": vcID,
"AltServiceList": altServiceList,
"generalid":GENERAL_ID
}, isLiveCare: _isLive);
} }
Future transferToAdmin(int vcID, String notes) async { Future transferToAdmin(int vcID, String notes) async {
@ -128,20 +119,17 @@ class LiveCarePatientServices extends BaseService {
Future sendSMSInstruction(int vcID) async { Future sendSMSInstruction(int vcID) async {
hasError = false; hasError = false;
await baseAppClient.post(SEND_SMS_INSTRUCTIONS, await baseAppClient.post(SEND_SMS_INSTRUCTIONS, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) {
transferToAdminResponse = response; transferToAdminResponse = response;
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: { }, body: {"VC_ID": vcID, "generalid": GENERAL_ID}, isLiveCare: _isLive);
"VC_ID": vcID, "generalid": GENERAL_ID
}, isLiveCare: _isLive);
} }
Future isLogin({LiveCareUserLoginRequestModel isLoginRequestModel, int loginStatus}) async { Future isLogin({LiveCareUserLoginRequestModel isLoginRequestModel, int loginStatus}) async {
hasError = false; hasError = false;
await getDoctorProfile( ); await getDoctorProfile();
isLoginRequestModel.doctorId = super.doctorProfile.doctorID; isLoginRequestModel.doctorId = super.doctorProfile.doctorID;
await baseAppClient.post(LIVE_CARE_IS_LOGIN, onSuccess: (response, statusCode) async { await baseAppClient.post(LIVE_CARE_IS_LOGIN, onSuccess: (response, statusCode) async {
isLoginResponse = response; isLoginResponse = response;
@ -155,17 +143,48 @@ class LiveCarePatientServices extends BaseService {
hasError = false; hasError = false;
alternativeServicesList.clear(); alternativeServicesList.clear();
await baseAppClient.post(GET_ALTERNATIVE_SERVICE, await baseAppClient.post(GET_ALTERNATIVE_SERVICE, onSuccess: (dynamic response, int statusCode) {
onSuccess: (dynamic response, int statusCode) {
response['AlternativeServicesList'].forEach((v) { response['AlternativeServicesList'].forEach((v) {
alternativeServicesList.add(AlternativeService.fromJson(v)); alternativeServicesList.add(AlternativeService.fromJson(v));
}); });
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: { }, body: {"VC_ID": vcID, "generalid": GENERAL_ID}, isLiveCare: _isLive);
"VC_ID": vcID, }
"generalid": GENERAL_ID
}, isLiveCare: _isLive); Future addPatientToDoctorList({int vcID}) async {
hasError = false;
await getDoctorProfile();
AddPatientToDoctorListRequestModel addPatientToDoctorListRequestModel = AddPatientToDoctorListRequestModel();
addPatientToDoctorListRequestModel.doctorId = super.doctorProfile.doctorID;
addPatientToDoctorListRequestModel.vCID = vcID;
addPatientToDoctorListRequestModel.isOutKsa = false;
addPatientToDoctorListRequestModel.generalid = GENERAL_ID;
await baseAppClient.post(ADD_PATIENT_TO_DOCTOR, onSuccess: (response, statusCode) async {
isLoginResponse = response;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: addPatientToDoctorListRequestModel.toJson(), isLiveCare: _isLive);
}
Future removePatientFromDoctorList({int vcID}) async {
hasError = false;
AddPatientToDoctorListRequestModel addPatientToDoctorListRequestModel = AddPatientToDoctorListRequestModel();
await getDoctorProfile();
addPatientToDoctorListRequestModel.doctorId = super.doctorProfile.doctorID;
addPatientToDoctorListRequestModel.vCID = vcID;
addPatientToDoctorListRequestModel.isOutKsa = false;
addPatientToDoctorListRequestModel.generalid = GENERAL_ID;
await baseAppClient.post(REMOVE_PATIENT_FROM_DOCTOR, onSuccess: (response, statusCode) async {
isLoginResponse = response;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: addPatientToDoctorListRequestModel.toJson(), isLiveCare: _isLive);
} }
} }

@ -20,8 +20,7 @@ class LiveCarePatientViewModel extends BaseViewModel {
StartCallRes get startCallRes => _liveCarePatientServices.startCallRes; StartCallRes get startCallRes => _liveCarePatientServices.startCallRes;
List<AlternativeService> get alternativeServicesList => List<AlternativeService> get alternativeServicesList => _liveCarePatientServices.alternativeServicesList;
_liveCarePatientServices.alternativeServicesList;
DashboardService _dashboardService = locator<DashboardService>(); DashboardService _dashboardService = locator<DashboardService>();
@ -106,8 +105,7 @@ class LiveCarePatientViewModel extends BaseViewModel {
selectedServices = getSelectedAlternativeServices(); selectedServices = getSelectedAlternativeServices();
} }
await _liveCarePatientServices.endCallWithCharge( await _liveCarePatientServices.endCallWithCharge(vcID, selectedServices);
vcID, selectedServices);
if (_liveCarePatientServices.hasError) { if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error; error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
@ -209,8 +207,7 @@ class LiveCarePatientViewModel extends BaseViewModel {
AlternativeService(serviceID: 2, serviceName: "LABORATORY"), AlternativeService(serviceID: 2, serviceName: "LABORATORY"),
); );
alternativeServicesList.add( alternativeServicesList.add(
AlternativeService( AlternativeService(serviceID: 3, serviceName: "RADIOLOGY(ULTRASOUND) For pregnant only"),
serviceID: 3, serviceName: "RADIOLOGY(ULTRASOUND) For pregnant only"),
); );
alternativeServicesList.add( alternativeServicesList.add(
AlternativeService(serviceID: 4, serviceName: "VACCINATIONS"), AlternativeService(serviceID: 4, serviceName: "VACCINATIONS"),
@ -231,25 +228,46 @@ class LiveCarePatientViewModel extends BaseViewModel {
AlternativeService(serviceID: 9, serviceName: "FAMILY MEDICIN DR"), AlternativeService(serviceID: 9, serviceName: "FAMILY MEDICIN DR"),
); );
alternativeServicesList.add( alternativeServicesList.add(
AlternativeService( AlternativeService(serviceID: 10, serviceName: "FOLYS CATHETER INSERTION"),
serviceID: 10, serviceName: "FOLYS CATHETER INSERTION"),
); );
alternativeServicesList.add( alternativeServicesList.add(
AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"), AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"),
); );
} }
updateInCallPatient({PatiantInformtion patient, appointmentNo}){ updateInCallPatient({PatiantInformtion patient, appointmentNo}) {
_liveCarePatientServices.patientList.forEach((e) {
_liveCarePatientServices.patientList.forEach((e) { if (e.patientId == patient.patientId) {
if(e.patientId == patient.patientId) { e.episodeNo = 0;
e.episodeNo = 0 ;
e.appointmentNo = appointmentNo; e.appointmentNo = appointmentNo;
return; return;
} }
}); });
setState(ViewState.Idle); setState(ViewState.Idle);
}
Future addPatientToDoctorList(int vcID) async {
await getDoctorProfile(isGetProfile: true);
setState(ViewState.BusyLocal);
await _liveCarePatientServices.addPatientToDoctorList(vcID: vcID);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}
Future removePatientFromDoctorList(int vcID) async {
await getDoctorProfile(isGetProfile: true);
setState(ViewState.BusyLocal);
await _liveCarePatientServices.removePatientFromDoctorList(vcID: vcID);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
} }
} }

@ -194,10 +194,7 @@ class _LiveCarePatientScreenState extends State<LiveCarePatientScreen> {
); );
} }
callConnected(){ callConnected() {}
} callDisconnected() {}
callDisconnected(){
}
} }

@ -32,6 +32,7 @@ class PatientProfileScreen extends StatefulWidget {
class _PatientProfileScreenState extends State<PatientProfileScreen> with SingleTickerProviderStateMixin { class _PatientProfileScreenState extends State<PatientProfileScreen> with SingleTickerProviderStateMixin {
PatiantInformtion patient; PatiantInformtion patient;
LiveCarePatientViewModel _liveCareViewModel = LiveCarePatientViewModel();
bool isFromSearch = false; bool isFromSearch = false;
bool isFromLiveCare = false; bool isFromLiveCare = false;
@ -63,6 +64,9 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
void dispose() { void dispose() {
_tabController.dispose(); _tabController.dispose();
super.dispose(); super.dispose();
if (isFromLiveCare) {
_liveCareViewModel.removePatientFromDoctorList(patient.vcId);
}
} }
@override @override
@ -123,6 +127,9 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
return BaseView<LiveCarePatientViewModel>( return BaseView<LiveCarePatientViewModel>(
onModelReady: (model) async {
if (isFromLiveCare && patient.patientStatus == 1) await model.addPatientToDoctorList(patient.vcId);
},
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).patientProfile, appBarTitle: TranslationBase.of(context).patientProfile,
@ -316,43 +323,35 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => builder: (BuildContext context) => EndCallScreen(patient: patient)));
EndCallScreen(patient: patient)));
} else { } else {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
await model.startCall( await model.startCall(isReCall: false, vCID: patient.vcId);
isReCall: false, vCID: patient.vcId);
if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(model.error); Helpers.showErrorToast(model.error);
} else { } else {
await model.getDoctorProfile(); await model.getDoctorProfile();
patient.appointmentNo = int.parse(model patient.appointmentNo = int.parse(model.startCallRes.appointmentNo.toString());
.startCallRes.appointmentNo
.toString());
patient.episodeNo = 0; patient.episodeNo = 0;
model.updateInCallPatient( model.updateInCallPatient(
patient: patient, patient: patient,
appointmentNo: int.parse(model appointmentNo: int.parse(model.startCallRes.appointmentNo.toString()));
.startCallRes.appointmentNo
.toString()));
setState(() { setState(() {
isCallStarted = true; isCallStarted = true;
}); });
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
AppPermissionsUtils AppPermissionsUtils.requestVideoCallPermission(
.requestVideoCallPermission( context: context,
context: context, onTapGrant: () {
onTapGrant: () { locator<VideoCallService>().openVideo(
locator<VideoCallService>() model.startCallRes,
.openVideo( patient,
model.startCallRes, model.startCallRes != null ? model.startCallRes.isRecording : true,
patient, callConnected,
model.startCallRes != null ? model.startCallRes.isRecording : true callDisconnected);
, callConnected, });
callDisconnected);
});
} }
} }
}, },

Loading…
Cancel
Save