From 88f1dc637f58a9940737adbdd9dfef14e4187f55 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 20 Jan 2021 13:33:46 +0200 Subject: [PATCH] some fixes --- lib/config/localized_values.dart | 2 ++ lib/core/service/patient-ucaf-service.dart | 19 +++++++++++-- .../viewModel/patient-ucaf-viewmodel.dart | 11 ++++++++ .../profile/UCAF/UCAF-detail-screen.dart | 14 +++++++++- .../vital_sing_chart_and_detials.dart | 28 ++++++++++++------- lib/util/date-utils.dart | 2 +- lib/util/translations_delegate_base.dart | 4 +++ .../profile/PatientHeaderWidgetNoAvatar.dart | 2 +- .../profile/profile_medical_info_widget.dart | 8 +++--- 9 files changed, 71 insertions(+), 19 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3103c583..8872f151 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -627,4 +627,6 @@ const Map> localizedValues = { 'addProgressNote': {'en': "Add Progress Note", 'ar':"أضف ملاحظة التقدم" }, 'createdBy': {'en': "Created By :", 'ar':"أضيفت : " }, 'editedBy': {'en': "Edited By :", 'ar':"عدلت : " }, + 'postUcafSuccessMsg': {'en': "UCAF request send successfully", 'ar':"تم ارسال طلب UCAF بنجاح" }, + 'vitalSignDetailEmpty': {'en': "There is no data for this vital sign", 'ar':"لا توجد بيانات لهذه العلامة الحيوية" }, }; diff --git a/lib/core/service/patient-ucaf-service.dart b/lib/core/service/patient-ucaf-service.dart index ac8ff300..38f2407b 100644 --- a/lib/core/service/patient-ucaf-service.dart +++ b/lib/core/service/patient-ucaf-service.dart @@ -41,8 +41,8 @@ class UcafService extends LookupService { hasError = false; Map body = Map(); body['PatientMRN'] = patient.patientMRN; - body['AppointmentNo'] = patient.appointmentNo; - body['EpisodeID'] = patient.episodeNo; + // body['AppointmentNo'] = patient.appointmentNo; + // body['EpisodeID'] = patient.episodeNo; await baseAppClient.post( GET_PATIENT_VITAL_SIGN_DATA, @@ -101,4 +101,19 @@ class UcafService extends LookupService { }, body: body); } + Future postUCAF(PatiantInformtion patient) async { + hasError = false; + Map body = Map(); + body['PatientMRN'] = patient.patientMRN; + body['AppointmentNo'] = patient.appointmentNo; + + await baseAppClient.post (POST_UCAF, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + } \ No newline at end of file diff --git a/lib/core/viewModel/patient-ucaf-viewmodel.dart b/lib/core/viewModel/patient-ucaf-viewmodel.dart index 5586e711..ae8fc96f 100644 --- a/lib/core/viewModel/patient-ucaf-viewmodel.dart +++ b/lib/core/viewModel/patient-ucaf-viewmodel.dart @@ -115,4 +115,15 @@ class UcafViewModel extends BaseViewModel { return null; } } + + Future postUCAF(PatiantInformtion patient) async { + setState(ViewState.Busy); + await _ucafService.postUCAF(patient); + if (_ucafService.hasError) { + error = _ucafService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); // but with empty list + } + } } diff --git a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart index 83f2d68b..489c462d 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-detail-screen.dart @@ -1,11 +1,13 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-ucaf-viewmodel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/order-procedure.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart'; @@ -82,7 +84,17 @@ class _UcafDetailScreenState extends State { backgroundColor: HexColor("#B8382B"), textColor: Colors.white, fontSize: SizeConfig.textMultiplier * 2.0, - handler: () {}, + handler: () async { + await model.postUCAF(patient); + if(model.state == ViewState.Idle){ + DrAppToastMsg.showSuccesToast(TranslationBase.of(context).postUcafSuccessMsg); + Navigator.of(context).popUntil((route){ + return route.settings.name == PATIENTS_PROFILE; + }); + } else { + DrAppToastMsg.showErrorToast(model.error); + } + }, ), ), Container( diff --git a/lib/screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart b/lib/screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart index cc93c77b..fbc0f3e1 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart @@ -2,8 +2,10 @@ import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign- import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-history.dart'; import 'package:doctor_app_flutter/screens/patients/profile/vital_sign/vital_sign_details_wideget.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/charts/app_time_series_chart.dart'; import 'package:doctor_app_flutter/widgets/shared/app_expandable_notifier.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; import 'package:charts_flutter/flutter.dart' as charts; @@ -29,8 +31,8 @@ class VitalSingChartAndDetials extends StatelessWidget { @override Widget build(BuildContext context) { - generateData(); - return Column( + generateData(); + return timeSeriesData.length != 0 ? Column( children: [ AppExpandableNotifier( // isExpand: true, @@ -43,6 +45,12 @@ class VitalSingChartAndDetials extends StatelessWidget { ), ), ], + ) : Container( + width: double.infinity, + height: MediaQuery.of(context).size.height, + child: Center( + child: AppText(TranslationBase.of(context).vitalSignDetailEmpty), + ), ); } @@ -50,14 +58,14 @@ class VitalSingChartAndDetials extends StatelessWidget { if (vitalList.length > 0) { vitalList.reversed.toList().forEach( (element) { - DateTime elementDate = DateUtils.getDateTimeFromServerFormat(element.createdOn); - if( element.toJson()[viewKey]!=null && element.toJson()[viewKey]?.toInt()!=0) - timeSeriesData.add( - TimeSeriesSales2( - new DateTime(elementDate.year, elementDate.month, elementDate.day), - element.toJson()[viewKey].toDouble(), - ), - ); + DateTime elementDate = DateUtils.getDateTimeFromServerFormat(element.createdOn); + if(element.toJson()[viewKey]!=null && element.toJson()[viewKey]?.toInt()!=0) + timeSeriesData.add( + TimeSeriesSales2( + new DateTime(elementDate.year, elementDate.month, elementDate.day), + element.toJson()[viewKey].toDouble(), + ), + ); }, ); } diff --git a/lib/util/date-utils.dart b/lib/util/date-utils.dart index a624dd2c..c414cd51 100644 --- a/lib/util/date-utils.dart +++ b/lib/util/date-utils.dart @@ -60,7 +60,7 @@ class DateUtils { var difference = now.difference(firstDate); int minutesInDays = difference.inMinutes; - int hoursInDays = minutesInDays ~/ 60; + int hoursInDays = minutesInDays ~/ 60; // ~/ : truncating division to make the result int int minutes = minutesInDays % 60; int days = hoursInDays ~/ 24; int hours = hoursInDays % 24; diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 3d1a8d50..49e75caa 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -665,6 +665,10 @@ class TranslationBase { localizedValues['createdBy'][locale.languageCode]; String get editedBy => localizedValues['editedBy'][locale.languageCode]; + String get postUcafSuccessMsg => + localizedValues['postUcafSuccessMsg'][locale.languageCode]; + String get vitalSignDetailEmpty => + localizedValues['vitalSignDetailEmpty'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart b/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart index 25bc80e4..1f1c4079 100644 --- a/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart +++ b/lib/widgets/patients/profile/PatientHeaderWidgetNoAvatar.dart @@ -48,7 +48,7 @@ class PatientHeaderWidgetNoAvatar extends StatelessWidget { fontSize: SizeConfig.textMultiplier * 2.0, ), AppText( - "${patient.companyName}", + "${patient.companyName != null ? patient.companyName : ""}", fontWeight: FontWeight.bold, fontSize: SizeConfig.textMultiplier * 2.0, ), diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 054d3c34..b243f15a 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -70,7 +70,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { nameLine2: TranslationBase.of(context).episode, route: UPDATE_EPISODE, icon: 'modilfy-episode.png'), - if (int.parse(patientType) == 7) + if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( key: key, patient: patient, @@ -106,7 +106,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { nameLine1: TranslationBase.of(context).progress, nameLine2: TranslationBase.of(context).note, icon: 'heartbeat.png'), - if (selectedPatientType == 7|| int.parse(patientType) == 6) + if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( key: key, patient: patient, @@ -128,7 +128,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { nameLine1: TranslationBase.of(context).orders, nameLine2: TranslationBase.of(context).procedures, icon: 'lab.png'), - if (selectedPatientType == 7|| int.parse(patientType) == 6) + if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( key: key, patient: patient, @@ -152,7 +152,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { nameLine1: TranslationBase.of(context).patientSick, nameLine2: TranslationBase.of(context).leave, icon: 'sick_leaves_icons.png'), - if (selectedPatientType == 7|| int.parse(patientType) == 6) + if (int.parse(patientType) == 7 || int.parse(patientType) == 6) PatientProfileButton( key: key, patient: patient,