diff --git a/lib/config/config.dart b/lib/config/config.dart index 01ddb6ef..1377a582 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -318,6 +318,14 @@ const GET_EDIT_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergy'; const GET_HOME_MEDICATION = 'Services/DoctorApplication.svc/REST/GetHomeMedication'; +const SEARCH_CURRENT_MEDICATION = 'Services/DoctorApplication.svc/REST/SearchFormulary'; + +const SEARCH_CURRENT_MEDICATION_DETAILS = 'Services/DoctorApplication.svc/REST/GetFormularyMaster'; + +const REMOVE_CURRENT_MEDICATION = 'Services/DoctorApplication.svc/REST/DeleteHomeMedication'; + +const ADD_CURRENT_MEDICATION = 'Services/DoctorApplication.svc/REST/AddHomeMedication'; + var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/core/model/SOAP/home_medication_vp/GetSearchCurrentMedication.dart b/lib/core/model/SOAP/home_medication_vp/GetSearchCurrentMedication.dart new file mode 100644 index 00000000..fd94d9cf --- /dev/null +++ b/lib/core/model/SOAP/home_medication_vp/GetSearchCurrentMedication.dart @@ -0,0 +1,40 @@ +class GetSearchCurrentMedication { + String? formularyName; + String? genericFormularyCode; + String? genericFormularyId; + int? hospitalGroupId; + int? hospitalId; + String? itemType; + bool? outOfStock; + + GetSearchCurrentMedication( + {this.formularyName, + this.genericFormularyCode, + this.genericFormularyId, + this.hospitalGroupId, + this.hospitalId, + this.itemType, + this.outOfStock}); + + GetSearchCurrentMedication.fromJson(Map json) { + formularyName = json['formularyName']; + genericFormularyCode = json['genericFormularyCode']; + genericFormularyId = json['genericFormularyId']; + hospitalGroupId = json['hospitalGroupId']; + hospitalId = json['hospitalId']; + itemType = json['itemType']; + outOfStock = json['outOfStock']; + } + + Map toJson() { + final Map data = new Map(); + data['formularyName'] = this.formularyName; + data['genericFormularyCode'] = this.genericFormularyCode; + data['genericFormularyId'] = this.genericFormularyId; + data['hospitalGroupId'] = this.hospitalGroupId; + data['hospitalId'] = this.hospitalId; + data['itemType'] = this.itemType; + data['outOfStock'] = this.outOfStock; + return data; + } +} diff --git a/lib/core/model/SOAP/home_medication_vp/GetSearchCurrentMedicationDetails.dart b/lib/core/model/SOAP/home_medication_vp/GetSearchCurrentMedicationDetails.dart new file mode 100644 index 00000000..0cdd9ada --- /dev/null +++ b/lib/core/model/SOAP/home_medication_vp/GetSearchCurrentMedicationDetails.dart @@ -0,0 +1,108 @@ +class GetSearchCurrentMedicationDetails { + List? genericItemFrequencyDetailsEntity; + List? genericItemRouteDetailsEntity; + List? itemStrengthDetailsDto; + int? patientTypeId; + + GetSearchCurrentMedicationDetails({this.genericItemFrequencyDetailsEntity, this.genericItemRouteDetailsEntity, this.itemStrengthDetailsDto, this.patientTypeId}); + + GetSearchCurrentMedicationDetails.fromJson(Map json) { + if (json['genericItemFrequencyDetailsEntity'] != null) { + genericItemFrequencyDetailsEntity = []; + json['genericItemFrequencyDetailsEntity'].forEach((v) { genericItemFrequencyDetailsEntity!.add(new GenericItemFrequencyDetailsEntity.fromJson(v)); }); + } + if (json['genericItemRouteDetailsEntity'] != null) { + genericItemRouteDetailsEntity = []; + json['genericItemRouteDetailsEntity'].forEach((v) { genericItemRouteDetailsEntity!.add(new GenericItemRouteDetailsEntity.fromJson(v)); }); + } + if (json['itemStrengthDetailsDto'] != null) { + itemStrengthDetailsDto = []; + json['itemStrengthDetailsDto'].forEach((v) { itemStrengthDetailsDto!.add(new ItemStrengthDetailsDto.fromJson(v)); }); + } + patientTypeId = json['patientTypeId']; + } + + Map toJson() { + final Map data = new Map(); + if (this.genericItemFrequencyDetailsEntity != null) { + data['genericItemFrequencyDetailsEntity'] = this.genericItemFrequencyDetailsEntity!.map((v) => v.toJson()).toList(); + } + if (this.genericItemRouteDetailsEntity != null) { + data['genericItemRouteDetailsEntity'] = this.genericItemRouteDetailsEntity!.map((v) => v.toJson()).toList(); + } + if (this.itemStrengthDetailsDto != null) { + data['itemStrengthDetailsDto'] = this.itemStrengthDetailsDto!.map((v) => v.toJson()).toList(); + } + data['patientTypeId'] = this.patientTypeId; + return data; + } +} + +class GenericItemFrequencyDetailsEntity { + bool? Default; + String? frequency; + int? frequencyId; + int? interval; + + GenericItemFrequencyDetailsEntity({this.Default, this.frequency, this.frequencyId, this.interval}); + +GenericItemFrequencyDetailsEntity.fromJson(Map json) { +Default = json['Default']; +frequency = json['Frequency']; +frequencyId = json['FrequencyId']; +interval = json['Interval']; +} + +Map toJson() { +final Map data = new Map(); +data['Default'] = this.Default; +data['Frequency'] = this.frequency; +data['FrequencyId'] = this.frequencyId; +data['Interval'] = this.interval; +return data; +} +} + +class GenericItemRouteDetailsEntity { +bool? Default; +String? route; +int? routeId; + +GenericItemRouteDetailsEntity({this.Default, this.route, this.routeId}); + +GenericItemRouteDetailsEntity.fromJson(Map json) { +Default = json['default']; +route = json['route']; +routeId = json['routeId']; +} + +Map toJson() { +final Map data = new Map(); +data['default'] = this.Default; +data['route'] = this.route; +data['routeId'] = this.routeId; +return data; +} +} + +class ItemStrengthDetailsDto { +bool? Default; +String? strength; +int? strengthId; + +ItemStrengthDetailsDto({this.Default, this.strength, this.strengthId}); + +ItemStrengthDetailsDto.fromJson(Map json) { +Default = json['default']; +strength = json['strength']; +strengthId = json['strengthId']; +} + +Map toJson() { +final Map data = new Map(); +data['default'] = this.Default; +data['strength'] = this.strength; +data['strengthId'] = this.strengthId; +return data; +} +} diff --git a/lib/core/service/patient_medical_file/soap/SOAP_service.dart b/lib/core/service/patient_medical_file/soap/SOAP_service.dart index 2aa75087..179e766e 100644 --- a/lib/core/service/patient_medical_file/soap/SOAP_service.dart +++ b/lib/core/service/patient_medical_file/soap/SOAP_service.dart @@ -1,8 +1,10 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/core/model/SOAP/Allergy/get_allergies_res_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/Assessment/get_assessment_res_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_allergies_list_vida_plus.dart'; import 'package:doctor_app_flutter/core/model/SOAP/allergy/get_patient_allergies_list_vida_plus.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/assessment/patch_assessment_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/episode_by_chief_complaint_vidaplus.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_vida_plus.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.dart'; @@ -10,6 +12,8 @@ import 'package:doctor_app_flutter/core/model/SOAP/general_get_req_for_SOAP.dart import 'package:doctor_app_flutter/core/model/SOAP/Assessment/get_assessment_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/get_hopi_details.dart'; import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetHomeMedication.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetSearchCurrentMedication.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetSearchCurrentMedicationDetails.dart'; import 'package:doctor_app_flutter/core/model/SOAP/post_episode_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_res_model.dart'; @@ -27,16 +31,12 @@ import 'package:doctor_app_flutter/core/model/SOAP/physical_exam/post_physical_e import 'package:doctor_app_flutter/core/model/SOAP/progress_note/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/get_progress_note_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/progress_note/post_progress_note_request_model.dart'; -import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/service/base/lookup-service.dart'; +import 'package:doctor_app_flutter/utils/date-utils.dart'; import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; -import 'package:http/http.dart'; -import '../../../../config/shared_pref_kay.dart'; -import '../../../../utils/date-utils.dart'; -import '../../../model/SOAP/assessment/patch_assessment_req_model.dart'; -import '../../../model/patient/patiant_info_model.dart'; -import '../../base/lookup-service.dart'; class SOAPService extends LookupService { List patientChiefComplaintList = []; @@ -52,8 +52,8 @@ class SOAPService extends LookupService { List searchChiefComplaintListVidaPlus = []; List episodeByChiefComplaintListVidaPlus = []; List getHomeMedicationList = []; - - + List getSearchCurrentMedication = []; + List getSearchCurrentMedicationDetails = []; int? episodeID; bool isPrescriptionOrder = false; @@ -745,7 +745,6 @@ class SOAPService extends LookupService { await baseAppClient.post(GET_HOME_MEDICATION, onSuccess: (dynamic response, int statusCode) { getHomeMedicationList.clear(); - response['ListHomeMedication']['resultData'].forEach((v) { getHomeMedicationList.add(GetHomeMedicationList.fromJson(v)); }); @@ -755,27 +754,91 @@ class SOAPService extends LookupService { }, body: request); } - // createCCByEpisodeVidaPlus( - // PatiantInformtion patient, List chiefComplaint) async { - // Map request = - // { - // "appointmentId": patient.appointmentNo, - // "projectId": patient.projectId, - // "setupId": 105, - // "chiefComplain":chiefComplaint, - // "patientId": patient.patientId, - // "pomrId": patient.pomrId, - // "doctorId": 2, - // }; - // - // hasError = false; - // await baseAppClient.post(UPDATE_CHIEF_COMPLAINT, - // onSuccess: (dynamic response, int statusCode) { - // print("Success"); - // }, onFailure: (String error, int statusCode) { - // hasError = true; - // super.error = error; - // }, body: request); - // } + searchCurrentMedication( + String query + ) async { + Map request = { + "SearchKey": query + }; + hasError = false; + await baseAppClient.post(SEARCH_CURRENT_MEDICATION, + onSuccess: (dynamic response, int statusCode) { + getSearchCurrentMedication.clear(); + response['ListFormulatorySearch']['resultData'].forEach((v) { + getSearchCurrentMedication.add(GetSearchCurrentMedication.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); + } + + + getCurrentMedicationDetails( + String id + ) async { + Map request = { + "genericFormularyId": id + }; + hasError = false; + await baseAppClient.post(SEARCH_CURRENT_MEDICATION_DETAILS, + onSuccess: (dynamic response, int statusCode) { + getSearchCurrentMedicationDetails.clear(); + response['ListFormularyMaster']['resultData'].forEach((v) { + getSearchCurrentMedicationDetails.add(GetSearchCurrentMedicationDetails.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: request); + } + + removeCurrentMedicationVidaPlus( + String medicationID) async { + Map request = { + + "homeMedicationId":medicationID + }; + hasError = false; + await baseAppClient.post(REMOVE_CURRENT_MEDICATION, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + + hasError = true; + super.error = error; + }, body: request); + } + + addCurrentMedicationVidaPlus( + Map request, PatiantInformtion patientInfo) async { + + var doctorProfile = await sharedPref.getObj(LOGGED_IN_USER); + + Map genericRequest ={ + "patientId": patientInfo.patientId, + "patientPomrId": patientInfo.pomrId, + "hospitalId": patientInfo.projectId, + "hospitalGroupId": await sharedPref.getString(DOCTOR_SETUP_ID), + "clinicGroupId": patientInfo.clinicGroupId, + "clinicId": patientInfo.clinicId, + "appointmentId": patientInfo.appointmentNo, + "created_by": patientInfo.doctorId, + "loginUserId": doctorProfile['List_MemberInformation'][0]['MemberID'], + }; + + Map finalRequest = {} + ..addAll(request) + ..addAll(genericRequest); + hasError = false; + await baseAppClient.post(ADD_CURRENT_MEDICATION, + onSuccess: (dynamic response, int statusCode) { + + }, onFailure: (String error, int statusCode) { + + hasError = true; + super.error = error; + }, body: finalRequest); + } } diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index ba6a0c24..71a95fe5 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -18,6 +18,8 @@ import 'package:doctor_app_flutter/core/model/SOAP/history/get_history_req_model import 'package:doctor_app_flutter/core/model/SOAP/history/get_history_res_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/history/post_histories_request_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetHomeMedication.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetSearchCurrentMedication.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetSearchCurrentMedicationDetails.dart'; import 'package:doctor_app_flutter/core/model/SOAP/in_patient/get_episode_for_inpatient_req_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/in_patient/post_episode_for_Inpatient_request_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; @@ -145,6 +147,14 @@ class SOAPViewModel extends BaseViewModel { _SOAPService.getHomeMedicationList; + List? get getMedicationListVP => + _SOAPService.getSearchCurrentMedication; + + + List? get getSearchCurrentMedicationDetails => + _SOAPService.getSearchCurrentMedicationDetails; + + late SubjectiveCallBack subjectiveCallBack; setSubjectiveCallBack(SubjectiveCallBack callBack) { @@ -1074,4 +1084,45 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + searchCurrentMedication(String searchQuery) async{ + setState(ViewState.BusyLocal); + await _SOAPService.searchCurrentMedication(searchQuery); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + getCurrentMedicationDetails(String id) async{ + setState(ViewState.BusyLocal); + await _SOAPService.getCurrentMedicationDetails(id); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + removeCurrentMedication(String id) async{ + setState(ViewState.BusyLocal); + await _SOAPService.removeCurrentMedicationVidaPlus(id); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + addCurrentMedication(request, PatiantInformtion patientInfo) async{ + setState(ViewState.BusyLocal); + await _SOAPService.addCurrentMedicationVidaPlus(request, patientInfo); + if (_SOAPService.hasError) { + error = _SOAPService.error; + + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + } diff --git a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart index 0fb93724..9735fe2c 100644 --- a/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/add_patient_sick_leave_screen.dart @@ -52,7 +52,9 @@ class _AddPatientSickLeaveScreenState extends State { showDatePicker( context: context, initialDate: currentDate ?? DateTime.now(), - firstDate: DateTime(DateTime.now().year - 1), + firstDate: AppDateUtils.convertStringToDate( + widget!.patient!.arrivedOn!, + ), lastDate: DateTime(DateTime.now().year + 1), ).then((pickedDate) { if (pickedDate == null) { diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart index b45912ef..8ac3c13b 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/allergies/reactions_selection.dart @@ -41,8 +41,12 @@ class _ReactionsSelectionAllergiesWidgetState extends State { bool loading = false; TextEditingController remark = TextEditingController(); + List? controllers =[]; + @override void initState() { + controllers = List.generate(widget.mySelectedAllergy! + .allergyReactionDTOs!.length, (index) => ExpansionTileController()); super.initState(); } @@ -71,6 +75,8 @@ class _ReactionsSelectionAllergiesWidgetState return Column(children: [ ExpansionTile( + + controller: controllers![index], key: Key(index.toString()), dense: false, enableFeedback: false, @@ -90,7 +96,11 @@ class _ReactionsSelectionAllergiesWidgetState .mySelectedAllergy! .allergyReactionDTOs![index] .isSelected = value; - setState(() {}); + + value ==true ? controllers![index].expand() : controllers![index].collapse() ; + setState(() { + + }); // setState(() {}); }), title: AppText(widget .mySelectedAllergy! diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/add_medication.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/add_medication.dart index 034da359..9cf67d16 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/add_medication.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/add_medication.dart @@ -2,341 +2,453 @@ import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetSearchCurrentMedication.dart'; import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; +import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/objective/widget/EmptyExamination.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/medication/dropdown_popup.dart'; +import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/utils/utils.dart'; import 'package:doctor_app_flutter/widgets/bottom_sheet/custom_bottom_sheet_container.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/dialogs/master_key_dailog.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/auto_complete_text_field.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; - // ignore: must_be_immutable class AddMedication extends StatefulWidget { - final Function(MySelectedAllergy mySelectedAllergy) addMedicationFun; - TextEditingController medicationController; - - AddMedication({Key? key, required this.addMedicationFun, required this.medicationController}) : super(key: key); + final Function() addMedicationFun; + final PatiantInformtion? patientInfo; + AddMedication({Key? key, required this.addMedicationFun, this.patientInfo}) : super(key: key); @override _AddMedicationState createState() => _AddMedicationState(); } class _AddMedicationState extends State { - MasterKeyModel? _selectedMedicationDose; - MasterKeyModel? _selectedMedicationStrength; - MasterKeyModel? _selectedMedicationRoute; - MasterKeyModel? _selectedMedicationFrequency; + int? _selectedMedicationStrength; + int? _selectedMedicationRoute; + int? _selectedMedicationFrequency; + TextEditingController medicationController = TextEditingController(); TextEditingController doseController = TextEditingController(); TextEditingController strengthController = TextEditingController(); TextEditingController routeController = TextEditingController(); TextEditingController frequencyController = TextEditingController(); - GetMedicationResponseModel? _selectedMedication; - - GlobalKey> key = GlobalKey>(); + GetSearchCurrentMedication? _selectedMedication; + TextEditingController remark = TextEditingController(); + bool isVisible = false; + GlobalKey> key = + GlobalKey>(); bool isFormSubmitted = false; @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); - return BaseView( - onModelReady: (model) async { - // model.onAddMedicationStart(); - }, - builder: (_, model, w) => AppScaffold( + return BaseView( + onModelReady: (model) async { + // model.onAddMedicationStart(); + }, + builder: (_, model, w) => AppScaffold( backgroundColor: Colors.white, - baseViewModel: model, - isShowAppBar: true, - appBar: PatientSearchHeader( - - title:TranslationBase.of(context).addMedication, - ), - body: Container( - padding: EdgeInsets.all(15), - child: - SingleChildScrollView( - child: Column( - children: [ - // SizedBox( - // height: SizeConfig.heightMultiplier! * - // (SizeConfig.isHeightVeryShort - // ? 2 - // : SizeConfig.isHeightShort - // ? 2 - // : 2), - // ), - // Container( - // // height: screenSize.height * 0.070, - // child: InkWell( - // onTap: model.allMedicationList != null - // ? () { - // setState(() { - // _selectedMedication = GetMedicationResponseModel(); - // }); - // } - // : null, - // child: _selectedMedication == null - // // ? - // CustomAutoCompleteTextField( - // isShowError: isFormSubmitted && _selectedMedication == null, - // child: AutoCompleteTextField( - // decoration: TextFieldsUtils.textFieldSelectorDecoration(TranslationBase.of(context).searchMedicineNameHere, "", true, suffixIcon: Icons.search), - // itemSubmitted: (item) => setState(() => _selectedMedication = item), - // key: key, - // suggestions: model.allMedicationList!, - // itemBuilder: (context, suggestion) => new Padding(child: AppText(suggestion.description! + '/' + suggestion.genericName!), padding: EdgeInsets.all(8.0)), - // itemSorter: (a, b) => 1, - // itemFilter: (suggestion, input) => - // suggestion.genericName!.toLowerCase().startsWith(input.toLowerCase()) || - // suggestion.description!.toLowerCase().startsWith(input.toLowerCase()) || - // suggestion.keywords!.toLowerCase().startsWith(input.toLowerCase()), - // ), - // ) - // : - AppTextFieldCustom( - height: Utils.getTextFieldHeight(), - hintText: _selectedMedication != null - ? _selectedMedication!.description! + (' (${_selectedMedication!.genericName} )') - : TranslationBase.of(context).searchMedicineNameHere, - minLines: 1, - maxLines: 1, - isTextFieldHasSuffix: true, - suffixIcon: IconButton( - icon: Icon( - Icons.search, - color: Colors.grey.shade600, - ), - onPressed: () {}, - ), + baseViewModel: model, + isShowAppBar: true, + appBar: PatientSearchHeader( + title: TranslationBase.of(context).addMedication, + ), + body: Container( + padding: EdgeInsets.all(15), + child: SingleChildScrollView( + child: Column( + children: [ - onChanged: (value) {}, - onFieldSubmitted: () {}, - ), - // ), - // ), - if (_selectedMedication != null) - Column( - children: [ - SizedBox( - height: 3, - ), - Container( - width: MediaQuery.of(context).size.width * 0.7, - child: AppText( - _selectedMedication!.description! + (' (${_selectedMedication!.genericName} )'), - color: Color(0xFF575757), - fontSize: 10, - fontWeight: FontWeight.w700, - letterSpacing: -0.4, - ), - ), - ], - ), - SizedBox( - height: 5, + AppTextFieldCustom( + height: Utils.getTextFieldHeight(), + controller: medicationController, + hintText: + TranslationBase.of(context).searchMedicineNameHere, + minLines: 1, + maxLines: 1, + isTextFieldHasSuffix: true, + validationError: isFormSubmitted && medicationController.text.isEmpty ? TranslationBase.of(context).emptyMessage : null, + suffixIcon: IconButton( + icon: model.state == ViewState.BusyLocal + ? SizedBox( + child: CircularProgressIndicator( + strokeWidth: 2, ), - AppTextFieldCustom( - height: Utils.getTextFieldHeight(), + height: 10, + width: 10, + ) + : Icon( + Icons.search, + color: Colors.grey.shade600, + ), + onPressed: () { + searchMedication(model); + }, + ), + onChanged: (value) {}, + onFieldSubmitted: () {}, + ), + // ), + // ), + model.getMedicationListVP!.isNotEmpty & isVisible + ? RoundedContainer( + width: MediaQuery.of(context).size.width, + height: MediaQuery.of(context).size.height * 0.60, + child: model.state == ViewState.Idle + ? ListView.builder( + itemCount: model.getMedicationListVP!.length, + itemBuilder: (context, index) { + return ListTile( + onTap: () { + selectMedication(model, index); + }, + title: AppText( + model.getMedicationListVP![index] + .formularyName!, + )); + }, + ) + : SizedBox()) + : SizedBox(), - onClick: model.medicationDoseTimeList != null - ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationDoseTimeList, - okText: TranslationBase.of(context).ok, - selectedValue: _selectedMedicationDose, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationDose = selectedValue; + if (_selectedMedication != null) + Column( + children: [ + SizedBox( + height: 3, + ), + Container( + width: MediaQuery.of(context).size.width * 0.9, + child: AppText( + _selectedMedication!.formularyName!, + color: Color(0xFF575757), + fontSize: 10, + fontWeight: FontWeight.w700, + letterSpacing: -0.4, + ), + ), + ], + ), + SizedBox( + height: 5, + ), - doseController.text = projectViewModel.isArabic ? _selectedMedicationDose!.nameAr! : _selectedMedicationDose!.nameEn!; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: TranslationBase.of(context).doseTime, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - controller: doseController, - validationError: isFormSubmitted && _selectedMedicationDose == null ? TranslationBase.of(context).emptyMessage : null, - onChanged: (value) {}, - onFieldSubmitted: () {}, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Utils.getTextFieldHeight(), + SizedBox( + height: 5, + ), + AppTextFieldCustom( + height: Utils.getTextFieldHeight(), + enabled: true, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly + ], + // onClick: model.medicationDoseTimeList != null + // ? () { + // MasterKeyDailog dialog = MasterKeyDailog( + // list: model.medicationDoseTimeList, + // okText: TranslationBase.of(context).ok, + // // selectedValue: _selectedMedicationDose, + // okFunction: (selectedValue) { + // setState(() { + // _selectedMedicationDose = selectedValue; + // + // doseController.text = projectViewModel.isArabic ? _selectedMedicationDose!.nameAr! : _selectedMedicationDose!.nameEn!; + // }); + // }, + // ); + // showDialog( + // barrierDismissible: false, + // context: context, + // builder: (BuildContext context) { + // return dialog; + // }, + // ); + // } + // : null, + hintText: TranslationBase.of(context).doseDetails, + maxLines: 1, + minLines: 1, - isTextFieldHasSuffix: true, - onClick: model.medicationStrengthList != null - ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationStrengthList, - okText: TranslationBase.of(context).ok, - selectedValue: _selectedMedicationStrength, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationStrength = selectedValue; + isTextFieldHasSuffix: false, + controller: doseController, + validationError: isFormSubmitted && doseController.text.isEmpty ? TranslationBase.of(context).emptyMessage : null, + onChanged: (value) {}, + onFieldSubmitted: () {}, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + height: Utils.getTextFieldHeight(), + enabled: false, + isTextFieldHasSuffix: true, + onClick: model.getSearchCurrentMedicationDetails! + .isNotEmpty && + model.getSearchCurrentMedicationDetails![0] + .itemStrengthDetailsDto != + null + ? () { - strengthController.text = projectViewModel.isArabic ? _selectedMedicationStrength!.nameAr! : _selectedMedicationStrength!.nameEn!; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: TranslationBase.of(context).strength, - maxLines: 1, - minLines: 1, - controller: strengthController, - validationError: isFormSubmitted && _selectedMedicationStrength == null ? TranslationBase.of(context).emptyMessage : null, - onChanged: (value) {}, - onFieldSubmitted: () {}, - ), - SizedBox( - height: 5, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Utils.getTextFieldHeight(), - enabled: false, - isTextFieldHasSuffix: true, - onClick: model.medicationRouteList != null - ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationRouteList, - selectedValue: _selectedMedicationRoute, - okText: TranslationBase.of(context).ok, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationRoute = selectedValue; + DropdownPopup dialog = DropdownPopup( + medicationDetails: + model.getSearchCurrentMedicationDetails![0], + isStrength: true, + okText: TranslationBase.of(context).ok, + selectedID:model.getSearchCurrentMedicationDetails![0] + .itemStrengthDetailsDto![0] + .strengthId!, + okFunction: (int id, String value) { + _selectedMedicationStrength = id; + strengthController.text = value; + setState(() {}); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: TranslationBase.of(context).strength, + maxLines: 1, + minLines: 1, + controller: strengthController, + // validationError: isFormSubmitted && _selectedMedicationStrength == null ? TranslationBase.of(context).emptyMessage : null, + onChanged: (value) {}, + onFieldSubmitted: () {}, + ), + SizedBox( + height: 5, + ), + SizedBox( + height: 5, + ), - routeController.text = projectViewModel.isArabic ? _selectedMedicationRoute!.nameAr! : _selectedMedicationRoute!.nameEn!; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: TranslationBase.of(context).route, - maxLines: 1, - minLines: 1, - controller: routeController, - validationError: isFormSubmitted && _selectedMedicationRoute == null ? TranslationBase.of(context).emptyMessage : null, - onChanged: (value) {}, - onFieldSubmitted: () {}, - ), - SizedBox( - height: 5, - ), - SizedBox( - height: 5, - ), - AppTextFieldCustom( - height: Utils.getTextFieldHeight(), - onClick: model.medicationFrequencyList != null - ? () { - MasterKeyDailog dialog = MasterKeyDailog( - list: model.medicationFrequencyList, - okText: TranslationBase.of(context).ok, - selectedValue: _selectedMedicationFrequency, - okFunction: (selectedValue) { - setState(() { - _selectedMedicationFrequency = selectedValue; + AppTextFieldCustom( + height: Utils.getTextFieldHeight(), + enabled: false, + isTextFieldHasSuffix: true, - frequencyController.text = projectViewModel.isArabic ? _selectedMedicationFrequency!.nameAr! : _selectedMedicationFrequency!.nameEn!; - }); - }, - ); - showDialog( - barrierDismissible: false, - context: context, - builder: (BuildContext context) { - return dialog; - }, - ); - } - : null, - hintText: TranslationBase.of(context).frequency, - enabled: false, - maxLines: 1, - minLines: 1, - isTextFieldHasSuffix: true, - controller: frequencyController, - validationError: isFormSubmitted && _selectedMedicationFrequency == null ? TranslationBase.of(context).emptyMessage : null, - onChanged: (value) {}, - onFieldSubmitted: () {}, - ), - // SizedBox( - // height: SizeConfig.heightMultiplier! * - // (SizeConfig.isHeightVeryShort - // ? 20 - // : SizeConfig.isHeightShort - // ? 15 - // : 10), - // ), - ], - ), - ),), + onClick: model.getSearchCurrentMedicationDetails! + .isNotEmpty && + model.getSearchCurrentMedicationDetails![0] + .genericItemRouteDetailsEntity != + null + ? () { + + DropdownPopup dialog = DropdownPopup( + medicationDetails: + model.getSearchCurrentMedicationDetails![0], + okText: TranslationBase.of(context).ok, + isRoute: true, + selectedID: model + .getSearchCurrentMedicationDetails![0] + .genericItemRouteDetailsEntity![0] + .routeId!, + // selectedText: , + okFunction: (int id, String value) { + setState(() { + _selectedMedicationRoute = id; + routeController.text = value; + }); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: TranslationBase.of(context).route, + maxLines: 1, + minLines: 1, + controller: routeController, + // validationError: isFormSubmitted && _selectedMedicationRoute == null ? TranslationBase.of(context).emptyMessage : null, + onChanged: (value) {}, + onFieldSubmitted: () {}, + ), + SizedBox( + height: 10, + ), + + AppTextFieldCustom( + height: Utils.getTextFieldHeight(), + + onClick: model.getSearchCurrentMedicationDetails! + .isNotEmpty && + model.getSearchCurrentMedicationDetails![0] + .genericItemFrequencyDetailsEntity != + null + ? () { + DropdownPopup dialog = DropdownPopup( + medicationDetails: + model.getSearchCurrentMedicationDetails![0], + okText: TranslationBase.of(context).ok, + selectedID: model + .getSearchCurrentMedicationDetails![0] + .genericItemFrequencyDetailsEntity![0] + .frequencyId! , + okFunction: (int id, String value) { + _selectedMedicationFrequency = id; + frequencyController.text = value; + setState(() {}); + }, + ); + showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return dialog; + }, + ); + } + : null, + hintText: TranslationBase.of(context).frequency, + enabled: false, + maxLines: 1, + minLines: 1, + isTextFieldHasSuffix: true, + controller: frequencyController, - bottomSheet: model.state != ViewState.Idle - ? Container( - height: 0, + // validationError: isFormSubmitted && _selectedMedicationFrequency == null ? TranslationBase.of(context).emptyMessage : null, + onChanged: (value) {}, + onFieldSubmitted: () {}, + ), + SizedBox( + height: 10, + ), + AppTextFieldCustom( + hintText: TranslationBase.of(context).remarks, + controller: remark, + maxLines: 4, + minLines: 4, + hasBorder: true, + inputType: TextInputType.multiline, + onClick: () {}, + onChanged: (value) {}, + onFieldSubmitted: () {}, ) - : CustomBottomSheetContainer( - label: TranslationBase.of(context).addMedication, - onTap: () { + ], + ), + ), + ), + bottomSheet: + CustomBottomSheetContainer( + label: TranslationBase.of(context).addMedication, + onTap: () { + if(medicationController.text.isNotEmpty && doseController.text.isNotEmpty){ + addMedication(model); + }else { + isFormSubmitted = true; setState(() { - isFormSubmitted = true; + }); - if (_selectedMedication != null && - _selectedMedicationDose != null && - _selectedMedicationStrength != null && - _selectedMedicationRoute != null && - _selectedMedicationFrequency != null) { - widget.medicationController.text = widget.medicationController.text + - '${_selectedMedication!.description} (${TranslationBase.of(context).doseTime} ) ${doseController.text} (${TranslationBase.of(context).strength}) ${strengthController.text} (${TranslationBase.of(context).route}) ${routeController.text} (${TranslationBase.of(context).frequency}) ${frequencyController.text} \n \n'; - Navigator.of(context).pop(); - } - }, - )), + } + }, + )), ); } + + searchMedication(model) async { + await model.searchCurrentMedication(medicationController.text); + isVisible = true; + setState(() {}); + } + + selectMedication(SOAPViewModel model, int index) { + _selectedMedication = model.getMedicationListVP![index]; + medicationController.text = + model.getMedicationListVP![index].formularyName!; + isVisible = false; + getOtherDetails(model, model.getMedicationListVP![index]); + setState(() {}); + } + + getOtherDetails( + SOAPViewModel model, GetSearchCurrentMedication selectMedicine) async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getCurrentMedicationDetails(selectMedicine.genericFormularyId!); + + GifLoaderDialogUtils.hideDialog(context); + setDefaultValues(model); + } + setDefaultValues(SOAPViewModel model){ + _selectedMedicationStrength = model.getSearchCurrentMedicationDetails![0] + .itemStrengthDetailsDto![0] + .strengthId!; + strengthController.text = model + .getSearchCurrentMedicationDetails![0] + .itemStrengthDetailsDto![0] + .strength!; + + _selectedMedicationRoute = model + .getSearchCurrentMedicationDetails![0] + .genericItemRouteDetailsEntity![0] + .routeId!; + routeController.text= model + .getSearchCurrentMedicationDetails![0] + .genericItemRouteDetailsEntity![0] + .route!; + _selectedMedicationFrequency = model + .getSearchCurrentMedicationDetails![0] + .genericItemFrequencyDetailsEntity![0] + .frequencyId!; + frequencyController.text= model + .getSearchCurrentMedicationDetails![0] + .genericItemFrequencyDetailsEntity![0] + .frequency!; + + } + + addMedication(SOAPViewModel model) async{ + Map request ={ + + "doseQuantity": doseController.text, + "frequencyId": _selectedMedicationFrequency, + "frequencyString":frequencyController.text, + "strengthId": _selectedMedicationStrength, + "strengthString": strengthController.text, + "routeId": _selectedMedicationRoute, + "routeString": routeController.text, + "remarks": remark.text, + "sentence": medicationController.text, + "formularyName": _selectedMedication!.formularyName!, + "genericFormularyId": _selectedMedication!.genericFormularyId!, + + }; + GifLoaderDialogUtils.showMyDialog(context); + + await model.addCurrentMedication(request, widget.patientInfo!); + await model.getHomeMedication(widget.patientInfo!); + GifLoaderDialogUtils.hideDialog(context); + Navigator.of(context).pop(); + + } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/dropdown_popup.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/dropdown_popup.dart new file mode 100644 index 00000000..07f7a617 --- /dev/null +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/dropdown_popup.dart @@ -0,0 +1,150 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetSearchCurrentMedicationDetails.dart'; +import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; +import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + + +class DropdownPopup extends StatefulWidget { + final GetSearchCurrentMedicationDetails? medicationDetails; + bool isStrength; + bool isRoute; + bool isFrequency; + int? selectedID; + String? selectedText; + final okText; + final Function(int selectedID, String selectedText)? okFunction; + DropdownPopup({this.medicationDetails, this.isStrength = false, this.okFunction, this.okText, this.selectedID, this.isRoute =false, this.isFrequency =false, this.selectedText }); + + @override + _DropdownPopupState createState() => _DropdownPopupState(); +} + +class _DropdownPopupState extends State { + @override + void initState() { + super.initState(); + + } + + @override + Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); + return showAlertDialog(context, projectViewModel); + } + + showAlertDialog(BuildContext context, ProjectViewModel projectViewModel) { + // set up the buttons + Widget cancelButton = ElevatedButton( + child: AppText( + TranslationBase.of(context).cancel, + color: Colors.white, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 3.5 : 5), + ), + onPressed: () { + Navigator.of(context).pop(); + }); + Widget continueButton = ElevatedButton( + child: AppText( + this.widget.okText, + color: Colors.white, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 3.5 : 5), + ), + onPressed: () { + + // this.widget.okFunction(selectedValue); + Navigator.of(context).pop(); + }); +// set up the AlertDialog + AlertDialog alert = AlertDialog( + // title: Text(widget.title), + content: createDialogList(projectViewModel), + actions: [ + cancelButton, + continueButton, + ], + ); + return alert; + } + + Widget createDialogList(ProjectViewModel projectViewModel) { + return Container( + height: MediaQuery.of(context).size.height * 0.5, + child: SingleChildScrollView( + child: widget.isStrength ? Column( + children: [ + + ...widget.medicationDetails!.itemStrengthDetailsDto! + .map((item) => RadioListTile( + title: AppText( + '${item.strength}', + ), + groupValue: widget.selectedID!.toString(), + value: item.strengthId.toString(), + activeColor: Colors.blue.shade700, + selected: item.strengthId.toString() == widget.selectedID!.toString(), + onChanged: (val) { + widget.selectedID = item.strengthId; + widget.selectedText = item.strength; + widget.okFunction!( item.strengthId!, item.strength!); + + }, + )) + .toList() + ], + ) : + + widget.isRoute ? Column( children: [ + + ...widget.medicationDetails!.genericItemRouteDetailsEntity! + .map((item) => RadioListTile( + title: AppText( + '${item.route}', + ), + groupValue: widget.selectedID!.toString(), + value: item.routeId.toString(), + activeColor: Colors.blue.shade700, + selected: item.routeId.toString() == widget.selectedID!.toString(), + onChanged: (val) { + widget.selectedID = item.routeId; + widget.selectedText = item.route; + widget.okFunction!( item.routeId!, item.route!); + + }, + )) + .toList() + ], + ) : Column( children: [ + + ...widget.medicationDetails!.genericItemFrequencyDetailsEntity! + .map((item) => RadioListTile( + title: AppText( + '${item.frequency}', + ), + groupValue: widget.selectedID!.toString(), + value: item.frequencyId.toString(), + activeColor: Colors.blue.shade700, + selected: item.frequencyId.toString() == widget.selectedID!.toString() , + onChanged: (val) { + widget.selectedID = item.frequencyId; + widget.selectedText = item.frequency; + widget.okFunction!( item.frequencyId!, item.frequency!); + setState(() { + + }); + }, + )) + .toList() + ], + ), + ), + ); + } + + static closeAlertDialog(BuildContext context) { + Navigator.of(context).pop(); + } +} diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/update_medication_widget.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/update_medication_widget.dart index 26606791..91cfd08c 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/update_medication_widget.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/medication/update_medication_widget.dart @@ -1,18 +1,25 @@ +import 'package:doctor_app_flutter/core/model/SOAP/home_medication_vp/GetHomeMedication.dart'; import 'package:doctor_app_flutter/core/model/SOAP/selected_items/my_selected_allergy.dart'; +import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/SOAP_open_items.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update_vida_plus/subjective/chief_complaint/widgets/add_soap_item.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; +import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; import 'add_medication.dart'; class UpdateMedicationWidget extends StatefulWidget { - final TextEditingController? medicationController; - + final PatiantInformtion patientInfo; UpdateMedicationWidget({ Key? key, - this.medicationController, + required this.patientInfo, }); @override @@ -20,45 +27,83 @@ class UpdateMedicationWidget extends StatefulWidget { } class _UpdateMedicationWidgetState extends State { + TextEditingController medicationController = TextEditingController(); + @override Widget build(BuildContext context) { - return Column( - children: [ - AddSoapItem( - title: "${TranslationBase.of(context).addMedication}", - onAddSoapItemClicked: () { - Navigator.push( - context, - FadePage( - page:AddMedication( - addMedicationFun: (MySelectedAllergy mySelectedAllergy) {}, - medicationController: widget.medicationController!, - ) + return BaseView( + onModelReady: (model) async { + model.getHomeMedication(widget.patientInfo); + }, + builder: (_, model, w) => + Column( + children: [ + AddSoapItem( + title: "${TranslationBase + .of(context) + .addMedication}", + onAddSoapItemClicked: () { + Navigator.push( + context, + FadePage( + page: AddMedication( + patientInfo: widget.patientInfo, + addMedicationFun:(){ + + } + ) - )); - // openMedicationList(context); - }, - ), - SizedBox( - height: 20, - ) + )); + // openMedicationList(context); + }, + ), + SizedBox( + height: 20, + ), + ListView( + padding: EdgeInsets.all(10), + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + children: model.getHomeMedicationList!.map((medication) { + return ListTile( + trailing: TextButton.icon( + onPressed: () { + removeMedication(medication, model); + }, + icon: SvgPicture.asset( + "assets/images/svgs/delete.svg", + height: 18, + color: Color(0xffD02127), + ), + label: AppText( + TranslationBase.of(context) + .remove, + fontSize: 12, + color: Color(0xffD02127))), + title: + AppText( + medication.prescribedItemName!, + fontSize: 12, + fontWeight: FontWeight.w800, + letterSpacing: -0.48, + ), + subtitle: AppText( + '${medication.doseQuantity!} - ${ medication.frequencyString!}', + fontSize: 10, - ], - ); + ), + ); + }).toList()), + + + ] + )); + } + removeMedication(GetHomeMedicationList medication, SOAPViewModel model) async{ + GifLoaderDialogUtils.showMyDialog(context); + await model.removeCurrentMedication(medication.id!); + await model.getHomeMedication(widget.patientInfo); + GifLoaderDialogUtils.hideDialog(context); } - // - // openMedicationList(BuildContext context) { - // showModalBottomSheet( - // backgroundColor: Colors.white, - // isScrollControlled: true, - // isDismissible: false, - // context: context, - // builder: (context) { - // return AddMedication( - // addMedicationFun: (MySelectedAllergy mySelectedAllergy) {}, - // medicationController: widget.medicationController!, - // ); - // }); - // } } diff --git a/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart index 46c803a7..f496ec09 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/subjective/update_subjective_page_vida_plus.dart @@ -279,7 +279,7 @@ class _UpdateSubjectivePageVidaPlusState (SizeConfig.isHeightVeryShort ? 4 : 2), ), UpdateMedicationWidget( - medicationController: medicationController, + patientInfo: widget.patientInfo, ), SizedBox( height: 10, diff --git a/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart b/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart index 4608e1e0..8bc4191f 100644 --- a/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart +++ b/lib/screens/patients/profile/soap_update_vida_plus/update_soap_index_vida_plus.dart @@ -177,8 +177,8 @@ class _UpdateSoapIndexVidaPlusState extends State fontWeight: FontWeight.w600, color: Colors.red[700]!, onPressed: () async { - - model.nextOnSubjectPage(model); + changePageViewIndex(1); + //model.nextOnSubjectPage(model); }, ), ); @@ -220,7 +220,8 @@ class _UpdateSoapIndexVidaPlusState extends State // padding: 10, disabled: model.state == ViewState.BusyLocal, onPressed: () async { - await model.nextOnObjectivePage(model); + changePageViewIndex(2); + // await model.nextOnObjectivePage(model); }, ), ), @@ -256,7 +257,7 @@ class _UpdateSoapIndexVidaPlusState extends State color: Colors.red[700]!, disabled: model.state == ViewState.BusyLocal, onPressed: () async { - model.nextOnAssessmentPage(model); + changePageViewIndex(3); }, ), ), @@ -294,7 +295,8 @@ class _UpdateSoapIndexVidaPlusState extends State color: Colors.red[700]!, disabled: model.progressNoteText.isEmpty, onPressed: () async { - model.nextOnPlanPage(model); + changePageViewIndex(3); + // model.nextOnPlanPage(model); }, ), ),