|
|
|
|
@ -8,6 +8,7 @@ import 'package:just_audio/just_audio.dart';
|
|
|
|
|
import 'package:queuing_system/core/api.dart';
|
|
|
|
|
import 'package:queuing_system/core/base/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:queuing_system/core/config/size_config.dart';
|
|
|
|
|
import 'package:queuing_system/core/response_model/call_config.dart';
|
|
|
|
|
import 'package:queuing_system/core/response_model/patient_call.dart';
|
|
|
|
|
import 'package:queuing_system/header/app_header.dart';
|
|
|
|
|
import 'package:queuing_system/home/home_screen_components.dart';
|
|
|
|
|
@ -19,7 +20,7 @@ import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
|
|
|
|
|
|
|
|
|
|
var deviceIPGlobal = "10.10.15.11";
|
|
|
|
|
|
|
|
|
|
bool isDevMode = true; // Testing IP
|
|
|
|
|
bool isDevMode = false; // Testing IP
|
|
|
|
|
|
|
|
|
|
// var DEVICE_IP = "10.10.14.11"; // Testing IP
|
|
|
|
|
// var DEVICE_IP = "10.10.15.11";
|
|
|
|
|
@ -38,6 +39,7 @@ class MyHomePage extends StatefulWidget {
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
SignalRHelper signalRHelper = SignalRHelper();
|
|
|
|
|
|
|
|
|
|
CallConfig callConfigsGlobal = CallConfig();
|
|
|
|
|
List<Tickets> waitings = [];
|
|
|
|
|
List<Tickets> isQueuePatients = [];
|
|
|
|
|
|
|
|
|
|
@ -52,8 +54,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
|
|
|
|
|
log("interfaces: ${interface.name}");
|
|
|
|
|
//TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN
|
|
|
|
|
if (interface.name == "wlan0") {
|
|
|
|
|
// if (interface.name == "eth0") {
|
|
|
|
|
// if (interface.name == "wlan0") {
|
|
|
|
|
if (interface.name == "eth0") {
|
|
|
|
|
for (var address in interface.addresses) {
|
|
|
|
|
deviceIPGlobal = address.address;
|
|
|
|
|
return deviceIPGlobal;
|
|
|
|
|
@ -106,7 +108,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
children: [
|
|
|
|
|
InkWell(
|
|
|
|
|
onTap: () {
|
|
|
|
|
onUpdateAvailable("");
|
|
|
|
|
// onUpdateAvailable("");
|
|
|
|
|
},
|
|
|
|
|
child: AppText(
|
|
|
|
|
"Powered By",
|
|
|
|
|
@ -156,29 +158,30 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
return noPatientInQueue();
|
|
|
|
|
} else if (waitings.length > 3) {
|
|
|
|
|
// Return Content With Side List
|
|
|
|
|
return priorityTicketsWithSideList(waitings);
|
|
|
|
|
return priorityTicketsWithSideList(waitings, callConfigsGlobal);
|
|
|
|
|
} else {
|
|
|
|
|
// Return Content In Center Aligned
|
|
|
|
|
return priorityTickets(waitings);
|
|
|
|
|
return priorityTickets(waitings, callConfigsGlobal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getCallTypeText(Tickets ticket) {
|
|
|
|
|
String getCallTypeText(Tickets ticket, CallConfig callConfig) {
|
|
|
|
|
final callType = ticket.getCallType();
|
|
|
|
|
final language = callConfig.screenLanguage;
|
|
|
|
|
switch (callType) {
|
|
|
|
|
case CallType.vitalSign:
|
|
|
|
|
return "Please Visit Nurse";
|
|
|
|
|
return callConfig.vitalSignText;
|
|
|
|
|
case CallType.doctor:
|
|
|
|
|
return "Please Visit Doctor";
|
|
|
|
|
return callConfig.doctorText;
|
|
|
|
|
case CallType.procedure:
|
|
|
|
|
return "Please Visit Procedure";
|
|
|
|
|
return callConfig.procedureText;
|
|
|
|
|
case CallType.vaccination:
|
|
|
|
|
return "Please Visit Vaccination";
|
|
|
|
|
return callConfig.vaccinationText;
|
|
|
|
|
case CallType.nebulization:
|
|
|
|
|
return "Please Visit Nebulization";
|
|
|
|
|
return callConfig.nebulizationText;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
return callConfig.vitalSignText;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -202,13 +205,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
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
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
if (waitings.first.isToneReq && waitings.first.isQueue) {
|
|
|
|
|
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 && waitings.first.isQueue) {
|
|
|
|
|
final postVoice = getCallTypeText(waitings.first);
|
|
|
|
|
if (waitings.first.isVoiceReq && voiceCaller == null && !waitings.first.isQueue) {
|
|
|
|
|
final postVoice = getCallTypeText(waitings.first, callConfigsGlobal);
|
|
|
|
|
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());
|
|
|
|
|
voiceCaller = null;
|
|
|
|
|
@ -253,8 +256,9 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
|
|
|
|
|
Future<void> callPatientsAPI() async {
|
|
|
|
|
waitings.clear();
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
|
|
|
|
|
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) {
|
|
|
|
|
setState(() {
|
|
|
|
|
callConfigsGlobal = callConfigs;
|
|
|
|
|
waitings = waitingCalls;
|
|
|
|
|
isQueuePatients = isQueuePatientsCalls;
|
|
|
|
|
// currents = currentInClinic;
|
|
|
|
|
@ -277,7 +281,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
|
if (waitings.isNotEmpty) {
|
|
|
|
|
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
|
|
|
|
|
// if (true) {
|
|
|
|
|
Timer(Duration(seconds: isQueuePatients.first.concurrentCallDelaySec), () async {
|
|
|
|
|
Timer(Duration(seconds: callConfigsGlobal.concurrentCallDelaySec), () async {
|
|
|
|
|
await callPatientsAPI();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
|