From 0d542a862e946147d3f6ab6efd8f57a217e6ecc7 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Wed, 12 Jan 2022 16:39:15 +0200 Subject: [PATCH] add new service --- lib/config/config.dart | 3 + .../intervention_medication_service.dart | 34 ++ .../intervention_medication_view_model.dart | 39 ++ .../profile/search_medication_view_model.dart | 42 +++ lib/locator.dart | 6 + lib/routes.dart | 1 - .../intervention_medication.dart | 357 +++++++++--------- .../new-medication/new_medication_screen.dart | 2 +- pubspec.lock | 9 +- 9 files changed, 317 insertions(+), 176 deletions(-) create mode 100644 lib/core/service/patient/profile/intervention_medication_service.dart create mode 100644 lib/core/viewModel/profile/intervention_medication_view_model.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 17abf2bf..8a93f3e1 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -389,6 +389,9 @@ const GET_ALL_DISCHARGE_SUMMARY = const VTE_ASSESSMENT = "Services/Patients.svc/REST/INP_GetVTEHistoryByTransactionNo"; +const GET_INTERVENTION_MEDICATION = + "Services/DoctorApplication.svc/REST/DoctorApp_GetInterventionMedications"; + var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/core/service/patient/profile/intervention_medication_service.dart b/lib/core/service/patient/profile/intervention_medication_service.dart new file mode 100644 index 00000000..0dbd5a2f --- /dev/null +++ b/lib/core/service/patient/profile/intervention_medication_service.dart @@ -0,0 +1,34 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/model/vte_assessment/vte_assessment_req_model.dart'; +import 'package:doctor_app_flutter/core/model/vte_assessment/vte_assessment_res_model.dart'; +import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/discharge_summary/GetDischargeSummaryReqModel.dart'; +import 'package:doctor_app_flutter/models/discharge_summary/GetDischargeSummaryResModel.dart'; + +import '../../../../screens/patients/profile/new-medication-model/new_medication_req_model.dart'; +import '../../../../screens/patients/profile/new-medication-model/new_medication_res_model.dart'; + +class InterventionMedicationService extends BaseService { + + List _allInterventionList = []; + + List get allInterventionList => + _allInterventionList; + + Future getInterventionMedication( + {InterventionMedicationReqModel interventionMedicationResModel}) async { + hasError = false; + await baseAppClient.post(GET_INTERVENTION_MEDICATION, + onSuccess: (dynamic response, int statusCode) { + _allInterventionList.clear(); + response['List_InterventionMedications'].forEach( + (v) { + _allInterventionList.add(InterventionMedicationResModel.fromJson(v)); + }, + ); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: interventionMedicationResModel.toJson()); + } +} diff --git a/lib/core/viewModel/profile/intervention_medication_view_model.dart b/lib/core/viewModel/profile/intervention_medication_view_model.dart new file mode 100644 index 00000000..5f627a1b --- /dev/null +++ b/lib/core/viewModel/profile/intervention_medication_view_model.dart @@ -0,0 +1,39 @@ +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/screens/patients/profile/new-medication-model/new_medication_res_model.dart'; + +import '../../../screens/patients/profile/new-medication-model/new_medication_req_model.dart'; +import '../../service/patient/profile/intervention_medication_service.dart'; + +class InterventionMedicationViewModel extends BaseViewModel { + bool hasError = false; + InterventionMedicationService _interventionMedicationService = + locator(); + + List get allInterventionList => + _interventionMedicationService.allInterventionList; + + Future getInterventionMedication({ + int patientId, + int admissionNo, + }) async { + InterventionMedicationReqModel interventionMedicationReqModel = + InterventionMedicationReqModel( + projectID: 15, + patientID: 79941, + fromDate: '\/Date(1488322922)\/', + toDate: '\/Date(1635886800000)\/', + ); + hasError = false; + setState(ViewState.Busy); + await _interventionMedicationService.getInterventionMedication( + interventionMedicationResModel: interventionMedicationReqModel); + if (_interventionMedicationService.hasError) { + error = _interventionMedicationService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } +} diff --git a/lib/core/viewModel/profile/search_medication_view_model.dart b/lib/core/viewModel/profile/search_medication_view_model.dart index 0e67496b..2d529872 100644 --- a/lib/core/viewModel/profile/search_medication_view_model.dart +++ b/lib/core/viewModel/profile/search_medication_view_model.dart @@ -420,3 +420,45 @@ class SearchMedicationViewModel extends BaseViewModel { } } } + +// +// import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +// import 'package:doctor_app_flutter/core/model/vte_assessment/vte_assessment_req_model.dart'; +// import 'package:doctor_app_flutter/core/model/vte_assessment/vte_assessment_res_model.dart'; +// import 'package:doctor_app_flutter/core/service/patient/profile/discharge_summary_servive.dart'; +// import 'package:doctor_app_flutter/core/service/patient/profile/vte_assessment_service.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/discharge_summary/GetDischargeSummaryReqModel.dart'; +// import 'package:doctor_app_flutter/models/discharge_summary/GetDischargeSummaryResModel.dart'; +// import 'package:doctor_app_flutter/screens/patients/profile/new-medication-model/new_medication_res_model.dart'; +// +// import '../../service/patient/profile/intervention_medication_service.dart'; +// +// class SearchMedicationViewModel extends BaseViewModel { +// bool hasError = false; +// InterventionMedicationService _interventionMedicationService = +// locator(); +// +// List get allVteHistoryList => +// _interventionMedicationService.allVteHistoryList; +// +// Future getVteAssessment({ +// int patientId, +// int admissionNo, +// }) async { +// VteAssessmentRequestModel vteAssessmentRequestModel = +// VteAssessmentRequestModel( +// transactionNo: admissionNo); +// hasError = false; +// setState(ViewState.Busy); +// await _interventionMedicationService.getVteAssessment( +// vteAssessmentRequestModel: vteAssessmentRequestModel); +// if (_interventionMedicationService.hasError) { +// error = _interventionMedicationService.error; +// setState(ViewState.ErrorLocal); +// } else { +// setState(ViewState.Idle); +// } +// } +// } diff --git a/lib/locator.dart b/lib/locator.dart index 93b1b2ce..5dd6a078 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -13,6 +13,7 @@ import 'package:doctor_app_flutter/core/viewModel/profile/discharge_summary_view import 'package:doctor_app_flutter/core/viewModel/profile/operation_report_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/scan_qr_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/new-medication/intervention_medication.dart'; import 'package:doctor_app_flutter/screens/patients/profile/new-medication/new_medication_screen.dart'; import 'package:get_it/get_it.dart'; @@ -33,6 +34,7 @@ import 'core/service/patient/out_patient_service.dart'; import 'core/service/patient/patient-doctor-referral-service.dart'; import 'core/service/patient/patientInPatientService.dart'; import 'core/service/patient/patient_service.dart'; +import 'core/service/patient/profile/intervention_medication_service.dart'; import 'core/service/patient/profile/operation_report_servive.dart'; import 'core/service/patient/profile/vte_assessment_service.dart'; import 'core/service/patient/referral_patient_service.dart'; @@ -67,6 +69,8 @@ import 'core/viewModel/patient-referral-viewmodel.dart'; 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/search_medication_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'; @@ -116,6 +120,7 @@ void setupLocator() { locator.registerLazySingleton(() => PatientRegistrationService()); locator.registerLazySingleton(() => DischargeSummaryService()); locator.registerLazySingleton(() => VteAssessmentService()); + locator.registerLazySingleton(() => InterventionMedicationService()); /// View Model locator.registerFactory(() => DoctorReplayViewModel()); @@ -150,4 +155,5 @@ void setupLocator() { locator.registerFactory(() => DischargeSummaryViewModel()); locator.registerFactory(() => SearchMedicationViewModel()); locator.registerFactory(() => VteAssessmentViewModel()); + locator.registerFactory(() => InterventionMedicationViewModel()); } diff --git a/lib/routes.dart b/lib/routes.dart index ac234eb7..c4b89347 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -139,6 +139,5 @@ var routes = { ADMISSION_ORDERS: (_) => AdmissionOrdersScreen(), DIABETIC_CHART_VALUES: (_) => DiabeticChart(), NEW_MEDICATION: (_) => NewMedicationScreen(), - INTERVENTION_MEDICATION: (_) => InterventionMedicationScreen(), VTE_ASSESSMENT: (_) => VteAssessmentScreen(), }; diff --git a/lib/screens/patients/profile/new-medication/intervention_medication.dart b/lib/screens/patients/profile/new-medication/intervention_medication.dart index aeca8f88..0a7af86d 100644 --- a/lib/screens/patients/profile/new-medication/intervention_medication.dart +++ b/lib/screens/patients/profile/new-medication/intervention_medication.dart @@ -1,24 +1,29 @@ +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/pednding_orders_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'; 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/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -class InterventionMedicationScreen extends StatefulWidget { - const InterventionMedicationScreen({Key key, this.patient}) : super(key: key); - final PatiantInformtion patient ; +import '../../../../core/viewModel/profile/intervention_medication_view_model.dart'; +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +class InterventionMedicationScreen extends StatefulWidget { + final PatiantInformtion patient; + const InterventionMedicationScreen(this.patient, {Key key}) : super(key: key); @override _InterventionMedicationScreenState createState() => _InterventionMedicationScreenState(); @@ -26,27 +31,29 @@ class InterventionMedicationScreen extends StatefulWidget { class _InterventionMedicationScreenState extends State { bool isDischargedPatient = false; - AuthenticationViewModel authenticationViewModel; - ProjectViewModel projectViewModel; - @override Widget build(BuildContext context) { authenticationViewModel = Provider.of(context); projectViewModel = Provider.of(context); - return BaseView( + + return BaseView( + onModelReady: (model) => model.getInterventionMedication(patientId: widget.patient.patientId, + // admissionNo: 2016023498 + + admissionNo:int.parse(widget.patient.admissionNo) + ), builder: (_, model, w) => AppScaffold( baseViewModel: model, backgroundColor: Theme.of(context).scaffoldBackgroundColor, - //appBarTitle: TranslationBase.of(context).progressNote, appBar: PatientProfileAppBar( widget.patient, isInpatient: true, ), - body: model.admissionOrderList == null || - model.admissionOrderList.length == 0 + body: model.allInterventionList == null || + model.allInterventionList.length == 0 ? Center( child: ErrorMessage( error: TranslationBase.of(context).noDataAvailable, @@ -56,42 +63,16 @@ class _InterventionMedicationScreenState extends State[ - Padding( - padding: EdgeInsets.all(12.0), - child: Column( - children: [ - Row( - children: [ - AppText( - TranslationBase.of(context).admission, - fontSize: 15.0, - fontWeight: FontWeight.w600, - fontFamily: 'Poppins', - ), - ], - ), - Row( - children: [ - AppText( - TranslationBase.of(context).orders, - fontSize: 30.0, - fontWeight: FontWeight.w700, - ), - ], - ), - ], - ), - ), Expanded( child: Container( child: ListView.builder( - itemCount: model.admissionOrderList.length, + itemCount: model.allInterventionList.length, itemBuilder: (BuildContext ctxt, int index) { return FractionallySizedBox( widthFactor: 0.95, child: CardWithBgWidget( hasBorder: false, - bgColor: Colors.white, + bgColor: Colors.transparent, widget: Column( children: [ Column( @@ -122,83 +103,13 @@ class _InterventionMedicationScreenState extends State { Navigator.push( context, - MaterialPageRoute(builder: (context) => InterventionMedicationScreen(patient: patient,)), + MaterialPageRoute(builder: (context) => InterventionMedicationScreen(patient)), ); diff --git a/pubspec.lock b/pubspec.lock index e4f5a19f..3ba5bc57 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -770,6 +770,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2" meta: dependency: transitive description: @@ -1173,7 +1180,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" timing: dependency: transitive description: