From 2ad96dad88a6027def6a4704c54cd3fa8bc08122 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Mon, 8 Jun 2020 12:06:07 +0300 Subject: [PATCH 01/42] create Prescription In and Out Patient --- lib/config/config.dart | 4 +- .../prescriptions/prescriptions_screen.dart | 85 +++---------------- .../prescription_in_patinets_widget.dart | 82 ++++++++++++++++++ .../prescription_out_patinets_widget.dart | 82 ++++++++++++++++++ 4 files changed, 180 insertions(+), 73 deletions(-) create mode 100644 lib/widgets/patients/profile/prescription_in_patinets_widget.dart create mode 100644 lib/widgets/patients/profile/prescription_out_patinets_widget.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index dade19d6..886430ad 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; -// const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; + const BASE_URL = 'https://hmgwebservices.com/Services/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart b/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart index 360ec776..b2ee2f48 100644 --- a/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart +++ b/lib/screens/patients/profile/prescriptions/prescriptions_screen.dart @@ -1,5 +1,7 @@ import 'package:doctor_app_flutter/models/patient/reauest_prescription_report_for_in_patient.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/prescription_in_patinets_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/prescription_out_patinets_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -33,9 +35,10 @@ class PrescriptionScreen extends StatefulWidget { class _PrescriptionScreenState extends State { PatientsProvider patientsProv; - var _isInit = true; + bool _isInit = true; + String type = '2'; - /* + /* *@author: Elham Rababah *@Date:28/4/2020 *@param: context @@ -46,7 +49,7 @@ class _PrescriptionScreenState extends State { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); - String type = await sharedPref.getString(SLECTED_PATIENT_TYPE); + type = await sharedPref.getString(SLECTED_PATIENT_TYPE); if (type == '1') { RequestPrescriptionReportForInPatient prescriptionReqModel = @@ -85,74 +88,14 @@ class _PrescriptionScreenState extends State { ? DrAppCircularProgressIndeicator() : patientsProv.isError ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.patientPrescriptionsList.length == 0 - ? DrAppEmbeddedError( - error: 'You don\'t have any Prescriptions') - : Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: ListView.builder( - itemCount: - patientsProv.patientPrescriptionsList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - child: CardWithBgWidgetNew( - widget: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - LargeAvatar( - url: patientsProv - .patientPrescriptionsList[index] - .doctorImageURL, - name: patientsProv - .patientPrescriptionsList[index] - .doctorName, - radius: 10, - width: 70, - ), - Expanded( - child: Container( - margin: EdgeInsets.only( - left: 15, right: 15), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - '${patientsProv.patientPrescriptionsList[index].name}', - fontSize: 2.5 * - SizeConfig.textMultiplier, - ), - SizedBox( - height: 8, - ), - AppText( - '${patientsProv.patientPrescriptionsList[index].clinicDescription}', - fontSize: 2.5 * - SizeConfig - .textMultiplier, - color: Theme.of(context) - .primaryColor), - SizedBox( - height: 8, - ), - ], - ), - ), - ) - ], - ), - ], - ), - ), - onTap: () {}, - ); - }), + : type == '1' + ? PrescriptionInPatientWidget( + prescriptionReportForInPatientList: + patientsProv.prescriptionReportForInPatientList, + ) + : PrescriptionOutPatientWidget( + patientPrescriptionsList: + patientsProv.patientPrescriptionsList, ), ); } diff --git a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart new file mode 100644 index 00000000..75eef63c --- /dev/null +++ b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart @@ -0,0 +1,82 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'large_avatar.dart'; + +class PrescriptionInPatientWidget extends StatelessWidget { + final List prescriptionReportForInPatientList; + + PrescriptionInPatientWidget( + {Key key, this.prescriptionReportForInPatientList}); + + @override + Widget build(BuildContext context) { + return Container( + child: prescriptionReportForInPatientList.length == 0 + ? DrAppEmbeddedError(error: 'You don\'t have any Prescriptions') + : Container( + margin: EdgeInsets.fromLTRB(SizeConfig.realScreenWidth * 0.05, 0, + SizeConfig.realScreenWidth * 0.05, 0), + child: ListView.builder( + itemCount: prescriptionReportForInPatientList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () {}, + child: CardWithBgWidgetNew( + widget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + LargeAvatar( + name: + prescriptionReportForInPatientList[index] + .createdByName, + radius: 10, + width: 70, + ), + Expanded( + child: Container( + margin: + EdgeInsets.only(left: 15, right: 15), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + '${prescriptionReportForInPatientList[index].createdByName}', + fontSize: + 2.5 * SizeConfig.textMultiplier, + ), + SizedBox( + height: 8, + ), + AppText( + '${prescriptionReportForInPatientList[index].itemDescription}', + fontSize: + 2.5 * SizeConfig.textMultiplier, + color: + Theme.of(context).primaryColor), + SizedBox( + height: 8, + ), + ], + ), + ), + ) + ], + ), + ], + ), + )); + }, + ), + ), + ); + } +} diff --git a/lib/widgets/patients/profile/prescription_out_patinets_widget.dart b/lib/widgets/patients/profile/prescription_out_patinets_widget.dart new file mode 100644 index 00000000..b4c75120 --- /dev/null +++ b/lib/widgets/patients/profile/prescription_out_patinets_widget.dart @@ -0,0 +1,82 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'large_avatar.dart'; + +class PrescriptionOutPatientWidget extends StatelessWidget { + final List patientPrescriptionsList; + + PrescriptionOutPatientWidget({Key key, this.patientPrescriptionsList}); + + @override + Widget build(BuildContext context) { + return Container( + child: patientPrescriptionsList.length == 0 + ? DrAppEmbeddedError(error: 'You don\'t have any Prescriptions') + : Container( + margin: EdgeInsets.fromLTRB(SizeConfig.realScreenWidth * 0.05, 0, + SizeConfig.realScreenWidth * 0.05, 0), + child: ListView.builder( + itemCount: patientPrescriptionsList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () {}, + child: CardWithBgWidgetNew( + widget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + LargeAvatar( + url: patientPrescriptionsList[index] + .doctorImageURL, + name: patientPrescriptionsList[index] + .doctorName, + radius: 10, + width: 70, + ), + Expanded( + child: Container( + margin: + EdgeInsets.only(left: 15, right: 15), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + '${patientPrescriptionsList[index].name}', + fontSize: + 2.5 * SizeConfig.textMultiplier, + ), + SizedBox( + height: 8, + ), + AppText( + '${patientPrescriptionsList[index].clinicDescription}', + fontSize: + 2.5 * SizeConfig.textMultiplier, + color: + Theme.of(context).primaryColor), + SizedBox( + height: 8, + ), + ], + ), + ), + ) + ], + ), + ], + ), + )); + }, + ), + ), + ); + } +} From 610ae3c1fb8bc2f43d0d0751db6323f4ffcf9af2 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 8 Jun 2020 16:51:34 +0300 Subject: [PATCH 02/42] add in patient prescription details screen --- .../prescription_report_for_in_patient.dart | 14 +- lib/providers/patients_provider.dart | 1 + lib/routes.dart | 6 +- lib/screens/auth/verify_account_screen.dart | 2 - ...n_patient_prescription_details_screen.dart | 200 ++++++++++++++++++ .../prescription_in_patinets_widget.dart | 7 +- 6 files changed, 220 insertions(+), 10 deletions(-) create mode 100644 lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart diff --git a/lib/models/patient/prescription_report_for_in_patient.dart b/lib/models/patient/prescription_report_for_in_patient.dart index d4452e32..9b88279e 100644 --- a/lib/models/patient/prescription_report_for_in_patient.dart +++ b/lib/models/patient/prescription_report_for_in_patient.dart @@ -1,3 +1,5 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; + class PrescriptionReportForInPatient { int admissionNo; int authorizedBy; @@ -25,7 +27,7 @@ class PrescriptionReportForInPatient { int orderNo; int patientID; String pharmacyRemarks; - String prescriptionDatetime; + DateTime prescriptionDatetime; int prescriptionNo; String processedBy; int projectID; @@ -38,11 +40,11 @@ class PrescriptionReportForInPatient { int routeId; Null routeN; Null setupID; - String startDatetime; + DateTime startDatetime; int status; String statusDescription; Null statusDescriptionN; - String stopDatetime; + DateTime stopDatetime; int unitofMeasurement; String unitofMeasurementDescription; Null unitofMeasurementDescriptionN; @@ -123,7 +125,7 @@ class PrescriptionReportForInPatient { orderNo = json['OrderNo']; patientID = json['PatientID']; pharmacyRemarks = json['PharmacyRemarks']; - prescriptionDatetime = json['PrescriptionDatetime']; + prescriptionDatetime = Helpers.convertStringToDate(json['PrescriptionDatetime']); prescriptionNo = json['PrescriptionNo']; processedBy = json['ProcessedBy']; projectID = json['ProjectID']; @@ -136,11 +138,11 @@ class PrescriptionReportForInPatient { routeId = json['RouteId']; routeN = json['RouteN']; setupID = json['SetupID']; - startDatetime = json['StartDatetime']; + startDatetime = Helpers.convertStringToDate(json['StartDatetime']) ; status = json['Status']; statusDescription = json['StatusDescription']; statusDescriptionN = json['StatusDescriptionN']; - stopDatetime = json['StopDatetime']; + stopDatetime = Helpers.convertStringToDate(json['StopDatetime']); unitofMeasurement = json['UnitofMeasurement']; unitofMeasurementDescription = json['UnitofMeasurementDescription']; unitofMeasurementDescriptionN = json['UnitofMeasurementDescriptionN']; diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 9bf8d34b..99b5f607 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -273,6 +273,7 @@ class PatientsProvider with ChangeNotifier { isLoading = false; }, onFailure: (String error, int statusCode) { isError = true; + isLoading = false; this.error = error; }, body: patient); notifyListeners(); diff --git a/lib/routes.dart b/lib/routes.dart index a24cfe52..b90a7e58 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,4 +1,6 @@ +import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart'; + import './screens/QR_reader_screen.dart'; import './screens/auth/change_password_screen.dart'; import './screens/auth/login_screen.dart'; @@ -58,6 +60,7 @@ const String PATIENT_ORDERS = 'patients/patient_orders'; const String PATIENT_INSURANCE_APPROVALS = 'patients/patient_insurance_approvals'; const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; const String BODY_MEASUREMENTS = 'patients/body-measurements'; +const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; var routes = { HOME: (_) => LandingPage(), @@ -89,5 +92,6 @@ var routes = { PATIENT_ORDERS: (_) => PatientsOrdersScreen(), PATIENT_INSURANCE_APPROVALS: (_) => InsuranceApprovalsScreen(), VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), - BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen() + BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen(), + IN_PATIENT_PRESCRIPTIONS_DETAILS:(_)=> InpatientPrescriptionDetailsScreen() }; diff --git a/lib/screens/auth/verify_account_screen.dart b/lib/screens/auth/verify_account_screen.dart index 61d58306..b7eee5df 100644 --- a/lib/screens/auth/verify_account_screen.dart +++ b/lib/screens/auth/verify_account_screen.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:flutter/material.dart'; import '../../lookups/auth_lookup.dart'; diff --git a/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart b/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart new file mode 100644 index 00000000..30a57b15 --- /dev/null +++ b/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart @@ -0,0 +1,200 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; +import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class InpatientPrescriptionDetailsScreen extends StatefulWidget { + @override + _InpatientPrescriptionDetailsScreenState createState() => + _InpatientPrescriptionDetailsScreenState(); +} + +class _InpatientPrescriptionDetailsScreenState + extends State { + bool _showDetails = false; + bool _isLoading = false; + final _formKey = GlobalKey(); + String error; + TextEditingController answerController; + bool _isInit = true; + PrescriptionReportForInPatient prescription; + + @override + void initState() { +// answerController = new TextEditingController(text: widget.myReferralPatientModel.referredDoctorRemarks ?? ''); + super.initState(); + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + prescription = routeArgs['prescription']; + } + _isInit = false; + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: 'perscription info', + body: CardWithBgWidgetNew( + widget: Container( + child: ListView( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + prescription.itemDescription, + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down)), + ], + ), + !_showDetails + ? Container() + : AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 5, + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + Table( + border: TableBorder.symmetric( + inside: BorderSide(width: 0.5), + ), + children: [ + buildTableRow( + des: '${prescription.direction}', + key: 'Direction'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Refill'), + buildTableRow( + des: '${prescription.dose}', + key: 'Dose'), + buildTableRow( + des: '${prescription.unitofMeasurement}', + key: 'UOM'), + buildTableRow( + des: '${Helpers.getDate(prescription.startDatetime) }', + key: 'Start Date'), + buildTableRow( + des: '${Helpers.getDate(prescription.stopDatetime)}', + key: 'Stop Date'), + buildTableRow( + des: '${prescription.noOfDoses}', + key: 'No of Doses'), + buildTableRow( + des: '${prescription.route}', + key: 'Route'), + buildTableRow( + des: '${prescription.comments}', + key: 'Comments'), + buildTableRow( + des: '${prescription.pharmacyRemarks}', + key: 'Pharmacy Remarks'), + buildTableRow( + des: '${Helpers.getDate(prescription.prescriptionDatetime)}', + key: 'Prescription Date'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Status'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Created By'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Processed By'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Authorized By'), + ], + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + SizedBox( + height: 5, + ), + ], + ), + ) + ], + ), + ), + ), + ); + } + + TableRow buildTableRow({des, key}) { + print('$key: $des'); + return TableRow(children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Row( + children: [ + Expanded( + child: Container( + child: AppText( + key, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + ), + ), + Expanded( + child: Container( + margin: + EdgeInsets.only(left: 4, top: 2.5, right: 2.5, bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + AppText( + '${des}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + textAlign: TextAlign.center, + ) + ], + ), + ), + ), + ], + ), + ), + ]); + } +} diff --git a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart index 75eef63c..cafa6290 100644 --- a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart +++ b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; @@ -26,7 +27,11 @@ class PrescriptionInPatientWidget extends StatelessWidget { itemCount: prescriptionReportForInPatientList.length, itemBuilder: (BuildContext context, int index) { return InkWell( - onTap: () {}, + onTap: () { + Navigator.of(context).pushNamed(IN_PATIENT_PRESCRIPTIONS_DETAILS, arguments: { + 'prescription': prescriptionReportForInPatientList[index] + }); + }, child: CardWithBgWidgetNew( widget: Column( crossAxisAlignment: CrossAxisAlignment.start, From 39cc4fa4bf1dc6983ecce732a60b0c3deb5004cd Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 8 Jun 2020 18:26:16 +0300 Subject: [PATCH 03/42] refere to doctor --- .vscode/settings.json | 2 +- lib/config/config.dart | 4 + .../get_clinic_by_project_id_request.dart | 80 +++++ .../get_doctor_by_clinic_id_request.dart | 86 +++++ ...t_list_stp_referral_frequency_request.dart | 75 +++++ .../patient/refer_to_doctor_request.dart | 147 +++++++++ .../pharmacies_items_request_model.dart | 80 +++-- lib/providers/medicine_provider.dart | 2 +- lib/providers/patients_provider.dart | 301 +++++++++++++++--- lib/routes.dart | 3 + .../profile/refer_patient_screen.dart | 269 ++++++++++++++++ .../profile/profile_medical_info_widget.dart | 2 +- 12 files changed, 971 insertions(+), 80 deletions(-) create mode 100644 lib/models/patient/get_clinic_by_project_id_request.dart create mode 100644 lib/models/patient/get_doctor_by_clinic_id_request.dart create mode 100644 lib/models/patient/get_list_stp_referral_frequency_request.dart create mode 100644 lib/models/patient/refer_to_doctor_request.dart create mode 100644 lib/screens/patients/profile/refer_patient_screen.dart diff --git a/.vscode/settings.json b/.vscode/settings.json index e592e48b..045932f0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "commentBox.styles": { "defaultStyle": { - "commentStartToken": "/* \n *@author: Amjad Amireh \n *@Date:27/4/2020 \n *@param: \n *@return:\n *@desc: ", + "commentStartToken": "/* \n *@author: Ibrahim Albitar \n *@Date:03/06/2020 \n *@param: \n *@return:\n *@desc: ", "commentEndToken": "\n */", "leftEdgeToken": " * ", "rightEdgeToken": "", diff --git a/lib/config/config.dart b/lib/config/config.dart index 6f094704..4f3a5770 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -9,6 +9,10 @@ const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; const PATIENT_INSURANCE_APPROVALS_URL = "DoctorApplication.svc/REST/GetApprovalStatusForInpatient"; const PATIENT_ORDERS_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; +const PATIENT_REFER_TO_DOCTOR_URL = "DoctorApplication.svc/REST/ReferToDoctor"; +const PATIENT_GET_DOCTOR_BY_CLINIC_URL = "DoctorApplication.svc/REST/GetDoctorsByClinicID"; +const PATIENT_GET_LIST_REFERAL_URL = "Lists.svc/REST/GetList_STPReferralFrequency"; +const PATIENT_GET_CLINIC_BY_PROJECT_URL = "DoctorApplication.svc/REST/GetClinicsByProjectID"; const GET_PROJECTS = 'Lists.svc/REST/GetProjectForDoctorAPP'; const GET_PATIENT_VITAL_SIGN = 'Doctors.svc/REST/Doctor_GetPatientVitalSign'; diff --git a/lib/models/patient/get_clinic_by_project_id_request.dart b/lib/models/patient/get_clinic_by_project_id_request.dart new file mode 100644 index 00000000..862fbab4 --- /dev/null +++ b/lib/models/patient/get_clinic_by_project_id_request.dart @@ -0,0 +1,80 @@ +class ClinicByProjectIdRequest { + + /* + *@author: Ibrahim Albitar + *@Date:03/06/2020 + *@param: + *@return: + *@desc: ClinicByProjectIdRequest + */ + + int projectID; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + int patientTypeID; + /* + { + "ProjectID": 21, + "LanguageID": 2, + "stamp": "2020-06-03T11:18:19.979Z", + "IPAdress": "11.11.11.11", + "VersionID": 1.2, + "Channel": 9, + "TokenID": "gyIQFH4WWEm2Tq7xjYMjsg==", + "SessionID": "JBXRsDl37L", + "IsLoginForDoctorApp": true, + "PatientOutSA": false, + "PatientTypeID": 1 +} + */ + + ClinicByProjectIdRequest( + {this.projectID, + this.languageID = 2, + this.stamp = "2020-06-03T11:18:19.979Z", + this.iPAdress = "11.11.11.11", + this.versionID = 1.2, + this.channel = 9, + this.tokenID, + this.sessionID = "JBXRsDl37L", + this.isLoginForDoctorApp = true, + this.patientOutSA = false, + this.patientTypeID = 1}); + + ClinicByProjectIdRequest.fromJson(Map json) { + projectID = json['ProjectID']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + patientTypeID = json['PatientTypeID']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + data['PatientTypeID'] = this.patientTypeID; + return data; + } +} diff --git a/lib/models/patient/get_doctor_by_clinic_id_request.dart b/lib/models/patient/get_doctor_by_clinic_id_request.dart new file mode 100644 index 00000000..a2b33e29 --- /dev/null +++ b/lib/models/patient/get_doctor_by_clinic_id_request.dart @@ -0,0 +1,86 @@ +class DoctorsByClinicIdRequest { + +/* + *@author: Ibrahim Albitar + *@Date:03/06/2020 + *@param: + *@return: + *@desc: DoctorsByClinicIdRequest + */ + + int projectID; + String clinicID; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + int patientTypeID; + + /* + { + "ProjectID": 21, + "ClinicID": "0", + "LanguageID": 2, + "stamp": "2020-06-03T11:22:04.702Z", + "IPAdress": "11.11.11.11", + "VersionID": 1.2, + "Channel": 9, + "TokenID": "gyIQFH4WWEm2Tq7xjYMjsg==", + "SessionID": "JBXRsDl37L", + "IsLoginForDoctorApp": true, + "PatientOutSA": false, + "PatientTypeID": 1 +} + */ + + DoctorsByClinicIdRequest( + {this.projectID, + this.clinicID, + this.languageID = 2, + this.stamp = "2020-06-03T11:22:04.702Z", + this.iPAdress = "11.11.11.11", + this.versionID = 1.2, + this.channel = 9, + this.tokenID, + this.sessionID = "JBXRsDl37L", + this.isLoginForDoctorApp = true, + this.patientOutSA = false, + this.patientTypeID = 1}); + + DoctorsByClinicIdRequest.fromJson(Map json) { + projectID = json['ProjectID']; + clinicID = json['ClinicID']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + patientTypeID = json['PatientTypeID']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['ClinicID'] = this.clinicID; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + data['PatientTypeID'] = this.patientTypeID; + return data; + } +} diff --git a/lib/models/patient/get_list_stp_referral_frequency_request.dart b/lib/models/patient/get_list_stp_referral_frequency_request.dart new file mode 100644 index 00000000..3b3c2655 --- /dev/null +++ b/lib/models/patient/get_list_stp_referral_frequency_request.dart @@ -0,0 +1,75 @@ +class STPReferralFrequencyRequest { + +/* + *@author: Ibrahim Albitar + *@Date:03/06/2020 + *@param: + *@return: + *@desc: + */ + + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + int patientTypeID; + /* +{ + "LanguageID": 2, + "stamp": "2020-06-03T11:18:19.986Z", + "IPAdress": "11.11.11.11", + "VersionID": 1.2, + "Channel": 9, + "TokenID": "gyIQFH4WWEm2Tq7xjYMjsg==", + "SessionID": "JBXRsDl37L", + "IsLoginForDoctorApp": true, + "PatientOutSA": false, + "PatientTypeID": 1 +} + */ + + STPReferralFrequencyRequest( + {this.languageID = 2, + this.stamp = "2020-06-03T11:18:19.986Z", + this.iPAdress = "11.11.11.11", + this.versionID = 1.2, + this.channel = 9, + this.tokenID, + this.sessionID = "JBXRsDl37L", + this.isLoginForDoctorApp = true, + this.patientOutSA = false, + this.patientTypeID = 1}); + + STPReferralFrequencyRequest.fromJson(Map json) { + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + patientTypeID = json['PatientTypeID']; + } + + Map toJson() { + final Map data = new Map(); + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + data['PatientTypeID'] = this.patientTypeID; + return data; + } +} diff --git a/lib/models/patient/refer_to_doctor_request.dart b/lib/models/patient/refer_to_doctor_request.dart new file mode 100644 index 00000000..11229596 --- /dev/null +++ b/lib/models/patient/refer_to_doctor_request.dart @@ -0,0 +1,147 @@ +class ReferToDoctorRequest { + +/* + *@author: Ibrahim Albitar + *@Date:03/06/2020 + *@param: + *@return: + *@desc: ReferToDoctor + */ + + int projectID; + int admissionNo; + String roomID; + String referralClinic; + String referralDoctor; + int createdBy; + int editedBy; + int patientID; + int patientTypeID; + int referringClinic; + int referringDoctor; + String referringDoctorRemarks; + String priority; + String frequency; + String extension; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + + + /* +{ + "ProjectID": 21, + "AdmissionNo": 2020005477, + "RoomID": "ISO-6", + "ReferralClinic": "36", + "ReferralDoctor": "230893", + "CreatedBy": 121814, + "EditedBy": 121814, + "PatientID": 3349491, + "PatientTypeID": 1, + "ReferringClinic": 14, + "ReferringDoctor": 121814, + "ReferringDoctorRemarks": "dfcdfdfdf", + "Priority": "1", + "Frequency": "1", + "Extension": "eeee", + "LanguageID": 2, + "stamp": "2020-06-03T11:26:42.358Z", + "IPAdress": "11.11.11.11", + "VersionID": 1.2, + "Channel": 9, + "TokenID": "gyIQFH4WWEm2Tq7xjYMjsg==", + "SessionID": "JBXRsDl37L", + "IsLoginForDoctorApp": true, + "PatientOutSA": false +} + */ + + ReferToDoctorRequest( + {this.projectID, + this.admissionNo, + this.roomID = "ISO-6", + this.referralClinic, + this.referralDoctor , + this.createdBy, + this.editedBy , + this.patientID, + this.patientTypeID = 1, + this.referringClinic, + this.referringDoctor, + this.referringDoctorRemarks, + this.priority , + this.frequency, + this.extension, + this.languageID = 2, + this.stamp = "2020-06-03T11:26:42.358Z", + this.iPAdress = "11.11.11.11", + this.versionID = 1.2, + this.channel = 9, + this.tokenID, + this.sessionID = "JBXRsDl37L", + this.isLoginForDoctorApp = true, + this.patientOutSA = false}); + + ReferToDoctorRequest.fromJson(Map json) { + projectID = json['ProjectID']; + admissionNo = json['AdmissionNo']; + roomID = json['RoomID']; + referralClinic = json['ReferralClinic']; + referralDoctor = json['ReferralDoctor']; + createdBy = json['CreatedBy']; + editedBy = json['EditedBy']; + patientID = json['PatientID']; + patientTypeID = json['PatientTypeID']; + referringClinic = json['ReferringClinic']; + referringDoctor = json['ReferringDoctor']; + referringDoctorRemarks = json['ReferringDoctorRemarks']; + priority = json['Priority']; + frequency = json['Frequency']; + extension = json['Extension']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['AdmissionNo'] = this.admissionNo; + data['RoomID'] = this.roomID; + data['ReferralClinic'] = this.referralClinic; + data['ReferralDoctor'] = this.referralDoctor; + data['CreatedBy'] = this.createdBy; + data['EditedBy'] = this.editedBy; + data['PatientID'] = this.patientID; + data['PatientTypeID'] = this.patientTypeID; + data['ReferringClinic'] = this.referringClinic; + data['ReferringDoctor'] = this.referringDoctor; + data['ReferringDoctorRemarks'] = this.referringDoctorRemarks; + data['Priority'] = this.priority; + data['Frequency'] = this.frequency; + data['Extension'] = this.extension; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/models/pharmacies_items_request_model.dart b/lib/models/pharmacies_items_request_model.dart index f9531e63..96df6da8 100644 --- a/lib/models/pharmacies_items_request_model.dart +++ b/lib/models/pharmacies_items_request_model.dart @@ -5,55 +5,65 @@ *@return: *@desc: */ + + class PharmaciesItemsRequestModel { - String phrItemName; - int languageID; - String stamp; - String ipAdress; - double versionID; - String tokenID; - String sessionID; - bool isLoginForDoctorApp; - bool patientOutSA; - int patientTypeID; + String pHRItemName; + int pageIndex = 0; + int pageSize = 20; + double versionID = 5.2; + int channel = 3; + int languageID = 2; + String iPAdress = "10.20.10.20"; + String generalid = "Cs2020@2016\$2958"; + int patientOutSA = 0; + String sessionID = "KvFJENeAUCxyVdIfEkHw"; + bool isDentalAllowedBackend = false; + int deviceTypeID = 2; PharmaciesItemsRequestModel( - {this.phrItemName = '', - this.patientTypeID = 1, - this.languageID = 2, - this.stamp = '2020-04-23T21:01:21.492Z', - this.ipAdress = '10.20.10.20', + {this.pHRItemName, + this.pageIndex = 0, + this.pageSize = 20, this.versionID = 5.2, - this.tokenID , + this.channel = 3, + this.languageID = 2, + this.iPAdress = "10.20.10.20", + this.generalid = "Cs2020@2016\$2958", + this.patientOutSA = 0, this.sessionID = "KvFJENeAUCxyVdIfEkHw", - this.isLoginForDoctorApp = true, - this.patientOutSA = false}); + this.isDentalAllowedBackend = false, + this.deviceTypeID = 2}); PharmaciesItemsRequestModel.fromJson(Map json) { - phrItemName = json['PHR_itemName']; - patientTypeID = json['PatientTypeID']; - languageID = json['LanguageID']; - stamp = json['stamp']; - ipAdress = json['IPAdress']; + pHRItemName = json['PHR_itemName']; + pageIndex = json['PageIndex']; + pageSize = json['PageSize']; versionID = json['VersionID']; - tokenID = json['TokenID']; - sessionID = json['SessionID']; - isLoginForDoctorApp = json['IsLoginForDoctorApp']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; } Map toJson() { final Map data = new Map(); - data['PHR_itemName'] = this.phrItemName; - data['PatientTypeID'] = this.patientTypeID; - data['LanguageID'] = this.languageID; - data['stamp'] = this.stamp; - data['IPAdress'] = this.ipAdress; + data['PHR_itemName'] = this.pHRItemName; + data['PageIndex'] = this.pageIndex; + data['PageSize'] = this.pageSize; data['VersionID'] = this.versionID; - data['TokenID'] = this.tokenID; - data['SessionID'] = this.sessionID; - data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; return data; } -} +} \ No newline at end of file diff --git a/lib/providers/medicine_provider.dart b/lib/providers/medicine_provider.dart index 97e030fe..a0d8f4ed 100644 --- a/lib/providers/medicine_provider.dart +++ b/lib/providers/medicine_provider.dart @@ -25,7 +25,7 @@ class MedicineProvider with ChangeNotifier { resetDefaultValues(); try { if (await Helpers.checkConnection()) { - _itemsRequestModel.phrItemName = itemName; + _itemsRequestModel.pHRItemName = itemName; final response = await AppClient.post(PHARMACY_ITEMS_URL, body: json.encode(_itemsRequestModel.toJson())); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 8b84420a..25e640ec 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -2,12 +2,18 @@ import 'dart:convert'; import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart'; +import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart'; +import 'package:doctor_app_flutter/models/patient/get_list_stp_referral_frequency_request.dart'; import 'package:doctor_app_flutter/models/patient/lab_orders_res_model.dart'; import 'package:doctor_app_flutter/models/patient/lab_result.dart'; import 'package:doctor_app_flutter/models/patient/lab_result_req_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; +import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart'; import 'package:http_interceptor/http_client_with_interceptor.dart'; @@ -35,7 +41,6 @@ class PatientsProvider with ChangeNotifier { List patientPrescriptionsList = []; List patientRadiologyList = []; - /*@author: ibrahe albitar *@Date:2/6/2020 *@desc: getPatientPrescriptions @@ -46,8 +51,20 @@ class PatientsProvider with ChangeNotifier { var patientProgressNoteList = []; var insuranceApporvalsList = []; + var doctorsList = []; + var clinicsList = []; + var referalFrequancyList = []; + + DoctorsByClinicIdRequest _doctorsByClinicIdRequest = + DoctorsByClinicIdRequest(); + STPReferralFrequencyRequest _referralFrequencyRequest = + STPReferralFrequencyRequest(); + ClinicByProjectIdRequest _clinicByProjectIdRequest = + ClinicByProjectIdRequest(); + ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); + Client client = - HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); + HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); PatiantInformtion _selectedPatient; @@ -220,7 +237,7 @@ class PatientsProvider with ChangeNotifier { try { if (await Helpers.checkConnection()) { final response = - await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); + await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -279,7 +296,7 @@ class PatientsProvider with ChangeNotifier { try { if (await Helpers.checkConnection()) { final response = - await AppClient.post(GET_RADIOLOGY, body: json.encode(patient)); + await AppClient.post(GET_RADIOLOGY, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -310,7 +327,6 @@ class PatientsProvider with ChangeNotifier { } } - getLabResult(LabOrdersResModel labOrdersResModel) async { labResultList.clear(); isLoading = true; @@ -320,15 +336,14 @@ class PatientsProvider with ChangeNotifier { requestLabResult.orderNo = labOrdersResModel.orderNo; requestLabResult.invoiceNo = labOrdersResModel.invoiceNo; requestLabResult.patientTypeID = labOrdersResModel.patientType; - await BaseAppClient.post( - 'DoctorApplication.svc/REST/GetPatientLabResults', + await BaseAppClient.post('DoctorApplication.svc/REST/GetPatientLabResults', onSuccess: (dynamic response, int statusCode) { - isError = false; - isLoading = false; - response['List_GetLabNormal'].forEach((v) { - labResultList.add(new LabResult.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { + isError = false; + isLoading = false; + response['List_GetLabNormal'].forEach((v) { + labResultList.add(new LabResult.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { isError = true; isLoading = false; this.error = error; @@ -336,13 +351,12 @@ class PatientsProvider with ChangeNotifier { notifyListeners(); } - getPatientInsuranceApprovals(patient) async { setBasicData(); try { if (await Helpers.checkConnection()) { - final response = await AppClient.post( - PATIENT_INSURANCE_APPROVALS_URL, body: json.encode(patient)); + final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL, + body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -371,44 +385,247 @@ class PatientsProvider with ChangeNotifier { } } -/*@author: ibrahe albitar +/*@author: ibrahem albitar *@Date:2/6/2020 - *@desc: getPatientPrescriptions + *@desc: getPatientProgressNote */ getPatientProgressNote(patient) async { - setBasicData(); - try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; + setBasicData(); + try { + if (await Helpers.checkConnection()) { + final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL, + body: json.encode(patient)); + final int statusCode = response.statusCode; + isLoading = false; + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientProgressNoteList = res['List_GetPregressNoteForInPatient']; } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - patientProgressNoteList = res['List_GetPregressNoteForInPatient']; - } else { - isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; } + } + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; + } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); + } + } + + /*@author: ibrahem albitar + *@Date:3/6/2020 + *@desc: getDoctorsList + */ + getDoctorsList(String clinicId) async { + String token = await sharedPref.getString(TOKEN); + int projectID = await sharedPref.getInt(PROJECT_ID); + setBasicData(); + try { + if (await Helpers.checkConnection()) { + _doctorsByClinicIdRequest.projectID = projectID; + _doctorsByClinicIdRequest.clinicID = clinicId; + _doctorsByClinicIdRequest.tokenID = token; + + final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, + body: json.encode(_doctorsByClinicIdRequest)); + final int statusCode = response.statusCode; + isLoading = false; + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; } else { - isLoading = false; + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + doctorsList = res['List_Doctors_All']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; + } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); + } + } + + List getDoctorNameList() { + var doctorNamelist = + doctorsList.map((value) => value['DoctorName'].toString()).toList(); + return doctorNamelist; + } + + /*@author: ibrahem albitar + *@Date:3/6/2020 + *@desc: getClinicsList + */ + getClinicsList() async { + String token = await sharedPref.getString(TOKEN); + setBasicData(); + try { + if (await Helpers.checkConnection()) { + int projectID = await sharedPref.getInt(PROJECT_ID); + _clinicByProjectIdRequest.projectID = projectID; + _clinicByProjectIdRequest.tokenID = token; + + final response = await AppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, + body: json.encode(_clinicByProjectIdRequest)); + final int statusCode = response.statusCode; + isLoading = false; + + if (statusCode < 200 || statusCode >= 400 || json == null) { isError = true; - error = 'Please Check The Internet Connection'; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + clinicsList = res['List_Clinic_All']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } } - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); } + } + List getClinicNameList() { + var clinicsNameslist = clinicsList + .map((value) => value['ClinicDescription'].toString()) + .toList(); + return clinicsNameslist; + } + + /*@author: ibrahem albitar + *@Date:3/6/2020 + *@desc: getReferralFrequancyList + */ + getReferralFrequancyList() async { + String token = await sharedPref.getString(TOKEN); + setBasicData(); + try { + if (await Helpers.checkConnection()) { + _referralFrequencyRequest.tokenID = token; + final response = await AppClient.post(PATIENT_GET_LIST_REFERAL_URL, + body: json.encode(_referralFrequencyRequest)); + final int statusCode = response.statusCode; + isLoading = false; + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + referalFrequancyList = res['list_STPReferralFrequency']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; + } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); + } + } + List getReferralNamesList() { + var referralNamesList = referalFrequancyList + .map((value) => value['Description'].toString()) + .toList(); + return referralNamesList; + } + /*@author: ibrahem albitar + *@Date:3/6/2020 + *@desc: referToDoctor + */ + referToDoctor( + int selectedDoctorID, + int selectedClinicID, + String selectedReferralFrequancyID, + int admissionNo, + String extension, + String doctorRemark) async { + String token = await sharedPref.getString(TOKEN); + int projectID = await sharedPref.getInt(PROJECT_ID); + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); + int doctorID = doctorProfile.doctorID; + int clinicId = doctorProfile.clinicID; + setBasicData(); + try { + if (await Helpers.checkConnection()) { + // _referToDoctorRequest.tokenID = token; + // _referToDoctorRequest.admissionNo = admissionNo; + // _referToDoctorRequest.projectID = projectID; + // _referToDoctorRequest.tokenID = token; + // _referToDoctorRequest.extension = extension; + // _referToDoctorRequest.frequency = selectedReferralFrequancyID; + // _referToDoctorRequest.patientID = + // _referToDoctorRequest.priority = + // _referToDoctorRequest.referralClinic = + // _referToDoctorRequest.referralDoctor = + // _referToDoctorRequest.referringDoctorRemarks = + // _referToDoctorRequest.roomID = + // _referToDoctorRequest.referringClinic = + // _referToDoctorRequest.referringDoctor = + + final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, + body: json.encode(_referralFrequencyRequest)); + final int statusCode = response.statusCode; + isLoading = false; + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientProgressNoteList = res['List_GetPregressNoteForInPatient']; + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; + } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); + } + } } diff --git a/lib/routes.dart b/lib/routes.dart index 9c87ff2f..9ef1237a 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/screens/patients/profile/insurance_approvals_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/patient_orders_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/progress_note_screen.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/refer_patient_screen.dart'; import './screens/patients/profile/vital_sign/body_measurements_screen.dart'; @@ -56,6 +57,7 @@ const String LAB_ORDERS = 'patients/lab_orders'; const String PRESCRIPTIONS = 'patients/prescription'; const String RADIOLOGY = 'patients/radiology'; const String PROGRESS_NOTE = 'patients/progress-note'; +const String REFER_PATIENT = 'patients/refer-patient'; const String PATIENT_ORDERS = 'patients/patient_orders'; const String PATIENT_INSURANCE_APPROVALS = 'patients/patient_insurance_approvals'; const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; @@ -88,6 +90,7 @@ var routes = { PRESCRIPTIONS: (_) => PrescriptionScreen(), RADIOLOGY: (_) => RadiologyScreen(), PROGRESS_NOTE: (_) => ProgressNoteScreen(), + REFER_PATIENT: (_)=> ReferPatientScreen(), PATIENT_ORDERS: (_) => PatientsOrdersScreen(), PATIENT_INSURANCE_APPROVALS: (_) => InsuranceApprovalsScreen(), VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart new file mode 100644 index 00000000..6f489237 --- /dev/null +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -0,0 +1,269 @@ +import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; +import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import '../../../config/size_config.dart'; +import '../../../providers/patients_provider.dart'; +import '../../../util/dr_app_shared_pref.dart'; +import '../../../widgets/shared/app_scaffold_widget.dart'; +import '../../../widgets/shared/app_texts_widget.dart'; +import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; + +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + +/* + *@author: ibrahim albitar + *@Date:4/6/2020 + *@param: + *@return: + *@desc: + */ + +class ReferPatientScreen extends StatefulWidget { + @override + _ReferPatientState createState() => _ReferPatientState(); +} + +class _ReferPatientState extends State { + PatientsProvider patientsProv; + var doctorsList; + var clinicsList; + var referralFrequancyList; + final _controller = TextEditingController(); + var _isInit = true; + + String _selectedClinic; + String _selectedDoctor; + String _selectedReferralFrequancy; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + patientsProv = Provider.of(context); + patientsProv.getClinicsList(); + patientsProv.getReferralFrequancyList(); + setState(() { + clinicsList = patientsProv.clinicsList; + referralFrequancyList = patientsProv.referalFrequancyList; + }); + } + _isInit = false; + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: "Progress Note", + showAppDrawer: false, + showBottomBar: false, + body: patientsProv.isLoading + ? DrAppCircularProgressIndeicator() + : patientsProv.isError + ? DrAppEmbeddedError(error: patientsProv.error) + : clinicsList == null + ? DrAppEmbeddedError( + error: 'You don\'t have any Progress Note') + : Column( + children: [ + RoundedContainer( + margin: 0, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedClinic, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getClinicNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedDoctor = null; + _selectedClinic = newValue; + var clinicInfo = + clinicsList.singleWhere((i) => + i['ClinicDescription'] + .toString() + .contains(_selectedClinic)); + var clinicId = + clinicInfo['ClinicID'].toString(); + patientsProv.getDoctorsList(clinicId); + }) + }, + items: patientsProv + .getClinicNameList() + .map((item) { + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), + ); + }).toList(), + ), + ), + ], + ), + ), + ), + //--------------------------------------------------------------------// + RoundedContainer( + margin: 0, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedDoctor, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getDoctorNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedDoctor = newValue; + }) + }, + items: patientsProv + .getDoctorNameList() + .map((item) { + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), + ); + }).toList(), + ), + ), + ], + ), + ), + ), //-----------------------------/// + RoundedContainer( + margin: 0, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedReferralFrequancy, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getReferralNamesList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedReferralFrequancy = newValue; + }) + }, + items: patientsProv + .getReferralNamesList() + .map((item) { + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), + ); + }).toList(), + ), + ), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 657690be..89acca60 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -127,7 +127,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { visible: selectedPatientType != 0 && selectedPatientType != 5 && selectedPatientType != 2, child: InkWell( onTap: () { - navigator(context, PRESCRIPTIONS); + navigator(context, REFER_PATIENT); }, child: CircleAvatarWidget( des: 'Refer Patient ', From 76f8eba86e7da798212ddf408fb4bdea883c4a7f Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Tue, 9 Jun 2020 10:24:22 +0300 Subject: [PATCH 04/42] create Prescription In and Out Patient --- lib/models/prescription_report.dart | 140 ++++++++++ lib/models/request_prescription_report.dart | 68 +++++ lib/providers/patients_provider.dart | 30 ++- ...t_patient_prescription_details_screen.dart | 247 ++++++++++++++++++ .../prescription_out_patinets_widget.dart | 14 +- 5 files changed, 495 insertions(+), 4 deletions(-) create mode 100644 lib/models/prescription_report.dart create mode 100644 lib/models/request_prescription_report.dart create mode 100644 lib/screens/patients/out_patient_prescription_details_screen.dart diff --git a/lib/models/prescription_report.dart b/lib/models/prescription_report.dart new file mode 100644 index 00000000..05d28bdc --- /dev/null +++ b/lib/models/prescription_report.dart @@ -0,0 +1,140 @@ +class PrescriptionReport { + String address; + int appointmentNo; + String clinic; + String companyName; + int days; + String doctorName; + int doseDailyQuantity; + String frequency; + int frequencyNumber; + Null imageExtension; + Null imageSRCUrl; + Null imageString; + Null imageThumbUrl; + String isCovered; + String itemDescription; + int itemID; + String orderDate; + int patientID; + String patientName; + String phoneOffice1; + Null prescriptionQR; + int prescriptionTimes; + Null productImage; + String productImageBase64; + String productImageString; + int projectID; + String projectName; + String remarks; + String route; + String sKU; + int scaleOffset; + String startDate; + + PrescriptionReport( + {this.address, + this.appointmentNo, + this.clinic, + this.companyName, + this.days, + this.doctorName, + this.doseDailyQuantity, + this.frequency, + this.frequencyNumber, + this.imageExtension, + this.imageSRCUrl, + this.imageString, + this.imageThumbUrl, + this.isCovered, + this.itemDescription, + this.itemID, + this.orderDate, + this.patientID, + this.patientName, + this.phoneOffice1, + this.prescriptionQR, + this.prescriptionTimes, + this.productImage, + this.productImageBase64, + this.productImageString, + this.projectID, + this.projectName, + this.remarks, + this.route, + this.sKU, + this.scaleOffset, + this.startDate}); + + PrescriptionReport.fromJson(Map json) { + address = json['Address']; + appointmentNo = json['AppointmentNo']; + clinic = json['Clinic']; + companyName = json['CompanyName']; + days = json['Days']; + doctorName = json['DoctorName']; + doseDailyQuantity = json['DoseDailyQuantity']; + frequency = json['Frequency']; + frequencyNumber = json['FrequencyNumber']; + imageExtension = json['ImageExtension']; + imageSRCUrl = json['ImageSRCUrl']; + imageString = json['ImageString']; + imageThumbUrl = json['ImageThumbUrl']; + isCovered = json['IsCovered']; + itemDescription = json['ItemDescription']; + itemID = json['ItemID']; + orderDate = json['OrderDate']; + patientID = json['PatientID']; + patientName = json['PatientName']; + phoneOffice1 = json['PhoneOffice1']; + prescriptionQR = json['PrescriptionQR']; + prescriptionTimes = json['PrescriptionTimes']; + productImage = json['ProductImage']; + productImageBase64 = json['ProductImageBase64']; + productImageString = json['ProductImageString']; + projectID = json['ProjectID']; + projectName = json['ProjectName']; + remarks = json['Remarks']; + route = json['Route']; + sKU = json['SKU']; + scaleOffset = json['ScaleOffset']; + startDate = json['StartDate']; + } + + Map toJson() { + final Map data = new Map(); + data['Address'] = this.address; + data['AppointmentNo'] = this.appointmentNo; + data['Clinic'] = this.clinic; + data['CompanyName'] = this.companyName; + data['Days'] = this.days; + data['DoctorName'] = this.doctorName; + data['DoseDailyQuantity'] = this.doseDailyQuantity; + data['Frequency'] = this.frequency; + data['FrequencyNumber'] = this.frequencyNumber; + data['ImageExtension'] = this.imageExtension; + data['ImageSRCUrl'] = this.imageSRCUrl; + data['ImageString'] = this.imageString; + data['ImageThumbUrl'] = this.imageThumbUrl; + data['IsCovered'] = this.isCovered; + data['ItemDescription'] = this.itemDescription; + data['ItemID'] = this.itemID; + data['OrderDate'] = this.orderDate; + data['PatientID'] = this.patientID; + data['PatientName'] = this.patientName; + data['PhoneOffice1'] = this.phoneOffice1; + data['PrescriptionQR'] = this.prescriptionQR; + data['PrescriptionTimes'] = this.prescriptionTimes; + data['ProductImage'] = this.productImage; + data['ProductImageBase64'] = this.productImageBase64; + data['ProductImageString'] = this.productImageString; + data['ProjectID'] = this.projectID; + data['ProjectName'] = this.projectName; + data['Remarks'] = this.remarks; + data['Route'] = this.route; + data['SKU'] = this.sKU; + data['ScaleOffset'] = this.scaleOffset; + data['StartDate'] = this.startDate; + return data; + } +} diff --git a/lib/models/request_prescription_report.dart b/lib/models/request_prescription_report.dart new file mode 100644 index 00000000..0581692e --- /dev/null +++ b/lib/models/request_prescription_report.dart @@ -0,0 +1,68 @@ +class RequestPrescriptionReport { + int projectID; + int appointmentNo; + int episodeID; + String setupID; + int patientTypeID; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + + RequestPrescriptionReport( + {this.projectID, + this.appointmentNo, + this.episodeID, + this.setupID, + this.patientTypeID, + this.languageID, + this.stamp, + this.iPAdress, + this.versionID, + this.channel, + this.tokenID, + this.sessionID, + this.isLoginForDoctorApp, + this.patientOutSA}); + + RequestPrescriptionReport.fromJson(Map json) { + projectID = json['ProjectID']; + appointmentNo = json['AppointmentNo']; + episodeID = json['EpisodeID']; + setupID = json['SetupID']; + patientTypeID = json['PatientTypeID']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeID'] = this.episodeID; + data['SetupID'] = this.setupID; + data['PatientTypeID'] = this.patientTypeID; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 9bf8d34b..a3e665c1 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -9,6 +9,7 @@ import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; +import 'package:doctor_app_flutter/models/prescription_report.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart'; import 'package:http_interceptor/http_client_with_interceptor.dart'; @@ -36,6 +37,7 @@ class PatientsProvider with ChangeNotifier { List patientPrescriptionsList = []; List patientRadiologyList = []; List prescriptionReportForInPatientList = []; + List prescriptionReport = []; /*@author: ibrahe albitar *@Date:2/6/2020 @@ -48,7 +50,7 @@ class PatientsProvider with ChangeNotifier { var insuranceApporvalsList = []; Client client = - HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); + HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); PatiantInformtion _selectedPatient; @@ -219,7 +221,7 @@ class PatientsProvider with ChangeNotifier { try { if (await Helpers.checkConnection()) { final response = - await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); + await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -276,12 +278,34 @@ class PatientsProvider with ChangeNotifier { this.error = error; }, body: patient); notifyListeners(); - } catch (err) { handelCatchErrorCase(err); } } + getPrescriptionReport(prescriptionReqModel) async{ + prescriptionReport = []; + isLoading = true; + isError = false; + error = ""; + notifyListeners(); + await BaseAppClient.post( + 'Patients.svc/REST/GetPrescriptionReport', + onSuccess: (dynamic response, int statusCode) { + response['ListPRM'].forEach((v) { + prescriptionReport + .add(PrescriptionReport.fromJson(v)); + }); + isError = false; + isLoading = false; + }, onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error = error; + }, body: prescriptionReqModel); + notifyListeners(); + } + /*@author: Elham Rababah *@Date:12/5/2020 *@param: patient diff --git a/lib/screens/patients/out_patient_prescription_details_screen.dart b/lib/screens/patients/out_patient_prescription_details_screen.dart new file mode 100644 index 00000000..aa61f1fb --- /dev/null +++ b/lib/screens/patients/out_patient_prescription_details_screen.dart @@ -0,0 +1,247 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; +import 'package:doctor_app_flutter/models/prescription_report.dart'; +import 'package:doctor_app_flutter/models/request_prescription_report.dart'; +import 'package:doctor_app_flutter/providers/patients_provider.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class OutPatientPrescriptionDetailsScreen extends StatefulWidget { + final PrescriptionResModel prescriptionResModel; + + OutPatientPrescriptionDetailsScreen({Key key, this.prescriptionResModel}); + + @override + _OutPatientPrescriptionDetailsScreenState createState() => + _OutPatientPrescriptionDetailsScreenState(); +} + +class _OutPatientPrescriptionDetailsScreenState + extends State { + bool _isInit = true; + PatientsProvider patientsProvider; + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + patientsProvider = Provider.of(context); + + RequestPrescriptionReport prescriptionReqModel = + RequestPrescriptionReport( + appointmentNo: widget.prescriptionResModel.appointmentNo, + episodeID: widget.prescriptionResModel.episodeID, + setupID: widget.prescriptionResModel.setupID, + patientTypeID: widget.prescriptionResModel.patientID); + patientsProvider.getPrescriptionReport(prescriptionReqModel.toJson()); + } + _isInit = false; + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: 'Prescription Details', + body: patientsProvider.isLoading + ? DrAppCircularProgressIndeicator() + : patientsProvider.isError + ? DrAppEmbeddedError(error: patientsProvider.error) + : CardWithBgWidgetNew( + widget: ListView.builder( + itemCount: patientsProvider.prescriptionReport.length, + itemBuilder: (BuildContext context, int index) { + return OutPatientPrescriptionDetailsItem( + prescriptionReport: + patientsProvider.prescriptionReport[index], + ); + }), + ), + ); + } +} + +class OutPatientPrescriptionDetailsItem extends StatefulWidget { + final PrescriptionReport prescriptionReport; + + OutPatientPrescriptionDetailsItem({Key key, this.prescriptionReport}); + + @override + _OutPatientPrescriptionDetailsItemState createState() => + _OutPatientPrescriptionDetailsItemState(); +} + +class _OutPatientPrescriptionDetailsItemState + extends State { + bool _showDetails = false; + @override + Widget build(BuildContext context) { + return Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + flex: 5, + child: AppText( + '${widget.prescriptionReport.itemDescription} ', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down)), + ), + ], + ), + !_showDetails + ? Container() + : AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 5, + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + Table( + border: TableBorder.symmetric( + inside: BorderSide(width: 0.5), + ), + children: [ + TableRow(children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Route', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.prescriptionReport.route}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + margin: EdgeInsets.only( + left: 4, top: 2.5, right: 2.5, bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Frequency Timing', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + widget.prescriptionReport.frequency, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ]), + TableRow(children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Insurance Covered', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + margin: EdgeInsets.only( + left: 4, top: 2.5, right: 2.5, bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Duration Days', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.prescriptionReport.days}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ) + ]), + TableRow( + children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Doctor Remarks', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.prescriptionReport.remarks}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container() + ], + ), + ], + ), + ], + ), + ) + ], + ), + ); + } +} diff --git a/lib/widgets/patients/profile/prescription_out_patinets_widget.dart b/lib/widgets/patients/profile/prescription_out_patinets_widget.dart index b4c75120..bedd6427 100644 --- a/lib/widgets/patients/profile/prescription_out_patinets_widget.dart +++ b/lib/widgets/patients/profile/prescription_out_patinets_widget.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; +import 'package:doctor_app_flutter/screens/patients/out_patient_prescription_details_screen.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; @@ -25,7 +26,18 @@ class PrescriptionOutPatientWidget extends StatelessWidget { itemCount: patientPrescriptionsList.length, itemBuilder: (BuildContext context, int index) { return InkWell( - onTap: () {}, + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + OutPatientPrescriptionDetailsScreen( + prescriptionResModel: + patientPrescriptionsList[index], + ), + ), + ); + }, child: CardWithBgWidgetNew( widget: Column( crossAxisAlignment: CrossAxisAlignment.start, From 14527e19b1744e5cfe56fed5c7325cb273ff3e7d Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Tue, 9 Jun 2020 11:07:04 +0300 Subject: [PATCH 05/42] fix issues --- lib/screens/patients/profile/refer_patient_screen.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 6f489237..1781867c 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -55,8 +55,6 @@ class _ReferPatientState extends State { Widget build(BuildContext context) { return AppScaffold( appBarTitle: "Progress Note", - showAppDrawer: false, - showBottomBar: false, body: patientsProv.isLoading ? DrAppCircularProgressIndeicator() : patientsProv.isError From 57cba4e78686b685e222a8c79f1cbaa677519a66 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 9 Jun 2020 11:27:57 +0300 Subject: [PATCH 06/42] fix verfiy account --- lib/widgets/auth/show_timer_text.dart | 8 +++++--- lib/widgets/auth/verfiy_account.dart | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/widgets/auth/show_timer_text.dart b/lib/widgets/auth/show_timer_text.dart index 3ee67312..1b77fd9a 100644 --- a/lib/widgets/auth/show_timer_text.dart +++ b/lib/widgets/auth/show_timer_text.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/providers/auth_provider.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; +import 'package:doctor_app_flutter/routes.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; @@ -34,6 +35,8 @@ class _ShowTimerTextState extends State { setState(() { sec = sec - 1; if (sec == 0 && min == 0) { + Navigator.of(context).pushNamed(LOGIN); + min = 0; sec = 0; } else if (sec == 0) { @@ -72,11 +75,10 @@ class _ShowTimerTextState extends State { resendActivatioinCode(); }, child: Text( - min == 0 && sec == 0 ? 'Resend Login Code' : timerText, + timerText, style: TextStyle( fontSize: 3.0 * SizeConfig.textMultiplier, - color: - min == 0 && sec == 0 ? Colors.blue : Hexcolor('#B8382C'), + color: Hexcolor('#B8382C'), fontWeight: FontWeight.bold), ), ), diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 9a4ad85c..feae82ce 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -100,6 +100,7 @@ class _VerifyAccountState extends State { child: TextFormField( textInputAction: TextInputAction.next, style: buildTextStyle(), + autofocus: true, maxLength: 1, textAlign: TextAlign.center, keyboardType: TextInputType.number, From d3818bd3b3fd10cb1431b9f601c02574db5918c0 Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Tue, 9 Jun 2020 11:48:58 +0300 Subject: [PATCH 07/42] fix --- lib/widgets/patients/profile/profile_medical_info_widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 4bb0421d..28868afb 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -71,7 +71,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { PatientProfileButton( key: key, patient: patient, - route: PRESCRIPTIONS, + route: REFER_PATIENT, name: 'Refer Patient', icon: 'note.png'), PatientProfileButton( From 0c94188405aaabec4deda9e9e01c87ef264415d0 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Tue, 9 Jun 2020 14:47:24 +0300 Subject: [PATCH 08/42] Done Prescription Details Screen --- lib/providers/doctor_reply_provider.dart | 26 +-- ...t_patient_prescription_details_screen.dart | 182 +----------------- ...n_patient_prescription_details_screen.dart | 26 +-- ...out_patient_prescription_details_item.dart | 138 +++++++++++++ 4 files changed, 161 insertions(+), 211 deletions(-) create mode 100644 lib/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart diff --git a/lib/providers/doctor_reply_provider.dart b/lib/providers/doctor_reply_provider.dart index c7e48afa..493cb472 100644 --- a/lib/providers/doctor_reply_provider.dart +++ b/lib/providers/doctor_reply_provider.dart @@ -3,7 +3,6 @@ import 'package:doctor_app_flutter/models/request_doctor_reply.dart'; import 'package:doctor_app_flutter/models/list_gt_my_pationents_question_model.dart'; import 'package:flutter/cupertino.dart'; - class DoctorReplyProvider with ChangeNotifier { List listDoctorWorkingHoursTable = []; @@ -18,20 +17,21 @@ class DoctorReplyProvider with ChangeNotifier { getDoctorReply() async { try { - await BaseAppClient.post('DoctorApplication.svc/REST/GtMyPatientsQuestions', - body: _requestDoctorReply.toJson(), - onSuccess: (dynamic response, int statusCode) { - response['List_GtMyPatientsQuestions'].forEach((v) { - listDoctorWorkingHoursTable.add(ListGtMyPatientsQuestions.fromJson(v)); - isError = false; - isLoading = false; - }); - }, - onFailure: (String error, int statusCode) { - isError = true; + await BaseAppClient.post( + 'DoctorApplication.svc/REST/GtMyPatientsQuestions', + body: _requestDoctorReply.toJson(), + onSuccess: (dynamic response, int statusCode) { + response['List_GtMyPatientsQuestions'].forEach((v) { + listDoctorWorkingHoursTable + .add(ListGtMyPatientsQuestions.fromJson(v)); + isError = false; isLoading = false; - this.error= error; }); + }, onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error = error; + }); notifyListeners(); } catch (error) { diff --git a/lib/screens/patients/out_patient_prescription_details_screen.dart b/lib/screens/patients/out_patient_prescription_details_screen.dart index aa61f1fb..a8f97290 100644 --- a/lib/screens/patients/out_patient_prescription_details_screen.dart +++ b/lib/screens/patients/out_patient_prescription_details_screen.dart @@ -1,11 +1,8 @@ -import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; -import 'package:doctor_app_flutter/models/prescription_report.dart'; import 'package:doctor_app_flutter/models/request_prescription_report.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; -import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; @@ -67,181 +64,4 @@ class _OutPatientPrescriptionDetailsScreenState } } -class OutPatientPrescriptionDetailsItem extends StatefulWidget { - final PrescriptionReport prescriptionReport; - OutPatientPrescriptionDetailsItem({Key key, this.prescriptionReport}); - - @override - _OutPatientPrescriptionDetailsItemState createState() => - _OutPatientPrescriptionDetailsItemState(); -} - -class _OutPatientPrescriptionDetailsItemState - extends State { - bool _showDetails = false; - @override - Widget build(BuildContext context) { - return Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - flex: 5, - child: AppText( - '${widget.prescriptionReport.itemDescription} ', - fontSize: 2.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - ), - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _showDetails = !_showDetails; - }); - }, - child: Icon(_showDetails - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down)), - ), - ], - ), - !_showDetails - ? Container() - : AnimatedContainer( - duration: Duration(milliseconds: 200), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 5, - ), - Divider( - color: Color(0xFF000000), - height: 0.5, - ), - Table( - border: TableBorder.symmetric( - inside: BorderSide(width: 0.5), - ), - children: [ - TableRow(children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Route', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '${widget.prescriptionReport.route}', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), - ), - Container( - margin: EdgeInsets.only( - left: 4, top: 2.5, right: 2.5, bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Frequency Timing', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - widget.prescriptionReport.frequency, - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), - ), - ]), - TableRow(children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Insurance Covered', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), - ), - Container( - margin: EdgeInsets.only( - left: 4, top: 2.5, right: 2.5, bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Duration Days', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '${widget.prescriptionReport.days}', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), - ) - ]), - TableRow( - children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Doctor Remarks', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '${widget.prescriptionReport.remarks}', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), - ), - Container() - ], - ), - ], - ), - ], - ), - ) - ], - ), - ); - } -} diff --git a/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart b/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart index 30a57b15..f4a8a395 100644 --- a/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart +++ b/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart @@ -1,12 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; -import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:doctor_app_flutter/widgets/shared/Text.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; @@ -23,8 +17,6 @@ class InpatientPrescriptionDetailsScreen extends StatefulWidget { class _InpatientPrescriptionDetailsScreenState extends State { bool _showDetails = false; - bool _isLoading = false; - final _formKey = GlobalKey(); String error; TextEditingController answerController; bool _isInit = true; @@ -32,7 +24,6 @@ class _InpatientPrescriptionDetailsScreenState @override void initState() { -// answerController = new TextEditingController(text: widget.myReferralPatientModel.referredDoctorRemarks ?? ''); super.initState(); } @@ -49,7 +40,7 @@ class _InpatientPrescriptionDetailsScreenState @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: 'perscription info', + appBarTitle: 'Prescription info', body: CardWithBgWidgetNew( widget: Container( child: ListView( @@ -99,23 +90,23 @@ class _InpatientPrescriptionDetailsScreenState des: '${prescription.refillID}', key: 'Refill'), buildTableRow( - des: '${prescription.dose}', - key: 'Dose'), + des: '${prescription.dose}', key: 'Dose'), buildTableRow( des: '${prescription.unitofMeasurement}', key: 'UOM'), buildTableRow( - des: '${Helpers.getDate(prescription.startDatetime) }', + des: + '${Helpers.getDate(prescription.startDatetime)}', key: 'Start Date'), buildTableRow( - des: '${Helpers.getDate(prescription.stopDatetime)}', + des: + '${Helpers.getDate(prescription.stopDatetime)}', key: 'Stop Date'), buildTableRow( des: '${prescription.noOfDoses}', key: 'No of Doses'), buildTableRow( - des: '${prescription.route}', - key: 'Route'), + des: '${prescription.route}', key: 'Route'), buildTableRow( des: '${prescription.comments}', key: 'Comments'), @@ -123,7 +114,8 @@ class _InpatientPrescriptionDetailsScreenState des: '${prescription.pharmacyRemarks}', key: 'Pharmacy Remarks'), buildTableRow( - des: '${Helpers.getDate(prescription.prescriptionDatetime)}', + des: + '${Helpers.getDate(prescription.prescriptionDatetime)}', key: 'Prescription Date'), buildTableRow( des: '${prescription.refillID}', diff --git a/lib/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart b/lib/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart new file mode 100644 index 00000000..fc212afe --- /dev/null +++ b/lib/screens/patients/profile/prescriptions/out_patient_prescription_details_item.dart @@ -0,0 +1,138 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/prescription_report.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class OutPatientPrescriptionDetailsItem extends StatefulWidget { + final PrescriptionReport prescriptionReport; + + OutPatientPrescriptionDetailsItem({Key key, this.prescriptionReport}); + + @override + _OutPatientPrescriptionDetailsItemState createState() => + _OutPatientPrescriptionDetailsItemState(); +} + +class _OutPatientPrescriptionDetailsItemState + extends State { + bool _showDetails = false; + + @override + Widget build(BuildContext context) { + return Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + flex: 5, + child: AppText( + '${widget.prescriptionReport.itemDescription} ', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down)), + ), + ], + ), + !_showDetails + ? Container() + : AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 5, + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + Table( + border: TableBorder.symmetric( + inside: BorderSide(width: 0.5), + ), + children: [ + buildTableRow( + key: 'Route', + des: widget.prescriptionReport.route), + buildTableRow( + key: 'Frequency Timing', + des: widget.prescriptionReport.frequency), + buildTableRow(key: 'Insurance Covered', des: ''), + buildTableRow( + key: 'Duration Days', + des: widget.prescriptionReport.days), + buildTableRow( + key: 'IDoctor Remarks', + des: widget.prescriptionReport.remarks), + ], + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + ], + ), + ) + ], + ), + ); + } + + TableRow buildTableRow({des, key}) { + print('$key: $des'); + return TableRow(children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Row( + children: [ + Expanded( + child: Container( + child: AppText( + key, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + ), + ), + Expanded( + child: Container( + margin: + EdgeInsets.only(left: 4, top: 2.5, right: 2.5, bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + AppText( + '${des}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + textAlign: TextAlign.center, + ) + ], + ), + ), + ), + ], + ), + ), + ]); + } +} \ No newline at end of file From a42f06c9ffe327524b58748dcb278f764e8fbcb5 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 9 Jun 2020 15:25:43 +0300 Subject: [PATCH 09/42] modify hospital provider to make it call app base --- lib/client/base_app_client.dart | 26 +++++++++++++++++++------- lib/config/config.dart | 8 ++++++-- lib/providers/hospital_provider.dart | 25 +++++++++++++++++-------- lib/screens/auth/login_screen.dart | 4 +++- lib/widgets/auth/login_form.dart | 18 ++++++++++++++---- 5 files changed, 59 insertions(+), 22 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 0d57b9dd..f23acf57 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -4,9 +4,16 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:http/http.dart'; +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +Helpers helpers = new Helpers(); + /* *@author: Mohammad Aljammal *@Date:28/5/2020 @@ -34,12 +41,14 @@ class BaseAppClient { try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - body['DoctorID'] = doctorProfile.doctorID; - body['EditedBy'] = doctorProfile.doctorID; - body['ProjectID'] = doctorProfile.projectID; - body['ClinicID'] = doctorProfile.clinicID; - body['TokenID'] = token; + if (profile != null) { + DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + body['DoctorID'] = doctorProfile?.doctorID; + body['EditedBy'] = doctorProfile?.doctorID; + body['ProjectID'] = doctorProfile?.projectID; + body['ClinicID'] = doctorProfile?.clinicID; + } + body['TokenID'] = token ?? ''; body['LanguageID'] = LANGUAGE_ID; body['stamp'] = STAMP; body['IPAdress'] = IP_ADDRESS; @@ -56,7 +65,10 @@ class BaseAppClient { onFailure('Error While Fetching data', statusCode); } else { var parsed = json.decode(response.body.toString()); - if (parsed['MessageStatus'] == 1) { + if (!parsed['IsAuthenticated']) { + Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); + helpers.showErrorToast('Your session expired Please login agian'); + } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], diff --git a/lib/config/config.dart b/lib/config/config.dart index 886430ad..b1cb4682 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; - const BASE_URL = 'https://hmgwebservices.com/Services/'; -//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; +// const BASE_URL = 'https://hmgwebservices.com/Services/'; +const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; @@ -64,3 +64,7 @@ const PATIENT_OUT_SA = false; /// Timer Info const TIMER_MIN =10; +class AppGlobal{ +static var CONTEX; +} + diff --git a/lib/providers/hospital_provider.dart b/lib/providers/hospital_provider.dart index abf758a2..834b3889 100644 --- a/lib/providers/hospital_provider.dart +++ b/lib/providers/hospital_provider.dart @@ -1,11 +1,11 @@ import 'dart:convert'; import 'package:doctor_app_flutter/client/app_client.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/cupertino.dart'; class HospitalProvider with ChangeNotifier { - Future getProjectsList() async { const url = GET_PROJECTS; var info = { @@ -18,12 +18,21 @@ class HospitalProvider with ChangeNotifier { "SessionID": "i1UJwCTSqt", "IsLoginForDoctorApp": true }; - try { - final response = await AppClient.post(url, body: json.encode(info)); - return Future.value(json.decode(response.body)); - } catch (error) { - throw error; - // print('error'); - } + // try { + // final response = await AppClient.post(url, body: json.encode(info)); + // return Future.value(json.decode(response.body)); + // } catch (error) { + // throw error; + // // print('error'); + // } + + await BaseAppClient.post(url, + onSuccess: ( response, statusCode) { + return Future.value(response); + }, + onFailure: (String error, int statusCode) { + throw error; + }, + body: info); } } diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 8b25d21d..2d43a048 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -11,8 +12,8 @@ import '../../widgets/auth/login_form.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class Loginsreen extends StatefulWidget { @override _LoginsreenState createState() => _LoginsreenState(); @@ -55,6 +56,7 @@ class _LoginsreenState extends State { @override Widget build(BuildContext context) { + AppGlobal.CONTEX = context; getSharedPref(); return AppScaffold( isLoading: _isLoading, diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index b93bfafa..ba6c9a02 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -36,7 +36,7 @@ class _LoginFormState extends State { String _platformImei = 'Unknown'; String uniqueId = "Unknown"; var projectsList = []; - + bool _isInit = true; FocusNode focusPass; FocusNode focusProject; @@ -54,6 +54,19 @@ class _LoginFormState extends State { void initState() { super.initState(); initPlatformState(); + + + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + if (projectsList.length == 0) { + getProjectsList(); + } + } + _isInit = false; } @override @@ -61,9 +74,6 @@ class _LoginFormState extends State { final focusPass = FocusNode(); final focusProject = FocusNode(); - if (projectsList.length == 0) { - getProjectsList(); - } AuthProvider authProv = Provider.of(context); return Form( From 02216b497cd89af687596df63204e93100186cba Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Tue, 9 Jun 2020 15:47:59 +0300 Subject: [PATCH 10/42] delete http intercceptor --- lib/client/app_client.dart | 12 +-- lib/client/base_app_client.dart | 11 ++- lib/interceptor/http_interceptor.dart | 65 ------------- lib/providers/patients_provider.dart | 127 ++++++++++++-------------- 4 files changed, 69 insertions(+), 146 deletions(-) delete mode 100644 lib/interceptor/http_interceptor.dart diff --git a/lib/client/app_client.dart b/lib/client/app_client.dart index 68c4fb8b..215b2714 100644 --- a/lib/client/app_client.dart +++ b/lib/client/app_client.dart @@ -1,6 +1,5 @@ import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; -import 'package:http/http.dart'; +import 'package:http/http.dart' as http; // OWNER : Ibrahim albitar // DATE : 22-04-2020 @@ -8,11 +7,12 @@ import 'package:http/http.dart'; class AppClient { - static Client client = HttpInterceptor().getClient(); - - static Future post(dynamic path, {dynamic body}) async { + static Future post(dynamic path, {dynamic body}) async { String _fullUrl = BASE_URL + path; - final response = await client.post(_fullUrl, body: body); + final response = await http.post(_fullUrl, body: body, headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }); return response; } } \ No newline at end of file diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index f23acf57..39b3c683 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -2,14 +2,13 @@ import 'dart:convert'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:http/http.dart'; +import 'package:http/http.dart' as http; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = new Helpers(); @@ -29,7 +28,6 @@ Helpers helpers = new Helpers(); body: null); * */ class BaseAppClient { - static Client client = HttpInterceptor().getClient(); static post( String endPoint, { @@ -59,7 +57,12 @@ class BaseAppClient { body['PatientOutSA'] = PATIENT_OUT_SA; if (await Helpers.checkConnection()) { - final response = await client.post(url, body: json.encode(body)); + final response = await http.post(url, + body: json.encode(body), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); diff --git a/lib/interceptor/http_interceptor.dart b/lib/interceptor/http_interceptor.dart deleted file mode 100644 index 4d0f9c33..00000000 --- a/lib/interceptor/http_interceptor.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/providers/auth_provider.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:http/http.dart'; -import 'package:http_interceptor/http_interceptor.dart'; - -import '../providers/auth_provider.dart'; -import '../util/dr_app_shared_pref.dart'; - -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); -List publicUrls = [ - LOGIN_URL, - SELECT_DEVICE_IMEI, - MEMBER_CHECK_ACTIVATION_CODE_NEW, - SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE -]; - -class HttpInterceptor extends InterceptorContract { - - Client getClient(){ - return HttpClientWithInterceptor.build(interceptors: [this]); -} - - Future interceptRequest({RequestData data}) async { - print('RequestData ${data.body}'); - print('RequestData ${data.url}'); - try { - data.headers["Content-Type"] = "application/json"; - data.headers["Accept"] = "application/json"; - // if (publicUrls.contains(data.url)) { - // var loggedUserInfo = await sharedPref.getObj('loggedUser'); - // var token = await sharedPref.getString(TOKEN); - // // print("token"+token); - // // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}'); - // // // the sevices handel the token in differat name so I ask to be change - // // // we must change the imple - // var body = json.decode(data.body); - // body['LogInTokenID']=token; - // data.body = json.encode(body); - - // // data.body['LogInTokenID'] = ''; - // } else { - // if (data.body['LogInTokenID']) { - // data.body['LogInTokenID'] = ''; - // } - // if (data.body['TokenID']) { - // data.body['TokenID'] = ''; - // } - // } - } catch (e) { - print(e); - } - - // print('data.body${data.body}'); - return data; - } - - @override - Future interceptResponse({ResponseData data}) async { - // print('ResponseData ${data.body}'); - return data; - } -} diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index e93c2ceb..e2e6c061 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -17,12 +17,9 @@ import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; import 'package:flutter/cupertino.dart'; -import 'package:http/http.dart'; -import 'package:http_interceptor/http_client_with_interceptor.dart'; import '../client/app_client.dart'; import '../config/config.dart'; -import '../interceptor/http_interceptor.dart'; import '../models/patient/lab_orders_res_model.dart'; import '../models/patient/patiant_info_model.dart'; import '../models/patient/patient_model.dart'; @@ -67,52 +64,46 @@ class PatientsProvider with ChangeNotifier { ClinicByProjectIdRequest(); ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); - Client client = - HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); + PatiantInformtion _selectedPatient; Future getPatientList(PatientModel patient, patientType) async { - /* const url = - BASE_URL+'DoctorApplication.svc/REST/GetMyInPatient';*/ - int val = int.parse(patientType); - //**********Modify url by amjad amireh for patiant type********* final url = BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val]; - // print("a===========$url=======a"); try { - final response = await client.post(url, - body: json.encode({ - "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(json.decode(response.body)); + await BaseAppClient.post(url, + onSuccess: (dynamic response, int statusCode) { + return Future.value(response); + }, onFailure: (String error, int statusCode) { + throw error; + }, body: { + "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 + }); } catch (err) { - throw err; + handelCatchErrorCase(error); } } @@ -239,7 +230,7 @@ class PatientsProvider with ChangeNotifier { try { if (await Helpers.checkConnection()) { final response = - await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); + await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -302,22 +293,20 @@ class PatientsProvider with ChangeNotifier { } } - getPrescriptionReport(prescriptionReqModel) async{ + getPrescriptionReport(prescriptionReqModel) async { prescriptionReport = []; isLoading = true; isError = false; error = ""; notifyListeners(); - await BaseAppClient.post( - 'Patients.svc/REST/GetPrescriptionReport', + await BaseAppClient.post('Patients.svc/REST/GetPrescriptionReport', onSuccess: (dynamic response, int statusCode) { - response['ListPRM'].forEach((v) { - prescriptionReport - .add(PrescriptionReport.fromJson(v)); - }); - isError = false; - isLoading = false; - }, onFailure: (String error, int statusCode) { + response['ListPRM'].forEach((v) { + prescriptionReport.add(PrescriptionReport.fromJson(v)); + }); + isError = false; + isLoading = false; + }, onFailure: (String error, int statusCode) { isError = true; isLoading = false; this.error = error; @@ -661,31 +650,27 @@ class PatientsProvider with ChangeNotifier { final int statusCode = response.statusCode; isLoading = false; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientProgressNoteList = res['List_GetPregressNoteForInPatient']; } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - patientProgressNoteList = res['List_GetPregressNoteForInPatient']; - } else { - isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; } - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); } - - - - + } } From 334150894a46cd528a26c233ae07f819da6c8557 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Tue, 9 Jun 2020 17:31:07 +0300 Subject: [PATCH 11/42] Change http call to BaseAppClient --- lib/client/base_app_client.dart | 5 +- lib/providers/hospital_provider.dart | 7 - lib/providers/medicine_provider.dart | 75 ++----- lib/providers/patients_provider.dart | 305 ++++++++------------------- 4 files changed, 109 insertions(+), 283 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 39b3c683..124e361e 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -20,6 +20,7 @@ Helpers helpers = new Helpers(); *@return: *@desc: */ + ///Example /* await BaseAppClient.post('', @@ -28,7 +29,6 @@ Helpers helpers = new Helpers(); body: null); * */ class BaseAppClient { - static post( String endPoint, { Map body, @@ -44,7 +44,8 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; body['EditedBy'] = doctorProfile?.doctorID; body['ProjectID'] = doctorProfile?.projectID; - body['ClinicID'] = doctorProfile?.clinicID; + if (!body.containsKey('ClinicID')) + body['ClinicID'] = doctorProfile?.clinicID; } body['TokenID'] = token ?? ''; body['LanguageID'] = LANGUAGE_ID; diff --git a/lib/providers/hospital_provider.dart b/lib/providers/hospital_provider.dart index 834b3889..8c22ae0b 100644 --- a/lib/providers/hospital_provider.dart +++ b/lib/providers/hospital_provider.dart @@ -18,13 +18,6 @@ class HospitalProvider with ChangeNotifier { "SessionID": "i1UJwCTSqt", "IsLoginForDoctorApp": true }; - // try { - // final response = await AppClient.post(url, body: json.encode(info)); - // return Future.value(json.decode(response.body)); - // } catch (error) { - // throw error; - // // print('error'); - // } await BaseAppClient.post(url, onSuccess: ( response, statusCode) { diff --git a/lib/providers/medicine_provider.dart b/lib/providers/medicine_provider.dart index a0d8f4ed..0f8734f4 100644 --- a/lib/providers/medicine_provider.dart +++ b/lib/providers/medicine_provider.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:doctor_app_flutter/client/app_client.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart'; @@ -11,47 +12,32 @@ import 'package:flutter/cupertino.dart'; class MedicineProvider with ChangeNotifier { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); - + var pharmacyItemsList = []; var pharmaciesList = []; bool isFinished = true; bool hasError = false; String errorMsg = ''; - PharmaciesItemsRequestModel _itemsRequestModel =PharmaciesItemsRequestModel(); + PharmaciesItemsRequestModel _itemsRequestModel = + PharmaciesItemsRequestModel(); PharmaciesListRequestModel _listRequestModel = PharmaciesListRequestModel(); Future getMedicineItem(String itemName) async { resetDefaultValues(); try { - if (await Helpers.checkConnection()) { - _itemsRequestModel.pHRItemName = itemName; - - final response = await AppClient.post(PHARMACY_ITEMS_URL, - body: json.encode(_itemsRequestModel.toJson())); - final int statusCode = response.statusCode; + _itemsRequestModel.pHRItemName = itemName; + await BaseAppClient.post(PHARMACY_ITEMS_URL, + onSuccess: (dynamic response, int statusCode) { + pharmacyItemsList = response['ListPharmcy_Region']; + hasError = false; isFinished = true; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isFinished = true; - hasError = true; - errorMsg = 'Error While Fetching data'; - } else { - var parsed = json.decode(response.body.toString()); - if (parsed['MessageStatus'] == 1) { - pharmacyItemsList = parsed['ListPharmcy_Region']; - hasError = false; - isFinished = true; - errorMsg = "Done"; - } else { - hasError = true; - errorMsg = parsed['ErrorMessage'] ?? parsed['ErrorEndUserMessage']; - } - } - } else { + errorMsg = "Done"; + }, onFailure: (String error, int statusCode) { isFinished = true; hasError = true; - errorMsg = 'Please Check The Internet Connection'; - } + errorMsg = error; + }, body: _itemsRequestModel.toJson()); notifyListeners(); } catch (error) { throw error; @@ -61,37 +47,20 @@ class MedicineProvider with ChangeNotifier { } Future getPharmaciesList(int itemId) async { - String token = await sharedPref.getString(TOKEN); resetDefaultValues(); try { - if (await Helpers.checkConnection()) { - _listRequestModel.itemID = itemId; - _listRequestModel.tokenID = token; - final response = await AppClient.post(PHARMACY_LIST_URL, - body: json.encode(_listRequestModel.toJson())); - final int statusCode = response.statusCode; + _listRequestModel.itemID = itemId; + await BaseAppClient.post(PHARMACY_LIST_URL, + onSuccess: (dynamic response, int statusCode) { + pharmaciesList = response['PharmList']; + hasError = false; isFinished = true; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isFinished = true; - hasError = true; - errorMsg = 'Error While Fetching data'; - } else { - var parsed = json.decode(response.body.toString()); - if (parsed['MessageStatus'] == 1) { - pharmaciesList = parsed['PharmList']; - hasError = false; - isFinished = true; - errorMsg = "Done"; - } else { - hasError = true; - errorMsg = parsed['ErrorMessage'] ?? parsed['ErrorEndUserMessage']; - } - } - } else { + errorMsg = "Done"; + }, onFailure: (String error, int statusCode) { isFinished = true; hasError = true; - errorMsg = 'Please Check The Internet Connection'; - } + errorMsg = error; + }, body: _listRequestModel.toJson()); notifyListeners(); } catch (error) { throw error; diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index e2e6c061..ca88a5b7 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -71,11 +71,8 @@ class PatientsProvider with ChangeNotifier { Future getPatientList(PatientModel patient, patientType) async { int val = int.parse(patientType); - final url = - BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val]; - try { - await BaseAppClient.post(url, + await BaseAppClient.post( SERVICES_PATIANT[val], onSuccess: (dynamic response, int statusCode) { return Future.value(response); }, onFailure: (String error, int statusCode) { @@ -125,21 +122,10 @@ class PatientsProvider with ChangeNotifier { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(GET_PATIENT_VITAL_SIGN, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_PATIENT_VITAL_SIGN, + onSuccess: (dynamic response, int statusCode) { patientVitalSignList = []; - res['List_DoctorPatientVitalSign'].forEach((v) { + response['List_DoctorPatientVitalSign'].forEach((v) { patientVitalSignList.add(new VitalSignResModel.fromJson(v)); }); @@ -157,16 +143,13 @@ class PatientsProvider with ChangeNotifier { .add(patientVitalSignOrderdSubListTemp[x]); } } - } else { + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -185,33 +168,19 @@ class PatientsProvider with ChangeNotifier { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(GET_PATIENT_LAB_OREDERS, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_PATIENT_LAB_OREDERS, + onSuccess: (dynamic response, int statusCode) { patientLabResultOrdersList = []; - res['List_GetLabOreders'].forEach((v) { + response['List_GetLabOreders'].forEach((v) { patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); }); - } else { + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -226,36 +195,21 @@ class PatientsProvider with ChangeNotifier { */ getOutPatientPrescriptions(patient) async { setBasicData(); - try { - if (await Helpers.checkConnection()) { - final response = - await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_PRESCRIPTION, + onSuccess: (dynamic response, int statusCode) { patientPrescriptionsList = []; - res['PatientPrescriptionList'].forEach((v) { + response['PatientPrescriptionList'].forEach((v) { patientPrescriptionsList .add(new PrescriptionResModel.fromJson(v)); }); - } else { + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -339,33 +293,20 @@ class PatientsProvider with ChangeNotifier { // notifyListeners(); setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = - await AppClient.post(GET_RADIOLOGY, body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_RADIOLOGY, + onSuccess: (dynamic response, int statusCode) { patientRadiologyList = []; - res['List_GetRadOreders'].forEach((v) { + response['List_GetRadOreders'].forEach((v) { patientRadiologyList.add(new RadiologyResModel.fromJson(v)); }); - } else { + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -399,31 +340,16 @@ class PatientsProvider with ChangeNotifier { getPatientInsuranceApprovals(patient) async { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - //patientRadiologyList = []; - insuranceApporvalsList = res['List_ApprovalMain_InPatient']; - } else { + await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL, + onSuccess: (dynamic response, int statusCode) { + insuranceApporvalsList = response['List_ApprovalMain_InPatient']; + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -437,30 +363,17 @@ class PatientsProvider with ChangeNotifier { getPatientProgressNote(patient) async { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - patientProgressNoteList = res['List_GetPregressNoteForInPatient']; - } else { + await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL, + onSuccess: (dynamic response, int statusCode) { + patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -472,38 +385,19 @@ class PatientsProvider with ChangeNotifier { *@desc: getDoctorsList */ getDoctorsList(String clinicId) async { - String token = await sharedPref.getString(TOKEN); - int projectID = await sharedPref.getInt(PROJECT_ID); setBasicData(); try { - if (await Helpers.checkConnection()) { - _doctorsByClinicIdRequest.projectID = projectID; - _doctorsByClinicIdRequest.clinicID = clinicId; - _doctorsByClinicIdRequest.tokenID = token; - - final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, - body: json.encode(_doctorsByClinicIdRequest)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - doctorsList = res['List_Doctors_All']; - } else { + _doctorsByClinicIdRequest.clinicID = clinicId; + await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, + onSuccess: (dynamic response, int statusCode) { + doctorsList = response['List_Doctors_All']; + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: _doctorsByClinicIdRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -521,37 +415,19 @@ class PatientsProvider with ChangeNotifier { *@desc: getClinicsList */ getClinicsList() async { - String token = await sharedPref.getString(TOKEN); setBasicData(); try { - if (await Helpers.checkConnection()) { - int projectID = await sharedPref.getInt(PROJECT_ID); - _clinicByProjectIdRequest.projectID = projectID; - _clinicByProjectIdRequest.tokenID = token; - final response = await AppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, - body: json.encode(_clinicByProjectIdRequest)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - clinicsList = res['List_Clinic_All']; - } else { + await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, + onSuccess: (dynamic response, int statusCode) { + clinicsList = response['List_Clinic_All']; + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: _clinicByProjectIdRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -573,30 +449,17 @@ class PatientsProvider with ChangeNotifier { String token = await sharedPref.getString(TOKEN); setBasicData(); try { - if (await Helpers.checkConnection()) { - _referralFrequencyRequest.tokenID = token; - final response = await AppClient.post(PATIENT_GET_LIST_REFERAL_URL, - body: json.encode(_referralFrequencyRequest)); - final int statusCode = response.statusCode; - isLoading = false; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - referalFrequancyList = res['list_STPReferralFrequency']; - } else { + + await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, + onSuccess: (dynamic response, int statusCode) { + referalFrequancyList = response['list_STPReferralFrequency']; + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: _referralFrequencyRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); From 480c64d25a38c07586aaecac9908cf04b31a8c60 Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Tue, 9 Jun 2020 17:44:21 +0300 Subject: [PATCH 12/42] complete refer patient --- .../patient/refer_to_doctor_request.dart | 34 +- lib/providers/patients_provider.dart | 120 ++-- .../profile/refer_patient_screen.dart | 580 ++++++++++++------ 3 files changed, 475 insertions(+), 259 deletions(-) diff --git a/lib/models/patient/refer_to_doctor_request.dart b/lib/models/patient/refer_to_doctor_request.dart index 11229596..28eb488b 100644 --- a/lib/models/patient/refer_to_doctor_request.dart +++ b/lib/models/patient/refer_to_doctor_request.dart @@ -1,3 +1,5 @@ +import 'package:flutter/cupertino.dart'; + class ReferToDoctorRequest { /* @@ -64,27 +66,27 @@ class ReferToDoctorRequest { */ ReferToDoctorRequest( - {this.projectID, - this.admissionNo, - this.roomID = "ISO-6", - this.referralClinic, - this.referralDoctor , - this.createdBy, - this.editedBy , - this.patientID, - this.patientTypeID = 1, - this.referringClinic, - this.referringDoctor, - this.referringDoctorRemarks, - this.priority , - this.frequency, - this.extension, + {@required this.projectID, + @required this.admissionNo, + @required this.roomID , + @required this.referralClinic, + @required this.referralDoctor , + @required this.createdBy, + @required this.editedBy , + @required this.patientID, + @required this.patientTypeID, + @required this.referringClinic, + @required this.referringDoctor, + @required this.referringDoctorRemarks, + @required this.priority , + @required this.frequency, + @required this.extension, this.languageID = 2, this.stamp = "2020-06-03T11:26:42.358Z", this.iPAdress = "11.11.11.11", this.versionID = 1.2, this.channel = 9, - this.tokenID, + @required this.tokenID, this.sessionID = "JBXRsDl37L", this.isLoginForDoctorApp = true, this.patientOutSA = false}); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index e93c2ceb..9af3879d 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -68,7 +68,7 @@ class PatientsProvider with ChangeNotifier { ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); Client client = - HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); + HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); PatiantInformtion _selectedPatient; @@ -239,7 +239,7 @@ class PatientsProvider with ChangeNotifier { try { if (await Helpers.checkConnection()) { final response = - await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); + await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -302,22 +302,20 @@ class PatientsProvider with ChangeNotifier { } } - getPrescriptionReport(prescriptionReqModel) async{ + getPrescriptionReport(prescriptionReqModel) async { prescriptionReport = []; isLoading = true; isError = false; error = ""; notifyListeners(); - await BaseAppClient.post( - 'Patients.svc/REST/GetPrescriptionReport', + await BaseAppClient.post('Patients.svc/REST/GetPrescriptionReport', onSuccess: (dynamic response, int statusCode) { - response['ListPRM'].forEach((v) { - prescriptionReport - .add(PrescriptionReport.fromJson(v)); - }); - isError = false; - isLoading = false; - }, onFailure: (String error, int statusCode) { + response['ListPRM'].forEach((v) { + prescriptionReport.add(PrescriptionReport.fromJson(v)); + }); + isError = false; + isLoading = false; + }, onFailure: (String error, int statusCode) { isError = true; isLoading = false; this.error = error; @@ -626,66 +624,70 @@ class PatientsProvider with ChangeNotifier { *@desc: referToDoctor */ referToDoctor( - int selectedDoctorID, - int selectedClinicID, - String selectedReferralFrequancyID, + {String selectedDoctorID, + String selectedClinicID, int admissionNo, String extension, - String doctorRemark) async { - String token = await sharedPref.getString(TOKEN); - int projectID = await sharedPref.getInt(PROJECT_ID); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); - int doctorID = doctorProfile.doctorID; - int clinicId = doctorProfile.clinicID; + String priority, + String frequency, + String referringDoctorRemarks, + int patientID, + int patientTypeID, + String roomID, + int projectID}) async { setBasicData(); try { if (await Helpers.checkConnection()) { - // _referToDoctorRequest.tokenID = token; - // _referToDoctorRequest.admissionNo = admissionNo; - // _referToDoctorRequest.projectID = projectID; - // _referToDoctorRequest.tokenID = token; - // _referToDoctorRequest.extension = extension; - // _referToDoctorRequest.frequency = selectedReferralFrequancyID; - // _referToDoctorRequest.patientID = - // _referToDoctorRequest.priority = - // _referToDoctorRequest.referralClinic = - // _referToDoctorRequest.referralDoctor = - // _referToDoctorRequest.referringDoctorRemarks = - // _referToDoctorRequest.roomID = - // _referToDoctorRequest.referringClinic = - // _referToDoctorRequest.referringDoctor = + String token = await sharedPref.getString(TOKEN); + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + DoctorProfileModel doctorProfile = + new DoctorProfileModel.fromJson(profile); + int doctorID = doctorProfile.doctorID; + int clinicId = doctorProfile.clinicID; + _referToDoctorRequest = ReferToDoctorRequest( + projectID: projectID, + admissionNo: admissionNo, + roomID: roomID, + referralClinic: selectedClinicID.toString(), + referralDoctor: selectedDoctorID.toString(), + createdBy: doctorID, + editedBy: doctorID, + patientID: patientID, + patientTypeID: patientTypeID, + referringClinic: clinicId, + referringDoctor: doctorID, + referringDoctorRemarks: referringDoctorRemarks, + priority: priority, + frequency: frequency, + extension: extension, + tokenID: token); final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, - body: json.encode(_referralFrequencyRequest)); + body: json.encode(_referToDoctorRequest)); final int statusCode = response.statusCode; isLoading = false; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + print('Done : /n $res'); } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - patientProgressNoteList = res['List_GetPregressNoteForInPatient']; - } else { - isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; } - notifyListeners(); - } catch (err) { - handelCatchErrorCase(err); + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; } + notifyListeners(); + } catch (err) { + handelCatchErrorCase(err); } - - - - + } } diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 1781867c..23f7f159 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -1,6 +1,13 @@ +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:hexcolor/hexcolor.dart'; +import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import '../../../config/size_config.dart'; import '../../../providers/patients_provider.dart'; @@ -29,13 +36,22 @@ class _ReferPatientState extends State { var doctorsList; var clinicsList; var referralFrequancyList; - final _controller = TextEditingController(); + final _remarksController = TextEditingController(); + final _extController = TextEditingController(); var _isInit = true; + var clinicId; + var doctorId; + var freqId; + String _selectedClinic; String _selectedDoctor; String _selectedReferralFrequancy; + List _priorities = ['Very Urgent', 'Urgent', 'Routine']; + int _activePriority = 2; + String _priorityTime; + @override void didChangeDependencies() { super.didChangeDependencies(); @@ -54,214 +70,410 @@ class _ReferPatientState extends State { @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: "Progress Note", + appBarTitle: "Refer Patient", body: patientsProv.isLoading ? DrAppCircularProgressIndeicator() : patientsProv.isError ? DrAppEmbeddedError(error: patientsProv.error) : clinicsList == null ? DrAppEmbeddedError( - error: 'You don\'t have any Progress Note') - : Column( - children: [ - RoundedContainer( - margin: 0, - showBorder: true, - raduis: 30, - borderColor: Color(0xff707070), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButton( - isExpanded: true, - value: _selectedClinic, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return patientsProv + error: 'Something Wrong!') + : SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + "Clinic", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + RoundedContainer( + margin: 10, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedClinic, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getClinicNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedDoctor = null; + _selectedClinic = newValue; + var clinicInfo = + clinicsList.singleWhere((i) => + i['ClinicDescription'] + .toString() + .contains(_selectedClinic)); + clinicId = + clinicInfo['ClinicID'].toString(); + patientsProv.getDoctorsList(clinicId); + }) + }, + items: patientsProv .getClinicNameList() .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - ), - ], + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - _selectedDoctor = null; - _selectedClinic = newValue; - var clinicInfo = - clinicsList.singleWhere((i) => - i['ClinicDescription'] - .toString() - .contains(_selectedClinic)); - var clinicId = - clinicInfo['ClinicID'].toString(); - patientsProv.getDoctorsList(clinicId); - }) - }, - items: patientsProv - .getClinicNameList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), + }).toList(), + ), ), - ), - ], + ], + ), ), ), - ), - //--------------------------------------------------------------------// - RoundedContainer( - margin: 0, - showBorder: true, - raduis: 30, - borderColor: Color(0xff707070), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButton( - isExpanded: true, - value: _selectedDoctor, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return patientsProv + //--------------------------------------------------------------------// + AppText( + "Doctor", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + + RoundedContainer( + margin: 10, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedDoctor, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getDoctorNameList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedDoctor = newValue; + var doctorInfo = + doctorsList.singleWhere((i) => + i['DoctorName'] + .toString() + .contains(_selectedDoctor)); + doctorId = + doctorInfo['DoctorID'].toString(); + }) + }, + items: patientsProv .getDoctorNameList() .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - ), - ], + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - _selectedDoctor = newValue; - }) - }, - items: patientsProv - .getDoctorNameList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), + }).toList(), + ), ), - ), - ], + ], + ), + ), + ), //-----------------------------/// + AppText( + "Ext#", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: AppTextFormField( + hintText: "Ext#", + controller: _extController, + inputFormatter: ONLY_NUMBERS, + textInputType: TextInputType.number, + onChanged: (value) => {}, ), ), - ), //-----------------------------/// - RoundedContainer( - margin: 0, - showBorder: true, - raduis: 30, - borderColor: Color(0xff707070), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only( - top: SizeConfig.widthMultiplier * 0.9, - bottom: SizeConfig.widthMultiplier * 0.9, - right: SizeConfig.widthMultiplier * 3, - left: SizeConfig.widthMultiplier * 3), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Expanded( - // add Expanded to have your dropdown button fill remaining space - child: DropdownButton( - isExpanded: true, - value: _selectedReferralFrequancy, - iconSize: 40, - elevation: 16, - selectedItemBuilder: - (BuildContext context) { - return patientsProv + AppText( + "Priority", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + + priorityBar(context), + + AppText( + "Replay Before: " + getPriority(), + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + + AppText( + "Referral Frequency", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + RoundedContainer( + margin: 10, + showBorder: true, + raduis: 30, + borderColor: Color(0xff707070), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only( + top: SizeConfig.widthMultiplier * 0.9, + bottom: SizeConfig.widthMultiplier * 0.9, + right: SizeConfig.widthMultiplier * 3, + left: SizeConfig.widthMultiplier * 3), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Expanded( + // add Expanded to have your dropdown button fill remaining space + child: DropdownButton( + isExpanded: true, + value: _selectedReferralFrequancy, + iconSize: 40, + elevation: 16, + selectedItemBuilder: + (BuildContext context) { + return patientsProv + .getReferralNamesList() + .map((item) { + return Row( + mainAxisSize: MainAxisSize.max, + children: [ + AppText( + item, + fontSize: + SizeConfig.textMultiplier * + 2.1, + ), + ], + ); + }).toList(); + }, + onChanged: (newValue) => { + setState(() { + _selectedReferralFrequancy = newValue; + var freqInfo = + referralFrequancyList.singleWhere((i) => + i['Description'] + .toString() + .contains(_selectedReferralFrequancy)); + freqId = + freqInfo['ParameterCode'].toString(); + }) + }, + items: patientsProv .getReferralNamesList() .map((item) { - return Row( - mainAxisSize: MainAxisSize.max, - children: [ - AppText( - item, - fontSize: - SizeConfig.textMultiplier * - 2.1, - ), - ], + return DropdownMenuItem( + value: item.toString(), + child: Text( + item, + textAlign: TextAlign.end, + ), ); - }).toList(); - }, - onChanged: (newValue) => { - setState(() { - _selectedReferralFrequancy = newValue; - }) - }, - items: patientsProv - .getReferralNamesList() - .map((item) { - return DropdownMenuItem( - value: item.toString(), - child: Text( - item, - textAlign: TextAlign.end, - ), - ); - }).toList(), + }).toList(), + ), ), - ), - ], + ], + ), ), ), + AppText( + "Clinical Details and Remarks", + fontSize: 18, + fontWeight: FontWeight.bold, + marginLeft: 15, + marginTop: 15, + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: AppTextFormField( + hintText: "Remarks", + controller: _remarksController, + inputFormatter: ONLY_LETTERS, + textInputType: TextInputType.text, + onChanged: (value) => {}, + ), + ), + Padding( + padding: const EdgeInsets.all(20.0), + child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{ + referToDoctor() + },), + ) + ], + ), + ), + ); + } + + Widget priorityBar(BuildContext _context) { + return Container( + height: MediaQuery.of(context).size.height * 0.065, + width: SizeConfig.screenWidth * 0.9, + margin: EdgeInsets.only(top: 10), + decoration: BoxDecoration( + color: Color(0Xffffffff), borderRadius: BorderRadius.circular(20)), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: _priorities.map((item) { + bool _isActive = _priorities[_activePriority] == item ? true : false; + return Column(mainAxisSize: MainAxisSize.min, children: [ + InkWell( + child: Center( + child: Container( + height: 40, + width: 90, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + color: _isActive ? Hexcolor("#B8382B") : Colors.white, + ), + child: Center( + child: Text( + item, + style: TextStyle( + fontSize: 12, + color: _isActive + ? Colors.white + : Colors.black, //Colors.black, + // backgroundColor:_isActive + // ? Hexcolor("#B8382B") + // : Colors.white,//sideColor, + + fontWeight: FontWeight.bold, + ), ), - ], - ), + )), + ), + onTap: () { + print(_priorities.indexOf(item)); + setState(() { + _activePriority = _priorities.indexOf(item); + }); + }), + _isActive + ? Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Colors.white), + alignment: Alignment.center, + height: 3, + width: 90, + ) + : Container() + ]); + }).toList(), + ), ); } + + String getPriority() { + DateTime date = DateTime.now(); + switch (_activePriority) { + case 0: + date = date.add(new Duration(hours: 3)); + break; + case 1: + date = date.add(new Duration(hours: 6)); + break; + case 2: + date = date.add(new Duration(days: 1)); + break; + } + var format = DateFormat('yyyy/mm/dd HH:mm a'); + var time = format.format(date); + print(time); + return time; + } + + void referToDoctor(){ + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + patientsProv.referToDoctor( + extension: _extController.value.text, + admissionNo:int.parse( patient.admissionNo), + referringDoctorRemarks: _remarksController.value.text, + frequency: freqId, + patientID: patient.patientId, + patientTypeID: patient.patientType, + priority: (_activePriority + 1).toString(), + roomID: patient.roomId, + selectedClinicID: clinicId.toString(), + selectedDoctorID: doctorId.toString(), + projectID: patient.projectId + ); + } } From eb09cda2a187573e9d473c33ccf2b9b23f7249a3 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Wed, 10 Jun 2020 11:04:53 +0300 Subject: [PATCH 13/42] fix issues in patients provider --- lib/client/base_app_client.dart | 2 +- lib/config/config.dart | 4 +-- lib/providers/patients_provider.dart | 45 +++++++++++++++++++++++----- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 124e361e..031c70ac 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -57,7 +57,7 @@ class BaseAppClient { body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = PATIENT_OUT_SA; - if (await Helpers.checkConnection()) { + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), headers: { diff --git a/lib/config/config.dart b/lib/config/config.dart index 6e75ccf2..e80acab5 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; -// const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; + const BASE_URL = 'https://hmgwebservices.com/Services/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index ca88a5b7..0770ad47 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -68,14 +68,15 @@ class PatientsProvider with ChangeNotifier { PatiantInformtion _selectedPatient; - Future getPatientList(PatientModel patient, patientType) async { + getPatientList(PatientModel patient, patientType) async { int val = int.parse(patientType); try { - await BaseAppClient.post( SERVICES_PATIANT[val], - onSuccess: (dynamic response, int statusCode) { - return Future.value(response); - }, onFailure: (String error, int statusCode) { + var localResponse ; + await BaseAppClient.post( 'DoctorApplication.svc/REST/'+SERVICES_PATIANT[val], + onSuccess: (dynamic response, int statusCode) async{ + localResponse = response; + }, onFailure: (String error, int statusCode) async{ throw error; }, body: { "ProjectID": patient.ProjectID, @@ -99,9 +100,12 @@ class PatientsProvider with ChangeNotifier { "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, "PatientOutSA": patient.PatientOutSA }); + + return localResponse; } catch (err) { handelCatchErrorCase(error); } + } setBasicData() { @@ -138,11 +142,15 @@ class PatientsProvider with ChangeNotifier { a.vitalSignDate.microsecondsSinceEpoch; }); patientVitalSignOrderdSubList.clear(); - for (int x = 0; x < 20; x++) { + int length = patientVitalSignOrderdSubListTemp.length >= 20 ? 20 : patientVitalSignOrderdSubListTemp.length; + for (int x = 0; x < length; x++) { patientVitalSignOrderdSubList .add(patientVitalSignOrderdSubListTemp[x]); } } + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -174,6 +182,9 @@ class PatientsProvider with ChangeNotifier { response['List_GetLabOreders'].forEach((v) { patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); }); + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -203,6 +214,9 @@ class PatientsProvider with ChangeNotifier { patientPrescriptionsList .add(new PrescriptionResModel.fromJson(v)); }); + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -300,6 +314,9 @@ class PatientsProvider with ChangeNotifier { response['List_GetRadOreders'].forEach((v) { patientRadiologyList.add(new RadiologyResModel.fromJson(v)); }); + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -343,6 +360,9 @@ class PatientsProvider with ChangeNotifier { await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL, onSuccess: (dynamic response, int statusCode) { insuranceApporvalsList = response['List_ApprovalMain_InPatient']; + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -367,6 +387,9 @@ class PatientsProvider with ChangeNotifier { await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL, onSuccess: (dynamic response, int statusCode) { patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -391,6 +414,9 @@ class PatientsProvider with ChangeNotifier { await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, onSuccess: (dynamic response, int statusCode) { doctorsList = response['List_Doctors_All']; + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -421,6 +447,9 @@ class PatientsProvider with ChangeNotifier { await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, onSuccess: (dynamic response, int statusCode) { clinicsList = response['List_Clinic_All']; + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; @@ -446,13 +475,15 @@ class PatientsProvider with ChangeNotifier { *@desc: getReferralFrequancyList */ getReferralFrequancyList() async { - String token = await sharedPref.getString(TOKEN); setBasicData(); try { await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, onSuccess: (dynamic response, int statusCode) { referalFrequancyList = response['list_STPReferralFrequency']; + isLoading = false; + isError = false; + this.error = ''; }, onFailure: (String error, int statusCode) { isLoading = false; From e6b99adc806807233f3ecf59564d245a38ce885a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 10 Jun 2020 11:20:47 +0300 Subject: [PATCH 14/42] change calling serivce to base app client --- lib/providers/auth_provider.dart | 120 +++++++++++++-------- lib/providers/hospital_provider.dart | 18 +--- lib/widgets/auth/verfiy_account.dart | 4 +- lib/widgets/auth/verification_methods.dart | 2 +- 4 files changed, 81 insertions(+), 63 deletions(-) diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index af93c837..f362442d 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -1,86 +1,108 @@ -import 'dart:convert'; -import 'package:doctor_app_flutter/client/app_client.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:flutter/cupertino.dart'; + import '../models/user_model.dart'; -const LOGIN_URL = - 'Sentry.svc/REST/MemberLogIN_New'; -const INSERT_DEVICE_IMEI = - 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; +const LOGIN_URL = 'Sentry.svc/REST/MemberLogIN_New'; +const INSERT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; const SELECT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = 'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; -const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Sentry.svc/REST/MemberCheckActivationCode_New'; +const MEMBER_CHECK_ACTIVATION_CODE_NEW = + 'Sentry.svc/REST/MemberCheckActivationCode_New'; const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; -class AuthProvider with ChangeNotifier { - Future login(UserModel userInfo) async { - const url = LOGIN_URL; +class AuthProvider with ChangeNotifier { + Future login(UserModel userInfo) async { try { - final response = await AppClient.post(url, - body: json.encode({ - "UserID": userInfo.UserID, - "Password": userInfo.Password, - "ProjectID": userInfo.ProjectID, - "LanguageID": userInfo.LanguageID, - "IPAdress": userInfo.IPAdress, - "VersionID": userInfo.VersionID, - "Channel": userInfo.Channel, - "SessionID": userInfo.SessionID - })); - return Future.value(json.decode(response.body)); + dynamic localRes; + + await BaseAppClient.post(LOGIN_URL, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: { + "UserID": userInfo.UserID, + "Password": userInfo.Password, + "ProjectID": userInfo.ProjectID, + "LanguageID": userInfo.LanguageID, + "IPAdress": userInfo.IPAdress, + "VersionID": userInfo.VersionID, + "Channel": userInfo.Channel, + "SessionID": userInfo.SessionID + }); + + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future insertDeviceImei(imei) async { - const url = INSERT_DEVICE_IMEI; - + Future insertDeviceImei(imei) async { try { - final response = await AppClient.post(url, body: json.encode(imei)); - return Future.value(json.decode(response.body)); + dynamic localRes; + + await BaseAppClient.post(INSERT_DEVICE_IMEI, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: imei); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future selectDeviceImei(imei) async { - const url = SELECT_DEVICE_IMEI; - + Future selectDeviceImei(imei) async { try { - final response = await AppClient.post(url, body: json.encode(imei)); - return Future.value(json.decode(response.body)); + dynamic localRes; + await BaseAppClient.post(SELECT_DEVICE_IMEI, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: imei); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future sendActivationCodeByOtpNotificationType( + Future sendActivationCodeByOtpNotificationType( activationCodeModel) async { - const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE; - try { - final response = await AppClient.post(url, body: json.encode(activationCodeModel)); - return Future.value(json.decode(response.body)); + var localRes; + await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future memberCheckActivationCodeNew(activationCodeModel) async { - const url = MEMBER_CHECK_ACTIVATION_CODE_NEW; - + Future memberCheckActivationCodeNew(activationCodeModel) async { try { - final response = await AppClient.post(url, body: json.encode(activationCodeModel)); - return Future.value(json.decode(response.body)); + dynamic localRes; + await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel); + return Future.value(localRes); } catch (error) { print(error); throw error; @@ -94,12 +116,16 @@ class AuthProvider with ChangeNotifier { *@return:Future *@desc: getDocProfiles */ - Future getDocProfiles(docInfo) async { - const url = GET_DOC_PROFILES; - + Future getDocProfiles(docInfo) async { try { - final response = await AppClient.post(url, body: json.encode(docInfo)); - return Future.value(json.decode(response.body)); + dynamic localRes; + await BaseAppClient.post(GET_DOC_PROFILES, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: docInfo); + return Future.value(localRes); } catch (error) { print(error); throw error; diff --git a/lib/providers/hospital_provider.dart b/lib/providers/hospital_provider.dart index 834b3889..262d258e 100644 --- a/lib/providers/hospital_provider.dart +++ b/lib/providers/hospital_provider.dart @@ -1,6 +1,3 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/cupertino.dart'; @@ -18,21 +15,16 @@ class HospitalProvider with ChangeNotifier { "SessionID": "i1UJwCTSqt", "IsLoginForDoctorApp": true }; - // try { - // final response = await AppClient.post(url, body: json.encode(info)); - // return Future.value(json.decode(response.body)); - // } catch (error) { - // throw error; - // // print('error'); - // } - + dynamic localRes ; await BaseAppClient.post(url, - onSuccess: ( response, statusCode) { - return Future.value(response); + onSuccess: ( response, statusCode) async { + localRes= response; }, onFailure: (String error, int statusCode) { throw error; }, body: info); + return Future.value(localRes); + } } diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index feae82ce..c72b0c10 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -322,7 +322,7 @@ class _VerifyAccountState extends State { verifyAccountFormValue['digit4']; print(activationCode); int projectID = await sharedPref.getInt(PROJECT_ID); - Map model = { + Map model = { "activationCode": activationCode, "DoctorID": _loggedUser['DoctorID'], "LogInTokenID": _loggedUser['LogInTokenID'], @@ -421,7 +421,7 @@ class _VerifyAccountState extends State { projectID: clinicInfo.projectID, tokenID: '', languageID: 2); - authProv.getDocProfiles(docInfo).then((res) { + authProv.getDocProfiles(docInfo.toJson()).then((res) { if (res['MessageStatus'] == 1) { print("DoctorProfileList ${res['DoctorProfileList'][0]}"); loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata); diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 3a7fa482..af72b092 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -255,7 +255,7 @@ class _VerificationMethodsState extends State { if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); - Map model = { + Map model = { "LogInTokenID": _loggedUser['LogInTokenID'], "Channel": 9, "MobileNumber": _loggedUser['MobileNumber'], From 3e05a58dd7ce7dc18b45d0d5a98050f5fc1d0bd1 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 10 Jun 2020 11:38:09 +0300 Subject: [PATCH 15/42] delete app client --- lib/client/app_client.dart | 18 -- lib/config/config.dart | 4 +- lib/providers/medicine_provider.dart | 8 +- lib/providers/patients_provider.dart | 321 ++++++++++++--------------- 4 files changed, 145 insertions(+), 206 deletions(-) delete mode 100644 lib/client/app_client.dart diff --git a/lib/client/app_client.dart b/lib/client/app_client.dart deleted file mode 100644 index 215b2714..00000000 --- a/lib/client/app_client.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:http/http.dart' as http; - -// OWNER : Ibrahim albitar -// DATE : 22-04-2020 -// DESCRIPTION : Custom App client to pin base url for all srvices - -class AppClient { - - static Future post(dynamic path, {dynamic body}) async { - String _fullUrl = BASE_URL + path; - final response = await http.post(_fullUrl, body: body, headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json' - }); - return response; - } -} \ No newline at end of file diff --git a/lib/config/config.dart b/lib/config/config.dart index e80acab5..f6849172 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; - const BASE_URL = 'https://hmgwebservices.com/Services/'; -//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; + // const BASE_URL = 'https://hmgwebservices.com/Services/'; +const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/providers/medicine_provider.dart b/lib/providers/medicine_provider.dart index 0f8734f4..1f432531 100644 --- a/lib/providers/medicine_provider.dart +++ b/lib/providers/medicine_provider.dart @@ -1,15 +1,11 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart'; import 'package:doctor_app_flutter/models/pharmacies_items_request_model.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; +import '.../../../util/dr_app_shared_pref.dart'; + class MedicineProvider with ChangeNotifier { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 0770ad47..2984398e 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -1,6 +1,3 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; @@ -18,7 +15,6 @@ import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; import 'package:flutter/cupertino.dart'; -import '../client/app_client.dart'; import '../config/config.dart'; import '../models/patient/lab_orders_res_model.dart'; import '../models/patient/patiant_info_model.dart'; @@ -64,19 +60,18 @@ class PatientsProvider with ChangeNotifier { ClinicByProjectIdRequest(); ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); - - PatiantInformtion _selectedPatient; getPatientList(PatientModel patient, patientType) async { int val = int.parse(patientType); try { - var localResponse ; - await BaseAppClient.post( 'DoctorApplication.svc/REST/'+SERVICES_PATIANT[val], - onSuccess: (dynamic response, int statusCode) async{ - localResponse = response; - }, onFailure: (String error, int statusCode) async{ + var localResponse; + await BaseAppClient.post( + 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val], + onSuccess: (dynamic response, int statusCode) async { + localResponse = response; + }, onFailure: (String error, int statusCode) async { throw error; }, body: { "ProjectID": patient.ProjectID, @@ -105,7 +100,6 @@ class PatientsProvider with ChangeNotifier { } catch (err) { handelCatchErrorCase(error); } - } setBasicData() { @@ -128,36 +122,36 @@ class PatientsProvider with ChangeNotifier { try { await BaseAppClient.post(GET_PATIENT_VITAL_SIGN, onSuccess: (dynamic response, int statusCode) { - patientVitalSignList = []; - response['List_DoctorPatientVitalSign'].forEach((v) { - patientVitalSignList.add(new VitalSignResModel.fromJson(v)); - }); - - if (patientVitalSignList.length > 0) { - List patientVitalSignOrderdSubListTemp = []; - patientVitalSignOrderdSubListTemp = patientVitalSignList; - patientVitalSignOrderdSubListTemp - .sort((VitalSignResModel a, VitalSignResModel b) { - return b.vitalSignDate.microsecondsSinceEpoch - - a.vitalSignDate.microsecondsSinceEpoch; - }); - patientVitalSignOrderdSubList.clear(); - int length = patientVitalSignOrderdSubListTemp.length >= 20 ? 20 : patientVitalSignOrderdSubListTemp.length; - for (int x = 0; x < length; x++) { - patientVitalSignOrderdSubList - .add(patientVitalSignOrderdSubListTemp[x]); - } - } - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: patient); + patientVitalSignList = []; + response['List_DoctorPatientVitalSign'].forEach((v) { + patientVitalSignList.add(new VitalSignResModel.fromJson(v)); + }); + + if (patientVitalSignList.length > 0) { + List patientVitalSignOrderdSubListTemp = []; + patientVitalSignOrderdSubListTemp = patientVitalSignList; + patientVitalSignOrderdSubListTemp + .sort((VitalSignResModel a, VitalSignResModel b) { + return b.vitalSignDate.microsecondsSinceEpoch - + a.vitalSignDate.microsecondsSinceEpoch; + }); + patientVitalSignOrderdSubList.clear(); + int length = patientVitalSignOrderdSubListTemp.length >= 20 + ? 20 + : patientVitalSignOrderdSubListTemp.length; + for (int x = 0; x < length; x++) { + patientVitalSignOrderdSubList + .add(patientVitalSignOrderdSubListTemp[x]); + } + } + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -178,20 +172,18 @@ class PatientsProvider with ChangeNotifier { try { await BaseAppClient.post(GET_PATIENT_LAB_OREDERS, onSuccess: (dynamic response, int statusCode) { - patientLabResultOrdersList = []; - response['List_GetLabOreders'].forEach((v) { - patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); - }); - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: patient); + patientLabResultOrdersList = []; + response['List_GetLabOreders'].forEach((v) { + patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); + }); + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -209,21 +201,18 @@ class PatientsProvider with ChangeNotifier { try { await BaseAppClient.post(GET_PRESCRIPTION, onSuccess: (dynamic response, int statusCode) { - patientPrescriptionsList = []; - response['PatientPrescriptionList'].forEach((v) { - patientPrescriptionsList - .add(new PrescriptionResModel.fromJson(v)); - }); - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: patient); + patientPrescriptionsList = []; + response['PatientPrescriptionList'].forEach((v) { + patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v)); + }); + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -307,23 +296,20 @@ class PatientsProvider with ChangeNotifier { // notifyListeners(); setBasicData(); try { - await BaseAppClient.post(GET_RADIOLOGY, onSuccess: (dynamic response, int statusCode) { - patientRadiologyList = []; - response['List_GetRadOreders'].forEach((v) { - patientRadiologyList.add(new RadiologyResModel.fromJson(v)); - }); - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: patient); + patientRadiologyList = []; + response['List_GetRadOreders'].forEach((v) { + patientRadiologyList.add(new RadiologyResModel.fromJson(v)); + }); + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -359,17 +345,15 @@ class PatientsProvider with ChangeNotifier { try { await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL, onSuccess: (dynamic response, int statusCode) { - insuranceApporvalsList = response['List_ApprovalMain_InPatient']; - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: patient); + insuranceApporvalsList = response['List_ApprovalMain_InPatient']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -383,20 +367,17 @@ class PatientsProvider with ChangeNotifier { getPatientProgressNote(patient) async { setBasicData(); try { - await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL, onSuccess: (dynamic response, int statusCode) { - patientProgressNoteList = response['List_GetPregressNoteForInPatient']; - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: patient); + patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -413,17 +394,15 @@ class PatientsProvider with ChangeNotifier { _doctorsByClinicIdRequest.clinicID = clinicId; await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, onSuccess: (dynamic response, int statusCode) { - doctorsList = response['List_Doctors_All']; - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: _doctorsByClinicIdRequest.toJson()); + doctorsList = response['List_Doctors_All']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: _doctorsByClinicIdRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -443,20 +422,17 @@ class PatientsProvider with ChangeNotifier { getClinicsList() async { setBasicData(); try { - await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, onSuccess: (dynamic response, int statusCode) { - clinicsList = response['List_Clinic_All']; - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: _clinicByProjectIdRequest.toJson()); + clinicsList = response['List_Clinic_All']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: _clinicByProjectIdRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -477,20 +453,17 @@ class PatientsProvider with ChangeNotifier { getReferralFrequancyList() async { setBasicData(); try { - await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, onSuccess: (dynamic response, int statusCode) { - referalFrequancyList = response['list_STPReferralFrequency']; - isLoading = false; - isError = false; - this.error = ''; - }, - onFailure: (String error, int statusCode) { - isLoading = false; - isError = true; - this.error = error; - }, - body: _referralFrequencyRequest.toJson()); + referalFrequancyList = response['list_STPReferralFrequency']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; + isError = true; + this.error = error; + }, body: _referralFrequencyRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -523,45 +496,33 @@ class PatientsProvider with ChangeNotifier { int clinicId = doctorProfile.clinicID; setBasicData(); try { - if (await Helpers.checkConnection()) { - // _referToDoctorRequest.tokenID = token; - // _referToDoctorRequest.admissionNo = admissionNo; - // _referToDoctorRequest.projectID = projectID; - // _referToDoctorRequest.tokenID = token; - // _referToDoctorRequest.extension = extension; - // _referToDoctorRequest.frequency = selectedReferralFrequancyID; - // _referToDoctorRequest.patientID = - // _referToDoctorRequest.priority = - // _referToDoctorRequest.referralClinic = - // _referToDoctorRequest.referralDoctor = - // _referToDoctorRequest.referringDoctorRemarks = - // _referToDoctorRequest.roomID = - // _referToDoctorRequest.referringClinic = - // _referToDoctorRequest.referringDoctor = - - final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, - body: json.encode(_referralFrequencyRequest)); - final int statusCode = response.statusCode; + // _referToDoctorRequest.tokenID = token; + // _referToDoctorRequest.admissionNo = admissionNo; + // _referToDoctorRequest.projectID = projectID; + // _referToDoctorRequest.tokenID = token; + // _referToDoctorRequest.extension = extension; + // _referToDoctorRequest.frequency = selectedReferralFrequancyID; + // _referToDoctorRequest.patientID = + // _referToDoctorRequest.priority = + // _referToDoctorRequest.referralClinic = + // _referToDoctorRequest.referralDoctor = + // _referToDoctorRequest.referringDoctorRemarks = + // _referToDoctorRequest.roomID = + // _referToDoctorRequest.referringClinic = + // _referToDoctorRequest.referringDoctor = + + await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL, + onSuccess: (dynamic response, int statusCode) { + patientProgressNoteList = response['List_GetPregressNoteForInPatient']; isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - patientProgressNoteList = res['List_GetPregressNoteForInPatient']; - } else { - isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { isLoading = false; isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: _referralFrequencyRequest.toJson()); + notifyListeners(); } catch (err) { handelCatchErrorCase(err); From be6c77f81b1fce432d0ef06e885f7d8e53c059c6 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 10 Jun 2020 12:33:27 +0300 Subject: [PATCH 16/42] AD-113: Remove Remember Me --- lib/widgets/auth/login_form.dart | 24 ++++----------------- lib/widgets/shared/app_scaffold_widget.dart | 5 ----- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index ba6c9a02..a00268f9 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -54,17 +54,15 @@ class _LoginFormState extends State { void initState() { super.initState(); initPlatformState(); - - } @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { - if (projectsList.length == 0) { - getProjectsList(); - } + if (projectsList.length == 0) { + getProjectsList(); + } } _isInit = false; } @@ -144,22 +142,8 @@ class _LoginFormState extends State { }), buildSizedBox(), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.end, children: [ - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Checkbox( - value: true, - activeColor: Theme.of(context).primaryColor, - onChanged: (bool newValue) {}), - Text("Remember me", - style: TextStyle( - fontSize: 2 * SizeConfig.textMultiplier)), - ], - ), - ), RaisedButton( onPressed: () { login(context, authProv, widget.changeLoadingStata); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 1e6da3fc..80c1a7d3 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,13 +1,8 @@ -import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; -import '../../config/size_config.dart'; -import '../../presentation/doctor_app_icons.dart'; -import '../../widgets/shared/app_drawer_widget.dart'; import '../../widgets/shared/app_loader_widget.dart'; -import '../../widgets/shared/custom_shape_clipper.dart'; class AppScaffold extends StatelessWidget { String appBarTitle; From a37a5ccd86d69d7ad1d8a6694d356d92a5678663 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Wed, 10 Jun 2020 12:38:39 +0300 Subject: [PATCH 17/42] DA-114:Reduce the font size for the project list --- lib/util/helpers.dart | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index e05f0d74..ea8352f7 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -7,7 +7,6 @@ import '../util/dr_app_toast_msg.dart'; import 'package:connectivity/connectivity.dart'; - /* *@author: Elham Rababah *@Date:12/4/2020 @@ -48,10 +47,6 @@ class Helpers { onPressed: () { Navigator.pop(context); }, - // padding: const EdgeInsets.symmetric( - // horizontal: 16.0, - // vertical: 5.0, - // ), ), CupertinoButton( child: Text( @@ -97,7 +92,7 @@ class Helpers { children: items.map((item) { return Text( '${item["$decKey"]}', - style: TextStyle(fontSize: SizeConfig.textMultiplier * 3), + style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), ); }).toList(), @@ -164,14 +159,15 @@ class Helpers { ), ); } - /* + + /* *@author: Amjad Amireh *@Date:5/5/2020 *@param: checkDate *@return: DateTime *@desc: convert String to DateTime */ -static String checkDate(String dateString) { + static String checkDate(String dateString) { DateTime checkedTime = DateTime.parse(dateString); DateTime currentTime = DateTime.now(); @@ -257,6 +253,7 @@ static String checkDate(String dateString) { return "Sunday"; } } + /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -275,6 +272,7 @@ static String checkDate(String dateString) { else return ""; } + /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -301,13 +299,14 @@ static String checkDate(String dateString) { *@return: List *@desc: convert workingHours string to List */ - static List getWorkingHours(String workingHours ){ - List myWorkingHours =[]; + static List getWorkingHours(String workingHours) { + List myWorkingHours = []; List listOfHours = workingHours.split('a'); listOfHours.forEach((element) { WorkingHours workingHours = WorkingHours(); - var from = element.substring(element.indexOf('m ') + 2 , element.indexOf('To')-2); + var from = element.substring( + element.indexOf('m ') + 2, element.indexOf('To') - 2); workingHours.from = from.trim(); var to = element.substring(element.indexOf('To') + 2); workingHours.to = to.trim(); @@ -316,9 +315,6 @@ static String checkDate(String dateString) { return myWorkingHours; } - - - /* *@author: Elham Rababah *@Date:12/5/2020 From 937f8ecd6a2306783917a217b63196dda7453908 Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Wed, 10 Jun 2020 14:44:31 +0300 Subject: [PATCH 18/42] fix --- lib/providers/patients_provider.dart | 14 ++++--- .../profile/refer_patient_screen.dart | 39 +++++++++---------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 9af3879d..754af77b 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -65,8 +65,7 @@ class PatientsProvider with ChangeNotifier { STPReferralFrequencyRequest(); ClinicByProjectIdRequest _clinicByProjectIdRequest = ClinicByProjectIdRequest(); - ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); - + ReferToDoctorRequest _referToDoctorRequest ; Client client = HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); @@ -493,19 +492,22 @@ class PatientsProvider with ChangeNotifier { final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, body: json.encode(_doctorsByClinicIdRequest)); final int statusCode = response.statusCode; - isLoading = false; + if (statusCode < 200 || statusCode >= 400 || json == null) { isError = true; error = 'Error While Fetching data'; + isLoading = false; } else { var res = json.decode(response.body); print('$res'); if (res['MessageStatus'] == 1) { doctorsList = res['List_Doctors_All']; + isLoading = false; } else { isError = true; error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + isLoading = false; } } } else { @@ -516,6 +518,7 @@ class PatientsProvider with ChangeNotifier { notifyListeners(); } catch (err) { handelCatchErrorCase(err); + isLoading = false; } } @@ -623,7 +626,7 @@ class PatientsProvider with ChangeNotifier { *@Date:3/6/2020 *@desc: referToDoctor */ - referToDoctor( + referToDoctor(context, {String selectedDoctorID, String selectedClinicID, int admissionNo, @@ -674,7 +677,8 @@ class PatientsProvider with ChangeNotifier { var res = json.decode(response.body); print('$res'); if (res['MessageStatus'] == 1) { - print('Done : /n $res'); + print('Done : \n $res'); + Navigator.pop(context); } else { isError = true; error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 23f7f159..24146ca5 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -34,8 +34,6 @@ class ReferPatientScreen extends StatefulWidget { class _ReferPatientState extends State { PatientsProvider patientsProv; var doctorsList; - var clinicsList; - var referralFrequancyList; final _remarksController = TextEditingController(); final _extController = TextEditingController(); var _isInit = true; @@ -50,19 +48,15 @@ class _ReferPatientState extends State { List _priorities = ['Very Urgent', 'Urgent', 'Routine']; int _activePriority = 2; - String _priorityTime; @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { + doctorsList = null; patientsProv = Provider.of(context); patientsProv.getClinicsList(); - patientsProv.getReferralFrequancyList(); - setState(() { - clinicsList = patientsProv.clinicsList; - referralFrequancyList = patientsProv.referalFrequancyList; - }); + patientsProv.getReferralFrequancyList(); } _isInit = false; } @@ -75,7 +69,7 @@ class _ReferPatientState extends State { ? DrAppCircularProgressIndeicator() : patientsProv.isError ? DrAppEmbeddedError(error: patientsProv.error) - : clinicsList == null + : patientsProv.clinicsList == null ? DrAppEmbeddedError( error: 'Something Wrong!') : SingleChildScrollView( @@ -134,13 +128,14 @@ class _ReferPatientState extends State { setState(() { _selectedDoctor = null; _selectedClinic = newValue; - var clinicInfo = - clinicsList.singleWhere((i) => + var clinicInfo = patientsProv.clinicsList.where((i) => i['ClinicDescription'] .toString() - .contains(_selectedClinic)); + .contains(_selectedClinic)).toList(); + clinicId = - clinicInfo['ClinicID'].toString(); + clinicInfo[0]['ClinicID'].toString(); + patientsProv.getDoctorsList(clinicId); }) }, @@ -213,13 +208,15 @@ class _ReferPatientState extends State { onChanged: (newValue) => { setState(() { _selectedDoctor = newValue; + doctorsList = patientsProv.doctorsList; + var doctorInfo = - doctorsList.singleWhere((i) => + doctorsList.where((i) => i['DoctorName'] .toString() - .contains(_selectedDoctor)); - doctorId = - doctorInfo['DoctorID'].toString(); + .contains(_selectedDoctor)).toList(); + doctorId = doctorInfo[0]['DoctorID'].toString(); + }) }, items: patientsProv @@ -324,7 +321,7 @@ class _ReferPatientState extends State { setState(() { _selectedReferralFrequancy = newValue; var freqInfo = - referralFrequancyList.singleWhere((i) => + patientsProv.referalFrequancyList.singleWhere((i) => i['Description'] .toString() .contains(_selectedReferralFrequancy)); @@ -369,7 +366,7 @@ class _ReferPatientState extends State { Padding( padding: const EdgeInsets.all(20.0), child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{ - referToDoctor() + referToDoctor(context) },), ) ], @@ -459,10 +456,10 @@ class _ReferPatientState extends State { return time; } - void referToDoctor(){ + void referToDoctor(context){ final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; - patientsProv.referToDoctor( + patientsProv.referToDoctor(context, extension: _extController.value.text, admissionNo:int.parse( patient.admissionNo), referringDoctorRemarks: _remarksController.value.text, From f3c20d9866f376de731db94c67ace21407b634ff Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Wed, 10 Jun 2020 14:59:55 +0300 Subject: [PATCH 19/42] Modify Patiant screen List style --- lib/config/config.dart | 4 +-- lib/screens/patients/patients_screen.dart | 6 ++-- lib/screens/profile_screen.dart | 37 +++++++++++++++++------ lib/widgets/shared/app_drawer_widget.dart | 6 +++- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index f6849172..6015f8df 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; - // const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; + const BASE_URL = 'https://hmgwebservices.com/Services/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 1128832f..a5d8d96e 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -52,7 +52,7 @@ class _PatientsScreenState extends State { final String assetName = 'assets/image.svg'; // List _locations = ['Today', 'Old Date', 'YESTERDAY']; - List _locations = ['Today', 'Tomorrow', 'Next Week']; + List _locations = ['All','Today', 'Tomorrow', 'Next Week']; int _activeLocation = 0; bool _isInit = true; @@ -277,10 +277,10 @@ class _PatientsScreenState extends State { if ((currentTime.day - checkedTime.day) <= -2) { return "Next Week"; } else { - return "Old Date"; + return "All"; } } - return "Old Date"; + return "All"; } /* diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart index 9a09424f..88f9565a 100644 --- a/lib/screens/profile_screen.dart +++ b/lib/screens/profile_screen.dart @@ -1,3 +1,7 @@ + +import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_drawer_widget.dart'; +////////////// import 'package:flutter/material.dart'; import '../config/size_config.dart'; @@ -7,17 +11,28 @@ import '../widgets/shared/profile_image_widget.dart'; import '../widgets/shared/rounded_container_widget.dart'; class ProfileScreen extends StatefulWidget { - ProfileScreen({Key key, this.title}) : super(key: key); + ProfileScreen({Key key, this.title,this.doctorProfileall}) : super(key: key); final String title; + DoctorProfileModel doctorProfileall ; @override _ProfileScreenState createState() => _ProfileScreenState(); } class _ProfileScreenState extends State { +//************************** + DoctorProfileModel doctorProfile ; + //AppDrawer dr; +//****************** @override Widget build(BuildContext context) { + + Map arg=ModalRoute.of(context).settings.arguments as Map;//ModalRoute.of(context).settings.arguments; + doctorProfile = arg['doctorProfileall']; + print("******************"); + //print(doctorProfile.doctorName); + print("******************"); return AppScaffold( appBarTitle: 'Profile', body: ListView(padding: EdgeInsets.zero, children: [ @@ -25,10 +40,10 @@ class _ProfileScreenState extends State { height: SizeConfig.heightMultiplier * 30, child: DrawerHeader( child: ProfileImageWidget( - url: - "https://p.kindpng.com/picc/s/404-4042774_profile-photo-circle-circle-profile-picture-png-transparent.png", - name: "Dr. Chris evans", - des: "Director of medical records", + url:doctorProfile.doctorImageURL, + //"https://p.kindpng.com/picc/s/404-4042774_profile-photo-circle-circle-profile-picture-png-transparent.png", + name: doctorProfile.doctorName,//"Dr. Chris evans", + des: doctorProfile.clinicDescription//"Director of medical records", ), ), ), @@ -36,28 +51,30 @@ class _ProfileScreenState extends State { child: ListView( children: [ DrawerItem( - "Gender", + "Gender" + , Icons.person_pin, color: Colors.black, - subTitle: "Male", + subTitle: doctorProfile.genderDescription//"Male" + , ), DrawerItem( "Clinic", Icons.build, color: Colors.black, - subTitle: "Neurology Clinic", + subTitle: doctorProfile.clinicDescription//"Neurology Clinic", ), DrawerItem( "Hospital", Icons.local_hospital, color: Colors.black, - subTitle: "Al-Takkassussi", + subTitle: doctorProfile.projectName,//"Al-Takkassussi", ), DrawerItem( "Speciality", Icons.crop_square, color: Colors.black, - subTitle: "being great", + subTitle: doctorProfile.doctorRate==0 ?"being bad":"being great", ), ], ), diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index e124a88f..53228c97 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -81,7 +81,11 @@ class _AppDrawerState extends State { ), ), onTap: () { - Navigator.of(context).pushNamed(PROFILE); + //Navigator.of(context).pushNamed(PROFILE); + Navigator.of(context).pushNamed(PROFILE, arguments: {'title':doctorProfile.doctorName, + "doctorProfileall": doctorProfile + }); + }, ), ), From 4638ba56a2b30367d5c079f2055714386729898f Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Thu, 11 Jun 2020 09:23:44 +0300 Subject: [PATCH 20/42] jira fixes --- lib/config/config.dart | 2 +- .../medicine/medicine_search_screen.dart | 8 +- .../medicine/pharmacies_list_screen.dart | 168 ++++++++++++------ .../medicine/medicine_item_widget.dart | 4 - 4 files changed, 116 insertions(+), 66 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 5fd2c67c..d199986c 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -1,6 +1,6 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; -const ONLY_LETTERS = "[a-zA-Z]"; +const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL = 'https://hmgwebservices.com/Services/'; //const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; diff --git a/lib/screens/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index 1add0181..2b14edeb 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -11,7 +11,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; -import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../util/extenstions.dart'; @@ -61,9 +60,6 @@ class _MedicineSearchState extends State { hintText: 'Search Medicine Name Here..', controller: myController, onSaved: (value) {}, - // validator: (value) { - // return TextValidator().validateName(value); - // }, inputFormatter: ONLY_LETTERS), ), @@ -99,7 +95,7 @@ class _MedicineSearchState extends State { ), Expanded( child: Container( - width: SizeConfig.screenWidth * 0.80, + width: SizeConfig.screenWidth * 0.97, child: !_medicineProvider.isFinished ? DrAppCircularProgressIndeicator() : _medicineProvider.hasError @@ -127,7 +123,7 @@ class _MedicineSearchState extends State { builder: (context) => ChangeNotifierProvider( create: (_) => MedicineProvider(), child: PharmaciesListScreen( - itemID: data[index]["ItemID"]), + itemID: data[index]["ItemID"], url: data[index]["ProductImageBase64"]), ), ), ); diff --git a/lib/screens/medicine/pharmacies_list_screen.dart b/lib/screens/medicine/pharmacies_list_screen.dart index 4c682cea..60f24862 100644 --- a/lib/screens/medicine/pharmacies_list_screen.dart +++ b/lib/screens/medicine/pharmacies_list_screen.dart @@ -1,11 +1,10 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'dart:convert'; +import 'dart:typed_data'; + import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/models/pharmacies_List_request_model.dart'; import 'package:doctor_app_flutter/providers/medicine_provider.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; @@ -20,8 +19,11 @@ DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); class PharmaciesListScreen extends StatefulWidget { final int itemID; + final String url; + // In the constructor, require a item id. - PharmaciesListScreen({Key key, @required this.itemID}) : super(key: key); + PharmaciesListScreen({Key key, @required this.itemID, this.url}) + : super(key: key); @override _PharmaciesListState createState() => _PharmaciesListState(); @@ -61,44 +63,77 @@ class _PharmaciesListState extends State { TextStyle(color: Theme.of(context).errorColor), ), ) - : Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - AppText( - "Description", - margin: 10, - fontWeight: FontWeight.bold, - ), - AppText( - _data[0]["ItemDescription"], - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 10, - ), - AppText( - "Price", - margin: 10, - fontWeight: FontWeight.bold, - ), - AppText( - _data[0]["SellingPrice"].toString(), - marginLeft: 10, - marginTop: 0, - marginRight: 10, - marginBottom: 10, - ), - ], - )), + : StreamBuilder( + stream: null, + builder: (context, snapshot) { + return Row( + children: [ + Expanded( + flex: 1, + child: ClipRRect( + borderRadius: + BorderRadius.all(Radius.circular(7)), + child: Image.memory( + dataFromBase64String(widget.url), + height: SizeConfig.imageSizeMultiplier * 21, + width: SizeConfig.imageSizeMultiplier * 20, + fit: BoxFit.cover, + ), + ), + ), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: [ + AppText( + "Description", + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 2, + fontWeight: FontWeight.bold, + ), + AppText( + _data[0]["ItemDescription"], + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 10, + ), + AppText( + "Price", + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 2, + fontWeight: FontWeight.bold, + ), + AppText( + _data[0]["SellingPrice"].toString(), + marginLeft: 10, + marginTop: 0, + marginRight: 10, + marginBottom: 10, + ), + ], + ), + ) + ], + ); + })), Container( - margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), + margin: EdgeInsets.only(top:SizeConfig.widthMultiplier * 2, + bottom: SizeConfig.widthMultiplier * 2, + right: SizeConfig.widthMultiplier * 4, + left: SizeConfig.widthMultiplier * 4,), child: Align( alignment: Alignment.centerLeft, child: AppText( "You can Find it in", fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 3, ))), Expanded( child: Container( @@ -114,7 +149,8 @@ class _PharmaciesListState extends State { Expanded( flex: 1, child: ClipRRect( - borderRadius:BorderRadius.all(Radius.circular(7)), + borderRadius: + BorderRadius.all(Radius.circular(7)), child: Image.network( _data[index]["ProjectImageURL"], height: SizeConfig.imageSizeMultiplier * 15, @@ -138,25 +174,36 @@ class _PharmaciesListState extends State { crossAxisAlignment: WrapCrossAlignment.end, children: [ Padding( - padding: EdgeInsets.all(5), - child: InkWell(child: Icon(Icons.call, color: Colors.red,),onTap: ()=>launch( - "tel://" + _data[index]["PhoneNumber"]),), - ), -Padding( - padding: EdgeInsets.all(5), - child: InkWell(child: Icon(Icons.pin_drop, color: Colors.red,),onTap: () { - MapsLauncher.launchCoordinates( - double.parse(_data[index]["Latitude"]), - double.parse(_data[index]["Longitude"]), - _data[index]["LocationDescription"]); - },), - ), + padding: EdgeInsets.all(5), + child: InkWell( + child: Icon( + Icons.call, + color: Colors.red, + ), + onTap: () => launch( + "tel://" + _data[index]["PhoneNumber"]), + ), + ), + Padding( + padding: EdgeInsets.all(5), + child: InkWell( + child: Icon( + Icons.pin_drop, + color: Colors.red, + ), + onTap: () { + MapsLauncher.launchCoordinates( + double.parse( + _data[index]["Latitude"]), + double.parse( + _data[index]["Longitude"]), + _data[index]["LocationDescription"]); + }, + ), + ), ], - ), ), - - ], ), ); @@ -170,9 +217,20 @@ Padding( _medicineProvider.getPharmaciesList(widget.itemID).then((result) { this.setState(() { _data = _medicineProvider.pharmaciesList; - //if(_data == null || _data.length == 0) }); }); return true; } + + Image imageFromBase64String(String base64String) { + return Image.memory(base64Decode(base64String)); + } + + Uint8List dataFromBase64String(String base64String) { + return base64Decode(base64String); + } + + String base64String(Uint8List data) { + return base64Encode(data); + } } diff --git a/lib/widgets/medicine/medicine_item_widget.dart b/lib/widgets/medicine/medicine_item_widget.dart index 1d606793..3998adc6 100644 --- a/lib/widgets/medicine/medicine_item_widget.dart +++ b/lib/widgets/medicine/medicine_item_widget.dart @@ -1,10 +1,6 @@ import 'dart:convert'; import 'dart:typed_data'; - -import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; -import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; - import '../shared/rounded_container_widget.dart'; import '../shared/app_texts_widget.dart'; import 'package:flutter/material.dart'; From 9b065036aedfd4e87e000638d7af6359236f0db5 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 11 Jun 2020 09:24:10 +0300 Subject: [PATCH 21/42] fix issues in get patients service --- lib/client/base_app_client.dart | 9 +++- lib/config/config.dart | 6 +-- lib/providers/patients_provider.dart | 22 +++++----- lib/screens/QR_reader_screen.dart | 14 ++++-- lib/screens/doctor/my_schedule_screen.dart | 3 +- .../patients/patients_list_screen.dart | 4 ++ lib/screens/patients/patients_screen.dart | 3 +- .../profile/radiology/radiology_screen.dart | 4 -- .../doctor/my_referral_patient_widget.dart | 44 +++++++++++-------- .../patients/profile/large_avatar.dart | 12 ++--- 10 files changed, 74 insertions(+), 47 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 031c70ac..93ca0690 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -9,6 +9,8 @@ import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; +import 'package:http_interceptor/http_methods.dart'; +import 'package:http_interceptor/models/request_data.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = new Helpers(); @@ -36,6 +38,9 @@ class BaseAppClient { Function(String error, int statusCode) onFailure, }) async { String url = BASE_URL + endPoint; + RequestData data = RequestData(body: body,baseUrl: url,method: Method.POST); + + try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); @@ -44,7 +49,7 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; body['EditedBy'] = doctorProfile?.doctorID; body['ProjectID'] = doctorProfile?.projectID; - if (!body.containsKey('ClinicID')) + // if (!body.containsKey('ClinicID')) body['ClinicID'] = doctorProfile?.clinicID; } body['TokenID'] = token ?? ''; @@ -56,6 +61,8 @@ class BaseAppClient { body['SessionID'] = SESSION_ID; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = PATIENT_OUT_SA; + print("URL : $url"); + print("Body : ${json.encode(body)}"); if (await Helpers.checkConnection()) { final response = await http.post(url, diff --git a/lib/config/config.dart b/lib/config/config.dart index f6849172..5f902f2f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; - // const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; +const BASE_URL = 'https://hmgwebservices.com/Services/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "DoctorApplication.svc/REST/GetProgressNoteForInPatient"; @@ -23,7 +23,7 @@ const GET_RADIOLOGY = 'DoctorApplication.svc/REST/GetPatientRadResult'; var selectedPatientType = 0; -//*********change value to decode json from Dropdown ************ +//*********change value to decode json from Dropdown ************1 var SERVICES_PATIANT = [ "GetMyOutPatient", "GetMyInPatient", diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 2984398e..3aebd306 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -62,17 +62,16 @@ class PatientsProvider with ChangeNotifier { PatiantInformtion _selectedPatient; - getPatientList(PatientModel patient, patientType) async { + Future getPatientList(PatientModel patient, patientType) async { int val = int.parse(patientType); try { - var localResponse; - await BaseAppClient.post( - 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val], - onSuccess: (dynamic response, int statusCode) async { - localResponse = response; - }, onFailure: (String error, int statusCode) async { - throw error; + dynamic localRes; + await BaseAppClient.post('DoctorApplication.svc/REST/' + SERVICES_PATIANT[val], + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; }, body: { "ProjectID": patient.ProjectID, "ClinicID": patient.ClinicID, @@ -96,9 +95,10 @@ class PatientsProvider with ChangeNotifier { "PatientOutSA": patient.PatientOutSA }); - return localResponse; - } catch (err) { - handelCatchErrorCase(error); + return Future.value(localRes); + } catch (error) { + print(error); + throw error; } } diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart index bbbe327a..80d9332d 100644 --- a/lib/screens/QR_reader_screen.dart +++ b/lib/screens/QR_reader_screen.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -159,9 +160,9 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); } else { setState(() { isError = true; - error = 'No patient'; isLoading = false; }); + DrAppToastMsg.showErrorToast('No patient'); } break; case "1": @@ -176,20 +177,27 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); }); } else { setState(() { - error = 'No patient'; isError = true; isLoading = false; }); + DrAppToastMsg.showErrorToast('No patient'); break; } } } else { setState(() { - error = response['ErrorEndUserMessage'] ?? response['ErrorMessage'] ; isLoading = false; isError = true; }); + DrAppToastMsg.showErrorToast(response['ErrorEndUserMessage'] ?? response['ErrorMessage']); + } + }).catchError((error){ + setState(() { + isLoading = false; + }); + helpers.showErrorToast(error); + //DrAppToastMsg.showErrorToast(error); }); } // } diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index f7b9d444..cd0f94a3 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -15,7 +15,8 @@ class MyScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { scheduleProvider = Provider.of(context); - return Scaffold( + return AppScaffold( + appBarTitle: TranslationBase.of(context).mySchedule, body: scheduleProvider.isLoading ? DrAppCircularProgressIndeicator() : scheduleProvider.isError diff --git a/lib/screens/patients/patients_list_screen.dart b/lib/screens/patients/patients_list_screen.dart index 6d0b97a8..150de5df 100644 --- a/lib/screens/patients/patients_list_screen.dart +++ b/lib/screens/patients/patients_list_screen.dart @@ -33,6 +33,10 @@ class _PatientsListScreenState extends State { print(res); }).catchError((error) { print(error); + setState(() { + _isLoading = false; + _hasError = error; + }); }); } _isInit = false; diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 1128832f..a5142dce 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -104,7 +104,8 @@ class _PatientsScreenState extends State { }).catchError((error) { setState(() { _isError = true; - this.error = helpers.generateContactAdminMsg(error); + _isLoading = false; + this.error = error; }); }); } diff --git a/lib/screens/patients/profile/radiology/radiology_screen.dart b/lib/screens/patients/profile/radiology/radiology_screen.dart index 1ddf944e..5d232d3a 100644 --- a/lib/screens/patients/profile/radiology/radiology_screen.dart +++ b/lib/screens/patients/profile/radiology/radiology_screen.dart @@ -132,10 +132,6 @@ class _RadiologyScreenState extends State { url: patientsProv .patientRadiologyList[index] .doctorImageURL, - name: patientsProv - .patientLabResultOrdersList[ - index] - .doctorName, ), Expanded( child: Padding( diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart index 02d3f10a..67db51fa 100644 --- a/lib/widgets/doctor/my_referral_patient_widget.dart +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -42,24 +42,26 @@ class _MyReferralPatientWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText( - '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', - fontSize: 2.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - InkWell( - onTap: () { - setState(() { - _showDetails = !_showDetails; - }); - }, - child: Icon(_showDetails - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down)), - ], + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down), + + ], + ), ), !_showDetails ? Container() @@ -87,6 +89,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.referringDoctor}', fontSize: @@ -108,6 +111,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( widget.myReferralPatientModel .referringClinicDescription, @@ -135,6 +139,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.referringClinicDescription}', fontSize: @@ -157,6 +162,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( widget.myReferralPatientModel .frequencyDescription, @@ -184,6 +190,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( '${widget.myReferralPatientModel.priorityDescription}', fontSize: @@ -206,6 +213,7 @@ class _MyReferralPatientWidgetState extends State { 1.7 * SizeConfig.textMultiplier, fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), AppText( Helpers.getDateFormatted(widget .myReferralPatientModel diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index 54cbcb30..3b70f393 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -35,25 +35,27 @@ class LargeAvatar extends StatelessWidget { ), ), ); - } else if (name == null || name.isEmpty) { + } else if (name != null || name.isNotEmpty) { return Center( child: AppText( - 'DR', + name[0].toUpperCase(), color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, )); } else { return Center( child: AppText( - name[0].toUpperCase(), + 'DR', color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.bold, )); } } @override Widget build(BuildContext context) { + var vlr = name; + var asd; return InkWell( onTap: disableProfileView ? null From 395a7947c313dc61087d31149ff35c8572a40a0e Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 11 Jun 2020 11:37:12 +0300 Subject: [PATCH 22/42] improve auth app --- lib/client/base_app_client.dart | 8 ++-- lib/providers/patients_provider.dart | 2 + lib/screens/auth/login_screen.dart | 2 +- lib/screens/dashboard_screen.dart | 21 ++++++---- lib/util/dr_app_shared_pref.dart | 14 ++++++- lib/util/helpers.dart | 14 +++++++ lib/widgets/auth/login_form.dart | 45 ++++++++++++++------- lib/widgets/auth/verfiy_account.dart | 33 +++++++++------ lib/widgets/auth/verification_methods.dart | 3 +- lib/widgets/shared/app_scaffold_widget.dart | 2 + 10 files changed, 101 insertions(+), 43 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 031c70ac..5ce4266d 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -7,7 +7,6 @@ import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -47,7 +46,7 @@ class BaseAppClient { if (!body.containsKey('ClinicID')) body['ClinicID'] = doctorProfile?.clinicID; } - body['TokenID'] = token ?? ''; + body['TokenID'] = token?? ''; body['LanguageID'] = LANGUAGE_ID; body['stamp'] = STAMP; body['IPAdress'] = IP_ADDRESS; @@ -57,7 +56,7 @@ class BaseAppClient { body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = PATIENT_OUT_SA; - if (await Helpers.checkConnection()) { + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), headers: { @@ -70,7 +69,8 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); + await helpers.logout(); + helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 2984398e..d0f2363a 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -13,6 +13,7 @@ import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import '../config/config.dart'; @@ -25,6 +26,7 @@ import '../models/patient/vital_sign_res_model.dart'; import '../util/helpers.dart'; Helpers helpers = Helpers(); +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class PatientsProvider with ChangeNotifier { bool isLoading = false; diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 2d43a048..737f42e4 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -56,7 +56,7 @@ class _LoginsreenState extends State { @override Widget build(BuildContext context) { - AppGlobal.CONTEX = context; + getSharedPref(); return AppScaffold( isLoading: _isLoading, diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index a00471df..d8e31273 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -36,13 +36,18 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { + FocusScopeNode currentFocus = FocusScope.of(context); + + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } projectsProvider = Provider.of(context); return SafeArea( bottom: true, child: Scaffold( body: SingleChildScrollView( child: SizedBox( - height: MediaQuery.of(context).size.height*1.09, + height: MediaQuery.of(context).size.height * 1.09, // height: MediaQuery.of(context).size.height * 0.2, // width: SizeConfig.screenWidth * 0.9, child: Column( @@ -101,16 +106,17 @@ class _DashboardScreenState extends State { flex: 1, child: Column( crossAxisAlignment: - CrossAxisAlignment.stretch, + CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).arrived, + TranslationBase.of(context).arrived, "23", )), Expanded( child: DashboardItemTexts( - TranslationBase.of(context).notArrived, + TranslationBase.of(context) + .notArrived, "23", ), ), @@ -119,18 +125,17 @@ class _DashboardScreenState extends State { ), Expanded( child: Column( - crossAxisAlignment: + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).er, + TranslationBase.of(context).er, "23", )), Expanded( child: DashboardItemTexts( - - TranslationBase.of(context).walkIn, + TranslationBase.of(context).walkIn, "23", )), ], diff --git a/lib/util/dr_app_shared_pref.dart b/lib/util/dr_app_shared_pref.dart index f75c171e..830622e1 100644 --- a/lib/util/dr_app_shared_pref.dart +++ b/lib/util/dr_app_shared_pref.dart @@ -74,12 +74,22 @@ class DrAppSharedPreferances { return prefs.getInt(key); } - getObj(String key) async{ + getObj(String key) async { final SharedPreferences prefs = await _prefs; var string = prefs.getString(key); - if (string == null ){ + if (string == null) { return null; } return json.decode(string); } + + clear() async { + final SharedPreferences prefs = await _prefs; + prefs.clear(); + } + + remove(String key) async { + final SharedPreferences prefs = await _prefs; + prefs.remove(key); + } } diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index ea8352f7..ebcf817c 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -1,12 +1,17 @@ import 'package:doctor_app_flutter/models/list_doctor_working_hours_table_model.dart'; +import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:doctor_app_flutter/config/config.dart'; import '../config/size_config.dart'; import '../util/dr_app_toast_msg.dart'; import 'package:connectivity/connectivity.dart'; +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + /* *@author: Elham Rababah *@Date:12/4/2020 @@ -329,4 +334,13 @@ class Helpers { } return localMsg; } + + clearSharedPref() async { + await sharedPref.clear(); + } + + logout() async { + await clearSharedPref(); + Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); + } } diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index a00268f9..bfbc5a59 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -97,8 +97,9 @@ class _LoginFormState extends State { userInfo.UserID = value.trim(); }, onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus(focusPass); + FocusScope.of(context).nextFocus(); }, + autofocus: false, ), buildSizedBox(), TextFormField( @@ -117,7 +118,7 @@ class _LoginFormState extends State { userInfo.Password = value; }, onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus(focusProject); + FocusScope.of(context).nextFocus(); helpers.showCupertinoPicker( context, projectsList, 'Name', onSelectProject); }, @@ -188,17 +189,26 @@ class _LoginFormState extends State { */ InputDecoration buildInputDecoration(BuildContext context, hint, asset) { return InputDecoration( - prefixIcon: Image.asset(asset), - hintText: hint, - hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - )); + prefixIcon: Image.asset(asset), + hintText: hint, + hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).primaryColor), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + ); } SizedBox buildSizedBox() { @@ -208,6 +218,11 @@ class _LoginFormState extends State { } login(context, AuthProvider authProv, Function changeLoadingStata) { + FocusScopeNode currentFocus = FocusScope.of(context); + + // if (!currentFocus.hasPrimaryFocus) { + // currentFocus.unfocus(); + // } changeLoadingStata(true); if (loginFormKey.currentState.validate()) { loginFormKey.currentState.save(); @@ -221,7 +236,7 @@ class _LoginFormState extends State { sharedPref.setString(TOKEN, res['LogInTokenID']); print("token" + res['LogInTokenID']); - Navigator.of(context).pushNamed(VERIFICATION_METHODS); + Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); } else { // handel error // widget.showCenterShortLoadingToast("watting"); @@ -231,7 +246,7 @@ class _LoginFormState extends State { }).catchError((err) { print('$err'); changeLoadingStata(false); - helpers.showErrorToast(); + helpers.showErrorToast(err); }); } else { changeLoadingStata(false); diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index c72b0c10..0448c838 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -264,16 +264,25 @@ class _VerifyAccountState extends State { */ InputDecoration buildInputDecoration(BuildContext context) { return InputDecoration( - // ts/images/password_icon.png - contentPadding: EdgeInsets.only(top: 30, bottom: 30), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10)), - borderSide: BorderSide(color: Colors.black), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - )); + // ts/images/password_icon.png + contentPadding: EdgeInsets.only(top: 30, bottom: 30), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: Colors.black), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).primaryColor), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + ); } /* @@ -322,7 +331,7 @@ class _VerifyAccountState extends State { verifyAccountFormValue['digit4']; print(activationCode); int projectID = await sharedPref.getInt(PROJECT_ID); - Map model = { + Map model = { "activationCode": activationCode, "DoctorID": _loggedUser['DoctorID'], "LogInTokenID": _loggedUser['LogInTokenID'], @@ -381,7 +390,7 @@ class _VerifyAccountState extends State { Map profile, Function changeLoadingStata) { changeLoadingStata(false); sharedPref.setObj(DOCTOR_PROFILE, profile); - Navigator.of(context).pushNamed(HOME); + Navigator.of(context).pushReplacementNamed(HOME); } Future _asyncSimpleDialog( diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index af72b092..2b620e10 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -251,6 +251,7 @@ class _VerificationMethodsState extends State { *@desc: send Activation Code By Otp Notification Type */ sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) { + // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); @@ -270,7 +271,7 @@ class _VerificationMethodsState extends State { widget.changeLoadingStata(false); if (res['MessageStatus'] == 1) { - Navigator.of(context).pushNamed(VERIFY_ACCOUNT, arguments: {'model':model}); + Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, arguments: {'model':model}); } else { print(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 80c1a7d3..5b87dba0 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -13,6 +14,7 @@ class AppScaffold extends StatelessWidget { @override Widget build(BuildContext context) { + AppGlobal.CONTEX = context; return Scaffold( backgroundColor: Hexcolor('#F5F5F5'), appBar: appBarTitle != '' From 25d42c4a26ea7ab269a2cff296b07ed9780ad6ba Mon Sep 17 00:00:00 2001 From: Elham Date: Thu, 11 Jun 2020 08:43:00 +0000 Subject: [PATCH 23/42] Revert "Merge branch 'elham' into 'master'" This reverts merge request !105 --- lib/client/base_app_client.dart | 8 +-- lib/providers/patients_provider.dart | 2 - lib/screens/auth/login_screen.dart | 2 +- lib/screens/dashboard_screen.dart | 21 +++---- lib/util/dr_app_shared_pref.dart | 14 +---- lib/util/helpers.dart | 36 ++++------- lib/widgets/auth/login_form.dart | 69 +++++++++++---------- lib/widgets/auth/verfiy_account.dart | 33 ++++------ lib/widgets/auth/verification_methods.dart | 3 +- lib/widgets/shared/app_scaffold_widget.dart | 7 ++- 10 files changed, 81 insertions(+), 114 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index d04cfa78..93ca0690 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:http_interceptor/http_methods.dart'; import 'package:http_interceptor/models/request_data.dart'; @@ -51,7 +52,7 @@ class BaseAppClient { // if (!body.containsKey('ClinicID')) body['ClinicID'] = doctorProfile?.clinicID; } - body['TokenID'] = token?? ''; + body['TokenID'] = token ?? ''; body['LanguageID'] = LANGUAGE_ID; body['stamp'] = STAMP; body['IPAdress'] = IP_ADDRESS; @@ -63,7 +64,7 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - if (await Helpers.checkConnection()) { + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), headers: { @@ -76,8 +77,7 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - await helpers.logout(); - + Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 2a626c28..3aebd306 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -13,7 +13,6 @@ import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import '../config/config.dart'; @@ -26,7 +25,6 @@ import '../models/patient/vital_sign_res_model.dart'; import '../util/helpers.dart'; Helpers helpers = Helpers(); -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class PatientsProvider with ChangeNotifier { bool isLoading = false; diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 737f42e4..2d43a048 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -56,7 +56,7 @@ class _LoginsreenState extends State { @override Widget build(BuildContext context) { - + AppGlobal.CONTEX = context; getSharedPref(); return AppScaffold( isLoading: _isLoading, diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index d8e31273..a00471df 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -36,18 +36,13 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { - FocusScopeNode currentFocus = FocusScope.of(context); - - if (!currentFocus.hasPrimaryFocus) { - currentFocus.unfocus(); - } projectsProvider = Provider.of(context); return SafeArea( bottom: true, child: Scaffold( body: SingleChildScrollView( child: SizedBox( - height: MediaQuery.of(context).size.height * 1.09, + height: MediaQuery.of(context).size.height*1.09, // height: MediaQuery.of(context).size.height * 0.2, // width: SizeConfig.screenWidth * 0.9, child: Column( @@ -106,17 +101,16 @@ class _DashboardScreenState extends State { flex: 1, child: Column( crossAxisAlignment: - CrossAxisAlignment.stretch, + CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).arrived, + TranslationBase.of(context).arrived, "23", )), Expanded( child: DashboardItemTexts( - TranslationBase.of(context) - .notArrived, + TranslationBase.of(context).notArrived, "23", ), ), @@ -125,17 +119,18 @@ class _DashboardScreenState extends State { ), Expanded( child: Column( - crossAxisAlignment: + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).er, + TranslationBase.of(context).er, "23", )), Expanded( child: DashboardItemTexts( - TranslationBase.of(context).walkIn, + + TranslationBase.of(context).walkIn, "23", )), ], diff --git a/lib/util/dr_app_shared_pref.dart b/lib/util/dr_app_shared_pref.dart index 830622e1..f75c171e 100644 --- a/lib/util/dr_app_shared_pref.dart +++ b/lib/util/dr_app_shared_pref.dart @@ -74,22 +74,12 @@ class DrAppSharedPreferances { return prefs.getInt(key); } - getObj(String key) async { + getObj(String key) async{ final SharedPreferences prefs = await _prefs; var string = prefs.getString(key); - if (string == null) { + if (string == null ){ return null; } return json.decode(string); } - - clear() async { - final SharedPreferences prefs = await _prefs; - prefs.clear(); - } - - remove(String key) async { - final SharedPreferences prefs = await _prefs; - prefs.remove(key); - } } diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index ebcf817c..e05f0d74 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -1,16 +1,12 @@ import 'package:doctor_app_flutter/models/list_doctor_working_hours_table_model.dart'; -import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:doctor_app_flutter/config/config.dart'; import '../config/size_config.dart'; import '../util/dr_app_toast_msg.dart'; import 'package:connectivity/connectivity.dart'; -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); /* *@author: Elham Rababah @@ -52,6 +48,10 @@ class Helpers { onPressed: () { Navigator.pop(context); }, + // padding: const EdgeInsets.symmetric( + // horizontal: 16.0, + // vertical: 5.0, + // ), ), CupertinoButton( child: Text( @@ -97,7 +97,7 @@ class Helpers { children: items.map((item) { return Text( '${item["$decKey"]}', - style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), + style: TextStyle(fontSize: SizeConfig.textMultiplier * 3), ); }).toList(), @@ -164,15 +164,14 @@ class Helpers { ), ); } - - /* + /* *@author: Amjad Amireh *@Date:5/5/2020 *@param: checkDate *@return: DateTime *@desc: convert String to DateTime */ - static String checkDate(String dateString) { +static String checkDate(String dateString) { DateTime checkedTime = DateTime.parse(dateString); DateTime currentTime = DateTime.now(); @@ -258,7 +257,6 @@ class Helpers { return "Sunday"; } } - /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -277,7 +275,6 @@ class Helpers { else return ""; } - /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -304,14 +301,13 @@ class Helpers { *@return: List *@desc: convert workingHours string to List */ - static List getWorkingHours(String workingHours) { - List myWorkingHours = []; + static List getWorkingHours(String workingHours ){ + List myWorkingHours =[]; List listOfHours = workingHours.split('a'); listOfHours.forEach((element) { WorkingHours workingHours = WorkingHours(); - var from = element.substring( - element.indexOf('m ') + 2, element.indexOf('To') - 2); + var from = element.substring(element.indexOf('m ') + 2 , element.indexOf('To')-2); workingHours.from = from.trim(); var to = element.substring(element.indexOf('To') + 2); workingHours.to = to.trim(); @@ -320,6 +316,9 @@ class Helpers { return myWorkingHours; } + + + /* *@author: Elham Rababah *@Date:12/5/2020 @@ -334,13 +333,4 @@ class Helpers { } return localMsg; } - - clearSharedPref() async { - await sharedPref.clear(); - } - - logout() async { - await clearSharedPref(); - Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); - } } diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index bfbc5a59..ba6c9a02 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -54,15 +54,17 @@ class _LoginFormState extends State { void initState() { super.initState(); initPlatformState(); + + } @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { - if (projectsList.length == 0) { - getProjectsList(); - } + if (projectsList.length == 0) { + getProjectsList(); + } } _isInit = false; } @@ -97,9 +99,8 @@ class _LoginFormState extends State { userInfo.UserID = value.trim(); }, onFieldSubmitted: (_) { - FocusScope.of(context).nextFocus(); + FocusScope.of(context).requestFocus(focusPass); }, - autofocus: false, ), buildSizedBox(), TextFormField( @@ -118,7 +119,7 @@ class _LoginFormState extends State { userInfo.Password = value; }, onFieldSubmitted: (_) { - FocusScope.of(context).nextFocus(); + FocusScope.of(context).requestFocus(focusProject); helpers.showCupertinoPicker( context, projectsList, 'Name', onSelectProject); }, @@ -143,8 +144,22 @@ class _LoginFormState extends State { }), buildSizedBox(), Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Checkbox( + value: true, + activeColor: Theme.of(context).primaryColor, + onChanged: (bool newValue) {}), + Text("Remember me", + style: TextStyle( + fontSize: 2 * SizeConfig.textMultiplier)), + ], + ), + ), RaisedButton( onPressed: () { login(context, authProv, widget.changeLoadingStata); @@ -189,26 +204,17 @@ class _LoginFormState extends State { */ InputDecoration buildInputDecoration(BuildContext context, hint, asset) { return InputDecoration( - prefixIcon: Image.asset(asset), - hintText: hint, - hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - ), - errorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), - ), - focusedErrorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), - ), - ); + prefixIcon: Image.asset(asset), + hintText: hint, + hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).primaryColor), + )); } SizedBox buildSizedBox() { @@ -218,11 +224,6 @@ class _LoginFormState extends State { } login(context, AuthProvider authProv, Function changeLoadingStata) { - FocusScopeNode currentFocus = FocusScope.of(context); - - // if (!currentFocus.hasPrimaryFocus) { - // currentFocus.unfocus(); - // } changeLoadingStata(true); if (loginFormKey.currentState.validate()) { loginFormKey.currentState.save(); @@ -236,7 +237,7 @@ class _LoginFormState extends State { sharedPref.setString(TOKEN, res['LogInTokenID']); print("token" + res['LogInTokenID']); - Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); + Navigator.of(context).pushNamed(VERIFICATION_METHODS); } else { // handel error // widget.showCenterShortLoadingToast("watting"); @@ -246,7 +247,7 @@ class _LoginFormState extends State { }).catchError((err) { print('$err'); changeLoadingStata(false); - helpers.showErrorToast(err); + helpers.showErrorToast(); }); } else { changeLoadingStata(false); diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 0448c838..c72b0c10 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -264,25 +264,16 @@ class _VerifyAccountState extends State { */ InputDecoration buildInputDecoration(BuildContext context) { return InputDecoration( - // ts/images/password_icon.png - contentPadding: EdgeInsets.only(top: 30, bottom: 30), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10)), - borderSide: BorderSide(color: Colors.black), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - ), - errorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), - ), - focusedErrorBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).errorColor), - ), - ); + // ts/images/password_icon.png + contentPadding: EdgeInsets.only(top: 30, bottom: 30), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: Colors.black), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).primaryColor), + )); } /* @@ -331,7 +322,7 @@ class _VerifyAccountState extends State { verifyAccountFormValue['digit4']; print(activationCode); int projectID = await sharedPref.getInt(PROJECT_ID); - Map model = { + Map model = { "activationCode": activationCode, "DoctorID": _loggedUser['DoctorID'], "LogInTokenID": _loggedUser['LogInTokenID'], @@ -390,7 +381,7 @@ class _VerifyAccountState extends State { Map profile, Function changeLoadingStata) { changeLoadingStata(false); sharedPref.setObj(DOCTOR_PROFILE, profile); - Navigator.of(context).pushReplacementNamed(HOME); + Navigator.of(context).pushNamed(HOME); } Future _asyncSimpleDialog( diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 2b620e10..af72b092 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -251,7 +251,6 @@ class _VerificationMethodsState extends State { *@desc: send Activation Code By Otp Notification Type */ sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) { - // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); @@ -271,7 +270,7 @@ class _VerificationMethodsState extends State { widget.changeLoadingStata(false); if (res['MessageStatus'] == 1) { - Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, arguments: {'model':model}); + Navigator.of(context).pushNamed(VERIFY_ACCOUNT, arguments: {'model':model}); } else { print(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 5b87dba0..1e6da3fc 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,9 +1,13 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../config/size_config.dart'; +import '../../presentation/doctor_app_icons.dart'; +import '../../widgets/shared/app_drawer_widget.dart'; import '../../widgets/shared/app_loader_widget.dart'; +import '../../widgets/shared/custom_shape_clipper.dart'; class AppScaffold extends StatelessWidget { String appBarTitle; @@ -14,7 +18,6 @@ class AppScaffold extends StatelessWidget { @override Widget build(BuildContext context) { - AppGlobal.CONTEX = context; return Scaffold( backgroundColor: Hexcolor('#F5F5F5'), appBar: appBarTitle != '' From 3eeac2734bde8a0c15329769617cb892256520cc Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Thu, 11 Jun 2020 12:16:51 +0300 Subject: [PATCH 24/42] Modify Patiant screen List style --- lib/screens/patients/profile/progress_note_screen.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/screens/patients/profile/progress_note_screen.dart b/lib/screens/patients/profile/progress_note_screen.dart index 07f0ff88..f9d8be44 100644 --- a/lib/screens/patients/profile/progress_note_screen.dart +++ b/lib/screens/patients/profile/progress_note_screen.dart @@ -20,7 +20,7 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); /* *@author: ibrahim albitar *@Date:15/5/2020 - *@param: + *@param: ' *@return: *@desc: */ @@ -182,7 +182,7 @@ class _ProgressNoteState extends State { if (strExist) { filteredNotesList = null; - filteredNotesList = notesList + filteredNotesList = patientsProv.patientProgressNoteList .where((note) => note["DoctorName"].toString().contains(str.toUpperCase())) .toList(); From e0b841a4c13e50d19948e27a64ee0024bf75391f Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Thu, 11 Jun 2020 12:24:41 +0300 Subject: [PATCH 25/42] change font size --- lib/screens/dashboard_screen.dart | 4 ++-- lib/widgets/patients/dynamic_elements.dart | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index a00471df..20557aeb 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -238,7 +238,7 @@ class _DashboardScreenState extends State { valueFontColor: Colors.black, titleFontColor: Colors.black, iconColor: Colors.black, - titleFontSize: 16, + titleFontSize: 14, ), onTap: () { Navigator.of(context).pushNamed(PATIENT_SEARCH); @@ -268,7 +268,7 @@ class _DashboardScreenState extends State { valueFontColor: Colors.black, titleFontColor: Colors.black, iconColor: Colors.black, - titleFontSize: 16, + titleFontSize: 14, ), ), ), diff --git a/lib/widgets/patients/dynamic_elements.dart b/lib/widgets/patients/dynamic_elements.dart index 8b6fc5a8..be66e88e 100644 --- a/lib/widgets/patients/dynamic_elements.dart +++ b/lib/widgets/patients/dynamic_elements.dart @@ -50,7 +50,7 @@ class _DynamicElementsState extends State { AppTextFormField( textInputType: TextInputType.number, hintText: 'From', - controller: _fromDateController, //_fromDateController, + controller: _fromDateController, inputFormatter: ONLY_DATE, onTap: () { @@ -83,7 +83,7 @@ class _DynamicElementsState extends State { AppTextFormField( textInputType: TextInputType.number, hintText: 'TO', - controller: _fromDateController, //_toDateController, + controller: _toDateController, onTap: () { _presentDatePicker('_selectedToDate'); }, From 3d8f8680b32aed28d92a3ca54daa3bc2178e592a Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 11 Jun 2020 12:27:55 +0300 Subject: [PATCH 26/42] DA-115:add Authentication Type to verfiy account screen --- lib/widgets/auth/verfiy_account.dart | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index 0448c838..611bd315 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -191,20 +191,13 @@ class _VerifyAccountState extends State { validator: validateCodeDigit)) ], ), - // buildSizedBox(40), buildSizedBox(20), buildText(), - // buildSizedBox(10.0), - // Text() - buildSizedBox(40), - - // buildSizedBox(), RaisedButton( onPressed: () { verifyAccount( authProv, widget.changeLoadingStata); - // Navigator.of(context).pushNamed(HOME); }, elevation: 0.0, child: Container( @@ -293,6 +286,16 @@ class _VerifyAccountState extends State { *@desc: buildText */ RichText buildText() { + String medthodName; + switch (model['OTP_SendType']) { + case 1: + medthodName = 'SMS'; + break; + case 2: + medthodName = 'WhatsApp'; + break; + default: + } var text = RichText( text: new TextSpan( style: new TextStyle( @@ -302,7 +305,7 @@ class _VerifyAccountState extends State { new TextSpan( text: 'Login Code ', style: TextStyle(fontWeight: FontWeight.w700)), - new TextSpan(text: 'By SMS, Please enter the code') + new TextSpan(text: 'By ${medthodName}, Please enter the code') ])); return text; } From 5294948a5826065db9c76c4b89ec59b728f250e9 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 11 Jun 2020 13:03:26 +0300 Subject: [PATCH 27/42] fix issues --- lib/landing_page.dart | 9 +------ lib/screens/doctor/my_schedule_screen.dart | 3 +-- lib/widgets/doctor/doctor_reply_widget.dart | 24 ++++++++++++++++++- lib/widgets/doctor/my_schedule_widget.dart | 2 ++ .../patients/profile/large_avatar.dart | 2 -- lib/widgets/shared/app_drawer_widget.dart | 17 +++---------- .../shared/app_expandable_notifier.dart | 1 + lib/widgets/shared/app_scaffold_widget.dart | 11 ++++----- 8 files changed, 36 insertions(+), 33 deletions(-) diff --git a/lib/landing_page.dart b/lib/landing_page.dart index a9f844f8..174a38ab 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -51,14 +51,7 @@ class _LandingPageState extends State { }, ), centerTitle: true, - actions: [ - ProfileImageWidget( - height: 50, - width: 50, - url: - "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png", - ) - ], + ), drawer: Theme( data: Theme.of(context).copyWith( diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index cd0f94a3..f7b9d444 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -15,8 +15,7 @@ class MyScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { scheduleProvider = Provider.of(context); - return AppScaffold( - appBarTitle: TranslationBase.of(context).mySchedule, + return Scaffold( body: scheduleProvider.isLoading ? DrAppCircularProgressIndeicator() : scheduleProvider.isError diff --git a/lib/widgets/doctor/doctor_reply_widget.dart b/lib/widgets/doctor/doctor_reply_widget.dart index 5ec30858..6fc9ec66 100644 --- a/lib/widgets/doctor/doctor_reply_widget.dart +++ b/lib/widgets/doctor/doctor_reply_widget.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/list_gt_my_pationents_question_model.dart'; +import 'package:doctor_app_flutter/presentation/doctor_app_icons.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; @@ -42,7 +43,28 @@ class _DoctorReplyWidgetState extends State { child: Row( children: [ SizedBox(width: 5,), - LargeAvatar(name: widget.reply.patientName,url: '',), + //LargeAvatar(icon: widget.reply.gender == 0 ? DoctorApp.male : DoctorApp.femaleicon ,), + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment(-1, -1), + end: Alignment(1, 1), + colors: [ + Colors.grey[100], + Colors.grey[200], + ]), + boxShadow: [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + offset: Offset(0.0, 5.0), + blurRadius: 16.0) + ], + borderRadius: BorderRadius.all(Radius.circular(50.0)), + ), + width: 80, + height: 80, + child: Icon(widget.reply.gender == 1 ? DoctorApp.male : DoctorApp.femaleicon,size: 80,)), + SizedBox(width: 15,), Expanded( child: Container( diff --git a/lib/widgets/doctor/my_schedule_widget.dart b/lib/widgets/doctor/my_schedule_widget.dart index c37d09ad..48f70d7c 100644 --- a/lib/widgets/doctor/my_schedule_widget.dart +++ b/lib/widgets/doctor/my_schedule_widget.dart @@ -45,6 +45,7 @@ class MyScheduleWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText('From',fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.bold,), + SizedBox(height: 5,), AppText(work.from,fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,) ], ), @@ -56,6 +57,7 @@ class MyScheduleWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText('To',fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.bold,), + SizedBox(height: 5,), AppText(work.to,fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,) ], ), diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index 3b70f393..845f1ee3 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -54,8 +54,6 @@ class LargeAvatar extends StatelessWidget { @override Widget build(BuildContext context) { - var vlr = name; - var asd; return InkWell( onTap: disableProfileView ? null diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index 53228c97..919dc939 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -89,35 +89,24 @@ class _AppDrawerState extends State { }, ), ), - InkWell( - child: DrawerItem("My Schedule", Icons.table_chart), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ChangeNotifierProvider( - create: (_) => ScheduleProvider(), - child: MyScheduleScreen(), - ), - ), - ); - }, - ), InkWell( child: DrawerItem("Settings", Icons.settings), onTap: () { + Navigator.pop(context); Navigator.of(context).pushNamed(SETTINGS); }, ), InkWell( child: DrawerItem("QR Reader", Icons.search), onTap: () { + Navigator.pop(context); Navigator.of(context).pushNamed(QR_READER); }, ), InkWell( child: DrawerItem("lOGOUT", Icons.exit_to_app), onTap: () { + Navigator.pop(context); Navigator.of(context).pushNamed(LOGIN); }, ), diff --git a/lib/widgets/shared/app_expandable_notifier.dart b/lib/widgets/shared/app_expandable_notifier.dart index ca3edd09..4ae87e8a 100644 --- a/lib/widgets/shared/app_expandable_notifier.dart +++ b/lib/widgets/shared/app_expandable_notifier.dart @@ -30,6 +30,7 @@ class AppExpandableNotifier extends StatelessWidget { padding: EdgeInsets.all(10), child: Text( "See Graph Details", + style: TextStyle(fontWeight: FontWeight.bold), )), collapsed: Text(''), expanded: bodyWid, diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 1e6da3fc..a390e064 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -37,12 +37,11 @@ class AppScaffold extends StatelessWidget { }), centerTitle: true, actions: [ - ProfileImageWidget( - height: 50, - width: 50, - url: - "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png", - ) + IconButton( + icon: Icon(DoctorApp.home_icon_active), + color: Colors.white, //Colors.black, + onPressed: () => Navigator.popAndPushNamed(context, HOME), + ), ], ) : null, From c8a3beb5301c29eebbf619ad548de4eb12780019 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 11 Jun 2020 15:13:08 +0300 Subject: [PATCH 28/42] fix issues in dev --- lib/config/config.dart | 3 +++ lib/widgets/shared/app_scaffold_widget.dart | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index d199986c..90b2592f 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -68,3 +68,6 @@ const PATIENT_OUT_SA = false; /// Timer Info const TIMER_MIN =10; +class AppGlobal{ + static var CONTEX; +} diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index fdc8611d..a390e064 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,9 +1,13 @@ -import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; +import '../../config/size_config.dart'; +import '../../presentation/doctor_app_icons.dart'; +import '../../widgets/shared/app_drawer_widget.dart'; import '../../widgets/shared/app_loader_widget.dart'; +import '../../widgets/shared/custom_shape_clipper.dart'; class AppScaffold extends StatelessWidget { String appBarTitle; @@ -14,7 +18,6 @@ class AppScaffold extends StatelessWidget { @override Widget build(BuildContext context) { - AppGlobal.CONTEX = context; return Scaffold( backgroundColor: Hexcolor('#F5F5F5'), appBar: appBarTitle != '' From e545d4992ca5dda2e2c5fe03a815842386350865 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 11 Jun 2020 16:01:00 +0300 Subject: [PATCH 29/42] fix issues in dev --- lib/client/base_app_client.dart | 2 +- lib/widgets/shared/app_scaffold_widget.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 63ae8fca..a6e14c51 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -73,7 +73,7 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); + await helpers.logout(); helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index a390e064..ef8a983b 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -40,7 +40,7 @@ class AppScaffold extends StatelessWidget { IconButton( icon: Icon(DoctorApp.home_icon_active), color: Colors.white, //Colors.black, - onPressed: () => Navigator.popAndPushNamed(context, HOME), + onPressed: () => Navigator.pushReplacementNamed(context, HOME), ), ], ) From 692674fac0571d1f67df6f2793ddec9acf708188 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 11 Jun 2020 17:09:08 +0300 Subject: [PATCH 30/42] merge ibrahim --- lib/client/base_app_client.dart | 59 ++- lib/config/config.dart | 4 + lib/providers/auth_provider.dart | 108 ++-- lib/providers/hospital_provider.dart | 24 +- lib/providers/patients_provider.dart | 448 ++++++---------- lib/screens/QR_reader_screen.dart | 134 ++--- lib/screens/auth/login_screen.dart | 46 +- lib/screens/doctor/my_schedule_screen.dart | 73 +-- .../profile/radiology/radiology_screen.dart | 210 ++++---- lib/widgets/auth/login_form.dart | 79 +-- lib/widgets/auth/verfiy_account.dart | 78 +-- lib/widgets/auth/verification_methods.dart | 33 +- .../doctor/my_referral_patient_widget.dart | 492 +++++++++--------- .../patients/profile/large_avatar.dart | 36 +- 14 files changed, 889 insertions(+), 935 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 0d57b9dd..25b2450c 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -2,10 +2,18 @@ import 'dart:convert'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:http/http.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:http/http.dart' as http; +import 'package:http_interceptor/http_methods.dart'; +import 'package:http_interceptor/models/request_data.dart'; + +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +Helpers helpers = new Helpers(); /* *@author: Mohammad Aljammal @@ -14,6 +22,7 @@ import 'package:http/http.dart'; *@return: *@desc: */ + ///Example /* await BaseAppClient.post('', @@ -22,24 +31,28 @@ import 'package:http/http.dart'; body: null); * */ class BaseAppClient { - static Client client = HttpInterceptor().getClient(); - static post( - String endPoint, { - Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure, - }) async { + String endPoint, { + Map body, + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + }) async { String url = BASE_URL + endPoint; + RequestData data = RequestData(body: body,baseUrl: url,method: Method.POST); + + try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - body['DoctorID'] = doctorProfile.doctorID; - body['EditedBy'] = doctorProfile.doctorID; - body['ProjectID'] = doctorProfile.projectID; - body['ClinicID'] = doctorProfile.clinicID; - body['TokenID'] = token; + if (profile != null) { + DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + body['DoctorID'] = doctorProfile?.doctorID; + body['EditedBy'] = doctorProfile?.doctorID; + body['ProjectID'] = doctorProfile?.projectID; + // if (!body.containsKey('ClinicID')) + body['ClinicID'] = doctorProfile?.clinicID; + } + body['TokenID'] = token ?? ''; body['LanguageID'] = LANGUAGE_ID; body['stamp'] = STAMP; body['IPAdress'] = IP_ADDRESS; @@ -48,15 +61,25 @@ class BaseAppClient { body['SessionID'] = SESSION_ID; body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; body['PatientOutSA'] = PATIENT_OUT_SA; + print("URL : $url"); + print("Body : ${json.encode(body)}"); - if (await Helpers.checkConnection()) { - final response = await client.post(url, body: json.encode(body)); + if (await Helpers.checkConnection()) { + final response = await http.post(url, + body: json.encode(body), + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + }); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { var parsed = json.decode(response.body.toString()); - if (parsed['MessageStatus'] == 1) { + if (!parsed['IsAuthenticated']) { + Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); + helpers.showErrorToast('Your session expired Please login agian'); + } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); } else { onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], diff --git a/lib/config/config.dart b/lib/config/config.dart index d199986c..3c7b107b 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -68,3 +68,7 @@ const PATIENT_OUT_SA = false; /// Timer Info const TIMER_MIN =10; +class AppGlobal{ +static var CONTEX; +} + diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index af93c837..e79192ae 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -1,27 +1,31 @@ -import 'dart:convert'; -import 'package:doctor_app_flutter/client/app_client.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:flutter/cupertino.dart'; + import '../models/user_model.dart'; -const LOGIN_URL = - 'Sentry.svc/REST/MemberLogIN_New'; -const INSERT_DEVICE_IMEI = - 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; +const LOGIN_URL = 'Sentry.svc/REST/MemberLogIN_New'; +const INSERT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; const SELECT_DEVICE_IMEI = 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = 'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; -const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Sentry.svc/REST/MemberCheckActivationCode_New'; +const MEMBER_CHECK_ACTIVATION_CODE_NEW = + 'Sentry.svc/REST/MemberCheckActivationCode_New'; const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; -class AuthProvider with ChangeNotifier { - Future login(UserModel userInfo) async { - const url = LOGIN_URL; +class AuthProvider with ChangeNotifier { + Future login(UserModel userInfo) async { try { - final response = await AppClient.post(url, - body: json.encode({ + dynamic localRes; + + await BaseAppClient.post(LOGIN_URL, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: { "UserID": userInfo.UserID, "Password": userInfo.Password, "ProjectID": userInfo.ProjectID, @@ -30,76 +34,98 @@ class AuthProvider with ChangeNotifier { "VersionID": userInfo.VersionID, "Channel": userInfo.Channel, "SessionID": userInfo.SessionID - })); - return Future.value(json.decode(response.body)); + }); + + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future insertDeviceImei(imei) async { - const url = INSERT_DEVICE_IMEI; - + Future insertDeviceImei(imei) async { try { - final response = await AppClient.post(url, body: json.encode(imei)); - return Future.value(json.decode(response.body)); + dynamic localRes; + + await BaseAppClient.post(INSERT_DEVICE_IMEI, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: imei); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future selectDeviceImei(imei) async { - const url = SELECT_DEVICE_IMEI; - + Future selectDeviceImei(imei) async { try { - final response = await AppClient.post(url, body: json.encode(imei)); - return Future.value(json.decode(response.body)); + dynamic localRes; + await BaseAppClient.post(SELECT_DEVICE_IMEI, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: imei); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future sendActivationCodeByOtpNotificationType( + Future sendActivationCodeByOtpNotificationType( activationCodeModel) async { - const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE; - try { - final response = await AppClient.post(url, body: json.encode(activationCodeModel)); - return Future.value(json.decode(response.body)); + var localRes; + await BaseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - Future memberCheckActivationCodeNew(activationCodeModel) async { - const url = MEMBER_CHECK_ACTIVATION_CODE_NEW; - + Future memberCheckActivationCodeNew(activationCodeModel) async { try { - final response = await AppClient.post(url, body: json.encode(activationCodeModel)); - return Future.value(json.decode(response.body)); + dynamic localRes; + await BaseAppClient.post(MEMBER_CHECK_ACTIVATION_CODE_NEW, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: activationCodeModel); + return Future.value(localRes); } catch (error) { print(error); throw error; } } - /* - *@author: Elham Rababah + /* + *@author: Elham Rababah *@Date:17/5/2020 *@param: docInfo *@return:Future *@desc: getDocProfiles */ - Future getDocProfiles(docInfo) async { - const url = GET_DOC_PROFILES; - + Future getDocProfiles(docInfo) async { try { - final response = await AppClient.post(url, body: json.encode(docInfo)); - return Future.value(json.decode(response.body)); + dynamic localRes; + await BaseAppClient.post(GET_DOC_PROFILES, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: docInfo); + return Future.value(localRes); } catch (error) { print(error); throw error; diff --git a/lib/providers/hospital_provider.dart b/lib/providers/hospital_provider.dart index abf758a2..547bffe2 100644 --- a/lib/providers/hospital_provider.dart +++ b/lib/providers/hospital_provider.dart @@ -1,11 +1,8 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/client/app_client.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/cupertino.dart'; class HospitalProvider with ChangeNotifier { - Future getProjectsList() async { const url = GET_PROJECTS; var info = { @@ -18,12 +15,17 @@ class HospitalProvider with ChangeNotifier { "SessionID": "i1UJwCTSqt", "IsLoginForDoctorApp": true }; - try { - final response = await AppClient.post(url, body: json.encode(info)); - return Future.value(json.decode(response.body)); - } catch (error) { - throw error; - // print('error'); - } + dynamic localRes ; + + await BaseAppClient.post(url, + onSuccess: ( response, statusCode) async { + localRes= response; + }, + onFailure: (String error, int statusCode) { + throw error; + }, + body: info); + return Future.value(localRes); + } } diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 754af77b..6da89e74 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -16,13 +16,10 @@ import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart'; import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart'; import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart'; import 'package:doctor_app_flutter/models/prescription_report.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; -import 'package:http/http.dart'; -import 'package:http_interceptor/http_client_with_interceptor.dart'; -import '../client/app_client.dart'; import '../config/config.dart'; -import '../interceptor/http_interceptor.dart'; import '../models/patient/lab_orders_res_model.dart'; import '../models/patient/patiant_info_model.dart'; import '../models/patient/patient_model.dart'; @@ -32,6 +29,7 @@ import '../models/patient/vital_sign_res_model.dart'; import '../util/helpers.dart'; Helpers helpers = Helpers(); +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class PatientsProvider with ChangeNotifier { bool isLoading = false; @@ -60,31 +58,26 @@ class PatientsProvider with ChangeNotifier { var referalFrequancyList = []; DoctorsByClinicIdRequest _doctorsByClinicIdRequest = - DoctorsByClinicIdRequest(); + DoctorsByClinicIdRequest(); STPReferralFrequencyRequest _referralFrequencyRequest = - STPReferralFrequencyRequest(); + STPReferralFrequencyRequest(); ClinicByProjectIdRequest _clinicByProjectIdRequest = - ClinicByProjectIdRequest(); - ReferToDoctorRequest _referToDoctorRequest ; - Client client = - HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); + ClinicByProjectIdRequest(); + ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); PatiantInformtion _selectedPatient; - Future getPatientList(PatientModel patient, patientType) async { - /* const url = - BASE_URL+'DoctorApplication.svc/REST/GetMyInPatient';*/ - + Future getPatientList(PatientModel patient, patientType) async { int val = int.parse(patientType); - //**********Modify url by amjad amireh for patiant type********* - - final url = - BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val]; - // print("a===========$url=======a"); try { - final response = await client.post(url, - body: json.encode({ + dynamic localRes; + await BaseAppClient.post('DoctorApplication.svc/REST/' + SERVICES_PATIANT[val], + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: { "ProjectID": patient.ProjectID, "ClinicID": patient.ClinicID, "DoctorID": patient.DoctorID, @@ -105,13 +98,12 @@ class PatientsProvider with ChangeNotifier { "SessionID": patient.SessionID, "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, "PatientOutSA": patient.PatientOutSA - })); -//********************** -//*********************** + }); - return Future.value(json.decode(response.body)); - } catch (err) { - throw err; + return Future.value(localRes); + } catch (error) { + print(error); + throw error; } } @@ -133,21 +125,10 @@ class PatientsProvider with ChangeNotifier { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(GET_PATIENT_VITAL_SIGN, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_PATIENT_VITAL_SIGN, + onSuccess: (dynamic response, int statusCode) { patientVitalSignList = []; - res['List_DoctorPatientVitalSign'].forEach((v) { + response['List_DoctorPatientVitalSign'].forEach((v) { patientVitalSignList.add(new VitalSignResModel.fromJson(v)); }); @@ -160,21 +141,22 @@ class PatientsProvider with ChangeNotifier { a.vitalSignDate.microsecondsSinceEpoch; }); patientVitalSignOrderdSubList.clear(); - for (int x = 0; x < 20; x++) { + int length = patientVitalSignOrderdSubListTemp.length >= 20 + ? 20 + : patientVitalSignOrderdSubListTemp.length; + for (int x = 0; x < length; x++) { patientVitalSignOrderdSubList .add(patientVitalSignOrderdSubListTemp[x]); } } - } else { + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -193,33 +175,20 @@ class PatientsProvider with ChangeNotifier { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(GET_PATIENT_LAB_OREDERS, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_PATIENT_LAB_OREDERS, + onSuccess: (dynamic response, int statusCode) { patientLabResultOrdersList = []; - res['List_GetLabOreders'].forEach((v) { + response['List_GetLabOreders'].forEach((v) { patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); }); - } else { + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -234,36 +203,21 @@ class PatientsProvider with ChangeNotifier { */ getOutPatientPrescriptions(patient) async { setBasicData(); - try { - if (await Helpers.checkConnection()) { - final response = - await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_PRESCRIPTION, + onSuccess: (dynamic response, int statusCode) { patientPrescriptionsList = []; - res['PatientPrescriptionList'].forEach((v) { - patientPrescriptionsList - .add(new PrescriptionResModel.fromJson(v)); + response['PatientPrescriptionList'].forEach((v) { + patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v)); }); - } else { + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -284,13 +238,13 @@ class PatientsProvider with ChangeNotifier { await BaseAppClient.post( 'DoctorApplication.svc/REST/GetPrescriptionReportForInPatient', onSuccess: (dynamic response, int statusCode) { - response['List_PrescriptionReportForInPatient'].forEach((v) { - prescriptionReportForInPatientList - .add(PrescriptionReportForInPatient.fromJson(v)); - }); - isError = false; - isLoading = false; - }, onFailure: (String error, int statusCode) { + response['List_PrescriptionReportForInPatient'].forEach((v) { + prescriptionReportForInPatientList + .add(PrescriptionReportForInPatient.fromJson(v)); + }); + isError = false; + isLoading = false; + }, onFailure: (String error, int statusCode) { isError = true; isLoading = false; this.error = error; @@ -309,16 +263,16 @@ class PatientsProvider with ChangeNotifier { notifyListeners(); await BaseAppClient.post('Patients.svc/REST/GetPrescriptionReport', onSuccess: (dynamic response, int statusCode) { - response['ListPRM'].forEach((v) { - prescriptionReport.add(PrescriptionReport.fromJson(v)); - }); - isError = false; - isLoading = false; - }, onFailure: (String error, int statusCode) { - isError = true; - isLoading = false; - this.error = error; - }, body: prescriptionReqModel); + response['ListPRM'].forEach((v) { + prescriptionReport.add(PrescriptionReport.fromJson(v)); + }); + isError = false; + isLoading = false; + }, onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error = error; + }, body: prescriptionReqModel); notifyListeners(); } @@ -347,33 +301,20 @@ class PatientsProvider with ChangeNotifier { // notifyListeners(); setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = - await AppClient.post(GET_RADIOLOGY, body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { + await BaseAppClient.post(GET_RADIOLOGY, + onSuccess: (dynamic response, int statusCode) { patientRadiologyList = []; - res['List_GetRadOreders'].forEach((v) { + response['List_GetRadOreders'].forEach((v) { patientRadiologyList.add(new RadiologyResModel.fromJson(v)); }); - } else { + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -391,47 +332,33 @@ class PatientsProvider with ChangeNotifier { requestLabResult.patientTypeID = labOrdersResModel.patientType; await BaseAppClient.post('DoctorApplication.svc/REST/GetPatientLabResults', onSuccess: (dynamic response, int statusCode) { - isError = false; - isLoading = false; - response['List_GetLabNormal'].forEach((v) { - labResultList.add(new LabResult.fromJson(v)); - }); - }, onFailure: (String error, int statusCode) { - isError = true; - isLoading = false; - this.error = error; - }, body: requestLabResult.toJson()); + isError = false; + isLoading = false; + response['List_GetLabNormal'].forEach((v) { + labResultList.add(new LabResult.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error = error; + }, body: requestLabResult.toJson()); notifyListeners(); } getPatientInsuranceApprovals(patient) async { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - //patientRadiologyList = []; - insuranceApporvalsList = res['List_ApprovalMain_InPatient']; - } else { + await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL, + onSuccess: (dynamic response, int statusCode) { + insuranceApporvalsList = response['List_ApprovalMain_InPatient']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -445,30 +372,17 @@ class PatientsProvider with ChangeNotifier { getPatientProgressNote(patient) async { setBasicData(); try { - if (await Helpers.checkConnection()) { - final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL, - body: json.encode(patient)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - patientProgressNoteList = res['List_GetPregressNoteForInPatient']; - } else { + await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL, + onSuccess: (dynamic response, int statusCode) { + patientProgressNoteList = response['List_GetPregressNoteForInPatient']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: patient); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -480,51 +394,29 @@ class PatientsProvider with ChangeNotifier { *@desc: getDoctorsList */ getDoctorsList(String clinicId) async { - String token = await sharedPref.getString(TOKEN); - int projectID = await sharedPref.getInt(PROJECT_ID); setBasicData(); try { - if (await Helpers.checkConnection()) { - _doctorsByClinicIdRequest.projectID = projectID; - _doctorsByClinicIdRequest.clinicID = clinicId; - _doctorsByClinicIdRequest.tokenID = token; - - final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, - body: json.encode(_doctorsByClinicIdRequest)); - final int statusCode = response.statusCode; - - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - isLoading = false; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - doctorsList = res['List_Doctors_All']; - isLoading = false; - } else { + _doctorsByClinicIdRequest.clinicID = clinicId; + await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL, + onSuccess: (dynamic response, int statusCode) { + doctorsList = response['List_Doctors_All']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - isLoading = false; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: _doctorsByClinicIdRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); - isLoading = false; } } List getDoctorNameList() { var doctorNamelist = - doctorsList.map((value) => value['DoctorName'].toString()).toList(); + doctorsList.map((value) => value['DoctorName'].toString()).toList(); return doctorNamelist; } @@ -533,37 +425,19 @@ class PatientsProvider with ChangeNotifier { *@desc: getClinicsList */ getClinicsList() async { - String token = await sharedPref.getString(TOKEN); setBasicData(); try { - if (await Helpers.checkConnection()) { - int projectID = await sharedPref.getInt(PROJECT_ID); - _clinicByProjectIdRequest.projectID = projectID; - _clinicByProjectIdRequest.tokenID = token; - - final response = await AppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, - body: json.encode(_clinicByProjectIdRequest)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - clinicsList = res['List_Clinic_All']; - } else { + await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL, + onSuccess: (dynamic response, int statusCode) { + clinicsList = response['List_Clinic_All']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: _clinicByProjectIdRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -582,33 +456,19 @@ class PatientsProvider with ChangeNotifier { *@desc: getReferralFrequancyList */ getReferralFrequancyList() async { - String token = await sharedPref.getString(TOKEN); setBasicData(); try { - if (await Helpers.checkConnection()) { - _referralFrequencyRequest.tokenID = token; - final response = await AppClient.post(PATIENT_GET_LIST_REFERAL_URL, - body: json.encode(_referralFrequencyRequest)); - final int statusCode = response.statusCode; - isLoading = false; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - referalFrequancyList = res['list_STPReferralFrequency']; - } else { + await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL, + onSuccess: (dynamic response, int statusCode) { + referalFrequancyList = response['list_STPReferralFrequency']; + isLoading = false; + isError = false; + this.error = ''; + }, onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, body: _referralFrequencyRequest.toJson()); notifyListeners(); } catch (err) { handelCatchErrorCase(err); @@ -628,23 +488,23 @@ class PatientsProvider with ChangeNotifier { */ referToDoctor(context, {String selectedDoctorID, - String selectedClinicID, - int admissionNo, - String extension, - String priority, - String frequency, - String referringDoctorRemarks, - int patientID, - int patientTypeID, - String roomID, - int projectID}) async { + String selectedClinicID, + int admissionNo, + String extension, + String priority, + String frequency, + String referringDoctorRemarks, + int patientID, + int patientTypeID, + String roomID, + int projectID}) async { setBasicData(); try { if (await Helpers.checkConnection()) { String token = await sharedPref.getString(TOKEN); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = - new DoctorProfileModel.fromJson(profile); + new DoctorProfileModel.fromJson(profile); int doctorID = doctorProfile.doctorID; int clinicId = doctorProfile.clinicID; _referToDoctorRequest = ReferToDoctorRequest( diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart index bbbe327a..27afd2ee 100644 --- a/lib/screens/QR_reader_screen.dart +++ b/lib/screens/QR_reader_screen.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart'; import 'package:doctor_app_flutter/providers/patients_provider.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -23,7 +24,7 @@ class QrReaderScreen extends StatefulWidget { } class _QrReaderScreenState extends State { -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); bool isLoading = false; bool isError = false; @@ -72,9 +73,9 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); height: 7, ), AppText( - 'scan Qr code to retrieve patient profile', - fontSize: 14, - fontWeight: FontWeight.w400, + 'scan Qr code to retrieve patient profile', + fontSize: 14, + fontWeight: FontWeight.w400, textAlign: TextAlign.center ), SizedBox( @@ -123,15 +124,15 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); /// var result = await BarcodeScanner.scan(); /// int patientID = get from qr result var result = await BarcodeScanner.scan(); - // if (result.rawContent == "") { - List listOfParams = result.rawContent.split(','); - String patientType = "1"; - setState(() { - isLoading = true; - isError = false; - patientList = []; - }); - String token = await sharedPref.getString(TOKEN); + // if (result.rawContent == "") { + List listOfParams = result.rawContent.split(','); + String patientType = "1"; + setState(() { + isLoading = true; + isError = false; + patientList = []; + }); + String token = await sharedPref.getString(TOKEN); // Map profile = await sharedPref.getObj(DOCTOR_PROFILE); // DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); // patient.PatientID = 8808; @@ -140,57 +141,64 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); // patient.setClinicID = doctorProfile.clinicID; // patient.setProjectID = doctorProfile.projectID; // Provider.of(context, listen: false); - patient.PatientID = 8808; - patient.TokenID = token; - Provider.of(context, listen: false) - .getPatientList(patient, "1") - .then((response) { - if (response['MessageStatus'] == 1) { - switch (patientType) { - case "0": - if (response['List_MyOutPatient'] != null) { - setState(() { - patientList = ModelResponse.fromJson(response['List_MyOutPatient']).list; - isLoading = false; - }); - Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { - "patient": patientList[0], - }); - } else { - setState(() { - isError = true; - error = 'No patient'; - isLoading = false; - }); - } + patient.PatientID = 8808; + patient.TokenID = token; + Provider.of(context, listen: false) + .getPatientList(patient, "1") + .then((response) { + if (response['MessageStatus'] == 1) { + switch (patientType) { + case "0": + if (response['List_MyOutPatient'] != null) { + setState(() { + patientList = ModelResponse.fromJson(response['List_MyOutPatient']).list; + isLoading = false; + }); + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": patientList[0], + }); + } else { + setState(() { + isError = true; + isLoading = false; + }); + DrAppToastMsg.showErrorToast('No patient'); + } + break; + case "1": + if (response['List_MyInPatient'] != null) { + setState(() { + patientList = ModelResponse.fromJson(response['List_MyInPatient']).list; + isLoading = false; + error = ""; + }); + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": patientList[0], + }); + } else { + setState(() { + isError = true; + isLoading = false; + }); + DrAppToastMsg.showErrorToast('No patient'); break; - case "1": - if (response['List_MyInPatient'] != null) { - setState(() { - patientList = ModelResponse.fromJson(response['List_MyInPatient']).list; - isLoading = false; - error = ""; - }); - Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { - "patient": patientList[0], - }); - } else { - setState(() { - error = 'No patient'; - isError = true; - isLoading = false; - }); - break; - } - } - } else { - setState(() { - error = response['ErrorEndUserMessage'] ?? response['ErrorMessage'] ; - isLoading = false; - isError = true; - }); + } } + } else { + setState(() { + isLoading = false; + isError = true; + }); + DrAppToastMsg.showErrorToast(response['ErrorEndUserMessage'] ?? response['ErrorMessage']); + + } + }).catchError((error){ + setState(() { + isLoading = false; }); - } - // } + helpers.showErrorToast(error); + //DrAppToastMsg.showErrorToast(error); + }); + } +// } } diff --git a/lib/screens/auth/login_screen.dart b/lib/screens/auth/login_screen.dart index 8b25d21d..38c81cc3 100644 --- a/lib/screens/auth/login_screen.dart +++ b/lib/screens/auth/login_screen.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:doctor_app_flutter/config/config.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -11,8 +12,8 @@ import '../../widgets/auth/login_form.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; -DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); class Loginsreen extends StatefulWidget { @override _LoginsreenState createState() => _LoginsreenState(); @@ -40,10 +41,10 @@ class _LoginsreenState extends State { }); } -/* - *@author: Elham Rababah - *@Date:19/4/2020 - *@param: isLoading +/* + *@author: Elham Rababah + *@Date:19/4/2020 + *@param: isLoading *@return: *@desc: Change Isloading attribute in order to show or hide loader */ @@ -55,6 +56,7 @@ class _LoginsreenState extends State { @override Widget build(BuildContext context) { + getSharedPref(); return AppScaffold( isLoading: _isLoading, @@ -78,24 +80,24 @@ class _LoginsreenState extends State { children: [ (platformImei == null) ? Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AuthHeader(loginType.knownUser), - LoginForm( - changeLoadingStata: - changeLoadingStata, - ), - ], - ) + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AuthHeader(loginType.knownUser), + LoginForm( + changeLoadingStata: + changeLoadingStata, + ), + ], + ) : Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AuthHeader(loginType.unknownUser), - KnownUserLogin(), - ], - ), + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AuthHeader(loginType.unknownUser), + KnownUserLogin(), + ], + ), ])); } } diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index f7b9d444..cef7e881 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -15,46 +15,47 @@ class MyScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { scheduleProvider = Provider.of(context); - return Scaffold( + return AppScaffold( + appBarTitle: TranslationBase.of(context).mySchedule, body: scheduleProvider.isLoading ? DrAppCircularProgressIndeicator() : scheduleProvider.isError - ? Center( - child: AppText( - scheduleProvider.error, - color: Theme.of(context).errorColor, - ), - ) - : scheduleProvider.listDoctorWorkingHoursTable.length == 0 - ? Center( - child: AppText( - TranslationBase.of(context).errorNoSchedule, - color: Theme.of(context).errorColor, - ), - ) - : Container( - padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), - child: ListView( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20, - ), - - scheduleListByDate(), - // scheduleListByDate('Wednesday, 8 April '), - ], - ), - ], - ), - ], - ), + ? Center( + child: AppText( + scheduleProvider.error, + color: Theme.of(context).errorColor, + ), + ) + : scheduleProvider.listDoctorWorkingHoursTable.length == 0 + ? Center( + child: AppText( + TranslationBase.of(context).errorNoSchedule, + color: Theme.of(context).errorColor, + ), + ) + : Container( + padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), + child: ListView( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 20, ), + + scheduleListByDate(), + // scheduleListByDate('Wednesday, 8 April '), + ], + ), + ], + ), + ], + ), + ), ); } diff --git a/lib/screens/patients/profile/radiology/radiology_screen.dart b/lib/screens/patients/profile/radiology/radiology_screen.dart index 1ddf944e..4b47956c 100644 --- a/lib/screens/patients/profile/radiology/radiology_screen.dart +++ b/lib/screens/patients/profile/radiology/radiology_screen.dart @@ -79,116 +79,112 @@ class _RadiologyScreenState extends State { body: patientsProv.isLoading ? DrAppCircularProgressIndeicator() : patientsProv.isError - ? DrAppEmbeddedError(error: patientsProv.error) - : patientsProv.patientRadiologyList.length == 0 - ? DrAppEmbeddedError(error: 'You don\'t have any Vital Sign') - : Container( - margin: EdgeInsets.fromLTRB( - SizeConfig.realScreenWidth * 0.05, - 0, - SizeConfig.realScreenWidth * 0.05, - 0), - child: Container( - margin: EdgeInsets.symmetric(vertical: 10), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(20.0), - ), - ), - child: ListView.builder( - itemCount: patientsProv.patientRadiologyList.length, - itemBuilder: (BuildContext context, int index) { - return InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => RadiologyReportScreen(reportData: patientsProv.patientRadiologyList[index].reportData,)),); - }, - child: Container( - padding: EdgeInsets.all(10), - margin: EdgeInsets.all(10), - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(10)), - border: Border( - bottom: BorderSide( - color: Colors.grey, width: 0.5), - top: BorderSide( - color: Colors.grey, width: 0.5), - left: BorderSide( - color: Colors.grey, width: 0.5), - right: BorderSide( - color: Colors.grey, width: 0.5), + ? DrAppEmbeddedError(error: patientsProv.error) + : patientsProv.patientRadiologyList.length == 0 + ? DrAppEmbeddedError(error: 'You don\'t have any Vital Sign') + : Container( + margin: EdgeInsets.fromLTRB( + SizeConfig.realScreenWidth * 0.05, + 0, + SizeConfig.realScreenWidth * 0.05, + 0), + child: Container( + margin: EdgeInsets.symmetric(vertical: 10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(20.0), + ), + ), + child: ListView.builder( + itemCount: patientsProv.patientRadiologyList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => RadiologyReportScreen(reportData: patientsProv.patientRadiologyList[index].reportData,)),); + }, + child: Container( + padding: EdgeInsets.all(10), + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + borderRadius: + BorderRadius.all(Radius.circular(10)), + border: Border( + bottom: BorderSide( + color: Colors.grey, width: 0.5), + top: BorderSide( + color: Colors.grey, width: 0.5), + left: BorderSide( + color: Colors.grey, width: 0.5), + right: BorderSide( + color: Colors.grey, width: 0.5), + ), + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + LargeAvatar( + url: patientsProv + .patientRadiologyList[index] + .doctorImageURL, + ), + Expanded( + child: Padding( + padding: + const EdgeInsets.fromLTRB( + 8, 0, 0, 0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + '${patientsProv.patientRadiologyList[index].doctorName}', + fontSize: 2.5 * + SizeConfig + .textMultiplier, + fontWeight: + FontWeight.bold), + SizedBox( + height: 8, + ), + AppText( + 'Invoice No:${patientsProv.patientRadiologyList[index].invoiceNo}', + fontSize: 2 * + SizeConfig + .textMultiplier, + ), + SizedBox( + height: 8, ), - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - LargeAvatar( - url: patientsProv - .patientRadiologyList[index] - .doctorImageURL, - name: patientsProv - .patientLabResultOrdersList[ - index] - .doctorName, - ), - Expanded( - child: Padding( - padding: - const EdgeInsets.fromLTRB( - 8, 0, 0, 0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - '${patientsProv.patientRadiologyList[index].doctorName}', - fontSize: 2.5 * - SizeConfig - .textMultiplier, - fontWeight: - FontWeight.bold), - SizedBox( - height: 8, - ), - AppText( - 'Invoice No:${patientsProv.patientRadiologyList[index].invoiceNo}', - fontSize: 2 * - SizeConfig - .textMultiplier, - ), - SizedBox( - height: 8, - ), - AppText( - ' ${patientsProv.patientRadiologyList[index].clinicName}', - fontSize: 2 * - SizeConfig - .textMultiplier, - color: Theme.of(context) - .primaryColor, - ), - SizedBox( - height: 8, - ), - ], - ), - ), - ) - ], - ), - ], - ), + AppText( + ' ${patientsProv.patientRadiologyList[index].clinicName}', + fontSize: 2 * + SizeConfig + .textMultiplier, + color: Theme.of(context) + .primaryColor, + ), + SizedBox( + height: 8, + ), + ], ), - ); - }), - ), + ), + ) + ], + ), + ], ), + ), + ); + }), + ), + ), ); } } diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index b93bfafa..ce6d8a95 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -36,7 +36,7 @@ class _LoginFormState extends State { String _platformImei = 'Unknown'; String uniqueId = "Unknown"; var projectsList = []; - + bool _isInit = true; FocusNode focusPass; FocusNode focusProject; @@ -56,14 +56,22 @@ class _LoginFormState extends State { initPlatformState(); } + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + if (projectsList.length == 0) { + getProjectsList(); + } + } + _isInit = false; + } + @override Widget build(BuildContext context) { final focusPass = FocusNode(); final focusProject = FocusNode(); - if (projectsList.length == 0) { - getProjectsList(); - } AuthProvider authProv = Provider.of(context); return Form( @@ -89,8 +97,9 @@ class _LoginFormState extends State { userInfo.UserID = value.trim(); }, onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus(focusPass); + FocusScope.of(context).nextFocus(); }, + autofocus: false, ), buildSizedBox(), TextFormField( @@ -109,7 +118,7 @@ class _LoginFormState extends State { userInfo.Password = value; }, onFieldSubmitted: (_) { - FocusScope.of(context).requestFocus(focusProject); + FocusScope.of(context).nextFocus(); helpers.showCupertinoPicker( context, projectsList, 'Name', onSelectProject); }, @@ -134,22 +143,8 @@ class _LoginFormState extends State { }), buildSizedBox(), Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.end, children: [ - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Checkbox( - value: true, - activeColor: Theme.of(context).primaryColor, - onChanged: (bool newValue) {}), - Text("Remember me", - style: TextStyle( - fontSize: 2 * SizeConfig.textMultiplier)), - ], - ), - ), RaisedButton( onPressed: () { login(context, authProv, widget.changeLoadingStata); @@ -194,17 +189,26 @@ class _LoginFormState extends State { */ InputDecoration buildInputDecoration(BuildContext context, hint, asset) { return InputDecoration( - prefixIcon: Image.asset(asset), - hintText: hint, - hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(20)), - borderSide: BorderSide(color: Hexcolor('#CCCCCC')), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - )); + prefixIcon: Image.asset(asset), + hintText: hint, + hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(20)), + borderSide: BorderSide(color: Hexcolor('#CCCCCC')), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).primaryColor), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + ); } SizedBox buildSizedBox() { @@ -214,6 +218,11 @@ class _LoginFormState extends State { } login(context, AuthProvider authProv, Function changeLoadingStata) { + FocusScopeNode currentFocus = FocusScope.of(context); + + // if (!currentFocus.hasPrimaryFocus) { + // currentFocus.unfocus(); + // } changeLoadingStata(true); if (loginFormKey.currentState.validate()) { loginFormKey.currentState.save(); @@ -227,7 +236,7 @@ class _LoginFormState extends State { sharedPref.setString(TOKEN, res['LogInTokenID']); print("token" + res['LogInTokenID']); - Navigator.of(context).pushNamed(VERIFICATION_METHODS); + Navigator.of(context).pushReplacementNamed(VERIFICATION_METHODS); } else { // handel error // widget.showCenterShortLoadingToast("watting"); @@ -237,7 +246,7 @@ class _LoginFormState extends State { }).catchError((err) { print('$err'); changeLoadingStata(false); - helpers.showErrorToast(); + helpers.showErrorToast(err); }); } else { changeLoadingStata(false); @@ -285,7 +294,7 @@ class _LoginFormState extends State { // Platform messages may fail, so we use a try/catch PlatformException. try { platformImei = - await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false); + await ImeiPlugin.getImei(shouldShowRequestPermissionRationale: false); idunique = await ImeiPlugin.getId(); } on PlatformException { platformImei = 'Failed to get platform version.'; diff --git a/lib/widgets/auth/verfiy_account.dart b/lib/widgets/auth/verfiy_account.dart index feae82ce..ca7a9aa8 100644 --- a/lib/widgets/auth/verfiy_account.dart +++ b/lib/widgets/auth/verfiy_account.dart @@ -93,7 +93,7 @@ class _VerifyAccountState extends State { buildSizedBox(30), Row( mainAxisAlignment: - MainAxisAlignment.spaceAround, + MainAxisAlignment.spaceAround, children: [ Container( width: SizeConfig.realScreenWidth * 0.20, @@ -131,7 +131,7 @@ class _VerifyAccountState extends State { style: buildTextStyle(), keyboardType: TextInputType.number, decoration: - buildInputDecoration(context), + buildInputDecoration(context), onSaved: (val) { verifyAccountFormValue['digit2'] = val; @@ -158,7 +158,7 @@ class _VerifyAccountState extends State { style: buildTextStyle(), keyboardType: TextInputType.number, decoration: - buildInputDecoration(context), + buildInputDecoration(context), onSaved: (val) { verifyAccountFormValue['digit3'] = val; @@ -183,7 +183,7 @@ class _VerifyAccountState extends State { style: buildTextStyle(), keyboardType: TextInputType.number, decoration: - buildInputDecoration(context), + buildInputDecoration(context), onSaved: (val) { verifyAccountFormValue['digit4'] = val; @@ -191,20 +191,13 @@ class _VerifyAccountState extends State { validator: validateCodeDigit)) ], ), - // buildSizedBox(40), buildSizedBox(20), buildText(), - // buildSizedBox(10.0), - // Text() - buildSizedBox(40), - - // buildSizedBox(), RaisedButton( onPressed: () { verifyAccount( authProv, widget.changeLoadingStata); - // Navigator.of(context).pushNamed(HOME); }, elevation: 0.0, child: Container( @@ -216,7 +209,7 @@ class _VerifyAccountState extends State { style: TextStyle( color: Colors.white, fontSize: - 3 * SizeConfig.textMultiplier), + 3 * SizeConfig.textMultiplier), ), ), ), @@ -264,16 +257,25 @@ class _VerifyAccountState extends State { */ InputDecoration buildInputDecoration(BuildContext context) { return InputDecoration( - // ts/images/password_icon.png - contentPadding: EdgeInsets.only(top: 30, bottom: 30), - enabledBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10)), - borderSide: BorderSide(color: Colors.black), - ), - focusedBorder: OutlineInputBorder( - borderRadius: BorderRadius.all(Radius.circular(10.0)), - borderSide: BorderSide(color: Theme.of(context).primaryColor), - )); + // ts/images/password_icon.png + contentPadding: EdgeInsets.only(top: 30, bottom: 30), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10)), + borderSide: BorderSide(color: Colors.black), + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).primaryColor), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + focusedErrorBorder: OutlineInputBorder( + borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderSide: BorderSide(color: Theme.of(context).errorColor), + ), + ); } /* @@ -284,17 +286,27 @@ class _VerifyAccountState extends State { *@desc: buildText */ RichText buildText() { + String medthodName; + switch (model['OTP_SendType']) { + case 1: + medthodName = 'SMS'; + break; + case 2: + medthodName = 'WhatsApp'; + break; + default: + } var text = RichText( text: new TextSpan( style: new TextStyle( fontSize: 3.0 * SizeConfig.textMultiplier, color: Colors.black), children: [ - new TextSpan(text: 'You will receive a '), - new TextSpan( - text: 'Login Code ', - style: TextStyle(fontWeight: FontWeight.w700)), - new TextSpan(text: 'By SMS, Please enter the code') - ])); + new TextSpan(text: 'You will receive a '), + new TextSpan( + text: 'Login Code ', + style: TextStyle(fontWeight: FontWeight.w700)), + new TextSpan(text: 'By ${medthodName}, Please enter the code') + ])); return text; } @@ -322,7 +334,7 @@ class _VerifyAccountState extends State { verifyAccountFormValue['digit4']; print(activationCode); int projectID = await sharedPref.getInt(PROJECT_ID); - Map model = { + Map model = { "activationCode": activationCode, "DoctorID": _loggedUser['DoctorID'], "LogInTokenID": _loggedUser['LogInTokenID'], @@ -348,7 +360,7 @@ class _VerifyAccountState extends State { res['List_DoctorProfile'][0], changeLoadingStata); } else { _asyncSimpleDialog(context, res['List_DoctorsClinic'], 'ClinicName', - 'Please Select Clinic') + 'Please Select Clinic') .then((clinicInfo) { ClinicModel clinic = ClinicModel.fromJson(clinicInfo); print(clinicInfo); @@ -381,7 +393,7 @@ class _VerifyAccountState extends State { Map profile, Function changeLoadingStata) { changeLoadingStata(false); sharedPref.setObj(DOCTOR_PROFILE, profile); - Navigator.of(context).pushNamed(HOME); + Navigator.of(context).pushReplacementNamed(HOME); } Future _asyncSimpleDialog( @@ -407,7 +419,7 @@ class _VerifyAccountState extends State { } /* - *@author: Elham Rababah + *@author: Elham Rababah *@Date:17/5/2020 *@param: ClinicModel clinicInfo, Function changeLoadingStata *@return: @@ -421,7 +433,7 @@ class _VerifyAccountState extends State { projectID: clinicInfo.projectID, tokenID: '', languageID: 2); - authProv.getDocProfiles(docInfo).then((res) { + authProv.getDocProfiles(docInfo.toJson()).then((res) { if (res['MessageStatus'] == 1) { print("DoctorProfileList ${res['DoctorProfileList'][0]}"); loginProcessCompleted(res['DoctorProfileList'][0], changeLoadingStata); diff --git a/lib/widgets/auth/verification_methods.dart b/lib/widgets/auth/verification_methods.dart index 3a7fa482..8c996556 100644 --- a/lib/widgets/auth/verification_methods.dart +++ b/lib/widgets/auth/verification_methods.dart @@ -50,7 +50,7 @@ class _VerificationMethodsState extends State { super.didChangeDependencies(); final routeArgs = ModalRoute.of(context).settings.arguments as Map; verificationMethod = - routeArgs != null ? routeArgs['verificationMethod'] : null; + routeArgs != null ? routeArgs['verificationMethod'] : null; } @override @@ -101,17 +101,17 @@ class _VerificationMethodsState extends State { child: buildFingerprintMethod( context, authProv), replacement: - buildWhatsAppMethod(context, authProv), + buildWhatsAppMethod(context, authProv), ), Visibility( visible: hideSilentMethods() ? false : true, child: buildFaceIDMethod(context, authProv), replacement: - buildSMSMethod(context, authProv), + buildSMSMethod(context, authProv), ), Visibility( visible: - hideSilentMethods() ? false : true, + hideSilentMethods() ? false : true, child: buildWhatsAppMethod( context, authProv)), Visibility( @@ -126,8 +126,8 @@ class _VerificationMethodsState extends State { // height: 500, ), SizedBox( - // height: 20, - ) + // height: 20, + ) ], ), ); @@ -136,7 +136,7 @@ class _VerificationMethodsState extends State { }); } - /* + /* *@author: Elham Rababah *@Date:28/5/2020 *@param: BuildContext context, AuthProvider authProv @@ -149,7 +149,7 @@ class _VerificationMethodsState extends State { sendActivationCodeByOtpNotificationType(1, authProv); }); } - /* + /* *@author: Elham Rababah *@Date:28/5/2020 *@param: BuildContext context, AuthProvider authProv @@ -159,9 +159,9 @@ class _VerificationMethodsState extends State { Center buildWhatsAppMethod(BuildContext context, AuthProvider authProv) { return buildVerificationMethod( context, 'assets/images/verification_whatsapp_icon.png', 'WhatsApp', - () { - sendActivationCodeByOtpNotificationType(2, authProv); - }); + () { + sendActivationCodeByOtpNotificationType(2, authProv); + }); } /* *@author: Elham Rababah @@ -186,8 +186,8 @@ class _VerificationMethodsState extends State { Center buildFingerprintMethod(BuildContext context, AuthProvider authProv) { return buildVerificationMethod(context, 'assets/images/verification_fingerprint_icon.png', 'Fingerprint', () { - sendActivationCodeByOtpNotificationType(4, authProv); - }); + sendActivationCodeByOtpNotificationType(4, authProv); + }); } /* @@ -212,7 +212,7 @@ class _VerificationMethodsState extends State { width: 1, color: Hexcolor( '#CCCCCC') // <--- border width here - ), + ), borderRadius: BorderRadius.all(Radius.circular(10))), child: Column( children: [ @@ -251,11 +251,12 @@ class _VerificationMethodsState extends State { *@desc: send Activation Code By Otp Notification Type */ sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) { + // TODO : build enum for verfication method if (oTPSendType == 1 || oTPSendType == 2) { widget.changeLoadingStata(true); - Map model = { + Map model = { "LogInTokenID": _loggedUser['LogInTokenID'], "Channel": 9, "MobileNumber": _loggedUser['MobileNumber'], @@ -270,7 +271,7 @@ class _VerificationMethodsState extends State { widget.changeLoadingStata(false); if (res['MessageStatus'] == 1) { - Navigator.of(context).pushNamed(VERIFY_ACCOUNT, arguments: {'model':model}); + Navigator.of(context).pushReplacementNamed(VERIFY_ACCOUNT, arguments: {'model':model}); } else { print(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']); diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart index 02d3f10a..f30de7cb 100644 --- a/lib/widgets/doctor/my_referral_patient_widget.dart +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -42,269 +42,277 @@ class _MyReferralPatientWidgetState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText( - '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', - fontSize: 2.5 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - InkWell( - onTap: () { - setState(() { - _showDetails = !_showDetails; - }); - }, - child: Icon(_showDetails - ? Icons.keyboard_arrow_up - : Icons.keyboard_arrow_down)), - ], + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down), + + ], + ), ), !_showDetails ? Container() : AnimatedContainer( - duration: Duration(milliseconds: 200), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 5,), - Divider(color: Color(0xFF000000),height: 0.5,), - Table( - border: TableBorder.symmetric(inside: BorderSide(width: 0.5),), + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 5,), + Divider(color: Color(0xFF000000),height: 0.5,), + Table( + border: TableBorder.symmetric(inside: BorderSide(width: 0.5),), + children: [ + TableRow( children: [ - TableRow( - children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'File No', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '${widget.myReferralPatientModel.referringDoctor}', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'File No', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, ), - ), - Container( - margin: EdgeInsets.only(left: 4,top: 2.5,right: 2.5,bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Referring Doctor', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - widget.myReferralPatientModel - .referringClinicDescription, - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + SizedBox(height: 5,), + AppText( + '${widget.myReferralPatientModel.referringDoctor}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + margin: EdgeInsets.only(left: 4,top: 2.5,right: 2.5,bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Referring Doctor', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, ), - ), - ] + SizedBox(height: 5,), + AppText( + widget.myReferralPatientModel + .referringClinicDescription, + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), ), - TableRow( - children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - 'Referring Clinic', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '${widget.myReferralPatientModel.referringClinicDescription}', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), + ] + ), + TableRow( + children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Referring Clinic', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, ), - Container( - margin: EdgeInsets.only(left: 4,top: 2.5,right: 2.5,bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - 'Frequency', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - widget.myReferralPatientModel - .frequencyDescription, - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), + SizedBox(height: 5,), + AppText( + '${widget.myReferralPatientModel.referringClinicDescription}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, ) - ] + ], + ), ), - TableRow( - children: [ - Container( - margin: EdgeInsets.all(2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - 'Priority', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - '${widget.myReferralPatientModel.priorityDescription}', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], + Container( + margin: EdgeInsets.only(left: 4,top: 2.5,right: 2.5,bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Frequency', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, ), + SizedBox(height: 5,), + AppText( + widget.myReferralPatientModel + .frequencyDescription, + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ) + ] + ), + TableRow( + children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Priority', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, ), - Container( - margin: EdgeInsets.only(left: 4,top: 2.5,right: 2.5,bottom: 2.5), - padding: EdgeInsets.all(5), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - 'Max Response Time', - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - ), - AppText( - Helpers.getDateFormatted(widget - .myReferralPatientModel - .mAXResponseTime), - fontSize: - 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.w300, - ) - ], - ), + SizedBox(height: 5,), + AppText( + '${widget.myReferralPatientModel.priorityDescription}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, ) ], ), + ), + Container( + margin: EdgeInsets.only(left: 4,top: 2.5,right: 2.5,bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Max Response Time', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + SizedBox(height: 5,), + AppText( + Helpers.getDateFormatted(widget + .myReferralPatientModel + .mAXResponseTime), + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ) + ], + ), - ], - ), - Divider(color: Color(0xFF000000),height: 0.5,), - SizedBox( - height: 5, - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - 'Clinic Details and Remarks', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, - textAlign: TextAlign.start,), - Texts( - '${widget.myReferralPatientModel.referringDoctorRemarks}', - style: "bodyText1", - readMore: true, - textAlign: TextAlign.start, - maxLength: 100) - ], - ), - SizedBox( - height: 5, - ), - AppText( - 'Answer/Suggestions', - fontSize: 1.7 * SizeConfig.textMultiplier, - fontWeight: FontWeight.bold, + ], + ), + Divider(color: Color(0xFF000000),height: 0.5,), + SizedBox( + height: 5, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Clinic Details and Remarks', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start,), + Texts( + '${widget.myReferralPatientModel.referringDoctorRemarks}', + style: "bodyText1", + readMore: true, textAlign: TextAlign.start, - ), - SizedBox( - height: 5, - ), - Form( - key: _formKey, - child: TextFields( - maxLines: 2, - minLines: 2, - hintText: 'Answer the patient', - fontWeight: FontWeight.normal, - initialValue: widget.myReferralPatientModel.referredDoctorRemarks ?? '', - readOnly: _isLoading, - validator: (value) { - if (value.isEmpty) - return "please enter answer"; - else - return null; - }, - ), - ), - SizedBox(height: 10.0), - SizedBox(height: 10.0), - Container( - width: double.infinity, - margin: EdgeInsets.only(left: 10,right: 10), - child: Button( - onTap: () async { - final form = _formKey.currentState; - if (form.validate()) { - setState(() { - _isLoading = true; - }); - try { - await Provider.of(context, listen: false).replay(answerController.text.toString(), widget.myReferralPatientModel); - setState(() { - _isLoading = false; - }); - DrAppToastMsg.showSuccesToast('Reply Successfully'); + maxLength: 100) + ], + ), + SizedBox( + height: 5, + ), + AppText( + 'Answer/Suggestions', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + SizedBox( + height: 5, + ), + Form( + key: _formKey, + child: TextFields( + maxLines: 2, + minLines: 2, + hintText: 'Answer the patient', + fontWeight: FontWeight.normal, + initialValue: widget.myReferralPatientModel.referredDoctorRemarks ?? '', + readOnly: _isLoading, + validator: (value) { + if (value.isEmpty) + return "please enter answer"; + else + return null; + }, + ), + ), + SizedBox(height: 10.0), + SizedBox(height: 10.0), + Container( + width: double.infinity, + margin: EdgeInsets.only(left: 10,right: 10), + child: Button( + onTap: () async { + final form = _formKey.currentState; + if (form.validate()) { + setState(() { + _isLoading = true; + }); + try { + await Provider.of(context, listen: false).replay(answerController.text.toString(), widget.myReferralPatientModel); + setState(() { + _isLoading = false; + }); + DrAppToastMsg.showSuccesToast('Reply Successfully'); - } catch (e) { - setState(() { - _isLoading = false; - }); - DrAppToastMsg.showErrorToast(e); - } - } - }, - title: 'Reply', - loading: _isLoading, - ), - ) - ], + } catch (e) { + setState(() { + _isLoading = false; + }); + DrAppToastMsg.showErrorToast(e); + } + } + }, + title: 'Reply', + loading: _isLoading, ), ) + ], + ), + ) ], ), ), diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index 54cbcb30..45e4c793 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -7,12 +7,12 @@ import 'avatar_gradients.dart'; class LargeAvatar extends StatelessWidget { LargeAvatar( {Key key, - this.name, - this.url, - this.disableProfileView: false, - this.radius = 60.0, - this.width = 90, - this.height = 90}) + this.name, + this.url, + this.disableProfileView: false, + this.radius = 60.0, + this.width = 90, + this.height = 90}) : super(key: key); final String name; @@ -35,31 +35,33 @@ class LargeAvatar extends StatelessWidget { ), ), ); - } else if (name == null || name.isEmpty) { + } else if (name != null || name.isNotEmpty) { return Center( child: AppText( - 'DR', - color: Colors.white, - )); + name[0].toUpperCase(), + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, + )); } else { return Center( child: AppText( - name[0].toUpperCase(), - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.bold, - )); + 'DR', + color: Colors.white, + )); } } @override Widget build(BuildContext context) { + var vlr = name; + var asd; return InkWell( onTap: disableProfileView ? null : () { - //TODO when we need that - }, + //TODO when we need that + }, child: Container( decoration: BoxDecoration( gradient: LinearGradient( From a3730e4efb78bd70dbd39018a5c6644548e051cb Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Fri, 12 Jun 2020 09:57:29 +0300 Subject: [PATCH 31/42] fix issues with sultan branch --- lib/client/base_app_client.dart | 27 +++---- lib/config/config.dart | 4 +- lib/landing_page.dart | 9 +-- lib/screens/doctor/my_schedule_screen.dart | 75 +++++++++---------- lib/util/dr_app_shared_pref.dart | 10 +++ lib/util/helpers.dart | 36 +++++---- lib/widgets/doctor/doctor_reply_widget.dart | 24 +++++- lib/widgets/doctor/my_schedule_widget.dart | 2 + .../patients/profile/large_avatar.dart | 34 ++++----- lib/widgets/shared/app_drawer_widget.dart | 17 +---- .../shared/app_expandable_notifier.dart | 1 + lib/widgets/shared/app_scaffold_widget.dart | 16 ++-- 12 files changed, 133 insertions(+), 122 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 25b2450c..27fcb103 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -3,14 +3,9 @@ import 'dart:convert'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; -import 'package:http_interceptor/http_methods.dart'; -import 'package:http_interceptor/models/request_data.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = new Helpers(); @@ -32,15 +27,12 @@ Helpers helpers = new Helpers(); * */ class BaseAppClient { static post( - String endPoint, { - Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure, - }) async { + String endPoint, { + Map body, + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + }) async { String url = BASE_URL + endPoint; - RequestData data = RequestData(body: body,baseUrl: url,method: Method.POST); - - try { Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); @@ -49,8 +41,8 @@ class BaseAppClient { body['DoctorID'] = doctorProfile?.doctorID; body['EditedBy'] = doctorProfile?.doctorID; body['ProjectID'] = doctorProfile?.projectID; - // if (!body.containsKey('ClinicID')) - body['ClinicID'] = doctorProfile?.clinicID; + // if (!body.containsKey('ClinicID')) + body['ClinicID'] = doctorProfile?.clinicID; } body['TokenID'] = token ?? ''; body['LanguageID'] = LANGUAGE_ID; @@ -64,7 +56,7 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - if (await Helpers.checkConnection()) { + if (await Helpers.checkConnection()) { final response = await http.post(url, body: json.encode(body), headers: { @@ -77,7 +69,8 @@ class BaseAppClient { } else { var parsed = json.decode(response.body.toString()); if (!parsed['IsAuthenticated']) { - Navigator.of(AppGlobal.CONTEX).pushNamed(LOGIN); + await helpers.logout(); + helpers.showErrorToast('Your session expired Please login agian'); } else if (parsed['MessageStatus'] == 1) { onSuccess(parsed, statusCode); diff --git a/lib/config/config.dart b/lib/config/config.dart index 3ed6f076..2bd1256d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,8 +2,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -//const BASE_URL = 'https://hmgwebservices.com/Services/'; -const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; +const BASE_URL = 'https://hmgwebservices.com/Services/'; +//const BASE_URL = 'https://uat.hmgwebservices.com/Services/'; const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems_Region"; const PHARMACY_LIST_URL = "Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = diff --git a/lib/landing_page.dart b/lib/landing_page.dart index a9f844f8..174a38ab 100644 --- a/lib/landing_page.dart +++ b/lib/landing_page.dart @@ -51,14 +51,7 @@ class _LandingPageState extends State { }, ), centerTitle: true, - actions: [ - ProfileImageWidget( - height: 50, - width: 50, - url: - "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png", - ) - ], + ), drawer: Theme( data: Theme.of(context).copyWith( diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index cef7e881..36b449a7 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -6,8 +6,6 @@ import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indei import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import '../../config/size_config.dart'; -import '../../widgets/shared/app_scaffold_widget.dart'; class MyScheduleScreen extends StatelessWidget { ScheduleProvider scheduleProvider; @@ -15,47 +13,46 @@ class MyScheduleScreen extends StatelessWidget { @override Widget build(BuildContext context) { scheduleProvider = Provider.of(context); - return AppScaffold( - appBarTitle: TranslationBase.of(context).mySchedule, + return Scaffold( body: scheduleProvider.isLoading ? DrAppCircularProgressIndeicator() : scheduleProvider.isError - ? Center( - child: AppText( - scheduleProvider.error, - color: Theme.of(context).errorColor, - ), - ) - : scheduleProvider.listDoctorWorkingHoursTable.length == 0 - ? Center( - child: AppText( - TranslationBase.of(context).errorNoSchedule, - color: Theme.of(context).errorColor, - ), - ) - : Container( - padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), - child: ListView( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20, - ), + ? Center( + child: AppText( + scheduleProvider.error, + color: Theme.of(context).errorColor, + ), + ) + : scheduleProvider.listDoctorWorkingHoursTable.length == 0 + ? Center( + child: AppText( + TranslationBase.of(context).errorNoSchedule, + color: Theme.of(context).errorColor, + ), + ) + : Container( + padding: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), + child: ListView( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 20, + ), - scheduleListByDate(), - // scheduleListByDate('Wednesday, 8 April '), - ], - ), - ], - ), - ], - ), - ), + scheduleListByDate(), + // scheduleListByDate('Wednesday, 8 April '), + ], + ), + ], + ), + ], + ), + ), ); } diff --git a/lib/util/dr_app_shared_pref.dart b/lib/util/dr_app_shared_pref.dart index f75c171e..54c8cc45 100644 --- a/lib/util/dr_app_shared_pref.dart +++ b/lib/util/dr_app_shared_pref.dart @@ -82,4 +82,14 @@ class DrAppSharedPreferances { } return json.decode(string); } + + clear() async { + final SharedPreferences prefs = await _prefs; + prefs.clear(); + } + + remove(String key) async { + final SharedPreferences prefs = await _prefs; + prefs.remove(key); + } } diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index e05f0d74..ebcf817c 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -1,12 +1,16 @@ import 'package:doctor_app_flutter/models/list_doctor_working_hours_table_model.dart'; +import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:doctor_app_flutter/config/config.dart'; import '../config/size_config.dart'; import '../util/dr_app_toast_msg.dart'; import 'package:connectivity/connectivity.dart'; +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); /* *@author: Elham Rababah @@ -48,10 +52,6 @@ class Helpers { onPressed: () { Navigator.pop(context); }, - // padding: const EdgeInsets.symmetric( - // horizontal: 16.0, - // vertical: 5.0, - // ), ), CupertinoButton( child: Text( @@ -97,7 +97,7 @@ class Helpers { children: items.map((item) { return Text( '${item["$decKey"]}', - style: TextStyle(fontSize: SizeConfig.textMultiplier * 3), + style: TextStyle(fontSize: SizeConfig.textMultiplier * 2), ); }).toList(), @@ -164,14 +164,15 @@ class Helpers { ), ); } - /* + + /* *@author: Amjad Amireh *@Date:5/5/2020 *@param: checkDate *@return: DateTime *@desc: convert String to DateTime */ -static String checkDate(String dateString) { + static String checkDate(String dateString) { DateTime checkedTime = DateTime.parse(dateString); DateTime currentTime = DateTime.now(); @@ -257,6 +258,7 @@ static String checkDate(String dateString) { return "Sunday"; } } + /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -275,6 +277,7 @@ static String checkDate(String dateString) { else return ""; } + /* *@author: Mohammad Aljammal *@Date:26/5/2020 @@ -301,13 +304,14 @@ static String checkDate(String dateString) { *@return: List *@desc: convert workingHours string to List */ - static List getWorkingHours(String workingHours ){ - List myWorkingHours =[]; + static List getWorkingHours(String workingHours) { + List myWorkingHours = []; List listOfHours = workingHours.split('a'); listOfHours.forEach((element) { WorkingHours workingHours = WorkingHours(); - var from = element.substring(element.indexOf('m ') + 2 , element.indexOf('To')-2); + var from = element.substring( + element.indexOf('m ') + 2, element.indexOf('To') - 2); workingHours.from = from.trim(); var to = element.substring(element.indexOf('To') + 2); workingHours.to = to.trim(); @@ -316,9 +320,6 @@ static String checkDate(String dateString) { return myWorkingHours; } - - - /* *@author: Elham Rababah *@Date:12/5/2020 @@ -333,4 +334,13 @@ static String checkDate(String dateString) { } return localMsg; } + + clearSharedPref() async { + await sharedPref.clear(); + } + + logout() async { + await clearSharedPref(); + Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); + } } diff --git a/lib/widgets/doctor/doctor_reply_widget.dart b/lib/widgets/doctor/doctor_reply_widget.dart index 5ec30858..6fc9ec66 100644 --- a/lib/widgets/doctor/doctor_reply_widget.dart +++ b/lib/widgets/doctor/doctor_reply_widget.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/list_gt_my_pationents_question_model.dart'; +import 'package:doctor_app_flutter/presentation/doctor_app_icons.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; @@ -42,7 +43,28 @@ class _DoctorReplyWidgetState extends State { child: Row( children: [ SizedBox(width: 5,), - LargeAvatar(name: widget.reply.patientName,url: '',), + //LargeAvatar(icon: widget.reply.gender == 0 ? DoctorApp.male : DoctorApp.femaleicon ,), + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment(-1, -1), + end: Alignment(1, 1), + colors: [ + Colors.grey[100], + Colors.grey[200], + ]), + boxShadow: [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + offset: Offset(0.0, 5.0), + blurRadius: 16.0) + ], + borderRadius: BorderRadius.all(Radius.circular(50.0)), + ), + width: 80, + height: 80, + child: Icon(widget.reply.gender == 1 ? DoctorApp.male : DoctorApp.femaleicon,size: 80,)), + SizedBox(width: 15,), Expanded( child: Container( diff --git a/lib/widgets/doctor/my_schedule_widget.dart b/lib/widgets/doctor/my_schedule_widget.dart index c37d09ad..48f70d7c 100644 --- a/lib/widgets/doctor/my_schedule_widget.dart +++ b/lib/widgets/doctor/my_schedule_widget.dart @@ -45,6 +45,7 @@ class MyScheduleWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText('From',fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.bold,), + SizedBox(height: 5,), AppText(work.from,fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,) ], ), @@ -56,6 +57,7 @@ class MyScheduleWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText('To',fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.bold,), + SizedBox(height: 5,), AppText(work.to,fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,) ], ), diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart index 45e4c793..d18fdf3d 100644 --- a/lib/widgets/patients/profile/large_avatar.dart +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -7,12 +7,12 @@ import 'avatar_gradients.dart'; class LargeAvatar extends StatelessWidget { LargeAvatar( {Key key, - this.name, - this.url, - this.disableProfileView: false, - this.radius = 60.0, - this.width = 90, - this.height = 90}) + this.name, + this.url, + this.disableProfileView: false, + this.radius = 60.0, + this.width = 90, + this.height = 90}) : super(key: key); final String name; @@ -35,20 +35,20 @@ class LargeAvatar extends StatelessWidget { ), ), ); - } else if (name != null || name.isNotEmpty) { + } else if (name == null || name.isEmpty) { return Center( child: AppText( - name[0].toUpperCase(), - color: Colors.white, - fontSize: 18, - fontWeight: FontWeight.bold, - )); + 'DR', + color: Colors.white, + )); } else { return Center( child: AppText( - 'DR', - color: Colors.white, - )); + name[0].toUpperCase(), + color: Colors.white, + fontSize: 18, + fontWeight: FontWeight.bold, + )); } } @@ -60,8 +60,8 @@ class LargeAvatar extends StatelessWidget { onTap: disableProfileView ? null : () { - //TODO when we need that - }, + //TODO when we need that + }, child: Container( decoration: BoxDecoration( gradient: LinearGradient( diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index 53228c97..919dc939 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -89,35 +89,24 @@ class _AppDrawerState extends State { }, ), ), - InkWell( - child: DrawerItem("My Schedule", Icons.table_chart), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => ChangeNotifierProvider( - create: (_) => ScheduleProvider(), - child: MyScheduleScreen(), - ), - ), - ); - }, - ), InkWell( child: DrawerItem("Settings", Icons.settings), onTap: () { + Navigator.pop(context); Navigator.of(context).pushNamed(SETTINGS); }, ), InkWell( child: DrawerItem("QR Reader", Icons.search), onTap: () { + Navigator.pop(context); Navigator.of(context).pushNamed(QR_READER); }, ), InkWell( child: DrawerItem("lOGOUT", Icons.exit_to_app), onTap: () { + Navigator.pop(context); Navigator.of(context).pushNamed(LOGIN); }, ), diff --git a/lib/widgets/shared/app_expandable_notifier.dart b/lib/widgets/shared/app_expandable_notifier.dart index ca3edd09..4ae87e8a 100644 --- a/lib/widgets/shared/app_expandable_notifier.dart +++ b/lib/widgets/shared/app_expandable_notifier.dart @@ -30,6 +30,7 @@ class AppExpandableNotifier extends StatelessWidget { padding: EdgeInsets.all(10), child: Text( "See Graph Details", + style: TextStyle(fontWeight: FontWeight.bold), )), collapsed: Text(''), expanded: bodyWid, diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 1e6da3fc..263e3848 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,13 +1,8 @@ import 'package:doctor_app_flutter/routes.dart'; -import 'package:doctor_app_flutter/widgets/shared/profile_image_widget.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; - -import '../../config/size_config.dart'; import '../../presentation/doctor_app_icons.dart'; -import '../../widgets/shared/app_drawer_widget.dart'; import '../../widgets/shared/app_loader_widget.dart'; -import '../../widgets/shared/custom_shape_clipper.dart'; class AppScaffold extends StatelessWidget { String appBarTitle; @@ -37,12 +32,11 @@ class AppScaffold extends StatelessWidget { }), centerTitle: true, actions: [ - ProfileImageWidget( - height: 50, - width: 50, - url: - "https://hmgwebservices.com/Images/MobileImages/DUBAI/unkown_female.png", - ) + IconButton( + icon: Icon(DoctorApp.home_icon_active), + color: Colors.white, //Colors.black, + onPressed: () => Navigator.pushReplacementNamed(context, HOME), + ), ], ) : null, From fa9e1a344a4a994504bcf2a5bd345a3a5b4160fb Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Fri, 12 Jun 2020 10:03:35 +0300 Subject: [PATCH 32/42] fix issues --- lib/widgets/auth/login_form.dart | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index 48769b59..2d2d2bfd 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -69,16 +69,6 @@ class _LoginFormState extends State { _isInit = false; } - @override - void didChangeDependencies() { - super.didChangeDependencies(); - if (_isInit) { - if (projectsList.length == 0) { - getProjectsList(); - } - } - _isInit = false; - } @override Widget build(BuildContext context) { From b758ae8196296ec9eabe8f79c53e2461b437eca9 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Sun, 14 Jun 2020 10:45:44 +0300 Subject: [PATCH 33/42] fix issues --- .../vital_sign/vital_sign_details_screen.dart | 4 +-- .../profile/patient_profile_widget.dart | 5 ++-- .../profile/profile_medical_info_widget.dart | 27 ++++++++----------- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart b/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart index 16466704..68966553 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sign_details_screen.dart @@ -99,7 +99,7 @@ class _VitalSignDetailsScreenState extends State { vitalSignDetails.bodyMeasurements }); }, - child: Expanded( + child: Container( child: VitalSignItem( des: 'Body Measurements', url: url + 'heartbeat.png', @@ -118,7 +118,7 @@ class _VitalSignDetailsScreenState extends State { }); }, - child: Expanded( + child: Container( child: VitalSignItem( des: 'Temperature', url: url + 'heartbeat.png', diff --git a/lib/widgets/patients/profile/patient_profile_widget.dart b/lib/widgets/patients/profile/patient_profile_widget.dart index 0ef50d81..87990fbf 100644 --- a/lib/widgets/patients/profile/patient_profile_widget.dart +++ b/lib/widgets/patients/profile/patient_profile_widget.dart @@ -36,8 +36,7 @@ class PatientProfileWidget extends StatelessWidget { SliverList( delegate: SliverChildListDelegate( [ - Expanded( - flex: 1, + Container( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -78,7 +77,7 @@ class PatientProfileWidget extends StatelessWidget { ), SliverPadding( padding: const EdgeInsets.fromLTRB(20, 30, 15, 10), - sliver: ProfileMedicalInfoWidget()) + sliver: ProfileMedicalInfoWidget(patient: patient,)) ]); // Container( diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index bc92db90..16c9a0bd 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -291,23 +291,18 @@ class PatientProfileButton extends StatelessWidget { navigator(context, this.route); }, child: Column(children: [ - Expanded( - flex: 1, - child: Expanded( - child: Container( - alignment: Alignment.topLeft, - padding: EdgeInsets.all(5), - child: new AppText( - this.name, - color: Colors.red, - fontWeight: FontWeight.w600, - textAlign: TextAlign.left, - fontSize: SizeConfig.textMultiplier * 2, - ), - )), + Container( + alignment: Alignment.topLeft, + padding: EdgeInsets.all(5), + child: new AppText( + this.name, + color: Colors.red, + fontWeight: FontWeight.w600, + textAlign: TextAlign.left, + fontSize: SizeConfig.textMultiplier * 2, + ), ), - Expanded( - flex: 1, + Container( child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ From b178f0827833ca9b556c563506f82b4e434860f2 Mon Sep 17 00:00:00 2001 From: hussam alhababieh Date: Sun, 14 Jun 2020 11:10:35 +0300 Subject: [PATCH 34/42] translate dashboard and patient search --- lib/config/localized_values.dart | 77 +++++++++++-------- lib/screens/dashboard_screen.dart | 22 +++--- .../patients/patient_search_screen.dart | 17 ++-- lib/util/translations_delegate_base.dart | 49 ++++++++---- 4 files changed, 100 insertions(+), 65 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 38212262..c5f26c7e 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -4,35 +4,50 @@ const Map> localizedValues = { 'language': {'en': 'App Language', 'ar': 'لغة التطبيق'}, 'lanEnglish': {'en': 'English', 'ar': 'English'}, 'lanArabic': {'en': 'العربية', 'ar': 'العربية'}, - 'doctorReply':{'en': 'Doctor Reply', 'ar': 'رد الطبيب'}, - 'time' :{'en': 'Time','ar':'الوقت'}, - 'fileNo' :{'en':'File No', 'ar':'رقم الملف'}, - 'mobileNo' :{'en':'Mobile No', 'ar':'رقم الموبايل'}, - 'messagesScreenToolbarTitle' : {'en': 'Messages','ar': 'الرسائل' }, - 'mySchedule' : {'en': 'My Schedule', 'ar' : 'جدولي'}, - 'errorNoSchedule' :{'en': 'You don\'t have any Schedule' , 'ar': 'ليس لديك أي جدول زمني'}, - 'verify': {'en': 'Verify', 'ar' : 'تحقق'}, - 'referralDoctor':{'en': 'Referral Doctor', 'ar' : 'الطبيب المُحول إليه'}, - 'referringClinic':{'en': 'Referring Clinic', 'ar' : 'العيادة المُحول إليها'}, - 'frequency':{'en': 'Frequency', 'ar' : 'نوع التحويلا'}, - 'priority':{'en': 'Priority', 'ar' : 'الأولوية'}, - 'maxResponseTime':{'en': 'Max Response Time', 'ar' : 'الوقت الأقصى للرد'}, - 'clinicDetailsandRemarks':{'en': 'Clinic Details and Remarks', 'ar' : 'ملاحضات وتفاصيل العيادة'}, - 'answerSuggestions':{'en': 'Answer/Suggestions', 'ar' : 'ملاحضات وتفاصيل العيادة'}, - 'outPatients':{'en': 'Out-Patients', 'ar' : 'ةالمريض الخارجي'}, - 'searchPatient':{'en': 'Search Patient', 'ar' : 'البحث عن مريض'}, - 'labResult':{'en': 'Lab Result', 'ar' : 'نتيجة المختبر'}, - 'todayStatistics':{'en': 'Today Statistics', 'ar' : 'إحصائيات اليوم'}, - 'arrived':{'en': 'Arrived', 'ar' : 'وصل'}, - 'er':{'en': 'ER', 'ar' : 'حالة طوارئ'}, - 'walkIn':{'en': 'Walk-in', 'ar' : 'ادخل'}, - 'notArrived':{'en': 'Not Arrived', 'ar' : 'لم يصل'}, - 'radiology':{'en': 'Radiology', 'ar' : 'الأشعة'}, - 'referral':{'en': 'Referral', 'ar' : 'االإحالة'}, - 'inPatient':{'en': 'In-Patient', 'ar' : 'االمريض الداخلي'}, - 'operations':{'en': 'Operations', 'ar' : 'عمليات'}, - 'patientServices':{'en': 'Patient Services', 'ar' : 'خدمات المرضى'}, - - - + 'doctorReply': {'en': 'Doctor Reply', 'ar': 'رد الطبيب'}, + 'time': {'en': 'Time', 'ar': 'الوقت'}, + 'fileNo': {'en': 'File No', 'ar': 'رقم الملف'}, + 'mobileNo': {'en': 'Mobile No', 'ar': 'رقم الموبايل'}, + 'messagesScreenToolbarTitle': {'en': 'Messages', 'ar': 'الرسائل'}, + 'mySchedule': {'en': 'My Schedule', 'ar': 'جدولي'}, + 'errorNoSchedule': { + 'en': 'You don\'t have any Schedule', + 'ar': 'ليس لديك أي جدول زمني' + }, + 'verify': {'en': 'Verify', 'ar': 'تحقق'}, + 'referralDoctor': {'en': 'Referral Doctor', 'ar': 'الطبيب المُحول إليه'}, + 'referringClinic': {'en': 'Referring Clinic', 'ar': 'العيادة المُحول إليها'}, + 'frequency': {'en': 'Frequency', 'ar': 'نوع التحويلا'}, + 'priority': {'en': 'Priority', 'ar': 'الأولوية'}, + 'maxResponseTime': {'en': 'Max Response Time', 'ar': 'الوقت الأقصى للرد'}, + 'clinicDetailsandRemarks': { + 'en': 'Clinic Details and Remarks', + 'ar': 'ملاحضات وتفاصيل العيادة' + }, + 'answerSuggestions': { + 'en': 'Answer/Suggestions', + 'ar': 'ملاحضات وتفاصيل العيادة' + }, + 'outPatients': {'en': 'Out-Patients', 'ar': 'ةالمريض الخارجي'}, + 'searchPatient': {'en': 'Search Patient', 'ar': 'البحث عن مريض'}, + 'labResult': {'en': 'Lab Result', 'ar': 'نتيجة المختبر'}, + 'todayStatistics': {'en': 'Today Statistics', 'ar': 'إحصائيات اليوم'}, + 'arrived': {'en': 'Arrived', 'ar': 'وصل'}, + 'er': {'en': 'ER', 'ar': 'حالة طوارئ'}, + 'walkIn': {'en': 'Walk-in', 'ar': 'ادخل'}, + 'notArrived': {'en': 'Not Arrived', 'ar': 'لم يصل'}, + 'radiology': {'en': 'Radiology', 'ar': 'الأشعة'}, + 'referral': {'en': 'Referral', 'ar': 'االإحالة'}, + 'inPatient': {'en': 'In-Patient', 'ar': 'االمريض الداخلي'}, + 'operations': {'en': 'Operations', 'ar': 'عمليات'}, + 'patientServices': {'en': 'Patient Services', 'ar': 'خدمات المرضى'}, + 'searchMedicine': {'en': 'Search Medicine', 'ar': 'بحث عن الدواء'}, + 'myReferralPatient': {'en': 'My Referral Patient', 'ar': 'مرضى الاحالة'}, + 'myReferredPatient': {'en': 'My Referred Patient', 'ar': 'مرضاي المحالين'}, + 'firstName': {'en': 'First Name', 'ar': 'الاسم الاول'}, + 'middleName': {'en': 'Middle Name', 'ar': 'اسم الاب'}, + 'lastName': {'en': 'Last Name', 'ar': 'اسم العائلة'}, + 'phoneNumber': {'en': 'Phone Number ', 'ar': 'رقم الجوال'}, + 'patientID': {'en': 'Patient ID', 'ar': 'رقم المريض'}, + 'patientFile ': {'en': 'Patient File', 'ar': 'ملف المريض'}, }; diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index a00471df..18c9ca38 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -42,7 +42,7 @@ class _DashboardScreenState extends State { child: Scaffold( body: SingleChildScrollView( child: SizedBox( - height: MediaQuery.of(context).size.height*1.09, + height: MediaQuery.of(context).size.height * 1.09, // height: MediaQuery.of(context).size.height * 0.2, // width: SizeConfig.screenWidth * 0.9, child: Column( @@ -101,16 +101,17 @@ class _DashboardScreenState extends State { flex: 1, child: Column( crossAxisAlignment: - CrossAxisAlignment.stretch, + CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).arrived, + TranslationBase.of(context).arrived, "23", )), Expanded( child: DashboardItemTexts( - TranslationBase.of(context).notArrived, + TranslationBase.of(context) + .notArrived, "23", ), ), @@ -119,18 +120,17 @@ class _DashboardScreenState extends State { ), Expanded( child: Column( - crossAxisAlignment: + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - TranslationBase.of(context).er, + TranslationBase.of(context).er, "23", )), Expanded( child: DashboardItemTexts( - - TranslationBase.of(context).walkIn, + TranslationBase.of(context).walkIn, "23", )), ], @@ -286,7 +286,7 @@ class _DashboardScreenState extends State { child: DashboardItemIconText( DoctorApp.home_icon, "", - "Search Medicine", + TranslationBase.of(context).searchMedicine, showBorder: true, backgroundColor: Colors.white, valueFontColor: Colors.black, @@ -324,7 +324,7 @@ class _DashboardScreenState extends State { child: DashboardItemIconText( DoctorApp.home_icon, "", - "My Referral Patient", + TranslationBase.of(context).myReferralPatient, showBorder: true, backgroundColor: Colors.white, valueFontColor: Colors.black, @@ -359,7 +359,7 @@ class _DashboardScreenState extends State { child: DashboardItemIconText( DoctorApp.home_icon, "", - "My Referred Patient", + TranslationBase.of(context).myReferredPatient, showBorder: true, backgroundColor: Colors.white, valueFontColor: Colors.black, diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index dffe342c..3d906bef 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -18,6 +18,7 @@ import '../../lookups/patient_lookup.dart'; import '../../widgets/patients/dynamic_elements.dart'; import '../../config/config.dart'; import '../../models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); Helpers helpers = Helpers(); @@ -112,7 +113,7 @@ class _PatientSearchScreenState extends State { @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: "SEARCH FOR PATIENT", + appBarTitle: TranslationBase.of(context).searchPatient, body: ListView( children: [ RoundedContainer( @@ -199,7 +200,7 @@ class _PatientSearchScreenState extends State { height: 10, ), AppTextFormField( - hintText: 'First Name', + hintText: TranslationBase.of(context).firstName, onSaved: (value) { value == null ? _patientSearchFormValues.setFirstName = @@ -219,7 +220,7 @@ class _PatientSearchScreenState extends State { height: 10, ), AppTextFormField( - hintText: 'Middle Name', + hintText: TranslationBase.of(context).middleName, onSaved: (value) { value == null ? _patientSearchFormValues.setMiddleName = @@ -238,7 +239,7 @@ class _PatientSearchScreenState extends State { height: 10, ), AppTextFormField( - hintText: 'Last Name', + hintText: TranslationBase.of(context).lastName, onSaved: (value) { value == null ? _patientSearchFormValues.setLastName = "0" @@ -254,7 +255,7 @@ class _PatientSearchScreenState extends State { ), AppTextFormField( textInputType: TextInputType.number, - hintText: 'Phone Number', + hintText: TranslationBase.of(context).phoneNumber, // validator: (value) { // return TextValidator().validateMobile(value); // }, @@ -277,7 +278,7 @@ class _PatientSearchScreenState extends State { ), AppTextFormField( textInputType: TextInputType.number, - hintText: 'Patient ID', + hintText: TranslationBase.of(context).patientID, // inputFormatter: ONLY_NUMBERS, onSaved: (value) { @@ -296,7 +297,7 @@ class _PatientSearchScreenState extends State { ), AppTextFormField( textInputType: TextInputType.number, - hintText: 'Patient File', + hintText: TranslationBase.of(context).patientID, // validator: (value) { // return TextValidator().validateIdNumber(value); // }, @@ -399,7 +400,7 @@ class _PatientSearchScreenState extends State { alignment: WrapAlignment.center, children: [ AppButton( - title: "Search", + title: TranslationBase.of(context).patientID, color: Color(0xff58434F), onPressed: () { _validateInputs(); diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index c62f9cb7..4c96593c 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -13,9 +13,8 @@ class TranslationBase { return Localizations.of(context, TranslationBase); } - - - String get dashboardScreenToolbarTitle => localizedValues['dashboardScreenToolbarTitle'][locale.languageCode]; + String get dashboardScreenToolbarTitle => + localizedValues['dashboardScreenToolbarTitle'][locale.languageCode]; String get settings => localizedValues['settings'][locale.languageCode]; @@ -33,25 +32,33 @@ class TranslationBase { String get mobileNo => localizedValues['mobileNo'][locale.languageCode]; - String get messagesScreenToolbarTitle => localizedValues['messagesScreenToolbarTitle'][locale.languageCode]; + String get messagesScreenToolbarTitle => + localizedValues['messagesScreenToolbarTitle'][locale.languageCode]; String get mySchedule => localizedValues['mySchedule'][locale.languageCode]; - String get errorNoSchedule => localizedValues['errorNoSchedule'][locale.languageCode]; - + String get errorNoSchedule => + localizedValues['errorNoSchedule'][locale.languageCode]; String get verify => localizedValues['verify'][locale.languageCode]; - String get referralDoctor => localizedValues['referralDoctor'][locale.languageCode]; - String get referringClinic => localizedValues['referringClinic'][locale.languageCode]; + String get referralDoctor => + localizedValues['referralDoctor'][locale.languageCode]; + String get referringClinic => + localizedValues['referringClinic'][locale.languageCode]; String get frequency => localizedValues['frequency'][locale.languageCode]; String get priority => localizedValues['priority'][locale.languageCode]; - String get maxResponseTime => localizedValues['maxResponseTime'][locale.languageCode]; - String get clinicDetailsandRemarks=> localizedValues['clinicDetailsandRemarks'][locale.languageCode]; - String get answerSuggestions => localizedValues['answerSuggestions'][locale.languageCode]; + String get maxResponseTime => + localizedValues['maxResponseTime'][locale.languageCode]; + String get clinicDetailsandRemarks => + localizedValues['clinicDetailsandRemarks'][locale.languageCode]; + String get answerSuggestions => + localizedValues['answerSuggestions'][locale.languageCode]; String get outPatients => localizedValues['outPatients'][locale.languageCode]; - String get searchPatient => localizedValues['searchPatient'][locale.languageCode]; + String get searchPatient => + localizedValues['searchPatient'][locale.languageCode]; String get labResult => localizedValues['labResult'][locale.languageCode]; - String get todayStatistics => localizedValues['todayStatistics'][locale.languageCode]; + String get todayStatistics => + localizedValues['todayStatistics'][locale.languageCode]; String get arrived => localizedValues['arrived'][locale.languageCode]; String get er => localizedValues['er'][locale.languageCode]; String get walkIn => localizedValues['walkIn'][locale.languageCode]; @@ -60,8 +67,20 @@ class TranslationBase { String get referral => localizedValues['referral'][locale.languageCode]; String get inPatient => localizedValues['inPatient'][locale.languageCode]; String get operations => localizedValues['inPatient'][locale.languageCode]; - String get patientServices => localizedValues['patientServices'][locale.languageCode]; - + String get patientServices => + localizedValues['patientServices'][locale.languageCode]; + String get searchMedicine => + localizedValues['searchMedicine'][locale.languageCode]; + String get myReferralPatient => + localizedValues['myReferralPatient'][locale.languageCode]; + String get myReferredPatient => + localizedValues['myReferredPatient'][locale.languageCode]; + String get firstName => localizedValues['firstName'][locale.languageCode]; + String get middleName => localizedValues['middleName'][locale.languageCode]; + String get lastName => localizedValues['lastName'][locale.languageCode]; + String get phoneNumber => localizedValues['phoneNumber'][locale.languageCode]; + String get patientID => localizedValues['patientID'][locale.languageCode]; + String get patientFile => localizedValues['PatientFile'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { From dcbf1312b780ba041742cf1dba1f2c1183f67ff5 Mon Sep 17 00:00:00 2001 From: hussam alhababieh Date: Sun, 14 Jun 2020 12:05:43 +0300 Subject: [PATCH 35/42] translate dashboard/patient search --- lib/config/localized_values.dart | 9 +++++++-- lib/screens/patients/patient_search_screen.dart | 8 +++++--- lib/util/translations_delegate_base.dart | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 1b05b5c6..33f184d2 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -49,6 +49,11 @@ const Map> localizedValues = { 'lastName': {'en': 'Last Name', 'ar': 'اسم العائلة'}, 'phoneNumber': {'en': 'Phone Number ', 'ar': 'رقم الجوال'}, 'patientID': {'en': 'Patient ID', 'ar': 'رقم المريض'}, - 'patientFile ': {'en': 'Patient File', 'ar': 'ملف المريض'}, - 'familyMedicine': {'en': 'Family Medicine Clinic', 'ar': 'عيادة طب الأسرة'} + 'patientFile': {'en': 'Patient File', 'ar': 'ملف المريض'}, + 'familyMedicine': {'en': 'Family Medicine Clinic', 'ar': 'عيادة طب الأسرة'}, + 'search': {'en': 'Search', 'ar': 'بحث'}, + 'onlyArrivedPatient': { + 'en': 'Only Arrived Patient', + 'ar': 'المريض الذي حضر للموعد' + }, }; diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 924357c6..f020ca2e 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -307,7 +307,7 @@ class _PatientSearchScreenState extends State { ), AppTextFormField( textInputType: TextInputType.number, - hintText: TranslationBase.of(context).patientID, + hintText: TranslationBase.of(context).patientFile, // validator: (value) { // return TextValidator().validateIdNumber(value); // }, @@ -401,7 +401,9 @@ class _PatientSearchScreenState extends State { value: true, activeColor: Color(0xffFFDDD9), onChanged: (bool newValue) {}), - AppText('Only Arrived Patient', + AppText( + TranslationBase.of(context) + .onlyArrivedPatient, fontSize: SizeConfig.textMultiplier * 2), ])), SizedBox( @@ -420,7 +422,7 @@ class _PatientSearchScreenState extends State { alignment: WrapAlignment.center, children: [ AppButton( - title: TranslationBase.of(context).patientID, + title: TranslationBase.of(context).search, color: Color(0xff58434F), onPressed: () { _validateInputs(); diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 61b1034e..41a923f5 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -82,7 +82,10 @@ class TranslationBase { String get lastName => localizedValues['lastName'][locale.languageCode]; String get phoneNumber => localizedValues['phoneNumber'][locale.languageCode]; String get patientID => localizedValues['patientID'][locale.languageCode]; - String get patientFile => localizedValues['PatientFile'][locale.languageCode]; + String get patientFile => localizedValues['patientFile'][locale.languageCode]; + String get search => localizedValues['search'][locale.languageCode]; + String get onlyArrivedPatient => + localizedValues['onlyArrivedPatient'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { From d52429564dedf0ef8b2346a046dc3ac971e8a0cb Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Sun, 14 Jun 2020 12:13:43 +0300 Subject: [PATCH 36/42] fix issues in Patient --- lib/screens/patients/patients_screen.dart | 2 ++ lib/widgets/shared/app_scaffold_widget.dart | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 68114a3d..96211046 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -102,8 +102,10 @@ class _PatientsScreenState extends State { } }); }).catchError((error) { + print(error); setState(() { _isError = true; + _isLoading = false; this.error = helpers.generateContactAdminMsg(error); }); }); diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index 263e3848..efdb0521 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -35,7 +35,7 @@ class AppScaffold extends StatelessWidget { IconButton( icon: Icon(DoctorApp.home_icon_active), color: Colors.white, //Colors.black, - onPressed: () => Navigator.pushReplacementNamed(context, HOME), + onPressed: () => Navigator.pushNamedAndRemoveUntil(context, HOME,(r) => false ), ), ], ) From 66627534a97ef3c724a26f90e988da43e2ada5c5 Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Sun, 14 Jun 2020 12:46:40 +0300 Subject: [PATCH 37/42] Modify date in time in search patiant --- lib/widgets/patients/dynamic_elements.dart | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/widgets/patients/dynamic_elements.dart b/lib/widgets/patients/dynamic_elements.dart index be66e88e..36808cb0 100644 --- a/lib/widgets/patients/dynamic_elements.dart +++ b/lib/widgets/patients/dynamic_elements.dart @@ -29,9 +29,28 @@ class _DynamicElementsState extends State { var selectedDate = DateFormat.yMd().format(pickedDate); if (id == '_selectedFromDate') { - _fromDateController.text = selectedDate; + // _fromDateController.text = selectedDate; + selectedDate = pickedDate.year.toString() + + "-" + + pickedDate.month.toString().padLeft(2, '0') + + "-" + + pickedDate.day.toString().padLeft(2, '0'); + + _fromDateController.text = selectedDate; + + + } else { + + + selectedDate = pickedDate.year.toString() + + "-" + + pickedDate.month.toString().padLeft(2, '0') + + "-" + + pickedDate.day.toString().padLeft(2, '0'); + _toDateController.text = selectedDate; + // _toDateController.text = selectedDate; } }); }); @@ -72,8 +91,11 @@ class _DynamicElementsState extends State { if (_fromDateController.text.toString().trim().isEmpty) { widget._patientSearchFormValues.From = "0"; } else { - widget._patientSearchFormValues.From = - _fromDateController.text; + widget._patientSearchFormValues.From = _fromDateController.text.replaceAll("/", "-"); + + + + // _fromDateController.text; } }, ), @@ -103,7 +125,7 @@ class _DynamicElementsState extends State { if (_toDateController.text.toString().trim().isEmpty) { widget._patientSearchFormValues.To = "0"; } else { - widget._patientSearchFormValues.To = _toDateController.text; + widget._patientSearchFormValues.To = _toDateController.text.replaceAll("/", "-"); } }, ), From 69173e8c46e4d15619d3978d7ff9186269cb7cac Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Sun, 14 Jun 2020 14:16:18 +0300 Subject: [PATCH 38/42] fix issues in login focus --- lib/widgets/auth/login_form.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/widgets/auth/login_form.dart b/lib/widgets/auth/login_form.dart index 2d2d2bfd..17b5520d 100644 --- a/lib/widgets/auth/login_form.dart +++ b/lib/widgets/auth/login_form.dart @@ -37,8 +37,8 @@ class _LoginFormState extends State { String uniqueId = "Unknown"; var projectsList = []; bool _isInit = true; - FocusNode focusPass; - FocusNode focusProject; + FocusNode focusPass = FocusNode(); + FocusNode focusProject = FocusNode(); var userInfo = UserModel( UserID: '', @@ -72,8 +72,7 @@ class _LoginFormState extends State { @override Widget build(BuildContext context) { - final focusPass = FocusNode(); - final focusProject = FocusNode(); + AuthProvider authProv = Provider.of(context); @@ -100,7 +99,7 @@ class _LoginFormState extends State { userInfo.UserID = value.trim(); }, onFieldSubmitted: (_) { - FocusScope.of(context).nextFocus(); + focusPass.nextFocus(); }, autofocus: false, ), @@ -121,7 +120,7 @@ class _LoginFormState extends State { userInfo.Password = value; }, onFieldSubmitted: (_) { - FocusScope.of(context).nextFocus(); + focusPass.nextFocus(); helpers.showCupertinoPicker( context, projectsList, 'Name', onSelectProject); }, From 0dad77bfa286216f62d50cf87be3d57299d1aca5 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Sun, 14 Jun 2020 15:12:38 +0300 Subject: [PATCH 39/42] fix issues in login --- lib/providers/auth_provider.dart | 37 ++++++++++++++++++++++ lib/root_page.dart | 38 +++++++++++++++++++++++ lib/routes.dart | 5 ++- lib/util/helpers.dart | 2 +- lib/widgets/shared/app_drawer_widget.dart | 4 ++- 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 lib/root_page.dart diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index e79192ae..415b8d39 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -1,4 +1,6 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; import '../models/user_model.dart'; @@ -14,8 +16,41 @@ const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = const MEMBER_CHECK_ACTIVATION_CODE_NEW = 'Sentry.svc/REST/MemberCheckActivationCode_New'; const GET_DOC_PROFILES = 'Doctors.svc/REST/GetDocProfiles'; +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); +enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } + class AuthProvider with ChangeNotifier { + + bool isLogin= false; + bool isLoading = true; + AuthProvider(){ + getUserAuthentication(); + } + + void getUserAuthentication() async{ + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + if(profile != null) + { + isLoading = false; + isLogin = true; + } else { + isLoading = false; + isLogin = false; + } + notifyListeners(); + } + APP_STATUS get stutas { + if (isLoading) { + return APP_STATUS.LOADING; + } else{ + if ( this.isLogin) { + return APP_STATUS.AUTHENTICATED; + } else { + return APP_STATUS.UNAUTHENTICATED; + } + } + } Future login(UserModel userInfo) async { try { dynamic localRes; @@ -131,4 +166,6 @@ class AuthProvider with ChangeNotifier { throw error; } } + + } diff --git a/lib/root_page.dart b/lib/root_page.dart new file mode 100644 index 00000000..a784183b --- /dev/null +++ b/lib/root_page.dart @@ -0,0 +1,38 @@ +import 'package:doctor_app_flutter/providers/auth_provider.dart'; +import 'package:doctor_app_flutter/screens/auth/login_screen.dart'; +import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import 'landing_page.dart'; + +class RootPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + AuthProvider authProvider = Provider.of(context); + + Widget buildRoot() { + switch (authProvider.stutas) { + case APP_STATUS.LOADING: + return Scaffold( + body: Center( + child: DrAppCircularProgressIndeicator(), + ), + ); + break; + case APP_STATUS.UNAUTHENTICATED: + return Loginsreen(); + break; + case APP_STATUS.AUTHENTICATED: + return LandingPage(); + break; + } + } + + return AnimatedSwitcher( + duration: Duration(microseconds: 350), + child: buildRoot(), + ); + } +} diff --git a/lib/routes.dart b/lib/routes.dart index 34d3224d..cd5b3187 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/root_page.dart'; import 'package:doctor_app_flutter/screens/patients/profile/insurance_approvals_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/patient_orders_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/progress_note_screen.dart'; @@ -38,7 +39,8 @@ import './screens/settings/settings_screen.dart'; import 'landing_page.dart'; import 'screens/doctor/doctor_reply_screen.dart'; -const String INIT_ROUTE = LOGIN; +const String INIT_ROUTE = ROOT; +const String ROOT = 'root'; const String HOME = '/'; const String LOGIN = 'login'; const String PROFILE = 'profile'; @@ -71,6 +73,7 @@ const String BODY_MEASUREMENTS = 'patients/body-measurements'; const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; var routes = { + ROOT: (_) => RootPage(), HOME: (_) => LandingPage(), LOGIN: (_) => Loginsreen(), PROFILE: (_) => ProfileScreen(), diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index ebcf817c..aa92b253 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -335,7 +335,7 @@ class Helpers { return localMsg; } - clearSharedPref() async { + static clearSharedPref() async { await sharedPref.clear(); } diff --git a/lib/widgets/shared/app_drawer_widget.dart b/lib/widgets/shared/app_drawer_widget.dart index 919dc939..b2cd3dd9 100644 --- a/lib/widgets/shared/app_drawer_widget.dart +++ b/lib/widgets/shared/app_drawer_widget.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -105,7 +106,8 @@ class _AppDrawerState extends State { ), InkWell( child: DrawerItem("lOGOUT", Icons.exit_to_app), - onTap: () { + onTap: () async { + await Helpers.clearSharedPref(); Navigator.pop(context); Navigator.of(context).pushNamed(LOGIN); }, From 6fd43a281d3a4840e1baa1b0bd33a4d7c2722fa2 Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Sun, 14 Jun 2020 16:02:44 +0300 Subject: [PATCH 40/42] fixing --- lib/providers/patients_provider.dart | 84 +++++------- .../profile/refer_patient_screen.dart | 128 ++++++++++++------ lib/widgets/shared/app_text_form_field.dart | 4 +- 3 files changed, 122 insertions(+), 94 deletions(-) diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 6da89e74..2d1f4fe1 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -63,7 +63,7 @@ class PatientsProvider with ChangeNotifier { STPReferralFrequencyRequest(); ClinicByProjectIdRequest _clinicByProjectIdRequest = ClinicByProjectIdRequest(); - ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); + ReferToDoctorRequest _referToDoctorRequest; PatiantInformtion _selectedPatient; @@ -486,7 +486,7 @@ class PatientsProvider with ChangeNotifier { *@Date:3/6/2020 *@desc: referToDoctor */ - referToDoctor(context, + referToDoctor(context, {String selectedDoctorID, String selectedClinicID, int admissionNo, @@ -500,56 +500,42 @@ class PatientsProvider with ChangeNotifier { int projectID}) async { setBasicData(); try { - if (await Helpers.checkConnection()) { - String token = await sharedPref.getString(TOKEN); - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - DoctorProfileModel doctorProfile = - new DoctorProfileModel.fromJson(profile); - int doctorID = doctorProfile.doctorID; - int clinicId = doctorProfile.clinicID; - _referToDoctorRequest = ReferToDoctorRequest( - projectID: projectID, - admissionNo: admissionNo, - roomID: roomID, - referralClinic: selectedClinicID.toString(), - referralDoctor: selectedDoctorID.toString(), - createdBy: doctorID, - editedBy: doctorID, - patientID: patientID, - patientTypeID: patientTypeID, - referringClinic: clinicId, - referringDoctor: doctorID, - referringDoctorRemarks: referringDoctorRemarks, - priority: priority, - frequency: frequency, - extension: extension, - tokenID: token); - - final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, - body: json.encode(_referToDoctorRequest)); - final int statusCode = response.statusCode; - isLoading = false; - - if (statusCode < 200 || statusCode >= 400 || json == null) { - isError = true; - error = 'Error While Fetching data'; - } else { - var res = json.decode(response.body); - print('$res'); - if (res['MessageStatus'] == 1) { - print('Done : \n $res'); + String token = await sharedPref.getString(TOKEN); + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + DoctorProfileModel doctorProfile = + new DoctorProfileModel.fromJson(profile); + int doctorID = doctorProfile.doctorID; + int clinicId = doctorProfile.clinicID; + _referToDoctorRequest = ReferToDoctorRequest( + projectID: projectID, + admissionNo: admissionNo, + roomID: roomID, + referralClinic: selectedClinicID.toString(), + referralDoctor: selectedDoctorID.toString(), + createdBy: doctorID, + editedBy: doctorID, + patientID: patientID, + patientTypeID: patientTypeID, + referringClinic: clinicId, + referringDoctor: doctorID, + referringDoctorRemarks: referringDoctorRemarks, + priority: priority, + frequency: frequency, + extension: extension, + tokenID: token); + await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL, + onSuccess: (dynamic response, int statusCode) { + // print('Done : \n $res'); Navigator.pop(context); - } else { + }, + onFailure: (String error, int statusCode) { + isLoading = false; isError = true; - error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + this.error = error; + }, + body: _referToDoctorRequest.toJson()); notifyListeners(); + } catch (err) { handelCatchErrorCase(err); } diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 24146ca5..1da89f97 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -15,6 +15,7 @@ import '../../../util/dr_app_shared_pref.dart'; import '../../../widgets/shared/app_scaffold_widget.dart'; import '../../../widgets/shared/app_texts_widget.dart'; import '../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import '../../../util/extenstions.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -37,6 +38,7 @@ class _ReferPatientState extends State { final _remarksController = TextEditingController(); final _extController = TextEditingController(); var _isInit = true; + bool isValid; var clinicId; var doctorId; @@ -49,14 +51,17 @@ class _ReferPatientState extends State { List _priorities = ['Very Urgent', 'Urgent', 'Routine']; int _activePriority = 2; + FocusNode myFocusNode; + @override void didChangeDependencies() { super.didChangeDependencies(); if (_isInit) { + myFocusNode = FocusNode(); doctorsList = null; patientsProv = Provider.of(context); patientsProv.getClinicsList(); - patientsProv.getReferralFrequancyList(); + patientsProv.getReferralFrequancyList(); } _isInit = false; } @@ -70,10 +75,9 @@ class _ReferPatientState extends State { : patientsProv.isError ? DrAppEmbeddedError(error: patientsProv.error) : patientsProv.clinicsList == null - ? DrAppEmbeddedError( - error: 'Something Wrong!') + ? DrAppEmbeddedError(error: 'Something Wrong!') : SingleChildScrollView( - child: Column( + child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -128,13 +132,17 @@ class _ReferPatientState extends State { setState(() { _selectedDoctor = null; _selectedClinic = newValue; - var clinicInfo = patientsProv.clinicsList.where((i) => + var clinicInfo = patientsProv + .clinicsList + .where((i) => i['ClinicDescription'] .toString() - .contains(_selectedClinic)).toList(); - - clinicId = - clinicInfo[0]['ClinicID'].toString(); + .contains( + _selectedClinic)) + .toList(); + + clinicId = clinicInfo[0]['ClinicID'] + .toString(); patientsProv.getDoctorsList(clinicId); }) @@ -208,15 +216,16 @@ class _ReferPatientState extends State { onChanged: (newValue) => { setState(() { _selectedDoctor = newValue; - doctorsList = patientsProv.doctorsList; - - var doctorInfo = - doctorsList.where((i) => - i['DoctorName'] - .toString() - .contains(_selectedDoctor)).toList(); - doctorId = doctorInfo[0]['DoctorID'].toString(); - + doctorsList = + patientsProv.doctorsList; + + var doctorInfo = doctorsList + .where((i) => i['DoctorName'] + .toString() + .contains(_selectedDoctor)) + .toList(); + doctorId = doctorInfo[0]['DoctorID'] + .toString(); }) }, items: patientsProv @@ -320,13 +329,16 @@ class _ReferPatientState extends State { onChanged: (newValue) => { setState(() { _selectedReferralFrequancy = newValue; - var freqInfo = - patientsProv.referalFrequancyList.singleWhere((i) => - i['Description'] - .toString() - .contains(_selectedReferralFrequancy)); - freqId = - freqInfo['ParameterCode'].toString(); + var freqInfo = patientsProv + .referalFrequancyList + .singleWhere((i) => i[ + 'Description'] + .toString() + .contains( + _selectedReferralFrequancy)); + freqId = freqInfo['ParameterCode'] + .toString(); + myFocusNode.requestFocus(); }) }, items: patientsProv @@ -357,6 +369,7 @@ class _ReferPatientState extends State { padding: const EdgeInsets.all(10.0), child: AppTextFormField( hintText: "Remarks", + focusNode: myFocusNode, controller: _remarksController, inputFormatter: ONLY_LETTERS, textInputType: TextInputType.text, @@ -364,14 +377,27 @@ class _ReferPatientState extends State { ), ), Padding( - padding: const EdgeInsets.all(20.0), - child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{ - referToDoctor(context) - },), - ) + padding: const EdgeInsets.all(20.0), + child: Column( + children: [ + AppText( + "Please fill all fields..!", + color: Colors.red, + fontWeight: FontWeight.bold, + margin: 10, + visibility: + isValid == null ? false : !isValid, + ), + AppButton( + title: "Send", + color: Color(PRIMARY_COLOR), + onPressed: () => {referToDoctor(context)}, + ) + ], + )) ], ), - ), + ), ); } @@ -456,21 +482,35 @@ class _ReferPatientState extends State { return time; } - void referToDoctor(context){ + void referToDoctor(context) { + if (!validation()) { + return; + } + final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; patientsProv.referToDoctor(context, - extension: _extController.value.text, - admissionNo:int.parse( patient.admissionNo), - referringDoctorRemarks: _remarksController.value.text, - frequency: freqId, - patientID: patient.patientId, - patientTypeID: patient.patientType, - priority: (_activePriority + 1).toString(), - roomID: patient.roomId, - selectedClinicID: clinicId.toString(), - selectedDoctorID: doctorId.toString(), - projectID: patient.projectId - ); + extension: _extController.value.text, + admissionNo: int.parse(patient.admissionNo), + referringDoctorRemarks: _remarksController.value.text, + frequency: freqId, + patientID: patient.patientId, + patientTypeID: patient.patientType, + priority: (_activePriority + 1).toString(), + roomID: patient.roomId, + selectedClinicID: clinicId.toString(), + selectedDoctorID: doctorId.toString(), + projectID: patient.projectId); + } + + bool validation() { + setState(() { + isValid = !_extController.value.text.isNullOrEmpty() && + !_remarksController.value.text.isNullOrEmpty() && + freqId != null && + clinicId != null && + doctorId != null; + }); + return isValid; } } diff --git a/lib/widgets/shared/app_text_form_field.dart b/lib/widgets/shared/app_text_form_field.dart index fd50ad66..06dfb9e7 100644 --- a/lib/widgets/shared/app_text_form_field.dart +++ b/lib/widgets/shared/app_text_form_field.dart @@ -18,7 +18,8 @@ class AppTextFormField extends FormField { TextEditingController controller, bool autovalidate = true, TextInputType textInputType, - String hintText + String hintText, + FocusNode focusNode }) : super( onSaved: onSaved, validator: validator, @@ -27,6 +28,7 @@ class AppTextFormField extends FormField { return Column( children: [ TextFormField( + focusNode: focusNode, keyboardType: textInputType, inputFormatters: [WhitelistingTextInputFormatter(RegExp(inputFormatter)),], onChanged: onChanged?? (value){ From 8da67db69fa85a29c10eb11c80c19ed0c268a77b Mon Sep 17 00:00:00 2001 From: ibrahim albitar Date: Sun, 14 Jun 2020 16:38:38 +0300 Subject: [PATCH 41/42] fix patient type dropdown --- lib/config/config.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 2bd1256d..1a4b5694 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -24,7 +24,7 @@ const GET_PATIENT_LAB_OREDERS = const GET_PRESCRIPTION = 'Patients.svc/REST/GetPrescriptionApptList'; const GET_RADIOLOGY = 'DoctorApplication.svc/REST/GetPatientRadResult'; -var selectedPatientType = 0; +var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ var SERVICES_PATIANT = [ From 94dbecca4a087215c8e995908cca146988af1fc9 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Sun, 14 Jun 2020 17:03:00 +0300 Subject: [PATCH 42/42] fix issues in login --- lib/main.dart | 2 ++ lib/root_page.dart | 2 +- lib/widgets/shared/app_scaffold_widget.dart | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/main.dart b/lib/main.dart index 470c5d52..d5f65406 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,7 @@ import './providers/auth_provider.dart'; import './providers/patients_provider.dart'; import './providers/hospital_provider.dart'; import './routes.dart'; +import 'config/config.dart'; void main() => runApp(MyApp()); @@ -18,6 +19,7 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { + AppGlobal.CONTEX = context; return LayoutBuilder( builder: (context, constraints) { return OrientationBuilder(builder: (context, orientation) { diff --git a/lib/root_page.dart b/lib/root_page.dart index a784183b..e361e42c 100644 --- a/lib/root_page.dart +++ b/lib/root_page.dart @@ -5,13 +5,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'config/config.dart'; import 'landing_page.dart'; class RootPage extends StatelessWidget { @override Widget build(BuildContext context) { AuthProvider authProvider = Provider.of(context); - Widget buildRoot() { switch (authProvider.stutas) { case APP_STATUS.LOADING: diff --git a/lib/widgets/shared/app_scaffold_widget.dart b/lib/widgets/shared/app_scaffold_widget.dart index efdb0521..824ba11b 100644 --- a/lib/widgets/shared/app_scaffold_widget.dart +++ b/lib/widgets/shared/app_scaffold_widget.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -13,6 +14,7 @@ class AppScaffold extends StatelessWidget { @override Widget build(BuildContext context) { + AppGlobal.CONTEX = context; return Scaffold( backgroundColor: Hexcolor('#F5F5F5'), appBar: appBarTitle != ''