diff --git a/lib/features/my_appointments/models/resp_models/patient_queue_details_response_model.dart b/lib/features/my_appointments/models/resp_models/patient_queue_details_response_model.dart index 8ad174ff..828bcf0f 100644 --- a/lib/features/my_appointments/models/resp_models/patient_queue_details_response_model.dart +++ b/lib/features/my_appointments/models/resp_models/patient_queue_details_response_model.dart @@ -1,4 +1,48 @@ class PatientQueueDetails { + Data? patientQueueData; + + PatientQueueDetails({this.patientQueueData}); + + PatientQueueDetails.fromJson(Map json) { + patientQueueData = json['data'] != null ? new Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.patientQueueData != null) { + data['data'] = this.patientQueueData!.toJson(); + } + return data; + } +} + +class Data { + List? patientInQueueList; + int? isClinicConfigured; + + Data({this.patientInQueueList, this.isClinicConfigured}); + + Data.fromJson(Map json) { + if (json['patientInQueueList'] != null) { + patientInQueueList = []; + json['patientInQueueList'].forEach((v) { + patientInQueueList!.add(new PatientInQueueList.fromJson(v)); + }); + } + isClinicConfigured = json['isClinicConfigured']; + } + + Map toJson() { + final Map data = new Map(); + 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 json) { + PatientInQueueList.fromJson(Map 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 toJson() { - final Map data = Map(); + final Map data = new Map(); 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 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 toJson() { +// final Map data = Map(); +// 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; +// } +// } diff --git a/lib/features/my_appointments/my_appointments_repo.dart b/lib/features/my_appointments/my_appointments_repo.dart index 7344bc22..d4669767 100644 --- a/lib/features/my_appointments/my_appointments_repo.dart +++ b/lib/features/my_appointments/my_appointments_repo.dart @@ -77,7 +77,7 @@ abstract class MyAppointmentsRepo { Future>> sendDoctorRate( int rate, int appointmentNo, int projectID, int doctorID, int clinicID, String note, String appoDate, String docName, String projectName, String clinicName); - Future>>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID}); + Future>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID}); Future>> convertPatientToCash({required int projectID}); @@ -833,20 +833,23 @@ class MyAppointmentsRepoImp implements MyAppointmentsRepo { } @override - Future>>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID}) async { + Future>> getPatientAppointmentQueueDetails({required int appointmentNo, required int patientID, required int clinicID}) async { Map mapDevice = {"appointmentNo": appointmentNo, "patientID": patientID, "clinicID": clinicID, "apiKey": "EE17D21C7943485D9780223CCE55DCE5"}; try { - GenericApiModel>? apiResponse; + GenericApiModel? 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)).toList().cast(); + final queueData = response; + // final queueList = list.map((item) => PatientQueueDetails.fromJson(item as Map)).toList().cast(); + final queueList = PatientQueueDetails.fromJson(queueData); - apiResponse = GenericApiModel>( + queueList.patientQueueData!.isClinicConfigured = 1; + + apiResponse = GenericApiModel( messageStatus: messageStatus, statusCode: statusCode, errorMessage: null, diff --git a/lib/features/my_appointments/my_appointments_view_model.dart b/lib/features/my_appointments/my_appointments_view_model.dart index a6f306ba..1b49b0ca 100644 --- a/lib/features/my_appointments/my_appointments_view_model.dart +++ b/lib/features/my_appointments/my_appointments_view_model.dart @@ -55,8 +55,8 @@ class MyAppointmentsViewModel extends ChangeNotifier { bool isAppointmentQueueDetailsLoading = false; bool isPatientHasQueueAppointment = false; int currentQueueStatus = 0; - List patientQueueDetailsList = []; - late PatientQueueDetails currentPatientQueueDetails; + List patientQueueDetailsList = []; + late PatientInQueueList currentPatientQueueDetails; List patientAppointmentsHistoryList = []; List 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); diff --git a/lib/presentation/appointments/appointment_queue_page.dart b/lib/presentation/appointments/appointment_queue_page.dart index 35403dc6..59522149 100644 --- a/lib/presentation/appointments/appointment_queue_page.dart +++ b/lib/presentation/appointments/appointment_queue_page.dart @@ -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), ], ), ), diff --git a/lib/presentation/home/landing_page.dart b/lib/presentation/home/landing_page.dart index 1c4a6b63..e61b6226 100644 --- a/lib/presentation/home/landing_page.dart +++ b/lib/presentation/home/landing_page.dart @@ -1017,11 +1017,11 @@ class _LandingPageState extends State { 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), ], ), ), @@ -1042,7 +1042,7 @@ class _LandingPageState extends State { 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,