|
|
|
@ -32,7 +32,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
SignalRHelper signalRHelper = SignalRHelper();
|
|
|
|
SignalRHelper signalRHelper = SignalRHelper();
|
|
|
|
|
|
|
|
|
|
|
|
List<Tickets> waitings = [];
|
|
|
|
List<Tickets> waitings = [];
|
|
|
|
List<Tickets> currents = [];
|
|
|
|
List<Tickets> isQueuePatients = [];
|
|
|
|
|
|
|
|
|
|
|
|
bool isLoading = false;
|
|
|
|
bool isLoading = false;
|
|
|
|
|
|
|
|
|
|
|
|
@ -113,31 +113,32 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onUpdateIPPressed() async {
|
|
|
|
onUpdateIPPressed() async {
|
|
|
|
if (controller.text.isNotEmpty) {
|
|
|
|
// if (controller.text.isNotEmpty) {
|
|
|
|
isLoading = true;
|
|
|
|
// isLoading = true;
|
|
|
|
setState(() {});
|
|
|
|
// setState(() {});
|
|
|
|
DEVICE_IP = controller.text;
|
|
|
|
// DEVICE_IP = controller.text;
|
|
|
|
|
|
|
|
//
|
|
|
|
await signalRHelper.connection.stop();
|
|
|
|
// await signalRHelper.connection.stop();
|
|
|
|
if (!signalRHelper.getConnectionState()) {
|
|
|
|
// if (!signalRHelper.getConnectionState()) {
|
|
|
|
await signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
// await signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
controller.clear();
|
|
|
|
// controller.clear();
|
|
|
|
waitings.clear();
|
|
|
|
// waitings.clear();
|
|
|
|
isLoading = false;
|
|
|
|
// isLoading = false;
|
|
|
|
setState(() {});
|
|
|
|
// setState(() {});
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget content() {
|
|
|
|
Widget content() {
|
|
|
|
|
|
|
|
// waitings.removeAt(0);
|
|
|
|
// waitings = waitings.sublist(0,3);
|
|
|
|
// waitings = waitings.sublist(0,3);
|
|
|
|
voiceCall();
|
|
|
|
voiceCall();
|
|
|
|
|
|
|
|
|
|
|
|
if (waitings.isEmpty) {
|
|
|
|
if (waitings.isEmpty) {
|
|
|
|
// No Patient in Queue
|
|
|
|
// No Patient in Queue
|
|
|
|
return noPatientInQueue();
|
|
|
|
return noPatientInQueue();
|
|
|
|
} else if (waitings.length > 4) {
|
|
|
|
} else if (waitings.length > 3) {
|
|
|
|
// Return Content With Side List
|
|
|
|
// Return Content With Side List
|
|
|
|
return priorityTicketsWithSideList(waitings);
|
|
|
|
return priorityTicketsWithSideList(waitings);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -167,31 +168,53 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallByVoice voiceCaller;
|
|
|
|
CallByVoice voiceCaller;
|
|
|
|
|
|
|
|
int callFlag = 0;
|
|
|
|
|
|
|
|
|
|
|
|
voiceCall() async {
|
|
|
|
voiceCall() async {
|
|
|
|
|
|
|
|
//TODO: 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
|
|
|
|
|
|
|
|
|
|
|
|
if (waitings.isNotEmpty && voiceCaller == null) {
|
|
|
|
if (waitings.isNotEmpty && voiceCaller == null) {
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
voiceCaller = CallByVoice(waitings.first.callNoStr.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
voiceCaller = CallByVoice(waitings.first.callNoStr.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
await voiceCaller.startCalling();
|
|
|
|
await voiceCaller.startCalling();
|
|
|
|
voiceCaller = null;
|
|
|
|
voiceCaller = null;
|
|
|
|
|
|
|
|
log("isQueuePatients : ${isQueuePatients.length}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
|
|
|
await Future.delayed(Duration(milliseconds: int.parse(isQueuePatients.first.queueDuration) * 10)).whenComplete(() async {
|
|
|
|
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
|
|
|
|
Tickets ticket = waitings.elementAt(0);
|
|
|
|
|
|
|
|
waitings.removeAt(0);
|
|
|
|
|
|
|
|
waitings.add(ticket);
|
|
|
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isQueuePatients.isEmpty && callFlag == 1) {
|
|
|
|
|
|
|
|
callFlag == 0;
|
|
|
|
|
|
|
|
log("Done : ${isQueuePatients.length}");
|
|
|
|
|
|
|
|
await Future.delayed(const Duration(seconds: 3));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onUpdateAvailable(data) async {
|
|
|
|
onUpdateAvailable(data) async {
|
|
|
|
|
|
|
|
if (isQueuePatients.isNotEmpty && callFlag == 0) {
|
|
|
|
|
|
|
|
callFlag = 1;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
waitings.clear();
|
|
|
|
waitings.clear();
|
|
|
|
API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls) {
|
|
|
|
API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
setState(() {
|
|
|
|
setState(() {
|
|
|
|
waitings = waitingCalls;
|
|
|
|
waitings = waitingCalls;
|
|
|
|
|
|
|
|
isQueuePatients = isQueuePatientsCalls;
|
|
|
|
// currents = currentInClinic;
|
|
|
|
// currents = currentInClinic;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
log("\n\n");
|
|
|
|
|
|
|
|
log("--------------------");
|
|
|
|
log("--------------------");
|
|
|
|
log("waiting: $waitings");
|
|
|
|
log("waiting: $waitings");
|
|
|
|
|
|
|
|
log("isQueuePatients: $isQueuePatients");
|
|
|
|
log("--------------------");
|
|
|
|
log("--------------------");
|
|
|
|
log("\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateTickets();
|
|
|
|
updateTickets();
|
|
|
|
}, onFailure: (error) {});
|
|
|
|
}, onFailure: (error) {});
|
|
|
|
|