Blood donation fixes

merge-update-with-lab-changes
haroon amjad 4 years ago
parent 924f685342
commit df7d8a8603

@ -32,7 +32,7 @@ class MyBalanceViewModel extends BaseViewModel {
_bloodDonationService.CitiesModelList;
BloodDetailsService _bloodDetailsService = locator<BloodDetailsService>();
List<List_BloodGroupDetailsModel> get BloodDetailsModelList =>
List<List_BloodGroupDetailsModel> get bloodDetailsModelList =>
_bloodDetailsService
.BloodModelList; //_bloodDonationService.CitiesModelList;

@ -1,4 +1,3 @@
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/model/blooddonation/blood_groub_details.dart';
@ -14,6 +13,7 @@ import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStat
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/h20_setting.dart';
import 'package:diplomaticquarterapp/pages/Blood/user_agreement_page.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
@ -26,10 +26,6 @@ import 'package:flutter/material.dart';
import 'package:giffy_dialog/giffy_dialog.dart';
import 'package:provider/provider.dart';
import 'dialogs/SelectBeneficiaryDialog.dart';
import 'dialogs/SelectPatientFamilyDialog.dart';
import 'dialogs/SelectPatientInfoDialog.dart';
enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON }
enum Gender { Male, Female, NON }
enum Blood { Oplus, Ominus, Aplus, Aminus, Bplus, Bminus, ABplus, ABminus, NON }
@ -73,7 +69,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/blood/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/images-info-home/blood/ar/0.png'),
);
WidgetsBinding.instance.addPostFrameCallback((_) {
if (projectProvider.isLogin) getAuthUser();
if (projectProvider.isLogin) authUser = projectProvider.user;
});
super.initState();
}
@ -83,7 +79,10 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
projectProvider = Provider.of(context);
return BaseView<MyBalanceViewModel>(
onModelReady: (model) => model.getCities(), //model.getHospitals(),
onModelReady: (model) {
model.getCities();
model.getBlood();
},
builder: (_, model, w) => AppScaffold(
isShowAppBar: true,
showNewAppBar: true,
@ -109,11 +108,11 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
SizedBox(height: 12),
CommonDropDownView(
TranslationBase.of(context).city,
model.CitiesModelList.isNotEmpty
? projectProvider.isArabic
model.bloodModelList.isNotEmpty
? model.bloodModelList[0].city
: projectProvider.isArabic
? model.CitiesModelList[_selectedHospitalIndex].descriptionN
: model.CitiesModelList[_selectedHospitalIndex].description
: "", () {
: model.CitiesModelList[_selectedHospitalIndex].description, () {
List<RadioSelectionDialogModel> list = [
for (int i = 0; i < model.CitiesModelList.length; i++)
RadioSelectionDialogModel(projectProvider.isArabic ? model.CitiesModelList[i].descriptionN : model.CitiesModelList[i].description, i),
@ -152,7 +151,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
);
}).withBorderedContainer,
SizedBox(height: 12),
CommonDropDownView(TranslationBase.of(context).bloodType, getBlood(_selectedBloodTypeIndex), () {
CommonDropDownView(TranslationBase.of(context).bloodType, model.bloodModelList.isNotEmpty ? model.bloodModelList[0].bloodGroup : getBlood(_selectedBloodTypeIndex), () {
List<RadioSelectionDialogModel> list = [
RadioSelectionDialogModel("O+", 0),
RadioSelectionDialogModel("O-", 1),
@ -253,97 +252,34 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
),
),
),
DefaultButton(TranslationBase.of(context).save, () async {
if (_selectedHospital == null) {
AppToast.showErrorToast(message: TranslationBase.of(context).selectCity);
return;
}
bloodDetails.city = projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description;
bloodDetails.cityCode = _selectedHospital.iD.toString();
bloodDetails.gender = _selectedGenderIndex;
bloodDetails.bloodGroup = getBlood(_selectedBloodTypeIndex);
await model.updateBloodGroup(bloodDetails);
if (model.state == ViewState.Idle) {
AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage);
} else {
AppToast.showErrorToast(message: model.error);
}
}).insideContainer
DefaultButton(
TranslationBase.of(context).save,
checkedValue
? () async {
if (_selectedHospital == null) {
AppToast.showErrorToast(message: TranslationBase.of(context).selectCity);
return;
}
bloodDetails.city = projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description;
bloodDetails.cityCode = _selectedHospital.iD.toString();
bloodDetails.gender = _selectedGenderIndex;
bloodDetails.bloodGroup = getBlood(_selectedBloodTypeIndex);
await model.updateBloodGroup(bloodDetails);
if (model.state == ViewState.Idle) {
AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage);
} else {
AppToast.showErrorToast(message: model.error);
}
}
: null,
disabledColor: CustomColors.grey2,
).insideContainer
],
),
),
);
}
void confirmSelectBeneficiaryDialog(MyBalanceViewModel model) {
showDialog(
context: context,
child: SelectBeneficiaryDialog(
beneficiaryType: beneficiaryType,
onValueSelected: (value) {
setState(() {
if (value == BeneficiaryType.MyAccount) {
_fileTextController.text = model.user.patientID.toString();
advanceModel.depositorName = model.user.firstName + " " + model.user.lastName;
} else
_fileTextController.text = "";
beneficiaryType = value;
});
},
),
);
}
void confirmSelectPatientDialog(List<PatientInfo> patientInfoList) {
showDialog(
context: context,
child: SelectPatientInfoDialog(
patientInfoList: patientInfoList,
selectedPatientInfo: _selectedPatientInfo,
onValueSelected: (value) {
setState(() {
advanceModel.depositorName = value.fullName;
_selectedPatientInfo = value;
});
},
),
);
}
void confirmSelectFamilyDialog(List<GetAllSharedRecordsByStatusList> getAllSharedRecordsByStatusList) {
showDialog(
context: context,
child: SelectPatientFamilyDialog(
getAllSharedRecordsByStatusList: getAllSharedRecordsByStatusList,
selectedPatientFamily: selectedPatientFamily,
onValueSelected: (value) {
setState(() {
selectedPatientFamily = value;
_fileTextController.text = selectedPatientFamily.patientID.toString();
advanceModel.depositorName = value.patientName;
});
},
),
);
}
String getBeneficiaryType() {
switch (beneficiaryType) {
case BeneficiaryType.MyAccount:
return TranslationBase.of(context).myAccount;
case BeneficiaryType.MyFamilyFiles:
return TranslationBase.of(context).myFamilyFiles;
break;
case BeneficiaryType.OtherAccount:
return TranslationBase.of(context).otherAccount;
break;
case BeneficiaryType.NON:
return TranslationBase.of(context).selectBeneficiary;
}
return TranslationBase.of(context).selectBeneficiary;
}
String getBlood(int index) {
switch (index) {
case 0:
@ -384,32 +320,5 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
return projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description;
else
return TranslationBase.of(context).selectCity;
// return List_BloodGroupDetailsModel.fromJson(0).city.toString();//"Select City";//TranslationBase.of(context).selectHospital;
}
String getPatientName() {
if (_selectedPatientInfo != null)
return _selectedPatientInfo.fullName;
else
return TranslationBase.of(context).selectPatientName;
}
getAuthUser() async {
if (await this.sharedPref.getObject(USER_PROFILE) != null) {
var data = AuthenticatedUser.fromJson(await this.sharedPref.getObject(USER_PROFILE));
setState(() {
authUser = data;
});
}
}
String getFamilyMembersName() {
if (selectedPatientFamily != null)
return selectedPatientFamily.patientName;
else
return TranslationBase.of(context).selectFamilyPatientName;
}
//================
}

Loading…
Cancel
Save