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.
PatientApp-KKUMC/lib/pages/AlHabibMedicalService/ancillary-orders/ancillaryOrdersDetails.dart

307 lines
11 KiB
Dart

import "package:collection/collection.dart";
import 'package:diplomaticquarterapp/core/viewModels/ancillary_orders_view_model.dart';
4 years ago
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ancillary-orders/ordersPayment.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
4 years ago
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/utils.dart';
4 years ago
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
4 years ago
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
5 years ago
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
4 years ago
import 'package:provider/provider.dart';
class AnicllaryOrdersDetails extends StatefulWidget {
final dynamic appoNo;
final dynamic orderNo;
5 years ago
final dynamic projectID;
AnicllaryOrdersDetails(this.appoNo, this.orderNo, this.projectID);
4 years ago
@override
_AnicllaryOrdersState createState() => _AnicllaryOrdersState();
}
class _AnicllaryOrdersState extends State<AnicllaryOrdersDetails> with SingleTickerProviderStateMixin {
4 years ago
ProjectViewModel projectViewModel;
void initState() {
super.initState();
}
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
4 years ago
projectViewModel = Provider.of(context);
return BaseView<AnciallryOrdersViewModel>(
5 years ago
onModelReady: (model) => model.getOrdersDetails(widget.appoNo, widget.orderNo, widget.projectID),
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
4 years ago
showNewAppBar: true,
showNewAppBarTitle: true,
baseViewModel: model,
appBarTitle: TranslationBase.of(context).anicllaryOrders,
body: SingleChildScrollView(
4 years ago
padding: EdgeInsets.all(12),
child: model.ancillaryListsDetails.length > 0
? Column(children: [
getPatientInfo(model),
getAncillaryDetails(model),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Texts(
TranslationBase.of(context).total,
fontSize: 20,
fontWeight: FontWeight.bold,
),
Texts(
getTotalValue(model),
fontSize: 20,
fontWeight: FontWeight.bold,
)
],
),
])
: getNoDataWidget(context),
),
bottomSheet: Container(
color: Theme.of(context).scaffoldBackgroundColor,
margin: EdgeInsets.only(bottom: 5.0),
width: double.infinity,
padding: EdgeInsets.all(12),
child: DefaultButton(
TranslationBase.of(context).payNow.toUpperCase(),
() {
Navigator.push(
context,
FadePage(
page: OrdersPayment(),
),
);
},
),
)));
}
Widget getPatientInfo(AnciallryOrdersViewModel model) {
return Padding(
child: Column(
children: [
4 years ago
Container(
width: double.infinity,
child: Container(
decoration: cardRadius(12),
margin: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
TranslationBase.of(context).patientName + ":",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 10,
letterSpacing: -0.6,
color: CustomColors.grey,
),
),
mWidth(3),
Text(
projectViewModel.user.firstName + " " + projectViewModel.user.lastName,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
Row(
children: [
Text(
TranslationBase.of(context).mrn + ":",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 10,
letterSpacing: -0.6,
color: CustomColors.grey,
),
),
mWidth(3),
Text(
projectViewModel.user.patientID.toString(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
Row(
children: [
Text(
TranslationBase.of(context).nationalIdNumber + ":",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 10,
letterSpacing: -0.6,
color: CustomColors.grey,
),
),
mWidth(3),
Text(
projectViewModel.user.patientIdentificationNo,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
4 years ago
Row(
children: [
Text(
TranslationBase.of(context).appointmentNo + ":",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 10,
letterSpacing: -0.6,
color: CustomColors.grey,
),
),
mWidth(3),
Text(
model.ancillaryListsDetails[0].appointmentNo.toString(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
mWidth(3),
Row(
children: [
Text(
TranslationBase.of(context).orderNo + ":",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 10,
letterSpacing: -0.6,
color: CustomColors.grey,
),
),
mWidth(3),
Text(
model.ancillaryListsDetails[0].ancillaryOrderProcDetailsList[0].orderNo.toString(),
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 12,
letterSpacing: -0.48,
),
),
],
),
4 years ago
],
),
),
4 years ago
),
),
4 years ago
Divider()
],
),
4 years ago
padding: EdgeInsets.only(top: 5.0, bottom: 10.0),
);
}
Widget getAncillaryDetails(model) {
5 years ago
Map newMap = groupBy(model.ancillaryListsDetails[0].ancillaryOrderProcDetailsList, (obj) => obj.procedureCategoryName);
4 years ago
return Padding(padding: EdgeInsets.only(top: 0, bottom: 10), child: getHeaderDetails(newMap));
5 years ago
}
Widget getHeaderDetails(newMap) {
4 years ago
List<Widget> list = [];
5 years ago
newMap.forEach((key, value) {
list.add(
4 years ago
Container(
child: Text(key, style: TextStyle(color: Colors.black, letterSpacing: -0.64, fontSize: 18.0, fontWeight: FontWeight.bold)),
),
);
list.add(
Container(
decoration: cardRadius(12),
margin: EdgeInsets.only(left: 0, top: 8, right: 0, bottom: 16),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Table(
columnWidths: {
0: FlexColumnWidth(2.0),
1: FlexColumnWidth(1.5),
2: FlexColumnWidth(1.5),
3: FlexColumnWidth(1.5),
},
children: fullData(context, value),
),
],
),
),
5 years ago
),
);
});
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: list,
);
}
5 years ago
String getTotalValue(value) {
double total = 0.0;
4 years ago
value.ancillaryListsDetails[0].ancillaryOrderProcDetailsList.forEach((result) => {total += result.patientShareWithTax});
5 years ago
return total.toStringAsFixed(2);
}
4 years ago
List<TableRow> fullData(context, value) {
List<TableRow> tableRow = [];
tableRow.add(
TableRow(
children: [
Utils.tableColumnTitle(TranslationBase.of(context).procedure),
Utils.tableColumnTitle(TranslationBase.of(context).price),
Utils.tableColumnTitle(TranslationBase.of(context).vat),
Utils.tableColumnTitle(TranslationBase.of(context).total),
],
),
5 years ago
);
4 years ago
for (int i = 0; i < value.length; i++) {
tableRow.add(
TableRow(children: [
Utils.tableColumnValue('${value[i].procedureName.toString()}', isLast: true),
Utils.tableColumnValue('${value[i].patientShare.toString()}', isLast: true),
Utils.tableColumnValue('${value[i].patientTaxAmount.toString() + " " + TranslationBase.of(context).sar}', isLast: true),
Utils.tableColumnValue('${value[i].patientShareWithTax.toString() + " " + TranslationBase.of(context).sar}', isLast: true),
]),
);
}
return tableRow;
}
}