You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
497 lines
24 KiB
Dart
497 lines
24 KiB
Dart
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
|
import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart';
|
|
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
|
|
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
|
|
import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/procedure_View_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/util/dr_app_toast_msg.dart';
|
|
import 'package:doctor_app_flutter/util/helpers.dart';
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.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/buttons/app_buttons_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'entity_list_checkbox_search_widget.dart';
|
|
|
|
valdateProcedure(ProcedureViewModel model, PatiantInformtion patient,
|
|
List<EntityList> entityList) async {
|
|
ProcedureValadteRequestModel procedureValadteRequestModel =
|
|
new ProcedureValadteRequestModel();
|
|
|
|
procedureValadteRequestModel.patientMRN = patient.appointmentNo;
|
|
procedureValadteRequestModel.episodeID = patient.episodeNo;
|
|
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
|
|
}
|
|
|
|
postProcedure(
|
|
{ProcedureViewModel model,
|
|
String remarks,
|
|
String orderType,
|
|
PatiantInformtion patient,
|
|
List<EntityList> entityList}) async {
|
|
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
|
|
ProcedureValadteRequestModel procedureValadteRequestModel =
|
|
new ProcedureValadteRequestModel();
|
|
procedureValadteRequestModel.patientMRN = patient.patientMRN;
|
|
procedureValadteRequestModel.episodeID = patient.episodeNo;
|
|
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
|
|
|
|
List<Procedures> controlsProcedure = List();
|
|
|
|
postProcedureReqModel.appointmentNo = patient.appointmentNo;
|
|
|
|
postProcedureReqModel.episodeID = patient.episodeNo;
|
|
postProcedureReqModel.patientMRN = patient.patientMRN;
|
|
|
|
entityList.forEach((element) {
|
|
procedureValadteRequestModel.procedure = [element.procedureId];
|
|
List<Controls> controls = List();
|
|
controls.add(
|
|
Controls(
|
|
code: "remarks",
|
|
controlValue: element.remarks != null ? element.remarks : ""),
|
|
);
|
|
controls.add(
|
|
Controls(code: "ordertype", controlValue: element.type ?? "1"),
|
|
);
|
|
controlsProcedure.add(Procedures(
|
|
category: element.categoryID,
|
|
procedure: element.procedureId,
|
|
controls: controls));
|
|
});
|
|
|
|
postProcedureReqModel.procedures = controlsProcedure;
|
|
await model.valadteProcedure(procedureValadteRequestModel);
|
|
if (model.state == ViewState.Idle) {
|
|
if (model.valadteProcedureList[0].entityList.length == 0) {
|
|
await model.postProcedure(postProcedureReqModel, patient.patientMRN);
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
Helpers.showErrorToast(model.error);
|
|
model.getProcedure(mrn: patient.patientMRN);
|
|
} else if (model.state == ViewState.Idle) {
|
|
DrAppToastMsg.showSuccesToast('procedure has been added');
|
|
}
|
|
} else {
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
Helpers.showErrorToast(model.error);
|
|
model.getProcedure(mrn: patient.patientMRN);
|
|
} else if (model.state == ViewState.Idle) {
|
|
Helpers.showErrorToast(
|
|
model.valadteProcedureList[0].entityList[0].warringMessages);
|
|
}
|
|
}
|
|
} else {
|
|
Helpers.showErrorToast(model.error);
|
|
}
|
|
}
|
|
|
|
void addSelectedProcedure(
|
|
context, ProcedureViewModel model, PatiantInformtion patient) {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
builder: (BuildContext bc) {
|
|
return AddSelectedProcedure(
|
|
model: model,
|
|
patient: patient,
|
|
);
|
|
});
|
|
}
|
|
|
|
class AddSelectedProcedure extends StatefulWidget {
|
|
final ProcedureViewModel model;
|
|
final PatiantInformtion patient;
|
|
|
|
const AddSelectedProcedure({Key key, this.model, this.patient})
|
|
: super(key: key);
|
|
@override
|
|
_AddSelectedProcedureState createState() =>
|
|
_AddSelectedProcedureState(patient: patient, model: model);
|
|
}
|
|
|
|
class _AddSelectedProcedureState extends State<AddSelectedProcedure> {
|
|
int selectedType;
|
|
ProcedureViewModel model;
|
|
PatiantInformtion patient;
|
|
_AddSelectedProcedureState({this.patient, this.model});
|
|
TextEditingController procedureController = TextEditingController();
|
|
TextEditingController remarksController = TextEditingController();
|
|
List<EntityList> entityList = List();
|
|
List<EntityList> entityListProcedure = List();
|
|
TextEditingController procedureName = TextEditingController();
|
|
|
|
dynamic selectedCategory;
|
|
|
|
setSelectedType(int val) {
|
|
setState(() {
|
|
selectedType = val;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BaseView<ProcedureViewModel>(
|
|
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
|
|
AppScaffold(
|
|
isShowAppBar: false,
|
|
body: Column(
|
|
children: [
|
|
Container(
|
|
height: MediaQuery.of(context).size.height * 0.070,
|
|
),
|
|
Expanded(
|
|
child: NetworkBaseView(
|
|
baseViewModel: model,
|
|
child: DraggableScrollableSheet(
|
|
minChildSize: 0.90,
|
|
initialChildSize: 0.95,
|
|
maxChildSize: 1.0,
|
|
builder: (BuildContext context,
|
|
ScrollController scrollController) {
|
|
return SingleChildScrollView(
|
|
child: Container(
|
|
height: MediaQuery.of(context).size.height * 1.20,
|
|
child: Padding(
|
|
padding: EdgeInsets.all(12.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
AppText(
|
|
TranslationBase.of(context)
|
|
.pleaseEnterProcedure,
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 20,
|
|
),
|
|
]),
|
|
SizedBox(
|
|
height:
|
|
MediaQuery.of(context).size.height * 0.04,
|
|
),
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: MediaQuery.of(context).size.width *
|
|
0.79,
|
|
child: AppTextFieldCustom(
|
|
hintText: TranslationBase.of(context)
|
|
.searchProcedureHere,
|
|
isTextFieldHasSuffix: false,
|
|
|
|
maxLines: 1,
|
|
minLines: 1,
|
|
hasBorder: true,
|
|
controller: procedureName,
|
|
// onSubmitted: (_) {
|
|
// model.getProcedureCategory(
|
|
// categoryName: procedureName.text);
|
|
// },
|
|
onClick: () {
|
|
if (procedureName.text.isNotEmpty &&
|
|
procedureName.text.length >= 3)
|
|
model.getProcedureCategory(
|
|
categoryName:
|
|
procedureName.text);
|
|
else
|
|
DrAppToastMsg.showErrorToast(
|
|
TranslationBase.of(context)
|
|
.atLeastThreeCharacters,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: MediaQuery.of(context).size.width *
|
|
0.02,
|
|
),
|
|
Expanded(
|
|
child: InkWell(
|
|
onTap: () {
|
|
if (procedureName.text.isNotEmpty &&
|
|
procedureName.text.length >= 3)
|
|
model.getProcedureCategory(
|
|
categoryName: procedureName.text);
|
|
else
|
|
DrAppToastMsg.showErrorToast(
|
|
TranslationBase.of(context)
|
|
.atLeastThreeCharacters,
|
|
);
|
|
},
|
|
child: Icon(
|
|
Icons.search,
|
|
size: 25.0,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
// SizedBox(
|
|
// width: MediaQuery.of(context).size.width * 0.29,
|
|
// ),
|
|
// InkWell(
|
|
// child: Icon(
|
|
// Icons.close,
|
|
// size: 24.0,
|
|
// ),
|
|
// onTap: () {
|
|
// Navigator.pop(context);
|
|
// },
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// SizedBox(
|
|
// height: 10.0,
|
|
// ),
|
|
// Container(
|
|
// height: screenSize.height * 0.070,
|
|
// child: InkWell(
|
|
// onTap: model.categoryList != null &&
|
|
// model.categoryList.length > 0
|
|
// ? () {
|
|
// ListSelectDialog dialog =
|
|
// ListSelectDialog(
|
|
// list: model.categoryList,
|
|
// attributeName: 'categoryName',
|
|
// attributeValueId: 'categoryId',
|
|
// okText: TranslationBase.of(context).ok,
|
|
// okFunction: (selectedValue) {
|
|
// setState(() {
|
|
// selectedCategory = selectedValue;
|
|
// model.getProcedureCategory(
|
|
// categoryName: selectedCategory[
|
|
// 'categoryName'],
|
|
// categoryID: selectedCategory[
|
|
// 'categoryId'] <=
|
|
// 9
|
|
// ? "0" +
|
|
// selectedCategory[
|
|
// 'categoryId']
|
|
// .toString()
|
|
// : selectedCategory[
|
|
// 'categoryId']
|
|
// .toString());
|
|
// });
|
|
// },
|
|
// );
|
|
// showDialog(
|
|
// barrierDismissible: false,
|
|
// context: context,
|
|
// builder: (BuildContext context) {
|
|
// return dialog;
|
|
// },
|
|
// );
|
|
// //model.getProcedureCategory();
|
|
// }
|
|
// : null,
|
|
// child: TextField(
|
|
// decoration: textFieldSelectorDecoration(
|
|
// TranslationBase.of(context)
|
|
// .procedureCategorise,
|
|
// selectedCategory != null
|
|
// ? selectedCategory['categoryName']
|
|
// : null,
|
|
// true,
|
|
// suffixIcon: Icon(
|
|
// Icons.search,
|
|
// color: Colors.black,
|
|
// )),
|
|
// enabled: false,
|
|
// ),
|
|
// ),
|
|
// ),
|
|
if (procedureName.text.isNotEmpty &&
|
|
model.procedureList.length != 0)
|
|
NetworkBaseView(
|
|
baseViewModel: model,
|
|
child:
|
|
// selectedCategory != null
|
|
// ? selectedCategory['categoryId'] == 02 ||
|
|
// selectedCategory['categoryId'] == 03
|
|
// ?
|
|
EntityListCheckboxSearchWidget(
|
|
model: widget.model,
|
|
masterList: widget
|
|
.model.categoriesList[0].entityList,
|
|
removeHistory: (item) {
|
|
setState(() {
|
|
entityList.remove(item);
|
|
});
|
|
},
|
|
addHistory: (history) {
|
|
setState(() {
|
|
entityList.add(history);
|
|
});
|
|
},
|
|
addSelectedHistories: () {
|
|
//TODO build your fun herr
|
|
// widget.addSelectedHistories();
|
|
},
|
|
isEntityListSelected: (master) =>
|
|
isEntityListSelected(master),
|
|
)
|
|
// : ProcedureListWidget(
|
|
// model: widget.model,
|
|
// masterList: widget.model
|
|
// .categoriesList[0].entityList,
|
|
// removeHistory: (item) {
|
|
// setState(() {
|
|
// entityList.remove(item);
|
|
// });
|
|
// },
|
|
// addHistory: (history) {
|
|
// setState(() {
|
|
// entityList.add(history);
|
|
// });
|
|
// },
|
|
// addSelectedHistories: () {
|
|
// //TODO build your fun herr
|
|
// // widget.addSelectedHistories();
|
|
// },
|
|
// isEntityListSelected: (master) =>
|
|
// isEntityListSelected(master),
|
|
// )
|
|
// : null,
|
|
),
|
|
SizedBox(
|
|
height: 15.0,
|
|
),
|
|
Column(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
// Container(
|
|
// child: Row(
|
|
// children: [
|
|
// AppText(
|
|
// TranslationBase.of(context).orderType),
|
|
// Radio(
|
|
// activeColor: Color(0xFFB9382C),
|
|
// value: 1,
|
|
// groupValue: selectedType,
|
|
// onChanged: (value) {
|
|
// setSelectedType(value);
|
|
// },
|
|
// ),
|
|
// Text('routine'),
|
|
// Radio(
|
|
// activeColor: Color(0xFFB9382C),
|
|
// groupValue: selectedType,
|
|
// value: 0,
|
|
// onChanged: (value) {
|
|
// setSelectedType(value);
|
|
// },
|
|
// ),
|
|
// Text(TranslationBase.of(context).urgent),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
// SizedBox(
|
|
// height: 15.0,
|
|
// ),
|
|
// TextFields(
|
|
// hintText: TranslationBase.of(context).remarks,
|
|
// controller: remarksController,
|
|
// minLines: 3,
|
|
// maxLines: 5,
|
|
// ),
|
|
SizedBox(
|
|
height: 100.0,
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
|
|
child: Wrap(
|
|
alignment: WrapAlignment.center,
|
|
children: <Widget>[
|
|
AppButton(
|
|
title: TranslationBase.of(context).addSelectedProcedures,
|
|
color: Color(0xff359846),
|
|
fontWeight: FontWeight.w700,
|
|
onPressed: () {
|
|
if (entityList.isEmpty == true) {
|
|
DrAppToastMsg.showErrorToast(
|
|
TranslationBase.of(context)
|
|
.fillTheMandatoryProcedureDetails,
|
|
);
|
|
return;
|
|
}
|
|
|
|
Navigator.pop(context);
|
|
postProcedure(
|
|
orderType: selectedType.toString(),
|
|
entityList: entityList,
|
|
patient: patient,
|
|
model: widget.model,
|
|
remarks: remarksController.text);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
bool isEntityListSelected(EntityList masterKey) {
|
|
Iterable<EntityList> history = entityList
|
|
.where((element) => masterKey.procedureId == element.procedureId);
|
|
if (history.length > 0) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
InputDecoration textFieldSelectorDecoration(
|
|
String hintText, String selectedText, bool isDropDown,
|
|
{Icon suffixIcon}) {
|
|
return InputDecoration(
|
|
focusedBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
disabledBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
hintText: selectedText != null ? selectedText : hintText,
|
|
suffixIcon: isDropDown
|
|
? suffixIcon != null
|
|
? suffixIcon
|
|
: Icon(
|
|
Icons.arrow_drop_down,
|
|
color: Colors.black,
|
|
)
|
|
: null,
|
|
hintStyle: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.grey.shade600,
|
|
),
|
|
);
|
|
}
|
|
}
|