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 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;

@ -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/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/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/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/livecare/end_call_req.dart';
@ -35,14 +35,12 @@ class LiveCarePatientServices extends BaseService {
StartCallRes get startCallRes => _startCallRes;
Future getPendingPatientERForDoctorApp(
PendingPatientERForDoctorAppRequestModel
pendingPatientERForDoctorAppRequestModel) async {
PendingPatientERForDoctorAppRequestModel pendingPatientERForDoctorAppRequestModel) async {
hasError = false;
await baseAppClient.post(
GET_PENDING_PATIENT_ER_FOR_DOCTOR_APP,
onSuccess: (dynamic response, int statusCode) {
List<PatiantInformtion> localPatientList= [];
List<PatiantInformtion> localPatientList = [];
response['List_PendingPatientList'].forEach((v) {
localPatientList.add(PatiantInformtion.fromJson(v));
@ -50,22 +48,19 @@ class LiveCarePatientServices extends BaseService {
/// add new items.
localPatientList.forEach((element) {
if ((_patientList.singleWhere((it) => it.patientId == element.patientId,
orElse: () => null)) == null) {
if ((_patientList.singleWhere((it) => it.patientId == element.patientId, orElse: () => null)) == null) {
_patientList.add(element);
}
});
/// remove items.
List<PatiantInformtion> removedPatientList= [];
List<PatiantInformtion> removedPatientList = [];
_patientList.forEach((element) {
if ((localPatientList.singleWhere((it) => it.patientId == element.patientId,
orElse: () => null)) == null) {
if ((localPatientList.singleWhere((it) => it.patientId == element.patientId, orElse: () => null)) == null) {
removedPatientList.add(element);
}
});
removedPatientList.forEach((element) {
_patientList.remove(element);
});
@ -105,11 +100,7 @@ class LiveCarePatientServices extends BaseService {
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: {
"VC_ID": vcID,
"AltServiceList": altServiceList,
"generalid":GENERAL_ID
}, isLiveCare: _isLive);
}, body: {"VC_ID": vcID, "AltServiceList": altServiceList, "generalid": GENERAL_ID}, isLiveCare: _isLive);
}
Future transferToAdmin(int vcID, String notes) async {
@ -128,20 +119,17 @@ class LiveCarePatientServices extends BaseService {
Future sendSMSInstruction(int vcID) async {
hasError = false;
await baseAppClient.post(SEND_SMS_INSTRUCTIONS,
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.post(SEND_SMS_INSTRUCTIONS, onSuccess: (dynamic response, int statusCode) {
transferToAdminResponse = response;
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: {
"VC_ID": vcID, "generalid": GENERAL_ID
}, isLiveCare: _isLive);
}, body: {"VC_ID": vcID, "generalid": GENERAL_ID}, isLiveCare: _isLive);
}
Future isLogin({LiveCareUserLoginRequestModel isLoginRequestModel, int loginStatus}) async {
hasError = false;
await getDoctorProfile( );
await getDoctorProfile();
isLoginRequestModel.doctorId = super.doctorProfile.doctorID;
await baseAppClient.post(LIVE_CARE_IS_LOGIN, onSuccess: (response, statusCode) async {
isLoginResponse = response;
@ -155,17 +143,48 @@ class LiveCarePatientServices extends BaseService {
hasError = false;
alternativeServicesList.clear();
await baseAppClient.post(GET_ALTERNATIVE_SERVICE,
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.post(GET_ALTERNATIVE_SERVICE, onSuccess: (dynamic response, int statusCode) {
response['AlternativeServicesList'].forEach((v) {
alternativeServicesList.add(AlternativeService.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: {
"VC_ID": vcID,
"generalid": GENERAL_ID
}, isLiveCare: _isLive);
}, body: {"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;
List<AlternativeService> get alternativeServicesList =>
_liveCarePatientServices.alternativeServicesList;
List<AlternativeService> get alternativeServicesList => _liveCarePatientServices.alternativeServicesList;
DashboardService _dashboardService = locator<DashboardService>();
@ -106,8 +105,7 @@ class LiveCarePatientViewModel extends BaseViewModel {
selectedServices = getSelectedAlternativeServices();
}
await _liveCarePatientServices.endCallWithCharge(
vcID, selectedServices);
await _liveCarePatientServices.endCallWithCharge(vcID, selectedServices);
if (_liveCarePatientServices.hasError) {
error = _liveCarePatientServices.error;
setState(ViewState.ErrorLocal);
@ -209,8 +207,7 @@ class LiveCarePatientViewModel extends BaseViewModel {
AlternativeService(serviceID: 2, serviceName: "LABORATORY"),
);
alternativeServicesList.add(
AlternativeService(
serviceID: 3, serviceName: "RADIOLOGY(ULTRASOUND) For pregnant only"),
AlternativeService(serviceID: 3, serviceName: "RADIOLOGY(ULTRASOUND) For pregnant only"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 4, serviceName: "VACCINATIONS"),
@ -231,25 +228,46 @@ class LiveCarePatientViewModel extends BaseViewModel {
AlternativeService(serviceID: 9, serviceName: "FAMILY MEDICIN DR"),
);
alternativeServicesList.add(
AlternativeService(
serviceID: 10, serviceName: "FOLYS CATHETER INSERTION"),
AlternativeService(serviceID: 10, serviceName: "FOLYS CATHETER INSERTION"),
);
alternativeServicesList.add(
AlternativeService(serviceID: 11, serviceName: "GASTRIC TUBE CHANGE"),
);
}
updateInCallPatient({PatiantInformtion patient, appointmentNo}){
_liveCarePatientServices.patientList.forEach((e) {
if(e.patientId == patient.patientId) {
e.episodeNo = 0 ;
updateInCallPatient({PatiantInformtion patient, appointmentNo}) {
_liveCarePatientServices.patientList.forEach((e) {
if (e.patientId == patient.patientId) {
e.episodeNo = 0;
e.appointmentNo = appointmentNo;
return;
}
});
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 {
PatiantInformtion patient;
LiveCarePatientViewModel _liveCareViewModel = LiveCarePatientViewModel();
bool isFromSearch = false;
bool isFromLiveCare = false;
@ -63,6 +64,9 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
void dispose() {
_tabController.dispose();
super.dispose();
if (isFromLiveCare) {
_liveCareViewModel.removePatientFromDoctorList(patient.vcId);
}
}
@override
@ -123,6 +127,9 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
return BaseView<LiveCarePatientViewModel>(
onModelReady: (model) async {
if (isFromLiveCare && patient.patientStatus == 1) await model.addPatientToDoctorList(patient.vcId);
},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
appBarTitle: TranslationBase.of(context).patientProfile,
@ -316,43 +323,35 @@ class _PatientProfileScreenState extends State<PatientProfileScreen> with Single
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
EndCallScreen(patient: patient)));
builder: (BuildContext context) => EndCallScreen(patient: patient)));
} else {
GifLoaderDialogUtils.showMyDialog(context);
await model.startCall(
isReCall: false, vCID: patient.vcId);
await model.startCall(isReCall: false, vCID: patient.vcId);
if (model.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Helpers.showErrorToast(model.error);
} else {
await model.getDoctorProfile();
patient.appointmentNo = int.parse(model
.startCallRes.appointmentNo
.toString());
patient.appointmentNo = int.parse(model.startCallRes.appointmentNo.toString());
patient.episodeNo = 0;
model.updateInCallPatient(
patient: patient,
appointmentNo: int.parse(model
.startCallRes.appointmentNo
.toString()));
appointmentNo: int.parse(model.startCallRes.appointmentNo.toString()));
setState(() {
isCallStarted = true;
});
GifLoaderDialogUtils.hideDialog(context);
AppPermissionsUtils
.requestVideoCallPermission(
context: context,
onTapGrant: () {
locator<VideoCallService>()
.openVideo(
model.startCallRes,
patient,
model.startCallRes != null ? model.startCallRes.isRecording : true
, callConnected,
callDisconnected);
});
AppPermissionsUtils.requestVideoCallPermission(
context: context,
onTapGrant: () {
locator<VideoCallService>().openVideo(
model.startCallRes,
patient,
model.startCallRes != null ? model.startCallRes.isRecording : true,
callConnected,
callDisconnected);
});
}
}
},

Loading…
Cancel
Save