diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 722aa533..77545340 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -10,7 +10,6 @@ import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import 'dart:io' show Platform; - DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = new Helpers(); //ProjectProvider projectsProvider = new ProjectProvider(); @@ -86,7 +85,7 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - String asd= json.encode(body); + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), @@ -126,10 +125,10 @@ class BaseAppClient { postPatient(String endPoint, {Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure, - @required PatiantInformtion patient, - bool isExternal = false}) async { + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + @required PatiantInformtion patient, + bool isExternal = false}) async { String url = BASE_URL + endPoint; try { @@ -138,65 +137,63 @@ class BaseAppClient { 'Accept': 'application/json' }; - String token = await sharedPref.getString(TOKEN); - var languageID = - await sharedPref.getStringWithDefaultValue(APP_Language, 'en'); - if (body.containsKey('SetupID')) { - body['SetupID'] = body.containsKey('SetupID') - ? body['SetupID'] != null - ? body['SetupID'] - : SETUP_ID - : SETUP_ID; - } - - body['VersionID'] = VERSION_ID; - body['Channel'] = CHANNEL; - body['LanguageID'] = languageID == 'ar' ? 1 : 2; + String token = await sharedPref.getString(TOKEN); + var languageID = + await sharedPref.getStringWithDefaultValue(APP_Language, 'en'); + if (body.containsKey('SetupID')) { + body['SetupID'] = body.containsKey('SetupID') + ? body['SetupID'] != null + ? body['SetupID'] + : SETUP_ID + : SETUP_ID; + } - body['IPAdress'] = IP_ADDRESS; - body['generalid'] = GENERAL_ID; - body['PatientOutSA'] = body.containsKey('PatientOutSA') - ? body['PatientOutSA'] != null - ? body['PatientOutSA'] - : PATIENT_OUT_SA_PATIENT_REQ - : PATIENT_OUT_SA_PATIENT_REQ; + body['VersionID'] = VERSION_ID; + body['Channel'] = CHANNEL; + body['LanguageID'] = languageID == 'ar' ? 1 : 2; - if (body.containsKey('isDentalAllowedBackend')) { - body['isDentalAllowedBackend'] = - body.containsKey('isDentalAllowedBackend') - ? body['isDentalAllowedBackend'] != null - ? body['isDentalAllowedBackend'] - : IS_DENTAL_ALLOWED_BACKEND - : IS_DENTAL_ALLOWED_BACKEND; - } + body['IPAdress'] = IP_ADDRESS; + body['generalid'] = GENERAL_ID; + body['PatientOutSA'] = body.containsKey('PatientOutSA') + ? body['PatientOutSA'] != null + ? body['PatientOutSA'] + : PATIENT_OUT_SA_PATIENT_REQ + : PATIENT_OUT_SA_PATIENT_REQ; - body['DeviceTypeID'] = Platform.isAndroid ? 1: 2; + if (body.containsKey('isDentalAllowedBackend')) { + body['isDentalAllowedBackend'] = + body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; + } + body['DeviceTypeID'] = Platform.isAndroid ? 1 : 2; - body['PatientType'] = body.containsKey('PatientType') - ? body['PatientType'] != null + body['PatientType'] = body.containsKey('PatientType') + ? body['PatientType'] != null ? body['PatientType'] - : patient.patientType!= null - ? patient.patientType - : PATIENT_TYPE - : PATIENT_TYPE; + : patient.patientType != null + ? patient.patientType + : PATIENT_TYPE + : PATIENT_TYPE; - body['PatientTypeID'] = body.containsKey('PatientTypeID') - ? body['PatientTypeID'] != null + body['PatientTypeID'] = body.containsKey('PatientTypeID') + ? body['PatientTypeID'] != null ? body['PatientTypeID'] - : patient.patientType!= null - ? patient.patientType - : PATIENT_TYPE_ID - : PATIENT_TYPE_ID; - - body['TokenID'] = token; - body['PatientID'] = body['PatientID'] != null - ? body['PatientID'] - : patient.patientId?? patient.patientMRN; + : patient.patientType != null + ? patient.patientType + : PATIENT_TYPE_ID + : PATIENT_TYPE_ID; - body['PatientOutSA'] = 0;//user['OutSA']; //TODO change it - body['SessionID'] = SESSION_ID; //getSe + body['TokenID'] = token; + body['PatientID'] = body['PatientID'] != null + ? body['PatientID'] + : patient.patientId ?? patient.patientMRN; + body['PatientOutSA'] = 0; //user['OutSA']; //TODO change it + body['SessionID'] = SESSION_ID; //getSe print("URL : $url"); print("Body : ${json.encode(body)}"); diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 67218e02..3351f831 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -843,7 +843,7 @@ class _DashboardScreenState extends State { MainAxisAlignment.start, children: [ AppText( - model.dashboardItemsList[5] + model.dashboardItemsList[6] .kPIName, fontSize: SizeConfig.textMultiplier * @@ -869,11 +869,11 @@ class _DashboardScreenState extends State { Axis.horizontal, children: new List.generate( model - .dashboardItemsList[5] + .dashboardItemsList[6] .summaryoptions .length, (int index) { return getActivityButton(model - .dashboardItemsList[5] + .dashboardItemsList[6] .summaryoptions[index]); }))) ], diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 3fc538ff..45d457cd 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -478,35 +478,32 @@ 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( - // labelText: TranslationBase.of(context) - // .patientFile, - // borderColor: Colors.white, - // textInputType: TextInputType.number, - // focusNode: _nodeText3, - // inputFormatter: ONLY_NUMBERS, - // onSaved: (value) {}, - // ), - // ), - // (!(_selectedType == '2' || - // _selectedType == '4')) - // ? DynamicElements( - // _patientSearchFormValues, - // isFormSubmitted) - // : SizedBox( - // height: 0, - // ), - 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) + .patientFile, + borderColor: Colors.white, + textInputType: TextInputType.number, + focusNode: _nodeText3, + inputFormatter: ONLY_NUMBERS, + onSaved: (value) {}, + ), ), + (!(_selectedType == '2' || + _selectedType == '4')) + ? DynamicElements( + _patientSearchFormValues, + isFormSubmitted) + : SizedBox( + height: 0, + ), SizedBox( height: 10, ), diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index a475589d..286f206d 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -304,17 +304,24 @@ class _PatientsScreenState extends State { //if (val2 == 7) { responseModelList.sort((a, b) { if (b.startTime != null && b.startTime != null) { - 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); + try { + 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); + } on Exception catch (_) { + print('never reached'); + var adate = a.startTime; //a.startTime; + var bdate = b.startTime; + return adate.compareTo(bdate); + } } else { var adate = convertDateFormat(a.appointmentDate); var bdate = convertDateFormat(b.appointmentDate); @@ -549,8 +556,10 @@ class _PatientsScreenState extends State { .getFrom, "to": patient.getTo, - "isSearch": isSearch, - "arrivalType" :arrivalType, + "isSearch": + isSearch, + "arrivalType": + arrivalType, }); }, ); diff --git a/lib/screens/patients/profile/patient_profile_screen.dart b/lib/screens/patients/profile/patient_profile_screen.dart index a2282f49..23c1d608 100644 --- a/lib/screens/patients/profile/patient_profile_screen.dart +++ b/lib/screens/patients/profile/patient_profile_screen.dart @@ -405,7 +405,9 @@ class PatientProfileScreen extends StatelessWidget { if (patient.episodeNo == 0) BorderedButton( "${TranslationBase.of(context).createNew}\n${TranslationBase.of(context).episode}", - backgroundColor: Colors.red.shade700, + backgroundColor: patient.patientStatusType == 43 + ? Colors.red.shade700 + : Colors.grey.shade700, textColor: Colors.white, vPadding: 8, radius: 30, @@ -419,17 +421,21 @@ class PatientProfileScreen extends StatelessWidget { height: 30, ), handler: () async { - PostEpisodeReqModel postEpisodeReqModel = - PostEpisodeReqModel( - appointmentNo: patient.appointmentNo, - patientMRN: patient.patientMRN); - GifLoaderDialogUtils.showMyDialog(context); - await model.postEpisode(postEpisodeReqModel); - GifLoaderDialogUtils.hideDialog(context); - patient.episodeNo = model.episodeID; - Navigator.of(context).pushNamed( - CREATE_EPISODE, - arguments: {'patient': patient}); + if (patient.patientStatusType == 43) { + PostEpisodeReqModel postEpisodeReqModel = + PostEpisodeReqModel( + appointmentNo: + patient.appointmentNo, + patientMRN: patient.patientMRN); + GifLoaderDialogUtils.showMyDialog(context); + await model + .postEpisode(postEpisodeReqModel); + GifLoaderDialogUtils.hideDialog(context); + patient.episodeNo = model.episodeID; + Navigator.of(context).pushNamed( + CREATE_EPISODE, + arguments: {'patient': patient}); + } }, ), if (patient.episodeNo != 0) diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/PatientCard.dart index 5e34e7b9..9ecc6a23 100644 --- a/lib/widgets/patients/PatientCard.dart +++ b/lib/widgets/patients/PatientCard.dart @@ -122,8 +122,9 @@ class PatientCard extends StatelessWidget { Row( children: [ AppText( - patientInfo.nationalityName ?? - patientInfo.nationality, + patientInfo.nationalityName != null + ? patientInfo.nationalityName + : patientInfo.nationality, fontWeight: FontWeight.bold, fontSize: 14, ), @@ -253,15 +254,19 @@ class PatientCard extends StatelessWidget { width: 3.5, ), Container( - child: AppText( - DateUtils.convertDateFromServerFormat( - patientInfo.appointmentDate - .toString(), - 'yyyy-MM-dd'), - fontSize: - 1.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), + child: patientInfo.appointmentDate != null + ? AppText( + DateUtils + .convertDateFromServerFormat( + patientInfo + .appointmentDate + .toString(), + 'yyyy-MM-dd'), + fontSize: 1.5 * + SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ) + : SizedBox(), ), SizedBox( height: 0.5,