|
|
|
|
@ -27,10 +27,10 @@ import 'package:jiffy/jiffy.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class PrescriptionDetailsPage extends StatefulWidget {
|
|
|
|
|
final PrescriptionReport prescriptionReport;
|
|
|
|
|
final PrescriptionReport? prescriptionReport;
|
|
|
|
|
final Prescriptions prescriptions;
|
|
|
|
|
|
|
|
|
|
PrescriptionDetailsPage({Key key, this.prescriptionReport, this.prescriptions});
|
|
|
|
|
PrescriptionDetailsPage({Key? key, this.prescriptionReport, required this.prescriptions});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_PrescriptionDetailsPageState createState() => _PrescriptionDetailsPageState();
|
|
|
|
|
@ -38,7 +38,7 @@ class PrescriptionDetailsPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
bool hasReminder = false;
|
|
|
|
|
LocationUtils locationUtils;
|
|
|
|
|
late LocationUtils locationUtils;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
@ -61,15 +61,15 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
DoctorHeader(
|
|
|
|
|
headerModel: HeaderModel(
|
|
|
|
|
widget.prescriptions.doctorName,
|
|
|
|
|
widget.prescriptions.doctorID,
|
|
|
|
|
widget.prescriptions.doctorImageURL,
|
|
|
|
|
widget.prescriptions.speciality,
|
|
|
|
|
widget.prescriptions.doctorName!,
|
|
|
|
|
widget.prescriptions.doctorID!,
|
|
|
|
|
widget.prescriptions.doctorImageURL!,
|
|
|
|
|
widget.prescriptions.speciality!,
|
|
|
|
|
"",
|
|
|
|
|
widget.prescriptions.name,
|
|
|
|
|
DateUtil.convertStringToDate(widget.prescriptions.appointmentDate),
|
|
|
|
|
DateUtil.formatDateToTime(DateUtil.convertStringToDate(widget.prescriptions.appointmentDate)),
|
|
|
|
|
widget.prescriptions.nationalityFlagURL,
|
|
|
|
|
widget.prescriptions.name!,
|
|
|
|
|
DateUtil.convertStringToDate(widget.prescriptions.appointmentDate!),
|
|
|
|
|
DateUtil.formatDateToTime(DateUtil.convertStringToDate(widget.prescriptions.appointmentDate!)),
|
|
|
|
|
widget.prescriptions.nationalityFlagURL!,
|
|
|
|
|
widget.prescriptions.doctorRate,
|
|
|
|
|
widget.prescriptions.actualDoctorRate,
|
|
|
|
|
widget.prescriptions.noOfPatientsRate,
|
|
|
|
|
@ -135,7 +135,7 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
// SizedBox(width: 12),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
(widget.prescriptionReport.itemDescription.isNotEmpty ? widget.prescriptionReport.itemDescription : widget.prescriptionReport.itemDescriptionN ?? '')
|
|
|
|
|
(widget.prescriptionReport!.itemDescription!.isNotEmpty ? widget.prescriptionReport!.itemDescription : widget.prescriptionReport!.itemDescriptionN ?? '')!
|
|
|
|
|
.toLowerCase()
|
|
|
|
|
.capitalizeFirstofEach,
|
|
|
|
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.64),
|
|
|
|
|
@ -167,7 +167,7 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
widget.prescriptionReport.remarks,
|
|
|
|
|
widget.prescriptionReport!.remarks!,
|
|
|
|
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -190,7 +190,7 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
context,
|
|
|
|
|
FadePage(
|
|
|
|
|
page: PharmacyForPrescriptionsPage(
|
|
|
|
|
itemID: widget.prescriptionReport.itemID,
|
|
|
|
|
itemID: widget.prescriptionReport!.itemID,
|
|
|
|
|
prescriptionReport: widget.prescriptionReport,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -209,21 +209,21 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
cancelReminders();
|
|
|
|
|
} else {
|
|
|
|
|
DateTime startDate = DateTime.now();
|
|
|
|
|
DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + widget.prescriptionReport.days);
|
|
|
|
|
DateTime endDate = DateTime(startDate.year, startDate.month, startDate.day + widget.prescriptionReport!.days!);
|
|
|
|
|
showReminderDialog(
|
|
|
|
|
context,
|
|
|
|
|
endDate,
|
|
|
|
|
"",
|
|
|
|
|
widget.prescriptionReport.itemID.toString(),
|
|
|
|
|
widget.prescriptionReport!.itemID.toString(),
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
title: "${widget.prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${widget.prescriptionReport.itemDescriptionN} ${widget.prescriptionReport.frequencyN} ${widget.prescriptionReport.routeN} ",
|
|
|
|
|
title: "${widget.prescriptionReport!.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${widget.prescriptionReport!.itemDescriptionN} ${widget.prescriptionReport!.frequencyN} ${widget.prescriptionReport!.routeN} ",
|
|
|
|
|
onSuccess: () {
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
},
|
|
|
|
|
onMultiDateSuccess: (int selectedIndex) {
|
|
|
|
|
setCalender(context, widget.prescriptionReport.itemID.toString(), selectedIndex);
|
|
|
|
|
setCalender(context, widget.prescriptionReport!.itemID.toString(), selectedIndex);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
@ -246,16 +246,16 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
checkIfHasReminder() async {
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30).dateTime;
|
|
|
|
|
DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120).dateTime;
|
|
|
|
|
DateTime startEventsDate = Jiffy.parseFromDateTime(DateTime.now()).subtract(days: 30).dateTime;
|
|
|
|
|
DateTime endEventsDate = Jiffy.parseFromDateTime(DateTime.now()).add(days: 120).dateTime;
|
|
|
|
|
|
|
|
|
|
RetrieveEventsParams params = new RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate);
|
|
|
|
|
|
|
|
|
|
if(calendarUtils.calendars != null) {
|
|
|
|
|
await calendarUtils.retrieveEvents(calendarUtils.calendars[0].id, params).then((value) {
|
|
|
|
|
if (calendarUtils.calendars != null) {
|
|
|
|
|
await calendarUtils.retrieveEvents(calendarUtils.calendars[0].id!, params).then((value) {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data.forEach((element) {
|
|
|
|
|
if (element.title.contains(widget.prescriptionReport.itemDescriptionN))
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!))
|
|
|
|
|
setState(() {
|
|
|
|
|
hasReminder = true;
|
|
|
|
|
});
|
|
|
|
|
@ -267,15 +267,15 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
cancelReminders() async {
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
DateTime startEventsDate = Jiffy(DateTime.now()).subtract(days: 30).dateTime;
|
|
|
|
|
DateTime endEventsDate = Jiffy(DateTime.now()).add(days: 120).dateTime;
|
|
|
|
|
DateTime startEventsDate = Jiffy.parseFromDateTime(DateTime.now()).subtract(days: 30).dateTime;
|
|
|
|
|
DateTime endEventsDate = Jiffy.parseFromDateTime(DateTime.now()).add(days: 120).dateTime;
|
|
|
|
|
|
|
|
|
|
RetrieveEventsParams params = new RetrieveEventsParams(startDate: startEventsDate, endDate: endEventsDate);
|
|
|
|
|
|
|
|
|
|
await calendarUtils.retrieveEvents(calendarUtils.calendars[0].id, params).then((value) {
|
|
|
|
|
await calendarUtils.retrieveEvents(calendarUtils.calendars[0].id!, params).then((value) {
|
|
|
|
|
Result<UnmodifiableListView<Event>> events = value;
|
|
|
|
|
events.data.forEach((element) {
|
|
|
|
|
if (element.title.contains(widget.prescriptionReport.itemDescriptionN)) calendarUtils.deleteEvent(calendarUtils.calendars[0], element);
|
|
|
|
|
events.data!.forEach((element) {
|
|
|
|
|
if (element.title!.contains(widget.prescriptionReport!.itemDescriptionN!)) calendarUtils.deleteEvent(calendarUtils.calendars[0], element);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderCancelSuccess);
|
|
|
|
|
@ -288,15 +288,16 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
|
|
|
|
|
|
|
|
|
|
DateTime actualDate = DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, 8, 0); //Time will start at 8:00 AM from starting date
|
|
|
|
|
if (widget.prescriptionReport?.frequencyNumber == null) widget.prescriptionReport.frequencyNumber = 1; //Some time frequency number is null so by default will be 2
|
|
|
|
|
if (widget.prescriptionReport?.frequencyNumber == null) widget.prescriptionReport!.frequencyNumber = 1; //Some time frequency number is null so by default will be 2
|
|
|
|
|
|
|
|
|
|
int remainingDays = widget.prescriptionReport.days - (Jiffy(DateTime.now()).diff(DateUtil.convertStringToDate(widget.prescriptionReport.orderDate), Units.DAY));
|
|
|
|
|
int remainingDays = widget.prescriptionReport!.days! -
|
|
|
|
|
(Jiffy.parseFromDateTime(DateTime.now()).diff(Jiffy.parseFromDateTime(DateUtil.convertStringToDate(widget.prescriptionReport!.orderDate!)), unit: Unit.day) as int);
|
|
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < remainingDays; i++) {
|
|
|
|
|
//event for number of days.
|
|
|
|
|
for (int j = 0; j < widget.prescriptionReport.frequencyNumber ?? 1; j++) {
|
|
|
|
|
for (int j = 0; j < widget.prescriptionReport!.frequencyNumber!; j++) {
|
|
|
|
|
// event for number of times per day.
|
|
|
|
|
if (j != 0) {
|
|
|
|
|
actualDate.add(new Duration(hours: 8)); // 8 hours addition for daily dose.
|
|
|
|
|
@ -304,32 +305,32 @@ class _PrescriptionDetailsPageState extends State<PrescriptionDetailsPage> {
|
|
|
|
|
//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;
|
|
|
|
|
actualDate = Jiffy.parseFromDateTime(actualDate).subtract(minutes: 30).dateTime;
|
|
|
|
|
// 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).dateTime;
|
|
|
|
|
actualDate = Jiffy.parseFromDateTime(actualDate).subtract(hours: 1).dateTime;
|
|
|
|
|
} else if (reminderIndex == 2) {
|
|
|
|
|
// Before 1 hour and 30 mints
|
|
|
|
|
// dateTime.add(new Duration(minutes: -90));
|
|
|
|
|
actualDate = Jiffy(actualDate).subtract(hours: 1, minutes: 30).dateTime;
|
|
|
|
|
actualDate = Jiffy.parseFromDateTime(actualDate).subtract(hours: 1, minutes: 30).dateTime;
|
|
|
|
|
} else if (reminderIndex == 3) {
|
|
|
|
|
// Before 2 hours
|
|
|
|
|
// dateTime.add(new Duration(minutes: -120));
|
|
|
|
|
actualDate = Jiffy(actualDate).subtract(hours: 2).dateTime;
|
|
|
|
|
actualDate = Jiffy.parseFromDateTime(actualDate).subtract(hours: 2).dateTime;
|
|
|
|
|
}
|
|
|
|
|
calendarUtils
|
|
|
|
|
.createOrUpdateEvent(
|
|
|
|
|
title: "${widget.prescriptionReport.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${widget.prescriptionReport.itemDescriptionN} ${widget.prescriptionReport.frequencyN} ${widget.prescriptionReport.routeN} ",
|
|
|
|
|
title: "${widget.prescriptionReport!.itemDescriptionN} Prescription Reminder",
|
|
|
|
|
description: "${widget.prescriptionReport!.itemDescriptionN} ${widget.prescriptionReport!.frequencyN} ${widget.prescriptionReport!.routeN} ",
|
|
|
|
|
scheduleDateTime: actualDate,
|
|
|
|
|
eventId: eventId + (i.toString() + j.toString()), //event id with varitions
|
|
|
|
|
)
|
|
|
|
|
.then((value) {});
|
|
|
|
|
actualDate = DateTime(actualDate.year, actualDate.month, actualDate.day, 8, 0);
|
|
|
|
|
}
|
|
|
|
|
actualDate = Jiffy(actualDate).add(days: 1).dateTime;
|
|
|
|
|
actualDate = Jiffy.parseFromDateTime(actualDate).add(days: 1).dateTime;
|
|
|
|
|
print(actualDate);
|
|
|
|
|
}
|
|
|
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
|
|
|
|
|
|