history delete is fixed

pull/234/head
Elham Rababah 5 years ago
parent 3dffd33728
commit bbcd218a94

@ -0,0 +1,30 @@
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
class MySelectedHistory {
MasterKeyModel selectedHistory;
String remark;
bool isChecked;
MySelectedHistory(
{ this.selectedHistory, this.remark, this.isChecked});
MySelectedHistory.fromJson(Map<String, dynamic> json) {
selectedHistory = json['selectedHistory'] != null
? new MasterKeyModel.fromJson(json['selectedHistory'])
: null;
remark = json['remark'];
remark = json['isChecked'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.selectedHistory != null) {
data['selectedHistory'] = this.selectedHistory.toJson();
}
data['remark'] = this.remark;
data['isChecked'] = this.remark;
return data;
}
}

@ -1,18 +1,15 @@
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.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/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_history.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/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.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/divider_with_spaces_around.dart';
import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/master_key_checkbox_search_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart'; import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@ -20,7 +17,7 @@ import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class UpdateHistoryWidget extends StatefulWidget { class UpdateHistoryWidget extends StatefulWidget {
final List<MasterKeyModel> myHistoryList; final List<MySelectedHistory> myHistoryList;
const UpdateHistoryWidget({Key key, this.myHistoryList}) : super(key: key); const UpdateHistoryWidget({Key key, this.myHistoryList}) : super(key: key);
@ -86,19 +83,28 @@ class _UpdateHistoryWidgetState extends State<UpdateHistoryWidget>
children: [ children: [
Container( Container(
child: Expanded( child: Expanded(
child: Texts(projectViewModel.isArabic?myHistory.nameAr:myHistory.nameEn, child: Texts(
variant: "bodyText", bold: true, color: Colors.black), projectViewModel.isArabic
? myHistory.selectedHistory.nameAr
: myHistory.selectedHistory.nameEn,
variant: "bodyText",
textDecoration: myHistory.isChecked
? null
: TextDecoration.lineThrough,
bold: true,
color: Colors.black),
), ),
width: MediaQuery.of(context).size.width * 0.7, width: MediaQuery.of(context).size.width * 0.7,
), ),
InkWell( if (myHistory.isChecked)
child: Icon( InkWell(
FontAwesomeIcons.trash, child: Icon(
color: Colors.grey, FontAwesomeIcons.trash,
size: 20, color: Colors.grey,
), size: 20,
onTap: () => removeHistory(myHistory), ),
) onTap: () => removeHistory(myHistory.selectedHistory),
)
], ],
), ),
SizedBox( SizedBox(
@ -113,13 +119,24 @@ class _UpdateHistoryWidgetState extends State<UpdateHistoryWidget>
); );
} }
removeHistory(MasterKeyModel masterKey) { removeHistory(MasterKeyModel historyKey) {
Iterable<MasterKeyModel> history = widget.myHistoryList.where((element) => // Iterable<MasterKeyModel> history = widget.myHistoryList.where((element) =>
masterKey.id == element.id && masterKey.typeId == element.typeId); // masterKey.id == element.id && masterKey.typeId == element.typeId);
//
List<MySelectedHistory> history =
// ignore: missing_return
widget.myHistoryList.where((element) =>
historyKey.id ==
element.selectedHistory.id &&
historyKey.typeId ==
element.selectedHistory.typeId
).toList();
if (history.length > 0) if (history.length > 0)
setState(() { setState(() {
widget.myHistoryList.remove(history.first); history[0].isChecked = false;
}); });
} }
@ -233,7 +250,7 @@ class _PriorityBarState extends State<PriorityBar> {
class AddHistoryDialog extends StatefulWidget { class AddHistoryDialog extends StatefulWidget {
final Function changePageViewIndex; final Function changePageViewIndex;
final PageController controller; final PageController controller;
final List<MasterKeyModel> myHistoryList; final List<MySelectedHistory> myHistoryList;
final Function addSelectedHistories; final Function addSelectedHistories;
final Function (MasterKeyModel) removeHistory; final Function (MasterKeyModel) removeHistory;
@ -306,7 +323,8 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
}, },
addHistory: (history){ addHistory: (history){
setState(() { setState(() {
widget.myHistoryList.add(history); createAndAddHistory(
history);
}); });
}, },
addSelectedHistories: (){ addSelectedHistories: (){
@ -324,7 +342,8 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
}, },
addHistory: (history){ addHistory: (history){
setState(() { setState(() {
widget.myHistoryList.add(history); createAndAddHistory(
history);
}); });
}, },
addSelectedHistories: (){ addSelectedHistories: (){
@ -342,7 +361,8 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
}, },
addHistory: (history){ addHistory: (history){
setState(() { setState(() {
widget.myHistoryList.add(history); createAndAddHistory(
history);
}); });
}, },
addSelectedHistories: (){ addSelectedHistories: (){
@ -361,12 +381,35 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
)); ));
} }
createAndAddHistory(MasterKeyModel history) {
List<MySelectedHistory> myhistory = widget.myHistoryList.where((element) =>
history.id ==
element.selectedHistory.id &&
history.typeId ==
element.selectedHistory.typeId
).toList();
if (myhistory.isEmpty) {
setState(() {
MySelectedHistory mySelectedHistory = MySelectedHistory(
remark: history.remarks ?? "",
selectedHistory: history,
isChecked: true);
widget.myHistoryList.add(mySelectedHistory);
});
} else {
myhistory.first.isChecked = true;
}
}
isServiceSelected(MasterKeyModel masterKey) { isServiceSelected(MasterKeyModel masterKey) {
Iterable<MasterKeyModel> history = Iterable<MySelectedHistory> history =
widget widget
.myHistoryList .myHistoryList
.where((element) => .where((element) =>
masterKey.id == element.id && masterKey.typeId == element.typeId); masterKey.id == element.selectedHistory.id &&
masterKey.typeId == element.selectedHistory.typeId &&
element.isChecked);
if (history.length > 0) { if (history.length > 0) {
return true; return true;
} }

@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart';
import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_history.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart';
@ -28,7 +29,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class UpdateSubjectivePage extends StatefulWidget { class UpdateSubjectivePage extends StatefulWidget {
final Function changePageViewIndex; final Function changePageViewIndex;
final List<MySelectedAllergy> myAllergiesList; final List<MySelectedAllergy> myAllergiesList;
final List<MasterKeyModel> myHistoryList; final List<MySelectedHistory> myHistoryList;
final PatiantInformtion patientInfo; final PatiantInformtion patientInfo;
UpdateSubjectivePage( UpdateSubjectivePage(
@ -90,7 +91,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId, id: element.historyId,
); );
if (history != null) { if (history != null) {
widget.myHistoryList.add(history); MySelectedHistory mySelectedHistory = MySelectedHistory(
selectedHistory: history,
isChecked: element.isChecked,
remark: element.remarks);
widget.myHistoryList.add(mySelectedHistory);
} }
} }
if (element.historyType == if (element.historyType ==
@ -100,7 +106,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId, id: element.historyId,
); );
if (history != null) { if (history != null) {
widget.myHistoryList.add(history); MySelectedHistory mySelectedHistory = MySelectedHistory(
selectedHistory: history,
isChecked: element.isChecked,
remark: element.remarks);
widget.myHistoryList.add(mySelectedHistory);
} }
} }
if (element.historyType == if (element.historyType ==
@ -110,7 +121,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId, id: element.historyId,
); );
if (history != null) { if (history != null) {
widget.myHistoryList.add(history); MySelectedHistory mySelectedHistory = MySelectedHistory(
selectedHistory: history,
isChecked: element.isChecked,
remark: element.remarks);
widget.myHistoryList.add(mySelectedHistory);
} }
} }
if (element.historyType == if (element.historyType ==
@ -120,7 +136,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId, id: element.historyId,
); );
if (history != null) { if (history != null) {
widget.myHistoryList.add(history); MySelectedHistory mySelectedHistory = MySelectedHistory(
selectedHistory: history,
isChecked: element.isChecked,
remark: element.remarks);
widget.myHistoryList.add(mySelectedHistory);
} }
} }
}); });
@ -408,10 +429,9 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
); );
} }
addSubjectiveInfo( addSubjectiveInfo({SOAPViewModel model,
{SOAPViewModel model, List<MySelectedAllergy> myAllergiesList,
List<MySelectedAllergy> myAllergiesList, List<MySelectedHistory> myHistoryList}) async {
List<MasterKeyModel> myHistoryList}) async {
formKey.currentState.save(); formKey.currentState.save();
formKey.currentState.validate(); formKey.currentState.validate();
@ -488,9 +508,9 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
} }
postHistories( postHistories(
{List<MasterKeyModel> myHistoryList, SOAPViewModel model}) async { {List<MySelectedHistory> myHistoryList, SOAPViewModel model}) async {
PostHistoriesRequestModel postHistoriesRequestModel = PostHistoriesRequestModel postHistoriesRequestModel =
new PostHistoriesRequestModel(); new PostHistoriesRequestModel();
widget.myHistoryList.forEach((history) { widget.myHistoryList.forEach((history) {
if (postHistoriesRequestModel.listMedicalHistoryVM == null) if (postHistoriesRequestModel.listMedicalHistoryVM == null)
postHistoriesRequestModel.listMedicalHistoryVM = []; postHistoriesRequestModel.listMedicalHistoryVM = [];
@ -500,9 +520,9 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
episodeId: widget.patientInfo.episodeNo, episodeId: widget.patientInfo.episodeNo,
appointmentNo: widget.patientInfo.appointmentNo, appointmentNo: widget.patientInfo.appointmentNo,
remarks: "", remarks: "",
historyId: history.id, historyId: history.selectedHistory.id,
historyType: history.typeId, historyType: history.selectedHistory.typeId,
isChecked: false, isChecked: history.isChecked,
)); ));
}); });

@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_assement.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_assement.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_history.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -30,7 +31,7 @@ class _UpdateSoapIndexState extends State<UpdateSoapIndex>
PageController _controller; PageController _controller;
int _currentIndex = 0; int _currentIndex = 0;
List<MySelectedAllergy> myAllergiesList= List(); List<MySelectedAllergy> myAllergiesList= List();
List<MasterKeyModel> myHistoryList = List(); List<MySelectedHistory> myHistoryList = List();
List<MySelectedExamination> mySelectedExamination = List(); List<MySelectedExamination> mySelectedExamination = List();
MySelectedAssessment mySelectedAssessment = new MySelectedAssessment(); MySelectedAssessment mySelectedAssessment = new MySelectedAssessment();
changePageViewIndex(pageIndex) { changePageViewIndex(pageIndex) {

Loading…
Cancel
Save