From 97dbe62f93e03e1dd6d95b870d95e959f38c2a07 Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Thu, 13 Aug 2020 14:53:04 +0300 Subject: [PATCH 1/5] done report service --- lib/config/config.dart | 5 + lib/core/enum/filter_type.dart | 1 + lib/core/enum/reportfilter_type.dart | 1 + lib/core/model/reports/Reports.dart | 137 +++++++++++++++++ lib/core/model/reports/request_reports.dart | 76 ++++++++++ lib/core/service/medical/reports_service.dart | 66 ++++++++ .../medical/reports_view_model.dart | 127 ++++++++++++++++ lib/locator.dart | 5 + lib/pages/medical/medical_profile_page.dart | 8 + .../medical/reports/report_home_page.dart | 142 ++++++++++++++++++ lib/pages/medical/reports/reports_page.dart | 10 ++ 11 files changed, 578 insertions(+) create mode 100644 lib/core/enum/reportfilter_type.dart create mode 100644 lib/core/model/reports/Reports.dart create mode 100644 lib/core/model/reports/request_reports.dart create mode 100644 lib/core/service/medical/reports_service.dart create mode 100644 lib/core/viewModels/medical/reports_view_model.dart create mode 100644 lib/pages/medical/reports/report_home_page.dart create mode 100644 lib/pages/medical/reports/reports_page.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 643a2ec9..5b43949e 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -20,6 +20,11 @@ const GET_PRESCRIPTIONS_ALL_ORDERS = '/Patients.svc/REST/PatientER_GetPatientAl const GET_PRESCRIPTION_REPORT = '/Patients.svc/REST/INP_GetPrescriptionReport'; const SEND_PRESCRIPTION_EMAIL = '/Notifications.svc/REST/SendPrescriptionEmail'; + +///Reports +const REPORTS = '/Doctors.svc/REST/GetPatientMedicalReportStatusInfo'; + + //const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment //const BASE_URL = 'https://uat.hmgwebservices.com/Services'; // UAT Environment diff --git a/lib/core/enum/filter_type.dart b/lib/core/enum/filter_type.dart index 9da35c43..4591e023 100644 --- a/lib/core/enum/filter_type.dart +++ b/lib/core/enum/filter_type.dart @@ -1 +1,2 @@ enum FilterType { Clinic, Hospital } + diff --git a/lib/core/enum/reportfilter_type.dart b/lib/core/enum/reportfilter_type.dart new file mode 100644 index 00000000..74cd97c6 --- /dev/null +++ b/lib/core/enum/reportfilter_type.dart @@ -0,0 +1 @@ +enum ReportFilterType { Requested, Ready,Completed,Cancelled } \ No newline at end of file diff --git a/lib/core/model/reports/Reports.dart b/lib/core/model/reports/Reports.dart new file mode 100644 index 00000000..eb09c0c5 --- /dev/null +++ b/lib/core/model/reports/Reports.dart @@ -0,0 +1,137 @@ +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +class Reports { + int status; + DateTime encounterDate; + int projectID; + int invoiceNo; + int encounterNo; + String procedureId; + int requestType; + String setupId; + int patientID; + int doctorID; + Null clinicID; + DateTime requestDate; + bool isRead; + DateTime isReadOn; + int actualDoctorRate; + String clinicDescription; + Null clinicDescriptionN; + String docName; + Null docNameN; + String doctorImageURL; + Null doctorName; + Null doctorNameN; + int doctorRate; + bool isDoctorAllowVedioCall; + bool isExecludeDoctor; + int noOfPatientsRate; + String projectName; + Null projectNameN; + + Reports( + {this.status, + this.encounterDate, + this.projectID, + this.invoiceNo, + this.encounterNo, + this.procedureId, + this.requestType, + this.setupId, + this.patientID, + this.doctorID, + this.clinicID, + this.requestDate, + this.isRead, + this.isReadOn, + this.actualDoctorRate, + this.clinicDescription, + this.clinicDescriptionN, + this.docName, + this.docNameN, + this.doctorImageURL, + this.doctorName, + this.doctorNameN, + this.doctorRate, + this.isDoctorAllowVedioCall, + this.isExecludeDoctor, + this.noOfPatientsRate, + this.projectName, + this.projectNameN}); + + Reports.fromJson(Map json) { + status = json['Status']; + encounterDate = DateUtil.convertStringToDate(json['EncounterDate']);//json['EncounterDate']; + projectID = json['ProjectID']; + invoiceNo = json['InvoiceNo']; + encounterNo = json['EncounterNo']; + procedureId = json['ProcedureId']; + requestType = json['RequestType']; + setupId = json['SetupId']; + patientID = json['PatientID']; + doctorID = json['DoctorID']; + clinicID = json['ClinicID']; + requestDate = DateUtil.convertStringToDate(json['RequestDate']);//json['RequestDate']; + isRead = json['IsRead']; + isReadOn =DateUtil.convertStringToDate(json['IsReadOn']); //json['IsReadOn']; + actualDoctorRate = json['ActualDoctorRate']; + clinicDescription = json['ClinicDescription']; + clinicDescriptionN = json['ClinicDescriptionN']; + docName = json['DocName']; + docNameN = json['DocNameN']; + doctorImageURL = json['DoctorImageURL']; + doctorName = json['DoctorName']; + doctorNameN = json['DoctorNameN']; + doctorRate = json['DoctorRate']; + isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall']; + isExecludeDoctor = json['IsExecludeDoctor']; + noOfPatientsRate = json['NoOfPatientsRate']; + projectName = json['ProjectName']; + projectNameN = json['ProjectNameN']; + } + + Map toJson() { + final Map data = new Map(); + data['Status'] = this.status; + data['EncounterDate'] = this.encounterDate; + data['ProjectID'] = this.projectID; + data['InvoiceNo'] = this.invoiceNo; + data['EncounterNo'] = this.encounterNo; + data['ProcedureId'] = this.procedureId; + data['RequestType'] = this.requestType; + data['SetupId'] = this.setupId; + data['PatientID'] = this.patientID; + data['DoctorID'] = this.doctorID; + data['ClinicID'] = this.clinicID; + data['RequestDate'] = this.requestDate; + data['IsRead'] = this.isRead; + data['IsReadOn'] = this.isReadOn; + data['ActualDoctorRate'] = this.actualDoctorRate; + data['ClinicDescription'] = this.clinicDescription; + data['ClinicDescriptionN'] = this.clinicDescriptionN; + data['DocName'] = this.docName; + data['DocNameN'] = this.docNameN; + data['DoctorImageURL'] = this.doctorImageURL; + data['DoctorName'] = this.doctorName; + data['DoctorNameN'] = this.doctorNameN; + data['DoctorRate'] = this.doctorRate; + data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall; + data['IsExecludeDoctor'] = this.isExecludeDoctor; + data['NoOfPatientsRate'] = this.noOfPatientsRate; + data['ProjectName'] = this.projectName; + data['ProjectNameN'] = this.projectNameN; + return data; + } +} + + +class ReportsList{ + String filterName=""; + // int filterName=1; + ListreportsList=List(); + ReportsList({this.filterName,Reports reports}){ + reportsList.add(reports); + } + + +} diff --git a/lib/core/model/reports/request_reports.dart b/lib/core/model/reports/request_reports.dart new file mode 100644 index 00000000..14359591 --- /dev/null +++ b/lib/core/model/reports/request_reports.dart @@ -0,0 +1,76 @@ +class RequestReports { + bool isReport; + int encounterType; + int requestType; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + + RequestReports( + {this.isReport, + this.encounterType, + this.requestType, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType}); + + RequestReports.fromJson(Map json) { + isReport = json['IsReport']; + encounterType = json['EncounterType']; + requestType = json['RequestType']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + } + + Map toJson() { + final Map data = new Map(); + data['IsReport'] = this.isReport; + data['EncounterType'] = this.encounterType; + data['RequestType'] = this.requestType; + data['VersionID'] = this.versionID; + 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; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + return data; + } +} \ No newline at end of file diff --git a/lib/core/service/medical/reports_service.dart b/lib/core/service/medical/reports_service.dart new file mode 100644 index 00000000..6e965e33 --- /dev/null +++ b/lib/core/service/medical/reports_service.dart @@ -0,0 +1,66 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/reports/Reports.dart'; +import 'package:diplomaticquarterapp/core/model/reports/request_reports.dart'; +import 'package:diplomaticquarterapp/core/service/base_service.dart'; + + + +class ReportsService extends BaseService{ + + List reportsList = List(); + + RequestReports _requestReports=RequestReports( + isReport: true, + encounterType: 1, + requestType: 1, + versionID: 5.5, + channel: 3, + languageID: 2, + iPAdress: "10.20.10.20", + generalid: 'Cs2020@2016\$2958', + patientOutSA: 0, + sessionID: 'KIbLoqkytuKJEWECHQ', + isDentalAllowedBackend: false, + deviceTypeID: 2, + patientID: 1231755, + tokenID: '@dm!n', + patientTypeID: 1, + patientType: 1 + + + ); + Future getReports() async { + hasError = false; + await baseAppClient.post(REPORTS, + onSuccess: (dynamic response, int statusCode) + { + reportsList.clear(); + + response['GetPatientMedicalStatus'].forEach((reports) { + reportsList.add(Reports.fromJson(reports)); + }); + },onFailure: (String error,int statusCode){ + hasError = true; + super.error = error; + },body: _requestReports.toJson()); + + } + + + + +// Future getPrescriptions() async { +// hasError = false; +// await baseAppClient.post(PRESCRIPTIONS, +// onSuccess: (dynamic response, int statusCode) { +// prescriptionsList.clear(); +// response['PatientPrescriptionList'].forEach((prescriptions) { +// prescriptionsList.add(Prescriptions.fromJson(prescriptions)); +// }); +// }, onFailure: (String error, int statusCode) { +// hasError = true; +// super.error = error; +// }, body: _requestPrescriptions.toJson()); +// } + +} \ No newline at end of file diff --git a/lib/core/viewModels/medical/reports_view_model.dart b/lib/core/viewModels/medical/reports_view_model.dart new file mode 100644 index 00000000..e0a4d8fb --- /dev/null +++ b/lib/core/viewModels/medical/reports_view_model.dart @@ -0,0 +1,127 @@ +//import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; + +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; + +import '../../../core/enum/reportfilter_type.dart'; +import '../../../core/enum/viewstate.dart'; +//import '../../../core/model/prescriptions/Prescriptions.dart'; +import '../../../core/model/reports/Reports.dart'; + +//import '../../../core/service/medical/prescriptions_service.dart'; +import '../../../core/service/medical/reports_service.dart'; + +import '../../../locator.dart'; +import '../base_view_model.dart'; + +class ReportsViewModel extends BaseViewModel { + ReportFilterType filterType = ReportFilterType.Requested; + + ReportsService _reportsService = locator(); + + List _reportsOrderRequestList = List(); + List _reportsOrderReadyList = List(); + List _reportsOrderCompletedList = List(); + List _reportsOrderCanceledList = List(); + + List get reportsList => _reportsService.reportsList; + + ///// + List get reportsOrderList { + switch (filterType) { + case ReportFilterType.Requested: + return _reportsOrderRequestList; + break; + + case ReportFilterType.Ready: + return _reportsOrderReadyList; + break; + + case ReportFilterType.Completed: + return _reportsOrderCompletedList; + break; + + default: + return _reportsOrderCanceledList; + } + } + + getReports() async { + setState(ViewState.Busy); + await _reportsService.getReports(); + if (_reportsService.hasError) { + error = _reportsService.error; + setState(ViewState.Error); + } else { + _filterList(); + setState(ViewState.Idle); + } + } + +//////////////////////// + void _filterList() { + _reportsService.reportsList.forEach((element) { + /// ReportsList list sort Request + List reportsByRequest = _reportsOrderRequestList + .where((elementStatus) => elementStatus.filterName == element.status) + .toList(); + + if (reportsByRequest.length != 0) { + _reportsOrderRequestList[ + _reportsOrderRequestList.indexOf(reportsByRequest[0])] + .reportsList + .add(element); + } else { + _reportsOrderRequestList.add(ReportsList( + filterName: element.clinicDescription, reports: element)); + } + //////// + /// ReportsList list sort Ready + List reportsByReady = _reportsOrderReadyList + .where((elementStatus) => elementStatus.filterName == element.status) + .toList(); + + if (reportsByReady.length != 0) { + _reportsOrderReadyList[ + _reportsOrderReadyList.indexOf(reportsByReady[0])] + .reportsList + .add(element); + } else { + _reportsOrderReadyList.add(ReportsList( + filterName: element.clinicDescription, reports: element)); + } + + /// ReportsList list sort Compleated + List reportsByCompleated = _reportsOrderCompletedList + .where((elementStatus) => elementStatus.filterName == element.status) + .toList(); + + if (reportsByCompleated.length != 0) { + _reportsOrderCompletedList[ + _reportsOrderCompletedList.indexOf(reportsByCompleated[0])] + .reportsList + .add(element); + } else { + _reportsOrderCompletedList.add(ReportsList( + filterName: element.clinicDescription, reports: element)); + } + /// ReportsList list sort Cancelled + List reportsByCancelled = _reportsOrderCanceledList + .where((elementStatus) => elementStatus.filterName == element.status) + .toList(); + + if (reportsByCancelled.length != 0) { + _reportsOrderCanceledList[ + _reportsOrderCanceledList.indexOf(reportsByCompleated[0])] + .reportsList + .add(element); + } else { + _reportsOrderCanceledList.add(ReportsList( + filterName: element.clinicDescription, reports: element)); + } + //**************************** + }); + + } +/////////////////////// + +} diff --git a/lib/locator.dart b/lib/locator.dart index c1a2a170..2e48655e 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,11 +1,14 @@ + import 'package:get_it/get_it.dart'; import 'core/service/hospital_service.dart'; import 'core/service/medical/my_doctor_service.dart'; import 'core/service/medical/prescriptions_service.dart'; +import 'core/service/medical/reports_service.dart'; import 'core/viewModels/hospital_view_model.dart'; import 'core/viewModels/medical/my_doctor_view_model.dart'; import 'core/viewModels/medical/prescriptions_view_model.dart'; +import 'core/viewModels/medical/reports_view_model.dart'; import 'core/viewModels/pharmacies_view_model.dart'; import 'core/service/pharmacies_service.dart'; @@ -18,10 +21,12 @@ void setupLocator() { locator.registerLazySingleton(() => PharmacyService()); locator.registerLazySingleton(() => MyDoctorService()); locator.registerLazySingleton(() => PrescriptionsService()); + locator.registerLazySingleton(() => ReportsService()); /// View Model locator.registerFactory(() => HospitalViewModel()); locator.registerFactory(() => PharmacyViewModel()); locator.registerFactory(() => MyDoctorViewModel()); locator.registerFactory(() => PrescriptionsViewModel()); + locator.registerFactory(() => ReportsViewModel()); } diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index ceacaed4..b6a0662a 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -1,6 +1,7 @@ import 'dart:math'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; +import 'package:diplomaticquarterapp/pages/medical/reports/report_home_page.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/sliver_app_bar_delegate.dart'; @@ -122,11 +123,18 @@ class _MedicalProfilePageState extends State { children: [ Expanded( flex: 1, + child:InkWell( + onTap: (){ + Navigator.push(context, FadePage(page: HomeRepoertsPage())); + + }, + child: MedicalProfileItem( title: 'Medical', imagePath: 'medical_history_icon.png', subTitle: 'Reports', ), + ), ), Expanded( flex: 1, diff --git a/lib/pages/medical/reports/report_home_page.dart b/lib/pages/medical/reports/report_home_page.dart new file mode 100644 index 00000000..10f75b67 --- /dev/null +++ b/lib/pages/medical/reports/report_home_page.dart @@ -0,0 +1,142 @@ +import 'dart:ui'; + +import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/reports_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_page.dart'; + +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class HomeRepoertsPage extends StatefulWidget { + @override + _HomeRepoertsPageState createState() => _HomeRepoertsPageState(); +} + +class _HomeRepoertsPageState extends State + with SingleTickerProviderStateMixin { + TabController _tabController; + + @override + void initState() { + super.initState(); + _tabController = TabController(length: 4, vsync: this); + } + + @override + void dispose() { + super.dispose(); + _tabController.dispose(); + } + + + @override + Widget build(BuildContext context) { + return BaseView( + onModelReady: (model) =>model.getReports(), //model.getPrescriptions(), + builder: (_, model, widget) => AppScaffold( + isShowAppBar: true, + appBarTitle: 'Request', + //bottomSheet: Container(), + body: Scaffold( + extendBodyBehindAppBar: true, + appBar: PreferredSize( + preferredSize: Size.fromHeight(65.0), + child: Stack( + children: [ + Positioned( + bottom: 1, + left: 0, + right: 0, + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), + child: Container( + color: Theme.of(context) + .scaffoldBackgroundColor + .withOpacity(0.8), + height: 70.0, + ), + ), + ), + Center( + child: Container( + height: 60.0, + margin: EdgeInsets.only(top: 10.0), + width: MediaQuery.of(context).size.width * 0.9, + decoration: BoxDecoration( + border: Border( + bottom: BorderSide( + color: Theme.of(context).dividerColor, + width: 0.7), + ), + color: Colors.white), + child: Center( + child: TabBar( + isScrollable: true, + controller: _tabController, + indicatorWeight: 5.0, + indicatorSize: TabBarIndicatorSize.label, + indicatorColor: Colors.red[800], + labelColor: Theme.of(context).primaryColor, + labelPadding: + EdgeInsets.only(top: 4.0, left: 18.0, right: 18.0), + unselectedLabelColor: Colors.grey[800], + tabs: [ + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: Center( + child: Texts('Requested'), + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: Center( + child: Texts('Ready'), + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: Center( + child: Texts('Completed'), + ), + ), + Container( + width: MediaQuery.of(context).size.width * 0.30, + child: Center( + child: Texts('Cancelled'), + ), + ), + ], + ), + ), + ), + ), + ], + ), + ), + body: Column( + children: [ + Expanded( + child: TabBarView( + physics: BouncingScrollPhysics(), + controller: _tabController, + children: [ +// PrescriptionsPage(prescriptionsViewModel: model,), +// PrescriptionsHistory() + Icon(Icons.directions_car), + Icon(Icons.directions_transit), + Icon(Icons.directions_bike), + Icon(Icons.directions_bike), + ], + ), + ) + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/medical/reports/reports_page.dart b/lib/pages/medical/reports/reports_page.dart new file mode 100644 index 00000000..bb89a9df --- /dev/null +++ b/lib/pages/medical/reports/reports_page.dart @@ -0,0 +1,10 @@ +import 'package:diplomaticquarterapp/core/enum/filter_type.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; +import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescription_items_page.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; \ No newline at end of file From 8495260c5af0e75975d0806310de6cbb11d8ec22 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Sun, 23 Aug 2020 15:06:34 +0300 Subject: [PATCH 2/5] fix issues in feedback --- lib/core/service/client/base_app_client.dart | 1 + .../service/feedback/feedback_service.dart | 2 +- lib/core/service/medical/medical_service.dart | 3 + .../feedback/feedback_view_model.dart | 46 +- lib/pages/feedback/send_feedback_page.dart | 473 ++++++++---------- lib/pages/feedback/status_feedback_page.dart | 44 +- .../medical/time_line_widget.dart | 34 ++ 7 files changed, 305 insertions(+), 298 deletions(-) create mode 100644 lib/widgets/data_display/medical/time_line_widget.dart diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 53f91de7..19bb01eb 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -55,6 +55,7 @@ class BaseAppClient { 'Accept': 'application/json' }); final int statusCode = response.statusCode; + print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { onFailure('Error While Fetching data', statusCode); } else { diff --git a/lib/core/service/feedback/feedback_service.dart b/lib/core/service/feedback/feedback_service.dart index 575e4110..74107585 100644 --- a/lib/core/service/feedback/feedback_service.dart +++ b/lib/core/service/feedback/feedback_service.dart @@ -59,7 +59,7 @@ class FeedbackService extends BaseService { onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: _requestInsertCOCItem.toJson()); + }, body: body); } Future getStatusCOC() async { diff --git a/lib/core/service/medical/medical_service.dart b/lib/core/service/medical/medical_service.dart index 95d45012..90230f6d 100644 --- a/lib/core/service/medical/medical_service.dart +++ b/lib/core/service/medical/medical_service.dart @@ -6,6 +6,9 @@ class MedicalService extends BaseService { List appoitmentAllHistoryResultList = List(); getAppointmentHistory() async { + hasError = false; + super.error = ""; + await baseAppClient.post(GET_PATIENT_APPOINTMENT_HISTORY, onSuccess: (response, statusCode) async { appoitmentAllHistoryResultList.clear(); diff --git a/lib/core/viewModels/feedback/feedback_view_model.dart b/lib/core/viewModels/feedback/feedback_view_model.dart index 5f464322..d5f14e2d 100644 --- a/lib/core/viewModels/feedback/feedback_view_model.dart +++ b/lib/core/viewModels/feedback/feedback_view_model.dart @@ -6,10 +6,52 @@ import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart'; import '../../../locator.dart'; +enum MessageType { + ComplaintOnAnAppointment, + ComplaintWithoutAppointment, + Question, + Compliment, + Suggestion, + NON +} + class FeedbackViewModel extends BaseViewModel { FeedbackService _feedbackService = locator(); List get cOCItemList => _feedbackService.cOCItemList; + MessageType messageType = MessageType.NON; + MessageType messageTypeDialog = MessageType.NON; + + String selected = "not selected"; + + setMessageDialogType(MessageType messageType) { + messageTypeDialog = messageType; + notifyListeners(); + } + + setMessageType(MessageType messageType) { + this.messageType = messageType; + switch (messageType) { + case MessageType.ComplaintOnAnAppointment: + selected = "Complaint on an appointment"; + break; + case MessageType.ComplaintWithoutAppointment: + selected = "Complaint without appointment"; + break; + case MessageType.Question: + selected = "Question"; + break; + case MessageType.Compliment: + selected = "Compliment"; + break; + case MessageType.Suggestion: + selected = "Suggestion"; + break; + case MessageType.NON: + break; + } + notifyListeners(); + } List get appointHistoryList => _feedbackService.appointHistoryList; @@ -30,9 +72,11 @@ class FeedbackViewModel extends BaseViewModel { if (_feedbackService.hasError) { error = _feedbackService.error; setState(ViewState.ErrorLocal); + setMessageType(MessageType.NON); return false; } else { setState(ViewState.Idle); + setMessageType(MessageType.NON); return true; } } @@ -48,7 +92,7 @@ class FeedbackViewModel extends BaseViewModel { } } - getPatentAppointmentHistory() async { + Future getPatentAppointmentHistory() async { setState(ViewState.Busy); await _feedbackService.getPatentAppointmentHistory(); if (_feedbackService.hasError) { diff --git a/lib/pages/feedback/send_feedback_page.dart b/lib/pages/feedback/send_feedback_page.dart index 436dae62..c5ec9757 100644 --- a/lib/pages/feedback/send_feedback_page.dart +++ b/lib/pages/feedback/send_feedback_page.dart @@ -10,22 +10,12 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'appointment_history.dart'; -enum MessageType { - ComplaintOnAnAppointment, - ComplaintWithoutAppointment, - Question, - Compliment, - Suggestion, - NON -} - class SendFeedbackPage extends StatefulWidget { @override _SendFeedbackPageState createState() => _SendFeedbackPageState(); @@ -34,8 +24,6 @@ class SendFeedbackPage extends StatefulWidget { class _SendFeedbackPageState extends State { TextEditingController titleController = TextEditingController(); TextEditingController messageController = TextEditingController(); - MessageType messageType = MessageType.NON; - String _selected = "not selected"; List images = []; String title; AppointmentHistory appointHistory; @@ -86,7 +74,7 @@ class _SendFeedbackPageState extends State { children: [ Container( child: Texts( - _selected, + model.selected, variant: 'bodyText', ), margin: EdgeInsets.only(left: 10), @@ -100,7 +88,8 @@ class _SendFeedbackPageState extends State { ), ), ), - if (appointHistory != null) + if (appointHistory != null && model.messageType == + MessageType.ComplaintOnAnAppointment) InkWell( onTap: () { setState(() { @@ -175,7 +164,8 @@ class _SendFeedbackPageState extends State { ), ), ), - if (messageType == MessageType.ComplaintOnAnAppointment && + if (model.messageType == + MessageType.ComplaintOnAnAppointment && model.appointHistoryList.length != 0 && isShowListAppointHistory) Container( @@ -403,14 +393,14 @@ class _SendFeedbackPageState extends State { loading: model.state == ViewState.BusyLocal, onTap: () { final form = formKey.currentState; - if (form.validate()) if (messageType != MessageType.NON) + if (form.validate()) if (model.messageType != MessageType.NON) model .sendCOCItem( title: titleController.text, attachment: images.length > 0 ? images[0] : "", details: messageController.text, - cOCTypeName: getCOCName(), - appointHistory: messageType == + cOCTypeName: getCOCName(model), + appointHistory: model.messageType == MessageType.ComplaintOnAnAppointment ? appointHistory : null) @@ -420,8 +410,8 @@ class _SendFeedbackPageState extends State { titleController.text = ""; messageController.text = ""; images = []; - messageType = MessageType.NON; }); + model.setMessageType(MessageType.NON); AppToast.showSuccessToast( message: "Your feedback was send"); } else { @@ -440,8 +430,8 @@ class _SendFeedbackPageState extends State { ); } - String getCOCName() { - switch (messageType) { + String getCOCName(FeedbackViewModel model) { + switch (model.messageType) { case MessageType.ComplaintOnAnAppointment: return "1"; break; @@ -469,292 +459,223 @@ class _SendFeedbackPageState extends State { showDialog( context: context, child: FeedbackTypeDialog( - onValueChange: (MessageType value) { + onValueSelected: (MessageType value) { if (value == MessageType.ComplaintOnAnAppointment) { - model.getPatentAppointmentHistory(); - setState(() { - appointHistory = null; + model.getPatentAppointmentHistory().then((value) { + setState(() { + appointHistory = null; + }); }); } - setState(() { - messageType = value; - }); - }, - initialValue: messageType, - onValueSelected: () { - setState(() { - switch (messageType) { - case MessageType.ComplaintOnAnAppointment: - _selected = "Complaint on an appointment"; - break; - case MessageType.ComplaintWithoutAppointment: - _selected = "Complaint without appointment"; - break; - case MessageType.Question: - _selected = "Question"; - break; - case MessageType.Compliment: - _selected = "Compliment"; - break; - case MessageType.Suggestion: - _selected = "Suggestion"; - break; - case MessageType.NON: - break; - } - }); - Navigator.pop(context); + model.setMessageType(value); }, )); } } class FeedbackTypeDialog extends StatefulWidget { - const FeedbackTypeDialog( - {this.onValueChange, this.initialValue, this.onValueSelected}); + final Function(MessageType) onValueSelected; - final MessageType initialValue; - final void Function(MessageType) onValueChange; - final GestureTapCallback onValueSelected; + const FeedbackTypeDialog({Key key, this.onValueSelected}) : super(key: key); @override State createState() => new FeedbackTypeDialogState(); } class FeedbackTypeDialogState extends State { - MessageType _messageType; - - @override - void initState() { - super.initState(); - _messageType = widget.initialValue; - } - Widget build(BuildContext context) { - return new SimpleDialog( - title: Text( - "Message Type", - textAlign: TextAlign.center, - ), - children: [ - Container( + return BaseView( + builder: (_, model, widge) => SimpleDialog( + title: Text( + "Message Type", + textAlign: TextAlign.center, + ), + children: [ + Container( // padding: const EdgeInsets.all(10.0), child: Column( - children: [ - Divider( - height: 2.5, - color: Colors.grey[500], - ), - Row( children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.ComplaintOnAnAppointment; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Complaint on an appointment'), - leading: Radio( - value: MessageType.ComplaintOnAnAppointment, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.ComplaintOnAnAppointment; - widget.onValueChange(_messageType); - }); - }, + Divider( + height: 2.5, + color: Colors.grey[500], + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => model.setMessageDialogType( + MessageType.ComplaintOnAnAppointment), + child: ListTile( + title: const Text('Complaint on an appointment'), + leading: Radio( + value: MessageType.ComplaintOnAnAppointment, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.ComplaintWithoutAppointment; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Complaint without appointment'), - leading: Radio( - value: MessageType.ComplaintWithoutAppointment, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = - MessageType.ComplaintWithoutAppointment; - widget.onValueChange(_messageType); - }); - }, + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => model.setMessageDialogType( + MessageType.ComplaintWithoutAppointment), + child: ListTile( + title: const Text('Complaint without appointment'), + leading: Radio( + value: MessageType.ComplaintWithoutAppointment, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.Question; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Question'), - leading: Radio( - value: MessageType.Question, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.Question; - widget.onValueChange(_messageType); - }); - }, + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => + model.setMessageDialogType(MessageType.Question), + child: ListTile( + title: const Text('Question'), + leading: Radio( + value: MessageType.Question, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.Compliment; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('compliment'), - leading: Radio( - value: MessageType.Compliment, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.Compliment; - widget.onValueChange(_messageType); - }); - }, + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => + model.setMessageDialogType(MessageType.Compliment), + child: ListTile( + title: const Text('compliment'), + leading: Radio( + value: MessageType.Compliment, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), ), - ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - setState(() { - _messageType = MessageType.Suggestion; - widget.onValueChange(_messageType); - }); - }, - child: ListTile( - title: const Text('Suggestion'), - leading: Radio( - value: MessageType.Suggestion, - groupValue: _messageType, - activeColor: Colors.red[800], - onChanged: (MessageType value) { - setState(() { - _messageType = MessageType.Suggestion; - widget.onValueChange(_messageType); - }); + ) + ], + ), + SizedBox( + height: 5.0, + ), + Row( + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => + model.setMessageDialogType(MessageType.Suggestion), + child: ListTile( + title: const Text('Suggestion'), + leading: Radio( + value: MessageType.Suggestion, + groupValue: model.messageTypeDialog, + activeColor: Colors.red[800], + onChanged: (MessageType value) => + model.setMessageDialogType(value), + ), + ), + ), + ) + ], + ), + SizedBox( + height: 5.0, + ), + Divider( + height: 2.5, + color: Colors.grey[500], + ), + SizedBox( + height: 5, + ), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () { + Navigator.pop(context); }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Center( + child: Texts( + 'cancel', + color: Colors.red, + ), + ), + ), + ), ), ), - ), - ) - ], - ), - SizedBox( - height: 5.0, - ), - Divider( - height: 2.5, - color: Colors.grey[500], - ), - SizedBox( - height: 5, - ), - Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - flex: 1, - child: InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Container( + Container( + width: 1, + height: 30, + color: Colors.grey[500], + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + widget.onValueSelected(model.messageTypeDialog); + Navigator.pop(context); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), child: Center( child: Texts( - 'cancel', - color: Colors.red, - ))), - ), - )), - Container( - width: 1, - height: 30, - color: Colors.grey[500], - ), - Expanded( - flex: 1, - child: InkWell( - onTap: widget.onValueSelected, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Center( - child: Texts( - 'ok', - fontWeight: FontWeight.w400, + 'ok', + fontWeight: FontWeight.w400, + )), + ), )), - ), - )), + ], + ) ], - ) - ], - )), - ], + ), + ), + ], + ), ); } } diff --git a/lib/pages/feedback/status_feedback_page.dart b/lib/pages/feedback/status_feedback_page.dart index 20ef4bed..01a2b4c9 100644 --- a/lib/pages/feedback/status_feedback_page.dart +++ b/lib/pages/feedback/status_feedback_page.dart @@ -43,27 +43,31 @@ class _StatusFeedbackPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts('${model.cOCItemList[index].cOCTitle}'), - Texts( - 'Number :${model.cOCItemList[index].itemID}', - variant: 'overline', - ), - ], + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts('${model.cOCItemList[index].cOCTitle}'), + Texts( + 'Number :${model.cOCItemList[index].itemID}', + variant: 'overline', + ), + ], + ), ), - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Texts('${model.cOCItemList[index].status}'), - Texts( - '${model.cOCItemList[index].date}', - variant: 'overline', - ), - ], + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Texts('${model.cOCItemList[index].status}'), + Texts( + '${model.cOCItemList[index].date}', + variant: 'overline', + ), + ], + ), ), ], ), diff --git a/lib/widgets/data_display/medical/time_line_widget.dart b/lib/widgets/data_display/medical/time_line_widget.dart new file mode 100644 index 00000000..eb6f1146 --- /dev/null +++ b/lib/widgets/data_display/medical/time_line_widget.dart @@ -0,0 +1,34 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class TimeLineWidget extends StatefulWidget { + final bool isUp; + + TimeLineWidget({Key key, this.isUp}); + + _TimeLineWidgetState createState() => _TimeLineWidgetState(); +} + +class _TimeLineWidgetState extends State { + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Container( + width: double.infinity, + height: 150, + color: Colors.grey[400], + child: Center( + child: Divider( + color: Colors.white, + height: 5, + thickness: 5, + ), + ), + ), + if (widget.isUp) Container() else Container(), + Container() + ], + ); + } +} From 75fdf280366ece36650e6a017d31e2dc2a82d3df Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Sun, 23 Aug 2020 15:13:03 +0300 Subject: [PATCH 3/5] fix lab Result --- lib/core/service/client/base_app_client.dart | 2 +- lib/pages/medical/medical_profile_page.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 19bb01eb..8e139aa1 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -24,7 +24,7 @@ class BaseAppClient { try { //Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); - var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); var user = await sharedPref.getObject(USER_PROFILE); body['SetupID'] = body.containsKey('SetupID') ? body['SetupID']!=null? body['SetupID'] :SETUP_ID :SETUP_ID; body['VersionID'] = body.containsKey('VersionID') ? body['VersionID']!=null? body['VersionID'] :VERSION_ID :VERSION_ID; diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 08e5ba6b..3fb0d9bf 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -86,7 +86,7 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap: () {}, + onTap: () => Navigator.push(context, FadePage(page: LabsHomePage())), child: MedicalProfileItem( title: 'Lab', imagePath: 'lab_result_icon.png', From f6d30178bfe75c7ef41b8885746681876e64746f Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 24 Aug 2020 10:37:36 +0300 Subject: [PATCH 4/5] done medical report --- lib/config/config.dart | 1 + lib/core/model/reports/Reports.dart | 76 ++++--- .../model/reports/request_report_history.dart | 76 +++++++ lib/core/service/medical/reports_service.dart | 113 ++++++---- .../medical/prescriptions_view_model.dart | 2 +- .../medical/reports_view_model.dart | 143 +++++------- lib/pages/feedback/appointment_history.dart | 4 +- lib/pages/medical/medical_profile_page.dart | 8 +- .../medical/reports/report_home_page.dart | 65 ++++-- .../medical/reports/report_list_widget.dart | 64 ++++++ lib/pages/medical/reports/reports_page.dart | 212 +++++++++++++++++- 11 files changed, 550 insertions(+), 214 deletions(-) create mode 100644 lib/core/model/reports/request_report_history.dart create mode 100644 lib/pages/medical/reports/report_list_widget.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 257a4684..b3e12498 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -47,6 +47,7 @@ const GET_PATIENT_VITAL_SIGN = '/Doctors.svc/REST/Doctor_GetPatientVitalSign'; ///Reports const REPORTS = '/Doctors.svc/REST/GetPatientMedicalReportStatusInfo'; +const INSERT_REQUEST_FOR_MEDICAL_REPORT = '/Doctors.svc/REST/InsertRequestForMedicalReport'; //const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment diff --git a/lib/core/model/reports/Reports.dart b/lib/core/model/reports/Reports.dart index eb09c0c5..a8a5869d 100644 --- a/lib/core/model/reports/Reports.dart +++ b/lib/core/model/reports/Reports.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; + class Reports { int status; DateTime encounterDate; @@ -31,37 +32,38 @@ class Reports { Reports( {this.status, - this.encounterDate, - this.projectID, - this.invoiceNo, - this.encounterNo, - this.procedureId, - this.requestType, - this.setupId, - this.patientID, - this.doctorID, - this.clinicID, - this.requestDate, - this.isRead, - this.isReadOn, - this.actualDoctorRate, - this.clinicDescription, - this.clinicDescriptionN, - this.docName, - this.docNameN, - this.doctorImageURL, - this.doctorName, - this.doctorNameN, - this.doctorRate, - this.isDoctorAllowVedioCall, - this.isExecludeDoctor, - this.noOfPatientsRate, - this.projectName, - this.projectNameN}); + this.encounterDate, + this.projectID, + this.invoiceNo, + this.encounterNo, + this.procedureId, + this.requestType, + this.setupId, + this.patientID, + this.doctorID, + this.clinicID, + this.requestDate, + this.isRead, + this.isReadOn, + this.actualDoctorRate, + this.clinicDescription, + this.clinicDescriptionN, + this.docName, + this.docNameN, + this.doctorImageURL, + this.doctorName, + this.doctorNameN, + this.doctorRate, + this.isDoctorAllowVedioCall, + this.isExecludeDoctor, + this.noOfPatientsRate, + this.projectName, + this.projectNameN}); Reports.fromJson(Map json) { status = json['Status']; - encounterDate = DateUtil.convertStringToDate(json['EncounterDate']);//json['EncounterDate']; + encounterDate = DateUtil.convertStringToDate( + json['EncounterDate']); //json['EncounterDate']; projectID = json['ProjectID']; invoiceNo = json['InvoiceNo']; encounterNo = json['EncounterNo']; @@ -71,9 +73,11 @@ class Reports { patientID = json['PatientID']; doctorID = json['DoctorID']; clinicID = json['ClinicID']; - requestDate = DateUtil.convertStringToDate(json['RequestDate']);//json['RequestDate']; + requestDate = DateUtil.convertStringToDate( + json['RequestDate']); //json['RequestDate']; isRead = json['IsRead']; - isReadOn =DateUtil.convertStringToDate(json['IsReadOn']); //json['IsReadOn']; + isReadOn = + DateUtil.convertStringToDate(json['IsReadOn']); //json['IsReadOn']; actualDoctorRate = json['ActualDoctorRate']; clinicDescription = json['ClinicDescription']; clinicDescriptionN = json['ClinicDescriptionN']; @@ -124,14 +128,12 @@ class Reports { } } +class ReportsList { + String filterName = ""; + + List reportsList = List(); -class ReportsList{ - String filterName=""; - // int filterName=1; - ListreportsList=List(); - ReportsList({this.filterName,Reports reports}){ + ReportsList({this.filterName, Reports reports}) { reportsList.add(reports); } - - } diff --git a/lib/core/model/reports/request_report_history.dart b/lib/core/model/reports/request_report_history.dart new file mode 100644 index 00000000..f7d02cc5 --- /dev/null +++ b/lib/core/model/reports/request_report_history.dart @@ -0,0 +1,76 @@ +class RequestReportHistory { + int projectID; + int clinicID; + bool isForMedicalReport; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int patientID; + String tokenID; + int patientTypeID; + int patientType; + + RequestReportHistory( + {this.projectID, + this.clinicID, + this.isForMedicalReport, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.patientID, + this.tokenID, + this.patientTypeID, + this.patientType}); + + RequestReportHistory.fromJson(Map json) { + projectID = json['ProjectID']; + clinicID = json['ClinicID']; + isForMedicalReport = json['IsForMedicalReport']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + patientID = json['PatientID']; + tokenID = json['TokenID']; + patientTypeID = json['PatientTypeID']; + patientType = json['PatientType']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['ClinicID'] = this.clinicID; + data['IsForMedicalReport'] = this.isForMedicalReport; + data['VersionID'] = this.versionID; + 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; + data['PatientID'] = this.patientID; + data['TokenID'] = this.tokenID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientType'] = this.patientType; + return data; + } +} diff --git a/lib/core/service/medical/reports_service.dart b/lib/core/service/medical/reports_service.dart index 6e965e33..b8e5f426 100644 --- a/lib/core/service/medical/reports_service.dart +++ b/lib/core/service/medical/reports_service.dart @@ -2,21 +2,20 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/reports/Reports.dart'; import 'package:diplomaticquarterapp/core/model/reports/request_reports.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; +import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart'; - - -class ReportsService extends BaseService{ - +class ReportsService extends BaseService { List reportsList = List(); + List appointHistoryList = List(); - RequestReports _requestReports=RequestReports( - isReport: true, - encounterType: 1, - requestType: 1, - versionID: 5.5, - channel: 3, - languageID: 2, - iPAdress: "10.20.10.20", + RequestReports _requestReports = RequestReports( + isReport: true, + encounterType: 1, + requestType: 1, + versionID: 5.5, + channel: 3, + languageID: 2, + iPAdress: "10.20.10.20", generalid: 'Cs2020@2016\$2958', patientOutSA: 0, sessionID: 'KIbLoqkytuKJEWECHQ', @@ -25,42 +24,60 @@ class ReportsService extends BaseService{ patientID: 1231755, tokenID: '@dm!n', patientTypeID: 1, - patientType: 1 - - - ); - Future getReports() async { - hasError = false; - await baseAppClient.post(REPORTS, - onSuccess: (dynamic response, int statusCode) - { - reportsList.clear(); - - response['GetPatientMedicalStatus'].forEach((reports) { - reportsList.add(Reports.fromJson(reports)); - }); - },onFailure: (String error,int statusCode){ - hasError = true; - super.error = error; - },body: _requestReports.toJson()); - - } - - + patientType: 1); + Future getReports() async { + hasError = false; + await baseAppClient.post(REPORTS, + onSuccess: (dynamic response, int statusCode) { + reportsList.clear(); + response['GetPatientMedicalStatus'].forEach((reports) { + reportsList.add(Reports.fromJson(reports)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestReports.toJson()); + } -// Future getPrescriptions() async { -// hasError = false; -// await baseAppClient.post(PRESCRIPTIONS, -// onSuccess: (dynamic response, int statusCode) { -// prescriptionsList.clear(); -// response['PatientPrescriptionList'].forEach((prescriptions) { -// prescriptionsList.add(Prescriptions.fromJson(prescriptions)); -// }); -// }, onFailure: (String error, int statusCode) { -// hasError = true; -// super.error = error; -// }, body: _requestPrescriptions.toJson()); -// } + Future getPatentAppointmentHistory() async { + hasError = false; + Map body = new Map(); + body['IsForMedicalReport'] = true; + await baseAppClient.post(GET_PATIENT_AppointmentHistory, + onSuccess: (dynamic response, int statusCode) { + appointHistoryList = []; + response['AppoimentAllHistoryResultList'].forEach((appoint) { + appointHistoryList.add(AppointmentHistory.fromJson(appoint)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } -} \ No newline at end of file + Future insertRequestForMedicalReport( + AppointmentHistory appointmentHistory) async { + Map body = new Map(); + body['ClinicID'] = appointmentHistory.clinicID; + body['DoctorID'] = appointmentHistory.doctorID; + body['SetupID'] = appointmentHistory.setupID; + body['EncounterNo'] = appointmentHistory.appointmentNo; + body['EncounterType'] = 1;// appointmentHistory.appointmentType; + body['IsActive'] = appointmentHistory.isActiveDoctor; + body['ProjectID'] = appointmentHistory.projectID; + body['Remarks'] = ""; + body['ProcedureId'] = ""; + body['RequestType'] = 1; + body['Source'] = 2; + body['Status'] = 1; + body['CreatedBy'] = 102; + hasError = false; + await baseAppClient.post(INSERT_REQUEST_FOR_MEDICAL_REPORT, + onSuccess: (dynamic response, int statusCode) {}, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } +} diff --git a/lib/core/viewModels/medical/prescriptions_view_model.dart b/lib/core/viewModels/medical/prescriptions_view_model.dart index f67df015..27b954d4 100644 --- a/lib/core/viewModels/medical/prescriptions_view_model.dart +++ b/lib/core/viewModels/medical/prescriptions_view_model.dart @@ -125,7 +125,7 @@ class PrescriptionsViewModel extends BaseViewModel { if (_prescriptionsService.hasError) { error = _prescriptionsService.error; setState(ViewState.ErrorLocal); - AppToast.showSuccessToast(message: error); + AppToast.showErrorToast(message: error); } else { AppToast.showSuccessToast(message: 'A copy has been sent to the e-mail'); setState(ViewState.Idle); diff --git a/lib/core/viewModels/medical/reports_view_model.dart b/lib/core/viewModels/medical/reports_view_model.dart index e0a4d8fb..e0fdfaa3 100644 --- a/lib/core/viewModels/medical/reports_view_model.dart +++ b/lib/core/viewModels/medical/reports_view_model.dart @@ -1,15 +1,10 @@ -//import 'package:diplomaticquarterapp/core/model/prescriptions/prescription_report.dart'; - +import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import '../../../core/enum/reportfilter_type.dart'; import '../../../core/enum/viewstate.dart'; -//import '../../../core/model/prescriptions/Prescriptions.dart'; import '../../../core/model/reports/Reports.dart'; - -//import '../../../core/service/medical/prescriptions_service.dart'; import '../../../core/service/medical/reports_service.dart'; - import '../../../locator.dart'; import '../base_view_model.dart'; @@ -18,35 +13,20 @@ class ReportsViewModel extends BaseViewModel { ReportsService _reportsService = locator(); - List _reportsOrderRequestList = List(); - List _reportsOrderReadyList = List(); - List _reportsOrderCompletedList = List(); - List _reportsOrderCanceledList = List(); - - List get reportsList => _reportsService.reportsList; + List reportsOrderRequestList = List(); + List reportsOrderReadyList = List(); + List reportsOrderCompletedList = List(); + List reportsOrderCanceledList = List(); - ///// - List get reportsOrderList { - switch (filterType) { - case ReportFilterType.Requested: - return _reportsOrderRequestList; - break; - - case ReportFilterType.Ready: - return _reportsOrderReadyList; - break; - - case ReportFilterType.Completed: - return _reportsOrderCompletedList; - break; - - default: - return _reportsOrderCanceledList; - } - } + List get appointHistoryList => + _reportsService.appointHistoryList; getReports() async { setState(ViewState.Busy); + reportsOrderRequestList.clear(); + reportsOrderReadyList.clear(); + reportsOrderCompletedList.clear(); + reportsOrderCanceledList.clear(); await _reportsService.getReports(); if (_reportsService.hasError) { error = _reportsService.error; @@ -57,71 +37,48 @@ class ReportsViewModel extends BaseViewModel { } } -//////////////////////// - void _filterList() { - _reportsService.reportsList.forEach((element) { - /// ReportsList list sort Request - List reportsByRequest = _reportsOrderRequestList - .where((elementStatus) => elementStatus.filterName == element.status) - .toList(); - - if (reportsByRequest.length != 0) { - _reportsOrderRequestList[ - _reportsOrderRequestList.indexOf(reportsByRequest[0])] - .reportsList - .add(element); - } else { - _reportsOrderRequestList.add(ReportsList( - filterName: element.clinicDescription, reports: element)); - } - //////// - /// ReportsList list sort Ready - List reportsByReady = _reportsOrderReadyList - .where((elementStatus) => elementStatus.filterName == element.status) - .toList(); - - if (reportsByReady.length != 0) { - _reportsOrderReadyList[ - _reportsOrderReadyList.indexOf(reportsByReady[0])] - .reportsList - .add(element); - } else { - _reportsOrderReadyList.add(ReportsList( - filterName: element.clinicDescription, reports: element)); - } - - /// ReportsList list sort Compleated - List reportsByCompleated = _reportsOrderCompletedList - .where((elementStatus) => elementStatus.filterName == element.status) - .toList(); - - if (reportsByCompleated.length != 0) { - _reportsOrderCompletedList[ - _reportsOrderCompletedList.indexOf(reportsByCompleated[0])] - .reportsList - .add(element); - } else { - _reportsOrderCompletedList.add(ReportsList( - filterName: element.clinicDescription, reports: element)); - } - /// ReportsList list sort Cancelled - List reportsByCancelled = _reportsOrderCanceledList - .where((elementStatus) => elementStatus.filterName == element.status) - .toList(); + getPatentAppointmentHistory() async { + setState(ViewState.Busy); + await _reportsService.getPatentAppointmentHistory(); + if (_reportsService.hasError) { + error = _reportsService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } - if (reportsByCancelled.length != 0) { - _reportsOrderCanceledList[ - _reportsOrderCanceledList.indexOf(reportsByCompleated[0])] - .reportsList - .add(element); - } else { - _reportsOrderCanceledList.add(ReportsList( - filterName: element.clinicDescription, reports: element)); + void _filterList() { + _reportsService.reportsList.forEach((report) { + switch (report.status) { + case 1: + reportsOrderRequestList.add(report); + break; + case 2: + reportsOrderReadyList.add(report); + break; + case 3: + reportsOrderCompletedList.add(report); + break; + case 4: + reportsOrderCanceledList.add(report); + break; + default: } - //**************************** }); - } -/////////////////////// + + insertRequestForMedicalReport(AppointmentHistory appointmentHistory)async{ + setState(ViewState.Busy); + await _reportsService.insertRequestForMedicalReport(appointmentHistory); + if (_reportsService.hasError) { + error = _reportsService.error; + AppToast.showErrorToast(message: error); + setState(ViewState.ErrorLocal); + } else { + AppToast.showSuccessToast(message: 'The order was send '); + setState(ViewState.Idle); + } + } } diff --git a/lib/pages/feedback/appointment_history.dart b/lib/pages/feedback/appointment_history.dart index cfbd5800..a1dcdd33 100644 --- a/lib/pages/feedback/appointment_history.dart +++ b/lib/pages/feedback/appointment_history.dart @@ -25,7 +25,7 @@ class AppointmentHistory { int confirmedBy; String confirmedOn; int arrivalChangedBy; - String arrivedOn; + DateTime arrivedOn; Null editedBy; Null editedOn; Null doctorName; @@ -159,7 +159,7 @@ class AppointmentHistory { confirmedBy = json['ConfirmedBy']; confirmedOn = json['ConfirmedOn']; arrivalChangedBy = json['ArrivalChangedBy']; - arrivedOn = json['ArrivedOn']; + arrivedOn = DateUtil.convertStringToDate(json['ArrivedOn']); editedBy = json['EditedBy']; editedOn = json['EditedOn']; doctorName = json['DoctorName']; diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 152780d4..26fe9a89 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -249,10 +249,10 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( -// onTap: () { -// Navigator.push( -// context, FadePage(page: InsuranceApproval())); -// }, + onTap: () { + Navigator.push( + context, FadePage(page: HomeReportPage())); + }, child: MedicalProfileItem( title: 'Medical', imagePath: 'insurance_approvals_icon.png', diff --git a/lib/pages/medical/reports/report_home_page.dart b/lib/pages/medical/reports/report_home_page.dart index 10f75b67..8f24d1dd 100644 --- a/lib/pages/medical/reports/report_home_page.dart +++ b/lib/pages/medical/reports/report_home_page.dart @@ -1,22 +1,22 @@ import 'dart:ui'; -import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/reports_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_history.dart'; -import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_page.dart'; - +import 'package:diplomaticquarterapp/pages/medical/reports/report_list_widget.dart'; +import 'package:diplomaticquarterapp/pages/medical/reports/reports_page.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -class HomeRepoertsPage extends StatefulWidget { +class HomeReportPage extends StatefulWidget { @override - _HomeRepoertsPageState createState() => _HomeRepoertsPageState(); + _HomeReportPageState createState() => _HomeReportPageState(); } -class _HomeRepoertsPageState extends State +class _HomeReportPageState extends State with SingleTickerProviderStateMixin { TabController _tabController; @@ -32,15 +32,16 @@ class _HomeRepoertsPageState extends State _tabController.dispose(); } - @override Widget build(BuildContext context) { return BaseView( - onModelReady: (model) =>model.getReports(), //model.getPrescriptions(), + onModelReady: (model) => model.getReports(), //model.getPrescriptions(), builder: (_, model, widget) => AppScaffold( isShowAppBar: true, appBarTitle: 'Request', + baseViewModel: model, //bottomSheet: Container(), + body: Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( @@ -81,30 +82,28 @@ class _HomeRepoertsPageState extends State indicatorSize: TabBarIndicatorSize.label, indicatorColor: Colors.red[800], labelColor: Theme.of(context).primaryColor, - labelPadding: - EdgeInsets.only(top: 4.0, left: 18.0, right: 18.0), unselectedLabelColor: Colors.grey[800], tabs: [ Container( - width: MediaQuery.of(context).size.width * 0.30, + width: MediaQuery.of(context).size.width * 0.22, child: Center( child: Texts('Requested'), ), ), Container( - width: MediaQuery.of(context).size.width * 0.30, + width: MediaQuery.of(context).size.width * 0.22, child: Center( child: Texts('Ready'), ), ), Container( - width: MediaQuery.of(context).size.width * 0.30, + width: MediaQuery.of(context).size.width * 0.22, child: Center( child: Texts('Completed'), ), ), Container( - width: MediaQuery.of(context).size.width * 0.30, + width: MediaQuery.of(context).size.width * 0.22, child: Center( child: Texts('Cancelled'), ), @@ -124,17 +123,39 @@ class _HomeRepoertsPageState extends State physics: BouncingScrollPhysics(), controller: _tabController, children: [ -// PrescriptionsPage(prescriptionsViewModel: model,), -// PrescriptionsHistory() - Icon(Icons.directions_car), - Icon(Icons.directions_transit), - Icon(Icons.directions_bike), - Icon(Icons.directions_bike), + ReportListWidget( + reportList: model.reportsOrderRequestList, + ), + ReportListWidget( + reportList: model.reportsOrderReadyList, + ), + ReportListWidget( + reportList: model.reportsOrderCompletedList, + ), + ReportListWidget( + reportList: model.reportsOrderCanceledList, + ), ], ), - ) + ), + SizedBox(height: 110,) ], ), + bottomSheet: Container( + width: double.infinity, + height: 90, + margin: EdgeInsets.all(8.0), + child: Button( + label: 'Resend order & deliver', + backgroundColor: Colors.grey[800], + onTap: () => Navigator.push( + context, + FadePage( + page: MedicalReports(), + ), + ), + ), + ), ), ), ); diff --git a/lib/pages/medical/reports/report_list_widget.dart b/lib/pages/medical/reports/report_list_widget.dart new file mode 100644 index 00000000..6408074a --- /dev/null +++ b/lib/pages/medical/reports/report_list_widget.dart @@ -0,0 +1,64 @@ +import 'package:diplomaticquarterapp/core/model/reports/Reports.dart'; +import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class ReportListWidget extends StatelessWidget { + final List reportList; + + ReportListWidget({@required this.reportList}); + + @override + Widget build(BuildContext context) { + return Container( + child: ListView.builder( + itemBuilder: (context, index) => Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + width: double.infinity,margin: EdgeInsets.only(left: 8,right: 8,top: 3), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.white, width: 2), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all( + Radius.circular(8.0), + )), + child: Row( + children: [ + Expanded( + flex: 1, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: LargeAvatar( + name: reportList[index].doctorName, + url: reportList[index].doctorImageURL, + ), + ), + ), + Expanded( + flex: 4, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 12,), + Texts(reportList[index].projectName), + Texts(reportList[index].clinicDescription), + Texts('invoice No: ${reportList[index].invoiceNo}'), + SizedBox(height: 12,), + + ], + ), + ), + ) + ], + ), + ), + ), + itemCount: reportList.length, + ), + ); + } +} diff --git a/lib/pages/medical/reports/reports_page.dart b/lib/pages/medical/reports/reports_page.dart index bb89a9df..5b64bc4e 100644 --- a/lib/pages/medical/reports/reports_page.dart +++ b/lib/pages/medical/reports/reports_page.dart @@ -1,10 +1,208 @@ -import 'package:diplomaticquarterapp/core/enum/filter_type.dart'; -import 'package:diplomaticquarterapp/core/viewModels/medical/prescriptions_view_model.dart'; -import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescription_items_page.dart'; +import 'package:diplomaticquarterapp/core/viewModels/medical/reports_view_model.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/feedback/appointment_history.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; +import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; \ No newline at end of file +import 'package:flutter/material.dart'; + +class MedicalReports extends StatelessWidget { + @override + Widget build(BuildContext context) { + void confirmBox( + AppointmentHistory model, ReportsViewModel reportsViewModel) { + showDialog( + context: context, + child: ConfirmDialog( + appointmentHistory: model, + onOkSelected: (model) => reportsViewModel.insertRequestForMedicalReport(model), + ), + ); + } + + return BaseView( + onModelReady: (model) => model.getPatentAppointmentHistory(), + builder: (_, model, widget) => AppScaffold( + baseViewModel: model, + isShowAppBar: true, + appBarTitle: 'Medical Reports', + body: ListView.builder( + itemCount: model.appointHistoryList.length, + itemBuilder: (context, index) => Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + width: double.infinity, + margin: EdgeInsets.only(left: 8, right: 8, top: 3), + decoration: BoxDecoration( + color: Colors.white, + border: Border.all(color: Colors.white, width: 2), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all( + Radius.circular(8.0), + )), + child: Row( + children: [ + Expanded( + flex: 1, + child: Container( + margin: EdgeInsets.only(left: 5, right: 5), + child: LargeAvatar( + width: 50, + height: 50, + name: model.appointHistoryList[index].doctorNameObj, + url: model.appointHistoryList[index].doctorImageURL, + ), + ), + ), + Expanded( + flex: 4, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 12, + ), + Texts(model.appointHistoryList[index].projectName), + Texts(model.appointHistoryList[index].clinicName), + Texts(DateUtil.getMonthDayYearDateFormatted( + model.appointHistoryList[index].appointmentDate)), + StarRating( + totalAverage: model + .appointHistoryList[index].actualDoctorRate + .toDouble(), + forceStars: true), + SizedBox( + height: 12, + ), + ], + ), + ), + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () => + confirmBox(model.appointHistoryList[index], model), + child: Container( + width: 80, + height: 50, + decoration: BoxDecoration( + color: Colors.black54, + border: + Border.all(color: Colors.transparent, width: 2), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all( + Radius.circular(8.0), + ), + ), + child: Center( + child: Texts( + 'Request', + fontSize: 12, + color: Colors.white, + ), + ), + ), + ), + ), + SizedBox( + width: 12, + ), + ], + ), + ), + ), + ), + ), + ); + } +} + +class ConfirmDialog extends StatefulWidget { + final Function(AppointmentHistory) onOkSelected; + final AppointmentHistory appointmentHistory; + + ConfirmDialog({this.onOkSelected, this.appointmentHistory}); + + @override + _ConfirmDialogState createState() => _ConfirmDialogState(); +} + +class _ConfirmDialogState extends State { + @override + Widget build(BuildContext context) { + return SimpleDialog( + title: Text('Confirm'), + children: [ + Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Texts('Request a medical report'), + SizedBox( + height: 5.0, + ), + Divider( + height: 2.5, + color: Colors.grey[500], + ), + SizedBox( + height: 5, + ), + Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 1, + child: InkWell( + onTap: () => Navigator.pop(context), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Container( + child: Center( + child: Texts( + 'cancel', + color: Colors.red, + ), + ), + ), + ), + ), + ), + Container( + width: 1, + height: 30, + color: Colors.grey[500], + ), + Expanded( + flex: 1, + child: InkWell( + onTap: () { + widget.onOkSelected(widget.appointmentHistory); + Navigator.pop(context); + }, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Center( + child: Texts( + 'ok', + fontWeight: FontWeight.w400, + ), + ), + ), + ), + ), + ], + ) + ], + ), + ) + ], + ); + } +} From f5b16734c6740ae93d0118f1222e14675c142aea Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 24 Aug 2020 17:22:27 +0300 Subject: [PATCH 5/5] add time line --- .../medical/medical_view_model.dart | 10 +- lib/pages/medical/medical_profile_page.dart | 36 +++-- .../medical/time_line_widget.dart | 143 ++++++++++++++++-- 3 files changed, 162 insertions(+), 27 deletions(-) diff --git a/lib/core/viewModels/medical/medical_view_model.dart b/lib/core/viewModels/medical/medical_view_model.dart index b5db9d80..59e8db48 100644 --- a/lib/core/viewModels/medical/medical_view_model.dart +++ b/lib/core/viewModels/medical/medical_view_model.dart @@ -5,14 +5,14 @@ import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; class MedicalViewModel extends BaseViewModel { - List get appoitmentAllHistoryResultList => - List(); - MedicalService _medicalService = locator(); - getAppointmentHistory() { + List get appoitmentAllHistoryResultList => + _medicalService.appoitmentAllHistoryResultList; + + getAppointmentHistory() async{ setState(ViewState.Busy); - _medicalService.getAppointmentHistory(); + await _medicalService.getAppointmentHistory(); if (_medicalService.hasError) { error = _medicalService.error; setState(ViewState.Error); diff --git a/lib/pages/medical/medical_profile_page.dart b/lib/pages/medical/medical_profile_page.dart index 26fe9a89..1e6a3b61 100644 --- a/lib/pages/medical/medical_profile_page.dart +++ b/lib/pages/medical/medical_profile_page.dart @@ -9,6 +9,7 @@ import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_home_page import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_details_screen.dart'; import 'package:diplomaticquarterapp/pages/medical/reports/report_home_page.dart'; import 'package:diplomaticquarterapp/widgets/data_display/medical/medical_profile_item.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/medical/time_line_widget.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/others/sliver_app_bar_delegate.dart'; @@ -28,7 +29,6 @@ class MedicalProfilePage extends StatefulWidget { } class _MedicalProfilePageState extends State { - @override Widget build(BuildContext context) { return BaseView( @@ -46,7 +46,18 @@ class _MedicalProfilePageState extends State { Container( width: double.infinity, color: Colors.grey, - height: 150, + height: 210, + child: ListView.builder( + itemBuilder: (context, index) => TimeLineWidget( + isUp: index % 2 == 1, + appoitmentAllHistoryResul: + model.appoitmentAllHistoryResultList[index], + ), + itemCount: + model.appoitmentAllHistoryResultList.length, + scrollDirection: Axis.horizontal, + reverse: true, + ), ), Padding( padding: EdgeInsets.symmetric(vertical: 12.0), @@ -87,7 +98,8 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap: () => Navigator.push(context, FadePage(page: LabsHomePage())), + onTap: () => Navigator.push(context, + FadePage(page: LabsHomePage())), child: MedicalProfileItem( title: 'Lab', imagePath: 'lab_result_icon.png', @@ -249,10 +261,10 @@ class _MedicalProfilePageState extends State { Expanded( flex: 1, child: InkWell( - onTap: () { - Navigator.push( - context, FadePage(page: HomeReportPage())); - }, + onTap: () { + Navigator.push(context, + FadePage(page: HomeReportPage())); + }, child: MedicalProfileItem( title: 'Medical', imagePath: 'insurance_approvals_icon.png', @@ -393,7 +405,7 @@ class _MedicalProfilePageState extends State { ), if (model.user != null) Positioned( - top: 110, + top: 175, left: 20, right: 20, child: Container( @@ -404,7 +416,7 @@ class _MedicalProfilePageState extends State { shape: BoxShape.rectangle, border: Border.all( color: Colors.transparent, width: 0.5), - borderRadius: BorderRadius.all(Radius.circular(5)), + borderRadius: BorderRadius.all(Radius.circular(9)), ), child: Column( crossAxisAlignment: CrossAxisAlignment.center, @@ -428,7 +440,11 @@ class _MedicalProfilePageState extends State { ], ), ), - ) + ), + + Positioned(top: 10,left: 10, + child: Texts('Time Line ',color: Colors.white,fontSize: 14,fontWeight: FontWeight.normal,), + ) ], ), ], diff --git a/lib/widgets/data_display/medical/time_line_widget.dart b/lib/widgets/data_display/medical/time_line_widget.dart index eb6f1146..18887bd2 100644 --- a/lib/widgets/data_display/medical/time_line_widget.dart +++ b/lib/widgets/data_display/medical/time_line_widget.dart @@ -1,32 +1,151 @@ +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/pages/MyAppointments/AppointmentDetails.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -class TimeLineWidget extends StatefulWidget { +class TimeLineWidget extends StatelessWidget { final bool isUp; + final AppoitmentAllHistoryResultList appoitmentAllHistoryResul; - TimeLineWidget({Key key, this.isUp}); + TimeLineWidget({Key key, this.isUp, this.appoitmentAllHistoryResul}); - _TimeLineWidgetState createState() => _TimeLineWidgetState(); -} - -class _TimeLineWidgetState extends State { @override Widget build(BuildContext context) { return Stack( children: [ Container( - width: double.infinity, - height: 150, - color: Colors.grey[400], + width: 140, + height: 190, + color: Colors.grey, child: Center( child: Divider( color: Colors.white, - height: 5, - thickness: 5, + height: 3, + thickness: 3, ), ), ), - if (widget.isUp) Container() else Container(), + if (isUp) + Positioned( + top: 20, + child: Container( + margin: EdgeInsets.only(left: 2, right: 2), + child: Column( + children: [ + Texts( + appoitmentAllHistoryResul.doctorNameObj, + color: Colors.white, + fontSize: 10.5, + fontWeight: FontWeight.normal, + ), + SizedBox( + height: 3, + ), + LargeAvatar( + onTap: () { + //AppointmentDetails + Navigator.push(context, + FadePage(page: AppointmentDetails(appo: appoitmentAllHistoryResul,))); + }, + name: appoitmentAllHistoryResul.doctorNameObj, + url: appoitmentAllHistoryResul.doctorImageURL, + width: 30, + height: 30, + ), + Container( + height: 20, + width: 3, + color: Colors.white, + ), + Container( + width: 15, + height: 15, + decoration: BoxDecoration( + color: Colors.yellow[700], + border: Border.all(color: Colors.yellow[700], width: 2), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all( + Radius.circular(25.0), + ), + ), + ), + SizedBox( + height: 4, + ), + Texts( + DateUtil.getMonthDayYearDateFormatted( + DateUtil.convertStringToDate( + appoitmentAllHistoryResul.appointmentDate)), + color: Colors.white, + fontSize: 10.5, + fontWeight: FontWeight.normal, + ) + ], + ), + ), + ) + else + Positioned( + top: 70, + child: Container( + margin: EdgeInsets.only(left: 2, right: 2), + child: Column( + children: [ + Texts( + DateUtil.getMonthDayYearDateFormatted( + DateUtil.convertStringToDate( + appoitmentAllHistoryResul.appointmentDate)), + color: Colors.white, + fontSize: 10.5, + fontWeight: FontWeight.normal, + ), + SizedBox( + height: 5, + ), + Container( + width: 15, + height: 15, + decoration: BoxDecoration( + color: Colors.yellow[700], + border: Border.all(color: Colors.yellow[700], width: 2), + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all( + Radius.circular(25.0), + ), + ), + ), + Container( + height: 20, + width: 3, + color: Colors.white, + ), + LargeAvatar( + onTap: (){ + Navigator.push(context, + FadePage(page: AppointmentDetails(appo: appoitmentAllHistoryResul,))); + }, + name: appoitmentAllHistoryResul.doctorNameObj, + url: appoitmentAllHistoryResul.doctorImageURL, + width: 30, + height: 30, + ), + SizedBox( + height: 3, + ), + Texts( + appoitmentAllHistoryResul.doctorNameObj, + color: Colors.white, + fontSize: 10.5, + fontWeight: FontWeight.normal, + ), + ], + ), + ), + ), Container() ], );