sick leave service

merge-requests/593/head
hussam al-habibeh 5 years ago
parent 98eec8fcdb
commit 058a6d9e8c

@ -1,3 +1,5 @@
import 'package:doctor_app_flutter/widgets/shared/StarRating.dart';
class SickLeavePatientModel {
String setupID;
int projectID;
@ -30,8 +32,10 @@ class SickLeavePatientModel {
dynamic patientName;
String projectName;
String qR;
List<String> speciality;
// List<String> speciality;
String strRequestDate;
String startDate;
String endDate;
SickLeavePatientModel(
{this.setupID,
@ -65,11 +69,14 @@ class SickLeavePatientModel {
this.patientName,
this.projectName,
this.qR,
this.speciality,
this.strRequestDate});
// this.speciality,
this.strRequestDate,
this.startDate,
this.endDate});
SickLeavePatientModel.fromJson(Map<String, dynamic> json) {
setupID = json['SetupID'];
projectID = json['ProjectID'];
patientID = json['PatientID'];
patientType = json['PatientType'];
@ -100,13 +107,16 @@ class SickLeavePatientModel {
patientName = json['PatientName'];
projectName = json['ProjectName'];
qR = json['QR'];
speciality = json['Speciality'].cast<String>();
// speciality = json['Speciality'].cast<String>();
strRequestDate = json['StrRequestDate'];
startDate = json['StartDate'];
endDate = json['EndDate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['SetupID'] = this.setupID;
data['ProjectID'] = this.projectID;
data['PatientID'] = this.patientID;
data['PatientType'] = this.patientType;
@ -137,8 +147,10 @@ class SickLeavePatientModel {
data['PatientName'] = this.patientName;
data['ProjectName'] = this.projectName;
data['QR'] = this.qR;
data['Speciality'] = this.speciality;
// data['Speciality'] = this.speciality;
data['StrRequestDate'] = this.strRequestDate;
data['StartDate'] = this.startDate;
data['EndDate'] = this.endDate;
return data;
}
}

@ -98,13 +98,13 @@ class SickLeaveService extends BaseService {
Future getSickLeave(patientMRN) async {
hasError = false;
await baseAppClient.post(
await baseAppClient.postPatient(
GET_SICK_LEAVE,
onSuccess: (dynamic response, int statusCode) {
Future.value(response);
_getAllsickLeave.clear();
response['SickLeavesList']['entityList'].forEach((v) {
_getAllsickLeave.add(GetAllSickLeaveResponse.fromJson(v));
_getAllsickLeavePatient.clear();
response['List_SickLeave'].forEach((v) {
_getAllsickLeavePatient.add(SickLeavePatientModel.fromJson(v));
});
},
onFailure: (String error, int statusCode) {
@ -115,26 +115,26 @@ class SickLeaveService extends BaseService {
);
}
// Future getSickLeavePatient(patientMRN) async {
// _sickLeavePatientRequestModel =
// SickLeavePatientRequestModel(patientID: patientMRN, patientType: 1);
// hasError = false;
// await baseAppClient.post(
// GET_SICK_LEAVE_PATIENT,
// onSuccess: (dynamic response, int statusCode) {
// Future.value(response);
// _getAllsickLeavePatient.clear();
// response['List_SickLeave'].forEach((v) {
// _getAllsickLeavePatient.add(SickLeavePatientModel.fromJson(v));
// });
// },
// onFailure: (String error, int statusCode) {
// hasError = true;
// super.error = error;
// },
// body: _sickLeavePatientRequestModel.toJson(),
// );
// }
Future getSickLeavePatient(patientMRN) async {
_sickLeavePatientRequestModel = SickLeavePatientRequestModel(
patientID: patientMRN, patientTypeID: 2, patientType: 1);
hasError = false;
await baseAppClient.postPatient(
GET_SICK_LEAVE_PATIENT,
onSuccess: (dynamic response, int statusCode) {
Future.value(response);
_getAllsickLeavePatient.clear();
response['List_SickLeave'].forEach((v) {
_getAllsickLeavePatient.add(SickLeavePatientModel.fromJson(v));
});
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: _sickLeavePatientRequestModel.toJson(),
);
}
Future getRescheduleLeave() async {
hasError = false;

@ -10,6 +10,7 @@ class SickLeaveViewModel extends BaseViewModel {
SickLeaveService _sickLeaveService = locator<SickLeaveService>();
get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics;
get getAllSIckLeave => _sickLeaveService.getAllSickLeave;
get getAllSIckLeavePatient => _sickLeaveService.getAllSickLeavePatient;
List get allOffTime => _sickLeaveService.getOffTimeList;
List get allReasons => _sickLeaveService.getReasons;
List get coveringDoctors => _sickLeaveService.coveringDoctorsList;
@ -56,6 +57,16 @@ class SickLeaveViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getSickLeavePatient(patientMRN) async {
setState(ViewState.Busy);
await _sickLeaveService.getSickLeavePatient(patientMRN);
if (_sickLeaveService.hasError) {
error = _sickLeaveService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future getRescheduleLeave() async {
setState(ViewState.Busy);
await _sickLeaveService.getRescheduleLeave();

@ -1,4 +1,5 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/model/sick_leave_patient_model.dart';
import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart';
@ -22,7 +23,7 @@ class AddSickLeavScreen extends StatelessWidget {
patient = routeArgs['patient'];
return BaseView<SickLeaveViewModel>(
onModelReady: (model) =>
model.getSickLeave(patient.patientMRN ?? patient.patientId),
model.getSickLeavePatient(patient.patientMRN ?? patient.patientId),
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: true,
@ -102,25 +103,26 @@ class AddSickLeavScreen extends StatelessWidget {
],
)
: SizedBox(),
model.getAllSIckLeave.length > 0
model.getAllSIckLeavePatient.length > 0
? Column(
children: model.getAllSIckLeave
.map<Widget>((GetAllSickLeaveResponse item) {
children: model.getAllSIckLeavePatient
.map<Widget>((SickLeavePatientModel item) {
return RoundedContainer(
margin: EdgeInsets.all(10),
child: Column(
children: [
Container(
decoration: BoxDecoration(
border: Border(
left: BorderSide(
color: item.status == 1
? Colors.yellow[800]
: item.status == 2
? Colors.green
: Colors.black,
width: 5.0,
))),
// decoration: BoxDecoration(
// border: Border(
// left: BorderSide(
// // color: item.status == 1
// // ? Colors.yellow[800]
// // : item.status == 2
// // ? Colors.green
// // : Colors.black,
// color: Colors.red,
// width: 5.0,
// ))),
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
@ -139,35 +141,37 @@ class AddSickLeavScreen extends StatelessWidget {
Container(
padding: EdgeInsets.all(3),
child: AppText(
item.status == 1
? TranslationBase.of(
context)
.hold
: item.status == 2
? TranslationBase
.of(
context)
.active
: TranslationBase
.of(context)
.all,
item.doctorName,
// item.status == 1
// ? TranslationBase.of(
// context)
// .hold
// : item.status == 2
// ? TranslationBase
// .of(
// context)
// .active
// : TranslationBase
// .of(context)
// .all,
fontWeight:
FontWeight.bold,
color: item.status == 1
? Colors.yellow[800]
: item.status == 2
? Colors.green
: Colors.black,
// color: item.status == 1
// ? Colors.yellow[800]
// : item.status == 2
// ? Colors.green
// : Colors.black,
color: Colors.red,
),
),
Row(
children: [
AppText(TranslationBase
.of(context)
.daysSickleave +
": "),
AppText(
TranslationBase.of(
context)
.daysSickleave),
AppText(
item.noOfDays
item.sickLeaveDays
.toString(),
fontWeight:
FontWeight.bold,
@ -183,52 +187,55 @@ class AddSickLeavScreen extends StatelessWidget {
' ',
),
Flexible(
child: AppText(
DateUtils
.convertStringToDateFormat(
item.startDate,
'dd-MMM-yyyy'),
fontWeight:
FontWeight.bold,
))
child: AppText(
DateUtils
.convertStringToDateFormat(
item.startDate,
'dd-MMM-yyyy'),
fontWeight:
FontWeight.bold,
),
)
],
),
Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
AppText(
item.remarks ?? "",
children: [
AppText(
TranslationBase.of(
context)
.endDate +
' ',
),
Flexible(
child: AppText(
DateUtils
.convertStringToDateFormat(
item.endDate,
'dd-MMM-yyyy'),
fontWeight:
FontWeight.bold,
),
// (item.status == 1 ||
// item.status == 2)
// ? IconButton(
// icon: Image.asset(
// 'assets/images/edit.png'),
//
// // color: Colors.green, //Colors.black,
// onPressed: () => {
// if (item.status ==
// 1)
// {
// DrAppToastMsg.showErrorToast(
// TranslationBase.of(
// context)
// .sickleaveonhold)
// }
// else
// {
// openSickLeave(
// context,
// true,
// extendedData:
// item)
// }
// },
// )
// : SizedBox()
]),
)
],
),
Row(children: [
AppText(TranslationBase.of(
context)
.branch +
": "),
AppText(
item.projectName ?? "",
),
]),
Row(children: [
AppText(TranslationBase.of(
context)
.clinic +
": "),
AppText(
item.clinicName ?? "",
),
]),
],
),
SizedBox(

Loading…
Cancel
Save