Merge pull request 'QLine API changes handled' (#223) from haroon_dev into master

Reviewed-on: https://34.17.182.140/Haroon6138/HMG_Patient_App_New/pulls/223
pull/225/head
Haroon6138 2 days ago
commit c5b91a0bb5

@ -1,4 +1,48 @@
class PatientQueueDetails {
Data? patientQueueData;
PatientQueueDetails({this.patientQueueData});
PatientQueueDetails.fromJson(Map<String, dynamic> json) {
patientQueueData = json['data'] != null ? new Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.patientQueueData != null) {
data['data'] = this.patientQueueData!.toJson();
}
return data;
}
}
class Data {
List<PatientInQueueList>? patientInQueueList;
int? isClinicConfigured;
Data({this.patientInQueueList, this.isClinicConfigured});
Data.fromJson(Map<String, dynamic> json) {
if (json['patientInQueueList'] != null) {
patientInQueueList = <PatientInQueueList>[];
json['patientInQueueList'].forEach((v) {
patientInQueueList!.add(new PatientInQueueList.fromJson(v));
});
}
isClinicConfigured = json['isClinicConfigured'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.patientInQueueList != null) {
data['patientInQueueList'] = this.patientInQueueList!.map((v) => v.toJson()).toList();
}
data['isClinicConfigured'] = this.isClinicConfigured;
return data;
}
}
class PatientInQueueList {
int? patientID;
String? patientName;
String? queueNo;
@ -6,18 +50,15 @@ class PatientQueueDetails {
String? roomNo;
String? calledOn;
bool? servingNow;
int? isClinicConfigured;
PatientQueueDetails(
{this.patientID,
PatientInQueueList({this.patientID,
this.patientName,
this.queueNo,
this.callType,
this.roomNo,
this.calledOn,
this.servingNow, this.isClinicConfigured});
this.calledOn, this.servingNow});
PatientQueueDetails.fromJson(Map<String, dynamic> json) {
PatientInQueueList.fromJson(Map<String, dynamic> json) {
patientID = json['patientID'];
patientName = json['patientName'];
queueNo = json['queueNo'];
@ -25,11 +66,10 @@ class PatientQueueDetails {
roomNo = json['roomNo'];
calledOn = json['calledOn'];
servingNow = json['servingNow'];
isClinicConfigured = json['isClinicConfigured'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = Map<String, dynamic>();
final Map<String, dynamic> data = new Map<String, dynamic>();
data['patientID'] = this.patientID;
data['patientName'] = this.patientName;
data['queueNo'] = this.queueNo;
@ -37,7 +77,50 @@ class PatientQueueDetails {
data['roomNo'] = this.roomNo;
data['calledOn'] = this.calledOn;
data['servingNow'] = this.servingNow;
data['isClinicConfigured'] = this.isClinicConfigured;
return data;
}
}
// class PatientQueueDetails {
// int? patientID;
// String? patientName;
// String? queueNo;
// int? callType;
// String? roomNo;
// String? calledOn;
// bool? servingNow;
// int? isClinicConfigured;
//
// PatientQueueDetails(
// {this.patientID,
// this.patientName,
// this.queueNo,
// this.callType,
// this.roomNo,
// this.calledOn,
// this.servingNow, this.isClinicConfigured});
//
// PatientQueueDetails.fromJson(Map<String, dynamic> json) {
// patientID = json['patientID'];
// patientName = json['patientName'];
// queueNo = json['queueNo'];
// callType = json['callType'];
// roomNo = json['roomNo'];
// calledOn = json['calledOn'];
// servingNow = json['servingNow'];
// isClinicConfigured = json['isClinicConfigured'];
// }
//
// Map<String, dynamic> toJson() {
// final Map<String, dynamic> data = Map<String, dynamic>();
// data['patientID'] = this.patientID;
// data['patientName'] = this.patientName;
// data['queueNo'] = this.queueNo;
// data['callType'] = this.callType;
// data['roomNo'] = this.roomNo;
// data['calledOn'] = this.calledOn;
// data['servingNow'] = this.servingNow;
// data['isClinicConfigured'] = this.isClinicConfigured;
// return data;
// }
// }

@ -77,7 +77,7 @@ abstract class MyAppointmentsRepo {
Future<Either<Failure, GenericApiModel<void>>> sendDoctorRate(
int rate, int appointmentNo, int projectID, int doctorID, int clinicID, String note, String appoDate, String docName, String projectName, String clinicName);
Future<Either<Failure, GenericApiModel<List<PatientQueueDetails>>>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID});
Future<Either<Failure, GenericApiModel<PatientQueueDetails>>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID});
Future<Either<Failure, GenericApiModel<dynamic>>> convertPatientToCash({required int projectID});
@ -833,20 +833,23 @@ class MyAppointmentsRepoImp implements MyAppointmentsRepo {
}
@override
Future<Either<Failure, GenericApiModel<List<PatientQueueDetails>>>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID}) async {
Future<Either<Failure, GenericApiModel<PatientQueueDetails>>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID}) async {
Map<String, dynamic> mapDevice = {"appointmentNo": appointmentNo, "patientID": patientID, "clinicID": clinicID, "apiKey": "EE17D21C7943485D9780223CCE55DCE5"};
try {
GenericApiModel<List<PatientQueueDetails>>? apiResponse;
GenericApiModel<PatientQueueDetails>? apiResponse;
Failure? failure;
await apiClient.post(ApiConsts.QLINE_URL, onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
}, onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
// final list = response['data'];
final list = response['data'];
final queueList = list.map((item) => PatientQueueDetails.fromJson(item as Map<String, dynamic>)).toList().cast<PatientQueueDetails>();
final queueData = response;
// final queueList = list.map((item) => PatientQueueDetails.fromJson(item as Map<String, dynamic>)).toList().cast<PatientQueueDetails>();
final queueList = PatientQueueDetails.fromJson(queueData);
apiResponse = GenericApiModel<List<PatientQueueDetails>>(
queueList.patientQueueData!.isClinicConfigured = 1;
apiResponse = GenericApiModel<PatientQueueDetails>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,

@ -55,8 +55,8 @@ class MyAppointmentsViewModel extends ChangeNotifier {
bool isAppointmentQueueDetailsLoading = false;
bool isPatientHasQueueAppointment = false;
int currentQueueStatus = 0;
List<PatientQueueDetails> patientQueueDetailsList = [];
late PatientQueueDetails currentPatientQueueDetails;
List<PatientInQueueList> patientQueueDetailsList = [];
late PatientInQueueList currentPatientQueueDetails;
List<PatientAppointmentHistoryResponseModel> patientAppointmentsHistoryList = [];
List<PatientAppointmentHistoryResponseModel> filteredAppointmentList = [];
@ -314,14 +314,14 @@ class MyAppointmentsViewModel extends ChangeNotifier {
// Build grouped list immediately so the UI has data for the default (By Clinic) view.
_groupAppointmentsByClinicAndHospital();
if (patientArrivedAppointmentsHistoryList.isNotEmpty) {
isPatientHasQueueAppointment = false;
notifyListeners();
if (Utils.isDateToday(DateUtil.convertStringToDate(patientArrivedAppointmentsHistoryList.first.appointmentDate))) {
// getPatientAppointmentQueueDetails(appointmentNo: patientArrivedAppointmentsHistoryList.first.appointmentNo, patientID: patientArrivedAppointmentsHistoryList.first.patientID);
getPatientAppointmentQueueDetails();
}
// if (patientArrivedAppointmentsHistoryList.isNotEmpty) {
isPatientHasQueueAppointment = false;
notifyListeners();
if (Utils.isDateToday(DateUtil.convertStringToDate(patientArrivedAppointmentsHistoryList.first.appointmentDate))) {
// getPatientAppointmentQueueDetails(appointmentNo: patientArrivedAppointmentsHistoryList.first.appointmentNo, patientID: patientArrivedAppointmentsHistoryList.first.patientID);
getPatientAppointmentQueueDetails();
}
// }
debugPrint('Upcoming Appointments: ${patientUpcomingAppointmentsHistoryList.length}');
debugPrint('Arrived Appointments: ${patientArrivedAppointmentsHistoryList.length}');
@ -949,10 +949,12 @@ class MyAppointmentsViewModel extends ChangeNotifier {
if (apiResponse.messageStatus == 2) {
onError!(apiResponse.errorMessage!);
} else if (apiResponse.messageStatus == 1) {
if (apiResponse.data != null && apiResponse.data!.isNotEmpty) {
patientQueueDetailsList = apiResponse.data!;
if (apiResponse.data != null) {
patientQueueDetailsList.clear();
patientQueueDetailsList = apiResponse.data!.patientQueueData!.patientInQueueList!;
if (patientQueueDetailsList.first.isClinicConfigured == 1) {
if (apiResponse.data!.patientQueueData!.isClinicConfigured == 1) {
currentPatientQueueDetails = PatientInQueueList();
isPatientHasQueueAppointment = true;
for (var element in patientQueueDetailsList) {
if (element.patientID == patientArrivedAppointmentsHistoryList.first.patientID) {
@ -965,33 +967,35 @@ class MyAppointmentsViewModel extends ChangeNotifier {
// patientQueueDetailsList.first.callType = 1;
patientQueueDetailsList.removeWhere((element) => element.patientID == patientArrivedAppointmentsHistoryList.first.patientID);
} else {
patientQueueDetailsList.clear();
isPatientHasQueueAppointment = false;
}
} else {
patientQueueDetailsList.clear();
isPatientHasQueueAppointment = false;
}
if (apiResponse.data != null && apiResponse.data!.isNotEmpty) {
patientQueueDetailsList = apiResponse.data!;
// if (patientQueueDetailsList.first.isClinicConfigured == 1) {
isPatientHasQueueAppointment = true;
for (var element in patientQueueDetailsList) {
if (element.patientID == patientArrivedAppointmentsHistoryList.first.patientID) {
currentPatientQueueDetails = element;
currentQueueStatus = element.callType!;
// currentQueueStatus = 2;
break;
}
}
// patientQueueDetailsList.first.callType = 1;
patientQueueDetailsList.removeWhere((element) => element.patientID == patientArrivedAppointmentsHistoryList.first.patientID);
// } else {
// isPatientHasQueueAppointment = false;
// }
} else {
isPatientHasQueueAppointment = false;
}
// if (apiResponse.data != null && apiResponse.data!.isNotEmpty) {
// patientQueueDetailsList = apiResponse.data!;
//
// // if (patientQueueDetailsList.first.isClinicConfigured == 1) {
// isPatientHasQueueAppointment = true;
// for (var element in patientQueueDetailsList) {
// if (element.patientID == patientArrivedAppointmentsHistoryList.first.patientID) {
// currentPatientQueueDetails = element;
// currentQueueStatus = element.callType!;
// // currentQueueStatus = 2;
// break;
// }
// }
// // patientQueueDetailsList.first.callType = 1;
// patientQueueDetailsList.removeWhere((element) => element.patientID == patientArrivedAppointmentsHistoryList.first.patientID);
// // } else {
// // isPatientHasQueueAppointment = false;
// // }
// } else {
// isPatientHasQueueAppointment = false;
// }
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse.data);

@ -67,7 +67,7 @@ class AppointmentQueuePage extends StatelessWidget {
labelText: myAppointmentsVM.currentQueueStatus == 0 ? LocaleKeys.inQueue.tr(context: context) : LocaleKeys.yourTurn.tr(context: context),
backgroundColor: Utils.getCardBorderColor(myAppointmentsVM.currentQueueStatus).withValues(alpha: 0.20),
textColor: Utils.getCardBorderColor(myAppointmentsVM.currentQueueStatus),
),
).toShimmer2(isShow: myAppointmentsVM.patientQueueDetailsList.isEmpty),
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.greyColor,
@ -86,7 +86,9 @@ class AppointmentQueuePage extends StatelessWidget {
.toText12(isBold: true, color: AppColors.textColorLight)
.toShimmer2(isShow: myAppointmentsVM.isAppointmentQueueDetailsLoading),
SizedBox(height: 8.h),
myAppointmentsVM.currentPatientQueueDetails.queueNo!.toText32(isBold: true).toShimmer2(isShow: myAppointmentsVM.isAppointmentQueueDetailsLoading),
(myAppointmentsVM.currentPatientQueueDetails.queueNo ?? "IM-123")
.toText32(isBold: true)
.toShimmer2(isShow: myAppointmentsVM.isAppointmentQueueDetailsLoading || myAppointmentsVM.patientQueueDetailsList.isEmpty),
SizedBox(height: 8.h),
CustomButton(
text: Utils.getCardButtonText(myAppointmentsVM.currentQueueStatus, myAppointmentsVM.currentPatientQueueDetails.roomNo ?? ""),
@ -101,7 +103,7 @@ class AppointmentQueuePage extends StatelessWidget {
height: 40.h,
iconColor: AppColors.whiteColor,
iconSize: 18.h,
).toShimmer2(isShow: myAppointmentsVM.isAppointmentQueueDetailsLoading),
).toShimmer2(isShow: myAppointmentsVM.isAppointmentQueueDetailsLoading || myAppointmentsVM.patientQueueDetailsList.isEmpty),
],
),
),

@ -1031,11 +1031,11 @@ class _LandingPageState extends State<LandingPage> {
color: AppColors.textColorLight,
),
SizedBox(height: 8.h),
currentQueue.queueNo!.toText28(isBold: true),
(currentQueue.queueNo ?? "IM-123").toText28(isBold: true).toShimmer2(isShow: myAppointmentsViewModel.patientQueueDetailsList.isEmpty),
SizedBox(height: 6.h),
_buildServingNowSection(),
SizedBox(height: 5.h),
_buildQueueActionButton(currentStatus, currentQueue.roomNo ?? ""),
_buildQueueActionButton(currentStatus, currentQueue.roomNo ?? "").toShimmer2(isShow: myAppointmentsViewModel.patientQueueDetailsList.isEmpty),
],
),
),
@ -1056,7 +1056,7 @@ class _LandingPageState extends State<LandingPage> {
labelText: currentStatus == 0 ? LocaleKeys.inQueue.tr() : LocaleKeys.yourTurn.tr(),
backgroundColor: Utils.getCardBorderColor(currentStatus).withValues(alpha: 0.20),
textColor: Utils.getCardBorderColor(currentStatus),
),
).toShimmer2(isShow: myAppointmentsViewModel.patientQueueDetailsList.isEmpty),
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.greyColor,

Loading…
Cancel
Save