From 153335538a3a8d52153e08efbafa76004c45a393 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 7 Sep 2020 17:59:58 +0300 Subject: [PATCH] done monthly reports --- lib/config/config.dart | 4 + lib/config/localized_values.dart | 8 + lib/core/service/medical/reports_service.dart | 35 +++- .../medical/reports_monthly_view_model.dart | 58 ++----- lib/main.dart | 2 +- lib/pages/medical/medical_profile_page.dart | 17 +- .../medical/reports/monthly_reports.dart | 153 +++++++++++++++++- .../medical/reports/user_agreement_page.dart | 25 +++ lib/uitl/translations_delegate_base.dart | 11 +- lib/widgets/buttons/secondary_button.dart | 2 +- lib/widgets/input/custom_switch.dart | 2 +- pubspec.yaml | 5 +- 12 files changed, 257 insertions(+), 65 deletions(-) create mode 100644 lib/pages/medical/reports/user_agreement_page.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 0165cb1b..a0bf52be 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -148,6 +148,10 @@ const CANCEL_LIVECARE_REQUEST = const SEND_LIVECARE_INVOICE_EMAIL = 'Services/Notifications.svc/REST/SendInvoiceForLiveCare'; + +const GET_USER_TERMS ='/Services/Patients.svc/REST/GetUserTermsAndConditions'; +const UPDATE_HEALTH_TERMS ='/services/Patients.svc/REST/UpdatePateintHealthSummaryReport'; + //URL to get medicine and pharmacies list const CHANNEL = 3; const GENERAL_ID = 'Cs2020@2016\$2958'; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 696e2665..f50ea02c 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -451,4 +451,12 @@ const Map> localizedValues = { "MonthlyReports": {"en": "Monthly Reports", "ar": "تقارير شهرية"}, "locationDialogMessage": {"en": "Allow the HMG app to access your location will assist you in showing the hospitals according to the nearest to you.", "ar": "السماح لتطبيق مجموعة الحبيب الطبية بالوصول إلى موقعك سيساعدك في إظهار المستشفيات وفقًا للأقرب إليك."}, "km":{"en":"KMs:","ar":"كم"}, + "PatientHealthSummaryReport":{"en":"Patient Health Summary Report","ar":" ملخص التقارير الشهرية"}, + "ToViewTheTermsAndConditions":{"en":"To View The Terms And Conditions Report","ar":" عرض الشروط والأحكام "}, + "ClickHere":{"en":"Click here","ar":"أنقر هنا"}, + "IAgreeToTheTermsAndConditions":{"en":"I agree to the terms and conditions ","ar":"أوافق على الشروط والاحكام "}, + "IAgreeToTheTermsAndConditionsSubtitle":{"en":"I agree to the terms and conditions ","ar":"هذا ملخص التقرير الصحي الشهري و الذي يسرد المؤشرات الصحية و نتائج التحاليل لأخر الزيارات. يرجى ملاحظة أن هذا التقرير هو تقرير يتم ارساله بشكل آلي من النظام و لا يعتبر رسمي و لا تؤخذ عليه أي قرارات طبية"}, + "Save":{"en":"Save","ar":"حفظ "}, + "UserAgreement":{"en":"User Agreement","ar":"اتفاقية الخصوصية "}, + "UpdateSuccessfully":{"en":"Update Successfully","ar":"تم التحديث بنجاح"}, }; diff --git a/lib/core/service/medical/reports_service.dart b/lib/core/service/medical/reports_service.dart index b8e5f426..316872ed 100644 --- a/lib/core/service/medical/reports_service.dart +++ b/lib/core/service/medical/reports_service.dart @@ -7,7 +7,7 @@ import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart'; class ReportsService extends BaseService { List reportsList = List(); List appointHistoryList = List(); - + String userAgreementContent = ""; RequestReports _requestReports = RequestReports( isReport: true, encounterType: 1, @@ -44,7 +44,7 @@ class ReportsService extends BaseService { hasError = false; Map body = new Map(); body['IsForMedicalReport'] = true; - await baseAppClient.post(GET_PATIENT_AppointmentHistory, + await baseAppClient.post(GET_PATIENT_AppointmentHistory, onSuccess: (dynamic response, int statusCode) { appointHistoryList = []; response['AppoimentAllHistoryResultList'].forEach((appoint) { @@ -56,6 +56,33 @@ class ReportsService extends BaseService { }, body: body); } + Future getUserTermsAndConditions() async { + hasError = false; + await baseAppClient.post(GET_USER_TERMS, + onSuccess: (dynamic response, int statusCode) { + userAgreementContent = response['UserAgreementContent']; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: Map()); + } + + + Future updatePatientHealthSummaryReport({bool isSummary}) async { + Map body = Map(); + body['RSummaryReport'] = isSummary; + hasError = false; + await baseAppClient.post(UPDATE_HEALTH_TERMS, + onSuccess: (dynamic response, int statusCode) { + + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + + + Future insertRequestForMedicalReport( AppointmentHistory appointmentHistory) async { Map body = new Map(); @@ -63,7 +90,7 @@ class ReportsService extends BaseService { body['DoctorID'] = appointmentHistory.doctorID; body['SetupID'] = appointmentHistory.setupID; body['EncounterNo'] = appointmentHistory.appointmentNo; - body['EncounterType'] = 1;// appointmentHistory.appointmentType; + body['EncounterType'] = 1; // appointmentHistory.appointmentType; body['IsActive'] = appointmentHistory.isActiveDoctor; body['ProjectID'] = appointmentHistory.projectID; body['Remarks'] = ""; @@ -73,7 +100,7 @@ class ReportsService extends BaseService { body['Status'] = 1; body['CreatedBy'] = 102; hasError = false; - await baseAppClient.post(INSERT_REQUEST_FOR_MEDICAL_REPORT, + await baseAppClient.post(INSERT_REQUEST_FOR_MEDICAL_REPORT, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; diff --git a/lib/core/viewModels/medical/reports_monthly_view_model.dart b/lib/core/viewModels/medical/reports_monthly_view_model.dart index 2e5952ae..3ae196f5 100644 --- a/lib/core/viewModels/medical/reports_monthly_view_model.dart +++ b/lib/core/viewModels/medical/reports_monthly_view_model.dart @@ -13,72 +13,34 @@ class ReportsMonthlyViewModel extends BaseViewModel { ReportsService _reportsService = locator(); - List reportsOrderRequestList = List(); - List reportsOrderReadyList = List(); - List reportsOrderCompletedList = List(); - List reportsOrderCanceledList = List(); - List get appointHistoryList => - _reportsService.appointHistoryList; - getReports() async { + String get userAgreementContent => _reportsService.userAgreementContent; + + getUserTermsAndConditions() async{ setState(ViewState.Busy); - reportsOrderRequestList.clear(); - reportsOrderReadyList.clear(); - reportsOrderCompletedList.clear(); - reportsOrderCanceledList.clear(); - await _reportsService.getReports(); + await _reportsService.getUserTermsAndConditions(); if (_reportsService.hasError) { error = _reportsService.error; setState(ViewState.Error); } else { - _filterList(); setState(ViewState.Idle); } } - getPatentAppointmentHistory() async { - setState(ViewState.Busy); - await _reportsService.getPatentAppointmentHistory(); + updatePatientHealthSummaryReport({String message, bool isSummary})async{ + setState(ViewState.BusyLocal); + await _reportsService.updatePatientHealthSummaryReport(isSummary: isSummary); if (_reportsService.hasError) { error = _reportsService.error; - setState(ViewState.Error); + AppToast.showErrorToast(message: error); + setState(ViewState.ErrorLocal); } else { + AppToast.showSuccessToast(message: message); setState(ViewState.Idle); } } - void _filterList() { - _reportsService.reportsList.forEach((report) { - switch (report.status) { - case 1: - reportsOrderRequestList.add(report); - break; - case 2: - reportsOrderReadyList.add(report); - break; - case 3: - reportsOrderCompletedList.add(report); - break; - case 4: - reportsOrderCanceledList.add(report); - break; - default: - } - }); - } - insertRequestForMedicalReport(AppointmentHistory appointmentHistory)async{ - setState(ViewState.Busy); - await _reportsService.insertRequestForMedicalReport(appointmentHistory); - if (_reportsService.hasError) { - error = _reportsService.error; - AppToast.showErrorToast(message: error); - setState(ViewState.ErrorLocal); - } else { - AppToast.showSuccessToast(message: 'The order was send '); - setState(ViewState.Idle); - } - } } diff --git a/lib/main.dart b/lib/main.dart index f641f22e..0c6b2760 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -66,7 +66,7 @@ class MyApp extends StatelessWidget { hintColor: Colors.grey[400], disabledColor: Colors.grey[300], errorColor: Color.fromRGBO(235, 80, 60, 1.0), - scaffoldBackgroundColor:Hexcolor('#E0E0E0'),// Colors.grey[100], + scaffoldBackgroundColor:Hexcolor('#E9E9E9'),// Colors.grey[100], textSelectionColor: Color.fromRGBO(80, 100, 253, 0.5), textSelectionHandleColor: Color.fromRGBO(80, 100, 253, 1.0), canvasColor: Colors.white, diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 5dccb514..e78e18a9 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model. import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/reports/monthly_reports.dart'; import 'package:diplomaticquarterapp/pages/vaccine/my_vaccines_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_home_page.dart'; @@ -329,11 +330,17 @@ class _MedicalProfilePageState extends State { ), Expanded( flex: 1, - child: MedicalProfileItem( - title: TranslationBase.of(context).monthly, - imagePath: 'medical_history_icon.png', - subTitle: TranslationBase.of(context) - .monthlySubtitle, + child: InkWell( + onTap: (){ + Navigator.push(context, + FadePage(page: MonthlyReportsPage())); + }, + child: MedicalProfileItem( + title: TranslationBase.of(context).monthly, + imagePath: 'medical_history_icon.png', + subTitle: TranslationBase.of(context) + .monthlySubtitle, + ), ), ), ]), diff --git a/lib/pages/medical/reports/monthly_reports.dart b/lib/pages/medical/reports/monthly_reports.dart index 9c913705..ae9cc295 100644 --- a/lib/pages/medical/reports/monthly_reports.dart +++ b/lib/pages/medical/reports/monthly_reports.dart @@ -1,17 +1,166 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/reports_monthly_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/reports/user_agreement_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/input/custom_switch.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 MonthlyReportsPage extends StatefulWidget { + @override + _MonthlyReportsPageState createState() => _MonthlyReportsPageState(); +} + +class _MonthlyReportsPageState extends State { + bool isAgree = false; + bool isSummary = false; -class MonthlyReportsPage extends StatelessWidget { @override Widget build(BuildContext context) { return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, appBarTitle: TranslationBase.of(context).monthlyReports, - body: Container(), + body: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.all(9), + height: 55, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(8)), + shape: BoxShape.rectangle, + border: Border.all(color: Colors.grey)), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).patientHealthSummaryReport, + bold: true, + ), + CustomSwitch( + value: isSummary, + activeColor: Colors.red, + inactiveColor: Colors.grey, + onChanged: () async { + setState(() { + isSummary = !isSummary; + }); + }, + ) + ], + ), + ), + SizedBox( + height: 15, + ), + Container( + margin: EdgeInsets.all(8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + model.user.emailAddress, + bold: true, + ), + ], + ), + ), + Divider( + height: 10.4, + thickness: 1.0, + ), + SizedBox( + height: 15, + ), + Container( + margin: EdgeInsets.all(8), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Texts(TranslationBase.of(context) + .toViewTheTermsAndConditions), + ), + InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: UserAgreementContent(), + ), + ); + }, + child: Texts( + TranslationBase.of(context).clickHere, + color: Colors.blue, + ), + ) + ], + ), + ), + SizedBox( + height: 5, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Checkbox( + value: isAgree, + onChanged: (value) { + setState(() { + isAgree = !isAgree; + }); + }, + activeColor: Colors.red, + ), + Texts(TranslationBase.of(context) + .iAgreeToTheTermsAndConditions), + ], + ), + Container( + margin: EdgeInsets.all(8), + width: double.infinity, + child: SecondaryButton( + textColor: Colors.white, + label: TranslationBase.of(context).save, + disabled: !isAgree, + loading: model.state == ViewState.BusyLocal, + onTap: () { + model.updatePatientHealthSummaryReport( + message: TranslationBase.of(context) + .updateSuccessfully, + isSummary: isSummary); + }, + ), + ), + Padding( + padding: const EdgeInsets.all(5.0), + child: Texts( + TranslationBase.of(context) + .iAgreeToTheTermsAndConditionsSubtitle, + fontWeight: FontWeight.normal, + ), + ), + SizedBox( + height: 12, + ), + Center(child: Image.asset('assets/images/report.jpg')) + ], + ), + ), + ), ), ); } diff --git a/lib/pages/medical/reports/user_agreement_page.dart b/lib/pages/medical/reports/user_agreement_page.dart new file mode 100644 index 00000000..9bb886e3 --- /dev/null +++ b/lib/pages/medical/reports/user_agreement_page.dart @@ -0,0 +1,25 @@ +import 'package:diplomaticquarterapp/core/viewModels/medical/reports_monthly_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter_html/flutter_html.dart'; + +class UserAgreementContent extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) => model.getUserTermsAndConditions(), + builder: (_, model, w) => AppScaffold( + isShowAppBar: true, + baseViewModel: model, + appBarTitle: TranslationBase.of(context).userAgreement, + body: SingleChildScrollView( + child: Html( + data: model.userAgreementContent, + ), + ), + ), + ); + } +} diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6f069e9c..41a5a537 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -512,8 +512,15 @@ class TranslationBase { String get locationDialogMessage => localizedValues['locationDialogMessage'][locale.languageCode]; - String get km => - localizedValues['km'][locale.languageCode]; + String get km => localizedValues['km'][locale.languageCode]; + String get patientHealthSummaryReport => localizedValues['PatientHealthSummaryReport'][locale.languageCode]; + String get toViewTheTermsAndConditions => localizedValues['ToViewTheTermsAndConditions'][locale.languageCode]; + String get clickHere => localizedValues['ClickHere'][locale.languageCode]; + String get iAgreeToTheTermsAndConditions => localizedValues['IAgreeToTheTermsAndConditions'][locale.languageCode]; + String get iAgreeToTheTermsAndConditionsSubtitle => localizedValues['IAgreeToTheTermsAndConditionsSubtitle'][locale.languageCode]; + String get save => localizedValues['Save'][locale.languageCode]; + String get userAgreement => localizedValues['UserAgreement'][locale.languageCode]; + String get updateSuccessfully => localizedValues['UpdateSuccessfully'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index d805fc94..65bb8d36 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -171,7 +171,7 @@ class _SecondaryButtonState extends State width: MediaQuery.of(context).size.width, height: 100, decoration: BoxDecoration( - color: Theme.of(context).disabledColor, + color: Theme.of(context).primaryColor, ), ), ), diff --git a/lib/widgets/input/custom_switch.dart b/lib/widgets/input/custom_switch.dart index 338bdcf2..ddd1d77b 100644 --- a/lib/widgets/input/custom_switch.dart +++ b/lib/widgets/input/custom_switch.dart @@ -34,7 +34,7 @@ class _CustomSwitchState extends State void initState() { super.initState(); _animationController = - AnimationController(vsync: this, duration: Duration(milliseconds: 800)); + AnimationController(vsync: this, duration: Duration(milliseconds: 500)); _circleAnimation = Tween(begin: 0.0, end: 30.0).animate(CurvedAnimation( parent: _animationController, curve: Curves.easeOutQuint, diff --git a/pubspec.yaml b/pubspec.yaml index 918bca3a..ea73a56b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,9 @@ dependencies: permission_handler: ^5.0.0+hotfix.3 device_info: ^0.4.2+4 + # Flutter Html View + flutter_html: ^1.0.2 + # Native flutter_device_type: ^0.2.0 local_auth: ^0.6.2+3 @@ -77,7 +80,7 @@ dependencies: table_calendar: ^2.2.3 # SVG Images - flutter_svg: ^0.17.4 + flutter_svg: ^0.18.0 # Location Helper map_launcher: ^0.8.1