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