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

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

@ -10,6 +10,7 @@ class SickLeaveViewModel extends BaseViewModel {
SickLeaveService _sickLeaveService = locator<SickLeaveService>(); SickLeaveService _sickLeaveService = locator<SickLeaveService>();
get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics; get sickLeaveStatistics => _sickLeaveService.sickLeavestatisitics;
get getAllSIckLeave => _sickLeaveService.getAllSickLeave; get getAllSIckLeave => _sickLeaveService.getAllSickLeave;
get getAllSIckLeavePatient => _sickLeaveService.getAllSickLeavePatient;
List get allOffTime => _sickLeaveService.getOffTimeList; List get allOffTime => _sickLeaveService.getOffTimeList;
List get allReasons => _sickLeaveService.getReasons; List get allReasons => _sickLeaveService.getReasons;
List get coveringDoctors => _sickLeaveService.coveringDoctorsList; List get coveringDoctors => _sickLeaveService.coveringDoctorsList;
@ -56,6 +57,16 @@ class SickLeaveViewModel extends BaseViewModel {
setState(ViewState.Idle); 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 { Future getRescheduleLeave() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _sickLeaveService.getRescheduleLeave(); await _sickLeaveService.getRescheduleLeave();

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

Loading…
Cancel
Save