From 5c4aee849e8ec43189e7b59d13c82560e3d497ac Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Wed, 14 Apr 2021 20:51:34 +0300 Subject: [PATCH] bug fixes --- lib/client/base_app_client.dart | 5 +- lib/core/service/patient_service.dart | 3 +- lib/models/patient/patient_model.dart | 9 +- .../search_medicine_patient_screen.dart | 8 +- .../patients/patient_search_screen.dart | 15 +- lib/screens/patients/patients_screen.dart | 56 +++--- .../prescription/add_prescription_form.dart | 162 ++++++++++-------- lib/util/helpers.dart | 6 +- lib/widgets/patients/PatientCard.dart | 7 +- 9 files changed, 157 insertions(+), 114 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 21caa827..43eda715 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -68,7 +68,7 @@ class BaseAppClient { body['LanguageID'] = 2; body['stamp'] = STAMP; - // if(!body.containsKey("IPAdress")) + // if(!body.containsKey("IPAdress")) body['IPAdress'] = IP_ADDRESS; body['VersionID'] = VERSION_ID; body['Channel'] = CHANNEL; @@ -86,9 +86,6 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - String bodyData= json.encode(body); - var asd = ""; - if (await Helpers.checkConnection()) { final response = await http.post(url, diff --git a/lib/core/service/patient_service.dart b/lib/core/service/patient_service.dart index 477d9d80..413bb6ae 100644 --- a/lib/core/service/patient_service.dart +++ b/lib/core/service/patient_service.dart @@ -130,7 +130,8 @@ class PatientService extends BaseService { "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, "PatientOutSA": patient.PatientOutSA, "SearchType": patient.Searchtype, - "MobileNo": '' + "MobileNo": patient.MobileNo, + "IdentificationNo": patient.IdentificationNo }, ); diff --git a/lib/models/patient/patient_model.dart b/lib/models/patient/patient_model.dart index 08b5d1d0..7368c538 100644 --- a/lib/models/patient/patient_model.dart +++ b/lib/models/patient/patient_model.dart @@ -29,7 +29,8 @@ class PatientModel { bool IsLoginForDoctorApp; bool PatientOutSA; int Searchtype; - + String IdentificationNo; + String MobileNo; int get getProjectID => ProjectID; set setProjectID(int ProjectID) => this.ProjectID = ProjectID; @@ -132,7 +133,9 @@ class PatientModel { this.SessionID, this.IsLoginForDoctorApp, this.PatientOutSA, - this.Searchtype}); + this.Searchtype, + this.IdentificationNo, + this.MobileNo}); factory PatientModel.fromJson(Map json) => PatientModel( FirstName: json["FirstName"], @@ -162,6 +165,8 @@ class PatientModel { data['IsLoginForDoctorApp'] = this.IsLoginForDoctorApp; data['PatientOutSA'] = this.PatientOutSA; data['Searchtype'] = this.Searchtype; + data['IdentificationNo'] = this.IdentificationNo; + data['MobileNo'] = this.MobileNo; return data; } } diff --git a/lib/screens/medicine/search_medicine_patient_screen.dart b/lib/screens/medicine/search_medicine_patient_screen.dart index 245c0602..305ad1d2 100644 --- a/lib/screens/medicine/search_medicine_patient_screen.dart +++ b/lib/screens/medicine/search_medicine_patient_screen.dart @@ -72,25 +72,27 @@ class _SearchMedicinePatientScreen extends State indicatorColor: Colors.red[800], labelColor: Theme.of(context).primaryColor, labelPadding: - EdgeInsets.only(top: 4.0, left: 35.0, right: 35.0), + EdgeInsets.only(top: 4.0, left: 30.0, right: 30.0), unselectedLabelColor: Colors.grey[800], tabs: [ Container( - width: MediaQuery.of(context).size.width * 0.30, + width: MediaQuery.of(context).size.width * 0.35, child: Center( child: AppText( TranslationBase.of(context).searchPatient, color: Colors.black, fontWeight: FontWeight.bold, + fontSize: 14, ), ), ), Container( - width: MediaQuery.of(context).size.width * 0.30, + width: MediaQuery.of(context).size.width * 0.35, child: Center( child: AppText( TranslationBase.of(context).searchMedicine, fontWeight: FontWeight.bold, + fontSize: 14, color: Colors.black), ), ), diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index bcd118c3..115b395b 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -56,6 +56,7 @@ class _PatientSearchScreenState extends State { LastName: "0", PatientMobileNumber: "0", PatientIdentificationID: "0", + MobileNo: '0', PatientID: 0, From: "0", To: "0", @@ -67,6 +68,7 @@ class _PatientSearchScreenState extends State { TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", SessionID: "5G0yXn0Jnq", IsLoginForDoctorApp: true, + IdentificationNo: '0', PatientOutSA: false); void _validateInputs() async { @@ -192,14 +194,19 @@ class _PatientSearchScreenState extends State { if (value.length == 10 && (value[0] == '2' || value[0] == '1')) { _patientSearchFormValues - .PatientIdentificationID = value; - } else if (value.length == 10 && + .IdentificationNo = value; + _patientSearchFormValues.Searchtype = 2; + _patientSearchFormValues.setPatientID = 0; + } else if ((value.length == 10 || + value.length == 9) && (value[0] == '05' || value[0] == '5')) { - _patientSearchFormValues - .setPatientMobileNumber = value; + _patientSearchFormValues.MobileNo = value; + _patientSearchFormValues.Searchtype = 0; + _patientSearchFormValues.setPatientID = 0; } else { _patientSearchFormValues.setPatientID = int.parse(value); + _patientSearchFormValues.Searchtype = 1; } } diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 42d2648b..e9b5f1a8 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -270,7 +270,7 @@ class _PatientsScreenState extends State { } if (routeArgs != null && routeArgs.containsKey("isSearch")) { isView = routeArgs['isView']; - patient.Searchtype = 1; + //patient.Searchtype = 1; } if (routeArgs != null && routeArgs.containsKey('activeFilter')) { _activeLocation = routeArgs['activeFilter']; @@ -333,34 +333,34 @@ class _PatientsScreenState extends State { } parsed = lItems; responseModelList = new ModelResponse.fromJson(parsed).list; - //if (val2 == 7) { - responseModelList.sort((a, b) { - if (b.startTime != null && b.startTime != null) { - 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); + if (val2 == 7) { + responseModelList.sort((a, b) { + if (b.startTime != null && b.startTime != null) { + 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); + return bdate.compareTo(adate); } - } else { - var adate = convertDateFormat(a.appointmentDate); - var bdate = convertDateFormat(b.appointmentDate); - return bdate.compareTo(adate); - } - }); - //} + }); + } responseModelList2 = responseModelList; _isError = false; } else { diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 870ab53f..46939262 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -1264,75 +1264,68 @@ class _PrescriptionFormWidgetState extends State { if (formKey.currentState .validate()) { Navigator.pop(context); - //openDrugToDrug(model); + openDrugToDrug(model); { - // var x = model - // .patientAssessmentList - // .map((value) => - // value.icdCode10ID) - // .toList() - // .join(','); - - postProcedure( - icdCode: model - .patientAssessmentList - .isNotEmpty - ? model - .patientAssessmentList[ - 0] - .icdCode10ID - .isEmpty - ? "test" - : model - .patientAssessmentList[ - 0] - .icdCode10ID - .toString() - : "test", - // icdCode: model - // .patientAssessmentList - // .map((value) => value - // .icdCode10ID - // .trim()) - // .toList() - // .join(' '), - dose: - strengthController - .text, - doseUnit: units[ - 'parameterCode'] - .toString(), - patient: - widget.patient, - doseTimeIn: - doseTime['id'] - .toString(), - model: widget.model, - duration: - duration['id'] - .toString(), - frequency: frequency[ - 'parameterCode'] - .toString(), - route: route[ - 'parameterCode'] - .toString(), - drugId: - _selectedMedication - .itemId - .toString(), - strength: - strengthController - .text, - indication: - indicationController - .text, - instruction: - instructionController - .text, - doseTime: - selectedDate, - ); + // postProcedure( + // icdCode: model + // .patientAssessmentList + // .isNotEmpty + // ? model + // .patientAssessmentList[ + // 0] + // .icdCode10ID + // .isEmpty + // ? "test" + // : model + // .patientAssessmentList[ + // 0] + // .icdCode10ID + // .toString() + // : "test", + // // icdCode: model + // // .patientAssessmentList + // // .map((value) => value + // // .icdCode10ID + // // .trim()) + // // .toList() + // // .join(' '), + // dose: + // strengthController + // .text, + // doseUnit: units[ + // 'parameterCode'] + // .toString(), + // patient: + // widget.patient, + // doseTimeIn: + // doseTime['id'] + // .toString(), + // model: widget.model, + // duration: + // duration['id'] + // .toString(), + // frequency: frequency[ + // 'parameterCode'] + // .toString(), + // route: route[ + // 'parameterCode'] + // .toString(), + // drugId: + // _selectedMedication + // .itemId + // .toString(), + // strength: + // strengthController + // .text, + // indication: + // indicationController + // .text, + // instruction: + // instructionController + // .text, + // doseTime: + // selectedDate, + // ); } } @@ -1432,7 +1425,7 @@ class _PrescriptionFormWidgetState extends State { context: context, builder: (context) { return Container( - height: SizeConfig.realScreenHeight * .5, + height: SizeConfig.realScreenHeight * .8, width: SizeConfig.realScreenWidth, child: SingleChildScrollView( child: Column( @@ -1448,6 +1441,7 @@ class _PrescriptionFormWidgetState extends State { title: TranslationBase.of(context).addMedication, onPressed: () { Navigator.pop(context); + postProcedure( icdCode: model.patientAssessmentList.isNotEmpty ? model.patientAssessmentList[0].icdCode10ID @@ -1477,6 +1471,36 @@ class _PrescriptionFormWidgetState extends State { instruction: instructionController.text, doseTime: selectedDate, ); + + // postProcedure( + // icdCode: model.patientAssessmentList.isNotEmpty + // ? model.patientAssessmentList[0].icdCode10ID + // .isEmpty + // ? "test" + // : model.patientAssessmentList[0].icdCode10ID + // .toString() + // : "test", + // // icdCode: model + // // .patientAssessmentList + // // .map((value) => value + // // .icdCode10ID + // // .trim()) + // // .toList() + // // .join(' '), + // dose: strengthController.text, + // doseUnit: units['parameterCode'].toString(), + // patient: widget.patient, + // doseTimeIn: doseTime['id'].toString(), + // model: widget.model, + // duration: duration['id'].toString(), + // frequency: frequency['parameterCode'].toString(), + // route: route['parameterCode'].toString(), + // drugId: _selectedMedication.itemId.toString(), + // strength: strengthController.text, + // indication: indicationController.text, + // instruction: instructionController.text, + // doseTime: selectedDate, + // ); }, )) ], diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 8a4cfbd0..7874cc82 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -423,6 +423,10 @@ class Helpers { } static String capitalize(str) { - return "${str[0].toUpperCase()}${str.substring(1).toLowerCase()}"; + if (str != "") { + return "${str[0].toUpperCase()}${str.substring(1).toLowerCase()}"; + } else { + return str; + } } } diff --git a/lib/widgets/patients/PatientCard.dart b/lib/widgets/patients/PatientCard.dart index 611f4898..faa7fee5 100644 --- a/lib/widgets/patients/PatientCard.dart +++ b/lib/widgets/patients/PatientCard.dart @@ -132,11 +132,14 @@ class PatientCard extends StatelessWidget { ? patientInfo.nationalityName.trim() : patientInfo.nationality != null ? patientInfo.nationality.trim() - : "", + : patientInfo.nationalityId != null + ? patientInfo.nationalityId + : "", fontWeight: FontWeight.bold, fontSize: 14, ), - patientInfo.nationality != null + patientInfo.nationality != null || + patientInfo.nationalityId != null ? ClipRRect( borderRadius: BorderRadius.circular(20.0),