Merge branch 'blood_pressure' into 'development'

fix prescription add reminder

See merge request Cloud_Solution/diplomatic-quarter!363
merge-requests/365/merge
Mohammad Aljammal 3 years ago
commit db128e5091

@ -1,6 +1,7 @@
import 'package:diplomaticquarterapp/pages/MyAppointments/models/AskDocRequestTypeModel.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/askDocDialog.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/reminder_dialog_prescription.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
@ -25,18 +26,13 @@ class CustomRadioState extends State<CustomRadio> {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.requestData != null) {
widget.requestData.forEach((element) {
sampleData.add(new RadioModel(
false, element.description, element.parameterCode));
sampleData.add(new RadioModel(false, element.description, element.parameterCode));
});
} else {
sampleData.add(new RadioModel(
false, TranslationBase.of(context).appoReminder30, 30));
sampleData.add(new RadioModel(
false, TranslationBase.of(context).appoReminder60, 60));
sampleData.add(new RadioModel(
false, TranslationBase.of(context).appoReminder90, 90));
sampleData.add(new RadioModel(
false, TranslationBase.of(context).appoReminder120, 120));
sampleData.add(new RadioModel(false, TranslationBase.of(context).appoReminder30, 30));
sampleData.add(new RadioModel(false, TranslationBase.of(context).appoReminder60, 60));
sampleData.add(new RadioModel(false, TranslationBase.of(context).appoReminder90, 90));
sampleData.add(new RadioModel(false, TranslationBase.of(context).appoReminder120, 120));
}
});
}
@ -57,12 +53,11 @@ class CustomRadioState extends State<CustomRadio> {
sampleData.forEach((element) => element.isSelected = false);
sampleData[index].isSelected = true;
if (widget.requestData != null) {
AskDocDialog.selectedParameterCode =
sampleData[index].duration;
AskDocDialog.selectedParameterCode = sampleData[index].duration;
print(AskDocDialog.selectedParameterCode);
} else {
ReminderDialog.selectedDuration =
sampleData[index].duration * 60000;
ReminderDialog.selectedDuration = sampleData[index].duration * 60000;
PrescriptionReminderDialog.selectedDuration = sampleData[index].duration * 60000;
}
});
},
@ -91,14 +86,11 @@ class RadioItem extends StatelessWidget {
height: 30.0,
width: 30.0,
child: new Center(
child: Image.asset("assets/images/new-design/check_icon.png",
width: 15.0, height: 15.0),
child: Image.asset("assets/images/new-design/check_icon.png", width: 15.0, height: 15.0),
),
decoration: new BoxDecoration(
color: _item.isSelected ? Colors.blue : Colors.transparent,
border: new Border.all(
width: 1.0,
color: _item.isSelected ? Colors.blue : Colors.grey),
border: new Border.all(width: 1.0, color: _item.isSelected ? Colors.blue : Colors.grey),
borderRadius: const BorderRadius.all(const Radius.circular(50.0)),
),
),

@ -1,5 +1,6 @@
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/custom_radio.dart';
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -16,7 +17,13 @@ class ReminderDialog extends StatefulWidget {
final String endDate;
final String location;
ReminderDialog({@required this.eventId, @required this.title, @required this.description, @required this.startDate, @required this.endDate, @required this.location});
ReminderDialog(
{@required this.eventId,
@required this.title,
@required this.description,
@required this.startDate,
@required this.endDate,
@required this.location});
@override
_ReminderDialogState createState() => _ReminderDialogState();
@ -29,65 +36,54 @@ class _ReminderDialogState extends State<ReminderDialog> {
Widget build(BuildContext context) {
return Container(
child: Dialog(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
child: Container(
// height: MediaQuery.of(context).size.height * 0.57,
width: 450.0,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
margin: EdgeInsets.all(20.0),
child: Text(TranslationBase.of(context).setReminder,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold)),
),
Container(
transform: Matrix4.translationValues(0.0, -30.0, 0.0),
child: CustomRadio(),
),
Container(
width: MediaQuery.of(context).size.width,
height: 40.0,
margin: EdgeInsets.only(left: 30.0, top: 0.0, right: 30.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
side: BorderSide(color: Colors.blue)),
color: Colors.blue,
onPressed: () {
print(ReminderDialog.selectedDuration);
createCalendarEvent();
},
child: Text(TranslationBase.of(context).confirm,
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold)),
),
),
Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.only(left: 100.0, top: 20.0, right: 100.0, bottom: 20.0),
child: OutlineButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
color: Colors.red,
borderSide: BorderSide(color: Colors.red),
highlightColor: Colors.red,
highlightedBorderColor: Colors.red,
onPressed: () {
Navigator.of(context).pop();
},
child: Text(TranslationBase.of(context).cancel_nocaps,
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold)),
),
),
]),
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[
Container(
margin: EdgeInsets.all(20.0),
child: Text(TranslationBase.of(context).setReminder,
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
Container(
transform: Matrix4.translationValues(0.0, -30.0, 0.0),
child: CustomRadio(),
),
Container(
width: MediaQuery.of(context).size.width,
height: 40.0,
margin: EdgeInsets.only(left: 30.0, top: 0.0, right: 30.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0), side: BorderSide(color: Colors.blue)),
color: Colors.blue,
onPressed: () {
print(ReminderDialog.selectedDuration);
createCalendarEvent();
},
child: Text(TranslationBase.of(context).confirm,
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
),
),
Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.only(left: 100.0, top: 20.0, right: 100.0, bottom: 20.0),
child: OutlineButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
color: Colors.red,
borderSide: BorderSide(color: Colors.red),
highlightColor: Colors.red,
highlightedBorderColor: Colors.red,
onPressed: () {
Navigator.of(context).pop();
},
child: Text(TranslationBase.of(context).cancel_nocaps,
style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold)),
),
),
]),
),
),
);
@ -107,17 +103,14 @@ class _ReminderDialogState extends State<ReminderDialog> {
title: widget.title,
description: widget.description,
startDate: DateUtil.convertStringToDate(widget.startDate)
.subtract(
new Duration(microseconds: ReminderDialog.selectedDuration)),
.subtract(new Duration(microseconds: ReminderDialog.selectedDuration)),
endDate: DateUtil.convertStringToDate(widget.endDate),
location: widget.location,
duration: new Duration(minutes: 15).inMinutes,
isAllDay: false,
hasAlarm: true);
_myPlugin
.createEvent(calendarId: "207749556", event: calendarEvent)
.then((value) {
_myPlugin.createEvent(calendarId: "207749556", event: calendarEvent).then((value) {
print("Cal event");
print(value);
if (int.parse(value) == int.parse(widget.eventId)) {

@ -0,0 +1,127 @@
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/pages/MyAppointments/widgets/custom_radio.dart';
import 'package:diplomaticquarterapp/uitl/CalendarUtils.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
import 'package:manage_calendar_events/manage_calendar_events.dart';
class PrescriptionReminderDialog extends StatefulWidget {
static var selectedDuration;
final String eventId;
final String title;
final String description;
final DateTime startDate;
final DateTime endDate;
final String location;
final int days;
List<DateTime> _scheduleList = List();
PrescriptionReminderDialog({
@required this.eventId,
@required this.title,
@required this.description,
@required this.startDate,
@required this.endDate,
@required this.location,
@required this.days,
});
@override
_ReminderDialogState createState() => _ReminderDialogState();
}
class _ReminderDialogState extends State<PrescriptionReminderDialog> {
final CalendarPlugin _myPlugin = CalendarPlugin();
@override
Widget build(BuildContext context) {
return Container(
child: Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
child: Container(
// height: MediaQuery.of(context).size.height * 0.57,
width: 450.0,
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: <Widget>[
Container(
margin: EdgeInsets.all(20.0),
child: Text(TranslationBase.of(context).setReminder,
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold)),
),
Container(
transform: Matrix4.translationValues(0.0, -30.0, 0.0),
child: CustomRadio(),
),
Container(
width: MediaQuery.of(context).size.width,
height: 40.0,
margin: EdgeInsets.only(left: 30.0, top: 0.0, right: 30.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0), side: BorderSide(color: Colors.blue)),
color: Colors.blue,
onPressed: () {
createOrUpdateEvents();
},
child: Text(TranslationBase.of(context).confirm,
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold)),
),
),
Container(
width: MediaQuery.of(context).size.width,
margin: EdgeInsets.only(left: 100.0, top: 20.0, right: 100.0, bottom: 20.0),
child: OutlineButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
color: Colors.red,
borderSide: BorderSide(color: Colors.red),
highlightColor: Colors.red,
highlightedBorderColor: Colors.red,
onPressed: () {
Navigator.of(context).pop();
},
child: Text(TranslationBase.of(context).cancel_nocaps,
style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold)),
),
),
]),
),
),
);
}
createOrUpdateEvents() async {
Navigator.pop(context);
for (int count = 0; count < widget.days; count++) {
widget._scheduleList.add(DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day));
}
List<DateTime> scheduleDateTime = calculateDaysInterval(
widget.startDate.subtract(new Duration(microseconds: PrescriptionReminderDialog.selectedDuration)),
widget.endDate);
CalendarUtils calendarUtils = await CalendarUtils.getInstance();
calendarUtils.createOrUpdateEvents(
scheduleList: widget._scheduleList,
description: widget.description,
title: widget.title,
scheduleDateTime: scheduleDateTime);
AppToast.showSuccessToast(message: TranslationBase.of(context).reminderSuccess);
}
List<DateTime> calculateDaysInterval(DateTime startDate, DateTime endDate) {
List<DateTime> days = [];
for (int i = 0; i <= endDate.difference(startDate).inDays; i++) {
widget._scheduleList.forEach((element) {
days.add(startDate.add(Duration(days: i, hours: element.hour, minutes: element.minute)));
});
}
return days;
}
}

@ -1,6 +1,7 @@
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/MyAppointments/widgets/reminder_dialog_prescription.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';
@ -223,14 +224,15 @@ class PrescriptionDetailsPage extends StatelessWidget {
transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0),
child: Opacity(
opacity: a1.value,
child: ReminderDialog(
child: PrescriptionReminderDialog(
eventId: prescriptionReport.itemID.toString(),
title: "Prescription Reminder",
title: "${prescriptionReport.itemDescriptionN} Prescription Reminder",
description:
"${prescriptionReport.itemDescriptionN} ${prescriptionReport.frequencyN} ${prescriptionReport.routeN} ",
startDate: "/Date(${startDate.millisecondsSinceEpoch}+0300)/",
endDate: "/Date(${endDate.millisecondsSinceEpoch}+0300)/",
startDate: startDate,
endDate: endDate,
location: prescriptionReport.remarks,
days: 1,
),
),
);

Loading…
Cancel
Save