ereferral fixes

merge-requests/429/head
haroon amjad 4 years ago
parent 28c0450544
commit 85d68b0388

@ -16,9 +16,6 @@ class VaccineService extends BaseService {
body['To'] = "0";
body['From'] = "0";
// body['PatientID'] = 1018977;
// body['TokenID'] = "@dm!n";
hasError = false;
_vaccineList.clear();
await baseAppClient.post(GET_VACCINES,

@ -10,13 +10,12 @@ import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.da
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/dialogs/select_country_ingo_Dialog.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/dialogs/select_relation_type_dialog.dart';
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/E-Referral/e_referral_confirm_sms_dialog.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/balance/new_text_Field.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart';
@ -28,13 +27,10 @@ class NewEReferralStepOnePage extends StatefulWidget {
final CreateEReferralRequestModel createEReferralRequestModel;
final Function changePageViewIndex;
const NewEReferralStepOnePage(
{Key key, this.createEReferralRequestModel, this.changePageViewIndex})
: super(key: key);
const NewEReferralStepOnePage({Key key, this.createEReferralRequestModel, this.changePageViewIndex}) : super(key: key);
@override
_NewEReferralStepOnePageState createState() =>
_NewEReferralStepOnePageState();
_NewEReferralStepOnePageState createState() => _NewEReferralStepOnePageState();
}
class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
@ -49,14 +45,7 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
// todo create a model for Country
// todo use country from the json
dynamic _selectedCountry = {
"name": "Saudi Arabia",
"name_ar": "المملكة العربية السعودية",
"code": "966",
"countryCode": "SA",
"pattern": "5xxxxxxxx",
"maxLength": 9
};
dynamic _selectedCountry = {"name": "Saudi Arabia", "name_ar": "المملكة العربية السعودية", "code": "966", "countryCode": "SA", "pattern": "5xxxxxxxx", "maxLength": 9};
AppSharedPreferences sharedPref = AppSharedPreferences();
AuthenticatedUser authUser;
@ -120,16 +109,14 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
),
Center(
child: Texts(
TranslationBase.of(context)
.referralRequesterInformation,
TranslationBase.of(context).referralRequesterInformation,
),
),
SizedBox(
height: 12,
),
NewTextFields(
hintText: TranslationBase.of(context)
.enterReferralRequesterName,
hintText: TranslationBase.of(context).enterReferralRequesterName,
controller: _nameTextController,
),
SizedBox(
@ -141,15 +128,10 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
padding: EdgeInsets.all(12),
width: double.infinity,
height: 65,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(getCountryName()),
Icon(Icons.arrow_drop_down)
],
children: [Texts(getCountryName()), Icon(Icons.arrow_drop_down)],
),
),
),
@ -158,9 +140,7 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
),
MobileNumberTextFiled(
controller: _mobileTextController,
code: _selectedCountry == null
? "11"
: _selectedCountry["code"],
code: _selectedCountry == null ? "11" : _selectedCountry["code"],
),
SizedBox(
height: 12,
@ -175,21 +155,15 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
height: 12,
),
InkWell(
onTap: () => confirmSelectRelationTypeDialog(
model.relationTypes),
onTap: () => confirmSelectRelationTypeDialog(model.relationTypes),
child: Container(
padding: EdgeInsets.all(12),
width: double.infinity,
height: 65,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Texts(getRelationName()),
Icon(Icons.arrow_drop_down)
],
children: [Texts(getRelationName()), Icon(Icons.arrow_drop_down)],
),
),
),
@ -204,22 +178,19 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
padding: EdgeInsets.all(9),
child: DefaultButton(
TranslationBase.of(context).next,
(_nameTextController.text.isEmpty ||
_selectedRelation == null ||
_mobileTextController.text.isEmpty)
(_nameTextController.text.isEmpty || _selectedRelation == null || _mobileTextController.text.isEmpty)
? null
: () async {
SendActivationCodeForEReferralRequestModel
sendActivationCodeForEReferralRequestModel =
SendActivationCodeForEReferralRequestModel(
zipCode: _selectedCountry['code'],
patientMobileNumber:
int.parse(_mobileTextController.text),
);
await model.sendActivationCodeForEReferral(
sendActivationCodeForEReferralRequestModel);
showSMSDialog(model);
Future.delayed(new Duration(milliseconds: 300)).then((value) async {
GifLoaderDialogUtils.showMyDialog(context);
SendActivationCodeForEReferralRequestModel sendActivationCodeForEReferralRequestModel = SendActivationCodeForEReferralRequestModel(
zipCode: _selectedCountry['code'],
patientMobileNumber: int.parse(_mobileTextController.text),
);
await model.sendActivationCodeForEReferral(sendActivationCodeForEReferralRequestModel);
GifLoaderDialogUtils.hideDialog(context);
showSMSDialog(model);
});
},
disabledColor: Colors.grey,
),
@ -228,30 +199,24 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
void submit(EReferralViewModel model, code) async {
final activationCode = code;
// ToDo call service
CheckActivationCodeForEReferralResponseModel
checkActivationCodeForEReferralRequestModel =
new CheckActivationCodeForEReferralResponseModel(
activationCode: activationCode);
await model.checkActivationCodeForEReferral(
checkActivationCodeForEReferralRequestModel);
if (model.state == ViewState.ErrorLocal) {
// Utils.showErrorToast(model.error);
} else {
Navigator.of(context).pop();
widget.changePageViewIndex(1);
widget.createEReferralRequestModel.requesterName =
_nameTextController.text;
widget.createEReferralRequestModel.requesterContactNo =
_selectedCountry['code'].toString().substring(1) +
_mobileTextController.text;
widget.createEReferralRequestModel.requesterRelationship =
_selectedRelation.iD;
}
Future.delayed(new Duration(milliseconds: 300)).then((value) async {
GifLoaderDialogUtils.showMyDialog(context);
CheckActivationCodeForEReferralResponseModel checkActivationCodeForEReferralRequestModel = new CheckActivationCodeForEReferralResponseModel(activationCode: activationCode);
await model.checkActivationCodeForEReferral(checkActivationCodeForEReferralRequestModel);
if (model.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
} else {
GifLoaderDialogUtils.hideDialog(context);
Navigator.of(context).pop();
widget.changePageViewIndex(1);
widget.createEReferralRequestModel.requesterName = _nameTextController.text;
widget.createEReferralRequestModel.requesterContactNo = _selectedCountry['code'].toString().substring(1) + _mobileTextController.text;
widget.createEReferralRequestModel.requesterRelationship = _selectedRelation.iD;
}
});
}
void confirmSelectRelationTypeDialog(
List<GetAllRelationshipTypeResponseModel> relations) {
void confirmSelectRelationTypeDialog(List<GetAllRelationshipTypeResponseModel> relations) {
showDialog(
context: context,
child: SelectRelationTypeDialog(
@ -302,9 +267,7 @@ class _NewEReferralStepOnePageState extends State<NewEReferralStepOnePage> {
}
class MobileNumberTextFiled extends StatelessWidget {
const MobileNumberTextFiled(
{Key key, this.controller, this.code, this.onChange})
: super(key: key);
const MobileNumberTextFiled({Key key, this.controller, this.code, this.onChange}) : super(key: key);
final TextEditingController controller;
final String code;
@ -314,8 +277,7 @@ class MobileNumberTextFiled extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15), color: Colors.white),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(15), color: Colors.white),
child: Row(textDirection: TextDirection.ltr, children: <Widget>[
Expanded(
flex: 1,
@ -337,8 +299,7 @@ class MobileNumberTextFiled extends StatelessWidget {
controller: controller,
onChanged: onChange,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
border: InputBorder.none, hintText: '5xxxxxxxx'),
decoration: InputDecoration(border: InputBorder.none, hintText: '5xxxxxxxx'),
),
),
)

@ -11,12 +11,12 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
import 'package:diplomaticquarterapp/widgets/bottom_options/BottomSheet.dart';
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
@ -29,13 +29,10 @@ class NewEReferralStepThreePage extends StatefulWidget {
final CreateEReferralRequestModel createEReferralRequestModel;
final Function changePageViewIndex;
const NewEReferralStepThreePage(
{Key key, this.createEReferralRequestModel, this.changePageViewIndex})
: super(key: key);
const NewEReferralStepThreePage({Key key, this.createEReferralRequestModel, this.changePageViewIndex}) : super(key: key);
@override
_NewEReferralStepThreePageState createState() =>
_NewEReferralStepThreePageState();
_NewEReferralStepThreePageState createState() => _NewEReferralStepThreePageState();
}
class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
@ -104,8 +101,7 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
mainAxisAlignment: MainAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 9),
padding: const EdgeInsets.symmetric(horizontal: 9),
child: Texts(
TranslationBase.of(context).medicalReport,
color: Colors.grey,
@ -120,21 +116,14 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
context,
(String image, File file) {
setState(() {
EReferralAttachment
eReferralAttachment =
new EReferralAttachment(
fileName:
'image ${medicalReportImages.length + 1}.png',
base64String: image);
medicalReportImages
.add(eReferralAttachment);
EReferralAttachment eReferralAttachment = new EReferralAttachment(fileName: 'image ${medicalReportImages.length + 1}.png', base64String: image);
medicalReportImages.add(eReferralAttachment);
});
},
);
},
child: Container(
margin: EdgeInsets.only(
left: 10, right: 10, top: 15),
margin: EdgeInsets.only(left: 10, right: 10, top: 15),
height: 50,
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
@ -144,10 +133,8 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
),
child: Center(
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.attach_file),
Texts(
@ -169,30 +156,24 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(
FontAwesomeIcons.paperclip),
Icon(FontAwesomeIcons.paperclip),
SizedBox(
width: 8,
),
Texts(
medicalReportImages[index]
.fileName,
medicalReportImages[index].fileName,
),
],
),
InkWell(
onTap: () {
setState(() {
medicalReportImages.remove(
medicalReportImages[
index]);
medicalReportImages.remove(medicalReportImages[index]);
});
},
child: Icon(
@ -210,27 +191,22 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
),
Container(
padding: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
child: Column(
children: [
Container(
width: double.infinity,
decoration: containerRadius(Colors.white, 12),
margin: EdgeInsets.only(left: 20, right: 20),
padding: EdgeInsets.only(
left: 10, right: 10, top: 12, bottom: 12),
padding: EdgeInsets.only(left: 10, right: 10, top: 12, bottom: 12),
child: Row(
children: [
Flexible(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
TranslationBase.of(context)
.preferredBranch,
TranslationBase.of(context).preferredBranch,
style: TextStyle(
fontSize: 11,
letterSpacing: -0.44,
@ -239,38 +215,24 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
),
Container(
height: 18,
child:
DropdownButtonHideUnderline(
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
key: projectDropdownKey,
hint: Text(TranslationBase.of(
context)
.selectPreferredBranch),
hint: Text(TranslationBase.of(context).selectPreferredBranch),
value: projectDropdownValue,
iconSize: 0,
isExpanded: true,
style: TextStyle(
fontSize: 14,
letterSpacing: -0.56,
color: Colors.black),
items:
projectsList.map((item) {
return new DropdownMenuItem<
String>(
value: item.mainProjectID
.toString() +
"," +
item.name.toString(),
child:
new Text(item.name),
style: TextStyle(fontSize: 14, letterSpacing: -0.56, color: Colors.black),
items: projectsList.map((item) {
return new DropdownMenuItem<String>(
value: item.mainProjectID.toString() + "," + item.name.toString(),
child: new Text(item.name),
);
}).toList(),
onChanged: (newValue) {
setState(() {
projectDropdownValue =
newValue;
print(
projectDropdownValue);
projectDropdownValue = newValue;
print(projectDropdownValue);
});
},
),
@ -289,9 +251,7 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
height: 12,
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white),
child: Column(
children: [
Row(
@ -337,25 +297,16 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
children: [
InkWell(
onTap: () {
ImageOptions.showImageOptions(context,
(String image, File file) {
ImageOptions.showImageOptions(context, (String image, File file) {
setState(() {
EReferralAttachment
eReferralAttachment =
new EReferralAttachment(
fileName:
'image ${medicalReportImages.length + 1}.png',
base64String: image);
EReferralAttachment eReferralAttachment = new EReferralAttachment(fileName: 'image ${medicalReportImages.length + 1}.png', base64String: image);
insuredPatientImages = [
eReferralAttachment
];
insuredPatientImages = [eReferralAttachment];
});
});
},
child: Container(
margin: EdgeInsets.only(
left: 10, right: 10, top: 15),
margin: EdgeInsets.only(left: 10, right: 10, top: 15),
height: 50,
decoration: BoxDecoration(
border: Border.all(color: Colors.grey),
@ -365,10 +316,8 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
),
child: Center(
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(Icons.attach_file),
Texts(
@ -390,15 +339,12 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
margin: EdgeInsets.all(10),
padding: EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
crossAxisAlignment:
CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(FontAwesomeIcons
.paperclip),
Icon(FontAwesomeIcons.paperclip),
SizedBox(
width: 8,
),
@ -410,9 +356,7 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
InkWell(
onTap: () {
setState(() {
insuredPatientImages.remove(
insuredPatientImages[
index]);
insuredPatientImages.remove(insuredPatientImages[index]);
});
},
child: Icon(
@ -444,44 +388,24 @@ class _NewEReferralStepThreePageState extends State<NewEReferralStepThreePage> {
medicalReportImages.length == 0
? null
: () async {
this
.widget
.createEReferralRequestModel
.medicalReportAttachment = medicalReportImages;
this
.widget
.createEReferralRequestModel
.insuranceCardAttachment =
insuredPatientImages.length != 0
? insuredPatientImages[0]
: null;
this
.widget
.createEReferralRequestModel
.isInsuredPatient = isPatientInsured;
// ToDo make the preferred Branch info dynamic
this
.widget
.createEReferralRequestModel
.preferredBranchCode =
num.tryParse(projectDropdownValue.split(",")[0]);
this
.widget
.createEReferralRequestModel
.preferredBranchName =
projectDropdownValue.split(",")[1];
this
.widget
.createEReferralRequestModel
.otherRelationship = "";
await model.createEReferral(
this.widget.createEReferralRequestModel);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
} else {
AppToast.showSuccessToast(
message: "Referral sent successfully");
}
Future.delayed(new Duration(milliseconds: 300)).then((value) async {
GifLoaderDialogUtils.showMyDialog(context);
this.widget.createEReferralRequestModel.medicalReportAttachment = medicalReportImages;
this.widget.createEReferralRequestModel.insuranceCardAttachment = insuredPatientImages.length != 0 ? insuredPatientImages[0] : null;
this.widget.createEReferralRequestModel.isInsuredPatient = isPatientInsured;
// ToDo make the preferred Branch info dynamic
this.widget.createEReferralRequestModel.preferredBranchCode = num.tryParse(projectDropdownValue.split(",")[0]);
this.widget.createEReferralRequestModel.preferredBranchName = projectDropdownValue.split(",")[1];
this.widget.createEReferralRequestModel.otherRelationship = "";
await model.createEReferral(this.widget.createEReferralRequestModel);
if (model.state == ViewState.ErrorLocal) {
GifLoaderDialogUtils.hideDialog(context);
Utils.showErrorToast(model.error);
} else {
GifLoaderDialogUtils.hideDialog(context);
AppToast.showSuccessToast(message: "Referral sent successfully");
}
});
},
disabledColor: Colors.grey,
color: Color(0xff359846),

@ -57,25 +57,29 @@ class _SearchForReferralsPageState extends State<SearchForReferralsPage> {
return BaseView<EReferralViewModel>(
onModelReady: (model) async {
if (projectViewModel.isLogin) {
SearchEReferralRequestModel searchEReferralRequestModel =
new SearchEReferralRequestModel(
patientMobileNumber: (projectViewModel.user.outSA == 0
? "966"
: "971") +
projectViewModel.user.mobileNumber
.substring(1, projectViewModel.user.mobileNumber.length),
);
if (selectedCriteria.value == 1) {
searchEReferralRequestModel.identificationNo =
_searchTextController.text;
searchEReferralRequestModel.referralNumber = 0;
} else {
searchEReferralRequestModel.referralNumber =
int.parse(_searchTextController.text);
searchEReferralRequestModel.identificationNo =
projectViewModel.user.patientIdentificationNo;
}
await model.getEReferrals(searchEReferralRequestModel);
Future.delayed(new Duration(milliseconds: 300)).then((value) async {
GifLoaderDialogUtils.showMyDialog(context);
SearchEReferralRequestModel searchEReferralRequestModel =
new SearchEReferralRequestModel(
patientMobileNumber: (projectViewModel.user.outSA == 0
? "966"
: "971") +
projectViewModel.user.mobileNumber
.substring(1, projectViewModel.user.mobileNumber.length),
);
if (selectedCriteria.value == 1) {
searchEReferralRequestModel.identificationNo =
_searchTextController.text;
searchEReferralRequestModel.referralNumber = 0;
} else {
searchEReferralRequestModel.referralNumber =
int.parse(_searchTextController.text);
searchEReferralRequestModel.identificationNo =
projectViewModel.user.patientIdentificationNo;
}
await model.getEReferrals(searchEReferralRequestModel);
GifLoaderDialogUtils.hideDialog(context);
});
}
},
builder: (_, model, widget) => AppScaffold(

Loading…
Cancel
Save