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.
doctor_app_flutter/lib/screens/procedures/update_procedure.dart

223 lines
8.8 KiB
Dart

import 'package:doctor_app_flutter/config/config.dart';
4 years ago
import 'package:doctor_app_flutter/core/enum/view_state.dart';
4 years ago
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
5 years ago
import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart';
5 years ago
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
5 years ago
import 'package:doctor_app_flutter/core/model/procedure/update_procedure_request_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
5 years ago
import 'package:doctor_app_flutter/screens/base/base_view.dart';
4 years ago
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart';
4 years ago
import 'package:doctor_app_flutter/utils/dr_app_toast_msg.dart';
4 years ago
import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart';
4 years ago
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';
5 years ago
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
4 years ago
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/TextFields.dart';
5 years ago
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
void updateProcedureForm(context,
{required String procedureName,
required int orderNo,
required int limetNo,
required PatiantInformtion patient,
required String orderType,
required String procedureId,
required String remarks,
required ProcedureViewModel model,
required String categoreId}) {
5 years ago
TextEditingController remarksController = TextEditingController();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return UpdateProcedureWidget(
procedureName: procedureName,
remarks: remarks,
remarksController: remarksController,
patient: patient,
4 years ago
previousModel: model,
5 years ago
procedureId: procedureId,
categoryId: categoreId,
5 years ago
orderNo: orderNo,
limetNo: limetNo,
4 years ago
selectedType: int.parse(orderType),
5 years ago
);
});
}
class UpdateProcedureWidget extends StatefulWidget {
final PatiantInformtion? patient;
final ProcedureViewModel? previousModel;
final String? procedureName;
final String? remarks;
final TextEditingController? remarksController;
final String? procedureId;
final String? categoryId;
final int? orderNo;
final int? limetNo;
int? selectedType;
5 years ago
2 years ago
UpdateProcedureWidget({this.previousModel, this.procedureName, this.remarks, this.remarksController, this.patient, this.procedureId, this.categoryId, this.orderNo, this.limetNo, this.selectedType});
4 years ago
5 years ago
@override
_UpdateProcedureWidgetState createState() => _UpdateProcedureWidgetState();
}
class _UpdateProcedureWidgetState extends State<UpdateProcedureWidget> {
setSelectedType(int val) {
setState(() {
4 years ago
widget.selectedType = val;
5 years ago
});
}
void initState() {
super.initState();
widget.remarksController!.text = widget.remarks!;
}
List<EntityList> entityList = [];
5 years ago
dynamic selectedCategory;
4 years ago
/// TODO Roaa Add translation and make sure it working fine
5 years ago
@override
Widget build(BuildContext context) {
4 years ago
return BaseView<ProcedureViewModel>(
onModelReady: (model) => model.getCategory(),
2 years ago
builder: (BuildContext context, ProcedureViewModel _model, Widget? child) => AppScaffold(
baseViewModel: widget.previousModel!,
isShowAppBar: true,
appBar: BottomSheetTitle(title: "Update Procedure"),
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height * 0.9,
child: Form(
child: Padding(
2 years ago
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
Utils.convertToTitleCase(widget.procedureName!),
fontWeight: FontWeight.w700,
),
SizedBox(
height: 30.0,
),
Container(
child: Row(
children: [
AppText(TranslationBase.of(context).orderType),
Radio(
activeColor: AppGlobal.appRedColor,
value: 0,
groupValue: widget.selectedType,
onChanged: (value) {
setSelectedType(value!);
},
4 years ago
),
Text('routine'),
Radio(
activeColor: AppGlobal.appRedColor,
groupValue: widget.selectedType,
value: 1,
onChanged: (value) {
setSelectedType(value!);
},
4 years ago
),
Text(TranslationBase.of(context).urgent),
],
),
4 years ago
),
SizedBox(
height: 12.0,
),
Container(
2 years ago
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!,
2 years ago
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,
onTap: () => updateProcedure(
lineItemNo: widget.limetNo!,
orderNo: widget.orderNo!,
orderType: widget.selectedType.toString(),
categoryId: widget.categoryId!,
procedureId: widget.procedureId!,
entityList: entityList,
patient: widget.patient!,
model: widget.previousModel!,
remarks: widget.remarksController!.text),
),
),
4 years ago
);
5 years ago
}
updateProcedure(
{required ProcedureViewModel model,
required String remarks,
required int lineItemNo,
required int orderNo,
String? newProcedureId,
String? newCategoryId,
required List<EntityList> entityList,
required String orderType,
required String procedureId,
required PatiantInformtion patient,
required String categoryId}) async {
2 years ago
UpdateProcedureRequestModel updateProcedureReqModel = new UpdateProcedureRequestModel();
List<Controls> controls = [];
ProcedureDetail controlsProcedure = ProcedureDetail();
5 years ago
updateProcedureReqModel.appointmentNo = patient.appointmentNo;
updateProcedureReqModel.episodeID = patient.episodeNo;
updateProcedureReqModel.patientMRN = patient.patientMRN;
4 years ago
updateProcedureReqModel.lineItemNo = lineItemNo;
5 years ago
updateProcedureReqModel.orderNo = orderNo;
5 years ago
{
controls.add(
2 years ago
Controls(code: "remarks", controlValue: remarks.isNotEmpty ? remarks : ""),
);
controls.add(
Controls(code: "ordertype", controlValue: orderType),
);
5 years ago
controlsProcedure.procedure = procedureId;
4 years ago
controlsProcedure.category = '0' + categoryId;
controlsProcedure.controls = controls;
}
5 years ago
updateProcedureReqModel.procedureDetail = controlsProcedure;
4 years ago
GifLoaderDialogUtils.showMyDialog(context);
2 years ago
await widget.previousModel!.updateProcedure(updateProcedureRequestModel: updateProcedureReqModel, mrn: patient.patientMRN, isLocalBusy: true);
5 years ago
if (model.state == ViewState.ErrorLocal) {
4 years ago
Utils.showErrorToast(model.error);
5 years ago
} else if (model.state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been updated');
2 years ago
await widget.previousModel!.getProcedure(mrn: patient.patientMRN!, isLocalBusy: true);
4 years ago
Navigator.of(context).pop();
}
4 years ago
GifLoaderDialogUtils.hideDialog(context);
5 years ago
}
}