reschedule leave

merge-requests/214/head
Sultan Khan 5 years ago
parent 70d11bfe9e
commit e23bb7ce94

@ -111,6 +111,7 @@ const EXTEND_SICK_LEAVE = 'Services/DoctorApplication.svc/REST/ExtendSickLeave';
const GET_OFFTIME = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; const GET_OFFTIME = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList';
const GET_COVERING_DOCTORS = const GET_COVERING_DOCTORS =
'Services/DoctorApplication.svc/REST/GetCoveringDoctor'; 'Services/DoctorApplication.svc/REST/GetCoveringDoctor';
const ADD_RESCHDEULE = 'Services/DoctorApplication.svc/REST/PostRequisition';
const GET_RESCHEDULE_LEAVE = const GET_RESCHEDULE_LEAVE =
'Services/DoctorApplication.svc/REST/GetRequisition'; 'Services/DoctorApplication.svc/REST/GetRequisition';
const GET_PRESCRIPTION_LIST = const GET_PRESCRIPTION_LIST =

@ -170,4 +170,20 @@ class SickLeaveService extends BaseService {
body: {"ClinicID": 1}, body: {"ClinicID": 1},
); );
} }
addReschedule(request) async {
hasError = false;
await baseAppClient.post(
ADD_RESCHDEULE,
onSuccess: (dynamic response, int statusCode) {
Future.value(response);
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: request,
);
}
} }

@ -95,4 +95,14 @@ class SickLeaveViewModel extends BaseViewModel {
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future addReschedule(request) async {
setState(ViewState.Busy);
await _sickLeaveService.addReschedule(request);
if (_sickLeaveService.hasError) {
error = _sickLeaveService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
} }

@ -1,3 +1,4 @@
import 'package:date_time_picker/date_time_picker.dart';
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/config/size_config.dart';
@ -34,16 +35,24 @@ class RescheduleLeaveScreen extends StatefulWidget {
class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> { class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
TextEditingController _toDateController = new TextEditingController(); TextEditingController _toDateController = new TextEditingController();
TextEditingController _toDateController2 = new TextEditingController();
ProjectViewModel projectsProvider; ProjectViewModel projectsProvider;
String _selectedClinic; String _selectedClinic;
Map profile = {}; Map profile = {};
AddSickLeaveRequest addSickLeave = AddSickLeaveRequest(); var offTime = '2';
var date;
var doctorID;
var reason;
var fromDate;
var toDate;
TextEditingController _controller4;
// AddSickLeaveRequest addSickLeave = AddSickLeaveRequest();
void _presentDatePicker(id) { void _presentDatePicker(id) {
showDatePicker( showDatePicker(
context: context, context: context,
initialDate: DateTime.now(), initialDate: DateTime.now(),
firstDate: DateTime(2019), firstDate: DateTime.now(),
lastDate: DateTime.now(), lastDate: DateTime(2050),
).then((pickedDate) { ).then((pickedDate) {
if (pickedDate == null) { if (pickedDate == null) {
return; return;
@ -51,9 +60,16 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
setState(() { setState(() {
// var selectedDate = DateFormat.yMd().format(pickedDate); // var selectedDate = DateFormat.yMd().format(pickedDate);
final df = new DateFormat('yyyy-MM-dd'); final df = new DateFormat('yyyy-MM-dd');
addSickLeave.startDate = df.format(pickedDate);
_toDateController.text = addSickLeave.startDate; //addSickLeave.startDate;
if (id == 'fromDate') {
fromDate = pickedDate; //df.format();
_toDateController.text = df.format(pickedDate);
} else {
toDate = pickedDate; //
_toDateController2.text = df.format(pickedDate);
}
//addSickLeave.startDate = selectedDate; //addSickLeave.startDate = selectedDate;
}); });
}); });
@ -223,8 +239,10 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
child: DropdownButton( child: DropdownButton(
focusColor: Colors.grey, focusColor: Colors.grey,
isExpanded: true, isExpanded: true,
value: model2.allOffTime[0] value: offTime == null
['code'], ? model2.allOffTime[0]
['code']
: offTime,
iconSize: 40, iconSize: 40,
elevation: 16, elevation: 16,
selectedItemBuilder: selectedItemBuilder:
@ -248,7 +266,18 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
); );
}).toList(); }).toList();
}, },
onChanged: (newValue) => {}, onChanged: (newValue) => {
setState(() {
offTime = newValue;
}),
if (offTime == '1')
{model2.getReasons(18)}
else if (offTime == '2')
{model2.getReasons(19)}
else if (offTime == '3' ||
offTime == '5')
{model2.getReasons(102)}
},
items: model2.allOffTime items: model2.allOffTime
.map((item) { .map((item) {
return DropdownMenuItem< return DropdownMenuItem<
@ -270,88 +299,215 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
], ],
), ),
)), )),
Container( offTime == '1'
margin: EdgeInsets.all(8), ? Column(
decoration: BoxDecoration( children: [
borderRadius: Container(
BorderRadius.all(Radius.circular(6.0)), margin: EdgeInsets.all(8),
border: Border.all( decoration: BoxDecoration(
width: 1.0, borderRadius: BorderRadius.all(
color: HexColor("#CCCCCC"))), Radius.circular(6.0)),
padding: EdgeInsets.all(5), border: Border.all(
child: Column( width: 1.0,
crossAxisAlignment: CrossAxisAlignment.start, color: HexColor("#CCCCCC"))),
children: [ padding: EdgeInsets.all(5),
AppTextFormField( child: Column(
hintText: TranslationBase.of(context) crossAxisAlignment:
.fromDate, CrossAxisAlignment.start,
borderColor: Colors.white, children: [
prefix: IconButton( AppTextFormField(
icon: Icon(Icons.calendar_today)), hintText: TranslationBase.of(
textInputType: TextInputType.number, context)
controller: _toDateController, .fromDate,
onTap: () { borderColor: Colors.white,
_presentDatePicker('_selectedToDate'); prefix: IconButton(
}, icon: Icon(Icons
inputFormatter: ONLY_DATE, .calendar_today)),
onChanged: (value) { textInputType:
addSickLeave.startDate = value; TextInputType.number,
}), controller: _toDateController,
], onTap: () {
)), _presentDatePicker(
'fromDate');
},
inputFormatter: ONLY_DATE,
onChanged: (value) {
fromDate = value;
}),
],
)),
Row(
children: [
Expanded(
child: Container(
margin: EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(
Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color:
HexColor("#CCCCCC"))),
padding: EdgeInsets.all(5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
// new AppTextFormField(
// readOnly: true,
// hintText: "",
// borderColor: Colors.white,
// onSaved: (value) {},
// inputFormatter: ONLY_NUMBERS),
Row( DateTimePicker(
children: [ type:
Expanded( DateTimePickerType.time,
child: Container( controller: _controller4,
margin: EdgeInsets.all(8), //initialValue: _initialValue,
decoration: BoxDecoration( // icon: Icon(Icons.access_time),
borderRadius: BorderRadius.all(
Radius.circular(6.0)), //use24HourFormat: false,
border: Border.all( //locale: Locale('en', 'US'),
width: 1.0, onChanged: (val) => () {
color: HexColor("#CCCCCC"))), print(val);
padding: EdgeInsets.all(5), },
child: Column( validator: (val) {
crossAxisAlignment: print(val);
CrossAxisAlignment.start, // setState(
children: [ // () => _valueToValidate4 = val);
new AppTextFormField( return null;
readOnly: true, },
hintText: "", onSaved: (val) => {},
borderColor: Colors.white, )
onSaved: (value) {}, ],
inputFormatter: ONLY_NUMBERS), ),
], ),
), ),
), Expanded(
), child: Container(
Expanded( margin: EdgeInsets.all(8),
child: Container( decoration: BoxDecoration(
margin: EdgeInsets.all(8), borderRadius:
decoration: BoxDecoration( BorderRadius.all(
borderRadius: BorderRadius.all( Radius.circular(6.0)),
Radius.circular(6.0)), border: Border.all(
border: Border.all( width: 1.0,
width: 1.0, color:
color: HexColor("#CCCCCC"))), HexColor("#CCCCCC"))),
padding: EdgeInsets.all(5), padding: EdgeInsets.all(5),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [ children: [
new AppTextFormField( DateTimePicker(
readOnly: true, type:
hintText: "", DateTimePickerType.time,
borderColor: Colors.white, controller: _controller4,
onSaved: (value) {}, //initialValue: _initialValue,
inputFormatter: ONLY_NUMBERS), // icon: Icon(Icons.access_time),
],
), //use24HourFormat: false,
//locale: Locale('en', 'US'),
onChanged: (val) => () {
print(val);
},
validator: (val) {
print(val);
// setState(
// () => _valueToValidate4 = val);
return null;
},
onSaved: (val) =>
{print(val)},
)
],
),
),
)
],
)
],
)
: Column(
children: [
Container(
margin: EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"))),
padding: EdgeInsets.all(5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
AppTextFormField(
hintText: TranslationBase.of(
context)
.fromDate,
borderColor: Colors.white,
prefix: IconButton(
icon: Icon(Icons
.calendar_today)),
textInputType:
TextInputType.number,
controller: _toDateController,
onTap: () {
_presentDatePicker(
'fromDate');
},
inputFormatter: ONLY_DATE,
onChanged: (value) {
setState(() {
toDate = value;
});
}),
],
)),
Container(
margin: EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"))),
padding: EdgeInsets.all(5),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
AppTextFormField(
hintText: TranslationBase
.of(context)
.fromDate,
borderColor: Colors.white,
prefix: IconButton(
icon: Icon(
Icons
.calendar_today)),
textInputType:
TextInputType.number,
controller:
_toDateController2,
onTap: () {
_presentDatePicker(
'toDate');
},
inputFormatter: ONLY_DATE,
onChanged: (value) {
setState(() {
toDate = value;
});
}),
],
))
],
), ),
)
],
),
Container( Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(8),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -382,9 +538,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
child: DropdownButton( child: DropdownButton(
focusColor: Colors.grey, focusColor: Colors.grey,
isExpanded: true, isExpanded: true,
value: model2.allReasons[0] value: reason == null
['id'] ? model2.allReasons[0]
.toString(), ['id']
.toString()
: reason,
iconSize: 40, iconSize: 40,
elevation: 16, elevation: 16,
selectedItemBuilder: selectedItemBuilder:
@ -412,7 +570,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
); );
}).toList(); }).toList();
}, },
onChanged: (newValue) => {}, onChanged: (newValue) => {
setState(() {
reason = newValue;
})
},
items: model2.allReasons items: model2.allReasons
.map((item) { .map((item) {
return DropdownMenuItem< return DropdownMenuItem<
@ -468,10 +630,12 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
child: DropdownButton( child: DropdownButton(
focusColor: Colors.grey, focusColor: Colors.grey,
isExpanded: true, isExpanded: true,
value: model2 value: doctorID == null
.coveringDoctors[0] ? model2
['doctorID'] .coveringDoctors[0]
.toString(), ['doctorID']
.toString()
: doctorID,
iconSize: 40, iconSize: 40,
elevation: 16, elevation: 16,
selectedItemBuilder: selectedItemBuilder:
@ -500,7 +664,11 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
); );
}).toList(); }).toList();
}, },
onChanged: (newValue) => {}, onChanged: (newValue) => {
setState(() {
doctorID = newValue;
})
},
items: model2 items: model2
.coveringDoctors .coveringDoctors
.map((item) { .map((item) {
@ -536,7 +704,9 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
children: <Widget>[ children: <Widget>[
AppButton( AppButton(
title: TranslationBase.of(context).add, title: TranslationBase.of(context).add,
onPressed: () {}, onPressed: () {
addRecheduleLeave(model2);
},
), ),
], ],
), ),
@ -569,4 +739,38 @@ class _RescheduleLeaveScreen extends State<RescheduleLeaveScreen> {
model.clinicsList.where((i) => i['ClinicID'] == clinicID).toList(); model.clinicsList.where((i) => i['ClinicID'] == clinicID).toList();
return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : ""; return clinicInfo.length > 0 ? clinicInfo[0]['ClinicDescription'] : "";
} }
addRecheduleLeave(model) {
final df = new DateFormat('yyyy-MM-ddThh:mm:ss');
Map<String, dynamic> request = {
"Requisition": {
"requisitionNo": 0,
"requisitionType": offTime,
"clinicId": this.profile['ClinicID'],
"doctorId": this.profile['ClinicID'],
"dateTimeFrom": df.format(fromDate),
"dateTimeTo": df.format(toDate),
"date": df.format(DateTime.now()),
"reasonId": reason == null ? model.allOffTime[0]['code'] : reason,
"coveringDoctorId":
doctorID == null ? model.coveringDoctors[0]['doctorID'] : doctorID,
"status": 2,
"schedule": [
{
"weekDayId": 1,
"shiftId": 1,
"isOpen": true,
"timeFrom": null,
"timeTo": null,
"timeFromstr": "",
"timeTostr": ""
}
]
}
};
model.addReschedule(request).then((response) {
print(response);
});
}
} }

@ -62,7 +62,7 @@ dependencies:
#Autocomplete TextField #Autocomplete TextField
autocomplete_textfield: ^1.7.3 autocomplete_textfield: ^1.7.3
date_time_picker: ^1.1.1
#speech to text #speech to text

Loading…
Cancel
Save