diff --git a/lib/core/model/procedure/categories_procedure.dart b/lib/core/model/procedure/categories_procedure.dart index 9e6f847f..a679aa3d 100644 --- a/lib/core/model/procedure/categories_procedure.dart +++ b/lib/core/model/procedure/categories_procedure.dart @@ -58,7 +58,7 @@ class EntityList { this.subGroup, this.template, this.remarks, - this.type}); + this.type ='1'}); EntityList.fromJson(Map json) { allowedClinic = json['allowedClinic']; diff --git a/lib/core/model/sick_leave/sick_leave_patient_model.dart b/lib/core/model/sick_leave/sick_leave_patient_model.dart index d4c15368..c1620b6f 100644 --- a/lib/core/model/sick_leave/sick_leave_patient_model.dart +++ b/lib/core/model/sick_leave/sick_leave_patient_model.dart @@ -9,6 +9,7 @@ class SickLeavePatientModel { dynamic requestDate; dynamic sickLeaveDays; dynamic appointmentNo; + dynamic appointmentNO; dynamic admissionNo; dynamic actualDoctorRate; dynamic appointmentDate; @@ -98,7 +99,7 @@ class SickLeavePatientModel { requestNo = json['RequestNo']; requestDate = json['RequestDate']; sickLeaveDays = json['SickLeaveDays']; - appointmentNo = json['AppointmentNo']; + appointmentNo = (json['AppointmentNo'] ==null ? json['appointmentNo'] : json['AppointmentNo']); admissionNo = json['AdmissionNo']; actualDoctorRate = json['ActualDoctorRate']; appointmentDate = json['AppointmentDate']; diff --git a/lib/core/viewModel/sick_leave_view_model.dart b/lib/core/viewModel/sick_leave_view_model.dart index 4a9a5875..768a36d6 100644 --- a/lib/core/viewModel/sick_leave_view_model.dart +++ b/lib/core/viewModel/sick_leave_view_model.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/core/enum/view_state.dart'; +import 'package:doctor_app_flutter/core/model/sick_leave/sick_leave_patient_model.dart'; import 'package:doctor_app_flutter/core/service/patient/patient_service.dart'; import 'package:doctor_app_flutter/core/service/patient_medical_file/sick_leave/sickleave_service.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; @@ -30,10 +31,10 @@ class SickLeaveViewModel extends BaseViewModel { get postSechedule => _sickLeaveService.postReschedule; - get getAllSIckLeavePatient => [ + get getAllSIckLeavePatient => removeDuplicates([ ..._sickLeaveService.getAllSickLeavePatient, ..._sickLeaveService.getAllSickLeaveDoctor - ]; + ]); Future addSickLeave(AddSickLeaveRequest addSickLeaveRequest) async { setState(ViewState.BusyLocal); @@ -183,4 +184,15 @@ class SickLeaveViewModel extends BaseViewModel { } else setState(ViewState.Idle); } + List removeDuplicates(List items) { + ListuniqueItems = []; + var uniqueIDs = items + .map((e) => e.appointmentNo) + .toSet(); + uniqueIDs.forEach((e) { + uniqueItems.add(items.firstWhere((i) => i.appointmentNo == e)); + }); + return uniqueItems; + } } + diff --git a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart index 0e5873df..4433bfa8 100644 --- a/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart +++ b/lib/screens/patient-sick-leave/patient_sick_leave_screen.dart @@ -29,185 +29,255 @@ class PatientSickLeaveScreen extends StatelessWidget { Widget build(BuildContext context) { ProjectViewModel projectsProvider = Provider.of(context); - final routeArgs = ModalRoute.of(context).settings.arguments as Map; + final routeArgs = ModalRoute + .of(context) + .settings + .arguments as Map; patient = routeArgs['patient']; bool isInpatient = routeArgs['isInpatient']; return BaseView( onModelReady: (model) async { await model.getSickLeaveForPatient(patient); }, - builder: (_, model, w) => AppScaffold( - baseViewModel: model, - isShowAppBar: true, - backgroundColor: Colors.grey[100], - appBar: PatientProfileAppBar( - patient, - isInpatient: isInpatient, - ), - body: Column(children: [ - 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) - AppText( - TranslationBase.of(context).patient, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 3 : 4), - fontWeight: FontWeight.w700, - letterSpacing: -0.72, - color: Color(0xFF2E303A), - ), + builder: (_, model, w) => + AppScaffold( + baseViewModel: model, + isShowAppBar: true, + backgroundColor: Colors.grey[100], + appBar: PatientProfileAppBar( + patient, + isInpatient: isInpatient, + ), + body: Column(children: [ + 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) AppText( - TranslationBase.of(context).sickLeave, - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() * (SizeConfig.isWidthLarge ? 6 : 6), - fontWeight: FontWeight.bold, - letterSpacing: -1.44, + 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), + fontWeight: FontWeight.bold, + letterSpacing: -1.44, + color: Color(0xFF2E303A), + ), + ], ), - AddNewOrder( - label: TranslationBase.of(context).noSickLeaveApplied, - onTap: () async { - await locator().logEvent( - eventCategory: "Add Sick Leave Screen" - "Leave Screen", - eventAction: "apply For Sick Leave", - ); - openSickLeave(context, model); - }), - ], - ) - : SizedBox(), - model.getAllSIckLeavePatient.length > 0 - ? Expanded( - child: FractionallySizedBox( - widthFactor: 0.95, - child: ListView.builder( - scrollDirection: Axis.vertical, - shrinkWrap: true, - itemCount: model.getAllSIckLeavePatient.length, - itemBuilder: (BuildContext ctxt, int index) { - SickLeavePatientModel item = model.getAllSIckLeavePatient[index]; - return Column( - children: [ - CardWithBgWidget( - padding: 0, - marginLeft: 10, - marginSymmetric: 10, - hasBorder: false, - bgColor: Colors.black, - widget: Container( - color: Colors.white, - padding: EdgeInsets.all(20), - child: InkWell( - child: Column( - children: [ - if (item.doctorName != null) - Row(crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, children: [ - Expanded( - // width: MediaQuery.of(context).size.width*0.51, - child: AppText( - Utils.capitalize(item.doctorName ?? ""), - fontSize: 18, - color: Color(0xff2e303a), - fontWeight: FontWeight.w700, - fontFamily: 'Poppins', - textOverflow: TextOverflow.ellipsis, - ), - ), - ]), - SizedBox( - height: 10, - ), - Row( - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(50.0), - child: CachedNetworkImage( - imageUrl: item.doctorImageURL ?? "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", - height: 30, - width: 30, - errorWidget: (context, url, error) => AppText( - 'No Image', - fontSize: 10, + ), + AddNewOrder( + label: TranslationBase + .of(context) + .noSickLeaveApplied, + onTap: () async { + await locator().logEvent( + eventCategory: "Add Sick Leave Screen" + "Leave Screen", + eventAction: "apply For Sick Leave", + ); + openSickLeave(context, model); + }), + ], + ) + : SizedBox(), + model.getAllSIckLeavePatient.length > 0 + ? Expanded( + child: FractionallySizedBox( + widthFactor: 0.95, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.getAllSIckLeavePatient.length, + itemBuilder: (BuildContext ctxt, int index) { + SickLeavePatientModel item = model + .getAllSIckLeavePatient[index]; + return Column( + children: [ + CardWithBgWidget( + padding: 0, + marginLeft: 10, + marginSymmetric: 10, + hasBorder: false, + bgColor: Colors.black, + widget: Container( + color: Colors.white, + padding: EdgeInsets.all(20), + child: InkWell( + child: Column( + children: [ + if (item.doctorName != null) + Row(crossAxisAlignment: CrossAxisAlignment + .start, + mainAxisAlignment: MainAxisAlignment + .start, + children: [ + Expanded( + // width: MediaQuery.of(context).size.width*0.51, + child: AppText( + Utils.capitalize( + item.doctorName ?? ""), + fontSize: 18, + color: Color(0xff2e303a), + fontWeight: FontWeight.w700, + fontFamily: 'Poppins', + textOverflow: TextOverflow + .ellipsis, ), ), - ), - SizedBox( - width: 10, - ), - Expanded( - child: Column( - children: [ - CustomRow( - label: TranslationBase.of(context).daysSickleave, - labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, - valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, - value: - (item.sickLeaveDays.toString() != null && item.sickLeaveDays.toString() != "null") ? item.sickLeaveDays.toString() : item.noOfDays.toString(), + ]), + SizedBox( + height: 10, + ), + Row( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular( + 50.0), + child: CachedNetworkImage( + imageUrl: item.doctorImageURL ?? + "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown.png", + height: 30, + width: 30, + errorWidget: (context, url, + error) => + AppText( + 'No Image', + fontSize: 10, ), - CustomRow( - label: TranslationBase.of(context).startDate + ' ' ?? "", - labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, - valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, - value: AppDateUtils.getDayMonthYearDateFormatted( - item.startDate.contains("/Date(") ? AppDateUtils.convertStringToDate(item.startDate) : DateTime.parse(item.startDate), - ), + ), + ), + SizedBox( + width: 10, + ), + Expanded( + child: Column( + children: [ + CustomRow( + label: TranslationBase + .of(context) + .daysSickleave, + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: + (item.sickLeaveDays + .toString() != null && + item.sickLeaveDays + .toString() != "null") + ? item.sickLeaveDays + .toString() + : item.noOfDays + .toString(), + ), + CustomRow( + label: TranslationBase + .of(context) + .startDate + ' ' ?? "", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: AppDateUtils + .getDayMonthYearDateFormatted( + item.startDate.contains( + "/Date(") + ? AppDateUtils + .convertStringToDate( + item.startDate) + : DateTime.parse( + item.startDate), ), - CustomRow( - label: TranslationBase.of(context).endDate + ' ' ?? "", - labelSize: SizeConfig.getTextMultiplierBasedOnWidth() * 3.3, - valueSize: SizeConfig.getTextMultiplierBasedOnWidth() * 4, - value: 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 ?? ""), - ), + ), + CustomRow( + label: TranslationBase + .of(context) + .endDate + ' ' ?? "", + labelSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 3.3, + valueSize: SizeConfig + .getTextMultiplierBasedOnWidth() * + 4, + value: 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 ?? + ""), ), ), - ], - crossAxisAlignment: CrossAxisAlignment.start, - ), + ), + ], + crossAxisAlignment: CrossAxisAlignment + .start, ), - ], - ), - ], - ), + ), + ], + ), + ], ), ), ), - ], - ); - }), - ), - ) - : patient.patientStatusType != 43 + ), + ], + ); + }), + ), + ) + : patient.patientStatusType != 43 ? ErrorMessage( - error: TranslationBase.of(context).noSickLeave, - ) + error: TranslationBase + .of(context) + .noSickLeave, + ) : SizedBox(), - SizedBox( - height: 100, - ) - ]), - ), + SizedBox( + height: 100, + ) + ]), + ), ); } @@ -226,3 +296,4 @@ class PatientSickLeaveScreen extends StatelessWidget { ); } } + diff --git a/lib/screens/procedures/add_procedure_page.dart b/lib/screens/procedures/add_procedure_page.dart index bedfea99..efb1185f 100644 --- a/lib/screens/procedures/add_procedure_page.dart +++ b/lib/screens/procedures/add_procedure_page.dart @@ -31,7 +31,7 @@ class AddProcedurePage extends StatefulWidget { } class _AddProcedurePageState extends State { - int selectedType; + String selectedType; ProcedureViewModel model; PatiantInformtion patient; ProcedureType procedureType; @@ -46,7 +46,7 @@ class _AddProcedurePageState extends State { dynamic selectedCategory; - setSelectedType(int val) { + setSelectedType(String val) { setState(() { selectedType = val; }); diff --git a/lib/screens/procedures/entity_list_checkbox_search_widget.dart b/lib/screens/procedures/entity_list_checkbox_search_widget.dart index 3a3f6b09..6e55c77e 100644 --- a/lib/screens/procedures/entity_list_checkbox_search_widget.dart +++ b/lib/screens/procedures/entity_list_checkbox_search_widget.dart @@ -37,11 +37,11 @@ class EntityListCheckboxSearchWidget extends StatefulWidget { class _EntityListCheckboxSearchWidgetState extends State { - int selectedType = 0; + String selectedType = '0'; int typeUrgent; int typeRegular; - setSelectedType(int val) { + setSelectedType(String val) { setState(() { selectedType = val; }); @@ -158,8 +158,8 @@ class _EntityListCheckboxSearchWidgetState Radio( activeColor: Color(0xFFD02127), - value: 0, - groupValue: selectedType, + value: '0', + groupValue: historyInfo.type, onChanged: (value) { historyInfo.type = setSelectedType(value) @@ -177,8 +177,8 @@ class _EntityListCheckboxSearchWidgetState Radio( activeColor: Color(0xFFD02127), - groupValue: selectedType, - value: 1, + groupValue: historyInfo.type, + value: '1', onChanged: (value) { historyInfo.type = setSelectedType(value)