|
|
|
|
@ -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() {
|
|
|
|
|
|