fix add sick leave

flutter_vervion_2
Elham Rababah 5 years ago
parent 46d09ee55d
commit 2140f0a229

@ -61,9 +61,8 @@ class SickLeaveService extends BaseService {
return Future.value(response);
},
onFailure: (String error, int statusCode) {
DrAppToastMsg.showErrorToast(error);
// hasError = true;
// super.error = error;
hasError = true;
super.error = error;
},
body: addSickLeaveRequest.toJson(),
);

@ -200,7 +200,7 @@ class PatientReferralViewModel extends BaseViewModel {
patientID: patient.patientId,
roomID: patient.roomId,
referralClinic: clinicID,
admissionNo: patient.appointmentNo,
admissionNo: patient.appointmentNo, /// TODO Elham* something in case inpateint since we send send appointmentNo for admissionNo which all time null
referralDoctor: doctorID,
patientTypeID: patient.patientType,
referringDoctorRemarks: remarks,

@ -17,12 +17,13 @@ class SickLeaveViewModel extends BaseViewModel {
get getReschduleLeave => _sickLeaveService.getAllRescheduleLeave;
get postSechedule => _sickLeaveService.postReschedule;
get sickleaveResponse => _sickLeaveService.sickLeaveResponse;
Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async {
setState(ViewState.Busy);
setState(ViewState.BusyLocal);
await _sickLeaveService.addSickLeave(addSickLeaveRequest);
if (_sickLeaveService.hasError) {
error = _sickLeaveService.error!;
setState(ViewState.Error);
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}

@ -86,7 +86,7 @@ class _AddVerifyMedicalReportState extends State<AddVerifyMedicalReport> {
if (txtOfMedicalReport.isNotEmpty) {
GifLoaderDialogUtils.showMyDialog(context);
model.insertMedicalReport(patient, txtOfMedicalReport);
await model.insertMedicalReport(patient, txtOfMedicalReport);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);

@ -476,27 +476,27 @@ class _PatientMakeInPatientReferralScreenState extends State<PatientMakeInPatien
if (_referTo == null) {
branchError = TranslationBase.of(context).fieldRequired!;
} else {
branchError = null!;
branchError = null;
}
if (_selectedBranch == null) {
hospitalError = TranslationBase.of(context).fieldRequired!;
} else {
hospitalError = null!;
hospitalError = null;
}
if (_selectedClinic == null) {
clinicError = TranslationBase.of(context).fieldRequired!;
} else {
clinicError = null!;
clinicError = null;
}
if (_selectedDoctor == null) {
doctorError = TranslationBase.of(context).fieldRequired!;
} else {
doctorError = null!;
doctorError = null;
}
if (_selectedFrequency == null) {
frequencyError = TranslationBase.of(context).fieldRequired!;
} else {
frequencyError = null!;
frequencyError = null;
}
});
if (_selectedFrequency == null ||

@ -26,7 +26,7 @@ class AddSickLeavScreen extends StatelessWidget {
final routeArgs = ModalRoute.of(context)!.settings.arguments as Map;
patient = routeArgs['patient'];
bool isInpatient = routeArgs['isInpatient'];
bool isInpatient = routeArgs['isInpatient']??false;
return BaseView<SickLeaveViewModel>(
onModelReady: (model) => model.getSickLeavePatient(patient.patientMRN ?? patient.patientId),
builder: (_, model, w) => AppScaffold(
@ -246,11 +246,6 @@ class AddSickLeavScreen extends StatelessWidget {
}
openSickLeave(BuildContext context, isExtend, {GetAllSickLeaveResponse? extendedData}) {
// showModalBottomSheet(
// context: context,
// builder: (context) {
// return new Container(
// child:
Navigator.push(
context,
FadePage(
@ -260,7 +255,7 @@ class AddSickLeavScreen extends StatelessWidget {
: patient.appointmentNo, //extendedData.appointmentNo,
patientMRN: isExtend == true ? extendedData!.patientMRN : patient.patientMRN,
isExtended: isExtend,
extendedData: extendedData!,
extendedData: extendedData??GetAllSickLeaveResponse(),
patient: patient)));
}
}

@ -1,6 +1,7 @@
import 'package:doctor_app_flutter/config/config.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/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
import 'package:doctor_app_flutter/models/sickleave/add_sickleave_request.dart';
@ -14,6 +15,7 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -29,7 +31,7 @@ class SickLeaveScreen extends StatefulWidget {
final patientMRN;
final patient;
SickLeaveScreen(
{this.appointmentNo, this.patientMRN, this.isExtended = false, required this.extendedData, this.patient});
{this.appointmentNo, this.patientMRN, this.isExtended = false, required this.extendedData, this.patient});
@override
_SickLeaveScreenState createState() => _SickLeaveScreenState();
}
@ -69,7 +71,7 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
@override
Widget build(BuildContext context) {
return BaseView<PatientViewModel>(
return BaseView<PatientViewModel>(
onModelReady: (model) => model.getClinicsList(),
builder: (_, model, w) => BaseView<SickLeaveViewModel>(
onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN),
@ -120,12 +122,12 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
borderColor: Colors.white,
onChanged: (value) {
addSickLeave.noOfDays = value;
if (widget.extendedData != null) {
if (widget.extendedData.noOfDays != null) {
widget.extendedData.noOfDays = int.parse(value);
}
},
hintText:
widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '',
widget.extendedData.noOfDays != null ? widget.extendedData.noOfDays.toString() : '',
// validator: (value) {
// return TextValidator().validateName(value);
// },
@ -371,13 +373,21 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
} else {
addSickLeave.patientMRN = widget.patient.patientMRN.toString();
addSickLeave.appointmentNo = widget.patient.appointmentNo.toString();
await model2.addSickLeave(addSickLeave).then((value) => print(value));
GifLoaderDialogUtils.showMyDialog(context);
await model2.addSickLeave(addSickLeave);
if(model2.state == ViewState.ErrorLocal){
GifLoaderDialogUtils.hideDialog(context);
DrAppToastMsg.showErrorToast(model2.error);
} else {
GifLoaderDialogUtils.hideDialog(context);
DrAppToastMsg.showSuccesToast("Sick leave created successfully");
Navigator.of(context).popUntil((route) {
return route.settings.name == PATIENTS_PROFILE;
});
Navigator.of(context).pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient});
}
DrAppToastMsg.showSuccesToast(model2.sickleaveResponse['ListSickLeavesToExtent']['success']);
Navigator.of(context).popUntil((route) {
return route.settings.name == PATIENTS_PROFILE;
});
Navigator.of(context).pushNamed(ADD_SICKLEAVE, arguments: {'patient': widget.patient});
}
} catch (err) {
print(err);

Loading…
Cancel
Save