recall prescription order log when refill or cancel order.

merge-update-with-lab-changes
Sikander Saleem 4 years ago
parent 062ca5c11c
commit 3403e07aba

@ -40,7 +40,7 @@ class PrescriptionsViewModel extends BaseViewModel {
setState(ViewState.Error);
} else {
_filterList();
await _getPrescriptionsOrders();
await getPrescriptionsOrders();
setState(ViewState.Idle);
}
}
@ -71,7 +71,8 @@ class PrescriptionsViewModel extends BaseViewModel {
});
}
_getPrescriptionsOrders() async {
getPrescriptionsOrders({bool showLoading = false}) async {
if (showLoading) setState(ViewState.Busy);
await _prescriptionsService.getPrescriptionsOrders();
if (_prescriptionsService.hasError) {
error = _prescriptionsService.error;

@ -21,11 +21,7 @@ class PrescriptionOrderOverview extends StatelessWidget {
final AddressInfo selectedAddress;
final double latitude;
final double longitude;
PrescriptionOrderOverview(
{Key key,
this.prescriptions,
this.prescriptionReportList,
this.prescriptionReportEnhList, this.selectedAddress, this.latitude, this.longitude});
PrescriptionOrderOverview({Key key, this.prescriptions, this.prescriptionReportList, this.prescriptionReportEnhList, this.selectedAddress, this.latitude, this.longitude});
@override
Widget build(BuildContext context) {
@ -50,14 +46,12 @@ class PrescriptionOrderOverview extends StatelessWidget {
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
border:
Border.all(color: Colors.grey[200], width: 0.5),
border: Border.all(color: Colors.grey[200], width: 0.5),
),
child: Row(
children: <Widget>[
ClipRRect(
borderRadius:
BorderRadius.all(Radius.circular(5)),
borderRadius: BorderRadius.all(Radius.circular(5)),
child: Image.network(
prescriptionReportList[index].imageSRCUrl,
fit: BoxFit.cover,
@ -72,13 +66,8 @@ class PrescriptionOrderOverview extends StatelessWidget {
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Texts(prescriptionReportList[index]
.itemDescription
.isNotEmpty
? prescriptionReportList[index]
.itemDescription
: prescriptionReportList[index]
.itemDescriptionN)),
child: Texts(
prescriptionReportList[index].itemDescription.isNotEmpty ? prescriptionReportList[index].itemDescription : prescriptionReportList[index].itemDescriptionN)),
)),
Icon(
Icons.arrow_forward_ios,
@ -114,8 +103,7 @@ class PrescriptionOrderOverview extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Texts(prescriptionReportEnhList[index]
.itemDescription),
Texts(prescriptionReportEnhList[index].itemDescription),
],
),
),
@ -138,7 +126,9 @@ class PrescriptionOrderOverview extends StatelessWidget {
color: Colors.grey[100],
child: Column(
children: <Widget>[
SizedBox(height: 12,),
SizedBox(
height: 12,
),
Container(
width: MediaQuery.of(context).size.width * 0.8,
child: SecondaryButton(
@ -152,28 +142,29 @@ class PrescriptionOrderOverview extends StatelessWidget {
okTitle: TranslationBase.of(context).ok,
onTap: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model.insertDeliveryOrder(lineItemNo: 0,
longitude: longitude,
latitude: latitude,appointmentNo: prescriptions.appointmentNo,
dischargeID: prescriptions.dischargeNo,createdBy: model.user.patientID)
await model
.insertDeliveryOrder(
lineItemNo: 0,
longitude: longitude,
latitude: latitude,
appointmentNo: prescriptions.appointmentNo,
dischargeID: prescriptions.dischargeNo,
createdBy: model.user.patientID)
.then((value) {
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal)
showErrorDialog(context,model.error);
else
{
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
}
showErrorDialog(context, model.error);
else {
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context, true);
}
}).catchError((e) {
GifLoaderDialogUtils.hideDialog(context);
});
},
),
);
},
))
],
@ -183,7 +174,7 @@ class PrescriptionOrderOverview extends StatelessWidget {
);
}
void showErrorDialog(BuildContext context,String error) {
void showErrorDialog(BuildContext context, String error) {
showDialog(
context: context,
child: ConfirmWithMessageDialog(
@ -192,12 +183,9 @@ class PrescriptionOrderOverview extends StatelessWidget {
onTap: () {
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context, true);
},
),
);
}
}

@ -70,21 +70,23 @@ class PrescriptionItemsPage extends StatelessWidget {
ListView.separated(
itemBuilder: (context, index) {
return InkWell(
onTap: () => Navigator.push(
context,
FadePage(
page: PrescriptionDetailsPageINP(
prescriptionReport: model.prescriptionReportListINP[index],
onTap: () {
Navigator.push(
context,
FadePage(
page: PrescriptionDetailsPageINP(
prescriptionReport: model.prescriptionReportListINP[index],
),
),
),
),
);
},
child: Container(
width: double.infinity,
child: Card(
margin: EdgeInsets.only(left: 16, right: 16, top: index == 0 ? 16 : 4, bottom: 4),
shape: cardRadius(12),
child: Padding(
padding: EdgeInsets.only(top: 12, bottom: 20, left:projectViewModel.isArabic? 12:20, right: projectViewModel.isArabic? 20:12),
padding: EdgeInsets.only(top: 12, bottom: 20, left: projectViewModel.isArabic ? 12 : 20, right: projectViewModel.isArabic ? 20 : 12),
child: Row(
children: [
Flexible(
@ -182,7 +184,10 @@ class PrescriptionItemsPage extends StatelessWidget {
],
),
),
Icon(Icons.arrow_forward_ios,size: 16,),
Icon(
Icons.arrow_forward_ios,
size: 16,
),
],
),
),
@ -238,7 +243,7 @@ class PrescriptionItemsPage extends StatelessWidget {
],
),
child: Padding(
padding: EdgeInsets.only(top: 12, bottom: 20, left:projectViewModel.isArabic? 12:20, right: projectViewModel.isArabic? 20:12),
padding: EdgeInsets.only(top: 12, bottom: 20, left: projectViewModel.isArabic ? 12 : 20, right: projectViewModel.isArabic ? 20 : 12),
child: Row(
children: [
Flexible(
@ -279,8 +284,8 @@ class PrescriptionItemsPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
myRichText(TranslationBase.of(context).route + ": ", model.prescriptionReportEnhList[index].route, projectViewModel.isArabic),
myRichText(
TranslationBase.of(context).dailyDoses + ": ", model.prescriptionReportEnhList[index].doseDailyQuantity.toString(), projectViewModel.isArabic),
myRichText(TranslationBase.of(context).dailyDoses + ": ", model.prescriptionReportEnhList[index].doseDailyQuantity.toString(),
projectViewModel.isArabic),
mHeight(9),
Text(
model.prescriptionReportEnhList[index].remarks,
@ -299,7 +304,10 @@ class PrescriptionItemsPage extends StatelessWidget {
],
),
),
Icon(Icons.arrow_forward_ios,size: 16,),
Icon(
Icons.arrow_forward_ios,
size: 16,
),
],
),
),
@ -317,29 +325,28 @@ class PrescriptionItemsPage extends StatelessWidget {
),
),
Container(
width: double.infinity,
padding: EdgeInsets.only(left: 16, right: 16, top: 16, bottom: 20),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
child: SecondaryButton(
label: TranslationBase.of(context).resendOrder,
disabled: (!projectViewModel.havePrivilege(62)) || projectViewModel.user.outSA == 1 || model.isMedDeliveryAllowed == false,
onTap: () {
Navigator.push(
context,
FadePage(
page: PrescriptionDeliveryAddressPage(
prescriptions: prescriptions,
prescriptionReportList: model.prescriptionReportList,
prescriptionReportEnhList: model.prescriptionReportEnhList,
),
),
);
},
color: Color(0xff359846),
),
color: Colors.white,
padding: EdgeInsets.only(top: 16, bottom: 16, right: 21, left: 21),
child: DefaultButton(
TranslationBase.of(context).resendOrder,
((!projectViewModel.havePrivilege(62)) || projectViewModel.user.outSA == 1 || model.isMedDeliveryAllowed == false)
? null
: () => {
Navigator.push(
context,
FadePage(
page: PrescriptionDeliveryAddressPage(
prescriptions: prescriptions,
prescriptionReportList: model.prescriptionReportList,
prescriptionReportEnhList: model.prescriptionReportEnhList,
),
),
)
},
color: Color(0xff359846),
disabledColor: Color(0xff575757),
),
)
),
],
),
),

@ -189,11 +189,10 @@ class PrescriptionsHistoryDetailsPage extends StatelessWidget {
confirmMessage: "Are you sure ?",
okText: TranslationBase.of(context).confirm,
cancelText: TranslationBase.of(context).cancel,
okFunction: () {
okFunction: () async {
Navigator.of(context).pop();
model.updatePressOrder(presOrderID: prescriptionsOrder.iD).then((value) {
Navigator.of(context).pop();
});
await model.updatePressOrder(presOrderID: prescriptionsOrder.iD);
Navigator.of(context).pop(true);
},
cancelFunction: () => {}).showAlertDialog(context);
// dialog.showAlertDialog(context);

@ -12,9 +12,10 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class PrescriptionsHistoryPage extends StatelessWidget {
final VoidCallback showOrderLog;
final PrescriptionsViewModel prescriptionsViewModel;
PrescriptionsHistoryPage({Key key, this.prescriptionsViewModel});
PrescriptionsHistoryPage({Key key, this.prescriptionsViewModel, this.showOrderLog});
@override
Widget build(BuildContext context) {
@ -47,14 +48,19 @@ class PrescriptionsHistoryPage extends StatelessWidget {
}
return InkWell(
onTap: () => Navigator.push(
context,
FadePage(
page: PrescriptionsHistoryDetailsPage(
prescriptionsOrder: prescriptionsViewModel.prescriptionsHistory[index],
),
onTap: () async {
final result = await Navigator.push(
context,
FadePage(
page: PrescriptionsHistoryDetailsPage(
prescriptionsOrder: prescriptionsViewModel.prescriptionsHistory[index],
),
),
);
if (result != null) {
showOrderLog();
}
},
child: Container(
height: 65,
decoration: BoxDecoration(
@ -78,16 +84,16 @@ class PrescriptionsHistoryPage extends StatelessWidget {
decoration: BoxDecoration(
color: _color,
borderRadius: BorderRadius.only(
topLeft:projectViewModel.isArabic? Radius.circular(0.0):Radius.circular(10.0),
bottomLeft:projectViewModel.isArabic? Radius.circular(0.0):Radius.circular(10.0),
topRight:projectViewModel.isArabic? Radius.circular(10.0):Radius.circular(0.0),
bottomRight:projectViewModel.isArabic? Radius.circular(10.0):Radius.circular(0.0),
topLeft: projectViewModel.isArabic ? Radius.circular(0.0) : Radius.circular(10.0),
bottomLeft: projectViewModel.isArabic ? Radius.circular(0.0) : Radius.circular(10.0),
topRight: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0.0),
bottomRight: projectViewModel.isArabic ? Radius.circular(10.0) : Radius.circular(0.0),
),
),
),
Expanded(
child: Padding(
padding: EdgeInsets.only(left: projectViewModel.isArabic?6:12, right: projectViewModel.isArabic?12:6),
padding: EdgeInsets.only(left: projectViewModel.isArabic ? 6 : 12, right: projectViewModel.isArabic ? 12 : 6),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
@ -126,7 +132,10 @@ class PrescriptionsHistoryPage extends StatelessWidget {
),
),
),
Icon(Icons.arrow_forward_ios,size: 16,),
Icon(
Icons.arrow_forward_ios,
size: 16,
),
mWidth(6),
],
),

@ -85,9 +85,18 @@ class _HomePrescriptionsPageState extends State<HomePrescriptionsPage> with Sing
children: <Widget>[
PrescriptionsPage(
prescriptionsViewModel: model,
showOrderLog: () async {
_tabController.animateTo(1);
await model.getPrescriptionsOrders(showLoading: true);
setState(() {});
},
),
PrescriptionsHistoryPage(
prescriptionsViewModel: model,
showOrderLog: () async {
await model.getPrescriptionsOrders(showLoading: true);
setState(() {});
},
)
],
),

@ -15,9 +15,10 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class PrescriptionsPage extends StatelessWidget {
final VoidCallback showOrderLog;
final PrescriptionsViewModel prescriptionsViewModel;
const PrescriptionsPage({Key key, this.prescriptionsViewModel}) : super(key: key);
const PrescriptionsPage({Key key, this.prescriptionsViewModel, this.showOrderLog}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -61,14 +62,19 @@ class PrescriptionsPage extends StatelessWidget {
itemBuilder: (context, _index) {
Prescriptions prescriptions = prescriptionsList[_index];
return DoctorCard(
onTap: () => Navigator.push(
context,
FadePage(
page: PrescriptionItemsPage(
prescriptions: prescriptions,
),
onTap: () async {
final _shouldRecallApi = await Navigator.push(
context,
FadePage(
page: PrescriptionItemsPage(
prescriptions: prescriptions,
),
),
);
if (_shouldRecallApi != null) {
showOrderLog();
}
},
name: prescriptions.doctorName,
profileUrl: prescriptions.doctorImageURL,
rating: prescriptions.actualDoctorRate.toDouble(),

Loading…
Cancel
Save