|
|
|
|
@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/blooddonation/blood_groub_details.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/blooddonation/get_all_cities.dart';
|
|
|
|
|
|
|
|
|
|
//import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/my_balance/AdvanceModel.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/core/model/my_balance/patient_info.dart';
|
|
|
|
|
@ -13,6 +14,7 @@ import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStat
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/Blood/user_agreement_page.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/pages/medical/balance/dialogs/SelectCiteisDialog.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';
|
|
|
|
|
@ -25,11 +27,8 @@ import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:giffy_dialog/giffy_dialog.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import 'dialogs/SelectBeneficiaryDialog.dart';
|
|
|
|
|
import 'dialogs/SelectBloodDialog.dart';
|
|
|
|
|
import 'dialogs/SelectGenderDialog.dart';
|
|
|
|
|
import 'dialogs/SelectPatientFamilyDialog.dart';
|
|
|
|
|
import 'dialogs/SelectPatientInfoDialog.dart';
|
|
|
|
|
|
|
|
|
|
enum BeneficiaryType { MyAccount, MyFamilyFiles, OtherAccount, NON }
|
|
|
|
|
enum Gender { Male, Female, NON }
|
|
|
|
|
@ -79,7 +78,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,
|
|
|
|
|
@ -95,9 +97,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(
|
|
|
|
|
TranslationBase.of(context).bloodDEnterDesc
|
|
|
|
|
),
|
|
|
|
|
Texts(TranslationBase.of(context).bloodDEnterDesc),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
|
@ -111,7 +111,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [Texts(getHospitalName(projectProvider, context), color: Colors.black), Icon(Icons.arrow_drop_down)],
|
|
|
|
|
children: [Texts(getHospitalName(projectProvider, context, model), color: Colors.black), Icon(Icons.arrow_drop_down)],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -119,7 +119,6 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
//======Gender========
|
|
|
|
|
onTap: () => confirmSelectGenderDialog(),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
@ -128,10 +127,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [
|
|
|
|
|
Texts(getGender(context), color: Colors.black),
|
|
|
|
|
Icon(Icons.arrow_drop_down)
|
|
|
|
|
],
|
|
|
|
|
children: [Texts(getGender(context), color: Colors.black), Icon(Icons.arrow_drop_down)],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -139,7 +135,6 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
|
InkWell(
|
|
|
|
|
//======Gender========
|
|
|
|
|
onTap: () => confirmSelectBloodDialog(),
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
|
@ -148,7 +143,7 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: [Texts(getBlood(), color: Colors.black), Icon(Icons.arrow_drop_down)],
|
|
|
|
|
children: [Texts(getBlood(model), color: Colors.black), Icon(Icons.arrow_drop_down)],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
@ -241,45 +236,31 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
padding: EdgeInsets.all(20),
|
|
|
|
|
child: 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 = gender == Gender.Male ? 1 : 2;
|
|
|
|
|
await model.updateBloodGroup(bloodDetails);
|
|
|
|
|
if (model.state == ViewState.Idle) {
|
|
|
|
|
AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: model.error);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
child: 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 = gender == Gender.Male ? 1 : 2;
|
|
|
|
|
await model.updateBloodGroup(bloodDetails);
|
|
|
|
|
if (model.state == ViewState.Idle) {
|
|
|
|
|
AppToast.showSuccessToast(message: model.updatedRegisterBloodMessage);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: model.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
: null,
|
|
|
|
|
disabledColor: CustomColors.grey2,
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 confirmSelectBloodDialog() {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
@ -289,48 +270,22 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
setState(() {
|
|
|
|
|
if (value == Blood.Oplus) {
|
|
|
|
|
bloodDetails.bloodGroup = "O+";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.Ominus) {
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
bloodDetails.bloodGroup = "O-";
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.ABplus) {
|
|
|
|
|
bloodDetails.bloodGroup = "AB+";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.ABminus) {
|
|
|
|
|
bloodDetails.bloodGroup = "AB-";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.Aplus) {
|
|
|
|
|
bloodDetails.bloodGroup = "A+";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.Aminus) {
|
|
|
|
|
bloodDetails.bloodGroup = "A-";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.Bplus) {
|
|
|
|
|
bloodDetails.bloodGroup = "B+";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else if (value == Blood.Bminus) {
|
|
|
|
|
bloodDetails.bloodGroup = "B-";
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else
|
|
|
|
|
_fileTextController.text = "";
|
|
|
|
|
|
|
|
|
|
// beneficiaryType = value;
|
|
|
|
|
blood = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
@ -346,17 +301,10 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
onValueSelected: (value) {
|
|
|
|
|
setState(() {
|
|
|
|
|
if (value == Gender.Male) {
|
|
|
|
|
// _fileTextController.text = model.user.patientID.toString();
|
|
|
|
|
bloodDetails.patientType = 1;
|
|
|
|
|
// advanceModel.depositorName =
|
|
|
|
|
// model.user.firstName + " " + model.user.lastName;
|
|
|
|
|
} else
|
|
|
|
|
// _fileTextController.text = "";
|
|
|
|
|
{
|
|
|
|
|
} else {
|
|
|
|
|
bloodDetails.gender = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// beneficiaryType = value;
|
|
|
|
|
gender = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
@ -364,7 +312,6 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//void confirmSelectHospitalDialog(List<HospitalsModel> hospitals) {
|
|
|
|
|
void confirmSelectHospitalDialog(List<CitiesModel> hospitals) {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
@ -380,55 +327,6 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 getGender(BuildContext context) {
|
|
|
|
|
switch (gender) {
|
|
|
|
|
case Gender.Male:
|
|
|
|
|
@ -436,62 +334,60 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
case Gender.Female:
|
|
|
|
|
return TranslationBase.of(context).female;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Gender.NON:
|
|
|
|
|
return TranslationBase.of(context).selectGender;
|
|
|
|
|
}
|
|
|
|
|
return TranslationBase.of(context).selectGender;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getBlood() {
|
|
|
|
|
switch (blood) {
|
|
|
|
|
case Blood.Oplus:
|
|
|
|
|
return "O+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Ominus:
|
|
|
|
|
return "O-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.ABplus:
|
|
|
|
|
return "AB+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.ABminus:
|
|
|
|
|
return "AB-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Aplus:
|
|
|
|
|
return "A+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Aminus:
|
|
|
|
|
return "A-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Bplus:
|
|
|
|
|
return "B-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Bminus:
|
|
|
|
|
return "B-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Bplus:
|
|
|
|
|
return "B+";
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Blood.NON:
|
|
|
|
|
return "Select Blood Type"; //TranslationBase.of(context).selectBeneficiary;
|
|
|
|
|
String getBlood(MyBalanceViewModel model) {
|
|
|
|
|
if (model.bloodModelList.length > 0) {
|
|
|
|
|
return model.bloodModelList[0].bloodGroup;
|
|
|
|
|
} else {
|
|
|
|
|
switch (blood) {
|
|
|
|
|
case Blood.Oplus:
|
|
|
|
|
return "O+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Ominus:
|
|
|
|
|
return "O-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.ABplus:
|
|
|
|
|
return "AB+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.ABminus:
|
|
|
|
|
return "AB-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Aplus:
|
|
|
|
|
return "A+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Aminus:
|
|
|
|
|
return "A-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Bplus:
|
|
|
|
|
return "B-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Bminus:
|
|
|
|
|
return "B-";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.Bplus:
|
|
|
|
|
return "B+";
|
|
|
|
|
break;
|
|
|
|
|
case Blood.NON:
|
|
|
|
|
return "Select Blood Type";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "Select Blood Type"; //TranslationBase.of(context).selectBeneficiary;
|
|
|
|
|
return "Select Blood Type";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getHospitalName(ProjectViewModel projectProvider, BuildContext context) {
|
|
|
|
|
if (_selectedHospital != null)
|
|
|
|
|
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;
|
|
|
|
|
String getHospitalName(ProjectViewModel projectProvider, BuildContext context, MyBalanceViewModel model) {
|
|
|
|
|
if (model.bloodModelList.length > 0) {
|
|
|
|
|
return model.bloodModelList[0].city;
|
|
|
|
|
} else {
|
|
|
|
|
if (_selectedHospital != null)
|
|
|
|
|
return projectProvider.isArabic ? _selectedHospital.descriptionN : _selectedHospital.description;
|
|
|
|
|
else
|
|
|
|
|
return TranslationBase.of(context).selectCity;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getAuthUser() async {
|
|
|
|
|
@ -502,14 +398,4 @@ class _BloodDonationPageState extends State<BloodDonationPage> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String getFamilyMembersName() {
|
|
|
|
|
if (selectedPatientFamily != null)
|
|
|
|
|
return selectedPatientFamily.patientName;
|
|
|
|
|
else
|
|
|
|
|
return TranslationBase.of(context).selectFamilyPatientName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//================
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|