You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
doctor_app_flutter/lib/screens/sick-leave/add-sickleave.dart

266 lines
14 KiB
Dart

5 years ago
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart';
import 'package:doctor_app_flutter/core/service/AnalyticsService.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
5 years ago
import 'package:doctor_app_flutter/core/viewModel/sick_leave_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
5 years ago
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
5 years ago
import 'package:doctor_app_flutter/models/sickleave/get_all_sickleave_response.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
5 years ago
import 'package:doctor_app_flutter/screens/sick-leave/sick_leave.dart';
5 years ago
import 'package:doctor_app_flutter/util/date-utils.dart';
5 years ago
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/add-order/addNewOrder.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.dart';
5 years ago
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
5 years ago
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart';
5 years ago
import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart';
5 years ago
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
5 years ago
import 'package:flutter/material.dart';
5 years ago
import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart';
5 years ago
class AddSickLeavScreen extends StatelessWidget {
5 years ago
PatiantInformtion patient;
5 years ago
@override
Widget build(BuildContext context) {
ProjectViewModel projectsProvider = Provider.of<ProjectViewModel>(context);
5 years ago
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
patient = routeArgs['patient'];
5 years ago
bool isInpatient = routeArgs['isInpatient'];
5 years ago
return BaseView<SickLeaveViewModel>(
onModelReady: (model) async {
await model
.getSickLeavePatient(patient.patientMRN ?? patient.patientId);
await model
.getSickLeaveDoctor(patient.patientMRN ?? patient.patientId);
},
5 years ago
builder: (_, model, w) => AppScaffold(
5 years ago
baseViewModel: model,
5 years ago
isShowAppBar: true,
backgroundColor: Colors.grey[100],
appBar: PatientProfileAppBar(
5 years ago
patient,
5 years ago
isInpatient: isInpatient,
5 years ago
),
5 years ago
body: SingleChildScrollView(
child: Column(children: [
5 years ago
patient.patientStatusType == 43
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: SizeConfig.isHeightVeryShort?30:SizeConfig.isHeightShort?35: 10,),
if (!projectsProvider.isArabic)
5 years ago
AppText(
TranslationBase.of(context).patient,
fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge? 3: 4),
fontWeight: FontWeight.w700,
letterSpacing:-0.72,
color: Color(0xFF2E303A),
),
AppText(TranslationBase.of(context).sickLeave,
fontSize:SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge? 6: 6),
5 years ago
fontWeight: FontWeight.bold,
letterSpacing:-1.44,
color: Color(0xFF2E303A),
5 years ago
),
],
)),
AddNewOrder(label: TranslationBase.of(context)
.noSickLeaveApplied, onTap: () async {
await locator<AnalyticsService>().logEvent(
eventCategory: "Add Sick Leave Screen"
"Leave Screen",
eventAction: "apply For Sick Leave",
);
openSickLeave(
context,
false,
);
}),
5 years ago
],
)
: SizedBox(),
model.getAllSIckLeavePatient.length > 0
? ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: model.getAllSIckLeavePatient.length,
itemBuilder: (BuildContext ctxt, int index) {
var item = model.getAllSIckLeavePatient[index];
return Container(
padding: EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 4,
child: Wrap(
// mainAxisAlignment:
// MainAxisAlignment.start,
5 years ago
children: <Widget>[
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.all(3),
child: AppText(
item = model.getAllSIckLeavePatient[index].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: Colors.red,
),
),
Row(
children: [
AppText(TranslationBase
.of(context)
.daysSickleave +
": "),
AppText(
(item.sickLeaveDays
.toString() !=
null &&
item.sickLeaveDays
.toString() !=
"null")
? item.sickLeaveDays
.toString()
: item.noOfDays
.toString(),
fontWeight:
FontWeight.bold,
),
],
),
Row(
children: [
AppText(
TranslationBase.of(
context)
.startDate +
' ' ??
"",
),
Flexible(
child: AppText(
AppDateUtils.getDayMonthYearDateFormatted(item
.startDate
.contains(
"/Date(")
? AppDateUtils
.convertStringToDate(item
.startDate)
: DateTime.parse(
item.startDate)),
fontWeight:
FontWeight.bold,
5 years ago
),
)
],
),
Row(
children: [
AppText(
TranslationBase.of(
context)
.endDate +
' ' ??
"",
),
Flexible(
child: AppText(
AppDateUtils.getDayMonthYearDateFormatted(item
.startDate
.contains(
"/Date(")
? AppDateUtils.convertStringToDate(
item.endDate ??
"")
.add(Duration(
days: item.noOfDays ??
item
.sickLeaveDays))
: DateTime.parse(
item.startDate ?? "")
.add(Duration(days: item.noOfDays ?? ""))),
fontWeight:
FontWeight.bold,
),
)
],
),
],
),
SizedBox(
width: 20,
5 years ago
),
],
),
),
],
));
})
: patient.patientStatusType != 43
? ErrorMessage(
error: TranslationBase.of(context)
.noSickLeave,
)
: SizedBox()
5 years ago
]))));
5 years ago
}
5 years ago
openSickLeave(BuildContext context, isExtend,
{GetAllSickLeaveResponse extendedData}) {
5 years ago
// showModalBottomSheet(
// context: context,
// builder: (context) {
// return new Container(
// child:
Navigator.push(
context,
FadePage(
page: SickLeaveScreen(
appointmentNo: isExtend == true
? extendedData.appointmentNo
: patient.appointmentNo,
//extendedData.appointmentNo,
patientMRN: isExtend == true
? extendedData.patientMRN
: patient.patientMRN,
5 years ago
isExtended: isExtend,
extendedData: extendedData,
patient: patient)));
5 years ago
}
5 years ago
}