diff --git a/assets/images/svg/switch_user.svg b/assets/images/svg/switch_user.svg
new file mode 100644
index 0000000..fa8e47e
--- /dev/null
+++ b/assets/images/svg/switch_user.svg
@@ -0,0 +1,8 @@
+
diff --git a/lib/core/app_assets.dart b/lib/core/app_assets.dart
index dd4bce4..424b90c 100644
--- a/lib/core/app_assets.dart
+++ b/lib/core/app_assets.dart
@@ -141,6 +141,7 @@ class AppAssets {
static const String ic_normal_result = '$svgBasePath/normal_result.svg';
static const String ic_low_result = '$svgBasePath/low_result.svg';
static const String ic_critical_low_result = '$svgBasePath/critical_low_result.svg';
+ static const String switch_user = '$svgBasePath/switch_user.svg';
//bottom navigation//
static const String homeBottom = '$svgBasePath/home_bottom.svg';
diff --git a/lib/core/app_state.dart b/lib/core/app_state.dart
index 206adc1..030cc36 100644
--- a/lib/core/app_state.dart
+++ b/lib/core/app_state.dart
@@ -57,7 +57,7 @@ class AppState {
}
}
- int? get superUserID => _superUserID;
+ int? get getSuperUserID => _superUserID;
set setSuperUserID(int? value) => _superUserID = value;
diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart
index 9244e4a..96bdc0b 100644
--- a/lib/features/authentication/authentication_repo.dart
+++ b/lib/features/authentication/authentication_repo.dart
@@ -205,6 +205,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
bool isSwitchUser = false,
int? patientID,
int? loginType}) async {
+ AppState appState = getIt.get();
if (isRegister) {
newRequest["activationCode"] = activationCode ?? "0000";
newRequest["isSilentLogin"] = activationCode != null ? false : true;
@@ -243,6 +244,16 @@ class AuthenticationRepoImp implements AuthenticationRepo {
} else {
switchRequest['LoginType'] = 2;
}
+
+ if (appState.getSuperUserID == responseID) {
+ switchRequest['LoginType'] = 3;
+ switchRequest['PatientIdentificationID'] = "";
+ // switchRequest['ProjectOutSA'] = newRequest.zipCode == '966' ? false : true;
+ switchRequest.remove('NationalID');
+ switchRequest.remove('isDentalAllowedBackend');
+ switchRequest.remove('ProjectOutSA');
+ switchRequest.remove('ForRegisteration');
+ }
}
final endpoint = isFormFamilyFile
diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart
index 1bdc09e..0a11eda 100644
--- a/lib/features/authentication/authentication_view_model.dart
+++ b/lib/features/authentication/authentication_view_model.dart
@@ -518,7 +518,7 @@ class AuthenticationViewModel extends ChangeNotifier {
responseID: responseID,
isSwitchUser: isSwitchUser,
patientID: patientID,
- loginType: _appState.superUserID != null ? 0 : 2,
+ loginType: _appState.getSuperUserID != null ? 0 : 2,
);
resultEither.fold(
diff --git a/lib/features/medical_file/medical_file_view_model.dart b/lib/features/medical_file/medical_file_view_model.dart
index 153828c..64075b4 100644
--- a/lib/features/medical_file/medical_file_view_model.dart
+++ b/lib/features/medical_file/medical_file_view_model.dart
@@ -257,7 +257,7 @@ class MedicalFileViewModel extends ChangeNotifier {
}
Future getFamilyFiles({int? status, Function(dynamic)? onSuccess, Function(String)? onError}) async {
- final result = await medicalFileRepo.getPatientFamilyFiles(status, _appState.superUserID != null ? _appState.superUserID! : _appState.getAuthenticatedUser()!.patientId!);
+ final result = await medicalFileRepo.getPatientFamilyFiles(status, _appState.getSuperUserID != null ? _appState.getSuperUserID! : _appState.getAuthenticatedUser()!.patientId!);
result.fold(
(failure) async => await errorHandlerService.handleError(
@@ -288,61 +288,157 @@ class MedicalFileViewModel extends ChangeNotifier {
),
);
+ // final List activeFamilyFiles = [];
+ // final List tempPendingFamilyFiles = [];
+ // for (var element in apiResponse.data!) {
+ // if (element.status != null && element.status == FamilyFileEnum.active.toInt) {
+ // activeFamilyFiles.add(FamilyFileResponseModelLists(
+ // patientId: element.patientId,
+ // patientName: element.patientName!,
+ // isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
+ // gender: element.gender!,
+ // responseId: element.patientId,
+ // mobileNumber: element.mobileNumber,
+ // age: element.age,
+ // patientIdenficationNumber: element.patientIdenficationNumber,
+ // relationship: element.relationship,
+ // relationshipId: element.relationshipId,
+ // relationshipN: element.relationshipN,
+ // status: element.status,
+ // statusDescription: element.statusDescription,
+ // createdOn: element.createdOn,
+ // editedOn: element.editedOn,
+ // patientDataVerified: element.patientDataVerified,
+ // regionId: element.regionId,
+ // familyRegionId: element.familyRegionId,
+ // genderDescription: element.genderDescription,
+ // genderImage: element.genderImage,
+ // emaiLAddress: element.emaiLAddress));
+ // }
+ //
+ // if (element.status != null && element.status == FamilyFileEnum.pending.toInt) {
+ // tempPendingFamilyFiles.add(FamilyFileResponseModelLists(
+ // patientId: element.patientId,
+ // patientName: element.patientName!,
+ // isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
+ // gender: element.gender!,
+ // responseId: element.patientId,
+ // mobileNumber: element.mobileNumber,
+ // age: element.age,
+ // patientIdenficationNumber: element.patientIdenficationNumber,
+ // relationship: element.relationship,
+ // relationshipId: element.relationshipId,
+ // relationshipN: element.relationshipN,
+ // status: element.status,
+ // statusDescription: element.statusDescription,
+ // createdOn: element.createdOn,
+ // editedOn: element.editedOn,
+ // patientDataVerified: element.patientDataVerified,
+ // regionId: element.regionId,
+ // familyRegionId: element.familyRegionId,
+ // genderDescription: element.genderDescription,
+ // genderImage: element.genderImage,
+ // emaiLAddress: element.emaiLAddress));
+ // }
+ // }
+ // patientFamilyFiles.addAll(activeFamilyFiles.where((element) => !patientFamilyFiles.any((e) => e.patientId == element.patientId)));
+ // pendingFamilyFiles.addAll(tempPendingFamilyFiles);
+
final List activeFamilyFiles = [];
final List tempPendingFamilyFiles = [];
- for (var element in apiResponse.data!) {
- if (element.status != null && element.status == FamilyFileEnum.active.toInt) {
- activeFamilyFiles.add(FamilyFileResponseModelLists(
- patientId: element.patientId,
- patientName: element.patientName!,
- isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
- gender: element.gender!,
- responseId: element.patientId,
- mobileNumber: element.mobileNumber,
- age: element.age,
- patientIdenficationNumber: element.patientIdenficationNumber,
- relationship: element.relationship,
- relationshipId: element.relationshipId,
- relationshipN: element.relationshipN,
- status: element.status,
- statusDescription: element.statusDescription,
- createdOn: element.createdOn,
- editedOn: element.editedOn,
- patientDataVerified: element.patientDataVerified,
- regionId: element.regionId,
- familyRegionId: element.familyRegionId,
- genderDescription: element.genderDescription,
- genderImage: element.genderImage,
- emaiLAddress: element.emaiLAddress));
- }
+ // final Set pendingIds = {};
+
+ // for (var element in apiResponse.data!) {
+ // if (element.status != null && element.status == FamilyFileEnum.pending.toInt) {
+ // tempPendingFamilyFiles.add(FamilyFileResponseModelLists(
+ // patientId: element.patientId,
+ // patientName: element.patientName!,
+ // isActive: false,
+ // gender: element.gender!,
+ // responseId: element.patientId,
+ // mobileNumber: element.mobileNumber,
+ // age: element.age,
+ // patientIdenficationNumber: element.patientIdenficationNumber,
+ // relationship: element.relationship,
+ // relationshipId: element.relationshipId,
+ // relationshipN: element.relationshipN,
+ // status: element.status,
+ // statusDescription: element.statusDescription,
+ // createdOn: element.createdOn,
+ // editedOn: element.editedOn,
+ // patientDataVerified: element.patientDataVerified,
+ // regionId: element.regionId,
+ // familyRegionId: element.familyRegionId,
+ // genderDescription: element.genderDescription,
+ // genderImage: element.genderImage,
+ // emaiLAddress: element.emaiLAddress));
+ // } else if (element.status != null && element.status == FamilyFileEnum.active.toInt) {
+ // activeFamilyFiles.add(FamilyFileResponseModelLists(
+ // patientId: element.patientId,
+ // patientName: element.patientName!,
+ // isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
+ // gender: element.gender!,
+ // responseId: element.patientId,
+ // mobileNumber: element.mobileNumber,
+ // age: element.age,
+ // patientIdenficationNumber: element.patientIdenficationNumber,
+ // relationship: element.relationship,
+ // relationshipId: element.relationshipId,
+ // relationshipN: element.relationshipN,
+ // status: element.status,
+ // statusDescription: element.statusDescription,
+ // createdOn: element.createdOn,
+ // editedOn: element.editedOn,
+ // patientDataVerified: element.patientDataVerified,
+ // regionId: element.regionId,
+ // familyRegionId: element.familyRegionId,
+ // genderDescription: element.genderDescription,
+ // genderImage: element.genderImage,
+ // emaiLAddress: element.emaiLAddress));
+ // }
+ // }
- if (element.status != null && element.status == FamilyFileEnum.pending.toInt) {
- tempPendingFamilyFiles.add(FamilyFileResponseModelLists(
- patientId: element.patientId,
- patientName: element.patientName!,
- isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
- gender: element.gender!,
- responseId: element.patientId,
- mobileNumber: element.mobileNumber,
- age: element.age,
- patientIdenficationNumber: element.patientIdenficationNumber,
- relationship: element.relationship,
- relationshipId: element.relationshipId,
- relationshipN: element.relationshipN,
- status: element.status,
- statusDescription: element.statusDescription,
- createdOn: element.createdOn,
- editedOn: element.editedOn,
- patientDataVerified: element.patientDataVerified,
- regionId: element.regionId,
- familyRegionId: element.familyRegionId,
- genderDescription: element.genderDescription,
- genderImage: element.genderImage,
- emaiLAddress: element.emaiLAddress));
+ for (var element in apiResponse.data!) {
+ if (element.status == null) continue;
+
+ final isPending = element.status == FamilyFileEnum.pending.toInt;
+ final isActive = element.status == FamilyFileEnum.active.toInt;
+
+ if (!isPending && !isActive) continue;
+
+ final familyFile = FamilyFileResponseModelLists(
+ patientId: element.patientId,
+ patientName: element.patientName!,
+ isActive: isActive,
+ gender: element.gender!,
+ responseId: element.patientId,
+ mobileNumber: element.mobileNumber,
+ age: element.age,
+ patientIdenficationNumber: element.patientIdenficationNumber,
+ relationship: element.relationship,
+ relationshipId: element.relationshipId,
+ relationshipN: element.relationshipN,
+ status: element.status,
+ statusDescription: element.statusDescription,
+ createdOn: element.createdOn,
+ editedOn: element.editedOn,
+ patientDataVerified: element.patientDataVerified,
+ regionId: element.regionId,
+ familyRegionId: element.familyRegionId,
+ genderDescription: element.genderDescription,
+ genderImage: element.genderImage,
+ emaiLAddress: element.emaiLAddress,
+ );
+
+ if (isPending) {
+ tempPendingFamilyFiles.add(familyFile);
+ } else if (isActive) {
+ activeFamilyFiles.add(familyFile);
}
}
- patientFamilyFiles.addAll(activeFamilyFiles.where((element) => !patientFamilyFiles.any((e) => e.patientId == element.patientId)));
- pendingFamilyFiles.addAll(tempPendingFamilyFiles);
+
+ patientFamilyFiles.addAll(activeFamilyFiles.where((element) => patientFamilyFiles.every((e) => e.patientId != element.patientId || e.status != FamilyFileEnum.active.toInt)));
+ pendingFamilyFiles.addAll(tempPendingFamilyFiles.where((element) => pendingFamilyFiles.every((e) => e.patientId != element.patientId)));
}
notifyListeners();
diff --git a/lib/presentation/medical_file/medical_file_page.dart b/lib/presentation/medical_file/medical_file_page.dart
index afea4e6..dcd83c6 100644
--- a/lib/presentation/medical_file/medical_file_page.dart
+++ b/lib/presentation/medical_file/medical_file_page.dart
@@ -73,13 +73,16 @@ class _MedicalFilePageState extends State {
@override
void initState() {
+ appState = getIt.get();
scheduleMicrotask(() {
if (appState.isAuthenticated) {
insuranceViewModel.initInsuranceProvider();
medicalFileViewModel.setIsPatientSickLeaveListLoading(true);
medicalFileViewModel.getPatientSickLeaveList();
- medicalFileViewModel.getFamilyFiles(); //TODO: Remove status: 1 by Aamir Need to Discuss With Sultan
- medicalFileViewModel.getAllPendingRecordsByResponseId(); //TODO: Added By Aamir
+ if (appState.getSuperUserID == null) {
+ medicalFileViewModel.getFamilyFiles(status: 3); //TODO: Remove status: 1 by Aamir Need to Discuss With Sultan
+ medicalFileViewModel.getAllPendingRecordsByResponseId(); //TODO: Added By Aamir
+ }
medicalFileViewModel.onTabChanged(0);
}
@@ -93,7 +96,6 @@ class _MedicalFilePageState extends State {
myAppointmentsViewModel = Provider.of(context, listen: false);
medicalFileViewModel = Provider.of(context, listen: false);
bookAppointmentsViewModel = Provider.of(context, listen: false);
- appState = getIt.get();
NavigationService navigationService = getIt.get();
return Scaffold(
backgroundColor: AppColors.bgScaffoldColor,
diff --git a/lib/presentation/my_family/my_Family.dart b/lib/presentation/my_family/my_Family.dart
index 1944704..c0d85c0 100644
--- a/lib/presentation/my_family/my_Family.dart
+++ b/lib/presentation/my_family/my_Family.dart
@@ -13,6 +13,7 @@ import 'package:hmg_patient_app_new/features/authentication/authentication_view_
import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
+import 'package:hmg_patient_app_new/presentation/lab/collapsing_list_view.dart';
import 'package:hmg_patient_app_new/presentation/my_family/widget/family_cards.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
@@ -51,33 +52,23 @@ class _FamilyMedicalScreenState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
- backgroundColor: AppColors.scaffoldBgColor,
- appBar: CustomAppBar(
- onBackPressed: () {
- Navigator.of(context).pop();
- },
- onLanguageChanged: (lang) {},
- hideLogoAndLang: true,
- ),
- body: SingleChildScrollView(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- LocaleKeys.myMedicalFile.tr().toText26(color: AppColors.textColor, weight: FontWeight.w600, letterSpacing: -2),
- SizedBox(height: 25.h),
- CustomTabBar(
- tabs: tabs,
- onTabChange: (index) {
- medicalVM!.onFamilyFileTabChange(index);
- },
- ),
- SizedBox(height: 25.h),
- Consumer(builder: (context, medicalVM, child) => getFamilyTabs(index: medicalVM.getSelectedFamilyFileTabIndex)),
- SizedBox(height: 20.h),
- ],
- ),
- ).paddingSymmetrical(20, 0),
+ body: CollapsingListView(
+ title: "My Medical File".needTranslation,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ CustomTabBar(
+ tabs: tabs,
+ onTabChange: (index) {
+ medicalVM!.onFamilyFileTabChange(index);
+ },
+ ),
+ SizedBox(height: 25.h),
+ Consumer(builder: (context, medicalVM, child) => getFamilyTabs(index: medicalVM.getSelectedFamilyFileTabIndex)),
+ SizedBox(height: 20.h),
+ ],
+ ).paddingSymmetrical(20, 0)),
bottomSheet: Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
@@ -85,15 +76,58 @@ class _FamilyMedicalScreenState extends State {
),
padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.h),
child: CustomButton(
- text: "Add a new family member",
- onPressed: () {
- showModelSheet();
- },
- icon: AppAssets.add_icon,
- height: 56.h,
- fontWeight: FontWeight.w600,
- )),
+ text: "Add a new family member",
+ onPressed: () {
+ showModelSheet();
+ },
+ icon: AppAssets.add_icon,
+ height: 56.h,
+ fontWeight: FontWeight.w600)),
);
+ // return Scaffold(
+ // backgroundColor: AppColors.scaffoldBgColor,
+ // appBar: CustomAppBar(
+ // onBackPressed: () {
+ // Navigator.of(context).pop();
+ // },
+ // onLanguageChanged: (lang) {},
+ // hideLogoAndLang: true,
+ // ),
+ // body: SingleChildScrollView(
+ // child: Column(
+ // mainAxisSize: MainAxisSize.min,
+ // crossAxisAlignment: CrossAxisAlignment.start,
+ // children: [
+ // LocaleKeys.myMedicalFile.tr().toText26(color: AppColors.textColor, weight: FontWeight.w600, letterSpacing: -2),
+ // SizedBox(height: 25.h),
+ // CustomTabBar(
+ // tabs: tabs,
+ // onTabChange: (index) {
+ // medicalVM!.onFamilyFileTabChange(index);
+ // },
+ // ),
+ // SizedBox(height: 25.h),
+ // Consumer(builder: (context, medicalVM, child) => getFamilyTabs(index: medicalVM.getSelectedFamilyFileTabIndex)),
+ // SizedBox(height: 20.h),
+ // ],
+ // ).paddingSymmetrical(20, 0),
+ // ),
+ // bottomSheet: Container(
+ // decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
+ // color: AppColors.whiteColor,
+ // customBorder: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
+ // ),
+ // padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.h),
+ // child: CustomButton(
+ // text: "Add a new family member",
+ // onPressed: () {
+ // showModelSheet();
+ // },
+ // icon: AppAssets.add_icon,
+ // height: 56.h,
+ // fontWeight: FontWeight.w600,
+ // )),
+ // );
}
Widget getFamilyTabs({required int index}) {
@@ -113,7 +147,8 @@ class _FamilyMedicalScreenState extends State {
// medicalVM!.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber);
},
isShowDetails: true,
- ); default:
+ );
+ default:
return SizedBox.shrink();
}
}
diff --git a/lib/presentation/my_family/widget/family_cards.dart b/lib/presentation/my_family/widget/family_cards.dart
index 40a2d8c..3916756 100644
--- a/lib/presentation/my_family/widget/family_cards.dart
+++ b/lib/presentation/my_family/widget/family_cards.dart
@@ -33,7 +33,7 @@ class _FamilyCardsState extends State {
Widget build(BuildContext context) {
return GridView.builder(
shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
+ physics: NeverScrollableScrollPhysics(),
itemCount: widget.profiles.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
@@ -41,6 +41,7 @@ class _FamilyCardsState extends State {
mainAxisSpacing: 10.h,
childAspectRatio: widget.isShowDetails ? 0.56.h : 0.74.h,
),
+ padding: EdgeInsets.only(bottom: 80.h),
itemBuilder: (context, index) {
final profile = widget.profiles[index];
final isActive = (profile.responseId == appState.getAuthenticatedUser()?.patientId);
@@ -99,12 +100,12 @@ class _FamilyCardsState extends State {
CustomButton(
height: 40.h,
onPressed: () => widget.onSelect(profile),
- text: LocaleKeys.select.tr(),
+ text: LocaleKeys.switchAccount.tr(),
backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.primaryRedColor,
fontSize: 13.h,
- icon: widget.isBottomSheet ? null : AppAssets.heart,
+ icon: widget.isBottomSheet ? null : AppAssets.switch_user,
iconColor: AppColors.primaryRedColor,
padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0),
).paddingOnly(top: 0, bottom: 0),