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/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/project_view_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/util/translations_delegate_base.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/app_buttons_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/network_base_view.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@ -20,7 +17,7 @@ import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
class UpdateHistoryWidget extends StatefulWidget {
final List<MasterKeyModel> myHistoryList;
final List<MySelectedHistory> myHistoryList;
const UpdateHistoryWidget({Key key, this.myHistoryList}) : super(key: key);
@ -86,19 +83,28 @@ class _UpdateHistoryWidgetState extends State<UpdateHistoryWidget>
children: [
Container(
child: Expanded(
child: Texts(projectViewModel.isArabic?myHistory.nameAr:myHistory.nameEn,
variant: "bodyText", bold: true, color: Colors.black),
child: Texts(
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,
),
InkWell(
child: Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
),
onTap: () => removeHistory(myHistory),
)
if (myHistory.isChecked)
InkWell(
child: Icon(
FontAwesomeIcons.trash,
color: Colors.grey,
size: 20,
),
onTap: () => removeHistory(myHistory.selectedHistory),
)
],
),
SizedBox(
@ -113,13 +119,24 @@ class _UpdateHistoryWidgetState extends State<UpdateHistoryWidget>
);
}
removeHistory(MasterKeyModel masterKey) {
Iterable<MasterKeyModel> history = widget.myHistoryList.where((element) =>
masterKey.id == element.id && masterKey.typeId == element.typeId);
removeHistory(MasterKeyModel historyKey) {
// Iterable<MasterKeyModel> history = widget.myHistoryList.where((element) =>
// 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)
setState(() {
widget.myHistoryList.remove(history.first);
history[0].isChecked = false;
});
}
@ -233,7 +250,7 @@ class _PriorityBarState extends State<PriorityBar> {
class AddHistoryDialog extends StatefulWidget {
final Function changePageViewIndex;
final PageController controller;
final List<MasterKeyModel> myHistoryList;
final List<MySelectedHistory> myHistoryList;
final Function addSelectedHistories;
final Function (MasterKeyModel) removeHistory;
@ -306,7 +323,8 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
},
addHistory: (history){
setState(() {
widget.myHistoryList.add(history);
createAndAddHistory(
history);
});
},
addSelectedHistories: (){
@ -324,7 +342,8 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
},
addHistory: (history){
setState(() {
widget.myHistoryList.add(history);
createAndAddHistory(
history);
});
},
addSelectedHistories: (){
@ -342,7 +361,8 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
},
addHistory: (history){
setState(() {
widget.myHistoryList.add(history);
createAndAddHistory(
history);
});
},
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) {
Iterable<MasterKeyModel> history =
Iterable<MySelectedHistory> history =
widget
.myHistoryList
.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) {
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/master_key_model.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_chief_complaint_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 {
final Function changePageViewIndex;
final List<MySelectedAllergy> myAllergiesList;
final List<MasterKeyModel> myHistoryList;
final List<MySelectedHistory> myHistoryList;
final PatiantInformtion patientInfo;
UpdateSubjectivePage(
@ -90,7 +91,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId,
);
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 ==
@ -100,7 +106,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId,
);
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 ==
@ -110,7 +121,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId,
);
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 ==
@ -120,7 +136,12 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
id: element.historyId,
);
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(
{SOAPViewModel model,
List<MySelectedAllergy> myAllergiesList,
List<MasterKeyModel> myHistoryList}) async {
addSubjectiveInfo({SOAPViewModel model,
List<MySelectedAllergy> myAllergiesList,
List<MySelectedHistory> myHistoryList}) async {
formKey.currentState.save();
formKey.currentState.validate();
@ -488,9 +508,9 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
}
postHistories(
{List<MasterKeyModel> myHistoryList, SOAPViewModel model}) async {
{List<MySelectedHistory> myHistoryList, SOAPViewModel model}) async {
PostHistoriesRequestModel postHistoriesRequestModel =
new PostHistoriesRequestModel();
new PostHistoriesRequestModel();
widget.myHistoryList.forEach((history) {
if (postHistoriesRequestModel.listMedicalHistoryVM == null)
postHistoriesRequestModel.listMedicalHistoryVM = [];
@ -500,9 +520,9 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
episodeId: widget.patientInfo.episodeNo,
appointmentNo: widget.patientInfo.appointmentNo,
remarks: "",
historyId: history.id,
historyType: history.typeId,
isChecked: false,
historyId: history.selectedHistory.id,
historyType: history.selectedHistory.typeId,
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_assement.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/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
@ -30,7 +31,7 @@ class _UpdateSoapIndexState extends State<UpdateSoapIndex>
PageController _controller;
int _currentIndex = 0;
List<MySelectedAllergy> myAllergiesList= List();
List<MasterKeyModel> myHistoryList = List();
List<MySelectedHistory> myHistoryList = List();
List<MySelectedExamination> mySelectedExamination = List();
MySelectedAssessment mySelectedAssessment = new MySelectedAssessment();
changePageViewIndex(pageIndex) {

Loading…
Cancel
Save