|
|
|
|
@ -6,6 +6,8 @@ import 'package:diplomaticquarterapp/models/header_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/reminder_dialog.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog_prescription.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/medical/prescriptions/pharmacy_for_prescriptions_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/LocalNotification.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
@ -18,6 +20,7 @@ import 'package:diplomaticquarterapp/widgets/show_zoom_image_dialog.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:jiffy/jiffy.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
@ -32,7 +35,6 @@ class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
showNewAppBar: true,
|
|
|
|
|
backgroundColor: Color(0xffF8F8F8),
|
|
|
|
|
showNewAppBarTitle: true,
|
|
|
|
|
appBarTitle: TranslationBase.of(context).prescriptions,
|
|
|
|
|
body: Column(
|
|
|
|
|
@ -212,34 +214,11 @@ class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
onSuccess: () {
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
},
|
|
|
|
|
onMultiDateSuccess: (int selectedIndex) {
|
|
|
|
|
setCalender(context, prescriptionReport.itemID.toString(), selectedIndex);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
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: PrescriptionReminderDialog(
|
|
|
|
|
eventId: prescriptionReport.itemID.toString(),
|
|
|
|
|
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
|
|
|
|
|
startDate: startDate,
|
|
|
|
|
endDate: endDate,
|
|
|
|
|
location: prescriptionReport.remarks,
|
|
|
|
|
days: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
transitionDuration: Duration(milliseconds: 500),
|
|
|
|
|
barrierDismissible: true,
|
|
|
|
|
barrierLabel: '',
|
|
|
|
|
context: context,
|
|
|
|
|
pageBuilder: (context, animation1, animation2) {});
|
|
|
|
|
},
|
|
|
|
|
iconData: Icons.notifications_active,
|
|
|
|
|
color: Color(0xffD02127),
|
|
|
|
|
@ -253,4 +232,75 @@ class PrescriptionDetailsPage extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setCalender(BuildContext context, String eventId, int reminderIndex) async {
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
DateTime startDate = DateUtil.convertStringToDate(prescriptionReport.startDate);
|
|
|
|
|
DateTime actualDate = DateTime(startDate.year, startDate.month, startDate.day, 8, 0); //Time will start at 8:00 AM from starting date
|
|
|
|
|
if (prescriptionReport?.frequencyNumber == null) prescriptionReport.frequencyNumber = 2; //Some time frequency number is null so by default will be 2
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < prescriptionReport.days; i++) {
|
|
|
|
|
//event for number of days.
|
|
|
|
|
for (int j = 0; j < prescriptionReport.frequencyNumber ?? 2; j++) {
|
|
|
|
|
// event for number of times per day.
|
|
|
|
|
|
|
|
|
|
if (j != 0) {
|
|
|
|
|
actualDate.add(new Duration(hours: 8)); // 8 hours addition for daily dose.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Time subtraction from actual reminder time. like before 30, or 1 hour.
|
|
|
|
|
if (reminderIndex == 0) {
|
|
|
|
|
// Before 30 mints
|
|
|
|
|
actualDate = Jiffy(actualDate).subtract(minutes: 30);
|
|
|
|
|
// dateTime.add(new Duration(minutes: -30));
|
|
|
|
|
} else if (reminderIndex == 1) {
|
|
|
|
|
// Before 1 hour
|
|
|
|
|
// dateTime.add(new Duration(minutes: -60));
|
|
|
|
|
actualDate = Jiffy(actualDate).subtract(hours: 1);
|
|
|
|
|
} else if (reminderIndex == 2) {
|
|
|
|
|
// Before 1 hour and 30 mints
|
|
|
|
|
// dateTime.add(new Duration(minutes: -90));
|
|
|
|
|
actualDate = Jiffy(actualDate).subtract(hours: 1, minutes: 30);
|
|
|
|
|
} else if (reminderIndex == 3) {
|
|
|
|
|
// Before 2 hours
|
|
|
|
|
// dateTime.add(new Duration(minutes: -120));
|
|
|
|
|
actualDate = Jiffy(actualDate).subtract(hours: 2);
|
|
|
|
|
}
|
|
|
|
|
calendarUtils
|
|
|
|
|
.createOrUpdateEvent(
|
|
|
|
|
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
|
|
|
|
|
scheduleDateTime: actualDate,
|
|
|
|
|
eventId: eventId + (i.toString() + j.toString()), //event id with varitions
|
|
|
|
|
)
|
|
|
|
|
.then(
|
|
|
|
|
(value) {},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
actualDate.add(new Duration(days: i + 1));
|
|
|
|
|
}
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//schedual local notifications
|
|
|
|
|
// setTheNotificatoin(BuildContext context) {
|
|
|
|
|
// DateTime startDate = DateUtil.convertStringToDate(prescriptionReport.startDate);
|
|
|
|
|
// DateTime actualDate = DateTime(startDate.year, startDate.month, startDate.day, 8, 0);
|
|
|
|
|
// if (prescriptionReport?.frequencyNumber == null) prescriptionReport.frequencyNumber = 2;
|
|
|
|
|
//
|
|
|
|
|
// for (int i = 0; i < prescriptionReport.days; i++) {
|
|
|
|
|
// for (int j = 0; j < prescriptionReport.frequencyNumber ?? 2; j++) {
|
|
|
|
|
// if (j != 0) {
|
|
|
|
|
// actualDate.add(new Duration(hours: 8));
|
|
|
|
|
// }
|
|
|
|
|
// LocalNotification.getInstance().scheduleNotification(
|
|
|
|
|
// scheduledNotificationDateTime: actualDate,
|
|
|
|
|
// title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
// description: "${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ");
|
|
|
|
|
// }
|
|
|
|
|
// actualDate.add(new Duration(days: i + 1));
|
|
|
|
|
// }
|
|
|
|
|
// AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|