add search in SOAP

pull/208/head
Mohammad Aljammal 4 years ago
parent 806682b921
commit 93bece09d7

@ -1,8 +1,10 @@
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:doctor_app_flutter/client/base_app_client.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/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_assement.dart';
import 'package:doctor_app_flutter/models/SOAP/post_assessment_request_model.dart';
@ -19,6 +21,7 @@ import 'package:doctor_app_flutter/widgets/shared/expandable-widget-header-body.
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class AssessmentPage extends StatefulWidget {
final Function changePageViewIndex;
@ -375,15 +378,17 @@ class _AddAssessmentDetailsState extends State<AddAssessmentDetails> {
TextEditingController remarkController = TextEditingController();
TextEditingController appointmentIdController = TextEditingController(
text: "234567");
GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<MasterKeyModel>>();
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
remarkController.text = widget.mySelectedAssessment.remark??"";
final screenSize = MediaQuery
.of(context)
.size;
InputDecoration textFieldSelectorDecoration(String hintText,
String selectedText, bool isDropDown) {
String selectedText, bool isDropDown,{IconData icon}) {
//TODO: make one Input InputDecoration for all
return InputDecoration(
focusedBorder: OutlineInputBorder(
@ -399,7 +404,7 @@ class _AddAssessmentDetailsState extends State<AddAssessmentDetails> {
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null,
suffixIcon: isDropDown ? Icon(icon??Icons.arrow_drop_down) : null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
@ -470,43 +475,28 @@ class _AddAssessmentDetailsState extends State<AddAssessmentDetails> {
child: InkWell(
onTap: model.listOfICD10 != null
? () {
MasterKeyDailog dialog = MasterKeyDailog(
isICD: true,
list: model.listOfICD10,
selectedValue: widget
.mySelectedAssessment
.selectedICD,
okText: TranslationBase
.of(context)
.ok,
okFunction:
(MasterKeyModel selectedValue) {
setState(() {
widget.mySelectedAssessment
.selectedICD =
selectedValue;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
setState(() {
widget.mySelectedAssessment.selectedICD = null;
});
}
: null,
child: TextField(
child:widget.mySelectedAssessment.selectedICD == null ? AutoCompleteTextField<MasterKeyModel>(
decoration: textFieldSelectorDecoration("Name or ICD", widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search),
itemSubmitted: (item) => setState(() => widget.mySelectedAssessment.selectedICD = item),
key: key,
suggestions: model.listOfICD10,
itemBuilder: (context, suggestion) => new Padding(
child:Texts( suggestion.description +" / "+ suggestion.code.toString()),
padding: EdgeInsets.all(8.0)),
itemSorter: (a, b) => 1,
itemFilter: (suggestion, input) =>
suggestion.description.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.description.toLowerCase().startsWith(input.toLowerCase())
||suggestion.code.toLowerCase().startsWith(input.toLowerCase())
,
): TextField(
decoration: textFieldSelectorDecoration(
"Name / ICD",
widget.mySelectedAssessment
.selectedICD !=
null
? widget.mySelectedAssessment
.selectedICD.nameEn
: null,
true),
widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.code :"Name or ICD",
widget.mySelectedAssessment.selectedICD != null ? widget.mySelectedAssessment.selectedICD.nameEn : null, true,icon: EvaIcons.search),
enabled: false,
),
),

@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart';
import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.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/master_key_checkbox_search_widget.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';
@ -469,98 +470,35 @@ class _AddExaminationDailogState extends State<AddExaminationDailog> {
SizedBox(
height: 16,
),
NetworkBaseView(
baseViewModel: model,
child: Container(
height:
MediaQuery
.of(context)
.size
.height * 0.5,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius
.circular(12),
color: Colors.white),
child: ListView(
children: [
Column(
children: model
.physicalExaminationList
.map((examinationInfo) {
return Column(
children: [
Row(
children: [
Checkbox(
value: isServiceSelected(
examinationInfo),
activeColor:
Colors.red[800],
onChanged:
(
bool newValue) {
setState(() {
if (isServiceSelected(
examinationInfo
)) {
widget
.removeExamination(
examinationInfo
);
}
else {
MySelectedExamination mySelectedExamination = new MySelectedExamination(
selectedExamination: examinationInfo
);
widget
.mySelectedExamination
.add(
mySelectedExamination);
}
});
}),
Expanded(
child: Padding(
padding:
const EdgeInsets
.symmetric(
horizontal: 10,
vertical: 0),
child: Texts(
examinationInfo
.nameEn,
variant: "bodyText",
bold: true,
color:
Colors.black),
),
),
],
),
DividerWithSpacesAround(),
],
);
}).toList(),
),
],
),
)),
),
),
SizedBox(
height: 10,
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED Examinations"
.toUpperCase(),
onPressed: () {
child: MasterKeyCheckboxSearchWidget(
model: model,
masterList: model.physicalExaminationList,
removeHistory: (history){
setState(() {
widget.removeExamination(history);
});
},
addHistory: (history){
setState(() {
MySelectedExamination mySelectedExamination = new MySelectedExamination(
selectedExamination: history
);
widget
.mySelectedExamination
.add(
mySelectedExamination);
});
},
addSelectedHistories: (){
widget.addSelectedExamination();
},
isServiceSelected: (master) =>isServiceSelected(master),
),
),
]),
))),
)),

@ -1,6 +1,8 @@
import 'package:autocomplete_textfield/autocomplete_textfield.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/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_allergy.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
@ -14,6 +16,7 @@ import 'package:doctor_app_flutter/widgets/shared/dialogs/master_key_dailog.dart
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
class AddAllergiesWidget extends StatefulWidget {
final List<MySelectedAllergy> myAllergiesList;
@ -43,11 +46,9 @@ class _AddAllergiesWidgetState extends State<AddAllergiesWidget> {
openAllergiesList(context);
},
readOnly: true,
// hintColor: Colors.black,
suffixIcon: EvaIcons.plusCircleOutline,
suffixIconColor: AppGlobal.appPrimaryColor,
fontWeight: FontWeight.w600,
// controller: messageController,
validator: (value) {
if (value == null)
return TranslationBase
@ -147,7 +148,7 @@ class _AddAllergiesState extends State<AddAllergies> {
InputDecoration textFieldSelectorDecoration(String hintText,
String selectedText, bool isDropDown) {
String selectedText, bool isDropDown,{IconData icon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
@ -162,16 +163,19 @@ class _AddAllergiesState extends State<AddAllergies> {
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null,
suffixIcon: isDropDown ? Icon(icon?? Icons.arrow_drop_down) : null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
),
);
}
bool _isShowSearch = false;
GlobalKey key = new GlobalKey<AutoCompleteTextFieldState<MasterKeyModel>>();
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
final screenSize = MediaQuery
.of(context)
.size;
@ -209,38 +213,30 @@ class _AddAllergiesState extends State<AddAllergies> {
SizedBox(
height: 16,
),
Container(
height: screenSize.height * 0.070,
child: InkWell(
onTap: model.listOfAllergies != null
? () {
MasterKeyDailog dialog = MasterKeyDailog(
list: model.listOfAllergies,
okText: TranslationBase
.of(context)
.ok,
okFunction: (MasterKeyModel selectedValue) {
setState(() {
_selectedAllergy = selectedValue;
});
},
);
showDialog(
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return dialog;
},
);
}
setState(() {
_selectedAllergy = null;
});
}
: null,
child: TextField(
decoration: textFieldSelectorDecoration(
"Select Allergy",
_selectedAllergy != null
? _selectedAllergy.nameEn
: null,
true),
child: _selectedAllergy==null? AutoCompleteTextField<MasterKeyModel>(
decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search),
itemSubmitted: (item) => setState(() => _selectedAllergy = item),
key: key,
suggestions: model.listOfAllergies,
itemBuilder: (context, suggestion) => new Padding(
child:Texts( projectViewModel.isArabic? suggestion.nameAr: suggestion.nameEn),
padding: EdgeInsets.all(8.0)),
itemSorter: (a, b) => 1,
itemFilter: (suggestion, input) =>
suggestion.nameAr.toLowerCase().startsWith(input.toLowerCase()) ||suggestion.nameEn.toLowerCase().startsWith(input.toLowerCase()),
):TextField(
decoration: textFieldSelectorDecoration("Select Allergy", _selectedAllergy != null ? _selectedAllergy.nameEn : null, true,icon: EvaIcons.search),
enabled: false,
),
),

@ -16,6 +16,8 @@ import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:hexcolor/hexcolor.dart';
import '../../../../shared/master_key_checkbox_search_widget.dart';
class AddHistoryWidget extends StatefulWidget {
final List<MasterKeyModel> myHistoryList;
@ -280,273 +282,59 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
},
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
child: Column(
children: [
NetworkBaseView(
baseViewModel: model,
child: Container(
height:
MediaQuery.of(context).size.height * 0.5,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: ListView(
children: [
Column(
children: model.historyFamilyList
.map((historyInfo) {
return Column(
children: [
Row(
children: [
Checkbox(
value: isServiceSelected(
historyInfo),
activeColor:
Colors.red[800],
onChanged:
(bool newValue) {
setState(() {
if (isServiceSelected(
historyInfo
)) {
widget
.removeHistory(
historyInfo
);
}
else {
widget
.myHistoryList
.add(
historyInfo);
}
});
}),
Expanded(
child: Padding(
padding:
const EdgeInsets
.symmetric(
horizontal: 10,
vertical: 0),
child: Texts(
historyInfo.nameEn,
variant: "bodyText",
bold: true,
color:
Colors.black),
),
),
],
),
DividerWithSpacesAround(),
],
);
}).toList(),
),
],
),
)),
),
),
SizedBox(
height: 10,
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES"
.toUpperCase(),
onPressed: () {
widget.addSelectedHistories();
},
),
],
),
MasterKeyCheckboxSearchWidget(
model: model,
masterList: model.historyFamilyList,
removeHistory: (history){
setState(() {
widget.removeHistory(history);
});
},
addHistory: (history){
setState(() {
widget.myHistoryList.add(history);
});
},
addSelectedHistories: (){
widget.addSelectedHistories();
},
isServiceSelected: (master) =>isServiceSelected(master),
),
Container(
child: Column(
children: [
NetworkBaseView(
baseViewModel: model,
child: Container(
height:
MediaQuery.of(context).size.height * 0.5,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: ListView(
children: [
Column(
children: model.mergeHistorySurgicalWithHistorySportList
.map((historyInfo) {
return Column(
children: [
Row(
children: [
Checkbox(
value: isServiceSelected(
historyInfo),
activeColor:
Colors.red[800],
onChanged:
(
bool newValue) {
setState(() {
if (isServiceSelected(
historyInfo
)) {
widget
.removeHistory(
historyInfo
);
}
else {
widget
.myHistoryList
.add(
historyInfo);
}
});
}),
Expanded(
child: Padding(
padding:
const EdgeInsets
.symmetric(
horizontal: 10,
vertical: 0),
child: Texts(
historyInfo.nameEn,
variant: "bodyText",
bold: true,
color:
Colors.black),
),
),
],
),
DividerWithSpacesAround(),
],
);
}).toList(),
),
],
),
)),
),
),
SizedBox(
height: 10,
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES"
.toUpperCase(),
onPressed: () {
widget.addSelectedHistories();
},
),
],
),
MasterKeyCheckboxSearchWidget(
model: model,
masterList: model.mergeHistorySurgicalWithHistorySportList,
removeHistory: (history){
setState(() {
widget.removeHistory(history);
});
},
addHistory: (history){
setState(() {
widget.myHistoryList.add(history);
});
},
addSelectedHistories: (){
widget.addSelectedHistories();
},
isServiceSelected: (master) =>isServiceSelected(master),
),
Container(
child: Column(
children: [
NetworkBaseView(
baseViewModel: model,
child: Container(
height:
MediaQuery.of(context).size.height * 0.5,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: ListView(
children: [
Column(
children: model.historyMedicalList
.map((historyInfo) {
return Column(
children: [
Row(
children: [
Checkbox(
value: isServiceSelected(
historyInfo),
activeColor:
Colors.red[800],
onChanged:
(
bool newValue) {
setState(() {
if (isServiceSelected(
historyInfo
)) {
widget
.removeHistory(
historyInfo
);
}
else {
widget
.myHistoryList
.add(
historyInfo);
}
});
}),
Expanded(
child: Padding(
padding:
const EdgeInsets
.symmetric(
horizontal: 10,
vertical: 0),
child: Texts(
historyInfo.nameEn,
variant: "bodyText",
bold: true,
color:
Colors.black),
),
),
],
),
DividerWithSpacesAround(),
],
);
}).toList(),
),
],
),
)),
),
),
SizedBox(
height: 10,
),
if (model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES"
.toUpperCase(),
onPressed: () {
setState(() {
widget.addSelectedHistories();
});
},
),
],
),
MasterKeyCheckboxSearchWidget(
model: model,
masterList: model.historyMedicalList,
removeHistory: (history){
setState(() {
widget.removeHistory(history);
});
},
addHistory: (history){
setState(() {
widget.myHistoryList.add(history);
});
},
addSelectedHistories: (){
widget.addSelectedHistories();
},
isServiceSelected: (master) =>isServiceSelected(master),
),
],
),
@ -559,12 +347,10 @@ class _AddHistoryDialogState extends State<AddHistoryDialog> {
));
}
isServiceSelected(MasterKeyModel masterKey) {
bool isServiceSelected(MasterKeyModel masterKey) {
Iterable<MasterKeyModel> history =
widget
.myHistoryList
.where((element) =>
masterKey.id == element.id && masterKey.typeId == element.typeId);
widget.myHistoryList.where((element) => masterKey.id == element.id && masterKey.typeId == element.typeId);
if (history.length > 0) {
return true;
}

@ -0,0 +1,149 @@
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/models/SOAP/master_key_model.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/divider_with_spaces_around.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MasterKeyCheckboxSearchWidget extends StatefulWidget {
final SOAPViewModel model;
final Function addSelectedHistories;
final Function(MasterKeyModel) removeHistory;
final Function(MasterKeyModel) addHistory;
final bool Function(MasterKeyModel) isServiceSelected;
final List<MasterKeyModel> masterList;
MasterKeyCheckboxSearchWidget(
{Key key,
this.model,
this.addSelectedHistories,
this.removeHistory,
this.masterList,
this.addHistory,
this.isServiceSelected})
: super(key: key);
@override
_MasterKeyCheckboxSearchWidgetState createState() => _MasterKeyCheckboxSearchWidgetState();
}
class _MasterKeyCheckboxSearchWidgetState extends State<MasterKeyCheckboxSearchWidget> {
List<MasterKeyModel> items = List();
@override
void initState() {
items.addAll(widget.masterList);
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
NetworkBaseView(
baseViewModel: widget.model,
child: Container(
height: MediaQuery.of(context).size.height * 0.5,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: ListView(
children: [
TextFields(
hintText: 'Search history',
suffixIcon: EvaIcons.search,
onChanged: (value) {
filterSearchResults(value);
},
),
SizedBox(height: 15,),
Column(
children: items.map((historyInfo) {
return Column(
children: [
Row(
children: [
Checkbox(
value:
widget.isServiceSelected(historyInfo),
activeColor: Colors.red[800],
onChanged: (bool newValue) {
setState(() {
if (widget
.isServiceSelected(historyInfo)) {
widget.removeHistory(historyInfo);
} else {
widget.addHistory(historyInfo);
}
});
}),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 0),
child: Texts(historyInfo.nameEn,
variant: "bodyText",
bold: true,
color: Colors.black),
),
),
],
),
DividerWithSpacesAround(),
],
);
}).toList(),
),
],
),
)),
),
),
SizedBox(
height: 10,
),
if (widget.model.state == ViewState.Idle)
AppButton(
title: "Add SELECTED HISTORIES".toUpperCase(),
onPressed: () {
widget.addSelectedHistories();
},
),
],
),
);
}
void filterSearchResults(String query) {
List<MasterKeyModel> dummySearchList = List();
dummySearchList.addAll(widget.masterList);
if (query.isNotEmpty) {
List<MasterKeyModel> dummyListData = List();
dummySearchList.forEach((item) {
if (item.nameAr.toLowerCase().contains(query.toLowerCase()) ||
item.nameEn.toLowerCase().contains(query.toLowerCase())) {
dummyListData.add(item);
}
});
setState(() {
items.clear();
items.addAll(dummyListData);
});
return;
} else {
setState(() {
items.clear();
items.addAll(widget.masterList);
});
}
}
}

@ -36,6 +36,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
autocomplete_textfield:
dependency: "direct main"
description:
name: autocomplete_textfield
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.3"
barcode_scan:
dependency: "direct main"
description:

@ -60,6 +60,9 @@ dependencies:
get_it: ^4.0.2
#Autocomplete TextField
autocomplete_textfield: ^1.7.3
#speech to text

Loading…
Cancel
Save