Updated Endpoints and DataModels

dev_faiz
FaizHashmiCS22 2 years ago
parent a44f58280d
commit 5379fdc6a6

@ -3,10 +3,11 @@ import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:queuing_system/core/base/base_app_client.dart';
import 'package:queuing_system/core/config/config.dart';
import 'package:queuing_system/core/response_model/patient_call.dart';
const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfoByIP";
const _call_UpdateNotIsQueueRecordByIDAsync = "/UpdateCallRequestQueue";
const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfo_ByIP";
const _callUpdateNotIsQueueRecordByIDAsync = "/CallRequest_QueueUpdate";
class MyHttpOverrides extends HttpOverrides {
@override
@ -17,26 +18,27 @@ class MyHttpOverrides extends HttpOverrides {
class API {
static getCallRequestInfoByClinicInfo(String deviceIp, {@required Function(List<Tickets>, List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async {
final body = {"IPAdress": deviceIp};
final body = {"ipAdress": deviceIp, "apiKey": apiKey};
BaseAppClient.post(_getCallRequestInfoByClinicInfo,
body: body,
onSuccess: (response, status) {
onSuccess: (apiResp, status) {
if (status == 200) {
var calledByNurse = (response["NurseCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
final patients = (response["DrCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
final response = apiResp["data"];
var calledByNurse = (response["nurseCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
final patients = (response["drCallPatients"] as List).map((j) => Tickets.fromJson(j)).toList();
calledByNurse.addAll(patients);
log("NurseCallPatients: ${calledByNurse.toString()} ");
log("patients: ${patients.toString()} ");
var isQueuePatients = calledByNurse.where((element) => element.isQueue == false).toList();
calledByNurse.removeWhere((element) => element.isQueue == false);
var isQueuePatients = calledByNurse.where((element) => element.isQueueNurse == false).toList();
calledByNurse.removeWhere((element) => element.isQueueNurse == false);
// calledByNurse.sort((a, b) => a.callNo.compareTo(b.callNo));
calledByNurse.addAll(isQueuePatients.toList());
onSuccess(calledByNurse.reversed.toList(), isQueuePatients.reversed.toList());
} else {
onFailure(response);
onFailure(apiResp);
}
},
onFailure: (error, status) => onFailure(error));
@ -50,14 +52,15 @@ class API {
List<Tickets> _ticketsUpdated = [];
// for (var ticket in tickets) {
final body = {"CallID": ticket.id};
await BaseAppClient.post(_call_UpdateNotIsQueueRecordByIDAsync,
final body = {"id": ticket.id, "apiKey": apiKey, "ipAddress": deviceIp};
await BaseAppClient.post(_callUpdateNotIsQueueRecordByIDAsync,
body: body,
onSuccess: (response, status) {
if (status == 200) {
ticket.callUpdated = true;
_ticketsUpdated.add(ticket);
}
log("here response: $response");
},
onFailure: (error, status) => onFailure(error));
// }

@ -5,7 +5,8 @@ const ONLY_NUMBERS = "[0-9]";
const ONLY_LETTERS = "[a-zA-Z &'\"]";
const ONLY_DATE = "[0-9/]";
const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/';
const BASE_URL = 'https://uat.hmgwebservices.com/services/Nurses.svc/REST'; // UAT
const BASE_URL = 'https://ms.hmg.com/nscapi/api/PatientCall'; // UAT
const apiKey = 'EE17D21C7943485D9780223CCE55DCE5'; // UAT
// const BASE_URL = 'http://10.200.204.11:2222/Services/Nurses.svc/REST';
// const BASE_URL = 'https://hmgwebservices.com/';

@ -1,6 +0,0 @@
enum FontType {
Poppins_Bold,
poppins_Medium,
poppins_Regular,
poppins_SemiBold,
}

@ -3,89 +3,88 @@ import 'dart:math';
import 'package:queuing_system/utils/call_type.dart';
class Tickets {
Tickets({
this.callNo,
this.roomNo,
this.callType,
this.createdON,
this.doctorName,
this.doctorNameN,
this.editedON,
this.mobileNo,
this.patientGender,
this.patientID,
this.callNoStr,
this.queueNo,
this.queueDuration,
this.isQueue,
this.isVoiceReq,
this.isToneReq,
});
int getRandomNum() {
return Random().nextInt(1);
}
Tickets.fromJson(dynamic json) {
id = json['ID'];
callNo = json['CallNo'];
roomNo = json['RoomNo'];
callType = json['CallType'];
createdON = json['CreatedON'];
doctorName = json['DoctorName'];
doctorNameN = json['DoctorNameN'];
editedON = json['EditedON'];
mobileNo = json['MobileNo'];
patientGender = json['PatientGender'];
patientID = json['PatientID'];
queueNo = json['QueueNo'];
queueDuration = json['QueueDuration'];
callNoStr = json['CallNoStr'] ?? json['CallNo'].toString();
isQueue = json["ISQueue"] ?? false;
isToneReq = json["IsToneReq"] ?? true;
isVoiceReq = json["IsVoiceReq"] ?? true;
// isQueue = getRandomNum();
}
int id;
int callNo;
String roomNo;
int callType;
String createdON;
int patientID;
String mobileNo;
String doctorName;
String doctorNameN;
String editedON;
String mobileNo;
int patientGender;
int patientID;
int callType;
String roomNo;
String createdOn;
String editedOn;
String queueNo;
String queueDuration;
String callNoStr;
bool callUpdated = false;
bool isQueue;
bool isQueueNurse;
bool isQueueDr;
bool isToneReq;
bool isVoiceReq;
String queueDuration;
bool callUpdated = false;
Tickets(
{this.id,
this.patientID,
this.mobileNo,
this.doctorName,
this.doctorNameN,
this.patientGender,
this.callType,
this.roomNo,
this.createdOn,
this.editedOn,
this.queueNo,
this.callNoStr,
this.isQueueNurse,
this.isQueueDr,
this.isToneReq,
this.isVoiceReq,
this.queueDuration});
int getRandomNum() {
return Random().nextInt(1);
}
Tickets.fromJson(Map<String, dynamic> json) {
id = json['id'];
patientID = json['patientID'];
mobileNo = json['mobileNo'];
doctorName = json['doctorName'];
doctorNameN = json['doctorNameN'];
patientGender = json['patientGender'];
callType = json['callType'];
roomNo = json['roomNo'];
createdOn = json['createdOn'];
editedOn = json['editedOn'];
queueNo = json['queueNo'];
callNoStr = json['callNoStr'];
isQueueNurse = json['isQueueNurse'];
isQueueDr = json['isQueueDr'];
isToneReq = json['isToneReq'];
isVoiceReq = json['isVoiceReq'];
queueDuration = json['queueDuration'];
}
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['ID'] = id;
map['CallNo'] = callNo;
map['RoomNo'] = roomNo;
map['callType'] = callType;
map['CreatedON'] = createdON;
map['DoctorName'] = doctorName;
map['DoctorNameN'] = doctorNameN;
map['EditedON'] = editedON;
map['MobileNo'] = mobileNo;
map['PatientGender'] = patientGender;
map['PatientID'] = patientID;
map['CallNoStr'] = callNoStr;
map['QueueNo'] = queueNo;
map['QueueDuration'] = queueDuration;
map['ISQueue'] = isQueue;
map['IsToneReq'] = isToneReq;
map['IsVoiceReq'] = isVoiceReq;
return map;
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['patientID'] = patientID;
data['mobileNo'] = mobileNo;
data['doctorName'] = doctorName;
data['doctorNameN'] = doctorNameN;
data['patientGender'] = patientGender;
data['callType'] = callType;
data['roomNo'] = roomNo;
data['createdOn'] = createdOn;
data['editedOn'] = editedOn;
data['queueNo'] = queueNo;
data['callNoStr'] = callNoStr;
data['isQueueNurse'] = isQueueNurse;
data['isQueueDr'] = isQueueDr;
data['isToneReq'] = isToneReq;
data['isVoiceReq'] = isVoiceReq;
data['queueDuration'] = queueDuration;
return data;
}
@override

@ -7,28 +7,35 @@ import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
class AppHeader extends StatelessWidget with PreferredSizeWidget {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.only(
left: 0,
right: 5,
),
decoration: BoxDecoration(
color: AppGlobal.appRedColor, border: const Border(bottom: BorderSide(color: Color(0xFFEFEFEF)))),
decoration: BoxDecoration(color: AppGlobal.appRedColor, border: const Border(bottom: BorderSide(color: Color(0xFFEFEFEF)))),
child: Container(
height: 100,
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 0,),
padding: const EdgeInsets.only(
left: 20,
right: 20,
bottom: 0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AppText(
" Current Serving",
color: Colors.white,
fontFamily: 'Poppins-SemiBold.ttf',
InkWell(
onTap: () {},
child: const AppText(
" Current Serving",
color: Colors.white,
fontFamily: 'Poppins-SemiBold.ttf',
),
),
SvgPicture.asset(
"assets/images/hmglogo.svg",
height: Utils.getHeight() * 0.5,
),
SvgPicture.asset( "assets/images/hmglogo.svg", height: Utils.getHeight() * 0.5,),
],
),
),
@ -36,7 +43,5 @@ class AppHeader extends StatelessWidget with PreferredSizeWidget {
}
@override
Size get preferredSize => Size(
double.maxFinite,
Utils.getHeight());
Size get preferredSize => Size(double.maxFinite, Utils.getHeight());
}

@ -17,7 +17,7 @@ import 'package:queuing_system/utils/signalR_utils.dart';
import 'package:queuing_system/utils/utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
var DEVICE_IP = "10.10.15.11"; // Testing IP
var deviceIPGlobal = "10.10.15.11"; // Testing IP
// var DEVICE_IP = "10.10.14.11"; // Testing IP
// var DEVICE_IP = "10.10.15.11";
@ -46,17 +46,18 @@ class _MyHomePageState extends State<MyHomePage> {
super.dispose();
}
Future<String> printIps() async {
Future<String> getCurrentIP() async {
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
log("interfaces: ${interface.name}");
if (interface.name == "eth0") {
for (var address in interface.addresses) {
DEVICE_IP = address.address;
return DEVICE_IP;
deviceIPGlobal = address.address;
return deviceIPGlobal;
}
}
return "";
}
return "";
}
@override
@ -64,11 +65,10 @@ class _MyHomePageState extends State<MyHomePage> {
listenNetworkConnectivity();
scheduleMicrotask(() async {
if (!signalRHelper.getConnectionState()) {
signalRHelper.startSignalRConnection(await printIps(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
signalRHelper.startSignalRConnection(await getCurrentIP(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
}
});
super.initState();
}
@ -98,7 +98,7 @@ class _MyHomePageState extends State<MyHomePage> {
fontSize: SizeConfig.getWidthMultiplier() * 2.6,
fontFamily: 'Poppins-Medium.ttf',
),
Text(DEVICE_IP, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)),
Text(deviceIPGlobal, style: TextStyle(fontWeight: FontWeight.w500, fontSize: SizeConfig.getWidthMultiplier() * 2.2)),
],
),
const SizedBox(width: 10),
@ -184,8 +184,8 @@ class _MyHomePageState extends State<MyHomePage> {
}
if (waitings.first.isVoiceReq && voiceCaller == null) {
final postVoice = getCallTypeText(waitings.first);
voiceCaller = CallByVoice(waitings.first.queueNo.toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
await voiceCaller.startCalling();
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;
}
}
@ -227,13 +227,12 @@ class _MyHomePageState extends State<MyHomePage> {
}
onUpdateAvailable(data) async {
print("here is the data: $data");
if (isQueuePatients.isNotEmpty && callFlag == 0) {
callFlag = 1;
return;
}
waitings.clear();
API.getCallRequestInfoByClinicInfo(DEVICE_IP, onSuccess: (waitingCalls, isQueuePatientsCalls) {
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls) {
setState(() {
waitings = waitingCalls;
isQueuePatients = isQueuePatientsCalls;
@ -252,7 +251,7 @@ class _MyHomePageState extends State<MyHomePage> {
updateTickets() {
if (waitings != null && waitings.isNotEmpty) {
List<Tickets> _ticketsToUpdate = waitings.where((t) => t.callUpdated == false).toList();
API.callUpdateNotIsQueueRecordByIDAsync(DEVICE_IP, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
API.callUpdateNotIsQueueRecordByIDAsync(deviceIPGlobal, ticket: _ticketsToUpdate.first, onSuccess: (tickets_updated) {
log("[${tickets_updated.length}] Tickets Updated: $tickets_updated");
}, onFailure: (e) {
log("API UPDate Tickets Failed with : ${e.toString()}");
@ -266,7 +265,7 @@ class _MyHomePageState extends State<MyHomePage> {
onDisconnect(exception) {
log("SignalR: onDisconnect");
signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
signalRHelper.startSignalRConnection(deviceIPGlobal, onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
}
onConnecting() {

@ -6,9 +6,9 @@ import 'package:queuing_system/utils/call_type.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
class PriorityTickets extends StatelessWidget {
List<Tickets> tickets;
final List<Tickets> tickets;
PriorityTickets(this.tickets, {Key key}) : super(key: key);
const PriorityTickets(this.tickets, {Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -20,12 +20,13 @@ class PriorityTickets extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 20),
vTicketItem(
TicketItem(
ticketNo: firstTicket.queueNo ?? '',
callType: firstTicket.getCallType(),
scale: 1,
blink: true,
roomNo: firstTicket.roomNo,
isClinicAdded: firstTicket.callNoStr != firstTicket.queueNo,
),
const SizedBox(height: 40),
if (tickets.length > 1) ...[
@ -35,11 +36,12 @@ class PriorityTickets extends StatelessWidget {
children: otherTickets
.map((ticket) => Padding(
padding: EdgeInsets.only(top: SizeConfig.getHeightMultiplier() * 2),
child: vTicketItem(
child: TicketItem(
ticketNo: ticket.queueNo ?? '',
callType: ticket.getCallType(),
scale: 0.7,
roomNo: ticket.roomNo,
isClinicAdded: ticket.callNoStr != ticket.queueNo,
),
))
.toList(),
@ -50,18 +52,22 @@ class PriorityTickets extends StatelessWidget {
}
}
class vTicketItem extends StatelessWidget {
class TicketItem extends StatelessWidget {
final String ticketNo;
final String roomNo;
final CallType callType;
final bool blink;
final double scale;
final bool isClinicAdded;
const vTicketItem({@required this.ticketNo, @required this.roomNo, @required this.callType, this.scale, this.blink = false});
const TicketItem({Key key, @required this.isClinicAdded, @required this.ticketNo, @required this.roomNo, @required this.callType, this.scale, this.blink = false}) : super(key: key);
String getFormattedTicket(String ticketNo) {
var formattedString = ticketNo.split(" ");
return formattedString[0] + " " + formattedString[1];
String getFormattedTicket(String ticketNo, bool isClinicAdded) {
if (isClinicAdded) {
var formattedString = ticketNo.split(" ");
return formattedString[0] + " " + formattedString[1];
}
return ticketNo;
}
@override
@ -71,7 +77,7 @@ class vTicketItem extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
BlinkText(getFormattedTicket(ticketNo),
BlinkText(getFormattedTicket(ticketNo, isClinicAdded),
style: TextStyle(
fontSize: SizeConfig.getWidthMultiplier() * 10,
letterSpacing: -9.32,

@ -17,16 +17,27 @@ class CallByVoice {
Future<dynamic> _getLanguages() async => await textToSpeech.getLanguages;
startCalling() async {
startCalling(bool isClinicNameAdded) async {
String clinicName = "";
String patientAlpha = "";
String patientNumeric = "";
if (isClinicNameAdded) {
var clinic = ticketNo.split(" ");
clinicName = clinic[0];
patientAlpha = clinic[1].split("-")[0];
patientNumeric = clinic[1].split("-")[1];
} else {
patientAlpha = ticketNo.split("-")[0];
patientNumeric = ticketNo.split("-")[1];
}
textToSpeech.setLanguage("en-US");
var clinic = ticketNo.split(" ");
var splitText = clinic[1].split("-");
// Create Pre Voice Players
if (preVoice != null && preVoice.isNotEmpty) {
textToSpeech.setSpeechRate(rate);
textToSpeech.setPitch(pitch);
textToSpeech.setVolume(volume);
await textToSpeech.speak(preVoice + " .. " + clinic[0] + " .. " + splitText[0] + " .. " + splitText[1] + " .. " + postVoice);
await textToSpeech.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
}
// // Create Ticket Number Voice Players

Loading…
Cancel
Save