|
|
|
@ -51,7 +51,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
Future<String> getCurrentIP() async {
|
|
|
|
Future<String> getCurrentIP() async {
|
|
|
|
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
|
|
|
|
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
|
|
|
|
log("interfaces: ${interface.name}");
|
|
|
|
log("interfaces: ${interface.name}");
|
|
|
|
if (interface.name == "eth0") {
|
|
|
|
//TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN
|
|
|
|
|
|
|
|
if (interface.name == "wlan0") {
|
|
|
|
|
|
|
|
// if (interface.name == "eth0") {
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
deviceIPGlobal = address.address;
|
|
|
|
deviceIPGlobal = address.address;
|
|
|
|
return deviceIPGlobal;
|
|
|
|
return deviceIPGlobal;
|
|
|
|
@ -83,7 +85,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
audioPlayer.playerStateStream.listen((playerState) {
|
|
|
|
audioPlayer.playerStateStream.listen((playerState) {
|
|
|
|
if (playerState.processingState == ProcessingState.completed) {
|
|
|
|
if (playerState.processingState == ProcessingState.completed) {
|
|
|
|
isCallingInProgress = false;
|
|
|
|
isCallingInProgress = false;
|
|
|
|
print("UpdatedInProgresslisten: $isCallingInProgress");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return AppScaffold(
|
|
|
|
return AppScaffold(
|
|
|
|
@ -165,17 +166,16 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
String getCallTypeText(Tickets ticket) {
|
|
|
|
String getCallTypeText(Tickets ticket) {
|
|
|
|
final callType = ticket.getCallType();
|
|
|
|
final callType = ticket.getCallType();
|
|
|
|
switch (callType) {
|
|
|
|
switch (callType) {
|
|
|
|
case CallType.RECEPTION:
|
|
|
|
case CallType.vitalSign:
|
|
|
|
return "Please Visit Doctor";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CallType.NURSE:
|
|
|
|
|
|
|
|
return "Please Visit Nurse";
|
|
|
|
return "Please Visit Nurse";
|
|
|
|
break;
|
|
|
|
case CallType.doctor:
|
|
|
|
case CallType.DOCTOR:
|
|
|
|
|
|
|
|
return "Please Visit Doctor";
|
|
|
|
return "Please Visit Doctor";
|
|
|
|
break;
|
|
|
|
case CallType.procedure:
|
|
|
|
case CallType.NONE:
|
|
|
|
return "Please Visit Procedure";
|
|
|
|
return "";
|
|
|
|
case CallType.vaccination:
|
|
|
|
|
|
|
|
return "Please Visit Vaccination";
|
|
|
|
|
|
|
|
case CallType.nebulization:
|
|
|
|
|
|
|
|
return "Please Visit Nebulization";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
@ -186,40 +186,28 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
|
|
int callFlag = 0;
|
|
|
|
int callFlag = 0;
|
|
|
|
|
|
|
|
|
|
|
|
bool isRequiredVoice({CallType callType, bool isQueueNurse, bool isQueueDr}) {
|
|
|
|
// bool isRequiredVoice({CallType callType, bool isQueue}) {
|
|
|
|
if (callType == CallType.DOCTOR && !isQueueDr) {
|
|
|
|
// if (callType == CallType.DOCTOR && !isQueue) {
|
|
|
|
return true;
|
|
|
|
// return true;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
if (callType == CallType.NURSE && !isQueueNurse) {
|
|
|
|
// if (callType == CallType.NURSE && !isQueue) {
|
|
|
|
return true;
|
|
|
|
// return true;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
return false;
|
|
|
|
// return false;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
bool isCallingInProgress = false;
|
|
|
|
bool isCallingInProgress = false;
|
|
|
|
|
|
|
|
|
|
|
|
voiceCall(AudioPlayer audioPlayer) async {
|
|
|
|
voiceCall(AudioPlayer audioPlayer) async {
|
|
|
|
isCallingInProgress = true;
|
|
|
|
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");
|
|
|
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
if (waitings.first.isToneReq &&
|
|
|
|
if (waitings.first.isToneReq && waitings.first.isQueue) {
|
|
|
|
isRequiredVoice(
|
|
|
|
|
|
|
|
callType: waitings.first.getCallType(),
|
|
|
|
|
|
|
|
isQueueDr: waitings.first.isQueueDr,
|
|
|
|
|
|
|
|
isQueueNurse: waitings.first.isQueueNurse,
|
|
|
|
|
|
|
|
)) {
|
|
|
|
|
|
|
|
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 && waitings.first.isQueue) {
|
|
|
|
voiceCaller == null &&
|
|
|
|
|
|
|
|
isRequiredVoice(
|
|
|
|
|
|
|
|
callType: waitings.first.getCallType(),
|
|
|
|
|
|
|
|
isQueueDr: waitings.first.isQueueDr,
|
|
|
|
|
|
|
|
isQueueNurse: waitings.first.isQueueNurse,
|
|
|
|
|
|
|
|
)) {
|
|
|
|
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
|
|
|
|
await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
|
|
|
|
await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
|
|
|
|
@ -227,7 +215,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
await Future.delayed(Duration(milliseconds: int.parse(isQueuePatients.first.queueDuration) * 10)).whenComplete(() async {
|
|
|
|
await Future.delayed(Duration(seconds: isQueuePatients.first.concurrentCallDelaySec)).whenComplete(() async {
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
if (isQueuePatients.isNotEmpty) {
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
isQueuePatients.removeAt(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -289,8 +277,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
|
|
|
|
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
|
|
|
|
// if (true) {
|
|
|
|
// if (true) {
|
|
|
|
print("I will wait with $isCallingInProgress ");
|
|
|
|
Timer(Duration(seconds: isQueuePatients.first.concurrentCallDelaySec), () async {
|
|
|
|
Timer(Duration(milliseconds: int.parse(waitings.first.queueDuration)), () async {
|
|
|
|
|
|
|
|
await callPatientsAPI();
|
|
|
|
await callPatientsAPI();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -304,8 +291,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
updateTickets() {
|
|
|
|
updateTickets() {
|
|
|
|
if (waitings != null && waitings.isNotEmpty) {
|
|
|
|
if (waitings != null && waitings.isNotEmpty) {
|
|
|
|
List<Tickets> _ticketsToUpdate = waitings.where((t) => t.callUpdated == false).toList();
|
|
|
|
List<Tickets> _ticketsToUpdate = waitings.where((t) => t.callUpdated == false).toList();
|
|
|
|
API.callUpdateNotIsQueueRecordByIDAsync(deviceIPGlobal, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
|
|
|
|
API.callUpdateNotIsQueueRecordByIDAsync(deviceIPGlobal, ticket: _ticketsToUpdate.first, onSuccess: (ticketsUpdated) {
|
|
|
|
log("[${tickets_updated.length}] Tickets Updated: $tickets_updated");
|
|
|
|
log("[${ticketsUpdated.length}] Tickets Updated: $ticketsUpdated");
|
|
|
|
}, onFailure: (e) {
|
|
|
|
}, onFailure: (e) {
|
|
|
|
log("API UPDate Tickets Failed with : ${e.toString()}");
|
|
|
|
log("API UPDate Tickets Failed with : ${e.toString()}");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|