diff --git a/lib/core/viewModel/profile/search_medication_view_model.dart b/lib/core/viewModel/profile/search_medication_view_model.dart new file mode 100644 index 00000000..0e67496b --- /dev/null +++ b/lib/core/viewModel/profile/search_medication_view_model.dart @@ -0,0 +1,422 @@ +import 'package:doctor_app_flutter/core/enum/filter_type.dart'; +import 'package:doctor_app_flutter/core/enum/patient_type.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; +import 'package:doctor_app_flutter/core/service/patient/out_patient_service.dart'; +import 'package:doctor_app_flutter/core/service/patient/patientInPatientService.dart'; +import 'package:doctor_app_flutter/core/service/special_clinics/special_clinic_service.dart'; +import 'package:doctor_app_flutter/models/dashboard/get_special_clinical_care_mapping_List_Respose_Model.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; + +import '../../../locator.dart'; +import '../base_view_model.dart'; + + + +class SearchMedicationViewModel extends BaseViewModel { + OutPatientService _outPatientService = locator(); + SpecialClinicsService _specialClinicsService = + locator(); + + List get patientList => _outPatientService.patientList; + + List + get specialClinicalCareMappingList => + _specialClinicsService.specialClinicalCareMappingList; + + List filterData = []; + + DateTime selectedFromDate; + DateTime selectedToDate; + + int firstSubsetIndex = 0; + int inPatientPageSize = 20; + int lastSubsetIndex = 20; + + List InpatientClinicList = []; + + searchData(String str) { + var strExist = str.length > 0 ? true : false; + if (strExist) { + filterData = []; + for (var i = 0; i < _outPatientService.patientList.length; i++) { + String firstName = + _outPatientService.patientList[i].firstName.toUpperCase(); + String lastName = + _outPatientService.patientList[i].lastName.toUpperCase(); + String mobile = + _outPatientService.patientList[i].mobileNumber.toUpperCase(); + String patientID = + _outPatientService.patientList[i].patientId.toString(); + + if (firstName.contains(str.toUpperCase()) || + lastName.contains(str.toUpperCase()) || + mobile.contains(str) || + patientID.contains(str)) { + filterData.add(_outPatientService.patientList[i]); + } + } + notifyListeners(); + } else { + filterData = _outPatientService.patientList; + notifyListeners(); + } + } + + getOutPatient(PatientSearchRequestModel patientSearchRequestModel, + {bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await getDoctorProfile(isGetProfile: true); + patientSearchRequestModel.doctorID = doctorProfile.doctorID; + await _outPatientService.getOutPatient(patientSearchRequestModel); + if (_outPatientService.hasError) { + error = _outPatientService.error; + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else { + filterData = _outPatientService.patientList; + setState(ViewState.Idle); + } + } + + sortOutPatient({bool isDes = false}) { + if (isDes) + filterData = filterData.reversed.toList(); + else + filterData = filterData.reversed.toList(); + setState(ViewState.Idle); + } + + getPatientFileInformation(PatientSearchRequestModel patientSearchRequestModel, + {bool isLocalBusy = false}) async { + setState(ViewState.Busy); + await _outPatientService + .getPatientFileInformation(patientSearchRequestModel); + if (_outPatientService.hasError) { + error = _outPatientService.error; + setState(ViewState.Error); + } else { + filterData = _outPatientService.patientList; + setState(ViewState.Idle); + } + } + + getPatientBasedOnDate( + {item, + PatientSearchRequestModel patientSearchRequestModel, + PatientType selectedPatientType, + bool isSearchWithKeyInfo, + OutPatientFilterType outPatientFilterType}) async { + String dateTo; + String dateFrom; + if (OutPatientFilterType.Previous == outPatientFilterType) { + selectedFromDate = DateTime( + DateTime.now().year, DateTime.now().month - 1, DateTime.now().day); + selectedToDate = DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day - 1); + dateTo = AppDateUtils.convertDateToFormat(selectedToDate, 'yyyy-MM-dd'); + dateFrom = + AppDateUtils.convertDateToFormat(selectedFromDate, 'yyyy-MM-dd'); + } else if (OutPatientFilterType.NextWeek == outPatientFilterType) { + dateTo = AppDateUtils.convertDateToFormat( + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 6), + 'yyyy-MM-dd'); + + dateFrom = AppDateUtils.convertDateToFormat( + DateTime(DateTime.now().year, DateTime.now().month, + DateTime.now().day + 1), + 'yyyy-MM-dd'); + } else { + dateFrom = AppDateUtils.convertDateToFormat( + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); + dateTo = AppDateUtils.convertDateToFormat( + DateTime( + DateTime.now().year, DateTime.now().month, DateTime.now().day), + 'yyyy-MM-dd'); + } + PatientSearchRequestModel currentModel = PatientSearchRequestModel(); + currentModel.patientID = patientSearchRequestModel.patientID; + currentModel.firstName = patientSearchRequestModel.firstName; + currentModel.lastName = patientSearchRequestModel.lastName; + currentModel.middleName = patientSearchRequestModel.middleName; + currentModel.doctorID = patientSearchRequestModel.doctorID; + currentModel.from = dateFrom; + currentModel.to = dateTo; + await getOutPatient(currentModel, isLocalBusy: true); + filterData = _outPatientService.patientList; + } + + PatientInPatientService _inPatientService = + locator(); + + List get inPatientList => _inPatientService.inPatientList; + + List get myIinPatientList => + _inPatientService.myInPatientList; + + List filteredInPatientItems = List(); + List filteredMyInPatientItems = List(); + + Future getInPatientList(PatientSearchRequestModel requestModel, + {bool isMyInpatient = false, bool isLocalBusy = false}) async { + await getDoctorProfile(); + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + if (inPatientList.length == 0) + await _inPatientService.getInPatientList(requestModel, false); + if (_inPatientService.hasError) { + error = _inPatientService.error; + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else { + setDefaultInPatientList(); + generateInpatientClinicList(); + setState(ViewState.Idle); + } + } + + sortInPatient({bool isDes = false, bool isAllClinic, bool isMyInPatient}) { + if (isMyInPatient + ? myIinPatientList.length > 0 + : isAllClinic + ? inPatientList.length > 0 + : filteredInPatientItems.length > 0) { + List localInPatient = isMyInPatient + ? [...filteredMyInPatientItems] + : isAllClinic + ? [...inPatientList] + : [...filteredInPatientItems]; + if (isDes) + localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => b + .admissionDateWithDateTimeForm + .compareTo(a.admissionDateWithDateTimeForm)); + else + localInPatient.sort((PatiantInformtion a, PatiantInformtion b) => a + .admissionDateWithDateTimeForm + .compareTo(b.admissionDateWithDateTimeForm)); + if (isMyInPatient) { + filteredMyInPatientItems.clear(); + filteredMyInPatientItems.addAll(localInPatient); + } else if (isAllClinic) { + resetInPatientPagination(); + filteredInPatientItems + .addAll(localInPatient.sublist(firstSubsetIndex, lastSubsetIndex)); + } else { + filteredInPatientItems.clear(); + filteredInPatientItems.addAll(localInPatient); + } + } + setState(ViewState.Idle); + } + + resetInPatientPagination() { + filteredInPatientItems.clear(); + firstSubsetIndex = 0; + lastSubsetIndex = inPatientPageSize - 1; + } + + Future setDefaultInPatientList() async { + setState(ViewState.BusyLocal); + await getDoctorProfile(); + resetInPatientPagination(); + if (inPatientList.length > 0) { + lastSubsetIndex = (inPatientList.length < inPatientPageSize - 1 + ? inPatientList.length + : inPatientPageSize - 1); + + filteredInPatientItems + .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); + } + + if (myIinPatientList.length > 0) { + filteredMyInPatientItems.addAll(myIinPatientList); + } + setState(ViewState.Idle); + } + + generateInpatientClinicList() { + InpatientClinicList.clear(); + inPatientList.forEach((element) { + if (!InpatientClinicList.contains(element.clinicDescription)) { + InpatientClinicList.add(element.clinicDescription); + } + }); + } + + addOnFilteredList() { + if (lastSubsetIndex < inPatientList.length) { + firstSubsetIndex = firstSubsetIndex + + (inPatientList.length - lastSubsetIndex < inPatientPageSize - 1 + ? inPatientList.length - lastSubsetIndex + : inPatientPageSize - 1); + lastSubsetIndex = lastSubsetIndex + + (inPatientList.length - lastSubsetIndex < inPatientPageSize - 1 + ? inPatientList.length - lastSubsetIndex + : inPatientPageSize - 1); + filteredInPatientItems + .addAll(inPatientList.sublist(firstSubsetIndex, lastSubsetIndex)); + setState(ViewState.Idle); + } + } + + removeOnFilteredList() { + if (lastSubsetIndex - inPatientPageSize - 1 > 0) { + filteredInPatientItems.removeAt(lastSubsetIndex - inPatientPageSize - 1); + setState(ViewState.Idle); + } + } + + filterByHospital({int hospitalId}) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + if (inPatientList[i].projectId == hospitalId) { + filteredInPatientItems.add(inPatientList[i]); + } + } + notifyListeners(); + } + + filterByClinic({String clinicName}) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + if (inPatientList[i].clinicDescription == clinicName) { + filteredInPatientItems.add(inPatientList[i]); + } + } + notifyListeners(); + } + + void clearPatientList() { + _inPatientService.inPatientList = []; + _inPatientService.myInPatientList = []; + } + + void filterSearchResults(String query, + {bool isAllClinic, bool isMyInPatient}) { + var strExist = query.length > 0 ? true : false; + + if (isMyInPatient) { + List localFilteredMyInPatientItems = [ + ...myIinPatientList + ]; + + if (strExist) { + filteredMyInPatientItems.clear(); + for (var i = 0; i < localFilteredMyInPatientItems.length; i++) { + String firstName = + localFilteredMyInPatientItems[i].firstName.toUpperCase(); + String lastName = + localFilteredMyInPatientItems[i].lastName.toUpperCase(); + String mobile = + localFilteredMyInPatientItems[i].mobileNumber.toUpperCase(); + String patientID = + localFilteredMyInPatientItems[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredMyInPatientItems.add(localFilteredMyInPatientItems[i]); + } + } + notifyListeners(); + } else { + if (myIinPatientList.length > 0) filteredMyInPatientItems.clear(); + filteredMyInPatientItems.addAll(myIinPatientList); + notifyListeners(); + } + } else { + if (isAllClinic) { + if (strExist) { + filteredInPatientItems = []; + for (var i = 0; i < inPatientList.length; i++) { + String firstName = inPatientList[i].firstName.toUpperCase(); + String lastName = inPatientList[i].lastName.toUpperCase(); + String mobile = inPatientList[i].mobileNumber.toUpperCase(); + String patientID = inPatientList[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredInPatientItems.add(inPatientList[i]); + } + } + notifyListeners(); + } else { + if (inPatientList.length > 0) filteredInPatientItems.clear(); + filteredInPatientItems.addAll(inPatientList); + notifyListeners(); + } + } else { + List localFilteredInPatientItems = [ + ...filteredInPatientItems + ]; + + if (strExist) { + filteredInPatientItems.clear(); + for (var i = 0; i < localFilteredInPatientItems.length; i++) { + String firstName = + localFilteredInPatientItems[i].firstName.toUpperCase(); + String lastName = + localFilteredInPatientItems[i].lastName.toUpperCase(); + String mobile = + localFilteredInPatientItems[i].mobileNumber.toUpperCase(); + String patientID = + localFilteredInPatientItems[i].patientId.toString(); + + if (firstName.contains(query.toUpperCase()) || + lastName.contains(query.toUpperCase()) || + mobile.contains(query) || + patientID.contains(query)) { + filteredInPatientItems.add(localFilteredInPatientItems[i]); + } + } + notifyListeners(); + } else { + if (localFilteredInPatientItems.length > 0) + filteredInPatientItems.clear(); + filteredInPatientItems.addAll(localFilteredInPatientItems); + notifyListeners(); + } + } + } + } + + getSpecialClinicalCareMappingList(clinicId, + {bool isLocalBusy = false}) async { + if (isLocalBusy) { + setState(ViewState.BusyLocal); + } else { + setState(ViewState.Busy); + } + await _specialClinicsService.getSpecialClinicalCareMappingList(clinicId); + if (_specialClinicsService.hasError) { + error = _specialClinicsService.error; + if (isLocalBusy) { + setState(ViewState.ErrorLocal); + } else { + setState(ViewState.Error); + } + } else { + setState(ViewState.Idle); + } + } +} diff --git a/lib/locator.dart b/lib/locator.dart index 28f4bfdf..d05643f0 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/new_medication_screen.dart'; import 'package:get_it/get_it.dart'; import 'core/service/AnalyticsService.dart'; @@ -65,6 +66,7 @@ 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/search_medication_view_model.dart'; import 'core/viewModel/radiology_view_model.dart'; import 'core/viewModel/referral_view_model.dart'; import 'core/viewModel/schedule_view_model.dart'; @@ -144,4 +146,5 @@ void setupLocator() { locator.registerFactory(() => PatientRegistrationViewModel()); locator.registerFactory(() => PendingOrdersViewModel()); locator.registerFactory(() => DischargeSummaryViewModel()); + locator.registerFactory(() => SearchMedicationViewModel()); } diff --git a/lib/screens/patients/profile/new-medication-model/new_medication_req_model.dart b/lib/screens/patients/profile/new-medication-model/new_medication_req_model.dart new file mode 100644 index 00000000..92cde706 --- /dev/null +++ b/lib/screens/patients/profile/new-medication-model/new_medication_req_model.dart @@ -0,0 +1,25 @@ +class InterventionMedicationReqModel { + int projectID; + int patientID; + String fromDate; + String toDate; + + InterventionMedicationReqModel( + {this.projectID, this.patientID, this.fromDate, this.toDate}); + + InterventionMedicationReqModel.fromJson(Map json) { + projectID = json['ProjectID']; + patientID = json['PatientID']; + fromDate = json['FromDate']; + toDate = json['ToDate']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['PatientID'] = this.patientID; + data['FromDate'] = this.fromDate; + data['ToDate'] = this.toDate; + return data; + } +} \ No newline at end of file diff --git a/lib/screens/patients/profile/new-medication-model/new_medication_res_model.dart b/lib/screens/patients/profile/new-medication-model/new_medication_res_model.dart new file mode 100644 index 00000000..5d3dca39 --- /dev/null +++ b/lib/screens/patients/profile/new-medication-model/new_medication_res_model.dart @@ -0,0 +1,100 @@ +class InterventionMedicationResModel { + String cS; + String iHR; + String setupID; + int projectID; + int accessLevel; + int patientID; + String patientName; + String description; + int admissionNo; + int orderNo; + int prescriptionNo; + int lineItemNo; + int itemID; + String medication; + String doctorComments; + String startDatetime; + String stopDatetime; + int status; + int createdBy; + int authorizedby; + Null pharmacyRemarks; + String statusDescription; + + InterventionMedicationResModel( + {this.cS, + this.iHR, + this.setupID, + this.projectID, + this.accessLevel, + this.patientID, + this.patientName, + this.description, + this.admissionNo, + this.orderNo, + this.prescriptionNo, + this.lineItemNo, + this.itemID, + this.medication, + this.doctorComments, + this.startDatetime, + this.stopDatetime, + this.status, + this.createdBy, + this.authorizedby, + this.pharmacyRemarks, + this.statusDescription}); + + InterventionMedicationResModel.fromJson(Map json) { + cS = json['CS']; + iHR = json['IHR']; + setupID = json['SetupID']; + projectID = json['ProjectID']; + accessLevel = json['AccessLevel']; + patientID = json['PatientID']; + patientName = json['PatientName']; + description = json['Description']; + admissionNo = json['AdmissionNo']; + orderNo = json['OrderNo']; + prescriptionNo = json['PrescriptionNo']; + lineItemNo = json['LineItemNo']; + itemID = json['ItemID']; + medication = json['Medication']; + doctorComments = json['DoctorComments']; + startDatetime = json['StartDatetime']; + stopDatetime = json['StopDatetime']; + status = json['Status']; + createdBy = json['CreatedBy']; + authorizedby = json['Authorizedby']; + pharmacyRemarks = json['PharmacyRemarks']; + statusDescription = json['StatusDescription']; + } + + Map toJson() { + final Map data = new Map(); + data['CS'] = this.cS; + data['IHR'] = this.iHR; + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['AccessLevel'] = this.accessLevel; + data['PatientID'] = this.patientID; + data['PatientName'] = this.patientName; + data['Description'] = this.description; + data['AdmissionNo'] = this.admissionNo; + data['OrderNo'] = this.orderNo; + data['PrescriptionNo'] = this.prescriptionNo; + data['LineItemNo'] = this.lineItemNo; + data['ItemID'] = this.itemID; + data['Medication'] = this.medication; + data['DoctorComments'] = this.doctorComments; + data['StartDatetime'] = this.startDatetime; + data['StopDatetime'] = this.stopDatetime; + data['Status'] = this.status; + data['CreatedBy'] = this.createdBy; + data['Authorizedby'] = this.authorizedby; + data['PharmacyRemarks'] = this.pharmacyRemarks; + data['StatusDescription'] = this.statusDescription; + 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 826d0739..aeca8f88 100644 --- a/lib/screens/patients/profile/new-medication/intervention_medication.dart +++ b/lib/screens/patients/profile/new-medication/intervention_medication.dart @@ -15,7 +15,10 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class InterventionMedicationScreen extends StatefulWidget { - const InterventionMedicationScreen({Key key}) : super(key: key); + const InterventionMedicationScreen({Key key, this.patient}) : super(key: key); + final PatiantInformtion patient ; + + @override _InterventionMedicationScreenState createState() => _InterventionMedicationScreenState(); @@ -28,25 +31,18 @@ class _InterventionMedicationScreenState extends State( - onModelReady: (model) => model.getAdmissionOrders( - admissionNo: int.parse(patient.admissionNo), - patientId: patient.patientMRN), builder: (_, model, w) => AppScaffold( baseViewModel: model, backgroundColor: Theme.of(context).scaffoldBackgroundColor, //appBarTitle: TranslationBase.of(context).progressNote, appBar: PatientProfileAppBar( - patient, + widget.patient, isInpatient: true, ), body: model.admissionOrderList == null || diff --git a/lib/screens/patients/profile/new-medication/new_medication_screen.dart b/lib/screens/patients/profile/new-medication/new_medication_screen.dart index fa3c3c69..391cafec 100644 --- a/lib/screens/patients/profile/new-medication/new_medication_screen.dart +++ b/lib/screens/patients/profile/new-medication/new_medication_screen.dart @@ -1,118 +1,268 @@ -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/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/core/enum/filter_type.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/patient_muse/PatientSearchRequestModel.dart'; +import 'package:doctor_app_flutter/core/viewModel/PatientSearchViewModel.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; import 'package:doctor_app_flutter/util/date-utils.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/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:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; -import 'package:provider/provider.dart'; +import 'package:hexcolor/hexcolor.dart'; -import '../../../../config/config.dart'; -import '../../../../routes.dart'; +import '../../../../core/viewModel/profile/operation_report_view_model.dart'; +import '../../../../core/viewModel/profile/search_medication_view_model.dart'; +import '../../../../models/patient/patiant_info_model.dart'; +import '../../../base/base_view.dart'; import 'intervention_medication.dart'; class NewMedicationScreen extends StatefulWidget { - const NewMedicationScreen({Key key}) : super(key: key); + final OutPatientFilterType outPatientFilterType; + + const NewMedicationScreen( + {Key key, this.outPatientFilterType, }) + : super(key: key); @override _NewMedicationScreenState createState() => _NewMedicationScreenState(); } class _NewMedicationScreenState extends State { - bool isDischargedPatient = false; - - AuthenticationViewModel authenticationViewModel; - - ProjectViewModel projectViewModel; + @override + void initState() { + // TODO: implement initState + super.initState(); + } @override Widget build(BuildContext context) { - authenticationViewModel = Provider.of(context); - projectViewModel = Provider.of(context); + var screenSize; final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; - String arrivalType = routeArgs['arrivalType']; - if (routeArgs.containsKey('isDischargedPatient')) - isDischargedPatient = routeArgs['isDischargedPatient']; - return BaseView( - onModelReady: (model) => model.getAdmissionOrders( - admissionNo: int.parse(patient.admissionNo), - patientId: patient.patientMRN), - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - backgroundColor: Colors.white, - //appBarTitle: TranslationBase.of(context).progressNote, - appBar: PatientProfileAppBar( - patient, - isInpatient: true, - ), - body: model.admissionOrderList == null || - model.admissionOrderList.length == 0 - ? Center( - child: ErrorMessage( - error: TranslationBase.of(context).noDataAvailable, - ), - ) - : Container( - color: Colors.white, + return BaseView( + builder: (_, model, w) =>AppScaffold( + isShowAppBar: false, + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + body: SingleChildScrollView( + child: Container( + height: MediaQuery.of(context).size.height * 1.0, child: Padding( - padding: EdgeInsets.only(left: 130,top: 300), + padding: EdgeInsets.all(0.0), child: Column( - children: [ - TextButton( - onPressed: () { - DatePicker.showDatePicker(context, - showTitleActions: true, - minTime: DateTime(1990, 3, 5), - maxTime: DateTime(2022, 6, 7), onChanged: (date) { - print('change $date'); - }, onConfirm: (date) { - print('confirm $date'); - }, currentTime: DateTime.now(), locale: LocaleType.en); - }, - child: Text( - 'Select Date From', - style: TextStyle(color: Colors.blue), - )), - TextButton( - onPressed: () { - DatePicker.showDatePicker(context, - showTitleActions: true, - minTime: DateTime(1990, 3, 5), - maxTime: DateTime(2022, 6, 7), onChanged: (date) { - print('change $date'); - }, onConfirm: (date) { - print('confirm $date'); - }, currentTime: DateTime.now(), locale: LocaleType.en); - }, - child: Text( - 'Select Date To', - style: TextStyle(color: Colors.blue), - )), - - RaisedButton( - onPressed: () => { - INTERVENTION_MEDICATION, - }, - child: - Text('Search'), - color: AppGlobal.appGreenColor, - textColor: Colors.white, - ), - ], + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + BottomSheetTitle( + title: (OutPatientFilterType.Previous == + widget.outPatientFilterType) + ? "" + : " New Medication", + ), + SizedBox( + height: 10.0, + ), + Center( + child: FractionallySizedBox( + widthFactor: 0.9, + child: Column( + children: [ + Container( + color: Colors.white, + child: InkWell( + onTap: () => selectDate(context,model, + firstDate: + getFirstDate(widget.outPatientFilterType), + lastDate: + getLastDate(widget.outPatientFilterType)), + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).fromDate, + model + .selectedFromDate != + null + ? "${AppDateUtils.convertStringToDateFormat(model.selectedFromDate.toString(), "yyyy-MM-dd")}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), + enabled: false, + ), + ), + ), + SizedBox( + height: 10, + ), + Container( + color: Colors.white, + child: InkWell( + onTap: () => selectDate(context,model, + isFromDate: false, + firstDate: + getFirstDate(widget.outPatientFilterType), + lastDate: + getLastDate(widget.outPatientFilterType)), + child: TextField( + decoration: textFieldSelectorDecoration( + TranslationBase.of(context).toDate, + model + .selectedToDate != + null + ? "${AppDateUtils.convertStringToDateFormat(model.selectedToDate.toString(), "yyyy-MM-dd")}" + : null, + true, + suffixIcon: Icon( + Icons.calendar_today, + color: Colors.black, + )), + enabled: false, + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ), ), + bottomSheet: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(0.0), ), + border: Border.all(color: HexColor('#707070'), width: 0), ), + height: MediaQuery.of(context).size.height * 0.1, + width: double.infinity, + child: Column( + children: [ + SizedBox( + height: 10, + ), + Container( + child: FractionallySizedBox( + widthFactor: .80, + child: Center( + child: AppButton( + title: TranslationBase.of(context).search, + padding: 5, + color: Color(0xFF359846), + onPressed: () async { + + Navigator.push( + context, + MaterialPageRoute(builder: (context) => InterventionMedicationScreen(patient: patient,)), + ); + }, + ), + ), + ), + ), + SizedBox( + height: 5, + ), + ], + ), + )) + ); + } + + selectDate(BuildContext context,SearchMedicationViewModel model, + {bool isFromDate = true, DateTime firstDate, lastDate}) async { + Helpers.hideKeyboard(context); + DateTime selectedDate = isFromDate + ? model.selectedFromDate ?? firstDate + : model.selectedToDate ?? lastDate; + final DateTime picked = await showDatePicker( + context: context, + initialDate: selectedDate, + firstDate: firstDate, + lastDate: lastDate, + initialEntryMode: DatePickerEntryMode.calendar, + ); + if (picked != null) { + if (isFromDate) { + setState(() { + model.selectedFromDate = picked; + var date = picked.add(Duration(days: 30)); + if (date.isBefore(lastDate)) { + model.selectedToDate = date; + } else + model.selectedToDate = lastDate; + }); + } else { + setState(() { + model.selectedToDate = picked; + }); + } + } + } + + getFirstDate(OutPatientFilterType outPatientFilterType) { + if (outPatientFilterType == OutPatientFilterType.Previous) { + return DateTime( + 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 + 7); + } + } + + InputDecoration textFieldSelectorDecoration( + String hintText, String selectedText, bool isDropDown, + {Icon suffixIcon}) { + return InputDecoration( + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Color(0xFFEFEFEF), width: 2.0), + borderRadius: BorderRadius.circular(8), + ), + hintText: selectedText != null ? selectedText : hintText, + suffixIcon: isDropDown + ? suffixIcon != null + ? suffixIcon + : Icon( + Icons.keyboard_arrow_down_sharp, + color: Color(0xff2E303A), + ) + : null, + hintStyle: TextStyle( + fontSize: 13, + color: Color(0xff2E303A), + fontFamily: 'Poppins', + fontWeight: FontWeight.w600, + ), + labelText: selectedText != null ? '$hintText\n$selectedText' : null, + labelStyle: TextStyle( + fontSize: 13, + color: Color(0xff2E303A), + fontFamily: 'Poppins', + fontWeight: FontWeight.w600, ), ); }