CMC APIs coverting to RC

merge-requests/438/head
haroon amjad 4 years ago
parent 6902e6529c
commit e62e3dae1b

@ -438,6 +438,11 @@ const PHARMACY_MAKE_REVIEW = 'epharmacy/api/insertreviews';
const BLOOD_DONATION_REGISTER_BLOOD_TYPE = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType'; const BLOOD_DONATION_REGISTER_BLOOD_TYPE = 'Services/PatientVarification.svc/REST/BloodDonation_RegisterBloodType';
const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation'; const ADD_USER_AGREEMENT_FOR_BLOOD_DONATION = 'Services/PatientVarification.svc/REST/AddUserAgreementForBloodDonation';
// CMC RC SERVICES
const GET_ALL_CMC_SERVICES_RC = 'rc/api/cmc/getallcmc';
const ADD_CMC_ORDER_RC = 'rc/api/cmc/add';
//Pharmacy wishlist //Pharmacy wishlist
const GET_WISHLIST = "shopping_cart_items/"; const GET_WISHLIST = "shopping_cart_items/";
const DELETE_WISHLIST = "delete_shopping_cart_item_by_product?customer_id="; const DELETE_WISHLIST = "delete_shopping_cart_item_by_product?customer_id=";

@ -73,20 +73,21 @@ class CMCInsertPresOrderRequestModel {
data['LanguageID'] = this.languageID; data['LanguageID'] = this.languageID;
data['IPAdress'] = this.iPAdress; data['IPAdress'] = this.iPAdress;
data['generalid'] = this.generalid; data['generalid'] = this.generalid;
data['PatientOutSA'] = this.patientOutSA; data['patientOutSa'] = this.patientOutSA;
data['isOutPatient'] = this.patientOutSA == 0 ? false : true;
data['SessionID'] = this.sessionID; data['SessionID'] = this.sessionID;
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
data['DeviceTypeID'] = this.deviceTypeID; data['DeviceTypeID'] = this.deviceTypeID;
data['PatientID'] = this.patientID; data['patientId'] = this.patientID.toString();
data['TokenID'] = this.tokenID; data['TokenID'] = this.tokenID;
data['PatientTypeID'] = this.patientTypeID; data['PatientTypeID'] = this.patientTypeID;
data['PatientType'] = this.patientType; data['PatientType'] = this.patientType;
data['Latitude'] = this.latitude; data['latitude'] = this.latitude;
data['Longitude'] = this.longitude; data['longitude'] = this.longitude;
data['CreatedBy'] = this.createdBy; // data['CreatedBy'] = this.createdBy;
data['OrderServiceID'] = this.orderServiceID; data['OrderServiceID'] = this.orderServiceID;
if (this.patientERCMCInsertServicesList != null) { if (this.patientERCMCInsertServicesList != null) {
data['PatientER_CMC_InsertServicesList'] = data['procedures'] =
this.patientERCMCInsertServicesList.map((v) => v.toJson()).toList(); this.patientERCMCInsertServicesList.map((v) => v.toJson()).toList();
} }
return data; return data;

@ -1,44 +1,56 @@
class GetCMCServicesResponseModel { class GetCMCServicesResponseModel {
String description; int id;
String descriptionN; String serviceID;
int iD; int orderServiceID;
bool isActive; String text;
String textN;
dynamic price; dynamic price;
int serviceID; dynamic priceVAT;
dynamic totalPrice; dynamic priceTotal;
dynamic vAT; bool isEnabled;
int orderId;
int quantity;
GetCMCServicesResponseModel( GetCMCServicesResponseModel(
{this.description, {this.id,
this.descriptionN,
this.iD,
this.isActive,
this.price,
this.serviceID, this.serviceID,
this.totalPrice, this.orderServiceID,
this.vAT}); this.text,
this.textN,
this.price,
this.priceVAT,
this.priceTotal,
this.isEnabled,
this.orderId,
this.quantity});
GetCMCServicesResponseModel.fromJson(Map<String, dynamic> json) { GetCMCServicesResponseModel.fromJson(Map<String, dynamic> json) {
description = json['Description']; id = json['id'];
descriptionN = json['DescriptionN']; serviceID = json['serviceID'];
iD = json['ID']; orderServiceID = json['orderServiceID'];
isActive = json['IsActive']; text = json['text'];
price = json['Price']; textN = json['textN'];
serviceID = json['ServiceID']; price = json['price'];
totalPrice = json['TotalPrice']; priceVAT = json['priceVAT'];
vAT = json['VAT']; priceTotal = json['priceTotal'];
isEnabled = json['isEnabled'];
orderId = json['orderId'];
quantity = json['quantity'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['Description'] = this.description; data['id'] = this.id;
data['DescriptionN'] = this.descriptionN; data['serviceID'] = this.serviceID;
data['ID'] = this.iD; data['orderServiceID'] = this.orderServiceID;
data['IsActive'] = this.isActive; data['text'] = this.text;
data['Price'] = this.price; data['textN'] = this.textN;
data['ServiceID'] = this.serviceID; data['price'] = this.price;
data['TotalPrice'] = this.totalPrice; data['priceVAT'] = this.priceVAT;
data['VAT'] = this.vAT; data['priceTotal'] = this.priceTotal;
data['isEnabled'] = this.isEnabled;
data['orderId'] = this.orderId;
data['quantity'] = this.quantity;
return data; return data;
} }
} }

@ -23,17 +23,30 @@ class CMCService extends BaseService {
bool isOrderUpdated; bool isOrderUpdated;
Future getCMCAllServices() async { Future getCMCAllServices() async {
GetCMCServicesRequestModel getCMCServicesRequestModel = new GetCMCServicesRequestModel(genderID: authenticatedUserObject.user.gender, identificationNo: authenticatedUserObject.user.patientIdentificationNo); GetCMCServicesRequestModel getCMCServicesRequestModel =
new GetCMCServicesRequestModel(genderID: authenticatedUserObject.user.gender, identificationNo: authenticatedUserObject.user.patientIdentificationNo);
hasError = false; hasError = false;
await baseAppClient.post(HHC_GET_ALL_CMC_SERVICES, onSuccess: (dynamic response, int statusCode) {
// RC IMPLEMENTATION
await baseAppClient.post(GET_ALL_CMC_SERVICES_RC + "?patientID=" + user.patientID.toString(), isAllowAny: true, onSuccess: (dynamic response, int statusCode) {
cmcAllServicesList.clear(); cmcAllServicesList.clear();
response['PatientER_CMC_GetAllServicesList'].forEach((data) { response.forEach((data) {
cmcAllServicesList.add(GetCMCServicesResponseModel.fromJson(data)); cmcAllServicesList.add(GetCMCServicesResponseModel.fromJson(data));
}); });
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: getCMCServicesRequestModel.toJson()); }, body: {});
// await baseAppClient.post(HHC_GET_ALL_CMC_SERVICES, onSuccess: (dynamic response, int statusCode) {
// cmcAllServicesList.clear();
// response['PatientER_CMC_GetAllServicesList'].forEach((data) {
// cmcAllServicesList.add(GetCMCServicesResponseModel.fromJson(data));
// });
// }, onFailure: (String error, int statusCode) {
// hasError = true;
// super.error = error;
// }, body: getCMCServicesRequestModel.toJson());
} }
Future getCmcAllPresOrders() async { Future getCmcAllPresOrders() async {
@ -87,12 +100,25 @@ class CMCService extends BaseService {
}, body: updatePresOrderRequestModel.toJson()); }, body: updatePresOrderRequestModel.toJson());
} }
Future<String> insertCMCOrderRC({CMCInsertPresOrderRequestModel order}) async {
hasError = false;
String reqId = "";
await baseAppClient.post(ADD_CMC_ORDER_RC, onSuccess: (dynamic response, int statusCode) {
isOrderUpdated = true;
reqId = response['RequestNo'].toString();
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: order.toJson());
return reqId;
}
Future<String> insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { Future<String> insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async {
hasError = false; hasError = false;
String reqId=""; String reqId = "";
await baseAppClient.post(PATIENT_ER_INSERT_PRES_ORDER, onSuccess: (dynamic response, int statusCode) { await baseAppClient.post(PATIENT_ER_INSERT_PRES_ORDER, onSuccess: (dynamic response, int statusCode) {
isOrderUpdated = true; isOrderUpdated = true;
reqId=response['RequestNo'].toString(); reqId = response['RequestNo'].toString();
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;

@ -126,60 +126,65 @@ class BaseAppClient {
} else { } else {
var decoded = utf8.decode(response.bodyBytes); var decoded = utf8.decode(response.bodyBytes);
var parsed = json.decode(utf8.decode(response.bodyBytes)); var parsed = json.decode(utf8.decode(response.bodyBytes));
if (parsed['Response_Message'] != null) {
if (isAllowAny) {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
if (parsed['ErrorType'] == 4) { if (parsed['Response_Message'] != null) {
navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']);
}
if (parsed['ErrorType'] == 2) {
await logout();
}
if (isAllowAny) {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else if (parsed['IsAuthenticated'] == null) { } else {
if (parsed['isSMSSent'] == true) { if (parsed['ErrorType'] == 4) {
onSuccess(parsed, statusCode); navigateToAppUpdate(AppGlobal.context, parsed['ErrorEndUserMessage']);
} else if (parsed['MessageStatus'] == 1) { }
onSuccess(parsed, statusCode); if (parsed['ErrorType'] == 2) {
} else if (parsed['Result'] == 'OK') { await logout();
}
if (isAllowAny) {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else if (parsed['IsAuthenticated'] == null) {
if (parsed != null) { if (parsed['isSMSSent'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 1) {
onSuccess(parsed, statusCode);
} else if (parsed['Result'] == 'OK') {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else {
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); if (parsed != null) {
logout(); onSuccess(parsed, statusCode);
} else {
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
logout();
}
} }
} } else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) {
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) {
onSuccess(parsed, statusCode);
} else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) {
if (parsed['SameClinicApptList'] != null) {
onSuccess(parsed, statusCode); onSuccess(parsed, statusCode);
} else { } else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { if (parsed['SameClinicApptList'] != null) {
if (parsed['ErrorSearchMsg'] == null) { onSuccess(parsed, statusCode);
onFailure("Server Error found with no available message", statusCode); } else {
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) {
if (parsed['ErrorSearchMsg'] == null) {
onFailure("Server Error found with no available message", statusCode);
} else {
onFailure(parsed['ErrorSearchMsg'], statusCode);
}
} else { } else {
onFailure(parsed['ErrorSearchMsg'], statusCode); onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
} }
} else {
onFailure(parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
} }
} }
} // else if (!parsed['IsAuthenticated']) {
// else if (!parsed['IsAuthenticated']) { // await logout();
// await logout(); // }
// } else {
else { if (parsed['SameClinicApptList'] != null) {
if (parsed['SameClinicApptList'] != null) { onSuccess(parsed, statusCode);
onSuccess(parsed, statusCode);
} else {
if (parsed['message'] != null) {
onFailure(parsed['message'] ?? parsed['message'], statusCode);
} else { } else {
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode); if (parsed['message'] != null) {
onFailure(parsed['message'] ?? parsed['message'], statusCode);
} else {
onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
}
} }
} }
} }

@ -38,9 +38,6 @@ class CMCViewModel extends BaseViewModel {
Future getCMCAllServices() async { Future getCMCAllServices() async {
await _cMCService.getCMCAllServices(); await _cMCService.getCMCAllServices();
CMCGetItemsRequestModel cMCGetItemsRequestModel = new CMCGetItemsRequestModel(checkupType: cmcAllServicesList[0].iD);
await getCheckupItems(cMCGetItemsRequestModel: cMCGetItemsRequestModel, isFirst: true);
if (_cMCService.hasError) { if (_cMCService.hasError) {
error = _cMCService.error; error = _cMCService.error;
setState(ViewState.Error); setState(ViewState.Error);
@ -92,7 +89,6 @@ class CMCViewModel extends BaseViewModel {
await _cMCService.getOrderDetailByOrderID(getOrderDetailByOrderIDRequestModel); await _cMCService.getOrderDetailByOrderID(getOrderDetailByOrderIDRequestModel);
} }
//TODO check it in uat
Future<String> insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async { Future<String> insertPresPresOrder({CMCInsertPresOrderRequestModel order}) async {
setState(ViewState.Busy); setState(ViewState.Busy);
order.createdBy = user.patientID; order.createdBy = user.patientID;
@ -104,7 +100,20 @@ class CMCViewModel extends BaseViewModel {
} else { } else {
getCmcAllPresOrders(); getCmcAllPresOrders();
} }
return requestId;
}
Future<String> insertCMCOrderRC({CMCInsertPresOrderRequestModel order}) async {
setState(ViewState.Busy);
order.createdBy = user.patientID;
order.orderServiceID = OrderService.Comprehensive_Medical_Checkup.getIdOrderService();
String requestId = await _cMCService.insertCMCOrderRC(order: order);
if (_cMCService.hasError) {
error = _cMCService.error;
setState(ViewState.ErrorLocal);
} else {
getCmcAllPresOrders();
}
return requestId; return requestId;
} }

@ -46,11 +46,11 @@ class _NewCMCPageState extends State<NewCMCPage> with TickerProviderStateMixin {
patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( patientERCMCInsertServicesList = new PatientERCMCInsertServicesList(
price: widget.model.cmcAllServicesList[0].price, price: widget.model.cmcAllServicesList[0].price,
serviceID: widget.model.cmcAllServicesList[0].serviceID.toString(), serviceID: widget.model.cmcAllServicesList[0].serviceID.toString(),
selectedServiceName: widget.model.cmcAllServicesList[0].description, selectedServiceName: widget.model.cmcAllServicesList[0].text,
selectedServiceNameAR: widget.model.cmcAllServicesList[0].descriptionN, selectedServiceNameAR: widget.model.cmcAllServicesList[0].textN,
recordID: 1, recordID: 1,
totalPrice: widget.model.cmcAllServicesList[0].totalPrice, totalPrice: widget.model.cmcAllServicesList[0].priceTotal,
vAT: widget.model.cmcAllServicesList[0].vAT); vAT: widget.model.cmcAllServicesList[0].priceVAT);
cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel(patientERCMCInsertServicesList: [patientERCMCInsertServicesList]); cMCInsertPresOrderRequestModel = new CMCInsertPresOrderRequestModel(patientERCMCInsertServicesList: [patientERCMCInsertServicesList]);
} }

@ -63,18 +63,18 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
return Row( return Row(
children: [ children: [
Radio( Radio(
value: widget.model.cmcAllServicesList[index].serviceID, value: num.tryParse(widget.model.cmcAllServicesList[index].serviceID),
activeColor: Colors.red[800], activeColor: Colors.red[800],
onChanged: (newValue) async { onChanged: (newValue) async {
selectedItem = index; selectedItem = index;
PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList(
price: widget.model.cmcAllServicesList[index].price, price: widget.model.cmcAllServicesList[index].price,
serviceID: widget.model.cmcAllServicesList[index].serviceID.toString(), serviceID: widget.model.cmcAllServicesList[index].serviceID,
selectedServiceName: widget.model.cmcAllServicesList[index].description, selectedServiceName: widget.model.cmcAllServicesList[index].text,
selectedServiceNameAR: widget.model.cmcAllServicesList[index].descriptionN, selectedServiceNameAR: widget.model.cmcAllServicesList[index].textN,
recordID: 1, recordID: 1,
totalPrice: widget.model.cmcAllServicesList[index].totalPrice, totalPrice: widget.model.cmcAllServicesList[index].priceTotal,
vAT: widget.model.cmcAllServicesList[index].vAT); vAT: widget.model.cmcAllServicesList[index].priceVAT);
setState(() { setState(() {
widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList];
}); });
@ -93,7 +93,7 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
bottom: 20, bottom: 20,
), ),
child: Text( child: Text(
projectViewModel.isArabic ? widget.model.cmcAllServicesList[index].descriptionN : widget.model.cmcAllServicesList[index].description, projectViewModel.isArabic ? widget.model.cmcAllServicesList[index].textN : widget.model.cmcAllServicesList[index].text,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -135,50 +135,6 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
), ),
], ],
), ),
// Card(
// shape: cardRadius(12),
// elevation: 4,
// child: Container(
// width: double.infinity,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Padding(
// padding: const EdgeInsets.only(left: 12, right: 12, top: 12),
// child: Text(
// TranslationBase.of(context).coveredService,
// style: TextStyle(
// fontSize: 14,
// fontWeight: FontWeight.w600,
// letterSpacing: -0.45,
// ),
// ),
// ),
// ListView.separated(
// itemBuilder: (context, index) {
// return Padding(
// padding: const EdgeInsets.all(12.0),
// child: Text(
// widget.model.checkupItems[index].itemName,
// style: TextStyle(
// fontSize: 12,
// fontWeight: FontWeight.w600,
// letterSpacing: -0.45,
// ),
// ),
// );
// },
// separatorBuilder: (context, index) {
// return mDivider(Colors.grey);
// },
// physics: NeverScrollableScrollPhysics(),
// shrinkWrap: true,
// itemCount: widget.model.checkupItems.length,
// ),
// ],
// ),
// ),
// ),
], ],
), ),
), ),
@ -194,13 +150,16 @@ class _NewCMCStepOnePageState extends State<NewCMCStepOnePage> {
PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList( PatientERCMCInsertServicesList patientERCMCInsertServicesList = new PatientERCMCInsertServicesList(
price: widget.model.cmcAllServicesList[selectedItem].price, price: widget.model.cmcAllServicesList[selectedItem].price,
serviceID: widget.model.cmcAllServicesList[selectedItem].serviceID.toString(), serviceID: widget.model.cmcAllServicesList[selectedItem].serviceID.toString(),
selectedServiceName: widget.model.cmcAllServicesList[selectedItem].description, selectedServiceName: widget.model.cmcAllServicesList[selectedItem].text,
selectedServiceNameAR: widget.model.cmcAllServicesList[selectedItem].descriptionN, selectedServiceNameAR: widget.model.cmcAllServicesList[selectedItem].textN,
recordID: 1, recordID: 1,
totalPrice: widget.model.cmcAllServicesList[selectedItem].totalPrice, totalPrice: widget.model.cmcAllServicesList[selectedItem].priceTotal,
vAT: widget.model.cmcAllServicesList[selectedItem].vAT, vAT: widget.model.cmcAllServicesList[selectedItem].priceVAT,
); );
widget.cMCInsertPresOrderRequestModel.patientID = projectViewModel.user.patientID;
widget.cMCInsertPresOrderRequestModel.patientOutSA = projectViewModel.user.outSA;
widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList]; widget.cMCInsertPresOrderRequestModel.patientERCMCInsertServicesList = [patientERCMCInsertServicesList];
await widget.model.getCustomerInfo(); await widget.model.getCustomerInfo();
// if (widget.model.state == ViewState.ErrorLocal) { // if (widget.model.state == ViewState.ErrorLocal) {

@ -202,7 +202,7 @@ class _NewCMCStepThreePageState extends State<NewCMCStepThreePage> {
color: CustomColors.green, color: CustomColors.green,
onTap: () async { onTap: () async {
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
String requestId = await widget.model.insertPresPresOrder(order: widget.cmcInsertPresOrderRequestModel); String requestId = await widget.model.insertCMCOrderRC(order: widget.cmcInsertPresOrderRequestModel);
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (widget.model.state != ViewState.ErrorLocal) { if (widget.model.state != ViewState.ErrorLocal) {
//show scuccess dialog //show scuccess dialog

@ -1,33 +1,30 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/models/DoctorScheduleResponse.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/models/DoctorScheduleResponse.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/indicator.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/indicator.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
class SchedulePage extends StatefulWidget { class SchedulePage extends StatefulWidget {
DoctorList doctorList; DoctorList doctorList;
AppoitmentAllHistoryResultList appo; AppoitmentAllHistoryResultList appo;
SchedulePage({ SchedulePage({
this.appo, this.appo,
this.doctorList, this.doctorList,
}); });
@override @override
_SchedulePageState createState() => _SchedulePageState(); _SchedulePageState createState() => _SchedulePageState();
} }
@ -45,6 +42,7 @@ class _SchedulePageState extends State<SchedulePage> {
bool isPageChange = false; bool isPageChange = false;
AppSharedPreferences sharedPref = AppSharedPreferences(); AppSharedPreferences sharedPref = AppSharedPreferences();
@override @override
void initState() { void initState() {
this.doctorList = widget.doctorList; this.doctorList = widget.doctorList;
@ -56,169 +54,132 @@ class _SchedulePageState extends State<SchedulePage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<MedicalViewModel>( return BaseView<MedicalViewModel>(
onModelReady: (model) => model.getDoctorSchedule(doctorList), onModelReady: (model) => model.getDoctorSchedule(doctorList),
allowAny: true, allowAny: true,
builder: (_, model, widget) => BaseView<MedicalViewModel>( builder: (_, model, widget) => BaseView<MedicalViewModel>(
onModelReady: (model2) => model2.getFreeSlots(doctorList), onModelReady: (model2) => model2.getFreeSlots(doctorList),
allowAny: true, allowAny: true,
builder: (_, model2, widget2) { builder: (_, model2, widget2) {
if (model2.freeSlots.length > 0 && isPageChange == false && model2.state == ViewState.Idle) { if (model2.freeSlots.length > 0 && isPageChange == false && model2.state == ViewState.Idle) {
this.freeSlots = model2.freeSlots; this.freeSlots = model2.freeSlots;
this.doctorScheduleResponse = model.getDoctorScheduleList; this.doctorScheduleResponse = model.getDoctorScheduleList;
this.generateWeeksSchedules(); this.generateWeeksSchedules();
} else if (model2.freeSlots.length == 0 && model2.state == ViewState.Idle) { } else if (model2.freeSlots.length == 0 && model2.state == ViewState.Idle) {
AppToast.showErrorToast(message: TranslationBase.of(context).emptySchedule); AppToast.showErrorToast(message: TranslationBase.of(context).emptySchedule);
Navigator.pop(context); Navigator.pop(context);
} }
return AppScaffold( return AppScaffold(
appBarTitle: TranslationBase.of(context).schedule, appBarTitle: TranslationBase.of(context).schedule,
showNewAppBar: true, showNewAppBar: true,
showNewAppBarTitle: true, showNewAppBarTitle: true,
isShowAppBar: true, isShowAppBar: true,
backgroundColor: Color(0xffF7F7F7), baseViewModel: model2,
baseViewModel: model2, isShowDecPage: false,
isShowDecPage: false, body: SizedBox(
body: Column( height: MediaQuery.of(context).size.height,
children: [ child: Stack(
SizedBox(height: 21), children: [
PageViewIndicator( Container(
isActive: true, margin: EdgeInsets.only(top: 40),
currentPage: this.currentPage, child: PageView.builder(
length: weeks.length, controller: _pageController,
), itemCount: weeks.length,
Expanded( onPageChanged: (index) {
child: PageView.builder( setState(() {
controller: _pageController, isPageChange = true;
itemCount: weeks.length, this.currentPage = index.toDouble();
onPageChanged: (index) { });
setState(() { },
isPageChange = true; itemBuilder: (context, index) {
this.currentPage = index.toDouble(); return Container(
}); child: ListView.builder(
}, itemCount: weeks[index].length,
itemBuilder: (context, index) { itemBuilder: (context, index2) => InkWell(
return ListView.separated( onTap: () {
itemCount: weeks[index].length, openBookAppointment(weeks[index][index2]);
padding: EdgeInsets.all(21), },
separatorBuilder: (context, index) => SizedBox(height: 12), child: Row(
itemBuilder: (context, index2) { children: [
bool isToday = DateUtil.convertStringToDate(weeks[index][index2]['Date']).toString().substring(0, 10) == DateTime.now().toString().substring(0, 10); Expanded(
Color toDayColor = isToday ? Color(0xff359846) : Colors.white; flex: 1,
child: Padding(
return InkWell( padding: projectViewModel.isArabic ? EdgeInsets.only(right: 20) : EdgeInsets.only(left: 20),
onTap: () { child: Row(children: [
openBookAppointment(weeks[index][index2]); Column(
children: [
Texts(
weeks[index][index2]['DayName'],
fontSize: 13,
fontWeight: projectViewModel.isArabic ? FontWeight.w600 : FontWeight.w500,
),
Texts(
getDayMonths(
DateUtil.convertStringToDate(
weeks[index][index2]['Date'],
),
),
fontWeight: FontWeight.bold,
fontSize: 18,
)
],
)
])),
),
Expanded(
flex: 3,
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
child: Container(
padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 20),
margin: EdgeInsets.only(left: 20, right: 20, top: 7, bottom: 7),
decoration: BoxDecoration(boxShadow: [
DateUtil.convertStringToDate(weeks[index][index2]['Date']).toString().substring(0, 10) == DateTime.now().toString().substring(0, 10)
? BoxShadow(color: Colors.green, offset: Offset(projectViewModel.isArabic ? 5 : -5, 0))
: BoxShadow(
color: Colors.grey[100],
blurRadius: 5,
spreadRadius: 4,
offset: Offset(0, 10),
),
], borderRadius: const BorderRadius.all(Radius.circular(10.0)), color: Colors.white),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
DateUtil.convertStringToDate(weeks[index][index2]['Date']).toString().substring(0, 10) == DateTime.now().toString().substring(0, 10)
? Texts(
TranslationBase.of(context).today,
color: Colors.green,
fontWeight: FontWeight.w600,
fontSize: 12,
marginTop: 0,
)
: SizedBox(),
Row(
children: [
Expanded(
child: Text(
weeks[index][index2]['WorkingHours'],
style: TextStyle(
fontWeight: FontWeight.w600,
),
),
),
Icon(Icons.arrow_forward, size: 16.0),
],
)
]))),
),
],
))));
}, },
child: Row( )),
crossAxisAlignment: CrossAxisAlignment.start, PageViewIndicator(
children: [ isActive: true,
Expanded( currentPage: this.currentPage,
flex: 1, length: weeks.length,
child: Column( )
mainAxisSize: MainAxisSize.min, ],
crossAxisAlignment: CrossAxisAlignment.start, )));
children: [ }));
Text(
weeks[index][index2]['DayName'],
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Color(0xff2E303A),
letterSpacing: -0.52,
),
),
Text(
getDayMonths(DateUtil.convertStringToDate(weeks[index][index2]['Date'])),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: Color(0xff2E303A),
letterSpacing: -0.72,
),
),
],
),
),
Expanded(
flex: 3,
child: Container(
decoration: BoxDecoration(
color: toDayColor,
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
boxShadow: [
BoxShadow(
color: Color(0xff000000).withOpacity(.05),
blurRadius: 27,
offset: Offset(0, -3),
),
],
),
child: Container(
margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0),
padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: Colors.white, width: 1),
borderRadius: BorderRadius.only(
bottomRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0),
topRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0),
bottomLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0),
topLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
if (isToday)
Text(
TranslationBase.of(context).today,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: toDayColor,
letterSpacing: -0.48,
),
),
Row(
children: [
Expanded(
child: Text(
weeks[index][index2]['WorkingHours'],
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Color(0xff2E303A),
letterSpacing: -0.56,
),
),
),
],
)
]),
),
Icon(Icons.arrow_forward, color: Color(0xff2B353E)),
],
),
),
),
),
],
),
);
});
},
),
),
],
),
);
}),
);
} }
generateWeeksSchedules() { generateWeeksSchedules() {
@ -284,3 +245,289 @@ class _SchedulePageState extends State<SchedulePage> {
// ); // );
} }
} }
// import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
// import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart';
//
// import 'package:diplomaticquarterapp/pages/MyAppointments/models/DoctorScheduleResponse.dart';
// import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/indicator.dart';
// import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
// import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
// import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
// import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
// import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
// import 'package:flutter/material.dart';
// import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
// import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart';
// import 'package:diplomaticquarterapp/pages/base/base_view.dart';
// import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
// import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
// import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
// import 'package:diplomaticquarterapp/uitl/app_toast.dart';
// import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
// import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
// import 'package:provider/provider.dart';
// import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
//
// class SchedulePage extends StatefulWidget {
// DoctorList doctorList;
// AppoitmentAllHistoryResultList appo;
// SchedulePage({
// this.appo,
// this.doctorList,
// });
// @override
// _SchedulePageState createState() => _SchedulePageState();
// }
//
// class _SchedulePageState extends State<SchedulePage> {
// DoctorsListService service;
// PageController _pageController = PageController();
// double currentPage = 0;
// int selectedindex = 0;
// List weeks = [];
// List<DoctorScheduleResponse> doctorScheduleResponse = [];
// int weekMS = 604800 * 1000;
// DoctorList doctorList;
// List<String> freeSlots = [];
// bool isPageChange = false;
//
// AppSharedPreferences sharedPref = AppSharedPreferences();
// @override
// void initState() {
// this.doctorList = widget.doctorList;
//
// super.initState();
// }
//
// @override
// Widget build(BuildContext context) {
// ProjectViewModel projectViewModel = Provider.of(context);
// return BaseView<MedicalViewModel>(
// onModelReady: (model) => model.getDoctorSchedule(doctorList),
// allowAny: true,
// builder: (_, model, widget) => BaseView<MedicalViewModel>(
// onModelReady: (model2) => model2.getFreeSlots(doctorList),
// allowAny: true,
// builder: (_, model2, widget2) {
// if (model2.freeSlots.length > 0 && isPageChange == false && model2.state == ViewState.Idle) {
// this.freeSlots = model2.freeSlots;
// this.doctorScheduleResponse = model.getDoctorScheduleList;
//
// this.generateWeeksSchedules();
// } else if (model2.freeSlots.length == 0 && model2.state == ViewState.Idle) {
// AppToast.showErrorToast(message: TranslationBase.of(context).emptySchedule);
// Navigator.pop(context);
// }
// return AppScaffold(
// appBarTitle: TranslationBase.of(context).schedule,
// showNewAppBar: true,
// showNewAppBarTitle: true,
// isShowAppBar: true,
// backgroundColor: Color(0xffF7F7F7),
// baseViewModel: model2,
// isShowDecPage: false,
// body: Column(
// children: [
// SizedBox(height: 21),
// PageViewIndicator(
// isActive: true,
// currentPage: this.currentPage,
// length: weeks.length,
// ),
// Expanded(
// child: PageView.builder(
// controller: _pageController,
// itemCount: weeks.length,
// onPageChanged: (index) {
// setState(() {
// isPageChange = true;
// this.currentPage = index.toDouble();
// });
// },
// itemBuilder: (context, index) {
// return ListView.separated(
// itemCount: weeks[index].length,
// padding: EdgeInsets.all(21),
// separatorBuilder: (context, index) => SizedBox(height: 12),
// itemBuilder: (context, index2) {
// bool isToday = DateUtil.convertStringToDate(weeks[index][index2]['Date']).toString().substring(0, 10) == DateTime.now().toString().substring(0, 10);
// Color toDayColor = isToday ? Color(0xff359846) : Colors.white;
// return InkWell(
// onTap: () {
// openBookAppointment(weeks[index][index2]);
// },
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Expanded(
// flex: 1,
// child: Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// weeks[index][index2]['DayName'],
// style: TextStyle(
// fontSize: 13,
// fontWeight: FontWeight.w600,
// color: Color(0xff2E303A),
// letterSpacing: -0.52,
// ),
// ),
// Text(
// getDayMonths(DateUtil.convertStringToDate(weeks[index][index2]['Date'])),
// style: TextStyle(
// fontSize: 18,
// fontWeight: FontWeight.w700,
// color: Color(0xff2E303A),
// letterSpacing: -0.72,
// ),
// ),
// ],
// ),
// ),
// Expanded(
// flex: 3,
// child: Container(
// decoration: BoxDecoration(
// color: toDayColor,
// borderRadius: BorderRadius.all(
// Radius.circular(10.0),
// ),
// boxShadow: [
// BoxShadow(
// color: Color(0xff000000).withOpacity(.05),
// blurRadius: 27,
// offset: Offset(0, -3),
// ),
// ],
// ),
// child: Container(
// margin: EdgeInsets.only(left: projectViewModel.isArabic ? 0 : 6, right: projectViewModel.isArabic ? 6 : 0),
// padding: EdgeInsets.symmetric(vertical: 14, horizontal: 12),
// decoration: BoxDecoration(
// color: Colors.white,
// border: Border.all(color: Colors.white, width: 1),
// borderRadius: BorderRadius.only(
// bottomRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0),
// topRight: projectViewModel.isArabic ? Radius.circular(0) : Radius.circular(10.0),
// bottomLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0),
// topLeft: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0),
// ),
// ),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// Expanded(
// child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
// if (isToday)
// Text(
// TranslationBase.of(context).today,
// style: TextStyle(
// fontSize: 12,
// fontWeight: FontWeight.w600,
// color: toDayColor,
// letterSpacing: -0.48,
// ),
// ),
// Row(
// children: [
// Expanded(
// child: Text(
// weeks[index][index2]['WorkingHours'],
// style: TextStyle(
// fontSize: 13,
// fontWeight: FontWeight.w600,
// color: Color(0xff2E303A),
// letterSpacing: -0.56,
// ),
// ),
// ),
// ],
// )
// ]),
// ),
// Icon(Icons.arrow_forward, color: Color(0xff2B353E)),
// ],
// ),
// ),
// ),
// ),
// ],
// ),
// );
// });
// },
// ),
// ),
// ],
// ),
// );
// }),
// );
// }
//
// generateWeeksSchedules() {
// this.weeks.clear();
// for (var i = 0; i < 8; i++) {
// var weekSchedule = generateNewWeekSchedule(i);
// this.markWeekFreeDays(weekSchedule);
// this.weeks.add(weekSchedule);
// }
// //print(this.weeks);
// }
//
// markWeekFreeDays(schedule) {
// for (var workDay in schedule) {
// workDay['fullDay'] = !this.hasFreeSlot(workDay['Date']);
// }
// }
//
// generateNewWeekSchedule(weekIndex) {
// var weekMSOffset = weekIndex * weekMS;
//
// var newWeekSchedule = [];
// for (var workDay in this.doctorScheduleResponse) {
// Map<String, dynamic> newWorkDay = Map();
// newWorkDay['Date'] = DateUtil.convertDateMSToJsonDate(DateUtil.convertStringToDate(workDay.date).millisecondsSinceEpoch + weekMSOffset);
// newWorkDay['DayName'] = workDay.dayName;
// newWorkDay['WorkingHours'] = workDay.workingHours;
// newWeekSchedule.add(newWorkDay);
// }
// return newWeekSchedule;
// }
//
// hasFreeSlot(String jsonDate) {
// var date = DateUtil.convertStringToDate(jsonDate);
// var scheduleDay = date;
// for (var event in this.freeSlots) {
// var date = DateUtil.convertStringToDate(event);
// var nDate = DateTime(date.year, date.month, date.day);
//
// if (nDate.millisecondsSinceEpoch == scheduleDay.millisecondsSinceEpoch) {
// return true;
// }
// }
// return false;
// }
//
// String getDayMonths(DateTime dateTime) {
// String dateFormat = '${dateTime.day} ${DateUtil.getMonth(dateTime.month).toString().substring(0, 3)}';
// return dateFormat;
// }
//
// openBookAppointment(selectedDate) {
// //sharedPref.setObject(DOCTOR_SCHEDULE_DATE_SEL, selectedDate);
// Navigator.of(context).pop(selectedDate);
// // Navigator.push(
// // context,
// // FadePage(
// // page: AppointmentDetails(
// // appo: widget.appo,
// // doctorSchedule: selectedDate,
// // ),
// // ),
// // );
// }
// }

Loading…
Cancel
Save