From e165ec5b1d866e0b42e9c0af5ea384315deb3bf9 Mon Sep 17 00:00:00 2001 From: RoaaGhali98 Date: Thu, 13 Jan 2022 14:06:28 +0200 Subject: [PATCH] add new service called intervention_medication_history_screen --- lib/config/config.dart | 3 + .../intervention_medication_service.dart | 28 +- .../intervention_medication_view_model.dart | 34 +- ...rvention_medication_history_req_model.dart | 32 ++ ...rvention_medication_history_res_model.dart | 96 ++++ .../intervention_medication.dart | 448 +++++++++--------- ...ntervention_medication_history_screen.dart | 418 ++++++++++++++++ 7 files changed, 839 insertions(+), 220 deletions(-) create mode 100644 lib/screens/patients/profile/new-medication-model/intervention_medication_history_req_model.dart create mode 100644 lib/screens/patients/profile/new-medication-model/intervention_medication_history_res_model.dart create mode 100644 lib/screens/patients/profile/new-medication/intervention_medication_history_screen.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 8a93f3e1..d85b75cc 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -392,6 +392,9 @@ const VTE_ASSESSMENT = const GET_INTERVENTION_MEDICATION = "Services/DoctorApplication.svc/REST/DoctorApp_GetInterventionMedications"; +const GET_INTERVENTION_MEDICATION_HISTORY = + "Services/DoctorApplication.svc/REST/DoctorApp_GetInterventionHistory"; + 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 index 0dbd5a2f..24d18eef 100644 --- a/lib/core/service/patient/profile/intervention_medication_service.dart +++ b/lib/core/service/patient/profile/intervention_medication_service.dart @@ -5,6 +5,8 @@ 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/intervention_medication_history_req_model.dart'; +import '../../../../screens/patients/profile/new-medication-model/intervention_medication_history_res_model.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'; @@ -12,11 +14,16 @@ class InterventionMedicationService extends BaseService { List _allInterventionList = []; + List _allInterventionHistoryList = []; + List get allInterventionList => _allInterventionList; + List get allInterventionHistoryList => + _allInterventionHistoryList; + Future getInterventionMedication( - {InterventionMedicationReqModel interventionMedicationResModel}) async { + {InterventionMedicationReqModel interventionMedicationReqModel}) async { hasError = false; await baseAppClient.post(GET_INTERVENTION_MEDICATION, onSuccess: (dynamic response, int statusCode) { @@ -29,6 +36,23 @@ class InterventionMedicationService extends BaseService { }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: interventionMedicationResModel.toJson()); + }, body: interventionMedicationReqModel.toJson()); + } + + Future getInterventionMedicationHistory( + {InterventionMedicationHistoryReqModel interventionMedicationHistoryReqModel}) async { + hasError = false; + await baseAppClient.post(GET_INTERVENTION_MEDICATION_HISTORY, + onSuccess: (dynamic response, int statusCode) { + _allInterventionHistoryList.clear(); + response['List_InterventionHistory'].forEach( + (v) { + _allInterventionHistoryList.add(InterventionMedicationHistoryResModel.fromJson(v)); + }, + ); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: interventionMedicationHistoryReqModel.toJson()); } } diff --git a/lib/core/viewModel/profile/intervention_medication_view_model.dart b/lib/core/viewModel/profile/intervention_medication_view_model.dart index 5f627a1b..8494b6d9 100644 --- a/lib/core/viewModel/profile/intervention_medication_view_model.dart +++ b/lib/core/viewModel/profile/intervention_medication_view_model.dart @@ -1,12 +1,16 @@ 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 'package:doctor_app_flutter/screens/patients/profile/new-medication-model/new_medication_res_model.dart'; +import '../../../screens/patients/profile/new-medication-model/intervention_medication_history_req_model.dart'; +import '../../../screens/patients/profile/new-medication-model/intervention_medication_history_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 { + PatiantInformtion patient; bool hasError = false; InterventionMedicationService _interventionMedicationService = locator(); @@ -14,6 +18,10 @@ class InterventionMedicationViewModel extends BaseViewModel { List get allInterventionList => _interventionMedicationService.allInterventionList; + List get allInterventionHistoryList => + _interventionMedicationService.allInterventionHistoryList; + + Future getInterventionMedication({ int patientId, int admissionNo, @@ -28,7 +36,31 @@ class InterventionMedicationViewModel extends BaseViewModel { hasError = false; setState(ViewState.Busy); await _interventionMedicationService.getInterventionMedication( - interventionMedicationResModel: interventionMedicationReqModel); + interventionMedicationReqModel: interventionMedicationReqModel); + if (_interventionMedicationService.hasError) { + error = _interventionMedicationService.error; + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Idle); + } + } + + + Future getInterventionMedicationHistory({ + int patientId, + }) async { + InterventionMedicationHistoryReqModel interventionMedicationHistoryReqModel = + InterventionMedicationHistoryReqModel( + projectID: 15, + patientID: 79941, + admissionNo: 2018013900, + prescriptionNo: 2045165, + orderNo: 1171570, + ); + hasError = false; + setState(ViewState.Busy); + await _interventionMedicationService.getInterventionMedicationHistory( + interventionMedicationHistoryReqModel: interventionMedicationHistoryReqModel); if (_interventionMedicationService.hasError) { error = _interventionMedicationService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/patients/profile/new-medication-model/intervention_medication_history_req_model.dart b/lib/screens/patients/profile/new-medication-model/intervention_medication_history_req_model.dart new file mode 100644 index 00000000..122212b7 --- /dev/null +++ b/lib/screens/patients/profile/new-medication-model/intervention_medication_history_req_model.dart @@ -0,0 +1,32 @@ +class InterventionMedicationHistoryReqModel { + int projectID; + int patientID; + int admissionNo; + int orderNo; + int prescriptionNo; + + InterventionMedicationHistoryReqModel( + {this.projectID, + this.patientID, + this.admissionNo, + this.orderNo, + this.prescriptionNo}); + + InterventionMedicationHistoryReqModel.fromJson(Map json) { + projectID = json['ProjectID']; + patientID = json['PatientID']; + admissionNo = json['AdmissionNo']; + orderNo = json['OrderNo']; + prescriptionNo = json['PrescriptionNo']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['PatientID'] = this.patientID; + data['AdmissionNo'] = this.admissionNo; + data['OrderNo'] = this.orderNo; + data['PrescriptionNo'] = this.prescriptionNo; + return data; + } +} \ No newline at end of file diff --git a/lib/screens/patients/profile/new-medication-model/intervention_medication_history_res_model.dart b/lib/screens/patients/profile/new-medication-model/intervention_medication_history_res_model.dart new file mode 100644 index 00000000..451cccb8 --- /dev/null +++ b/lib/screens/patients/profile/new-medication-model/intervention_medication_history_res_model.dart @@ -0,0 +1,96 @@ +class InterventionMedicationHistoryResModel { + String setupId; + String projectId; + int patientId; + int admissionNo; + int prescriptionId; + int orderNo; + int id; + int interventionId; + Null intervention; + String remark; + int commentedBy; + bool isDoctor; + bool isActive; + int createdBy; + String createdByName; + String createdByNameN; + String createdOn; + Null editedBy; + Null editedByName; + Null editedByNameN; + Null editedOn; + + InterventionMedicationHistoryResModel( + {this.setupId, + this.projectId, + this.patientId, + this.admissionNo, + this.prescriptionId, + this.orderNo, + this.id, + this.interventionId, + this.intervention, + this.remark, + this.commentedBy, + this.isDoctor, + this.isActive, + this.createdBy, + this.createdByName, + this.createdByNameN, + this.createdOn, + this.editedBy, + this.editedByName, + this.editedByNameN, + this.editedOn}); + + InterventionMedicationHistoryResModel.fromJson(Map json) { + setupId = json['SetupId']; + projectId = json['ProjectId']; + patientId = json['PatientId']; + admissionNo = json['AdmissionNo']; + prescriptionId = json['PrescriptionId']; + orderNo = json['OrderNo']; + id = json['Id']; + interventionId = json['InterventionId']; + intervention = json['Intervention']; + remark = json['Remark']; + commentedBy = json['CommentedBy']; + isDoctor = json['IsDoctor']; + isActive = json['IsActive']; + createdBy = json['CreatedBy']; + createdByName = json['CreatedByName']; + createdByNameN = json['CreatedByNameN']; + createdOn = json['CreatedOn']; + editedBy = json['EditedBy']; + editedByName = json['EditedByName']; + editedByNameN = json['EditedByNameN']; + editedOn = json['EditedOn']; + } + + Map toJson() { + final Map data = new Map(); + data['SetupId'] = this.setupId; + data['ProjectId'] = this.projectId; + data['PatientId'] = this.patientId; + data['AdmissionNo'] = this.admissionNo; + data['PrescriptionId'] = this.prescriptionId; + data['OrderNo'] = this.orderNo; + data['Id'] = this.id; + data['InterventionId'] = this.interventionId; + data['Intervention'] = this.intervention; + data['Remark'] = this.remark; + data['CommentedBy'] = this.commentedBy; + data['IsDoctor'] = this.isDoctor; + data['IsActive'] = this.isActive; + data['CreatedBy'] = this.createdBy; + data['CreatedByName'] = this.createdByName; + data['CreatedByNameN'] = this.createdByNameN; + data['CreatedOn'] = this.createdOn; + data['EditedBy'] = this.editedBy; + data['EditedByName'] = this.editedByName; + data['EditedByNameN'] = this.editedByNameN; + data['EditedOn'] = this.editedOn; + return data; + } +} \ No newline at end of file diff --git a/lib/screens/patients/profile/new-medication/intervention_medication.dart b/lib/screens/patients/profile/new-medication/intervention_medication.dart index 2e3fb589..0ae3cee3 100644 --- a/lib/screens/patients/profile/new-medication/intervention_medication.dart +++ b/lib/screens/patients/profile/new-medication/intervention_medication.dart @@ -18,6 +18,8 @@ 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'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -59,43 +61,64 @@ 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, - children: [ - Container( - width: MediaQuery.of(context) - .size - .width * - 0.60, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, + children: [ + 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, + 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( children: [ Row( crossAxisAlignment: @@ -103,9 +126,15 @@ class _InterventionMedicationScreenState extends State _InterventionMedicationHistoryScreenState(); +} + +class _InterventionMedicationHistoryScreenState extends State { + bool isDischargedPatient = false; + AuthenticationViewModel authenticationViewModel; + ProjectViewModel projectViewModel; + + @override + Widget build(BuildContext context) { + authenticationViewModel = Provider.of(context); + projectViewModel = Provider.of(context); + + return BaseView( + onModelReady: (model) => model.getInterventionMedicationHistory(patientId: widget.patient.patientId, + ), + builder: (_, model, w) => AppScaffold( + baseViewModel: model, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + appBar: PatientProfileAppBar( + widget.patient, + isInpatient: true, + ), + body: model.allInterventionHistoryList == null || + model.allInterventionHistoryList.length == 0 + ? Center( + child: ErrorMessage( + error: TranslationBase.of(context).noDataAvailable, + ), + ) + : Container( + color: Colors.grey[200], + child: Column( + children: [ + Expanded( + child: Container( + child: ListView.builder( + itemCount: model.allInterventionHistoryList.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, + children: [ + Container( + width: MediaQuery.of(context) + .size + .width * + 0.60, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + AppText( + model + .allInterventionHistoryList[ + index].setupId, + fontWeight: FontWeight.w600, + fontSize: 14, + ), + + ], + ), + ], + ), + ), + Column( + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + AppText( + AppDateUtils.getDayMonthYearDateFormatted( + AppDateUtils.convertStringToDate( + model + .allInterventionHistoryList[ + index].createdOn) + ,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 + .allInterventionHistoryList[ + index] + .remark, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + SizedBox( + height: 8, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context) + // .pharmacology + + // " : ", + // fontSize: 12, + // ), + Expanded( + child: AppText( + model + .allInterventionHistoryList[ + index] + .createdByName, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + SizedBox( + height: 8, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context) + // .reasonsThrombo + + // " : ", + // fontSize: 12, + // ), + Expanded( + child: AppText( + model + .allInterventionHistoryList[ + index] + .setupId, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + SizedBox( + height: 8, + ), + + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + // AppText( + // TranslationBase.of(context) + // .reasonsThrombo + + // " : ", + // fontSize: 12, + // ), + Expanded( + child: AppText( + model + .allInterventionHistoryList[ + index] + .setupId, + fontSize: 12, + isCopyable: true, + ), + ), + ]), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + InkWell( + onTap: () async { + await locator() + .logEvent( + eventCategory: + "Operation Report Screen", + eventAction: + "Update Operation Report ", + ); + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => + // UpdateOperationReport( + // reservation: model + // .reservationList[ + // index], + // patient: patient, + // isUpdate: true, + // )), + // ); + }, + child: Container( + decoration: BoxDecoration( + color: AppGlobal.appRedColor, + borderRadius: + BorderRadius.circular(10), + ), + // color:Colors.red[600], + + child: Row( + children: [ + + SizedBox( + width: 2, + ), + AppText( + TranslationBase.of(context) + .accept, + fontSize: 10, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), + ), + ), + SizedBox( + width: 10, + ), + InkWell( + onTap: () async { + await locator() + .logEvent( + eventCategory: + "Operation Report Screen", + eventAction: + "Update Operation Report ", + ); + // Navigator.push( + // context, + // MaterialPageRoute( + // builder: (context) => + // UpdateOperationReport( + // reservation: model + // .reservationList[ + // index], + // patient: patient, + // isUpdate: true, + // )), + // ); + }, + child: Container( + decoration: BoxDecoration( + color: AppGlobal.appGreenColor, + borderRadius: + BorderRadius.circular(10), + ), + // color:Colors.red[600], + + child: Row( + children: [ + + SizedBox( + width: 2, + ), + AppText( + TranslationBase.of(context) + .reject, + fontSize: 10, + color: Colors.white, + ), + ], + ), + padding: EdgeInsets.all(6), + ), + ), + ], + ), + + ], + ), + SizedBox( + height: 20, + ), + ], + ), + ), + ); + }), + ), + ), + ], + ), + ), + ), + ); + } +}