add my vaccines item screen

find_us
Mohammad Aljammal 5 years ago
parent 9159928e27
commit 33bd972984

@ -179,6 +179,9 @@ const GET_PAtIENTS_INSURANCE_APPROVALS =
"Services/Patients.svc/REST/GetApprovalStatus";
const SEARCH_BOT = 'HabibiChatBotApi/BotInterface/GetVoiceCommandResponse';
const GET_VACCINATIONS_ITEMS = "/Services/ERP.svc/REST/GET_VACCINATIONS_ITEMS";
const GET_VACCINATION_ONHAND = "/Services/ERP.svc/REST/GET_VACCINATION_ONHAND";
class AppGlobal {
static var context;

@ -227,6 +227,7 @@ const Map<String, Map<String, String>> localizedValues = {
'ar': 'مسح فوق رمز الاستجابة السريعة للتحقق في الجهاز في المستشفى'
},
"sendEmail": {"en": "Send Email", "ar": "ارسال نسخة"},
"EmailSentSuccessfully": {"en": "Email Sent Successfully", "ar": "تم إرسال البريد الإلكتروني بنجاح"},
"close": {"en": "Close", "ar": "مغلق"},
"booked": {"en": "Booked", "ar": "محجوز"},
"confirmed": {"en": "Confirmed", "ar": "مؤكد"},
@ -459,4 +460,6 @@ const Map<String, Map<String, String>> localizedValues = {
"Save":{"en":"Save","ar":"حفظ "},
"UserAgreement":{"en":"User Agreement","ar":"اتفاقية الخصوصية "},
"UpdateSuccessfully":{"en":"Update Successfully","ar":"تم التحديث بنجاح"},
"CHECK_VACCINE_AVAILABILITY":{"en":"CHECK VACCINE AVAILABILITY","ar":"تحقق من توافر اللقاح"},
"MyVaccinesAvailability":{"en":"MyVaccinesAvailability","ar":"توفر لقاحي"},
};

@ -0,0 +1,18 @@
class VaccinationItem {
String dESCRIPTION;
String iTEMCODE;
VaccinationItem({this.dESCRIPTION, this.iTEMCODE});
VaccinationItem.fromJson(Map<String, dynamic> json) {
dESCRIPTION = json['DESCRIPTION'];
iTEMCODE = json['ITEM_CODE'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['DESCRIPTION'] = this.dESCRIPTION;
data['ITEM_CODE'] = this.iTEMCODE;
return data;
}
}

@ -0,0 +1,44 @@
class VaccinationOnHand {
int distanceInKilometers;
int iTEMONHAND;
bool isThereItems;
String oRGANIZATIONCODE;
String oRGANIZATIONNAME;
String projectAlias;
int projectID;
String projectName;
VaccinationOnHand(
{this.distanceInKilometers,
this.iTEMONHAND,
this.isThereItems,
this.oRGANIZATIONCODE,
this.oRGANIZATIONNAME,
this.projectAlias,
this.projectID,
this.projectName});
VaccinationOnHand.fromJson(Map<String, dynamic> json) {
distanceInKilometers = json['DistanceInKilometers'];
iTEMONHAND = json['ITEM_ONHAND'];
isThereItems = json['IsThereItems'];
oRGANIZATIONCODE = json['ORGANIZATION_CODE'];
oRGANIZATIONNAME = json['ORGANIZATION_NAME'];
projectAlias = json['ProjectAlias'];
projectID = json['ProjectID'];
projectName = json['ProjectName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['DistanceInKilometers'] = this.distanceInKilometers;
data['ITEM_ONHAND'] = this.iTEMONHAND;
data['IsThereItems'] = this.isThereItems;
data['ORGANIZATION_CODE'] = this.oRGANIZATIONCODE;
data['ORGANIZATION_NAME'] = this.oRGANIZATIONNAME;
data['ProjectAlias'] = this.projectAlias;
data['ProjectID'] = this.projectID;
data['ProjectName'] = this.projectName;
return data;
}
}

@ -1,9 +1,13 @@
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_item.dart';
import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_on_hand.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/core/model/vaccine/my_vaccine.dart';
class VaccineService extends BaseService {
List<VaccineModel> _vaccineList = List();
List<VaccinationItem> vaccinationItemList = List();
List<VaccinationOnHand> vaccinationOnHandList = List();
List<VaccineModel> get vaccineList => _vaccineList;
@ -25,24 +29,47 @@ class VaccineService extends BaseService {
}
Future sendEmail() async {
Map<String, dynamic> body = Map();
body['ListVaccines'] = vaccineList.map((v) => v.toJson()).toList();
body['ListVaccines'] = user.emailAddress;
body['To'] = user.emailAddress;
body['DateofBirth'] = user.dateofBirth;
body['PatientIditificationNum'] = user.patientIdentificationNo;
body['PatientMobileNumber'] = user.mobileNumber;
body['PatientName'] = user.firstName + " "+ user.lastName;
body['PatientName'] = user.firstName + " " + user.lastName;
hasError = false;
await baseAppClient.post(GET_VACCINES,
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.post(GET_VACCINES_EMAIL,
onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
Future getMyVaccinationItem() async {
await baseAppClient.post(GET_VACCINATIONS_ITEMS,
onSuccess: (dynamic response, int statusCode) {
response['GetVaccinationsList'].forEach((item) {
vaccinationItemList.add(VaccinationItem.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
Future getMyVaccinationOnHand({String pItemCode}) async {
Map<String, dynamic> body = Map();
body['P_ITEM_CODE'] = pItemCode;
await baseAppClient.post(GET_VACCINATION_ONHAND,
onSuccess: (dynamic response, int statusCode) {
response['GetVaccinationOnHandList'].forEach((item) {
vaccinationOnHandList.add(VaccinationOnHand.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}

@ -1,3 +1,4 @@
import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_item.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'base_view_model.dart';
@ -12,10 +13,11 @@ class VaccineViewModel extends BaseViewModel {
VaccineService _vaccineService = locator<VaccineService>();
List<VaccineModel> get vaccineList => _vaccineService.vaccineList;
List<VaccinationItem> get vaccinationItemList => _vaccineService.vaccinationItemList;
Future getVaccine() async {
hasError = false;
//_insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
await _vaccineService.getMyVaccine();
if (_vaccineService.hasError) {
@ -25,6 +27,28 @@ class VaccineViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getMyVaccinationItem() async {
hasError = false;
setState(ViewState.Busy);
await _vaccineService.getMyVaccinationItem();
if (_vaccineService.hasError) {
error = _vaccineService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future getMyVaccinationOnHand({String pItemCode}) async {
hasError = false;
setState(ViewState.Busy);
await _vaccineService.getMyVaccinationOnHand(pItemCode: pItemCode);
if (_vaccineService.hasError) {
error = _vaccineService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future sendEmail({String message}) async {
hasError = false;
setState(ViewState.BusyLocal);

@ -0,0 +1,78 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:flutter/cupertino.dart';
import 'package:provider/provider.dart';
import '../base/base_view.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/core/viewModels/vaccine_view_model.dart';
import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart';
import 'package:popup_box/popup_box.dart';
class MyVaccinesItemPage extends StatefulWidget {
@override
_MyVaccinesItemPageState createState() => _MyVaccinesItemPageState();
}
class _MyVaccinesItemPageState extends State<MyVaccinesItemPage> {
@override
Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<VaccineViewModel>(
onModelReady: (model) => model.getMyVaccinationItem(),
builder: (BuildContext context, VaccineViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).myVaccinesAvailability,
baseViewModel: model,
body: Container(
margin: EdgeInsets.only(
left: SizeConfig.screenWidth * 0.004,
right: SizeConfig.screenWidth * 0.004,
top: SizeConfig.screenWidth * 0.04,
),
child: ListView.builder(
itemCount: model.vaccinationItemList.length,
itemBuilder: (context, index) => InkWell(
onTap: () async {
await model.getMyVaccinationOnHand(
pItemCode: model.vaccinationItemList[index].iTEMCODE);
if (model.hasError) {
AppToast.showErrorToast(message: model.error);
} else {
//TODO show dialog
}
},
child: Container(
margin: EdgeInsets.all(5),
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(7),
color: Colors.white,
),
child: Row(
children: [
Expanded(
child: Texts(
model.vaccinationItemList[index].dESCRIPTION)),
Icon(projectViewModel.isArabic
? Icons.arrow_forward_ios
: Icons.arrow_back_ios)
],
),
),
),
),
),
),
);
}
}

@ -1,5 +1,8 @@
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:diplomaticquarterapp/config/size_config.dart';
import 'package:flutter/cupertino.dart';
@ -9,6 +12,8 @@ import 'package:diplomaticquarterapp/core/viewModels/vaccine_view_model.dart';
import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart';
import 'package:popup_box/popup_box.dart';
import 'my_vaccines_item_screen.dart';
class MyVaccines extends StatefulWidget {
@override
_MyVaccinesState createState() => _MyVaccinesState();
@ -21,193 +26,174 @@ class _MyVaccinesState extends State<MyVaccines> {
onModelReady: (model) => model.getVaccine(),
builder: (BuildContext context, VaccineViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: true,
appBarTitle: 'My Vaccines',
baseViewModel: model,
body: Container(
margin: EdgeInsets.only(
left: SizeConfig.screenWidth * 0.004,
right: SizeConfig.screenWidth * 0.004,
top: SizeConfig.screenWidth * 0.04,
),
child: Column(
children: <Widget>[
RoundedContainer(
backgroundColor: Colors.white,
child: ExpansionTile(
title: Container(
height: 65.0,
child: Text('2018'),
),
children: <Widget>[
Container(
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: model.vaccineList == null
? 0
: model.vaccineList.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: <Widget>[
RoundedContainer(
child: Column(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).myVaccines,
baseViewModel: model,
body: Container(
margin: EdgeInsets.only(
left: SizeConfig.screenWidth * 0.004,
right: SizeConfig.screenWidth * 0.004,
top: SizeConfig.screenWidth * 0.04,
),
child: Column(
children: <Widget>[
RoundedContainer(
backgroundColor: Colors.white,
child: ExpansionTile(
title: Container(
height: 65.0,
child: Text('2018'),
),
children: <Widget>[
Container(
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: model.vaccineList == null
? 0
: model.vaccineList.length,
itemBuilder: (BuildContext context, int index) {
return Column(
children: <Widget>[
RoundedContainer(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 20.0),
child: Image.network(
model.vaccineList[index]
.doctorImageURL,
height: SizeConfig
Expanded(
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 20.0),
child: Image.network(
model.vaccineList[index]
.doctorImageURL,
height: SizeConfig
.imageSizeMultiplier *
23,
width: SizeConfig
23,
width: SizeConfig
.imageSizeMultiplier *
20,
fit: BoxFit.fill,
),
),
],
20,
fit: BoxFit.fill,
),
),
flex: 2,
),
Expanded(
child: Container(
child: Column(
crossAxisAlignment:
],
),
flex: 2,
),
Expanded(
child: Container(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Text(
model.vaccineList[index]
children: <Widget>[
Text(
model.vaccineList[index]
.doctorTitle +
model.vaccineList[index]
.doctorName,
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 16.6,
),
),
SpaceBetweenTexts(space: 7.0),
Text(
model.vaccineList[index]
.projectName,
style: TextStyle(
fontSize: 17.0,
letterSpacing: 0.5,
),
),
SpaceBetweenTexts(space: 7.0),
Text(
model.vaccineList[index]
.vaccineName,
style: TextStyle(
fontSize: 17.0,
),
),
SpaceBetweenTexts(space: 7.0),
Text(
'Date Taken ' +
convertDateFormat(model
.vaccineList[index]
.invoiceDate),
style:
TextStyle(fontSize: 17.0),
),
],
.doctorName,
style: TextStyle(
fontWeight:
FontWeight.w900,
fontSize: 16.6,
),
),
),
flex: 5,
SizedBox(height: 7.0),
Text(
model.vaccineList[index]
.projectName,
style: TextStyle(
fontSize: 17.0,
letterSpacing: 0.5,
),
),
SizedBox(height: 7.0),
Text(
model.vaccineList[index]
.vaccineName,
style: TextStyle(
fontSize: 17.0,
),
),
SizedBox(height: 7.0),
Text(
'Date Taken ' +
convertDateFormat(model
.vaccineList[index]
.invoiceDate),
style: TextStyle(
fontSize: 17.0),
),
],
),
],
),
flex: 5,
),
],
),
),
],
);
}),
)
],
),
),
// SpaceBetweenTexts(space: 165.0),
],
),
),
bottomSheet: Container(
color: Theme.of(context).scaffoldBackgroundColor,
padding: EdgeInsets.all(12),
height: MediaQuery.of(context).size.height *0.25,
width: double.infinity,
child: Column(
children: [
Divider(height: 2,thickness: 1,),
SizedBox(height: 6,),
Container(
width: double.infinity,
// height: 80.0,
child: Button(
label: 'CHECK VACCINE AVAILABILITY',
backgroundColor: Color(0xff9EA3A4),
),
),
Container(
width: double.infinity,
// height: 80.0,
child: SecondaryButton(
label: 'SEND EMAIL',
color: Color(0xffF62426),
textColor: Colors.white,
disabled: model.vaccineList.length==0,
onTap: () async {
await PopupBox.showPopupBox(
context: context,
button: MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(3),
),
color: Colors.white,
child: Text(
'CANCEL',
style: TextStyle(fontSize: 16.5),
),
onPressed: () {
Navigator.of(context).pop();
},
),
willDisplayWidget: Column(
children: <Widget>[
Text(
'Conform \nSend a copy of this report to the email' +
model.vaccineList[0].doctorName,
style: TextStyle(
fontSize: 20,
color: Colors.black26,
fontWeight: FontWeight.w900),
),
SizedBox(
height: 30.0,
],
),
),
],
));
},
),
),
],
);
}),
)
],
),
),
// SpaceBetweenTexts(space: 165.0),
],
),
),
bottomSheet: Container(
color: Theme.of(context).scaffoldBackgroundColor,
padding: EdgeInsets.all(12),
height: MediaQuery.of(context).size.height * 0.25,
width: double.infinity,
child: Column(
children: [
Divider(
height: 2,
thickness: 1,
),
SizedBox(
height: 6,
),
Container(
width: double.infinity,
// height: 80.0,
child: Button(
label: TranslationBase.of(context).checkVaccineAvailability,
backgroundColor: Color(0xff9EA3A4),
onTap: () =>
Navigator.push(context, FadePage(page: MyVaccinesItemPage())),
),
),
Container(
width: double.infinity,
// height: 80.0,
child: SecondaryButton(
label: TranslationBase.of(context).sendEmail,
color: Color(0xffF62426),
textColor: Colors.white,
disabled: model.vaccineList.length == 0,
loading: model.state == ViewState.BusyLocal,
onTap: () async {
model.sendEmail(
message:
TranslationBase.of(context).emailSentSuccessfully);
},
),
),
),
],
),
),
),
);
}
convertDateFormat(String Date) {
const start = "/Date(";
const end = "+0300)";
@ -225,18 +211,4 @@ class _MyVaccinesState extends State<MyVaccines> {
return newDate.toString();
}
}
class SpaceBetweenTexts extends StatelessWidget {
final double space;
SpaceBetweenTexts({this.space});
@override
Widget build(BuildContext context) {
return SizedBox(
height: space,
);
}
}

@ -521,6 +521,9 @@ class TranslationBase {
String get save => localizedValues['Save'][locale.languageCode];
String get userAgreement => localizedValues['UserAgreement'][locale.languageCode];
String get updateSuccessfully => localizedValues['UpdateSuccessfully'][locale.languageCode];
String get emailSentSuccessfully => localizedValues['EmailSentSuccessfully'][locale.languageCode];
String get checkVaccineAvailability => localizedValues['CHECK_VACCINE_AVAILABILITY'][locale.languageCode];
String get myVaccinesAvailability => localizedValues['MyVaccinesAvailability'][locale.languageCode];
}
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

Loading…
Cancel
Save