Allergies list implemented

pull/110/head
haroon amjad 1 month ago
parent 03811586f1
commit 3185d1e9e7

@ -266,10 +266,10 @@ class AuthenticationRepoImp implements AuthenticationRepo {
newRequest.forRegisteration = newRequest.isRegister ?? false;
newRequest.isRegister = false;
//silent login case removed token and login token
if(newRequest.logInTokenID.isEmpty && newRequest.isSilentLogin == true) {
newRequest.logInTokenID = null;
newRequest.deviceToken = null;
}
// if(newRequest.logInTokenID.isEmpty && newRequest.isSilentLogin == true) {
// newRequest.logInTokenID = null;
// newRequest.deviceToken = null;
// }
}

@ -0,0 +1,37 @@
class GetAllergiesResponseModel {
int? patientID;
int? allergyDiseaseType;
int? allergyDiseaseID;
String? description;
String? descriptionN;
String? remarks;
GetAllergiesResponseModel({
this.patientID,
this.allergyDiseaseType,
this.allergyDiseaseID,
this.description,
this.descriptionN,
this.remarks,
});
GetAllergiesResponseModel.fromJson(Map<String, dynamic> json) {
patientID = json['PatientID'];
allergyDiseaseType = json['AllergyDiseaseType'];
allergyDiseaseID = json['AllergyDiseaseID'];
description = json['Description'];
descriptionN = json['DescriptionN'];
remarks = json['Remarks'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['PatientID'] = this.patientID;
data['AllergyDiseaseType'] = this.allergyDiseaseType;
data['AllergyDiseaseID'] = this.allergyDiseaseID;
data['Description'] = this.description;
data['DescriptionN'] = this.descriptionN;
data['Remarks'] = this.remarks;
return data;
}
}

@ -5,6 +5,7 @@ import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
import 'package:hmg_patient_app_new/core/exceptions/api_failure.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/features/book_appointments/models/resp_models/get_allergies_response_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/patient_medical_response_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/patient_sickleave_response_model.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/patient_vaccine_response_model.dart';
@ -38,6 +39,8 @@ abstract class MedicalFileRepo {
Future<Either<Failure, GenericApiModel<dynamic>>> removeFamilyFile({required int? id});
Future<Either<Failure, GenericApiModel<dynamic>>> acceptRejectFamilyFile({required int? id, required int? status});
Future<Either<Failure, GenericApiModel<List<GetAllergiesResponseModel>>>> getPatientAllergiesList({Function(dynamic)? onSuccess, Function(String)? onError});
}
class MedicalFileRepoImp implements MedicalFileRepo {
@ -549,4 +552,42 @@ class MedicalFileRepoImp implements MedicalFileRepo {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel<List<GetAllergiesResponseModel>>>> getPatientAllergiesList({Function(dynamic)? onSuccess, Function(String)? onError}) async {
Map<String, dynamic> mapDevice = {"isDentalAllowedBackend": false, "OutSA": 0};
try {
GenericApiModel<List<GetAllergiesResponseModel>>? apiResponse;
Failure? failure;
await apiClient.post(
GET_PATIENT_ALLERGIES,
body: mapDevice,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final list = response['Patient_Allergies'];
final vaccinesList = list.map((item) => GetAllergiesResponseModel.fromJson(item as Map<String, dynamic>)).toList().cast<GetAllergiesResponseModel>();
apiResponse = GenericApiModel<List<GetAllergiesResponseModel>>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
data: vaccinesList,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
},
);
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
} catch (e) {
return Left(UnknownFailure(e.toString()));
}
}
}

@ -9,6 +9,7 @@ import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/features/authentication/authentication_view_model.dart';
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/authenticated_user_resp_model.dart';
import 'package:hmg_patient_app_new/features/book_appointments/models/resp_models/get_allergies_response_model.dart';
import 'package:hmg_patient_app_new/features/common/models/family_file_request.dart';
import 'package:hmg_patient_app_new/features/medical_file/medical_file_repo.dart';
import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart';
@ -27,6 +28,7 @@ class MedicalFileViewModel extends ChangeNotifier {
bool isPatientSickLeaveListLoading = false;
bool isPatientSickLeavePDFLoading = false;
bool isPatientMedicalReportsListLoading = false;
bool isPatientAllergiesListLoading = false;
MedicalFileRepo medicalFileRepo;
ErrorHandlerService errorHandlerService;
@ -34,6 +36,8 @@ class MedicalFileViewModel extends ChangeNotifier {
List<PatientVaccineResponseModel> patientVaccineList = [];
List<PatientSickLeavesResponseModel> patientSickLeaveList = [];
List<GetAllergiesResponseModel> patientAllergiesList = [];
List<PatientMedicalReportResponseModel> patientMedicalReportList = [];
List<PatientMedicalReportResponseModel> patientMedicalReportRequestedList = [];
@ -69,8 +73,10 @@ class MedicalFileViewModel extends ChangeNotifier {
initMedicalFileProvider() {
patientMedicalReportAppointmentHistoryList.clear();
patientAllergiesList.clear();
isPatientVaccineListLoading = true;
isPatientMedicalReportsListLoading = true;
isPatientAllergiesListLoading = true;
notifyListeners();
}
@ -162,6 +168,32 @@ class MedicalFileViewModel extends ChangeNotifier {
);
}
Future<void> getPatientAllergiesList({Function(dynamic)? onSuccess, Function(String)? onError}) async {
isPatientAllergiesListLoading = true;
patientAllergiesList.clear();
notifyListeners();
final result = await medicalFileRepo.getPatientAllergiesList();
result.fold(
(failure) async {
isPatientAllergiesListLoading = false;
notifyListeners();
},
(apiResponse) {
if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
patientAllergiesList = apiResponse.data!;
isPatientAllergiesListLoading = false;
notifyListeners();
if (onSuccess != null) {
onSuccess(apiResponse);
}
}
},
);
}
Future<void> getPatientSickLeaveList({Function(dynamic)? onSuccess, Function(String)? onError}) async {
patientSickLeaveList.clear();
final result = await medicalFileRepo.getPatientSickLeavesList();

@ -0,0 +1,138 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
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/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/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/medical_file/medical_file_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 AllergiesListPage extends StatelessWidget {
AllergiesListPage({super.key});
late MedicalFileViewModel medicalFileViewModel;
@override
Widget build(BuildContext context) {
medicalFileViewModel = Provider.of<MedicalFileViewModel>(context, listen: false);
return Scaffold(
backgroundColor: AppColors.bgScaffoldColor,
body: CollapsingListView(
title: LocaleKeys.allergies.tr(),
child: SingleChildScrollView(
child: Consumer<MedicalFileViewModel>(builder: (context, medicalFileVM, child) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 16.h),
ListView.separated(
scrollDirection: Axis.vertical,
itemCount: medicalFileVM.isPatientAllergiesListLoading
? 5
: medicalFileVM.patientAllergiesList.isNotEmpty
? medicalFileVM.patientAllergiesList.length
: 1,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(left: 24.h, right: 24.h),
itemBuilder: (context, index) {
return medicalFileVM.isPatientAllergiesListLoading
? Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.h,
hasShadow: true,
),
child: Padding(
padding: EdgeInsets.all(14.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Utils.buildSvgWithAssets(icon: AppAssets.allergy_info_icon, width: 36.w, height: 36.h, fit: BoxFit.contain).toShimmer2(isShow: true),
SizedBox(width: 16.h),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
"Dr John Smith".toText16(isBold: true).toShimmer2(isShow: true),
SizedBox(height: 8.h),
Wrap(
direction: Axis.horizontal,
spacing: 3.h,
runSpacing: 4.h,
children: [
// AppCustomChipWidget(labelText: "").toShimmer2(isShow: true, width: 16.h),
// AppCustomChipWidget(labelText: "").toShimmer2(isShow: true, width: 16.h),
],
),
],
),
),
],
),
],
),
),
)
: medicalFileVM.patientAllergiesList.isNotEmpty
? AnimationConfiguration.staggeredList(
position: index,
duration: const Duration(milliseconds: 1000),
child: SlideAnimation(
verticalOffset: 100.0,
child: FadeInAnimation(
child: Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.h,
hasShadow: false,
),
child: Padding(
padding: EdgeInsets.all(16.h),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Utils.buildSvgWithAssets(icon: AppAssets.allergy_info_icon, width: 36.w, height: 36.h, fit: BoxFit.contain),
SizedBox(height: 16.h),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(medicalFileVM.patientAllergiesList[index].description).toString().toText16(isBold: true).toShimmer2(isShow: false),
(medicalFileVM.patientAllergiesList[index].remarks).toString().toText12(),
],
),
),
],
),
],
),
),
),
),
),
)
: Utils.getNoDataWidget(context, noDataText: "No allergies data found...".needTranslation);
},
separatorBuilder: (BuildContext cxt, int index) => SizedBox(height: 16.h),
),
SizedBox(height: 60.h),
],
);
}),
),
),
);
}
}

@ -24,6 +24,7 @@ import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/
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/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/presentation/allergies/allergies_list_page.dart';
import 'package:hmg_patient_app_new/presentation/appointments/my_appointments_page.dart';
import 'package:hmg_patient_app_new/presentation/appointments/my_doctors_page.dart';
import 'package:hmg_patient_app_new/presentation/appointments/widgets/ask_doctor_request_type_select.dart';
@ -801,7 +802,14 @@ class _MedicalFilePageState extends State<MedicalFilePage> {
svgIcon: AppAssets.allergy_info_icon,
isLargeText: true,
iconSize: 36.w,
),
).onPress(() {
medicalFileViewModel.getPatientAllergiesList();
Navigator.of(context).push(
CustomPageRoute(
page: AllergiesListPage(),
),
);
}),
MedicalFileCard(
label: "Vaccine Info".needTranslation,
textColor: AppColors.blackColor,

Loading…
Cancel
Save