From 940b3275615c0d612aca97f7cf06f50cc16c0b5c Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Wed, 5 Aug 2020 12:23:35 +0300 Subject: [PATCH] done Prescriptions --- lib/config/config.dart | 1 + .../prescriptions/perscription_pharmacy.dart | 108 +++++++++++++ .../prescription_report_enh.dart | 144 ++++++++++++++++++ ...t_get_list_pharmacy_for_prescriptions.dart | 60 ++++++++ .../request_prescription_report_enh.dart | 84 ++++++++++ .../medical/prescriptions_service.dart | 82 +++++++++- .../medical/prescriptions_view_model.dart | 35 ++++- .../pharmacy_for_prescriptions_page.dart | 100 ++++++++++++ .../prescription_details_page.dart | 19 ++- .../prescriptions/prescriptions_history.dart | 13 -- .../prescriptions_history_details_page.dart | 109 +++++++++++++ .../prescriptions_history_page.dart | 83 ++++++++++ .../prescriptions_home_page.dart | 10 +- lib/uitl/date_uitl.dart | 21 ++- lib/widgets/data_display/text.dart | 6 +- 15 files changed, 841 insertions(+), 34 deletions(-) create mode 100644 lib/core/model/prescriptions/perscription_pharmacy.dart create mode 100644 lib/core/model/prescriptions/prescription_report_enh.dart create mode 100644 lib/core/model/prescriptions/request_get_list_pharmacy_for_prescriptions.dart create mode 100644 lib/core/model/prescriptions/request_prescription_report_enh.dart create mode 100644 lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart delete mode 100644 lib/pages/medical/prescriptions/prescriptions_history.dart create mode 100644 lib/pages/medical/prescriptions/prescriptions_history_details_page.dart create mode 100644 lib/pages/medical/prescriptions/prescriptions_history_page.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 643a2ec9..1908ee0b 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -18,6 +18,7 @@ const GET_DOCTOR_RATING = '/Doctors.svc/REST/dr_GetAvgDoctorRating'; const PRESCRIPTIONS = '/Patients.svc/REST/GetPrescriptionApptList'; const GET_PRESCRIPTIONS_ALL_ORDERS = '/Patients.svc/REST/PatientER_GetPatientAllPresOrders'; const GET_PRESCRIPTION_REPORT = '/Patients.svc/REST/INP_GetPrescriptionReport'; +const GET_PRESCRIPTION_REPORT_ENH = '/Patients.svc/REST/GetPrescriptionReport_enh'; const SEND_PRESCRIPTION_EMAIL = '/Notifications.svc/REST/SendPrescriptionEmail'; //const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment diff --git a/lib/core/model/prescriptions/perscription_pharmacy.dart b/lib/core/model/prescriptions/perscription_pharmacy.dart new file mode 100644 index 00000000..5180689f --- /dev/null +++ b/lib/core/model/prescriptions/perscription_pharmacy.dart @@ -0,0 +1,108 @@ +class PharmacyPrescriptions { + String expiryDate; + double sellingPrice; + int quantity; + int itemID; + int locationID; + int projectID; + String setupID; + String locationDescription; + Null locationDescriptionN; + String itemDescription; + Null itemDescriptionN; + String alias; + int locationTypeID; + int barcode; + Null companybarcode; + int cityID; + String cityName; + int distanceInKilometers; + String latitude; + int locationType; + String longitude; + String phoneNumber; + String projectImageURL; + Null sortOrder; + + PharmacyPrescriptions( + {this.expiryDate, + this.sellingPrice, + this.quantity, + this.itemID, + this.locationID, + this.projectID, + this.setupID, + this.locationDescription, + this.locationDescriptionN, + this.itemDescription, + this.itemDescriptionN, + this.alias, + this.locationTypeID, + this.barcode, + this.companybarcode, + this.cityID, + this.cityName, + this.distanceInKilometers, + this.latitude, + this.locationType, + this.longitude, + this.phoneNumber, + this.projectImageURL, + this.sortOrder}); + + PharmacyPrescriptions.fromJson(Map json) { + expiryDate = json['ExpiryDate']; + sellingPrice = json['SellingPrice']; + quantity = json['Quantity']; + itemID = json['ItemID']; + locationID = json['LocationID']; + projectID = json['ProjectID']; + setupID = json['SetupID']; + locationDescription = json['LocationDescription']; + locationDescriptionN = json['LocationDescriptionN']; + itemDescription = json['ItemDescription']; + itemDescriptionN = json['ItemDescriptionN']; + alias = json['Alias']; + locationTypeID = json['LocationTypeID']; + barcode = json['Barcode']; + companybarcode = json['Companybarcode']; + cityID = json['CityID']; + cityName = json['CityName']; + distanceInKilometers = json['DistanceInKilometers']; + latitude = json['Latitude']; + locationType = json['LocationType']; + longitude = json['Longitude']; + phoneNumber = json['PhoneNumber']; + projectImageURL = json['ProjectImageURL']; + sortOrder = json['SortOrder']; + } + + Map toJson() { + final Map data = new Map(); + data['ExpiryDate'] = this.expiryDate; + data['SellingPrice'] = this.sellingPrice; + data['Quantity'] = this.quantity; + data['ItemID'] = this.itemID; + data['LocationID'] = this.locationID; + data['ProjectID'] = this.projectID; + data['SetupID'] = this.setupID; + data['LocationDescription'] = this.locationDescription; + data['LocationDescriptionN'] = this.locationDescriptionN; + data['ItemDescription'] = this.itemDescription; + data['ItemDescriptionN'] = this.itemDescriptionN; + data['Alias'] = this.alias; + data['LocationTypeID'] = this.locationTypeID; + data['Barcode'] = this.barcode; + data['Companybarcode'] = this.companybarcode; + data['CityID'] = this.cityID; + data['CityName'] = this.cityName; + data['DistanceInKilometers'] = this.distanceInKilometers; + data['Latitude'] = this.latitude; + data['LocationType'] = this.locationType; + data['Longitude'] = this.longitude; + data['PhoneNumber'] = this.phoneNumber; + data['ProjectImageURL'] = this.projectImageURL; + data['SortOrder'] = this.sortOrder; + return data; + } +} diff --git a/lib/core/model/prescriptions/prescription_report_enh.dart b/lib/core/model/prescriptions/prescription_report_enh.dart new file mode 100644 index 00000000..203eaaff --- /dev/null +++ b/lib/core/model/prescriptions/prescription_report_enh.dart @@ -0,0 +1,144 @@ +class PrescriptionReportEnh { + String address; + int appointmentNo; + String clinic; + Null companyName; + int days; + String doctorName; + int doseDailyQuantity; + String frequency; + int frequencyNumber; + Null image; + Null imageExtension; + String imageSRCUrl; + Null imageString; + String imageThumbUrl; + String isCovered; + String itemDescription; + int itemID; + String orderDate; + int patientID; + String patientName; + String phoneOffice1; + Null prescriptionQR; + int prescriptionTimes; + Null productImage; + Null productImageBase64; + String productImageString; + int projectID; + String projectName; + String remarks; + String route; + String sKU; + int scaleOffset; + String startDate; + + PrescriptionReportEnh( + {this.address, + this.appointmentNo, + this.clinic, + this.companyName, + this.days, + this.doctorName, + this.doseDailyQuantity, + this.frequency, + this.frequencyNumber, + this.image, + this.imageExtension, + this.imageSRCUrl, + this.imageString, + this.imageThumbUrl, + this.isCovered, + this.itemDescription, + this.itemID, + this.orderDate, + this.patientID, + this.patientName, + this.phoneOffice1, + this.prescriptionQR, + this.prescriptionTimes, + this.productImage, + this.productImageBase64, + this.productImageString, + this.projectID, + this.projectName, + this.remarks, + this.route, + this.sKU, + this.scaleOffset, + this.startDate}); + + PrescriptionReportEnh.fromJson(Map json) { + address = json['Address']; + appointmentNo = json['AppointmentNo']; + clinic = json['Clinic']; + companyName = json['CompanyName']; + days = json['Days']; + doctorName = json['DoctorName']; + doseDailyQuantity = json['DoseDailyQuantity']; + frequency = json['Frequency']; + frequencyNumber = json['FrequencyNumber']; + image = json['Image']; + imageExtension = json['ImageExtension']; + imageSRCUrl = json['ImageSRCUrl']; + imageString = json['ImageString']; + imageThumbUrl = json['ImageThumbUrl']; + isCovered = json['IsCovered']; + itemDescription = json['ItemDescription']; + itemID = json['ItemID']; + orderDate = json['OrderDate']; + patientID = json['PatientID']; + patientName = json['PatientName']; + phoneOffice1 = json['PhoneOffice1']; + prescriptionQR = json['PrescriptionQR']; + prescriptionTimes = json['PrescriptionTimes']; + productImage = json['ProductImage']; + productImageBase64 = json['ProductImageBase64']; + productImageString = json['ProductImageString']; + projectID = json['ProjectID']; + projectName = json['ProjectName']; + remarks = json['Remarks']; + route = json['Route']; + sKU = json['SKU']; + scaleOffset = json['ScaleOffset']; + startDate = json['StartDate']; + } + + Map toJson() { + final Map data = new Map(); + data['Address'] = this.address; + data['AppointmentNo'] = this.appointmentNo; + data['Clinic'] = this.clinic; + data['CompanyName'] = this.companyName; + data['Days'] = this.days; + data['DoctorName'] = this.doctorName; + data['DoseDailyQuantity'] = this.doseDailyQuantity; + data['Frequency'] = this.frequency; + data['FrequencyNumber'] = this.frequencyNumber; + data['Image'] = this.image; + data['ImageExtension'] = this.imageExtension; + data['ImageSRCUrl'] = this.imageSRCUrl; + data['ImageString'] = this.imageString; + data['ImageThumbUrl'] = this.imageThumbUrl; + data['IsCovered'] = this.isCovered; + data['ItemDescription'] = this.itemDescription; + data['ItemID'] = this.itemID; + data['OrderDate'] = this.orderDate; + data['PatientID'] = this.patientID; + data['PatientName'] = this.patientName; + data['PhoneOffice1'] = this.phoneOffice1; + data['PrescriptionQR'] = this.prescriptionQR; + data['PrescriptionTimes'] = this.prescriptionTimes; + data['ProductImage'] = this.productImage; + data['ProductImageBase64'] = this.productImageBase64; + data['ProductImageString'] = this.productImageString; + data['ProjectID'] = this.projectID; + data['ProjectName'] = this.projectName; + data['Remarks'] = this.remarks; + data['Route'] = this.route; + data['SKU'] = this.sKU; + data['ScaleOffset'] = this.scaleOffset; + data['StartDate'] = this.startDate; + return data; + } +} diff --git a/lib/core/model/prescriptions/request_get_list_pharmacy_for_prescriptions.dart b/lib/core/model/prescriptions/request_get_list_pharmacy_for_prescriptions.dart new file mode 100644 index 00000000..739bb838 --- /dev/null +++ b/lib/core/model/prescriptions/request_get_list_pharmacy_for_prescriptions.dart @@ -0,0 +1,60 @@ +class RequestGetListPharmacyForPrescriptions { + int latitude; + int longitude; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int itemID; + + RequestGetListPharmacyForPrescriptions( + {this.latitude, + this.longitude, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.itemID}); + + RequestGetListPharmacyForPrescriptions.fromJson(Map json) { + latitude = json['Latitude']; + longitude = json['Longitude']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + itemID = json['ItemID']; + } + + Map toJson() { + final Map data = new Map(); + data['Latitude'] = this.latitude; + data['Longitude'] = this.longitude; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['ItemID'] = this.itemID; + return data; + } +} diff --git a/lib/core/model/prescriptions/request_prescription_report_enh.dart b/lib/core/model/prescriptions/request_prescription_report_enh.dart new file mode 100644 index 00000000..42b89c15 --- /dev/null +++ b/lib/core/model/prescriptions/request_prescription_report_enh.dart @@ -0,0 +1,84 @@ +class RequestPrescriptionReportEnh { + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + int appointmentNo; + String setupID; + int episodeID; + int clinicID; + int projectID; + + RequestPrescriptionReportEnh( + {this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType, + this.appointmentNo, + this.setupID, + this.episodeID, + this.clinicID, + this.projectID}); + + RequestPrescriptionReportEnh.fromJson(Map json) { + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + appointmentNo = json['AppointmentNo']; + setupID = json['SetupID']; + episodeID = json['EpisodeID']; + clinicID = json['ClinicID']; + projectID = json['ProjectID']; + } + + Map toJson() { + final Map data = new Map(); + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + data['AppointmentNo'] = this.appointmentNo; + data['SetupID'] = this.setupID; + data['EpisodeID'] = this.episodeID; + data['ClinicID'] = this.clinicID; + data['ProjectID'] = this.projectID; + return data; + } +} diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index 3e7259f7..294ef897 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -1,8 +1,12 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/Prescriptions.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/perscription_pharmacy.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_enh.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/request_get_list_pharmacy_for_prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/request_prescription_report.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/request_prescription_report_enh.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/request_prescriptions.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/request_prescriptions_orders.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/request_send_prescription_email.dart'; @@ -137,13 +141,83 @@ class PrescriptionsService extends BaseService { _requestSendPrescriptionEmail.projectID = projectID; hasError = false; await baseAppClient.post(SEND_PRESCRIPTION_EMAIL, - onSuccess: (dynamic response, int statusCode){ - var asd = ""; - - }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: _requestSendPrescriptionEmail.toJson()); } + + RequestGetListPharmacyForPrescriptions + requestGetListPharmacyForPrescriptions = + RequestGetListPharmacyForPrescriptions( + latitude: 0, + longitude: 0, + versionID: 5.5, + channel: 3, + languageID: 2, + iPAdress: '10.20.10.20', + generalid: 'Cs2020@2016\$2958', + patientOutSA: 0, + sessionID: 'HGNerTUSXhpaHXBg', + isDentalAllowedBackend: false, + deviceTypeID: 2, + ); + List pharmacyPrescriptionsList = List(); + + Future getListPharmacyForPrescriptions({int itemId}) async { + hasError = false; + requestGetListPharmacyForPrescriptions.itemID = itemId; + await baseAppClient.post(GET_PHARMACY_LIST, + onSuccess: (dynamic response, int statusCode) { + pharmacyPrescriptionsList.clear(); + response['PharmList'].forEach((prescriptions) { + pharmacyPrescriptionsList + .add(PharmacyPrescriptions.fromJson(prescriptions)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: requestGetListPharmacyForPrescriptions.toJson()); + } + + + RequestPrescriptionReportEnh _requestPrescriptionReportEnh = RequestPrescriptionReportEnh( + versionID: 5.5, + channel: 3, + languageID: 2, + iPAdress: '10.20.10.20', + generalid: 'Cs2020@2016\$2958', + patientOutSA: 0, + sessionID: 'bQQdesEKpyYKTFMVNeg', + isDentalAllowedBackend: false, + deviceTypeID: 2, + patientID: 1231755, + tokenID: '@dm!n', + patientTypeID: 1, + patientType: 1, + setupID: '91877', + appointmentNo: 5926390, + episodeID: 140251928, + clinicID: 25, + projectID: 12 + + ); + + List prescriptionReportEnhList = List(); + Future getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder})async{ + hasError = false; + // _requestPrescriptionReportEnh.appointmentNo = int.parse(prescriptionsOrder.appointmentNo); + // _requestPrescriptionReportEnh.patientID = prescriptionsOrder.projectID; + + await baseAppClient.post(GET_PRESCRIPTION_REPORT_ENH, + onSuccess: (dynamic response, int statusCode) { + prescriptionReportEnhList.clear(); + response['ListPRM'].forEach((prescriptions) { + prescriptionReportEnhList.add(PrescriptionReportEnh.fromJson(prescriptions)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestPrescriptionReportEnh.toJson()); + } } diff --git a/lib/core/viewModels/medical/prescriptions_view_model.dart b/lib/core/viewModels/medical/prescriptions_view_model.dart index 6ad25380..125bee66 100644 --- a/lib/core/viewModels/medical/prescriptions_view_model.dart +++ b/lib/core/viewModels/medical/prescriptions_view_model.dart @@ -1,4 +1,7 @@ +import 'package:diplomaticquarterapp/core/model/prescriptions/perscription_pharmacy.dart'; import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report_enh.dart'; +import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import '../../../core/enum/filter_type.dart'; @@ -16,12 +19,18 @@ class PrescriptionsViewModel extends BaseViewModel { List _prescriptionsOrderListClinic = List(); List _prescriptionsOrderListHospital = List(); + List get prescriptionReportList => _prescriptionsService.prescriptionReportList; List get prescriptionsList => _prescriptionsService.prescriptionsList; + List get prescriptionsHistory => _prescriptionsService.prescriptionsOrderList; + + List get pharmacyPrescriptionsList => _prescriptionsService.pharmacyPrescriptionsList ; + + List get prescriptionsOrderList => filterType == FilterType.Clinic ? _prescriptionsOrderListClinic @@ -105,7 +114,7 @@ class PrescriptionsViewModel extends BaseViewModel { } } - sendPrescriptionEmail( + sendPrescriptionEmail( {String appointmentDate, int patientID, String clinicName, @@ -124,5 +133,29 @@ class PrescriptionsViewModel extends BaseViewModel { } } + getListPharmacyForPrescriptions({int itemId}) async { + setState(ViewState.Busy); + await _prescriptionsService.getListPharmacyForPrescriptions(itemId: itemId); + if (_prescriptionsService.hasError) { + error = _prescriptionsService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + + + List get prescriptionReportEnhList => _prescriptionsService.prescriptionReportEnhList; + + getPrescriptionReportEnh({PrescriptionsOrder prescriptionsOrder}) async { + setState(ViewState.Busy); + await _prescriptionsService.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder); + if (_prescriptionsService.hasError) { + error = _prescriptionsService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } } diff --git a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart new file mode 100644 index 00000000..643cca01 --- /dev/null +++ b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart @@ -0,0 +1,100 @@ +import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:maps_launcher/maps_launcher.dart'; + +class PharmacyForPrescriptionsPage extends StatelessWidget { + final PrescriptionReport prescriptionReport; + + PharmacyForPrescriptionsPage({Key key, this.prescriptionReport}); + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getListPharmacyForPrescriptions(itemId: prescriptionReport.itemID), + builder: (_, model, widget) => AppScaffold( + isShowAppBar: true, + appBarTitle: 'Title', + baseViewModel: model, + body: ListView.builder( + itemBuilder: (context, index) => Container( + width: double.infinity, + margin: EdgeInsets.only(top: 10, left: 10, right: 10), + padding: EdgeInsets.all(8.0), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + border: Border.all(color: Colors.grey[200], width: 0.5), + ), + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: Image.network( + model.pharmacyPrescriptionsList[index].projectImageURL, + fit: BoxFit.cover, + width: 60, + height: 70, + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts(model.pharmacyPrescriptionsList[index] + .locationDescription), + SizedBox( + height: 5, + ), + Texts(model.pharmacyPrescriptionsList[index].cityName), + ], + ), + ), + ), + InkWell( + onTap: () { + MapsLauncher.launchCoordinates( + double.parse( + model.pharmacyPrescriptionsList[index].latitude), + double.parse( + model.pharmacyPrescriptionsList[index].longitude)); + }, + child: Icon( + Icons.pin_drop, + size: 18, + color: Colors.red[900], + ), + ), + SizedBox( + width: 15, + ), + InkWell( + onTap: Feedback.wrapForTap((){ + launch("tel://${model.pharmacyPrescriptionsList[index].phoneNumber}"); + },context), + child: Container( + child: Icon( + Icons.call, + size: 18, + color: Colors.red[900], + ), + ), + ) + ], + ), + ), + itemCount: model.pharmacyPrescriptionsList.length, + ), + ), + ); + } +} diff --git a/lib/pages/medical/prescriptions/prescription_details_page.dart b/lib/pages/medical/prescriptions/prescription_details_page.dart index 35a9a307..72c82c55 100644 --- a/lib/pages/medical/prescriptions/prescription_details_page.dart +++ b/lib/pages/medical/prescriptions/prescription_details_page.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -53,16 +55,20 @@ class PrescriptionDetailsPage extends StatelessWidget { Container( margin: EdgeInsets.all(8), child: InkWell( - onTap: () {}, + onTap: () => Navigator.push( + context, + FadePage( + page: PharmacyForPrescriptionsPage( + prescriptionReport: prescriptionReport), + ), + ), child: Center( child: Column( children: [ Container( width: 50, decoration: BoxDecoration( - color: Colors.white, - shape: BoxShape.rectangle - ), + color: Colors.white, shape: BoxShape.rectangle), child: Column( children: [ Icon( @@ -73,9 +79,10 @@ class PrescriptionDetailsPage extends StatelessWidget { ], ), ), - SizedBox(height: 5,), + SizedBox( + height: 5, + ), Texts('Ports') - ], ), )), diff --git a/lib/pages/medical/prescriptions/prescriptions_history.dart b/lib/pages/medical/prescriptions/prescriptions_history.dart deleted file mode 100644 index 1df9a467..00000000 --- a/lib/pages/medical/prescriptions/prescriptions_history.dart +++ /dev/null @@ -1,13 +0,0 @@ -import 'package:flutter/cupertino.dart'; - -class PrescriptionsHistory extends StatefulWidget { - @override - _PrescriptionsHistoryState createState() => _PrescriptionsHistoryState(); -} - -class _PrescriptionsHistoryState extends State { - @override - Widget build(BuildContext context) { - return Container(); - } -} diff --git a/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart b/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart new file mode 100644 index 00000000..a8b4f484 --- /dev/null +++ b/lib/pages/medical/prescriptions/prescriptions_history_details_page.dart @@ -0,0 +1,109 @@ +import 'package:diplomaticquarterapp/core/model/prescriptions/prescriptions_order.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/BottomButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class PrescriptionsHistoryDetailsPage extends StatelessWidget { + final PrescriptionsOrder prescriptionsOrder; + + PrescriptionsHistoryDetailsPage({Key key,this.prescriptionsOrder}); + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getPrescriptionReportEnh(prescriptionsOrder: prescriptionsOrder), + builder: (_,model,widget) => AppScaffold( + isShowAppBar: true, + appBarTitle: 'Order History', + baseViewModel: model, + body: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: Container( + margin: EdgeInsets.all(15.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Table( + border: TableBorder.symmetric( + inside: BorderSide(width: 0.5), + outside: BorderSide(width: 0.5)), + children: [ + TableRow( + children: [ + Container( + height: 50, + color: Colors.white, + child: Center(child: Texts('Order No'),), + ), + Container( + height: 50, + color: Colors.white, + child: Center(child: Texts('Date'),), + ), + ] + ), + TableRow( + children: [ + Container( + height: 50, + color: Colors.white, + child: Center(child: Texts('12655'),), + ), + Container( + height: 50, + color: Colors.white, + child: Center(child: Texts('2020-7-15'),), + ), + ] + ) + ], + ), + SizedBox(height: 15,), + ...List.generate(model.prescriptionReportEnhList.length, (index) => Container( + margin: EdgeInsets.all(8.0), + color: Colors.white, + child: Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: Image.network( + model.prescriptionReportEnhList[index].imageSRCUrl, + fit: BoxFit.cover, + width: 60, + height: 70, + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts(model.prescriptionReportEnhList[index] + .itemDescription), + ], + ), + ), + ), + + ], + ), + )) + ], + ), + ), + ), + bottomSheet: Container( + //padding: EdgeInsets.all(8.0), + // margin: EdgeInsets.all(8.0), + child: BottomButton(label: 'Cancel order',color: Colors.red[300],), + ), + ), + ); + } +} diff --git a/lib/pages/medical/prescriptions/prescriptions_history_page.dart b/lib/pages/medical/prescriptions/prescriptions_history_page.dart new file mode 100644 index 00000000..efd9df44 --- /dev/null +++ b/lib/pages/medical/prescriptions/prescriptions_history_page.dart @@ -0,0 +1,83 @@ +import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_details_page.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class PrescriptionsHistoryPage extends StatelessWidget { + final PrescriptionsViewModel prescriptionsViewModel; + + PrescriptionsHistoryPage({Key key, this.prescriptionsViewModel}); + + @override + Widget build(BuildContext context) { + return AppScaffold( + baseViewModel: prescriptionsViewModel, + body: ListView.builder( + physics: BouncingScrollPhysics(), + itemBuilder: (context, index) => InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PrescriptionsHistoryDetailsPage( + prescriptionsOrder: + prescriptionsViewModel.prescriptionsHistory[index], + ), + ), + ), + child: Container( + padding: EdgeInsets.all(15.0), + margin: EdgeInsets.all(8.0), + decoration: + BoxDecoration(shape: BoxShape.rectangle, color: Colors.white), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + DateUtil.getDayMonthYearHourMinuteDateFormatted( + prescriptionsViewModel + .prescriptionsHistory[index].createdOn), + fontWeight: FontWeight.w300, + ), + SizedBox( + height: 5, + ), + Texts( + 'Order No ${prescriptionsViewModel.prescriptionsHistory[index].iD}'), + SizedBox( + height: 5, + ), + Texts( + '${prescriptionsViewModel.prescriptionsHistory[index].descriptionN}'), + SizedBox( + height: 5, + ), + Texts( + 'Order Details', + fontWeight: FontWeight.w300, + ), + SizedBox( + height: 5, + ), + ], + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 25, + ) + ], + ), + ), + ), + itemCount: prescriptionsViewModel.prescriptionsHistory.length, + ), + ); + } +} diff --git a/lib/pages/medical/prescriptions/prescriptions_home_page.dart b/lib/pages/medical/prescriptions/prescriptions_home_page.dart index e4c6ca9f..fd903b4b 100644 --- a/lib/pages/medical/prescriptions/prescriptions_home_page.dart +++ b/lib/pages/medical/prescriptions/prescriptions_home_page.dart @@ -2,7 +2,7 @@ import 'dart:ui'; import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_page.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -108,8 +108,12 @@ class _HomePrescriptionsPageState extends State physics: BouncingScrollPhysics(), controller: _tabController, children: [ - PrescriptionsPage(prescriptionsViewModel: model,), - PrescriptionsHistory() + PrescriptionsPage( + prescriptionsViewModel: model, + ), + PrescriptionsHistoryPage( + prescriptionsViewModel: model, + ) ], ), ) diff --git a/lib/uitl/date_uitl.dart b/lib/uitl/date_uitl.dart index c70e05b7..8b8d0c19 100644 --- a/lib/uitl/date_uitl.dart +++ b/lib/uitl/date_uitl.dart @@ -1,5 +1,4 @@ class DateUtil { - /// convert String To Date function /// [date] String we want to convert static DateTime convertStringToDate(String date) { @@ -91,7 +90,6 @@ class DateUtil { } } - /// get data formatted like Apr 26,2020 /// [dateTime] convert DateTime to data formatted static String getMonthDayYearDateFormatted(DateTime dateTime) { @@ -105,11 +103,9 @@ class DateUtil { return ""; } - /// get data formatted like 26/4/2020 /// [dateTime] convert DateTime to data formatted static String getDayMonthYearDateFormatted(DateTime dateTime) { - print(dateTime); if (dateTime != null) return dateTime.day.toString() + "/" + @@ -119,4 +115,21 @@ class DateUtil { else return ""; } + + /// get data formatted like 26/4/2020 10:30 + /// [dateTime] convert DateTime to data formatted + static String getDayMonthYearHourMinuteDateFormatted(DateTime dateTime) { + if (dateTime != null) + return dateTime.day.toString() + + "/" + + dateTime.month.toString() + + "/" + + dateTime.year.toString() + + " " + + dateTime.hour.toString() + + ":" + + dateTime.minute.toString(); + else + return ""; + } } diff --git a/lib/widgets/data_display/text.dart b/lib/widgets/data_display/text.dart index c357b777..4357b291 100644 --- a/lib/widgets/data_display/text.dart +++ b/lib/widgets/data_display/text.dart @@ -15,7 +15,7 @@ class Texts extends StatefulWidget { final String style; final bool allowExpand; final double fontSize; - final String fontWeight; + final FontWeight fontWeight; final double margin; final double marginTop; final double marginRight; @@ -216,7 +216,7 @@ class _TextsState extends State { ? _getFontStyle().copyWith( fontStyle: widget.italic ? FontStyle.italic : null, color: widget.color != null ? widget.color : null, - fontWeight: _getFontWeight(), + fontWeight: widget.fontWeight?? _getFontWeight(), ) : TextStyle( fontStyle: widget.italic ? FontStyle.italic : null, @@ -224,7 +224,7 @@ class _TextsState extends State { fontSize: widget.fontSize ?? _getFontSize(), letterSpacing: widget.variant == "overline" ? 1.5 : null, - fontWeight: _getFontWeight(), + fontWeight: widget.fontWeight?? _getFontWeight(), )), if (widget.readMore && text.length > widget.maxLength && hidden) Positioned(