diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart index 70bf0899..5f4b6c9a 100644 --- a/lib/core/viewModel/patient_view_model.dart +++ b/lib/core/viewModel/patient_view_model.dart @@ -49,23 +49,21 @@ class PatientViewModel extends BaseViewModel { _patientService.referalFrequancyList; Future getPatientList(patient, patientType, - - {bool isBusyLocal = false}) async { - var localRes ; + {bool isBusyLocal = false, isView}) async { + var localRes; if (isBusyLocal) { setState(ViewState.BusyLocal); } else { setState(ViewState.Busy); } - localRes = await _patientService.getPatientList(patient, patientType); + localRes = await _patientService.getPatientList(patient, patientType, + isView: isView); if (_patientService.hasError) { error = _patientService.error; setState(ViewState.Error); - } return localRes; - } Future getPatientVitalSign(patient) async { diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 8b34c50d..d1a8cd22 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -93,6 +93,7 @@ class _PatientSearchScreenState extends State { "patientSearchForm": _patientSearchFormValues, "selectedType": _selectedType, "isSearch": true, + "isView": isView }); } } else { @@ -180,7 +181,7 @@ class _PatientSearchScreenState extends State { padding: EdgeInsets.all(10), child: AppTextFormField( labelText: - TranslationBase.of(context).phoneNumber, + TranslationBase.of(context).patientID, borderColor: Colors.white, textInputType: TextInputType.number, textInputAction: TextInputAction.done, @@ -188,15 +189,14 @@ class _PatientSearchScreenState extends State { focusNode: _nodeText1, onSaved: (value) { value == null || value == '' - ? _patientSearchFormValues - .setPatientMobileNumber = "0" - : _patientSearchFormValues - .setPatientMobileNumber = value; + ? _patientSearchFormValues.setPatientID = + 0 + : _patientSearchFormValues.setPatientID = + int.parse(value); if (value != null && value.toString().trim().isEmpty) { - _patientSearchFormValues - .setPatientMobileNumber = "0"; + _patientSearchFormValues.setPatientID = 0; } }, ), @@ -263,7 +263,8 @@ class _PatientSearchScreenState extends State { elevation: 16, selectedItemBuilder: (BuildContext context) { - return PATIENT_TYPE_Des.map((item) { + return PATIENT_TYPE_Des.map( + (item) { return Row( mainAxisSize: MainAxisSize.max, @@ -292,7 +293,8 @@ class _PatientSearchScreenState extends State { int.parse(_selectedType); }) }, - items: PATIENT_TYPE_Des.map((item) { + items: + PATIENT_TYPE_Des.map((item) { !projectsProvider.isArabic ? itemText = item['text'] : itemText = @@ -347,35 +349,39 @@ class _PatientSearchScreenState extends State { SizedBox( height: 10, ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(6.0)), - border: Border.all( - width: 1.0, - color: HexColor("#CCCCCC"))), - padding: EdgeInsets.all(10), - child: AppTextFormField( + if (_selectedType != '7') + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + border: Border.all( + width: 1.0, + color: HexColor("#CCCCCC"))), + padding: EdgeInsets.all(10), + child: AppTextFormField( labelText: TranslationBase.of(context) - .middleName, + .phoneNumber, borderColor: Colors.white, + textInputType: TextInputType.number, + textInputAction: TextInputAction.done, + inputFormatter: ONLY_NUMBERS, + focusNode: _nodeText1, onSaved: (value) { value == null || value == '' ? _patientSearchFormValues - .setMiddleName = "0" + .setPatientMobileNumber = "0" : _patientSearchFormValues - .setMiddleName = value; + .setPatientMobileNumber = + value; + if (value != null && value.toString().trim().isEmpty) { _patientSearchFormValues - .setMiddleName = "0"; + .setPatientMobileNumber = "0"; } }, - // validator: (value) { - // return TextValidator().validateName(value); - // }, - inputFormatter: ONLY_LETTERS), - ), + ), + ), SizedBox( height: 10, ), @@ -389,20 +395,23 @@ class _PatientSearchScreenState extends State { padding: EdgeInsets.all(10), child: AppTextFormField( labelText: TranslationBase.of(context) - .lastName, + .middleName, borderColor: Colors.white, onSaved: (value) { value == null || value == '' ? _patientSearchFormValues - .setLastName = "0" + .setMiddleName = "0" : _patientSearchFormValues - .setLastName = value; + .setMiddleName = value; if (value != null && value.toString().trim().isEmpty) { _patientSearchFormValues - .setLastName = "0"; + .setMiddleName = "0"; } }, + // validator: (value) { + // return TextValidator().validateName(value); + // }, inputFormatter: ONLY_LETTERS), ), SizedBox( @@ -418,25 +427,54 @@ class _PatientSearchScreenState extends State { padding: EdgeInsets.all(10), child: AppTextFormField( labelText: TranslationBase.of(context) - .patientID, + .lastName, borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - focusNode: _nodeText2, onSaved: (value) { value == null || value == '' ? _patientSearchFormValues - .setPatientID = 0 + .setLastName = "0" : _patientSearchFormValues - .setPatientID = - int.parse(value); + .setLastName = value; if (value != null && - value.trim().toString().isEmpty) { + value.toString().trim().isEmpty) { _patientSearchFormValues - .setPatientID = 0; + .setLastName = "0"; } - }), + }, + inputFormatter: ONLY_LETTERS), ), + // SizedBox( + // height: 10, + // ), + // Container( + // decoration: BoxDecoration( + // borderRadius: BorderRadius.all( + // Radius.circular(6.0)), + // border: Border.all( + // width: 1.0, + // color: HexColor("#CCCCCC"))), + // padding: EdgeInsets.all(10), + // child: AppTextFormField( + // labelText: TranslationBase.of(context) + // .patientID, + // borderColor: Colors.white, + // textInputType: TextInputType.number, + // inputFormatter: ONLY_NUMBERS, + // focusNode: _nodeText2, + // onSaved: (value) { + // value == null || value == '' + // ? _patientSearchFormValues + // .setPatientID = 0 + // : _patientSearchFormValues + // .setPatientID = + // int.parse(value); + // if (value != null && + // value.trim().toString().isEmpty) { + // _patientSearchFormValues + // .setPatientID = 0; + // } + // }), + // ), SizedBox( height: 10, ), diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 2900f56a..acd5dfa9 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -24,6 +24,7 @@ import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.d import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import '../../config/size_config.dart'; @@ -34,11 +35,13 @@ class PatientsScreen extends StatefulWidget { final selectedType; final isAppbar; final arrivalType; + final isView; PatientsScreen( {this.patientSearchForm, this.selectedType, this.isAppbar = true, - this.arrivalType}); + this.arrivalType, + this.isView}); @override _PatientsScreenState createState() => _PatientsScreenState(); } @@ -261,7 +264,8 @@ class _PatientsScreenState extends State { val2 == 7 ? getPatientArrivalListRequestModel.toJson() : patient, - patientType) + patientType, + isView: widget.isView) .then((res) { setState(() { if (res != null && res['MessageStatus'] == 1) { @@ -289,6 +293,20 @@ class _PatientsScreenState extends State { } parsed = lItems; responseModelList = new ModelResponse.fromJson(parsed).list; + responseModelList.sort((a, b) { + DateTime now = DateTime.now(); + DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm"); + String formattedDate = + DateFormat('yyyy-MM-dd ' + a.startTime).format(now); + DateTime dateTimeA = dateFormat.parse(formattedDate); + String formattedDateB = + DateFormat('yyyy-MM-dd ' + b.startTime).format(now); + DateTime dateTimeB = dateFormat.parse(formattedDateB); + var adate = dateTimeA; //a.startTime; + var bdate = dateTimeB; + return adate.compareTo(bdate); + }); + responseModelList2 = responseModelList; _isError = false; } else { @@ -516,7 +534,8 @@ class _PatientsScreenState extends State { .getFrom, "to": patient.getTo, - "isSearch":isSearch + "isSearch": + isSearch }); }, ); @@ -597,8 +616,16 @@ class _PatientsScreenState extends State { parsed = lItems; responseModelList = new ModelResponse.fromJson(parsed).list; responseModelList.sort((a, b) { - var adate = a.arrivedOn; - var bdate = b.arrivedOn; //before -> var bdate = b.expiry; + DateTime now = DateTime.now(); + DateFormat dateFormat = DateFormat("yyyy-MM-dd HH:mm"); + String formattedDate = + DateFormat('yyyy-MM-dd ' + a.startTime).format(now); + DateTime dateTimeA = dateFormat.parse(formattedDate); + String formattedDateB = + DateFormat('yyyy-MM-dd ' + b.startTime).format(now); + DateTime dateTimeB = dateFormat.parse(formattedDateB); + var adate = dateTimeA; //a.startTime; + var bdate = dateTimeB; return adate.compareTo(bdate); }); responseModelList2 = responseModelList; diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/PatientCard.dart index f067e161..5e34e7b9 100644 --- a/lib/widgets/patients/PatientCard.dart +++ b/lib/widgets/patients/PatientCard.dart @@ -286,7 +286,14 @@ class PatientCard extends StatelessWidget { bottomRight: Radius.circular(8), topLeft: Radius.circular(8), ), - color: Colors.red, + color: patientInfo.appointmentType == + 'Regular' && + patientInfo.visitTypeId == 100 + ? HexColor('#D02127') + : patientInfo.appointmentType == + 'Walkin' + ? HexColor('#28323A') + : HexColor('#6C7379'), ), child: Image.asset( patientInfo.appointmentType ==