From 76f8eba86e7da798212ddf408fb4bdea883c4a7f Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Tue, 9 Jun 2020 10:24:22 +0300 Subject: [PATCH] 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,