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); return Future.value(response);
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
DrAppToastMsg.showErrorToast(error); hasError = true;
// hasError = true; super.error = error;
// super.error = error;
}, },
body: addSickLeaveRequest.toJson(), body: addSickLeaveRequest.toJson(),
); );

@ -200,7 +200,7 @@ class PatientReferralViewModel extends BaseViewModel {
patientID: patient.patientId, patientID: patient.patientId,
roomID: patient.roomId, roomID: patient.roomId,
referralClinic: clinicID, 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, referralDoctor: doctorID,
patientTypeID: patient.patientType, patientTypeID: patient.patientType,
referringDoctorRemarks: remarks, referringDoctorRemarks: remarks,

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

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

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

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

@ -1,6 +1,7 @@
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';
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/patient_view_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/sickleave/add_sickleave_request.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_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_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/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:doctor_app_flutter/widgets/shared/text_fields/app_text_form_field.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -29,7 +31,7 @@ class SickLeaveScreen extends StatefulWidget {
final patientMRN; final patientMRN;
final patient; final patient;
SickLeaveScreen( 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 @override
_SickLeaveScreenState createState() => _SickLeaveScreenState(); _SickLeaveScreenState createState() => _SickLeaveScreenState();
} }
@ -69,7 +71,7 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PatientViewModel>( return BaseView<PatientViewModel>(
onModelReady: (model) => model.getClinicsList(), onModelReady: (model) => model.getClinicsList(),
builder: (_, model, w) => BaseView<SickLeaveViewModel>( builder: (_, model, w) => BaseView<SickLeaveViewModel>(
onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN), onModelReady: (model2) => model2.preSickLeaveStatistics(widget.appointmentNo, widget.patientMRN),
@ -120,12 +122,12 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
borderColor: Colors.white, borderColor: Colors.white,
onChanged: (value) { onChanged: (value) {
addSickLeave.noOfDays = value; addSickLeave.noOfDays = value;
if (widget.extendedData != null) { if (widget.extendedData.noOfDays != null) {
widget.extendedData.noOfDays = int.parse(value); widget.extendedData.noOfDays = int.parse(value);
} }
}, },
hintText: hintText:
widget.extendedData != null ? widget.extendedData.noOfDays.toString() : '', widget.extendedData.noOfDays != null ? widget.extendedData.noOfDays.toString() : '',
// validator: (value) { // validator: (value) {
// return TextValidator().validateName(value); // return TextValidator().validateName(value);
// }, // },
@ -371,13 +373,21 @@ class _SickLeaveScreenState extends State<SickLeaveScreen> {
} else { } else {
addSickLeave.patientMRN = widget.patient.patientMRN.toString(); addSickLeave.patientMRN = widget.patient.patientMRN.toString();
addSickLeave.appointmentNo = widget.patient.appointmentNo.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) { } catch (err) {
print(err); print(err);

Loading…
Cancel
Save