From 1ac94d9ec86f97cc5787d7d5f94099b9d17c3fa4 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 24 Mar 2021 10:53:32 +0300 Subject: [PATCH 1/2] bug fixes --- lib/config/config.dart | 3 ++ lib/core/service/patient_service.dart | 57 +++++++++++++++------------ 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 81dea160..56fe8bff 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -53,6 +53,9 @@ const GET_PRESCRIPTION_REPORT = const GT_MY_PATIENT_QUESTION = 'Services/DoctorApplication.svc/REST/GtMyPatientsQuestions'; +const PRM_SEARCH_PATIENT = + 'Services/Patients.svc/REST/GetPatientInformation_PRM'; + const GET_PATIENT = 'Services/DoctorApplication.svc/REST/'; const GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT = diff --git a/lib/core/service/patient_service.dart b/lib/core/service/patient_service.dart index f18a9360..8370287a 100644 --- a/lib/core/service/patient_service.dart +++ b/lib/core/service/patient_service.dart @@ -87,13 +87,18 @@ class PatientService extends BaseService { ClinicByProjectIdRequest(); ReferToDoctorRequest _referToDoctorRequest; - Future getPatientList( patient, patientType) async { + Future getPatientList(patient, patientType, {isView}) async { hasError = false; int val = int.parse(patientType); - + var url; + if (isView == false && patientType == '1') { + url = PRM_SEARCH_PATIENT; + } else { + url = GET_PATIENT + SERVICES_PATIANT[val]; + } dynamic localRes; await baseAppClient.post( - GET_PATIENT + SERVICES_PATIANT[val], + url, onSuccess: (dynamic response, int statusCode) { localRes = response; }, @@ -101,28 +106,30 @@ class PatientService extends BaseService { hasError = true; super.error = error; }, - body:val ==7?patient: { - "ProjectID": patient.ProjectID, - "ClinicID": patient.ClinicID, - "DoctorID": patient.DoctorID, - "FirstName": patient.FirstName, - "MiddleName": patient.MiddleName, - "LastName": patient.LastName, - "PatientMobileNumber": patient.PatientMobileNumber, - "PatientIdentificationID": patient.PatientIdentificationID, - "PatientID": patient.PatientID, - "From": patient.From, - "To": patient.To, - "LanguageID": patient.LanguageID, - "stamp": patient.stamp, - "IPAdress": patient.IPAdress, - "VersionID": patient.VersionID, - "Channel": patient.Channel, - "TokenID": patient.TokenID, - "SessionID": patient.SessionID, - "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, - "PatientOutSA": patient.PatientOutSA - }, + body: val == 7 + ? patient + : { + "ProjectID": patient.ProjectID, + "ClinicID": patient.ClinicID, + "DoctorID": patient.DoctorID, + "FirstName": patient.FirstName, + "MiddleName": patient.MiddleName, + "LastName": patient.LastName, + "PatientMobileNumber": patient.PatientMobileNumber, + "PatientIdentificationID": patient.PatientIdentificationID, + "PatientID": patient.PatientID, + "From": patient.From, + "To": patient.To, + "LanguageID": patient.LanguageID, + "stamp": patient.stamp, + "IPAdress": patient.IPAdress, + "VersionID": patient.VersionID, + "Channel": patient.Channel, + "TokenID": patient.TokenID, + "SessionID": patient.SessionID, + "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, + "PatientOutSA": patient.PatientOutSA + }, ); return Future.value(localRes); From 10ef8f79548df08a92fc7ba3841b88967d4f35d6 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 24 Mar 2021 10:53:48 +0300 Subject: [PATCH 2/2] bug fixes --- lib/core/viewModel/patient_view_model.dart | 10 +- .../patients/patient_search_screen.dart | 120 ++++++++++++------ lib/screens/patients/patients_screen.dart | 37 +++++- lib/widgets/patients/PatientCard.dart | 9 +- 4 files changed, 123 insertions(+), 53 deletions(-) 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 ==