|
|
|
|
@ -34,6 +34,7 @@ class AppProvider extends ChangeNotifier {
|
|
|
|
|
listenNetworkConnectivity();
|
|
|
|
|
listenAudioPlayerEvents();
|
|
|
|
|
getTheWidgetsConfigurationsEveryMidnight();
|
|
|
|
|
initializeFlutterTTS();
|
|
|
|
|
// await callPatientsAPI();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -51,6 +52,54 @@ class AppProvider extends ChangeNotifier {
|
|
|
|
|
bool isInternetConnectionAvailable = true;
|
|
|
|
|
bool isApiCallNeeded = false;
|
|
|
|
|
|
|
|
|
|
initializeFlutterTTS() async {
|
|
|
|
|
flutterTts.setCompletionHandler(() => onVoiceCompleted());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> onVoiceCompleted() async {
|
|
|
|
|
log("My Value is in setCompletionHandler: $isVoiceActualCompletedGlobally");
|
|
|
|
|
log("isQueuePatients.length in setCompletionHandler: ${isQueuePatients.length}");
|
|
|
|
|
if (!isVoiceActualCompletedGlobally) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(
|
|
|
|
|
() async {
|
|
|
|
|
PatientTicketModel temp = PatientTicketModel();
|
|
|
|
|
if (patientTickets.isNotEmpty && isQueuePatients.length > 1) {
|
|
|
|
|
temp = patientTickets.elementAt(0);
|
|
|
|
|
patientTickets.removeAt(0);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
|
}
|
|
|
|
|
if (patientTickets.isNotEmpty && isQueuePatients.length > 1) {
|
|
|
|
|
patientTickets.add(temp);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
await voiceCallPatientTicket(patientTickets.first, "setCompletionHandler");
|
|
|
|
|
updatePatientTicket(patientTickets.first);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log("here logg: ${isQueuePatients.length}");
|
|
|
|
|
|
|
|
|
|
if (isQueuePatients.isEmpty) {
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
if (isApiCallNeeded && isQueuePatients.isEmpty) {
|
|
|
|
|
log("Setting isCallingInProgress : $isCallingInProgress");
|
|
|
|
|
Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async {
|
|
|
|
|
await callPatientsAPI();
|
|
|
|
|
isApiCallNeeded = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateInternetConnection(bool value) {
|
|
|
|
|
isInternetConnectionAvailable = value;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
@ -352,9 +401,8 @@ class AppProvider extends ChangeNotifier {
|
|
|
|
|
);
|
|
|
|
|
await voiceCaller!.startCalling(patientTicket.queueNo.trim().toString() != patientTicket.callNoStr.trim().toString()).whenComplete(() {
|
|
|
|
|
voiceCaller = null;
|
|
|
|
|
// if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
// isQueuePatients.removeAt(0);
|
|
|
|
|
// }
|
|
|
|
|
onVoiceCompleted();
|
|
|
|
|
log("Completed Calling!! ${isQueuePatients.length}");
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
@ -418,53 +466,6 @@ class AppProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
flutterTts.setCompletionHandler(() async {
|
|
|
|
|
log("My Value is in setCompletionHandler: $isVoiceActualCompletedGlobally");
|
|
|
|
|
log("isQueuePatients.length in setCompletionHandler: ${isQueuePatients.length}");
|
|
|
|
|
if (!isVoiceActualCompletedGlobally) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
// final length = isQueuePatients.length;
|
|
|
|
|
// for (int i = 0; i < length; i++) {
|
|
|
|
|
await Future.delayed(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec)).whenComplete(
|
|
|
|
|
() async {
|
|
|
|
|
PatientTicketModel temp = PatientTicketModel();
|
|
|
|
|
if (patientTickets.isNotEmpty && isQueuePatients.length > 1) {
|
|
|
|
|
temp = patientTickets.elementAt(0);
|
|
|
|
|
patientTickets.removeAt(0);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
|
}
|
|
|
|
|
if (patientTickets.isNotEmpty && isQueuePatients.length > 1) {
|
|
|
|
|
patientTickets.add(temp);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
|
await voiceCallPatientTicket(patientTickets.first, "setCompletionHandler");
|
|
|
|
|
updatePatientTicket(patientTickets.first);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log("here logg: ${isQueuePatients.length}");
|
|
|
|
|
|
|
|
|
|
if (isQueuePatients.isEmpty) {
|
|
|
|
|
isCallingInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
if (isApiCallNeeded && isQueuePatients.isEmpty) {
|
|
|
|
|
log("Setting isCallingInProgress : $isCallingInProgress");
|
|
|
|
|
Timer(Duration(seconds: patientCallConfigurations.concurrentCallDelaySec), () async {
|
|
|
|
|
await callPatientsAPI();
|
|
|
|
|
isApiCallNeeded = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// updatePatientTickets() {
|
|
|
|
|
|