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); setState(ViewState.Error);
} else { } else {
_filterList(); _filterList();
await _getPrescriptionsOrders(); await getPrescriptionsOrders();
setState(ViewState.Idle); 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(); await _prescriptionsService.getPrescriptionsOrders();
if (_prescriptionsService.hasError) { if (_prescriptionsService.hasError) {
error = _prescriptionsService.error; error = _prescriptionsService.error;

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

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

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

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

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

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

Loading…
Cancel
Save