From 1b8e3eb8950cc03c03d74eef3321fc15dd1707b0 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Sat, 24 Apr 2021 15:46:17 +0300 Subject: [PATCH] some fixes --- lib/config/localized_values.dart | 1 + lib/core/service/patient-ucaf-service.dart | 26 ++-- .../viewModel/patient-ucaf-viewmodel.dart | 55 +++++++- .../profile/UCAF/UCAF-input-screen.dart | 10 +- .../referred_patient_detail_in-paint.dart | 118 ++++++++++++------ lib/util/translations_delegate_base.dart | 4 +- .../shared/buttons/app_buttons_widget.dart | 8 +- 7 files changed, 162 insertions(+), 60 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 12286b64..2bfceb67 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -862,4 +862,5 @@ const Map> localizedValues = { "try-saying": {"en": "Try saying something", "ar": 'حاول قول شيء ما'}, "refClinic": {"en": "Ref Clinic", "ar": "Ref Clinic"}, "acknowledged": {"en": "Acknowledged", "ar": "إقرار"}, + "showDetail": {"en": "Show Detail", "ar": "أظهر المعلومات"}, }; diff --git a/lib/core/service/patient-ucaf-service.dart b/lib/core/service/patient-ucaf-service.dart index 90a45ee2..80f0714f 100644 --- a/lib/core/service/patient-ucaf-service.dart +++ b/lib/core/service/patient-ucaf-service.dart @@ -8,11 +8,12 @@ import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.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/models/patient/vital_sign/patient-vital-sign-data.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-history.dart'; class UcafService extends LookupService { List patientChiefComplaintList = []; - VitalSignData patientVitalSigns; + List patientVitalSignsHistory = []; List patientAssessmentList = []; List orderProcedureList = []; PrescriptionModel prescriptionList; @@ -38,21 +39,28 @@ class UcafService extends LookupService { }, body: body); } - Future getPatientVitalSign(PatiantInformtion patient) async { - patientVitalSigns = null; + Future getPatientVitalSignsHistory( + PatiantInformtion patient, String fromDate, String toDate) async { hasError = false; Map body = Map(); - body['PatientMRN'] = patient.patientMRN; - body['AppointmentNo'] = patient.appointmentNo; + body['PatientMRN'] = patient.patientId; // patient.patientMRN + // body['AppointmentNo'] = patient.appointmentNo; // body['EpisodeID'] = patient.episodeNo; + body['PatientTypeID'] = 1; + body['PatientType'] = 1; + body['DeviceTypeID'] = 1; + body['isDentalAllowedBackend'] = false; + body['From'] = fromDate; + body['To'] = toDate; await baseAppClient.post( GET_PATIENT_VITAL_SIGN_DATA, onSuccess: (dynamic response, int statusCode) { - if(response['VitalSignsList'] != null){ - if(response['VitalSignsList']['entityList'] != null && (response['VitalSignsList']['entityList'] as List).length > 0){ - patientVitalSigns = VitalSignData.fromJson(response['VitalSignsList']['entityList'][0]); - } + patientVitalSignsHistory.clear(); + if (response['VitalSignsHistory'] != null) { + response['VitalSignsHistory'].forEach((v) { + patientVitalSignsHistory.add(new VitalSignHistory.fromJson(v)); + }); } }, onFailure: (String error, int statusCode) { diff --git a/lib/core/viewModel/patient-ucaf-viewmodel.dart b/lib/core/viewModel/patient-ucaf-viewmodel.dart index f48ef485..f1d85fa0 100644 --- a/lib/core/viewModel/patient-ucaf-viewmodel.dart +++ b/lib/core/viewModel/patient-ucaf-viewmodel.dart @@ -10,6 +10,8 @@ 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/models/patient/vital_sign/patient-vital-sign-data.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-history.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:flutter/material.dart'; import '../../locator.dart'; @@ -20,7 +22,8 @@ class UcafViewModel extends BaseViewModel { List get patientChiefComplaintList => _ucafService.patientChiefComplaintList; - VitalSignData get patientVitalSigns => _ucafService.patientVitalSigns; + List get patientVitalSignsHistory => + _ucafService.patientVitalSignsHistory; List get patientAssessmentList => _ucafService.patientAssessmentList; @@ -35,6 +38,13 @@ class UcafViewModel extends BaseViewModel { List get orderProcedures => _ucafService.orderProcedureList; String selectedLanguage; + String heightCm = "0"; + String weightKg = "0"; + String bodyMax = "0"; + String temperatureCelcius = "0"; + String hartRat = "0"; + String respirationBeatPerMinute = "0"; + String bloodPressure = "0 / 0"; resetDataInFirst(){ _ucafService.patientAssessmentList = []; @@ -48,13 +58,54 @@ class UcafViewModel extends BaseViewModel { Future getUCAFData(PatiantInformtion patient) async { setState(ViewState.Busy); - await _ucafService.getPatientVitalSign(patient); + + String from; + String to; + if (from == null || from == "0") { + from = DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd'); + } + if (to == null || to == "0") { + to = DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd'); + } + + await _ucafService.getPatientVitalSignsHistory(patient, from, to); await _ucafService.getPatientChiefComplaint(patient); if (_ucafService.hasError) { error = _ucafService.error; setState(ViewState.Error); } else { + patientVitalSignsHistory.forEach((element) { + if (heightCm == "0" || heightCm == null || heightCm == 'null') { + heightCm = element.heightCm.toString(); + } + if (weightKg == "0" || weightKg == null || weightKg == 'null') { + weightKg = element.weightKg.toString(); + } + if (bodyMax == "0" || bodyMax == null || bodyMax == 'null') { + bodyMax = element.bodyMassIndex.toString(); + } + if (temperatureCelcius == "0" || + temperatureCelcius == null || + temperatureCelcius == 'null') { + temperatureCelcius = element.temperatureCelcius.toString(); + } + if (hartRat == "0" || hartRat == null || hartRat == 'null') { + hartRat = element.pulseBeatPerMinute.toString(); + } + if (respirationBeatPerMinute == "0" || + respirationBeatPerMinute == null || + respirationBeatPerMinute == 'null') { + respirationBeatPerMinute = + element.respirationBeatPerMinute.toString(); + } + if (bloodPressure == "0 / 0" || + bloodPressure == null || + bloodPressure == 'null') { + bloodPressure = element.bloodPressure.toString(); + } + }); + setState(ViewState.Idle); } } diff --git a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart index 32eb99f5..4baca2ea 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart @@ -70,7 +70,7 @@ class _UCAFInputScreenState extends State { appBar: PatientProfileHeaderNewDesignAppBar( patient, patientType, arrivalType), appBarTitle: TranslationBase.of(context).ucaf, - body: model.patientVitalSigns != null && + body: model.patientVitalSignsHistory.length > 0 && model.patientChiefComplaintList != null && model.patientChiefComplaintList.length > 0 ? Column( @@ -186,7 +186,7 @@ class _UCAFInputScreenState extends State { width: 8, ), AppText( - "${model.patientVitalSigns.bloodPressureHigher}/${model.patientVitalSigns.bloodPressureLower}", + "${model.bloodPressure}", fontSize: SizeConfig.textMultiplier * 2, color: Colors.grey.shade800, @@ -212,7 +212,7 @@ class _UCAFInputScreenState extends State { ), Expanded( child: AppText( - "${model.patientVitalSigns.temperatureCelcius}(C), ${(model.patientVitalSigns.temperatureCelcius * (9 / 5) + 32).toStringAsFixed(2)}(F)", + "${model.temperatureCelcius}(C), ${(double.parse(model.temperatureCelcius) * (9 / 5) + 32).toStringAsFixed(2)}(F)", fontSize: SizeConfig.textMultiplier * 2, color: Colors.grey.shade800, @@ -244,7 +244,7 @@ class _UCAFInputScreenState extends State { width: 4, ), AppText( - "${model.patientVitalSigns.pulseBeatPerMinute}", + "${model.hartRat}", fontSize: SizeConfig.textMultiplier * 2, color: Colors.grey.shade800, @@ -430,7 +430,7 @@ class _UCAFInputScreenState extends State { Padding( padding: const EdgeInsets.all(8.0), child: AppText( - model.patientVitalSigns == null + model.patientVitalSignsHistory.length > 0 ? TranslationBase.of(context).vitalSignEmptyMsg : TranslationBase.of(context).chiefComplaintEmptyMsg, fontWeight: FontWeight.normal, diff --git a/lib/screens/patients/profile/referral/referred_patient_detail_in-paint.dart b/lib/screens/patients/profile/referral/referred_patient_detail_in-paint.dart index de13d096..b68eeac1 100644 --- a/lib/screens/patients/profile/referral/referred_patient_detail_in-paint.dart +++ b/lib/screens/patients/profile/referral/referred_patient_detail_in-paint.dart @@ -76,8 +76,10 @@ class ReferredPatientDetailScreen extends StatelessWidget { "patientType": "1", "isInpatient": true, "arrivalType": "1", - "from": DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd'), - "to": DateUtils.convertDateToFormat(DateTime.now(), 'yyyy-MM-dd'), + "from": DateUtils.convertDateToFormat( + DateTime.now(), 'yyyy-MM-dd'), + "to": DateUtils.convertDateToFormat( + DateTime.now(), 'yyyy-MM-dd'), }); }, child: Icon( @@ -90,17 +92,47 @@ class ReferredPatientDetailScreen extends StatelessWidget { Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: EdgeInsets.only(left: 12.0), - child: Container( - width: 60, - height: 60, - child: Image.asset( - referredPatient.gender == 1 - ? 'assets/images/male_avatar.png' - : 'assets/images/female_avatar.png', - fit: BoxFit.cover, - ), + InkWell( + onTap: (){ + PatiantInformtion patient = + model.getPatientFromReferral(referredPatient); + Navigator.of(context) + .pushNamed(PATIENTS_PROFILE, arguments: { + "patient": patient, + "patientType": "1", + "isInpatient": true, + "arrivalType": "1", + "from": DateUtils.convertDateToFormat( + DateTime.now(), 'yyyy-MM-dd'), + "to": DateUtils.convertDateToFormat( + DateTime.now(), 'yyyy-MM-dd'), + }); + }, + child: Column( + children: [ + Padding( + padding: EdgeInsets.only(left: 12.0), + child: Container( + width: 60, + height: 60, + child: Image.asset( + referredPatient.gender == 1 + ? 'assets/images/male_avatar.png' + : 'assets/images/female_avatar.png', + fit: BoxFit.cover, + ), + ), + ), + SizedBox( + height: 20, + ), + AppText( + TranslationBase.of(context).showDetail, + fontWeight: FontWeight.w700, + fontSize: 1.7 * SizeConfig.textMultiplier, + color: Colors.blue, + ) + ], ), ), SizedBox( @@ -148,14 +180,15 @@ class ReferredPatientDetailScreen extends StatelessWidget { .fileNumber, fontFamily: 'Poppins', fontWeight: FontWeight.w600, - fontSize: 1.7 * SizeConfig.textMultiplier, + fontSize: + 1.7 * SizeConfig.textMultiplier, color: Color(0XFF575757), ), AppText( "${referredPatient.patientID}", fontFamily: 'Poppins', fontWeight: FontWeight.w700, - fontSize:14, + fontSize: 14, color: Color(0XFF2E303A), ), ], @@ -284,7 +317,7 @@ class ReferredPatientDetailScreen extends StatelessWidget { referredPatient.priorityDescription, fontFamily: 'Poppins', fontWeight: FontWeight.w700, - fontSize:14, + fontSize: 14, color: Color(0XFF2E303A), ), ], @@ -382,7 +415,8 @@ class ReferredPatientDetailScreen extends StatelessWidget { color: Colors.black, ), AppText( - referredPatient.referralClinicDescription, + referredPatient + .referralClinicDescription, fontFamily: 'Poppins', fontWeight: FontWeight.w700, fontSize: 1.3 * @@ -480,7 +514,10 @@ class ReferredPatientDetailScreen extends StatelessWidget { color: Color(0XFF2E303A), ), AppText( - referredPatient.referredDoctorRemarks.isNotEmpty? referredPatient.referredDoctorRemarks:" Not Replied yet", + referredPatient + .referredDoctorRemarks.isNotEmpty + ? referredPatient.referredDoctorRemarks + : " Not Replied yet", fontFamily: 'Poppins', fontWeight: FontWeight.w600, fontSize: 1.6 * SizeConfig.textMultiplier, @@ -496,28 +533,31 @@ class ReferredPatientDetailScreen extends StatelessWidget { ), ), ), - if(referredPatient.referralStatus ==1) - Container( - margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: AppButton( - title: TranslationBase.of(context).acknowledged, - color: Colors.red[700], - fontColor: Colors.white, - fontWeight: FontWeight.w700, - fontSize: 1.8, - hPadding: 8, - vPadding: 12, - onPressed: () async { - await model.verifyReferralDoctorRemarks(referredPatient); - if (model.state == ViewState.ErrorLocal) { - DrAppToastMsg.showErrorToast(model.error); - } else { - DrAppToastMsg.showSuccesToast("Referral is acknowledged"); - Navigator.pop(context); - } - }, + Container( + margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), + child: AppButton( + title: TranslationBase.of(context).acknowledged, + color: Colors.red[700], + fontColor: Colors.white, + fontWeight: FontWeight.w700, + fontSize: 1.8, + hPadding: 8, + vPadding: 12, + disabled: referredPatient.referredDoctorRemarks.isNotEmpty + ? false + : true, + onPressed: () async { + await model.verifyReferralDoctorRemarks(referredPatient); + if (model.state == ViewState.ErrorLocal) { + DrAppToastMsg.showErrorToast(model.error); + } else { + DrAppToastMsg.showSuccesToast( + "Referral is acknowledged"); + Navigator.pop(context); + } + }, + ), ), - ), ], ), ), diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 505fc351..044f95a5 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1172,8 +1172,8 @@ class TranslationBase { localizedValues['SpecialResult'][locale.languageCode]; String get noDataAvailable => localizedValues['noDataAvailable'][locale.languageCode]; - String get showMoreBtn => - localizedValues['show-more-btn'][locale.languageCode]; + String get showMoreBtn => localizedValues['show-more-btn'][locale.languageCode]; + String get showDetail => localizedValues['showDetail'][locale.languageCode]; String get fileNumber => localizedValues['fileNumber'][locale.languageCode]; String get reschedule => localizedValues['reschedule'][locale.languageCode]; diff --git a/lib/widgets/shared/buttons/app_buttons_widget.dart b/lib/widgets/shared/buttons/app_buttons_widget.dart index 521d1025..eab11a57 100644 --- a/lib/widgets/shared/buttons/app_buttons_widget.dart +++ b/lib/widgets/shared/buttons/app_buttons_widget.dart @@ -51,7 +51,8 @@ class _AppButtonState extends State { return IgnorePointer( ignoring: widget.loading ||widget.disabled, child: RawMaterialButton( - fillColor: widget.color != null ? widget.color : HexColor("#B8382C"), + fillColor: widget.disabled + ? Colors.grey : widget.color != null ? widget.color : HexColor("#B8382C"), splashColor: widget.color, child: Padding( padding: (widget.hPadding > 0 || widget.vPadding > 0) @@ -103,11 +104,12 @@ class _AppButtonState extends State { ], ), ), - onPressed: widget.onPressed, + onPressed: widget.disabled ? (){} : widget.onPressed, shape: RoundedRectangleBorder( side: BorderSide( color: - widget.hasBorder ? widget.borderColor : widget.color ?? Color(0xFFB8382C), + widget.hasBorder ? widget.borderColor : widget.disabled + ? Colors.grey : widget.color ?? Color(0xFFB8382C), width: 0.8, ), borderRadius: BorderRadius.all(Radius.circular(widget.radius))),