patient profile settings page integration implementation contd.

pull/67/head
haroon amjad 1 month ago
parent 5f43063f2d
commit 1af2db5c09

@ -177,7 +177,7 @@ class ApiClientImp implements ApiClient {
} }
// body['TokenID'] = "@dm!n"; // body['TokenID'] = "@dm!n";
// body['PatientID'] = 4767477; // body['PatientID'] = 1018977;
} }
body.removeWhere((key, value) => value == null); body.removeWhere((key, value) => value == null);

@ -727,7 +727,7 @@ const FAMILY_FILES= 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatu
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -12,6 +12,8 @@ class InsuranceViewModel extends ChangeNotifier {
bool isInsuranceDetailsLoading = false; bool isInsuranceDetailsLoading = false;
bool isInsuranceUpdateDetailsLoading = false; bool isInsuranceUpdateDetailsLoading = false;
bool isInsuranceDataToBeLoaded = true;
InsuranceRepo insuranceRepo; InsuranceRepo insuranceRepo;
ErrorHandlerService errorHandlerService; ErrorHandlerService errorHandlerService;
@ -23,13 +25,15 @@ class InsuranceViewModel extends ChangeNotifier {
InsuranceViewModel({required this.insuranceRepo, required this.errorHandlerService}); InsuranceViewModel({required this.insuranceRepo, required this.errorHandlerService});
initInsuranceProvider() { initInsuranceProvider() {
if (isInsuranceDataToBeLoaded) {
patientInsuranceList.clear(); patientInsuranceList.clear();
patientInsuranceCardHistoryList.clear();
isInsuranceLoading = true; isInsuranceLoading = true;
getPatientInsuranceDetails();
}
patientInsuranceCardHistoryList.clear();
isInsuranceHistoryLoading = true; isInsuranceHistoryLoading = true;
isInsuranceDetailsLoading = true; isInsuranceDetailsLoading = true;
isInsuranceUpdateDetailsLoading = true; isInsuranceUpdateDetailsLoading = true;
getPatientInsuranceDetails();
notifyListeners(); notifyListeners();
} }
@ -48,7 +52,14 @@ class InsuranceViewModel extends ChangeNotifier {
notifyListeners(); notifyListeners();
} }
setIsInsuranceDataToBeLoaded(bool val) {
isInsuranceDataToBeLoaded = val;
notifyListeners();
}
Future<void> getPatientInsuranceDetails({Function(dynamic)? onSuccess, Function(String)? onError}) async { Future<void> getPatientInsuranceDetails({Function(dynamic)? onSuccess, Function(String)? onError}) async {
if (!isInsuranceDataToBeLoaded) return;
final result = await insuranceRepo.getPatientInsuranceDetails(); final result = await insuranceRepo.getPatientInsuranceDetails();
result.fold( result.fold(
@ -62,6 +73,7 @@ class InsuranceViewModel extends ChangeNotifier {
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
patientInsuranceList = apiResponse.data!; patientInsuranceList = apiResponse.data!;
isInsuranceLoading = false; isInsuranceLoading = false;
isInsuranceDataToBeLoaded = false;
notifyListeners(); notifyListeners();
if (onSuccess != null) { if (onSuccess != null) {
onSuccess(apiResponse); onSuccess(apiResponse);

@ -16,6 +16,7 @@ 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/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
import 'package:hmg_patient_app_new/features/insurance/insurance_view_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/patient_appointment_history_response_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/my_appointments_view_model.dart';
import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart'; import 'package:hmg_patient_app_new/features/prescriptions/prescriptions_view_model.dart';
@ -61,6 +62,8 @@ class _LandingPageState extends State<LandingPage> {
late PrescriptionsViewModel prescriptionsViewModel; late PrescriptionsViewModel prescriptionsViewModel;
final CacheService cacheService = GetIt.instance<CacheService>(); final CacheService cacheService = GetIt.instance<CacheService>();
late InsuranceViewModel insuranceViewModel;
final SwiperController _controller = SwiperController(); final SwiperController _controller = SwiperController();
@override @override
@ -81,6 +84,7 @@ class _LandingPageState extends State<LandingPage> {
myAppointmentsViewModel.getPatientAppointments(true, false); myAppointmentsViewModel.getPatientAppointments(true, false);
myAppointmentsViewModel.getPatientMyDoctors(); myAppointmentsViewModel.getPatientMyDoctors();
prescriptionsViewModel.initPrescriptionsViewModel(); prescriptionsViewModel.initPrescriptionsViewModel();
insuranceViewModel.initInsuranceProvider();
} }
}); });
super.initState(); super.initState();
@ -92,6 +96,7 @@ class _LandingPageState extends State<LandingPage> {
NavigationService navigationService = getIt.get<NavigationService>(); NavigationService navigationService = getIt.get<NavigationService>();
myAppointmentsViewModel = Provider.of<MyAppointmentsViewModel>(context, listen: false); myAppointmentsViewModel = Provider.of<MyAppointmentsViewModel>(context, listen: false);
prescriptionsViewModel = Provider.of<PrescriptionsViewModel>(context, listen: false); prescriptionsViewModel = Provider.of<PrescriptionsViewModel>(context, listen: false);
insuranceViewModel = Provider.of<InsuranceViewModel>(context, listen: false);
return Scaffold( return Scaffold(
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
body: SingleChildScrollView( body: SingleChildScrollView(

@ -55,7 +55,7 @@ class PatientInsuranceCard extends StatelessWidget {
icon: isInsuranceExpired ? AppAssets.cancel_circle_icon : AppAssets.insurance_active_icon, icon: isInsuranceExpired ? AppAssets.cancel_circle_icon : AppAssets.insurance_active_icon,
iconColor: isInsuranceExpired ? AppColors.primaryRedColor : AppColors.successColor, iconColor: isInsuranceExpired ? AppColors.primaryRedColor : AppColors.successColor,
iconSize: 13.h, iconSize: 13.h,
text: isInsuranceExpired ? "Insurance Expired" : "Insurance Active", text: isInsuranceExpired ? "Insurance Expired".needTranslation : "Insurance Active".needTranslation,
onPressed: () {}, onPressed: () {},
backgroundColor: isInsuranceExpired ? AppColors.primaryRedColor.withOpacity(0.15) : AppColors.successColor.withOpacity(0.15), backgroundColor: isInsuranceExpired ? AppColors.primaryRedColor.withOpacity(0.15) : AppColors.successColor.withOpacity(0.15),
borderColor: isInsuranceExpired ? AppColors.primaryRedColor.withOpacity(0.01) : AppColors.successColor.withOpacity(0.01), borderColor: isInsuranceExpired ? AppColors.primaryRedColor.withOpacity(0.01) : AppColors.successColor.withOpacity(0.01),

@ -3,12 +3,16 @@ import 'package:flutter/material.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart'; import 'package:flutter_swiper_view/flutter_swiper_view.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_export.dart'; import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/int_extensions.dart'; import 'package:hmg_patient_app_new/extensions/int_extensions.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.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/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
import 'package:hmg_patient_app_new/features/insurance/insurance_view_model.dart';
import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart'; import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/habib_wallet/habib_wallet_page.dart'; import 'package:hmg_patient_app_new/presentation/habib_wallet/habib_wallet_page.dart';
import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart'; import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart';
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart'; import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
@ -21,6 +25,8 @@ import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart'; import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../core/dependencies.dart' show getIt;
class ProfileSettings extends StatefulWidget { class ProfileSettings extends StatefulWidget {
ProfileSettings({Key? key}) : super(key: key); ProfileSettings({Key? key}) : super(key: key);
@ -75,7 +81,7 @@ class _ProfileSettingsState extends State<ProfileSettings> {
builder: DotSwiperPaginationBuilder(color: Color(0xffD9D9D9), activeColor: AppColors.blackBgColor), builder: DotSwiperPaginationBuilder(color: Color(0xffD9D9D9), activeColor: AppColors.blackBgColor),
), ),
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return FamilyCardWidget().paddingOnly(right: 16); return FamilyCardWidget(isRootUser: true).paddingOnly(right: 16);
}, },
), ),
GridView( GridView(
@ -224,10 +230,14 @@ class _ProfileSettingsState extends State<ProfileSettings> {
} }
class FamilyCardWidget extends StatelessWidget { class FamilyCardWidget extends StatelessWidget {
FamilyCardWidget(); FamilyCardWidget({this.isRootUser = true, Key? key}) : super(key: key);
bool isRootUser;
late AppState appState;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
appState = getIt.get<AppState>();
return Container( return Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration( decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor, color: AppColors.whiteColor,
@ -243,17 +253,18 @@ class FamilyCardWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8.h, spacing: 8.h,
children: [ children: [
Image.asset(true ? AppAssets.male_img : AppAssets.femaleImg, width: 56.h, height: 56.h), Image.asset(appState.getAuthenticatedUser()?.gender == 1 ? AppAssets.male_img : AppAssets.femaleImg, width: 56.h, height: 56.h),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
spacing: 0.h, spacing: 0.h,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
"Mahmoud Shrouf Shrouf".toText18(isBold: true, weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}"
.toText18(isBold: true, weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1),
AppCustomChipWidget( AppCustomChipWidget(
icon: AppAssets.file_icon, icon: AppAssets.file_icon,
labelText: "File no: 3423443", labelText: "${LocaleKeys.fileNo.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}",
iconSize: 14, iconSize: 12,
), ),
], ],
).expanded, ).expanded,
@ -266,22 +277,52 @@ class FamilyCardWidget extends StatelessWidget {
alignment: WrapAlignment.start, alignment: WrapAlignment.start,
spacing: 8.h, spacing: 8.h,
children: [ children: [
AppCustomChipWidget(labelText: "35 Years Old"), AppCustomChipWidget(labelText: "${appState.getAuthenticatedUser()!.age} Years Old"),
AppCustomChipWidget(labelText: "Blood: A+"),
AppCustomChipWidget( AppCustomChipWidget(
icon: AppAssets.insurance_active_icon, icon: AppAssets.blood_icon,
labelText: "Insurance Active", labelText: "${LocaleKeys.bloodType.tr(context: context)}: ${appState.getUserBloodGroup}",
iconColor: AppColors.bgGreenColor, iconColor: AppColors.primaryRedColor,
iconSize: 14,
backgroundColor: AppColors.bgGreenColor.withValues(alpha: 0.15),
), ),
Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) {
return AppCustomChipWidget(
icon: insuranceVM.isInsuranceLoading
? AppAssets.cancel_circle_icon
: (DateTime.now().isAfter(
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
))
? AppAssets.cancel_circle_icon
: AppAssets.insurance_active_icon,
labelText: insuranceVM.isInsuranceLoading
? "Insurance"
: (DateTime.now().isAfter(
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
)
? "Insurance Expired".needTranslation
: "Insurance Active".needTranslation),
iconColor: insuranceVM.isInsuranceLoading
? AppColors.primaryRedColor
: (DateTime.now().isAfter(
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
))
? AppColors.primaryRedColor
: AppColors.successColor,
iconSize: 14,
backgroundColor: insuranceVM.isInsuranceLoading
? AppColors.primaryRedColor
: (DateTime.now().isAfter(
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
))
? AppColors.primaryRedColor.withValues(alpha: 0.15)
: AppColors.successColor.withValues(alpha: 0.15),
).toShimmer2(isShow: insuranceVM.isInsuranceLoading);
}),
], ],
), ),
), ),
], ],
).paddingOnly(top: 16, right: 16, left: 16, bottom: 12).expanded, ).paddingOnly(top: 16, right: 16, left: 16, bottom: 12).expanded,
1.divider, 1.divider,
CustomButton(icon: AppAssets.add_family, text: "Add a new family member".needTranslation, onPressed: () {}).paddingOnly(top: 12, right: 16, left: 16, bottom: 16), CustomButton(icon: AppAssets.add_family, text: "Add a new family member".needTranslation, height: 40.h, fontSize: 14, onPressed: () {}).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
], ],
), ),
); );

Loading…
Cancel
Save