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