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/procedure_screen.dart

683 lines
35 KiB
Dart

import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.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/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.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/screens/procedures/entity_list_checkbox_search_widget.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_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';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_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:hexcolor/hexcolor.dart';
class ProcedureScreen extends StatefulWidget {
@override
_ProcedureScreenState createState() => _ProcedureScreenState();
}
class _ProcedureScreenState extends State<ProcedureScreen> {
int testNum = 1;
PatiantInformtion patient;
TextEditingController procedureController = TextEditingController();
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
patient = routeArgs['patient'];
return BaseView<ProcedureViewModel>(
onModelReady: (model) => model.getProcedure(),
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: true,
appBarTitle: 'ORDER PROCEDURE',
body: NetworkBaseView(
baseViewModel: model,
child: SingleChildScrollView(
child: Container(
child: Column(
children: [
Padding(
padding: EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
AvatarWidget(
Icon(
patient.genderDescription == "Male"
? DoctorApp.male
: DoctorApp.female_icon,
size: 70,
color: Colors.white,
),
),
SizedBox(
width: 20,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
patient.firstName + ' ' + patient.lastName,
color: Colors.black,
fontWeight: FontWeight.bold,
),
Row(
children: [
AppText(
TranslationBase.of(context).age2,
color: Colors.black,
fontWeight: FontWeight.bold,
),
SizedBox(
width: 5.0,
),
AppText(
patient.age.toString(),
color: Colors.black,
fontWeight: FontWeight.normal,
),
],
),
AppText(
"ALLERGIC TO: FOOD, ASPIRIN",
color: Color(0xFFB9382C),
fontWeight: FontWeight.bold,
),
],
)
],
),
),
Divider(
height: 1.0,
thickness: 1.0,
color: Colors.grey,
),
if (model.procedureList.length != 0)
SizedBox(
height: model.procedureList[0].rowcount == 0
? 200.0
: 10.0),
//model.prescriptionList == null
if (model.procedureList.length != 0)
model.procedureList[0].rowcount == 0
? Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.stretch,
children: [
InkWell(
onTap: () {
model.getCategories().then((value) {
addSelectedProcedure(context, model);
});
//model.postPrescription();
},
child: CircleAvatar(
radius: 65,
backgroundColor: Color(0XFFB8382C),
child: CircleAvatar(
radius: 60,
backgroundColor: Colors.white,
child: Icon(
Icons.add,
color: Colors.black,
size: 45.0,
),
),
),
),
SizedBox(
height: 15.0,
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
AppText(
'NO ORDER FOR PROCEDURE LISTED',
color: Colors.black,
fontWeight: FontWeight.w900,
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
AppText(
TranslationBase.of(context).addNow,
color: Color(0XFFB8382C),
fontWeight: FontWeight.w700,
),
],
),
],
)
: Padding(
padding: EdgeInsets.all(16.0),
child: NetworkBaseView(
baseViewModel: model,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
InkWell(
child: Container(
height: 50.0,
width: 450.0,
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey),
borderRadius:
BorderRadius.circular(10.0),
),
child: Padding(
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
AppText(
' Add more procedure',
fontWeight: FontWeight.w100,
fontSize: 12.5,
),
Icon(
Icons.add,
color: Color(0XFFB8382C),
)
],
),
),
),
onTap: () {
model.getCategories().then((value) {
addSelectedProcedure(
context, model);
});
//model.postPrescription();
},
),
// Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.all(
// Radius.circular(6.0)),
// border: Border.all(
// width: 1.0,
// color: HexColor("#CCCCCC"))),
// child: AppTextFormField(
// labelText: 'Add more procedure',
// borderColor: Colors.white,
// //suffixIcon: Icons.search,
//
// //textInputType: TextInputType.number,
// inputFormatter: ONLY_NUMBERS,
// onTap: () {
// addSelectedProcedure(context);
// },
// ),
// ),
SizedBox(
height: 35.0,
),
...List.generate(
model.procedureList[0].rowcount,
(index) => Container(
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Container(
height: 120.0,
width: 45.0,
child: Column(
children: [
AppText(
'8\nDEC',
color: Colors.green,
)
],
),
),
Expanded(
child: Container(
height: 120,
width: 325.0,
child: Column(
children: [
Row(
children: [
AppText(
'Code #: ',
fontWeight:
FontWeight
.w700,
fontSize:
15.0,
),
AppText(
model
.procedureList[
0]
.entityList[
index]
.procedureId
.toString(),
fontSize:
13.0,
),
SizedBox(
width: 12.0,
),
AppText(
'Order Type: ',
fontWeight:
FontWeight
.w700,
fontSize:
15.0,
),
AppText(
'Urgent',
fontSize:
13.0,
color: Colors
.red,
),
],
),
Row(
children: [
Container(
child:
Expanded(
child:
AppText(
model
.procedureList[
0]
.entityList[
index]
.procedureName,
fontWeight:
FontWeight
.w800,
),
),
)
],
),
Row(
children: [
AppText(
'Price: ',
fontWeight:
FontWeight
.w700,
),
Expanded(
child: AppText(
model
.procedureList[
0]
.entityList[
index]
.price
.toString(),
fontSize:
13.0),
)
],
),
SizedBox(
height: 10.0,
),
Row(
children: [
AppText(
'Some short remark about the procedure',
fontSize:
13.5,
),
],
),
SizedBox(
height: 10.0,
),
Divider(
height: 5.0,
thickness: 1.0,
color:
Colors.grey,
)
// SizedBox(
// height: 40,
// ),
],
),
),
),
Container(
child: Column(
children: [
InkWell(
child: Icon(
Icons.edit),
onTap: () {
updateProcedureForm(
context,
procedureName: model
.procedureList[
0]
.entityList[
index]
.procedureName);
},
)
],
),
)
],
),
],
),
),
),
],
),
),
)
],
),
),
),
)),
);
}
}
postProcedure({ProcedureViewModel model, String remarks}) async {
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
List<Controls> controls = List();
List<Procedures> controlsProcedure = List();
postProcedureReqModel.appointmentNo = 2016054575;
postProcedureReqModel.episodeID = 200012166;
postProcedureReqModel.patientMRN = 3120725;
postProcedureReqModel.vidaAuthTokenID =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiZjQ4YTk0OTQtYTczZS00MDI3LWI2MjgtNzc4MjAwMzUyYWEzIiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUyMTAiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODM2NDU2OCwiZXhwIjoxNjA5MjI4NTY4LCJpYXQiOjE2MDgzNjQ1Njh9.YLbvq5nxPn8o9ZYkcbc5YAX7Jy23Mm0s33oRmE8GHDI';
controls.add(
Controls(code: remarks.isEmpty ? '' : remarks, controlValue: 'sssssssss'),
);
controlsProcedure.add(
Procedures(category: "02", procedure: "02011009", controls: controls));
postProcedureReqModel.procedures = controlsProcedure;
await model.postProcedure(postProcedureReqModel);
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
} else if (model.state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been added');
}
}
updateProcedure(
{ProcedureViewModel model, String remarks, String procedureId}) async {
PostProcedureReqModel updateProcedureReqModel = new PostProcedureReqModel();
List<Controls> controls = List();
List<Procedures> controlsProcedure = List();
updateProcedureReqModel.appointmentNo = 2016054575;
updateProcedureReqModel.episodeID = 200012166;
updateProcedureReqModel.patientMRN = 3120725;
updateProcedureReqModel.vidaAuthTokenID =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiZjQ4YTk0OTQtYTczZS00MDI3LWI2MjgtNzc4MjAwMzUyYWEzIiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUyMTAiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODM2NDU2OCwiZXhwIjoxNjA5MjI4NTY4LCJpYXQiOjE2MDgzNjQ1Njh9.YLbvq5nxPn8o9ZYkcbc5YAX7Jy23Mm0s33oRmE8GHDI';
controls.add(
Controls(
code: remarks.isEmpty ? '' : remarks,
controlValue: 'Testing',
),
);
controlsProcedure.add(
Procedures(category: "02", procedure: "02011002", controls: controls));
updateProcedureReqModel.procedures = controlsProcedure;
await model.updateProcedure(updateProcedureReqModel);
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
} else if (model.state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been updated');
}
}
void addSelectedProcedure(context, ProcedureViewModel model) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return AddSelectedProcedure(
model: model,
);
});
}
class AddSelectedProcedure extends StatefulWidget {
final ProcedureViewModel model;
const AddSelectedProcedure({Key key, this.model}) : super(key: key);
@override
_AddSelectedProcedureState createState() => _AddSelectedProcedureState();
}
class _AddSelectedProcedureState extends State<AddSelectedProcedure> {
TextEditingController procedureController = TextEditingController();
TextEditingController remarksController = TextEditingController();
List<EntityList> entityList = List();
@override
Widget build(BuildContext context) {
return NetworkBaseView(
baseViewModel: widget.model,
child: SingleChildScrollView(
child: Container(
height: 790,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
'Select Procedure'.toUpperCase(),
fontWeight: FontWeight.w900,
),
if (widget.model.categoriesList.length != 0)
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),
),
SizedBox(
height: 15.0,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0, color: HexColor("#CCCCCC"))),
child: TextFields(
hintText: 'Order Type'.toUpperCase(),
controller: procedureController,
),
),
SizedBox(
height: 15.0,
),
TextFields(
hintText: 'Remarks',
controller: remarksController,
minLines: 3,
maxLines: 5,
),
SizedBox(
height: 80.0,
),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: 'add Selected Procedures'.toUpperCase(),
onPressed: () {
Navigator.pop(context);
postProcedure(
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;
}
}
void updateProcedureForm(context, {String procedureName}) {
ProcedureViewModel procedureViewModel = ProcedureViewModel();
TextEditingController remarksController = TextEditingController();
TextEditingController orderController = TextEditingController();
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return Container(
height: 400,
child: Form(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
procedureName.toUpperCase(),
fontWeight: FontWeight.w700,
),
SizedBox(
height: 30.0,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0, color: HexColor("#CCCCCC"))),
child: TextFields(
hintText: 'Order ',
controller: orderController,
),
),
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(
hintText: 'Remarks',
controller: remarksController,
maxLines: 5,
minLines: 3,
),
),
SizedBox(
height: 100.0,
),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 2),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: 'Update procedure'.toUpperCase(),
onPressed: () {
Navigator.pop(context);
updateProcedure(
model: procedureViewModel,
remarks: remarksController.text);
// authorizationForm(context);
},
),
],
),
),
],
),
),
));
});
}