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.
248 lines
9.0 KiB
Dart
248 lines
9.0 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/core/enum/view_state.dart';
|
|
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.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/update_procedure_request_model.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
|
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
|
import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.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/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_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/TextFields.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
|
|
void updateProcedureForm(context,
|
|
{String procedureName,
|
|
int orderNo,
|
|
int limetNo,
|
|
PatiantInformtion patient,
|
|
String orderType,
|
|
String procedureId,
|
|
String remarks,
|
|
ProcedureViewModel model,
|
|
String categoreId}) {
|
|
TextEditingController remarksController = TextEditingController();
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
builder: (BuildContext bc) {
|
|
return UpdateProcedureWidget(
|
|
procedureName: procedureName,
|
|
remarks: remarks,
|
|
remarksController: remarksController,
|
|
patient: patient,
|
|
model: model,
|
|
procedureId: procedureId,
|
|
categoryId: categoreId,
|
|
orderNo: orderNo,
|
|
limetNo: limetNo,
|
|
);
|
|
});
|
|
}
|
|
|
|
class UpdateProcedureWidget extends StatefulWidget {
|
|
final PatiantInformtion patient;
|
|
final ProcedureViewModel model;
|
|
final String procedureName;
|
|
final String remarks;
|
|
final TextEditingController remarksController;
|
|
final String procedureId;
|
|
final String categoryId;
|
|
final int orderNo;
|
|
final int limetNo;
|
|
|
|
UpdateProcedureWidget(
|
|
{this.model,
|
|
this.procedureName,
|
|
this.remarks,
|
|
this.remarksController,
|
|
this.patient,
|
|
this.procedureId,
|
|
this.categoryId,
|
|
this.orderNo,
|
|
this.limetNo});
|
|
|
|
@override
|
|
_UpdateProcedureWidgetState createState() => _UpdateProcedureWidgetState();
|
|
}
|
|
|
|
class _UpdateProcedureWidgetState extends State<UpdateProcedureWidget> {
|
|
int selectedType = 0;
|
|
|
|
setSelectedType(int val) {
|
|
setState(() {
|
|
selectedType = val;
|
|
});
|
|
}
|
|
|
|
void initState() {
|
|
super.initState();
|
|
widget.remarksController.text = widget.remarks;
|
|
}
|
|
|
|
List<EntityList> entityList = List();
|
|
dynamic selectedCategory;
|
|
|
|
/// TODO Roaa Add translation and make sure it working fine
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return StatefulBuilder(builder:
|
|
(BuildContext context, StateSetter setState /*You can rename this!*/) {
|
|
return BaseView<ProcedureViewModel>(
|
|
onModelReady: (model) => model.getCategory(),
|
|
builder:
|
|
(BuildContext context, ProcedureViewModel model, Widget child) =>
|
|
AppScaffold(
|
|
baseViewModel: model,
|
|
isShowAppBar: true,
|
|
appBar: PatientSearchHeader(title: "Update Procedure"),
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
height: MediaQuery.of(context).size.height * 0.9,
|
|
child: Form(
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AppText(
|
|
widget.procedureName.toUpperCase(),
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
SizedBox(
|
|
height: 30.0,
|
|
),
|
|
Container(
|
|
child: Row(
|
|
children: [
|
|
AppText(TranslationBase.of(context).orderType),
|
|
Radio(
|
|
activeColor: AppGlobal.appRedColor,
|
|
value: 0,
|
|
groupValue: selectedType,
|
|
onChanged: (value) {
|
|
setSelectedType(value);
|
|
},
|
|
),
|
|
Text('routine'),
|
|
Radio(
|
|
activeColor: AppGlobal.appRedColor,
|
|
groupValue: selectedType,
|
|
value: 1,
|
|
onChanged: (value) {
|
|
setSelectedType(value);
|
|
},
|
|
),
|
|
Text(TranslationBase.of(context).urgent),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 12.0,
|
|
),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius:
|
|
BorderRadius.all(Radius.circular(6.0)),
|
|
border: Border.all(
|
|
width: 1.0, color: HexColor("#CCCCCC"))),
|
|
child: TextFields(
|
|
fontSize: 15.0,
|
|
controller: widget.remarksController,
|
|
hintText: widget.remarksController.text.isEmpty
|
|
? 'No Remarks Added'
|
|
: '',
|
|
maxLines: 3,
|
|
minLines: 2,
|
|
onChanged: (value) {},
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 70.0,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
)),
|
|
),
|
|
bottomSheet: CustomBottomSheetContainer(
|
|
label: TranslationBase.of(context).updateProcedure.toUpperCase(),
|
|
onTap: () => updateProcedure(
|
|
lineItemNo: widget.limetNo,
|
|
orderNo: widget.orderNo,
|
|
orderType: selectedType.toString(),
|
|
categoryId: widget.categoryId,
|
|
procedureId: widget.procedureId,
|
|
entityList: entityList,
|
|
patient: widget.patient,
|
|
model: widget.model,
|
|
remarks: widget.remarksController.text),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
updateProcedure(
|
|
{ProcedureViewModel model,
|
|
String remarks,
|
|
int lineItemNo,
|
|
int orderNo,
|
|
String newProcedureId,
|
|
String newCategoryId,
|
|
List<EntityList> entityList,
|
|
String orderType,
|
|
String procedureId,
|
|
PatiantInformtion patient,
|
|
String categoryId}) async {
|
|
UpdateProcedureRequestModel updateProcedureReqModel =
|
|
new UpdateProcedureRequestModel();
|
|
List<Controls> controls = List();
|
|
ProcedureDetail controlsProcedure = new ProcedureDetail();
|
|
|
|
updateProcedureReqModel.appointmentNo = patient.appointmentNo;
|
|
|
|
updateProcedureReqModel.episodeID = patient.episodeNo;
|
|
updateProcedureReqModel.patientMRN = patient.patientMRN;
|
|
updateProcedureReqModel.lineItemNo = lineItemNo;
|
|
updateProcedureReqModel.orderNo = orderNo;
|
|
|
|
{
|
|
controls.add(
|
|
Controls(
|
|
code: "remarks", controlValue: remarks.isNotEmpty ? remarks : ""),
|
|
);
|
|
controls.add(
|
|
Controls(code: "ordertype", controlValue: orderType),
|
|
);
|
|
|
|
controlsProcedure.procedure = procedureId;
|
|
controlsProcedure.category = '0' + categoryId;
|
|
|
|
controlsProcedure.controls = controls;
|
|
}
|
|
updateProcedureReqModel.procedureDetail = controlsProcedure;
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
await model.updateProcedure(
|
|
updateProcedureRequestModel: updateProcedureReqModel,
|
|
mrn: patient.patientMRN);
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
Utils.showErrorToast(model.error);
|
|
} else if (model.state == ViewState.Idle) {
|
|
DrAppToastMsg.showSuccesToast('procedure has been updated');
|
|
await model.getProcedure(mrn: patient.patientMRN, isLocalBusy: true);
|
|
}
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
}
|
|
}
|