From e5474b30629a2d655318be6643aa4698a2a8f88b Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 18 Mar 2021 09:58:47 +0200 Subject: [PATCH] fix perscription pages bugs --- lib/config/localized_values.dart | 5 +- .../prescriptions/prescription_report.dart | 230 +++++++++++------- .../widgets/AppointmentActions.dart | 23 +- .../widgets/reminder_dialog.dart | 26 +- .../pharmacy_for_prescriptions_page.dart | 2 +- .../prescription_details_page.dart | 168 ++++++++++--- .../pharmacyAddresses/PharmacyAddresses.dart | 2 +- lib/uitl/translations_delegate_base.dart | 1 + 8 files changed, 321 insertions(+), 136 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 78a4fa8b..1670930c 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -643,8 +643,8 @@ const Map localizedValues = { "Remarks": {"en": "Remarks", "ar": "ملاحضات"}, "ActiveMedications": {"en": "Active Medications", "ar": "ادويتي النشطة"}, "ExpDate": {"en": "Active Exp Date :", "VA": "تاريخ الإنتهاء"}, - "Route": {"en": "Route :", "ar": "الطريقة"}, - "Frequency": {"en": "Frequency :", "ar": "المعدل"}, + "Route": {"en": "Route", "ar": "الطريقة"}, + "Frequency": {"en": "Frequency", "ar": "المعدل"}, "DailyQuantity": {"en": "Daily Quantity :", "ar": "جرعات يومية"}, "AddReminder": {"en": "Add Reminder", "ar": "إضافة تذكير"}, "reminderDes": { @@ -1084,6 +1084,7 @@ const Map localizedValues = { "Average": {"en": "Average", "ar": "المعدل"}, "DailyDoses": {"en": "Daily Doses", "ar": "جرعات يومية"}, "Period": {"en": "Period", "ar": "الفترة"}, + "duration": {"en": "Duration", "ar": "المدة"}, "cm": {"en": "CM", "ar": "سم"}, "ft": {"en": "ft", "ar": "قدم"}, "kg": {"en": "kg", "ar": "كجم"}, diff --git a/lib/core/model/prescriptions/prescription_report.dart b/lib/core/model/prescriptions/prescription_report.dart index 51f5750f..8c18df62 100644 --- a/lib/core/model/prescriptions/prescription_report.dart +++ b/lib/core/model/prescriptions/prescription_report.dart @@ -1,127 +1,193 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; class PrescriptionReport { + String address; + int appointmentNo; + String clinic; + String companyName; + int days; + String doctorName; + var doseDailyQuantity; + String frequency; + int frequencyNumber; + String image; + String imageExtension; + String imageSRCUrl; + String imageString; + String imageThumbUrl; + String isCovered; + String itemDescription; + int itemID; + String orderDate; int patientID; String patientName; + String phoneOffice1; + String prescriptionQR; + int prescriptionTimes; + String productImage; + String productImageBase64; + String productImageString; + int projectID; + String projectName; + String remarks; + String route; + String sKU; + int scaleOffset; + String startDate; + String patientAge; String patientGender; - String address; String phoneOffice; - String itemDescription; int doseTimingID; int frequencyID; int routeID; - String clinic; - String doctorName; - String route; - String frequency; - String remarks; String name; - int days; - String startDate; - String orderDate; - int doseDailyQuantity; - int itemID; - Null productImage; - String sKU; String itemDescriptionN; String routeN; String frequencyN; - String imageSRCUrl; - String imageThumbUrl; - PrescriptionReport( - {this.patientID, - this.patientName, - this.patientAge, - this.patientGender, - this.address, - this.phoneOffice, - this.itemDescription, - this.doseTimingID, - this.frequencyID, - this.routeID, - this.clinic, - this.doctorName, - this.route, - this.frequency, - this.remarks, - this.name, - this.days, - this.startDate, - this.orderDate, - this.doseDailyQuantity, - this.itemID, - this.productImage, - this.sKU, - this.itemDescriptionN, - this.routeN, - this.frequencyN, - this.imageSRCUrl, - this.imageThumbUrl}); + PrescriptionReport({ + 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, + this.patientAge, + this.patientGender, + this.phoneOffice, + this.doseTimingID, + this.frequencyID, + this.routeID, + this.name, + this.itemDescriptionN, + this.routeN, + this.frequencyN, + }); PrescriptionReport.fromJson(Map json) { - patientID = json['PatientID']; - patientName = json['PatientName']; - patientAge = json['PatientAge']; - patientGender = json['PatientGender']; address = json['Address']; - phoneOffice = json['PhoneOffice']; - itemDescription = json['ItemDescription']; - doseTimingID = json['DoseTimingID']; - frequencyID = json['FrequencyID']; - routeID = json['RouteID']; + appointmentNo = json['AppointmentNo']; clinic = json['Clinic']; - doctorName = json['DoctorName']; - route = json['Route']; - frequency = json['Frequency']; - remarks = json['Remarks']; - name = json['Name']; + companyName = json['CompanyName']; days = json['Days']; - startDate = json['StartDate']; - orderDate = json['OrderDate']; + 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']; - itemDescriptionN = json['ItemDescriptionN']; - routeN = json['RouteN']; - frequencyN = json['FrequencyN']; - imageSRCUrl = json['ImageSRCUrl']; - imageThumbUrl = json['ImageThumbUrl']; + scaleOffset = json['ScaleOffset']; + startDate = json['StartDate']; + + patientAge = json['patientAge']; + patientGender = json['patientGender']; + phoneOffice = json['phoneOffice']; + doseTimingID = json['doseTimingID']; + frequencyID = json['frequencyID']; + routeID = json['routeID']; + name = json['name']; + itemDescriptionN = json['itemDescriptionN']; + routeN = json['routeN']; + frequencyN = json['frequencyN']; } 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; + data['PatientAge'] = this.patientAge; data['PatientGender'] = this.patientGender; - data['Address'] = this.address; data['PhoneOffice'] = this.phoneOffice; - data['ItemDescription'] = this.itemDescription; data['DoseTimingID'] = this.doseTimingID; data['FrequencyID'] = this.frequencyID; data['RouteID'] = this.routeID; - data['Clinic'] = this.clinic; - data['DoctorName'] = this.doctorName; - data['Route'] = this.route; - data['Frequency'] = this.frequency; - data['Remarks'] = this.remarks; data['Name'] = this.name; - data['Days'] = this.days; - data['StartDate'] = this.startDate; - data['OrderDate'] = this.orderDate; - data['DoseDailyQuantity'] = this.doseDailyQuantity; - data['ItemID'] = this.itemID; - data['ProductImage'] = this.productImage; - data['SKU'] = this.sKU; data['ItemDescriptionN'] = this.itemDescriptionN; data['RouteN'] = this.routeN; data['FrequencyN'] = this.frequencyN; - data['ImageSRCUrl'] = this.imageSRCUrl; - data['ImageThumbUrl'] = this.imageThumbUrl; data['hasPlan'] = false; + return data; } } diff --git a/lib/pages/MyAppointments/widgets/AppointmentActions.dart b/lib/pages/MyAppointments/widgets/AppointmentActions.dart index 51eefe1a..b335c740 100644 --- a/lib/pages/MyAppointments/widgets/AppointmentActions.dart +++ b/lib/pages/MyAppointments/widgets/AppointmentActions.dart @@ -509,8 +509,7 @@ class _AppointmentActionsState extends State { Navigator.push( context, FadePage( - page: - LaboratoryResultPage(patientLabOrders: patientLabOrders))) + page: LaboratoryResultPage(patientLabOrders: patientLabOrders))) .then((value) {}); } @@ -518,8 +517,7 @@ class _AppointmentActionsState extends State { Navigator.push( context, FadePage( - page: - RadiologyDetailsPage(finalRadiology: finalRadiology))) + page: RadiologyDetailsPage(finalRadiology: finalRadiology))) .then((value) {}); } @@ -542,7 +540,17 @@ class _AppointmentActionsState extends State { transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0), child: Opacity( opacity: a1.value, - child: ReminderDialog(appo: appo), + child: ReminderDialog( + eventId: appo.appointmentNo.toString(), + title: "Doctor Appointment", + description: "You have an appointment with " + + appo.doctorTitle + + " " + + appo.doctorNameObj, + startDate: appo.appointmentDate, + endDate: appo.appointmentDate, + location: appo.projectName, + ), ), ); }, @@ -668,7 +676,10 @@ class _AppointmentActionsState extends State { context, FadePage( page: VitalSignDetailsScreen( - appointmentNo: appoNo, projectID: projectID,isNotOneAppointment: false,))); + appointmentNo: appoNo, + projectID: projectID, + isNotOneAppointment: false, + ))); } navigateToInsertComplaint() { diff --git a/lib/pages/MyAppointments/widgets/reminder_dialog.dart b/lib/pages/MyAppointments/widgets/reminder_dialog.dart index b8803469..0db8cda4 100644 --- a/lib/pages/MyAppointments/widgets/reminder_dialog.dart +++ b/lib/pages/MyAppointments/widgets/reminder_dialog.dart @@ -9,9 +9,14 @@ import 'package:manage_calendar_events/manage_calendar_events.dart'; class ReminderDialog extends StatefulWidget { static var selectedDuration; - AppoitmentAllHistoryResultList appo; + final String eventId; + final String title; + final String description; + final String startDate; + final String endDate; + final String location; - ReminderDialog({@required this.appo}); + ReminderDialog({@required this.eventId, @required this.title, @required this.description, @required this.startDate, @required this.endDate, @required this.location}); @override _ReminderDialogState createState() => _ReminderDialogState(); @@ -98,17 +103,14 @@ class _ReminderDialogState extends State { }); CalendarEvent calendarEvent = new CalendarEvent( - eventId: widget.appo.appointmentNo.toString(), - title: "Doctor Appointment", - description: "You have an appointment with " + - widget.appo.doctorTitle + - " " + - widget.appo.doctorNameObj, - startDate: DateUtil.convertStringToDate(widget.appo.appointmentDate) + eventId: widget.eventId, + title: widget.title, + description: widget.description, + startDate: DateUtil.convertStringToDate(widget.startDate) .subtract( new Duration(microseconds: ReminderDialog.selectedDuration)), - endDate: DateUtil.convertStringToDate(widget.appo.appointmentDate), - location: widget.appo.projectName, + endDate: DateUtil.convertStringToDate(widget.endDate), + location: widget.location, duration: new Duration(minutes: 15).inMinutes, isAllDay: false, hasAlarm: true); @@ -118,7 +120,7 @@ class _ReminderDialogState extends State { .then((value) { print("Cal event"); print(value); - if (int.parse(value) == widget.appo.appointmentNo) { + if (int.parse(value) == int.parse(widget.eventId)) { AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess); } Navigator.of(context).pop(); diff --git a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart index 1b1eaf3f..96227fba 100644 --- a/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart +++ b/lib/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart @@ -20,7 +20,7 @@ class PharmacyForPrescriptionsPage extends StatelessWidget { onModelReady: (model) => model.getListPharmacyForPrescriptions(itemId: prescriptionReport.itemID), builder: (_, model, widget) => AppScaffold( isShowAppBar: true, - appBarTitle: TranslationBase.of(context).ports, + appBarTitle: TranslationBase.of(context).availability, baseViewModel: model, body: ListView.builder( itemBuilder: (context, index) => Container( diff --git a/lib/pages/medical/prescriptions/prescription_details_page.dart b/lib/pages/medical/prescriptions/prescription_details_page.dart index d59bc06d..f40999c2 100644 --- a/lib/pages/medical/prescriptions/prescription_details_page.dart +++ b/lib/pages/medical/prescriptions/prescription_details_page.dart @@ -1,4 +1,6 @@ import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -6,6 +8,7 @@ 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'; +import 'package:provider/provider.dart'; class PrescriptionDetailsPage extends StatelessWidget { final PrescriptionReport prescriptionReport; @@ -59,40 +62,49 @@ class PrescriptionDetailsPage extends StatelessWidget { ), Container( margin: EdgeInsets.all(8), - child: InkWell( - 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), + child: Row( + children: [ + Expanded( + child: InkWell( + onTap: () => Navigator.push( + context, + FadePage( + page: PharmacyForPrescriptionsPage( + prescriptionReport: prescriptionReport), + ), + ), + child: Center( child: Column( children: [ - Icon( - Icons.pin_drop, - color: Colors.red[800], - size: 55, + Container( + width: 50, + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.rectangle), + child: Column( + children: [ + Icon( + Icons.pin_drop, + color: Colors.red[800], + size: 55, + ), + ], + ), + ), + SizedBox( + height: 5, ), + Texts(TranslationBase.of(context).availability) ], ), - ), - SizedBox( - height: 5, - ), - Texts(TranslationBase.of(context).ports) - ], - ), - )), + )), + ), + _addReminderButton(context) + ], + ), ), Container( + color: Colors.white, margin: EdgeInsets.only(top: 10, left: 10, right: 10), child: Table( border: TableBorder.symmetric( @@ -106,28 +118,28 @@ class PrescriptionDetailsPage extends StatelessWidget { height: 30, width: double.infinity, child: Center( - child: Texts(TranslationBase.of(context).way))), + child: Texts(TranslationBase.of(context).route, fontSize: 14,))), Container( color: Colors.white, height: 30, width: double.infinity, child: Center( child: - Texts(TranslationBase.of(context).average))), + Texts(TranslationBase.of(context).frequency, fontSize: 14,))), Container( color: Colors.white, - height: 30, width: double.infinity, + padding: EdgeInsets.symmetric(horizontal: 4), child: Center( child: Texts( - TranslationBase.of(context).dailyDoses))), + "${TranslationBase.of(context).dailyDoses}", fontSize: 14,))), Container( color: Colors.white, height: 30, width: double.infinity, child: Center( child: - Texts(TranslationBase.of(context).period))), + Texts(TranslationBase.of(context).duration, fontSize: 14,))), ], ), TableRow( @@ -192,4 +204,96 @@ class PrescriptionDetailsPage extends StatelessWidget { ), ); } + + Widget _addReminderButton(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + + return GestureDetector( + onTap: () { + DateTime startDate = DateTime.now(); + DateTime endDate = DateTime(startDate.year, startDate.month, + startDate.day + prescriptionReport.days); + + print(prescriptionReport); + showGeneralDialog( + barrierColor: Colors.black.withOpacity(0.5), + transitionBuilder: (context, a1, a2, widget) { + final curvedValue = + Curves.easeInOutBack.transform(a1.value) - 1.0; + return Transform( + transform: + Matrix4.translationValues(0.0, curvedValue * 200, 0.0), + child: Opacity( + opacity: a1.value, + child: ReminderDialog( + eventId: prescriptionReport.itemID.toString(), + title: "Prescription Reminder", + description: + "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ", + startDate: + "/Date(${startDate.millisecondsSinceEpoch}+0300)/", + endDate: "/Date(${endDate.millisecondsSinceEpoch}+0300)/", + location: prescriptionReport.remarks, + ), + ), + ); + }, + transitionDuration: Duration(milliseconds: 500), + barrierDismissible: true, + barrierLabel: '', + context: context, + pageBuilder: (context, animation1, animation2) {}); + }, + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + Container( + // height: 100.0, + margin: EdgeInsets.all(7.0), + padding: EdgeInsets.only(bottom: 4.0), + decoration: BoxDecoration(boxShadow: [ + BoxShadow( + color: Colors.grey[400], blurRadius: 2.0, spreadRadius: 0.0) + ], borderRadius: BorderRadius.circular(10), color: Colors.white), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + margin: EdgeInsets.fromLTRB(5.0, 5.0, 5.0, 0.0), + child: Text("add", + overflow: TextOverflow.clip, + style: TextStyle( + color: new Color(0xffB8382C), + letterSpacing: 1.0, + fontSize: 18.0)), + ), + Container( + margin: EdgeInsets.fromLTRB(5.0, 0.0, 5.0, 0.0), + child: Text("reminder", + overflow: TextOverflow.clip, + style: TextStyle( + color: Colors.black, + letterSpacing: 1.0, + fontSize: 15.0)), + ), + Container( + alignment: projectViewModel.isArabic + ? Alignment.bottomLeft + : Alignment.bottomRight, + margin: projectViewModel.isArabic + ? EdgeInsets.fromLTRB(10.0, 7.0, 0.0, 8.0) + : EdgeInsets.fromLTRB(0.0, 7.0, 10.0, 8.0), + child: Image.asset( + "assets/images/new-design/reminder_icon.png", + width: 45.0, + height: 45.0), + ), + ], + ), + ), + ], + ), + ); + } } diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 340e2bd8..51256e11 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -104,7 +104,7 @@ class _PharmacyAddressesState extends State { fontWeight: FontWeight.bold, backgroundColor: Color(0xFF5AB145), fontSize: 14, - vPadding: 12, + vPadding: 8, handler: () { model.saveSelectedAddressLocally( model.addresses[model.selectedAddressIndex]); diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index a90f8614..74922edc 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -985,6 +985,7 @@ class TranslationBase { String get average => localizedValues['Average'][locale.languageCode]; String get dailyDoses => localizedValues['DailyDoses'][locale.languageCode]; String get period => localizedValues['Period'][locale.languageCode]; + String get duration => localizedValues['duration'][locale.languageCode]; String get cm => localizedValues['cm'][locale.languageCode]; String get kg => localizedValues['kg'][locale.languageCode]; String get lb => localizedValues['lb'][locale.languageCode];