Final testing done

faiz_dev_new
FaizHashmiCS22 3 years ago
parent a15aaa4db9
commit 14f1268f66

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

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

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

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

Loading…
Cancel
Save