Final testing done

faiz_dev_new
FaizHashmiCS22 2 years ago
parent a15aaa4db9
commit 14f1268f66

@ -24,19 +24,19 @@ class API {
onSuccess: (apiResp, status) {
if (status == 200) {
final response = apiResp["data"];
var calledByNurse = (response["nurseCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
final patients = (response["drCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
calledByNurse.addAll(patients);
log("NurseCallPatients: ${calledByNurse.toString()} ");
log("patients: ${patients.toString()} ");
var callPatients = (response["callPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
// final patients = (response["drCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
// callPatients.addAll(patients);
// log("callPatients: ${callPatients.toString()} ");
// log("patients: ${patients.toString()} ");
var isQueuePatients = calledByNurse.where((element) => element.isQueueNurse == false || element.isQueueDr == false).toList();
calledByNurse.removeWhere((element) => element.isQueueNurse == false || element.isQueueDr == false);
// calledByNurse.sort((a, b) => a.callNo.compareTo(b.callNo));
var isQueuePatients = callPatients.where((element) => (element.callType == 1 && element.isQueueNurse == false) || (element.callType == 2 && element.isQueueDr == false)).toList();
// callPatients.removeWhere((element) => (element.callType == 1 && element.isQueueNurse == false) || (element.callType == 2 && element.isQueueDr == false));
callPatients.sort((a, b) => a.editedOnTimeStamp.compareTo(b.editedOnTimeStamp));
calledByNurse.addAll(isQueuePatients.toList());
// callPatients.addAll(isQueuePatients.toList());
onSuccess(calledByNurse.reversed.toList(), isQueuePatients.reversed.toList());
onSuccess(callPatients.reversed.toList(), isQueuePatients.reversed.toList());
} else {
onFailure(apiResp);
}

@ -10,6 +10,7 @@ class Tickets {
String doctorNameN;
int patientGender;
int callType;
int editedOnTimeStamp;
String roomNo;
String createdOn;
String editedOn;
@ -30,6 +31,7 @@ class Tickets {
this.doctorNameN,
this.patientGender,
this.callType,
this.editedOnTimeStamp,
this.roomNo,
this.createdOn,
this.editedOn,
@ -53,6 +55,7 @@ class Tickets {
doctorNameN = json['doctorNameN'];
patientGender = json['patientGender'];
callType = json['callType'];
editedOnTimeStamp = DateTime.parse(json['editedOn']).millisecondsSinceEpoch;
roomNo = json['roomNo'];
createdOn = json['createdOn'];
editedOn = json['editedOn'];

@ -76,9 +76,16 @@ class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
final AudioPlayer audioPlayer = AudioPlayer();
audioPlayer.playerStateStream.listen((playerState) {
if (playerState.processingState == ProcessingState.completed) {
isCallingInProgress = false;
print("UpdatedInProgresslisten: $isCallingInProgress");
}
});
return AppScaffold(
appBar: AppHeader(),
body: dataContent(),
body: dataContent(audioPlayer),
bottomNavigationBar: Container(
color: Colors.grey.withOpacity(0.1),
height: Utils.getHeight(),
@ -132,10 +139,8 @@ class _MyHomePageState extends State<MyHomePage> {
// }
}
Widget dataContent() {
// waitings.removeAt(0);
// waitings = waitings.sublist(0,3);
voiceCall();
Widget dataContent(AudioPlayer audioPlayer) {
voiceCall(audioPlayer);
if (waitings.isEmpty) {
// No Patient in Queue
@ -170,7 +175,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
CallByVoice voiceCaller;
final AudioPlayer audioPlayer = AudioPlayer();
int callFlag = 0;
bool isRequiredVoice({CallType callType, bool isQueueNurse, bool isQueueDr}) {
@ -183,7 +188,10 @@ class _MyHomePageState extends State<MyHomePage> {
return false;
}
voiceCall() async {
bool isCallingInProgress = false;
voiceCall(AudioPlayer audioPlayer) async {
isCallingInProgress = true;
//DONE: After calling this voice call, we should delay for milliseconds that is given by API. After that we will check if there are more patients in isQueuePatients we will remove the patient from waiting list and then update the state
print("I am here");
if (waitings.isNotEmpty) {
@ -195,7 +203,7 @@ class _MyHomePageState extends State<MyHomePage> {
)) {
audioPlayer.setAsset("assets/tones/call_tone.mp3");
await audioPlayer.play();
// await Future.delayed(const Duration(seconds: 2));
await Future.delayed(const Duration(seconds: 2));
}
if (waitings.first.isVoiceReq &&
voiceCaller == null &&
@ -247,26 +255,47 @@ class _MyHomePageState extends State<MyHomePage> {
}
}
onUpdateAvailable(data) async {
if (isQueuePatients.isNotEmpty && callFlag == 0) {
callFlag = 1;
return;
}
waitings.clear();
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
setState(() {
waitings = waitingCalls;
isQueuePatients = isQueuePatientsCalls;
// currents = currentInClinic;
onUpdateAvailable(data, audioPlayer) async {
// if (isQueuePatients.isNotEmpty && callFlag == 0) {
// callFlag = 1;
// return;
// }
print("hereValues: ${isCallingInProgress || voiceCaller != null}");
if ((isCallingInProgress || voiceCaller != null) && waitings.isNotEmpty) {
Timer(Duration(milliseconds: int.parse(waitings.first.queueDuration)), () {
waitings.clear();
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
setState(() {
waitings = waitingCalls;
isQueuePatients = isQueuePatientsCalls;
// currents = currentInClinic;
});
log("--------------------");
log("waiting: $waitings");
log("isQueuePatients: $isQueuePatients");
log("--------------------");
updateTickets();
}, onFailure: (error) {});
});
} else {
waitings.clear();
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
setState(() {
waitings = waitingCalls;
isQueuePatients = isQueuePatientsCalls;
// currents = currentInClinic;
});
log("--------------------");
log("waiting: $waitings");
log("isQueuePatients: $isQueuePatients");
log("--------------------");
log("--------------------");
log("waiting: $waitings");
log("isQueuePatients: $isQueuePatients");
log("--------------------");
updateTickets();
}, onFailure: (error) {});
updateTickets();
}, onFailure: (error) {});
}
}
updateTickets() {

@ -2,6 +2,7 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:http/io_client.dart';
import 'package:just_audio/just_audio.dart';
import 'package:signalr_core/signalr_core.dart';
/*
@ -26,12 +27,12 @@ class SignalRHelper {
HubConnection connection;
startSignalRConnection(String deviceIp,
{@required Function(dynamic) onUpdateAvailable, @required VoidCallback onConnect, @required Function(dynamic) onDisconnect, @required VoidCallback onConnecting}) async {
{@required Function(dynamic, dynamic) onUpdateAvailable, @required VoidCallback onConnect, @required Function(dynamic) onDisconnect, @required VoidCallback onConnecting}) async {
// Hardcoded IP For Testing
// deviceIp = "10.10.14.11";
print("Connecting Signal R with: $deviceIp");
final url = hubBaseURL+"?IPAddress=$deviceIp";
final url = hubBaseURL + "?IPAddress=$deviceIp";
// final url = hubBaseURL;
connection = HubConnectionBuilder()
.withUrl(
@ -50,7 +51,7 @@ class SignalRHelper {
connection.onreconnected((connectionId) => onConnect());
connection.on('addChatMessage', (message) {
onUpdateAvailable(message);
onUpdateAvailable(message, AudioPlayer());
});
// try {

Loading…
Cancel
Save