Pushing after callType Testing

dev_faiz
Faiz Hashmi 3 years ago
parent 3295bbc9e1
commit 7e82746ce3

@ -21,27 +21,27 @@ class API{
}, onFailure: (error, status) => onFailure(error)); }, onFailure: (error, status) => onFailure(error));
} }
static Call_UpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required List<Tickets> tickets, @required Function(List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async{ // static Call_UpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required List<Tickets> tickets, @required Function(List<Tickets>) onSuccess, @required Function(dynamic) onFailure}) async{
if(tickets.isEmpty) { // if(tickets.isEmpty) {
return; // return;
} // }
//
List<Tickets> _ticketsUpdated = []; // List<Tickets> _ticketsUpdated = [];
//
for (var ticket in tickets) { // for (var ticket in tickets) {
final body = { "CallID" : ticket.callNo}; // final body = { "CallID" : ticket.callNo};
await BaseAppClient.post(_call_UpdateNotIsQueueRecordByIDAsync, body: body, onSuccess: (response, status){ // await BaseAppClient.post(_call_UpdateNotIsQueueRecordByIDAsync, body: body, onSuccess: (response, status){
if(status == 200){ // if(status == 200){
ticket.call_updated = true; // ticket.call_updated = true;
_ticketsUpdated.add(ticket); // _ticketsUpdated.add(ticket);
} // }
}, onFailure: (error, status) => onFailure(error)); // }, onFailure: (error, status) => onFailure(error));
} // }
//
if(_ticketsUpdated.isNotEmpty) { // if(_ticketsUpdated.isNotEmpty) {
onSuccess(_ticketsUpdated); // onSuccess(_ticketsUpdated);
}else{ // }else{
onFailure(false); // onFailure(false);
} // }
} // }
} }

@ -32,7 +32,7 @@ class BaseAppClient {
if (statusCode < 200 || statusCode >= 400) { if (statusCode < 200 || statusCode >= 400) {
onFailure(Utils.generateContactAdminMsg(), statusCode); onFailure(Utils.generateContactAdminMsg(), statusCode);
} else { } else {
print(response.body.toString()); print("Response: ${response.body.toString()}");
var parsed = json.decode(response.body.toString()); var parsed = json.decode(response.body.toString());
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} }
@ -57,8 +57,8 @@ class BaseAppClient {
try { try {
// String token = await sharedPref.getString(TOKEN); // String token = await sharedPref.getString(TOKEN);
print("URL : $url"); print("URL GET: $url");
print("Body : ${json.encode(body)}"); print("Body GET: ${json.encode(body)}");
var asd = json.encode(body); var asd = json.encode(body);
var asd2; var asd2;
if (await Utils.checkConnection()) { if (await Utils.checkConnection()) {

@ -1,6 +1,4 @@
import 'dart:convert';
import 'package:queuing_system/utils/call_type.dart'; import 'package:queuing_system/utils/call_type.dart';
class Tickets { class Tickets {
@ -15,12 +13,13 @@ class Tickets {
this.mobileNo, this.mobileNo,
this.patientGender, this.patientGender,
this.patientID, this.patientID,
this.queueNo,}); this.queueNo,
});
Tickets.fromJson(dynamic json) { Tickets.fromJson(dynamic json) {
callNo = json['CallNo']; callNo = json['CallNo'];
roomNo = json['RoomNo']; roomNo = json['RoomNo'];
callType = json['CallType']; callType = json['callType'];
createdON = json['CreatedON']; createdON = json['CreatedON'];
doctorName = json['DoctorName']; doctorName = json['DoctorName'];
doctorNameN = json['DoctorNameN']; doctorNameN = json['DoctorNameN'];
@ -48,7 +47,7 @@ class Tickets {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['CallNo'] = callNo; map['CallNo'] = callNo;
map['RoomNo'] = roomNo; map['RoomNo'] = roomNo;
map['CallType'] = callType; map['callType'] = callType;
map['CreatedON'] = createdON; map['CreatedON'] = createdON;
map['DoctorName'] = doctorName; map['DoctorName'] = doctorName;
map['DoctorNameN'] = doctorNameN; map['DoctorNameN'] = doctorNameN;
@ -65,11 +64,10 @@ class Tickets {
return (callNo).toString(); return (callNo).toString();
} }
CallType getCallType(){ CallType getCallType() {
if(callType == 0) return CallType.RECEPTION; if (callType == 0) return CallType.RECEPTION;
if(callType == 1) return CallType.NURSE; if (callType == 1) return CallType.NURSE;
if(callType == 2) return CallType.DOCTOR; if (callType == 2) return CallType.DOCTOR;
return CallType.NONE; return CallType.NONE;
} }
}
}

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:connectivity/connectivity.dart'; import 'package:connectivity/connectivity.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:queuing_system/core/api.dart'; import 'package:queuing_system/core/api.dart';
@ -12,7 +14,7 @@ import 'package:queuing_system/utils/signalR_utils.dart';
import 'package:queuing_system/utils/utils.dart'; import 'package:queuing_system/utils/utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
var DEVICE_IP = "10.20.20.19"; // Testing IP var DEVICE_IP = "10.10.14.11"; // Testing IP
// var DEVICE_IP = "10.70.249.21"; // (Make sure by Haroon before use it) Production IP // var DEVICE_IP = "10.70.249.21"; // (Make sure by Haroon before use it) Production IP
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
@ -55,7 +57,6 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
appBar: AppHeader(), appBar: AppHeader(),
body: content(), body: content(),
@ -124,12 +125,12 @@ class _MyHomePageState extends State<MyHomePage> {
currents = currentInClinic; currents = currentInClinic;
}); });
print("\n\n"); log("\n\n");
print("--------------------"); log("--------------------");
print("Current: $currentInClinic"); log("Current: $currentInClinic");
print("Waiting: $waitingCalls"); log("Waiting: $waitingCalls");
print("--------------------"); log("--------------------");
print("\n\n"); log("\n\n");
updateTickets(); updateTickets();
@ -150,15 +151,15 @@ class _MyHomePageState extends State<MyHomePage> {
onConnect(){ onConnect(){
print("SignalR: onConnect"); log("SignalR: onConnect");
} }
onDisconnect(exception){ onDisconnect(exception){
print("SignalR: onDisconnect"); log("SignalR: onDisconnect");
} }
onConnecting(){ onConnecting(){
print("SignalR: onConnecting"); log("SignalR: onConnecting");
} }
listenNetworkConnectivity() async{ listenNetworkConnectivity() async{

@ -1,205 +1,205 @@
import 'dart:async'; // import 'dart:async';
import 'package:flutter/material.dart'; // import 'package:flutter/material.dart';
import 'package:queuing_system/core/api.dart'; // import 'package:queuing_system/core/api.dart';
import 'package:queuing_system/core/base/app_scaffold_widget.dart'; // import 'package:queuing_system/core/base/app_scaffold_widget.dart';
import 'package:queuing_system/core/base/base_app_client.dart'; // import 'package:queuing_system/core/base/base_app_client.dart';
import 'package:queuing_system/core/config/config.dart'; // import 'package:queuing_system/core/config/config.dart';
import 'package:queuing_system/core/config/size_config.dart'; // import 'package:queuing_system/core/config/size_config.dart';
import 'package:queuing_system/header/app_header.dart'; // import 'package:queuing_system/header/app_header.dart';
import 'package:queuing_system/home/que_item_list.dart'; // import 'package:queuing_system/home/que_item_list.dart';
import 'package:queuing_system/utils/signalR_utils.dart'; // import 'package:queuing_system/utils/signalR_utils.dart';
import 'package:queuing_system/utils/utils.dart'; // import 'package:queuing_system/utils/utils.dart';
import 'package:queuing_system/widget/data_display/app_texts_widget.dart'; // import 'package:queuing_system/widget/data_display/app_texts_widget.dart';
import 'first_column.dart'; // import 'first_column.dart';
//
//
var DEVICE_IP = "10.70.249.21"; // var DEVICE_IP = "10.70.249.21";
//
class MyHomePage extends StatefulWidget { // class MyHomePage extends StatefulWidget {
String title = "MyHomePage"; // String title = "MyHomePage";
bool have0Patient = true; // bool have0Patient = true;
bool have1Patient = false; // bool have1Patient = false;
bool have2Patient = false; // bool have2Patient = false;
bool have3Patient = false; // bool have3Patient = false;
bool haveListOfPatient = false; // bool haveListOfPatient = false;
//
@override // @override
State<MyHomePage> createState() => _MyHomePageState(); // State<MyHomePage> createState() => _MyHomePageState();
} // }
//
class _MyHomePageState extends State<MyHomePage> { // class _MyHomePageState extends State<MyHomePage> {
Timer _timer; // Timer _timer;
int remainingTime = 30; // int remainingTime = 30;
//
@override // @override
void dispose() { // void dispose() {
_timer.cancel(); // _timer.cancel();
super.dispose(); // super.dispose();
} // }
//
startTimer() { // startTimer() {
Timer.periodic(const Duration(seconds: 1), (timer) { // Timer.periodic(const Duration(seconds: 1), (timer) {
if (remainingTime == 0) { // if (remainingTime == 0) {
setState(() { // setState(() {
remainingTime = 30; // remainingTime = 30;
}); // });
} else { // } else {
setState(() { // setState(() {
remainingTime--; // remainingTime--;
if (remainingTime > 25) { // if (remainingTime > 25) {
//
/// for 0 patinet // /// for 0 patinet
widget.have0Patient = true; // widget.have0Patient = true;
widget.have1Patient = false; // widget.have1Patient = false;
widget.have2Patient = false; // widget.have2Patient = false;
widget.have3Patient = false; // widget.have3Patient = false;
widget.haveListOfPatient = false; // widget.haveListOfPatient = false;
} else if (remainingTime > 20) { // } else if (remainingTime > 20) {
/// for 1 patinet // /// for 1 patinet
//
widget.have0Patient = false; // widget.have0Patient = false;
widget.have1Patient = true; // widget.have1Patient = true;
widget.have2Patient = false; // widget.have2Patient = false;
widget.have3Patient = false; // widget.have3Patient = false;
widget.haveListOfPatient = false; // widget.haveListOfPatient = false;
} else if (remainingTime > 15) { // } else if (remainingTime > 15) {
//
/// for 2 patinet // /// for 2 patinet
//
widget.have0Patient = false; // widget.have0Patient = false;
widget.have1Patient = false; // widget.have1Patient = false;
widget.have2Patient = true; // widget.have2Patient = true;
widget.have3Patient = false; // widget.have3Patient = false;
widget.haveListOfPatient = false; // widget.haveListOfPatient = false;
} else if (remainingTime > 10) { // } else if (remainingTime > 10) {
/// for 3 only patinet // /// for 3 only patinet
widget.have0Patient = false; // widget.have0Patient = false;
widget.have1Patient = false; // widget.have1Patient = false;
widget.have2Patient = false; // widget.have2Patient = false;
widget.have3Patient = true; // widget.have3Patient = true;
widget.haveListOfPatient = false; // widget.haveListOfPatient = false;
} else { // } else {
/// for 3+ only patinet // /// for 3+ only patinet
//
widget.have0Patient = false; // widget.have0Patient = false;
widget.have1Patient = false; // widget.have1Patient = false;
widget.have2Patient = false; // widget.have2Patient = false;
widget.have3Patient = true; // widget.have3Patient = true;
widget.haveListOfPatient = true; // widget.haveListOfPatient = true;
} // }
}); // });
} // }
}); // });
} // }
//
@override // @override
void initState() { // void initState() {
startTimer(); // startTimer();
// Get Ticket Info // // Get Ticket Info
// http://10.200.204.11:2222/Services/Nurses.svc/REST/GetCallRequestInfoByClinincInfo // // http://10.200.204.11:2222/Services/Nurses.svc/REST/GetCallRequestInfoByClinincInfo
//
SignalRHelper signalRHelper = SignalRHelper(); // SignalRHelper signalRHelper = SignalRHelper();
if (!signalRHelper.getConnectionState()) { // if (!signalRHelper.getConnectionState()) {
signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable); // signalRHelper.startSignalRConnection(DEVICE_IP, onUpdateAvailable: onUpdateAvailable);
} // }
super.initState(); // super.initState();
} // }
//
@override // @override
Widget build(BuildContext context) { // Widget build(BuildContext context) {
//
//
return AppScaffold( // return AppScaffold(
appBar: AppHeader(), // appBar: AppHeader(),
body: Column( // body: Column(
children: [ // children: [
SizedBox( // SizedBox(
height: SizeConfig.getHeightMultiplier() * // height: SizeConfig.getHeightMultiplier() *
(widget.haveListOfPatient // (widget.haveListOfPatient
? 2 // ? 2
: widget.have1Patient || widget.have0Patient // : widget.have1Patient || widget.have0Patient
? 20 // ? 20
: 10)), // : 10)),
widget.have0Patient // widget.have0Patient
? Column( // ? Column(
mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
children: [ // children: [
Center( // Center(
child: AppText("Awaiting Patients Arrival", // child: AppText("Awaiting Patients Arrival",
fontFamily: 'Poppins-SemiBold.ttf', // fontFamily: 'Poppins-SemiBold.ttf',
fontSize: SizeConfig.getWidthMultiplier() * 9), // fontSize: SizeConfig.getWidthMultiplier() * 9),
), // ),
], // ],
) // )
: widget.haveListOfPatient // : widget.haveListOfPatient
? Row( // ? Row(
children: [ // children: [
FirstColumn( // FirstColumn(
have3Patient: widget.have3Patient, // have3Patient: widget.have3Patient,
have2Patient: widget.have2Patient, // have2Patient: widget.have2Patient,
), // ),
const SizedBox( // const SizedBox(
width: 40, // width: 40,
), // ),
if (widget.haveListOfPatient) // if (widget.haveListOfPatient)
Container( // Container(
width: 10, // width: 10,
height: SizeConfig.getHeightMultiplier() * 40, // height: SizeConfig.getHeightMultiplier() * 40,
color: AppGlobal.appLightGreyColor, // color: AppGlobal.appLightGreyColor,
), // ),
if (widget.haveListOfPatient) // if (widget.haveListOfPatient)
const SizedBox( // const SizedBox(
width: 40, // width: 40,
), // ),
if (widget.haveListOfPatient) const QueItemList() // if (widget.haveListOfPatient) const QueItemList()
], // ],
) // )
: FirstColumn( // : FirstColumn(
have3Patient: widget.have3Patient, // have3Patient: widget.have3Patient,
have2Patient: widget.have2Patient, // have2Patient: widget.have2Patient,
), // ),
], // ],
), // ),
bottomSheet: Container( // bottomSheet: Container(
color: Colors.transparent, // color: Colors.transparent,
height: Utils.getHeight(), // height: Utils.getHeight(),
width: double.infinity, // width: double.infinity,
child: Row( // child: Row(
children: [ // children: [
Padding( // Padding(
padding: const EdgeInsets.only(top: 30, left: 30), // padding: const EdgeInsets.only(top: 30, left: 30),
child: AppText( // child: AppText(
"Powered By", // "Powered By",
fontSize: SizeConfig.getWidthMultiplier() * 2.6, // fontSize: SizeConfig.getWidthMultiplier() * 2.6,
fontFamily: 'Poppins-Medium.ttf', // fontFamily: 'Poppins-Medium.ttf',
), // ),
), // ),
Padding( // Padding(
padding: const EdgeInsets.only(top: 40, left: 18), // padding: const EdgeInsets.only(top: 40, left: 18),
child: Image.asset( // child: Image.asset(
"assets/images/cloud_logo.png", // "assets/images/cloud_logo.png",
height: SizeConfig.getHeightMultiplier() * 6, // height: SizeConfig.getHeightMultiplier() * 6,
), // ),
), // ),
], // ],
), // ),
), // This trailing comma makes auto-formatting nicer for build methods. // ), // This trailing comma makes auto-formatting nicer for build methods.
); // );
} // }
//
//
onUpdateAvailable(data) async{ // onUpdateAvailable(data) async{
API.GetCallRequestInfoByClinincInfo( // API.GetCallRequestInfoByClinincInfo(
DEVICE_IP, // DEVICE_IP,
onSuccess: (waitingCalls, currentInClinic){ // onSuccess: (waitingCalls, currentInClinic){
print("\n\n"); // print("\n\n");
print("--------------------"); // print("--------------------");
print("Current: $currentInClinic"); // print("Current: $currentInClinic");
print("Waiting: $waitingCalls"); // print("Waiting: $waitingCalls");
print("--------------------"); // print("--------------------");
print("\n\n"); // print("\n\n");
}, onFailure: (error){ // }, onFailure: (error){
//
}); // });
} // }
} // }

Loading…
Cancel
Save