From fde96fbce7a88ec10079c1158f4abc6a43e0959c Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Sun, 16 Jan 2022 16:07:53 +0200 Subject: [PATCH] Fix some issues --- lib/config/localized_values.dart | 2 + .../intervention_medication_view_model.dart | 70 ++- lib/locator.dart | 2 - .../intervention_medication.dart | 457 ++++++++---------- ...ntervention_medication_history_screen.dart | 137 ++---- .../pharmacy_intervention_screen.dart | 32 +- .../profile_gird_for_InPatient.dart | 6 +- lib/util/translations_delegate_base.dart | 4 + 8 files changed, 305 insertions(+), 405 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 5424f389..fa97bf62 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1054,6 +1054,8 @@ const Map> localizedValues = { "maritalStatus": {"en": "Marital Status", "ar": "الحالة الزوجية"}, "nursing": {"en": "Nursing", "ar": "تمريض"}, "diabetic": {"en": "Diabetic", "ar": "مرض السكري"}, + "pharmacy": {"en": "Pharmacy", "ar": "الصيدلاني"}, + "intervention": {"en": "Intervention", "ar": "التدخل"}, "chart": {"en": "Chart", "ar": "جدول"}, "operationTimeStart": { "en": "Operation Time Start :", diff --git a/lib/core/viewModel/profile/intervention_medication_view_model.dart b/lib/core/viewModel/profile/intervention_medication_view_model.dart index 5cc6a9b4..998c7958 100644 --- a/lib/core/viewModel/profile/intervention_medication_view_model.dart +++ b/lib/core/viewModel/profile/intervention_medication_view_model.dart @@ -2,14 +2,30 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import '../../../models/dashboard/get_special_clinical_care_mapping_List_Respose_Model.dart'; import '../../../screens/patients/profile/pharmacy-intervention-model/accept_or_reject_req_model.dart'; import '../../../screens/patients/profile/pharmacy-intervention-model/intervention_medication_history_req_model.dart'; import '../../../screens/patients/profile/pharmacy-intervention-model/intervention_medication_history_res_model.dart'; import '../../../screens/patients/profile/pharmacy-intervention-model/new_medication_req_model.dart'; import '../../../screens/patients/profile/pharmacy-intervention-model/new_medication_res_model.dart'; +import '../../../util/date-utils.dart'; import '../../service/patient/profile/intervention_medication_service.dart'; +import '../../service/special_clinics/special_clinic_service.dart'; class InterventionMedicationViewModel extends BaseViewModel { + + SpecialClinicsService _specialClinicsService = + locator(); + + List + get specialClinicalCareMappingList => + _specialClinicsService.specialClinicalCareMappingList; + + List filterData = []; + + DateTime selectedFromDate; + DateTime selectedToDate; + PatiantInformtion patient; bool hasError = false; InterventionMedicationService _interventionMedicationService = @@ -23,18 +39,25 @@ class InterventionMedicationViewModel extends BaseViewModel { Future getInterventionMedication({ + int projectId, int patientId, int admissionNo, + DateTime fromDate, + DateTime toDate, }) async { InterventionMedicationReqModel interventionMedicationReqModel = InterventionMedicationReqModel( - projectID: 15, - patientID: 79941, - fromDate: '\/Date(1488322922)\/', - toDate: '\/Date(1635886800000)\/', + projectID: projectId, + patientID: patientId, + fromDate: AppDateUtils.convertToServerFormat( + fromDate.toString(), + 'MM/dd/yyyy'), + toDate: AppDateUtils.convertToServerFormat( + toDate.toString(), + 'MM/dd/yyyy'), ); hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _interventionMedicationService.getInterventionMedication( interventionMedicationReqModel: interventionMedicationReqModel); if (_interventionMedicationService.hasError) { @@ -47,18 +70,22 @@ class InterventionMedicationViewModel extends BaseViewModel { Future getInterventionMedicationHistory({ + int projectId, int patientId, + int admissionNo, + int prescriptionNo, + int orderNo, }) async { InterventionMedicationHistoryReqModel interventionMedicationHistoryReqModel = InterventionMedicationHistoryReqModel( - projectID: 15, - patientID: 79941, - admissionNo: 2018013900, - prescriptionNo: 2045165, - orderNo: 1171570, + projectID: projectId, + patientID: patientId, + admissionNo: admissionNo, + prescriptionNo: prescriptionNo, + orderNo: orderNo, ); hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _interventionMedicationService.getInterventionMedicationHistory( interventionMedicationHistoryReqModel: interventionMedicationHistoryReqModel); if (_interventionMedicationService.hasError) { @@ -72,15 +99,24 @@ class InterventionMedicationViewModel extends BaseViewModel { Future setAcceptedOrRejected({ String remarks, + int memberId, + int projectId, + int patientID, + int admissionNo, + int prescriptionNo, + int orderNo, }) async { AcceptOrRejectReqModel acceptOrRejectReqModel = AcceptOrRejectReqModel( - projectID: 15, - patientID: 79941, - admissionNo: 2018013900, - prescriptionNo: 2045165, - orderNo: 1171570, - remarks: remarks + projectID: projectId, + patientID: patientID, + admissionNo: admissionNo, + prescriptionNo: prescriptionNo, + orderNo: orderNo, + accessLevel: 4, + lineItemNo: 1, + remarks: remarks, + memberID: memberId, ); hasError = false; setState(ViewState.BusyLocal); diff --git a/lib/locator.dart b/lib/locator.dart index 76be7fa0..fc42e632 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -67,7 +67,6 @@ import 'core/viewModel/patient-ucaf-viewmodel.dart'; import 'core/viewModel/patient-vital-sign-viewmodel.dart'; import 'core/viewModel/prescriptions_view_model.dart'; import 'core/viewModel/profile/intervention_medication_view_model.dart'; -import 'core/viewModel/profile/pharmacy_intervention_view_model.dart'; import 'core/viewModel/profile/vte_assessment_view_model.dart'; import 'core/viewModel/radiology_view_model.dart'; import 'core/viewModel/referral_view_model.dart'; @@ -150,7 +149,6 @@ void setupLocator() { locator.registerFactory(() => PatientRegistrationViewModel()); locator.registerFactory(() => PendingOrdersViewModel()); locator.registerFactory(() => DischargeSummaryViewModel()); - locator.registerFactory(() => PharmacyInterventionViewModel()); locator.registerFactory(() => VteAssessmentViewModel()); locator.registerFactory(() => InterventionMedicationViewModel()); } diff --git a/lib/screens/patients/profile/pharmacy-intervention/intervention_medication.dart b/lib/screens/patients/profile/pharmacy-intervention/intervention_medication.dart index 0ae3cee3..4587ce8d 100644 --- a/lib/screens/patients/profile/pharmacy-intervention/intervention_medication.dart +++ b/lib/screens/patients/profile/pharmacy-intervention/intervention_medication.dart @@ -1,8 +1,4 @@ -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/core/model/diagnosis/GetDiagnosisForInPatientRequestModel.dart'; import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/profile/vte_assessment_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -16,7 +12,6 @@ import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; - import '../../../../core/viewModel/profile/intervention_medication_view_model.dart'; import '../../../../widgets/transitions/fade_page.dart'; import 'intervention_medication_history_screen.dart'; @@ -28,10 +23,12 @@ class InterventionMedicationScreen extends StatefulWidget { const InterventionMedicationScreen(this.patient, {Key key}) : super(key: key); @override - _InterventionMedicationScreenState createState() => _InterventionMedicationScreenState(); + _InterventionMedicationScreenState createState() => + _InterventionMedicationScreenState(); } -class _InterventionMedicationScreenState extends State { +class _InterventionMedicationScreenState + extends State { bool isDischargedPatient = false; AuthenticationViewModel authenticationViewModel; ProjectViewModel projectViewModel; @@ -42,11 +39,13 @@ class _InterventionMedicationScreenState extends State( - onModelReady: (model) => model.getInterventionMedication(patientId: widget.patient.patientId, - // admissionNo: 2016023498 - - admissionNo:int.parse(widget.patient.admissionNo) + onModelReady: (model) => model.getInterventionMedication( + patientId: widget.patient.patientId, + admissionNo: int.parse(widget.patient.admissionNo), + fromDate: model.selectedFromDate, + toDate: model.selectedToDate, ), + builder: (_, model, w) => AppScaffold( baseViewModel: model, backgroundColor: Theme.of(context).scaffoldBackgroundColor, @@ -55,270 +54,212 @@ class _InterventionMedicationScreenState extends State[ - Expanded( - child: Container( - child: ListView.builder( - itemCount: model.allInterventionList.length, - itemBuilder: (BuildContext ctxt, int index) { - return FractionallySizedBox( - widthFactor: 0.95, - child: CardWithBgWidget( - hasBorder: false, - bgColor: Colors.transparent, - widget: Column( - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, + child: ErrorMessage( + error: TranslationBase.of(context).noDataAvailable, + ), + ) + : Container( + color: Colors.grey[200], + child: Column( + children: [ + Expanded( + child: Container( + child: ListView.builder( + itemCount: model.allInterventionList.length, + itemBuilder: (BuildContext ctxt, int index) { + return InkWell( + child: FractionallySizedBox( + widthFactor: 0.95, + child: CardWithBgWidget( + hasBorder: false, + bgColor: Colors.transparent, + widget: Column( children: [ - Container( - width: MediaQuery.of(context) - .size - .width * - 0.60, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - AppText( - model - .allInterventionList[ - index].cS, - fontWeight: FontWeight.w600, - fontSize: 14, - ), - - ], - ), - ], - ), - ), Column( + crossAxisAlignment: + CrossAxisAlignment.start, children: [ + SizedBox( + height: 10, + ), Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, crossAxisAlignment: - CrossAxisAlignment - .start, + CrossAxisAlignment.start, children: [ - AppText( - AppDateUtils.getDayMonthYearDateFormatted( - AppDateUtils.convertStringToDate( - model - .allInterventionList[ - index].startDatetime) - ,isArabic: - projectViewModel - .isArabic, - isMonthShort: true), - fontWeight: FontWeight.w600, - fontSize: 14, + Container( + width: MediaQuery.of(context) + .size + .width * + 0.60, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + AppText( + model + .allInterventionList[ + index] + .cS, + fontWeight: + FontWeight.w600, + fontSize: 14, + ), + ], + ), + ], + ), ), - + Column( + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + AppText( + AppDateUtils.getDayMonthYearDateFormatted( + AppDateUtils.convertStringToDate(model + .allInterventionList[ + index] + .startDatetime), + isArabic: + projectViewModel + .isArabic, + isMonthShort: + true), + fontWeight: + FontWeight.w600, + fontSize: 14, + ), + ], + ), + ], + ) ], ), - ], - ) - // Column( - // children: [ - // AppText( - // model - // .allInterventionList[ - // index] - // .startDatetime != - // null - // ? AppDateUtils.getDayMonthYearDateFormatted( - // AppDateUtils - // .getDateTimeFromString(model - // .allInterventionList[ - // index] - // .startDatetime), - // isArabic: - // projectViewModel - // .isArabic, - // isMonthShort: true) - // : AppDateUtils - // .getDayMonthYearDateFormatted( - // DateTime.now(), - // isArabic: - // projectViewModel - // .isArabic), - // fontWeight: FontWeight.w600, - // fontSize: 14, - // isCopyable: true, - // ), - // AppText( - // model - // .allInterventionList[ - // index] - // .startDatetime != - // null - // ? AppDateUtils.getHour( - // AppDateUtils - // .getDateTimeFromString(model - // .allInterventionList[ - // index] - // .startDatetime)) - // : AppDateUtils.getHour( - // DateTime.now()), - // fontWeight: FontWeight.w600, - // fontSize: 14, - // isCopyable: true, - // ), - // ], - // crossAxisAlignment: - // CrossAxisAlignment.end, - // ) - ], - ), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context) - // .VTE_Type + - // " : ", - // fontSize: 12, - // ), - Expanded( - child: AppText( - model - .allInterventionList[ - index] - .description, - fontSize: 12, - isCopyable: true, + SizedBox( + height: 8, ), - ), - ]), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context) - // .pharmacology + - // " : ", - // fontSize: 12, - // ), - Expanded( - child: AppText( - model - .allInterventionList[ - index] - .medication, - fontSize: 12, - isCopyable: true, + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + 'Description: ', + fontSize: 12, + ), + Expanded( + child: AppText( + model + .allInterventionList[ + index] + .description, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + SizedBox( + height: 8, ), - ), - ]), - SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context) - // .reasonsThrombo + - // " : ", - // fontSize: 12, - // ), - Expanded( - child: AppText( - model - .allInterventionList[ - index] - .doctorComments, - fontSize: 12, - isCopyable: true, + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + 'Medication: ', + fontSize: 12, + ), + Expanded( + child: AppText( + model + .allInterventionList[ + index] + .medication, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + SizedBox( + height: 8, ), - ), - ]), - SizedBox( - height: 8, - ), - - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - // AppText( - // TranslationBase.of(context) - // .reasonsThrombo + - // " : ", - // fontSize: 12, - // ), - Expanded( - child: AppText( - model - .allInterventionList[ - index] - .statusDescription, - fontSize: 12, - isCopyable: true, + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + 'Doctor Comments: ', + fontSize: 12, + ), + Expanded( + child: AppText( + model + .allInterventionList[ + index] + .doctorComments, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + SizedBox( + height: 8, ), - ), - ]), - - ], - ), - SizedBox( - height: 20, + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + 'Status Description: ', + fontSize: 12, + ), + Expanded( + child: AppText( + model + .allInterventionList[ + index] + .statusDescription, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + ], + ), + SizedBox( + height: 20, + ), + ], + ), + ), ), - ], - ), - ), - ); - }), + onTap: () { + Navigator.push( + context, + FadePage( + page: InterventionMedicationHistoryScreen(widget.patient, model.allInterventionList[index]), + ), + ); + }, + ); + }), + ), + ), + ], ), ), - ], - ), - ), - onTap: () { - // PatiantInformtion patient; - Navigator.push( - context, - FadePage( - page: InterventionMedicationHistoryScreen(widget.patient), - - ), - ); - }, - ), ), ); } diff --git a/lib/screens/patients/profile/pharmacy-intervention/intervention_medication_history_screen.dart b/lib/screens/patients/profile/pharmacy-intervention/intervention_medication_history_screen.dart index 2ae9d78e..a2c751bb 100644 --- a/lib/screens/patients/profile/pharmacy-intervention/intervention_medication_history_screen.dart +++ b/lib/screens/patients/profile/pharmacy-intervention/intervention_medication_history_screen.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/core/viewModel/authentication_view_model.dart import 'package:doctor_app_flutter/core/viewModel/project_view_model.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/screens/patients/profile/pharmacy-intervention-model/new_medication_res_model.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; @@ -24,7 +25,8 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class InterventionMedicationHistoryScreen extends StatefulWidget { final PatiantInformtion patient; - const InterventionMedicationHistoryScreen(this.patient, {Key key}) : super(key: key); + final InterventionMedicationResModel interventionMedication; + const InterventionMedicationHistoryScreen(this.patient, this.interventionMedication, {Key key}) : super(key: key); @override _InterventionMedicationHistoryScreenState createState() => _InterventionMedicationHistoryScreenState(); @@ -41,7 +43,12 @@ class _InterventionMedicationHistoryScreenState extends State( - onModelReady: (model) => model.getInterventionMedicationHistory(patientId: widget.patient.patientId, + onModelReady: (model) => model.getInterventionMedicationHistory( + patientId: widget.patient.patientId, + projectId: widget.interventionMedication.projectID, + admissionNo: widget.interventionMedication.admissionNo, + prescriptionNo: widget.interventionMedication.prescriptionNo, + orderNo: widget.interventionMedication.orderNo, ), builder: (_, model, w) => AppScaffold( baseViewModel: model, @@ -133,61 +140,10 @@ class _InterventionMedicationHistoryScreenState extends State( + return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: false, backgroundColor: Theme.of(context).scaffoldBackgroundColor, @@ -173,7 +173,7 @@ class _PharmacyInterventionScreenState context, MaterialPageRoute( builder: (context) => - InterventionMedicationScreen(patient)), + InterventionMedicationScreen(patient,)), ); }, ), @@ -188,7 +188,7 @@ class _PharmacyInterventionScreenState ))); } - selectDate(BuildContext context, PharmacyInterventionViewModel model, + selectDate(BuildContext context, InterventionMedicationViewModel model, {bool isFromDate = true, DateTime firstDate, lastDate, @@ -205,7 +205,7 @@ class _PharmacyInterventionScreenState if (isFromDate) { setState(() { model.selectedFromDate = picked; - var date = picked.add(Duration(days: 30)); + var date = picked.add(Duration(days: 1)); if (date.isBefore(lastDate)) { model.selectedToDate = date; } else @@ -219,26 +219,6 @@ class _PharmacyInterventionScreenState } } - // getFirstDate(OutPatientFilterType outPatientFilterType) { - // if (outPatientFilterType == OutPatientFilterType.Previous) { - // return DateTime(F - // DateTime.now().year - 20, DateTime.now().month, DateTime.now().day); - // } else { - // return DateTime( - // DateTime.now().year, DateTime.now().month, DateTime.now().day + 1); - // } - // } - - // getLastDate(OutPatientFilterType outPatientFilterType) { - // if (outPatientFilterType == OutPatientFilterType.Previous) { - // return DateTime( - // DateTime.now().year, DateTime.now().month, DateTime.now().day - 1); - // } else { - // return DateTime( - // DateTime.now().year , DateTime.now().month , DateTime.now().day + 100); - // } - // } - InputDecoration textFieldSelectorDecoration( String hintText, String selectedText, bool isDropDown, {Icon suffixIcon}) { diff --git a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart index bdc7af5d..b43dbc44 100644 --- a/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart +++ b/lib/screens/patients/profile/profile_screen/profile_gird_for_InPatient.dart @@ -176,10 +176,10 @@ class ProfileGridForInPatient extends StatelessWidget { isInPatient: isInpatient, ), PatientProfileCardModel( - 'Pharmacy', - 'intervention', + TranslationBase.of(context).pharmacy, + TranslationBase.of(context).intervention, PHARMACY_INTERVENTION, - '', + 'assets/images/svgs/profile_screen/medical report.svg', isInPatient: isInpatient, ), ]; diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 303a9acf..96a4adf0 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1725,6 +1725,10 @@ class TranslationBase { String get diabetic => localizedValues['diabetic'][locale.languageCode]; + String get pharmacy => localizedValues['pharmacy'][locale.languageCode]; + + String get intervention => localizedValues['intervention'][locale.languageCode]; + String get chart => localizedValues['chart'][locale.languageCode]; String get investigation =>