current medication done.

update_flutter_3.24_vida_plus_episode_MDS
Sultan khan 11 months ago
parent b727e66ac1
commit 7765e8ff35

@ -318,6 +318,14 @@ const GET_EDIT_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergy';
const GET_HOME_MEDICATION = 'Services/DoctorApplication.svc/REST/GetHomeMedication'; 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; var selectedPatientType = 1;
//*********change value to decode json from Dropdown ************ //*********change value to decode json from Dropdown ************

@ -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<String, dynamic> json) {
formularyName = json['formularyName'];
genericFormularyCode = json['genericFormularyCode'];
genericFormularyId = json['genericFormularyId'];
hospitalGroupId = json['hospitalGroupId'];
hospitalId = json['hospitalId'];
itemType = json['itemType'];
outOfStock = json['outOfStock'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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;
}
}

@ -0,0 +1,108 @@
class GetSearchCurrentMedicationDetails {
List<GenericItemFrequencyDetailsEntity>? genericItemFrequencyDetailsEntity;
List<GenericItemRouteDetailsEntity>? genericItemRouteDetailsEntity;
List<ItemStrengthDetailsDto>? itemStrengthDetailsDto;
int? patientTypeId;
GetSearchCurrentMedicationDetails({this.genericItemFrequencyDetailsEntity, this.genericItemRouteDetailsEntity, this.itemStrengthDetailsDto, this.patientTypeId});
GetSearchCurrentMedicationDetails.fromJson(Map<String, dynamic> json) {
if (json['genericItemFrequencyDetailsEntity'] != null) {
genericItemFrequencyDetailsEntity = <GenericItemFrequencyDetailsEntity>[];
json['genericItemFrequencyDetailsEntity'].forEach((v) { genericItemFrequencyDetailsEntity!.add(new GenericItemFrequencyDetailsEntity.fromJson(v)); });
}
if (json['genericItemRouteDetailsEntity'] != null) {
genericItemRouteDetailsEntity = <GenericItemRouteDetailsEntity>[];
json['genericItemRouteDetailsEntity'].forEach((v) { genericItemRouteDetailsEntity!.add(new GenericItemRouteDetailsEntity.fromJson(v)); });
}
if (json['itemStrengthDetailsDto'] != null) {
itemStrengthDetailsDto = <ItemStrengthDetailsDto>[];
json['itemStrengthDetailsDto'].forEach((v) { itemStrengthDetailsDto!.add(new ItemStrengthDetailsDto.fromJson(v)); });
}
patientTypeId = json['patientTypeId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
Default = json['Default'];
frequency = json['Frequency'];
frequencyId = json['FrequencyId'];
interval = json['Interval'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
Default = json['default'];
route = json['route'];
routeId = json['routeId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
Default = json['default'];
strength = json['strength'];
strengthId = json['strengthId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['default'] = this.Default;
data['strength'] = this.strength;
data['strengthId'] = this.strengthId;
return data;
}
}

@ -1,8 +1,10 @@
import 'package:doctor_app_flutter/config/config.dart'; 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/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/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_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/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/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/get_chief_complaint_vida_plus.dart';
import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/search_chief_complaint_vidaplus.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/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/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/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/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_req_model.dart';
import 'package:doctor_app_flutter/core/model/SOAP/chief_complaint/get_chief_complaint_res_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/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/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/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/model/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_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/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/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 { class SOAPService extends LookupService {
List<GetChiefComplaintResModel> patientChiefComplaintList = []; List<GetChiefComplaintResModel> patientChiefComplaintList = [];
@ -52,8 +52,8 @@ class SOAPService extends LookupService {
List<SearchChiefComplaint> searchChiefComplaintListVidaPlus = []; List<SearchChiefComplaint> searchChiefComplaintListVidaPlus = [];
List<EpisodeByChiefComplaintVidaPlus> episodeByChiefComplaintListVidaPlus = []; List<EpisodeByChiefComplaintVidaPlus> episodeByChiefComplaintListVidaPlus = [];
List<GetHomeMedicationList> getHomeMedicationList = []; List<GetHomeMedicationList> getHomeMedicationList = [];
List<GetSearchCurrentMedication> getSearchCurrentMedication = [];
List<GetSearchCurrentMedicationDetails> getSearchCurrentMedicationDetails = [];
int? episodeID; int? episodeID;
bool isPrescriptionOrder = false; bool isPrescriptionOrder = false;
@ -745,7 +745,6 @@ class SOAPService extends LookupService {
await baseAppClient.post(GET_HOME_MEDICATION, await baseAppClient.post(GET_HOME_MEDICATION,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
getHomeMedicationList.clear(); getHomeMedicationList.clear();
response['ListHomeMedication']['resultData'].forEach((v) { response['ListHomeMedication']['resultData'].forEach((v) {
getHomeMedicationList.add(GetHomeMedicationList.fromJson(v)); getHomeMedicationList.add(GetHomeMedicationList.fromJson(v));
}); });
@ -755,27 +754,91 @@ class SOAPService extends LookupService {
}, body: request); }, body: request);
} }
// createCCByEpisodeVidaPlus( searchCurrentMedication(
// PatiantInformtion patient, List<PatientPomrs> chiefComplaint) async { String query
// Map<String, dynamic> request = ) async {
// { Map<String, dynamic> request = {
// "appointmentId": patient.appointmentNo, "SearchKey": query
// "projectId": patient.projectId, };
// "setupId": 105, hasError = false;
// "chiefComplain":chiefComplaint, await baseAppClient.post(SEARCH_CURRENT_MEDICATION,
// "patientId": patient.patientId, onSuccess: (dynamic response, int statusCode) {
// "pomrId": patient.pomrId, getSearchCurrentMedication.clear();
// "doctorId": 2, response['ListFormulatorySearch']['resultData'].forEach((v) {
// }; getSearchCurrentMedication.add(GetSearchCurrentMedication.fromJson(v));
// });
// hasError = false; }, onFailure: (String error, int statusCode) {
// await baseAppClient.post(UPDATE_CHIEF_COMPLAINT, hasError = true;
// onSuccess: (dynamic response, int statusCode) { super.error = error;
// print("Success"); }, body: request);
// }, onFailure: (String error, int statusCode) { }
// hasError = true;
// super.error = error;
// }, body: request); getCurrentMedicationDetails(
// } String id
) async {
Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> request, PatiantInformtion patientInfo) async {
var doctorProfile = await sharedPref.getObj(LOGGED_IN_USER);
Map<String, dynamic> 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<String, dynamic> 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);
}
} }

@ -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/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/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/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/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/in_patient/post_episode_for_Inpatient_request_model.dart';
import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/core/model/SOAP/master_key_model.dart';
@ -145,6 +147,14 @@ class SOAPViewModel extends BaseViewModel {
_SOAPService.getHomeMedicationList; _SOAPService.getHomeMedicationList;
List<GetSearchCurrentMedication>? get getMedicationListVP =>
_SOAPService.getSearchCurrentMedication;
List<GetSearchCurrentMedicationDetails>? get getSearchCurrentMedicationDetails =>
_SOAPService.getSearchCurrentMedicationDetails;
late SubjectiveCallBack subjectiveCallBack; late SubjectiveCallBack subjectiveCallBack;
setSubjectiveCallBack(SubjectiveCallBack callBack) { setSubjectiveCallBack(SubjectiveCallBack callBack) {
@ -1074,4 +1084,45 @@ class SOAPViewModel extends BaseViewModel {
setState(ViewState.Idle); 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);
}
} }

@ -52,7 +52,9 @@ class _AddPatientSickLeaveScreenState extends State<AddPatientSickLeaveScreen> {
showDatePicker( showDatePicker(
context: context, context: context,
initialDate: currentDate ?? DateTime.now(), initialDate: currentDate ?? DateTime.now(),
firstDate: DateTime(DateTime.now().year - 1), firstDate: AppDateUtils.convertStringToDate(
widget!.patient!.arrivedOn!,
),
lastDate: DateTime(DateTime.now().year + 1), lastDate: DateTime(DateTime.now().year + 1),
).then((pickedDate) { ).then((pickedDate) {
if (pickedDate == null) { if (pickedDate == null) {

@ -41,8 +41,12 @@ class _ReactionsSelectionAllergiesWidgetState
extends State<ReactionsSelectionAllergiesWidget> { extends State<ReactionsSelectionAllergiesWidget> {
bool loading = false; bool loading = false;
TextEditingController remark = TextEditingController(); TextEditingController remark = TextEditingController();
List<ExpansionTileController>? controllers =[];
@override @override
void initState() { void initState() {
controllers = List.generate(widget.mySelectedAllergy!
.allergyReactionDTOs!.length, (index) => ExpansionTileController());
super.initState(); super.initState();
} }
@ -71,6 +75,8 @@ class _ReactionsSelectionAllergiesWidgetState
return Column(children: [ return Column(children: [
ExpansionTile( ExpansionTile(
controller: controllers![index],
key: Key(index.toString()), key: Key(index.toString()),
dense: false, dense: false,
enableFeedback: false, enableFeedback: false,
@ -90,7 +96,11 @@ class _ReactionsSelectionAllergiesWidgetState
.mySelectedAllergy! .mySelectedAllergy!
.allergyReactionDTOs![index] .allergyReactionDTOs![index]
.isSelected = value; .isSelected = value;
setState(() {});
value ==true ? controllers![index].expand() : controllers![index].collapse() ;
setState(() {
}); // setState(() {});
}), }),
title: AppText(widget title: AppText(widget
.mySelectedAllergy! .mySelectedAllergy!

@ -2,341 +2,453 @@
import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:doctor_app_flutter/config/size_config.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/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/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/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/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/SOAP_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_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/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/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/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/translations_delegate_base_utils.dart';
import 'package:doctor_app_flutter/utils/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/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_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_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/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/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/auto_complete_text_field.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/text_fields_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class AddMedication extends StatefulWidget { class AddMedication extends StatefulWidget {
final Function(MySelectedAllergy mySelectedAllergy) addMedicationFun; final Function() addMedicationFun;
TextEditingController medicationController; final PatiantInformtion? patientInfo;
AddMedication({Key? key, required this.addMedicationFun, this.patientInfo}) : super(key: key);
AddMedication({Key? key, required this.addMedicationFun, required this.medicationController}) : super(key: key);
@override @override
_AddMedicationState createState() => _AddMedicationState(); _AddMedicationState createState() => _AddMedicationState();
} }
class _AddMedicationState extends State<AddMedication> { class _AddMedicationState extends State<AddMedication> {
MasterKeyModel? _selectedMedicationDose; int? _selectedMedicationStrength;
MasterKeyModel? _selectedMedicationStrength; int? _selectedMedicationRoute;
MasterKeyModel? _selectedMedicationRoute; int? _selectedMedicationFrequency;
MasterKeyModel? _selectedMedicationFrequency; TextEditingController medicationController = TextEditingController();
TextEditingController doseController = TextEditingController(); TextEditingController doseController = TextEditingController();
TextEditingController strengthController = TextEditingController(); TextEditingController strengthController = TextEditingController();
TextEditingController routeController = TextEditingController(); TextEditingController routeController = TextEditingController();
TextEditingController frequencyController = TextEditingController(); TextEditingController frequencyController = TextEditingController();
GetMedicationResponseModel? _selectedMedication; GetSearchCurrentMedication? _selectedMedication;
TextEditingController remark = TextEditingController();
GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>> key = GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>(); bool isVisible = false;
GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>> key =
GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
bool isFormSubmitted = false; bool isFormSubmitted = false;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<SOAPViewModel>( return BaseView<SOAPViewModel>(
onModelReady: (model) async { onModelReady: (model) async {
// model.onAddMedicationStart(); // model.onAddMedicationStart();
}, },
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
baseViewModel: model, baseViewModel: model,
isShowAppBar: true, isShowAppBar: true,
appBar: PatientSearchHeader( appBar: PatientSearchHeader(
title: TranslationBase.of(context).addMedication,
title:TranslationBase.of(context).addMedication, ),
), body: Container(
body: Container( padding: EdgeInsets.all(15),
padding: EdgeInsets.all(15), child: SingleChildScrollView(
child: child: Column(
SingleChildScrollView( children: [
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<GetMedicationResponseModel>(
// 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: () {},
),
onChanged: (value) {}, AppTextFieldCustom(
onFieldSubmitted: () {}, height: Utils.getTextFieldHeight(),
), controller: medicationController,
// ), hintText:
// ), TranslationBase.of(context).searchMedicineNameHere,
if (_selectedMedication != null) minLines: 1,
Column( maxLines: 1,
children: [ isTextFieldHasSuffix: true,
SizedBox( validationError: isFormSubmitted && medicationController.text.isEmpty ? TranslationBase.of(context).emptyMessage : null,
height: 3, suffixIcon: IconButton(
), icon: model.state == ViewState.BusyLocal
Container( ? SizedBox(
width: MediaQuery.of(context).size.width * 0.7, child: CircularProgressIndicator(
child: AppText( strokeWidth: 2,
_selectedMedication!.description! + (' (${_selectedMedication!.genericName} )'),
color: Color(0xFF575757),
fontSize: 10,
fontWeight: FontWeight.w700,
letterSpacing: -0.4,
),
),
],
),
SizedBox(
height: 5,
), ),
AppTextFieldCustom( height: 10,
height: Utils.getTextFieldHeight(), 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 if (_selectedMedication != null)
? () { Column(
MasterKeyDailog dialog = MasterKeyDailog( children: [
list: model.medicationDoseTimeList, SizedBox(
okText: TranslationBase.of(context).ok, height: 3,
selectedValue: _selectedMedicationDose, ),
okFunction: (selectedValue) { Container(
setState(() { width: MediaQuery.of(context).size.width * 0.9,
_selectedMedicationDose = selectedValue; 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!; SizedBox(
}); height: 5,
}, ),
); AppTextFieldCustom(
showDialog( height: Utils.getTextFieldHeight(),
barrierDismissible: false, enabled: true,
context: context, inputFormatters: <TextInputFormatter>[
builder: (BuildContext context) { FilteringTextInputFormatter.digitsOnly
return dialog; ],
}, // onClick: model.medicationDoseTimeList != null
); // ? () {
} // MasterKeyDailog dialog = MasterKeyDailog(
: null, // list: model.medicationDoseTimeList,
hintText: TranslationBase.of(context).doseTime, // okText: TranslationBase.of(context).ok,
maxLines: 1, // // selectedValue: _selectedMedicationDose,
minLines: 1, // okFunction: (selectedValue) {
isTextFieldHasSuffix: true, // setState(() {
controller: doseController, // _selectedMedicationDose = selectedValue;
validationError: isFormSubmitted && _selectedMedicationDose == null ? TranslationBase.of(context).emptyMessage : null, //
onChanged: (value) {}, // doseController.text = projectViewModel.isArabic ? _selectedMedicationDose!.nameAr! : _selectedMedicationDose!.nameEn!;
onFieldSubmitted: () {}, // });
), // },
SizedBox( // );
height: 5, // showDialog(
), // barrierDismissible: false,
AppTextFieldCustom( // context: context,
height: Utils.getTextFieldHeight(), // builder: (BuildContext context) {
// return dialog;
// },
// );
// }
// : null,
hintText: TranslationBase.of(context).doseDetails,
maxLines: 1,
minLines: 1,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: false,
onClick: model.medicationStrengthList != null controller: doseController,
? () { validationError: isFormSubmitted && doseController.text.isEmpty ? TranslationBase.of(context).emptyMessage : null,
MasterKeyDailog dialog = MasterKeyDailog( onChanged: (value) {},
list: model.medicationStrengthList, onFieldSubmitted: () {},
okText: TranslationBase.of(context).ok, ),
selectedValue: _selectedMedicationStrength, SizedBox(
okFunction: (selectedValue) { height: 10,
setState(() { ),
_selectedMedicationStrength = selectedValue; 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!; DropdownPopup dialog = DropdownPopup(
}); medicationDetails:
}, model.getSearchCurrentMedicationDetails![0],
); isStrength: true,
showDialog( okText: TranslationBase.of(context).ok,
barrierDismissible: false, selectedID:model.getSearchCurrentMedicationDetails![0]
context: context, .itemStrengthDetailsDto![0]
builder: (BuildContext context) { .strengthId!,
return dialog; okFunction: (int id, String value) {
}, _selectedMedicationStrength = id;
); strengthController.text = value;
} setState(() {});
: null, },
hintText: TranslationBase.of(context).strength, );
maxLines: 1, showDialog(
minLines: 1, barrierDismissible: false,
controller: strengthController, context: context,
validationError: isFormSubmitted && _selectedMedicationStrength == null ? TranslationBase.of(context).emptyMessage : null, builder: (BuildContext context) {
onChanged: (value) {}, return dialog;
onFieldSubmitted: () {}, },
), );
SizedBox( }
height: 5, : null,
), hintText: TranslationBase.of(context).strength,
SizedBox( maxLines: 1,
height: 5, minLines: 1,
), controller: strengthController,
AppTextFieldCustom( // validationError: isFormSubmitted && _selectedMedicationStrength == null ? TranslationBase.of(context).emptyMessage : null,
height: Utils.getTextFieldHeight(), onChanged: (value) {},
enabled: false, onFieldSubmitted: () {},
isTextFieldHasSuffix: true, ),
onClick: model.medicationRouteList != null SizedBox(
? () { height: 5,
MasterKeyDailog dialog = MasterKeyDailog( ),
list: model.medicationRouteList, SizedBox(
selectedValue: _selectedMedicationRoute, height: 5,
okText: TranslationBase.of(context).ok, ),
okFunction: (selectedValue) {
setState(() {
_selectedMedicationRoute = selectedValue;
routeController.text = projectViewModel.isArabic ? _selectedMedicationRoute!.nameAr! : _selectedMedicationRoute!.nameEn!; AppTextFieldCustom(
}); height: Utils.getTextFieldHeight(),
}, enabled: false,
); isTextFieldHasSuffix: true,
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;
frequencyController.text = projectViewModel.isArabic ? _selectedMedicationFrequency!.nameAr! : _selectedMedicationFrequency!.nameEn!; onClick: model.getSearchCurrentMedicationDetails!
}); .isNotEmpty &&
}, model.getSearchCurrentMedicationDetails![0]
); .genericItemRouteDetailsEntity !=
showDialog( null
barrierDismissible: false, ? () {
context: context,
builder: (BuildContext context) { DropdownPopup dialog = DropdownPopup(
return dialog; medicationDetails:
}, model.getSearchCurrentMedicationDetails![0],
); okText: TranslationBase.of(context).ok,
} isRoute: true,
: null, selectedID: model
hintText: TranslationBase.of(context).frequency, .getSearchCurrentMedicationDetails![0]
enabled: false, .genericItemRouteDetailsEntity![0]
maxLines: 1, .routeId!,
minLines: 1, // selectedText: ,
isTextFieldHasSuffix: true, okFunction: (int id, String value) {
controller: frequencyController, setState(() {
validationError: isFormSubmitted && _selectedMedicationFrequency == null ? TranslationBase.of(context).emptyMessage : null, _selectedMedicationRoute = id;
onChanged: (value) {}, routeController.text = value;
onFieldSubmitted: () {}, });
), },
// SizedBox( );
// height: SizeConfig.heightMultiplier! * showDialog(
// (SizeConfig.isHeightVeryShort barrierDismissible: false,
// ? 20 context: context,
// : SizeConfig.isHeightShort builder: (BuildContext context) {
// ? 15 return dialog;
// : 10), },
// ), );
], }
), : 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 // validationError: isFormSubmitted && _selectedMedicationFrequency == null ? TranslationBase.of(context).emptyMessage : null,
? Container( onChanged: (value) {},
height: 0, 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(() { 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<String, dynamic> 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();
}
} }

@ -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<DropdownPopup> {
@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();
}
}

@ -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/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/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/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/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:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'add_medication.dart'; import 'add_medication.dart';
class UpdateMedicationWidget extends StatefulWidget { class UpdateMedicationWidget extends StatefulWidget {
final TextEditingController? medicationController; final PatiantInformtion patientInfo;
UpdateMedicationWidget({ UpdateMedicationWidget({
Key? key, Key? key,
this.medicationController, required this.patientInfo,
}); });
@override @override
@ -20,45 +27,83 @@ class UpdateMedicationWidget extends StatefulWidget {
} }
class _UpdateMedicationWidgetState extends State<UpdateMedicationWidget> { class _UpdateMedicationWidgetState extends State<UpdateMedicationWidget> {
TextEditingController medicationController = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return BaseView<SOAPViewModel>(
children: [ onModelReady: (model) async {
AddSoapItem( model.getHomeMedication(widget.patientInfo);
title: "${TranslationBase.of(context).addMedication}", },
onAddSoapItemClicked: () { builder: (_, model, w) =>
Navigator.push( Column(
context, children: [
FadePage( AddSoapItem(
page:AddMedication( title: "${TranslationBase
addMedicationFun: (MySelectedAllergy mySelectedAllergy) {}, .of(context)
medicationController: widget.medicationController!, .addMedication}",
) onAddSoapItemClicked: () {
Navigator.push(
context,
FadePage(
page: AddMedication(
patientInfo: widget.patientInfo,
addMedicationFun:(){
}
)
)); ));
// openMedicationList(context); // openMedicationList(context);
}, },
), ),
SizedBox( SizedBox(
height: 20, 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!,
// );
// });
// }
} }

@ -279,7 +279,7 @@ class _UpdateSubjectivePageVidaPlusState
(SizeConfig.isHeightVeryShort ? 4 : 2), (SizeConfig.isHeightVeryShort ? 4 : 2),
), ),
UpdateMedicationWidget( UpdateMedicationWidget(
medicationController: medicationController, patientInfo: widget.patientInfo,
), ),
SizedBox( SizedBox(
height: 10, height: 10,

@ -177,8 +177,8 @@ class _UpdateSoapIndexVidaPlusState extends State<UpdateSoapIndexVidaPlus>
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.red[700]!, color: Colors.red[700]!,
onPressed: () async { onPressed: () async {
changePageViewIndex(1);
model.nextOnSubjectPage(model); //model.nextOnSubjectPage(model);
}, },
), ),
); );
@ -220,7 +220,8 @@ class _UpdateSoapIndexVidaPlusState extends State<UpdateSoapIndexVidaPlus>
// padding: 10, // padding: 10,
disabled: model.state == ViewState.BusyLocal, disabled: model.state == ViewState.BusyLocal,
onPressed: () async { onPressed: () async {
await model.nextOnObjectivePage(model); changePageViewIndex(2);
// await model.nextOnObjectivePage(model);
}, },
), ),
), ),
@ -256,7 +257,7 @@ class _UpdateSoapIndexVidaPlusState extends State<UpdateSoapIndexVidaPlus>
color: Colors.red[700]!, color: Colors.red[700]!,
disabled: model.state == ViewState.BusyLocal, disabled: model.state == ViewState.BusyLocal,
onPressed: () async { onPressed: () async {
model.nextOnAssessmentPage(model); changePageViewIndex(3);
}, },
), ),
), ),
@ -294,7 +295,8 @@ class _UpdateSoapIndexVidaPlusState extends State<UpdateSoapIndexVidaPlus>
color: Colors.red[700]!, color: Colors.red[700]!,
disabled: model.progressNoteText.isEmpty, disabled: model.progressNoteText.isEmpty,
onPressed: () async { onPressed: () async {
model.nextOnPlanPage(model); changePageViewIndex(3);
// model.nextOnPlanPage(model);
}, },
), ),
), ),

Loading…
Cancel
Save