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