prescription order implementation contd.

pull/103/head
haroon amjad 1 week ago
parent 1be430aa76
commit b90883a596

@ -711,7 +711,7 @@ var GET_PRESCRIPTION_INSTRUCTIONS_PDF = 'Services/ChatBot_Service.svc/REST/Chatb
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -130,7 +130,7 @@ class AppDependencies {
), ),
); );
getIt.registerLazySingleton<PrescriptionsViewModel>(() => PrescriptionsViewModel(prescriptionsRepo: getIt(), errorHandlerService: getIt())); getIt.registerLazySingleton<PrescriptionsViewModel>(() => PrescriptionsViewModel(prescriptionsRepo: getIt(), errorHandlerService: getIt(), navServices: getIt()));
getIt.registerLazySingleton<InsuranceViewModel>(() => InsuranceViewModel(insuranceRepo: getIt(), errorHandlerService: getIt())); getIt.registerLazySingleton<InsuranceViewModel>(() => InsuranceViewModel(insuranceRepo: getIt(), errorHandlerService: getIt()));

@ -1054,8 +1054,8 @@ class EmergencyServicesViewModel extends ChangeNotifier {
bool result = await navServices.push( bool result = await navServices.push(
CustomPageRoute( CustomPageRoute(
page: MapUtilityScreen( page: MapUtilityScreen(
confirmButtonString: "Submit Request ".needTranslation, confirmButtonString: "Submit Request".needTranslation,
titleString: "Select Location", titleString: "Select Location".needTranslation,
subTitleString: "Please select the location".needTranslation, subTitleString: "Please select the location".needTranslation,
isGmsAvailable: appState.isGMSAvailable, isGmsAvailable: appState.isGMSAvailable,
), ),

@ -1,8 +1,22 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/location_util.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/location/GeocodeResponse.dart';
import 'package:hmg_patient_app_new/features/location/PlaceDetails.dart';
import 'package:hmg_patient_app_new/features/location/PlacePrediction.dart';
import 'package:hmg_patient_app_new/features/location/location_view_model.dart';
import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/patient_prescriptions_response_model.dart'; import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/patient_prescriptions_response_model.dart';
import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/prescription_detail_response_model.dart'; import 'package:hmg_patient_app_new/features/prescriptions/models/resp_models/prescription_detail_response_model.dart';
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_repo.dart'; import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_repo.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/prescriptions/prescription_delivery_order_summary_page.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart'; import 'package:hmg_patient_app_new/services/error_handler_service.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart';
import 'package:hmg_patient_app_new/widgets/map/map_utility_screen.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
class PrescriptionsViewModel extends ChangeNotifier { class PrescriptionsViewModel extends ChangeNotifier {
bool isPrescriptionsOrdersLoading = false; bool isPrescriptionsOrdersLoading = false;
@ -10,6 +24,7 @@ class PrescriptionsViewModel extends ChangeNotifier {
PrescriptionsRepo prescriptionsRepo; PrescriptionsRepo prescriptionsRepo;
ErrorHandlerService errorHandlerService; ErrorHandlerService errorHandlerService;
NavigationService navServices;
// Prescription Orders Lists // Prescription Orders Lists
List<PatientPrescriptionsResponseModel> patientPrescriptionOrders = []; List<PatientPrescriptionsResponseModel> patientPrescriptionOrders = [];
@ -27,7 +42,9 @@ class PrescriptionsViewModel extends ChangeNotifier {
String prescriptionPDFBase64Data = ""; String prescriptionPDFBase64Data = "";
PrescriptionsViewModel({required this.prescriptionsRepo, required this.errorHandlerService}); late GeocodeResponse locationGeocodeResponse;
PrescriptionsViewModel({required this.prescriptionsRepo, required this.errorHandlerService, required this.navServices});
initPrescriptionsViewModel() { initPrescriptionsViewModel() {
patientPrescriptionOrders.clear(); patientPrescriptionOrders.clear();
@ -173,4 +190,31 @@ class PrescriptionsViewModel extends ChangeNotifier {
}, },
); );
} }
void initiatePrescriptionDelivery() async {
getIt.get<LocationUtils>().getLocation(
isShowConfirmDialog: true,
onSuccess: (position) async {
bool result = await navServices.push(
CustomPageRoute(
page: MapUtilityScreen(
confirmButtonString: LocaleKeys.next.tr(),
titleString: "Select Location".needTranslation,
subTitleString: "Please select the location for prescription delivery".needTranslation,
isGmsAvailable: getIt.get<AppState>().isGMSAvailable,
),
direction: AxisDirection.down),
);
print("Location Selected: $result");
if (result) {
LocationViewModel locationViewModel = getIt.get<LocationViewModel>();
locationGeocodeResponse = locationViewModel.geocodeResponse!;
navServices.push(
CustomPageRoute(
page: PrescriptionDeliveryOrderSummaryPage(),
),
);
}
});
}
} }

@ -0,0 +1,88 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:provider/provider.dart';
class PrescriptionDeliveryOrderSummaryPage extends StatelessWidget {
PrescriptionDeliveryOrderSummaryPage({super.key});
late PrescriptionsViewModel prescriptionsViewModel;
@override
Widget build(BuildContext context) {
prescriptionsViewModel = Provider.of<PrescriptionsViewModel>(context, listen: false);
return Scaffold(
backgroundColor: AppColors.bgScaffoldColor,
body: Column(
children: [
Expanded(
child: CollapsingListView(
title: LocaleKeys.deliveryLocation.tr(context: context),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 16.h),
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.r,
hasShadow: true,
),
child: Padding(
padding: EdgeInsets.all(16.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocaleKeys.orderSummary.tr(context: context).toText16(isBold: true),
SizedBox(height: 16.h),
...List.generate(
prescriptionsViewModel.prescriptionDetailsList.length,
(index) => Container(
margin: EdgeInsets.all(0.0),
child: Row(
children: <Widget>[
ClipRRect(
borderRadius: BorderRadius.all(
Radius.circular(5.r),
),
child: Image.network(
prescriptionsViewModel.prescriptionDetailsList[index].imageSRCUrl!,
fit: BoxFit.cover,
width: 60.w,
height: 70.h,
),
),
SizedBox(
width: 10.w,
),
Expanded(
child: Padding(
padding: EdgeInsets.all(8.h),
child: Center(
child: prescriptionsViewModel.prescriptionDetailsList[index].itemDescription!.toText12(),
),
),
),
],
),
))
],
),
),
),
],
).paddingSymmetrical(24.w, 0),
),
),
Container()
],
),
);
}
}

@ -6,6 +6,7 @@ import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart'; import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart'; import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/location_util.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart'; import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
@ -18,6 +19,8 @@ import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
import 'package:hmg_patient_app_new/presentation/prescriptions/prescription_detail_page.dart'; import 'package:hmg_patient_app_new/presentation/prescriptions/prescription_detail_page.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
import 'package:hmg_patient_app_new/widgets/map/map_utility_screen.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart'; import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:hmg_patient_app_new/widgets/shimmer/common_shimmer_widget.dart'; import 'package:hmg_patient_app_new/widgets/shimmer/common_shimmer_widget.dart';
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart'; import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
@ -237,16 +240,26 @@ class _PrescriptionsListPageState extends State<PrescriptionsListPage> {
text: prescription.isHomeMedicineDeliverySupported! text: prescription.isHomeMedicineDeliverySupported!
? LocaleKeys.resendOrder.tr(context: context) ? LocaleKeys.resendOrder.tr(context: context)
: LocaleKeys.prescriptionDeliveryError.tr(context: context), : LocaleKeys.prescriptionDeliveryError.tr(context: context),
onPressed: () {}, onPressed: () async {
backgroundColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor.withOpacity(0.15) : AppColors.greyF7Color, if (prescription.isHomeMedicineDeliverySupported!) {
borderColor: AppColors.successColor.withOpacity(0.01), LoaderBottomSheet.showLoader(loadingText: "Fetching prescription details...".needTranslation);
textColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35), await prescriptionsViewModel.getPrescriptionDetails(prescriptionsViewModel.patientPrescriptionOrders[index],
fontSize: prescription.isHomeMedicineDeliverySupported! ? 14 : 12, onSuccess: (val) {
fontWeight: FontWeight.w500, LoaderBottomSheet.hideLoader();
borderRadius: 12, prescriptionsViewModel.initiatePrescriptionDelivery();
padding: EdgeInsets.fromLTRB(10, 0, 10, 0), });
height: 40.h, }
icon: AppAssets.prescription_refill_icon, },
backgroundColor:
prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor.withOpacity(0.15) : AppColors.greyF7Color,
borderColor: AppColors.successColor.withOpacity(0.01),
textColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
fontSize: prescription.isHomeMedicineDeliverySupported! ? 14 : 12,
fontWeight: FontWeight.w500,
borderRadius: 12,
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 40.h,
icon: AppAssets.prescription_refill_icon,
iconColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35), iconColor: prescription.isHomeMedicineDeliverySupported! ? AppColors.successColor : AppColors.textColor.withOpacity(0.35),
iconSize: 14.h, iconSize: 14.h,
), ),

@ -146,6 +146,7 @@ class MapUtilityScreen extends StatelessWidget {
spacing: 24.h, spacing: 24.h,
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 4.h, spacing: 4.h,
children: [ children: [
titleString.toText21( titleString.toText21(

Loading…
Cancel
Save