From 3c3d85c255e330d9d7b4583b211af1a251a2e23e Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Tue, 2 Jun 2020 09:48:03 +0300 Subject: [PATCH] My Referred Patient --- lib/models/my_referred_patient_model.dart | 224 +++++++++++ lib/providers/referred_patient_provider.dart | 77 ++++ lib/screens/dashboard_screen.dart | 35 +- .../doctor/my_referred_patient_screen.dart | 67 ++++ .../doctor/my_referred_patient_widget.dart | 360 ++++++++++++++++++ 5 files changed, 760 insertions(+), 3 deletions(-) create mode 100644 lib/models/my_referred_patient_model.dart create mode 100644 lib/providers/referred_patient_provider.dart create mode 100644 lib/screens/doctor/my_referred_patient_screen.dart create mode 100644 lib/widgets/doctor/my_referred_patient_widget.dart diff --git a/lib/models/my_referred_patient_model.dart b/lib/models/my_referred_patient_model.dart new file mode 100644 index 00000000..4aaef077 --- /dev/null +++ b/lib/models/my_referred_patient_model.dart @@ -0,0 +1,224 @@ +/* + *@author: Amjad amireh + *@Date:1/6/2020 + *@param: + *@return: + *@desc: MyReferredPatientModel + */ + +import 'dart:convert'; +import 'package:doctor_app_flutter/util/helpers.dart'; + + +import 'package:doctor_app_flutter/util/helpers.dart'; + +class MyReferredPatientModel { + int projectID; + int lineItemNo; + int doctorID; + int patientID; + String doctorName; + String doctorNameN; + String firstName; + String middleName; + String lastName; + String firstNameN; + String middleNameN; + String lastNameN; + int gender; + String dateofBirth; + String mobileNumber; + String emailAddress; + String patientIdentificationNo; + int patientType; + String admissionNo; + String admissionDate; + String roomID; + String bedID; + String nursingStationID; + String description; + String nationalityName; + String nationalityNameN; + String clinicDescription; + String clinicDescriptionN; + int referralDoctor; + int referringDoctor; + int referralClinic; + int referringClinic; + int referralStatus; + String referralDate; + String referringDoctorRemarks; + String referredDoctorRemarks; + String referralResponseOn; + int priority; + int frequency; + DateTime mAXResponseTime; + String age; + String frequencyDescription; + String genderDescription; + bool isDoctorLate; + bool isDoctorResponse; + String nursingStationName; + String priorityDescription; + String referringClinicDescription; + String referringDoctorName; + + MyReferredPatientModel( + {this.projectID, + this.lineItemNo, + this.doctorID, + this.patientID, + this.doctorName, + this.doctorNameN, + this.firstName, + this.middleName, + this.lastName, + this.firstNameN, + this.middleNameN, + this.lastNameN, + this.gender, + this.dateofBirth, + this.mobileNumber, + this.emailAddress, + this.patientIdentificationNo, + this.patientType, + this.admissionNo, + this.admissionDate, + this.roomID, + this.bedID, + this.nursingStationID, + this.description, + this.nationalityName, + this.nationalityNameN, + this.clinicDescription, + this.clinicDescriptionN, + this.referralDoctor, + this.referringDoctor, + this.referralClinic, + this.referringClinic, + this.referralStatus, + this.referralDate, + this.referringDoctorRemarks, + this.referredDoctorRemarks, + this.referralResponseOn, + this.priority, + this.frequency, + this.mAXResponseTime, + this.age, + this.frequencyDescription, + this.genderDescription, + this.isDoctorLate, + this.isDoctorResponse, + this.nursingStationName, + this.priorityDescription, + this.referringClinicDescription, + this.referringDoctorName}); + + MyReferredPatientModel.fromJson(Map json) { + projectID = json['ProjectID']; + lineItemNo = json['LineItemNo']; + doctorID = json['DoctorID']; + patientID = json['PatientID']; + doctorName = json['DoctorName']; + doctorNameN = json['DoctorNameN']; + firstName = json['FirstName']; + middleName = json['MiddleName']; + lastName = json['LastName']; + firstNameN = json['FirstNameN']; + middleNameN = json['MiddleNameN']; + lastNameN = json['LastNameN']; + gender = json['Gender']; + dateofBirth = json['DateofBirth']; + mobileNumber = json['MobileNumber']; + emailAddress = json['EmailAddress']; + patientIdentificationNo = json['PatientIdentificationNo']; + patientType = json['PatientType']; + admissionNo = json['AdmissionNo']; + admissionDate = json['AdmissionDate']; + roomID = json['RoomID']; + bedID = json['BedID']; + nursingStationID = json['NursingStationID']; + description = json['Description']; + nationalityName = json['NationalityName']; + nationalityNameN = json['NationalityNameN']; + clinicDescription = json['ClinicDescription']; + clinicDescriptionN = json['ClinicDescriptionN']; + referralDoctor = json['ReferralDoctor']; + referringDoctor = json['ReferringDoctor']; + referralClinic = json['ReferralClinic']; + referringClinic = json['ReferringClinic']; + referralStatus = json['ReferralStatus']; + referralDate = json['ReferralDate']; + referringDoctorRemarks = json['ReferringDoctorRemarks']; + referredDoctorRemarks = json['ReferredDoctorRemarks']; + referralResponseOn = json['ReferralResponseOn']; + priority = json['Priority']; + frequency = json['Frequency']; + mAXResponseTime = Helpers.convertStringToDate(json['MAXResponseTime']); + age = json['Age']; + frequencyDescription = json['FrequencyDescription']; + genderDescription = json['GenderDescription']; + isDoctorLate = json['IsDoctorLate']; + isDoctorResponse = json['IsDoctorResponse']; + nursingStationName = json['NursingStationName']; + priorityDescription = json['PriorityDescription']; + referringClinicDescription = json['ReferringClinicDescription']; + referringDoctorName = json['ReferringDoctorName']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['LineItemNo'] = this.lineItemNo; + data['DoctorID'] = this.doctorID; + data['PatientID'] = this.patientID; + data['DoctorName'] = this.doctorName; + data['DoctorNameN'] = this.doctorNameN; + data['FirstName'] = this.firstName; + data['MiddleName'] = this.middleName; + data['LastName'] = this.lastName; + data['FirstNameN'] = this.firstNameN; + data['MiddleNameN'] = this.middleNameN; + data['LastNameN'] = this.lastNameN; + data['Gender'] = this.gender; + data['DateofBirth'] = this.dateofBirth; + data['MobileNumber'] = this.mobileNumber; + data['EmailAddress'] = this.emailAddress; + data['PatientIdentificationNo'] = this.patientIdentificationNo; + data['PatientType'] = this.patientType; + data['AdmissionNo'] = this.admissionNo; + data['AdmissionDate'] = this.admissionDate; + data['RoomID'] = this.roomID; + data['BedID'] = this.bedID; + data['NursingStationID'] = this.nursingStationID; + data['Description'] = this.description; + data['NationalityName'] = this.nationalityName; + data['NationalityNameN'] = this.nationalityNameN; + data['ClinicDescription'] = this.clinicDescription; + data['ClinicDescriptionN'] = this.clinicDescriptionN; + data['ReferralDoctor'] = this.referralDoctor; + data['ReferringDoctor'] = this.referringDoctor; + data['ReferralClinic'] = this.referralClinic; + data['ReferringClinic'] = this.referringClinic; + data['ReferralStatus'] = this.referralStatus; + data['ReferralDate'] = this.referralDate; + data['ReferringDoctorRemarks'] = this.referringDoctorRemarks; + data['ReferredDoctorRemarks'] = this.referredDoctorRemarks; + data['ReferralResponseOn'] = this.referralResponseOn; + data['Priority'] = this.priority; + data['Frequency'] = this.frequency; + data['MAXResponseTime'] = this.mAXResponseTime; + data['Age'] = this.age; + data['FrequencyDescription'] = this.frequencyDescription; + data['GenderDescription'] = this.genderDescription; + data['IsDoctorLate'] = this.isDoctorLate; + data['IsDoctorResponse'] = this.isDoctorResponse; + data['NursingStationName'] = this.nursingStationName; + data['PriorityDescription'] = this.priorityDescription; + data['ReferringClinicDescription'] = this.referringClinicDescription; + data['ReferringDoctorName'] = this.referringDoctorName; + return data; + } +} + + diff --git a/lib/providers/referred_patient_provider.dart b/lib/providers/referred_patient_provider.dart new file mode 100644 index 00000000..19904f2b --- /dev/null +++ b/lib/providers/referred_patient_provider.dart @@ -0,0 +1,77 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; +import 'package:doctor_app_flutter/models/my_referred_patient_model.dart'; +//import 'package:doctor_app_flutter/models/my_referred_patient_model.dart'; +import 'package:doctor_app_flutter/models/request_add_referred_doctor_remarks.dart'; +import 'package:doctor_app_flutter/models/request_my_referral_patient_model.dart'; +import 'package:flutter/cupertino.dart'; + + +class MyReferredPatientProvider with ChangeNotifier { + List listMyReferralPatientModel = []; + + bool isLoading = true; + bool isError = false; + String error = ''; + + RequestMyReferralPatientModel _requestMyReferralPatient = RequestMyReferralPatientModel(); + RequestAddReferredDoctorRemarks _requestAddReferredDoctorRemarks = RequestAddReferredDoctorRemarks(); + + MyReferredPatientProvider() { + getMyReferralPatient(); + } + + getMyReferralPatient() async { + try { + await BaseAppClient.post( + 'DoctorApplication.svc/REST/GtMyReferralPatient', + body: _requestMyReferralPatient.toJson(), + onSuccess: (dynamic response, int statusCode) { + response['List_MyReferralPatient'].forEach((v) { + listMyReferralPatientModel.add(MyReferredPatientModel.fromJson(v)); + }); + isError = false; + isLoading = false; + }, + onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error = error; + }, + ); + notifyListeners(); + } catch (error) { + isLoading = false; + isError = true; + this.error = 'Something wrong happened, please contact the admin'; + notifyListeners(); + } + } + + Future replay( + String referredDoctorRemarks, MyReferredPatientModel model) async { + try { + _requestAddReferredDoctorRemarks.admissionNo = model.admissionNo; + _requestAddReferredDoctorRemarks.patientID = model.patientID; + _requestAddReferredDoctorRemarks.referredDoctorRemarks = referredDoctorRemarks; + _requestAddReferredDoctorRemarks.lineItemNo = model.lineItemNo; + _requestAddReferredDoctorRemarks.referringDoctor = model.referringDoctor; + + await BaseAppClient.post( + 'DoctorApplication.svc/REST/GtMyReferredPatient', + body: _requestAddReferredDoctorRemarks.toJson(), + onSuccess: (dynamic body, int statusCode) { + model.referredDoctorRemarks = referredDoctorRemarks; + listMyReferralPatientModel[ + listMyReferralPatientModel.indexOf(model)] = model; + notifyListeners(); + }, + onFailure: (String error, int statusCode) { + throw (error); + }, + ); + } catch (error) { + throw error; + } + } +} diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index d2a777f1..fc6ceb54 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/providers/doctor_reply_provider.dart'; import 'package:doctor_app_flutter/providers/medicine_provider.dart'; import 'package:doctor_app_flutter/providers/hospital_provider.dart'; import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; +import 'package:doctor_app_flutter/providers/referred_patient_provider.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -19,6 +20,8 @@ import '../widgets/shared/rounded_container_widget.dart'; import 'doctor/doctor_reply_screen.dart'; import 'doctor/my_referral_patient_screen.dart'; +import 'doctor/my_referred_patient_screen.dart'; + class DashboardScreen extends StatefulWidget { DashboardScreen({Key key, this.title}) : super(key: key); @@ -244,12 +247,12 @@ class _DashboardScreenState extends State { ), ), Expanded( - flex: 2, + flex: 3, child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( - flex: 2, + flex: 1, child: InkWell( child: DashboardItemIconText( DoctorApp.home_icon, @@ -272,7 +275,7 @@ class _DashboardScreenState extends State { ), ), Expanded( - flex: 2, + flex: 1, child: InkWell( onTap: (){ Navigator.push( @@ -294,6 +297,32 @@ class _DashboardScreenState extends State { ), ), ), + + //================== + Expanded( + flex: 1, + child: InkWell( + onTap: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (_) => MyReferredPatientProvider(), + child: MyReferredPatient(), + ), + ), + ); + }, + child: DashboardItemIconText( + DoctorApp.home_icon, + "", + "My Referred Patient", + showBorder: false, + backgroundColor: Colors.orange, + ), + ), + ), + //================== ], ), ), diff --git a/lib/screens/doctor/my_referred_patient_screen.dart b/lib/screens/doctor/my_referred_patient_screen.dart new file mode 100644 index 00000000..009f62ec --- /dev/null +++ b/lib/screens/doctor/my_referred_patient_screen.dart @@ -0,0 +1,67 @@ +import 'package:doctor_app_flutter/providers/referred_patient_provider.dart'; +import 'package:doctor_app_flutter/providers/schedule_provider.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/doctor/my_referred_patient_widget.dart'; +import 'package:doctor_app_flutter/widgets/doctor/my_schedule_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../widgets/shared/app_scaffold_widget.dart'; + +class MyReferredPatient extends StatelessWidget { + + MyReferredPatientProvider referredPatientProvider; + + @override + Widget build(BuildContext context) { + referredPatientProvider = Provider.of(context); + return AppScaffold( + showBottomBar: false, + showAppDrawer: false, + appBarTitle: TranslationBase.of(context).mySchedule, + body: referredPatientProvider.isLoading + ? DrAppCircularProgressIndeicator() + : referredPatientProvider.isError + ? Center( + child: AppText( + referredPatientProvider.error, + color: Theme.of(context).errorColor, + ), + ) + : referredPatientProvider.listMyReferralPatientModel.length == 0 + ? Center( + child: AppText( + TranslationBase.of(context).errorNoSchedule, + color: Theme.of(context).errorColor, + ), + ) + : Container( + padding: EdgeInsetsDirectional.fromSTEB(20, 0, 20, 0), + child: ListView( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + Container( + child: Column( + + children: referredPatientProvider.listMyReferralPatientModel.map((item) { + return MyReferredPatientWidget( + myReferredPatientModel: item, + ); + }).toList(), + ), + ), + ], + ), + ], + ), + ), + ); + } +} \ No newline at end of file diff --git a/lib/widgets/doctor/my_referred_patient_widget.dart b/lib/widgets/doctor/my_referred_patient_widget.dart new file mode 100644 index 00000000..0ab91954 --- /dev/null +++ b/lib/widgets/doctor/my_referred_patient_widget.dart @@ -0,0 +1,360 @@ + +import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; +import 'package:doctor_app_flutter/models/my_referred_patient_model.dart'; +import 'package:flutter/material.dart'; + + +import 'package:doctor_app_flutter/config/size_config.dart'; + +import 'package:doctor_app_flutter/providers/referred_patient_provider.dart'; + +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:flutter/cupertino.dart'; + +import 'package:provider/provider.dart'; + + + +class MyReferredPatientWidget extends StatefulWidget { + +final MyReferredPatientModel myReferredPatientModel; + + MyReferredPatientWidget({Key key, this.myReferredPatientModel}); + + @override + _MyReferredPatientWidgetState createState() => _MyReferredPatientWidgetState(); + + + +} + +class _MyReferredPatientWidgetState extends State { + + bool _showDetails = false; + bool _isLoading = false; + final _formKey = GlobalKey(); + String error; + TextEditingController answerController; + + @override + void initState() { + + + super.initState(); + + } + + @override + Widget build(BuildContext context) { + return CardWithBgWidgetNew( + widget: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppText( + '${widget.myReferredPatientModel.firstName} ${widget.myReferredPatientModel.lastName}', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down)), + ], + ), + !_showDetails + ? Container() + : AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'File No', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.myReferredPatientModel.referringDoctor}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + + ), + Container( + height: SizeConfig.realScreenWidth * 0.1, + width: 0.8, + color: Colors.grey, + margin: EdgeInsets.only(left: 15, right: 15), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Referring Doctor', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + widget.myReferredPatientModel + .referringClinicDescription, + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ], + ), + + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Referring Clinic', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.myReferredPatientModel.referringClinicDescription}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + height: SizeConfig.realScreenWidth * 0.1, + width: 0.8, + color: Colors.grey, + margin: EdgeInsets.only(left: 15, right: 15), + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Frequency', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + widget.myReferredPatientModel + .frequencyDescription, + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ], + ), + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Priority', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.myReferredPatientModel.priorityDescription}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + height: SizeConfig.realScreenWidth * 0.1, + width: 0.8, + color: Colors.grey, + margin: EdgeInsets.only(left: 15, right: 15), + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Max Response Time', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + Helpers.getDateFormatted(widget + .myReferredPatientModel + .mAXResponseTime), + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ], + ), + Divider(color: Colors.grey), + AppText( + 'Clinic Details and Remarks', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + SizedBox( + height: 5, + ), + AppText( + '${widget.myReferredPatientModel.referringDoctorRemarks}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ), + SizedBox( + height: 5, + ), + AppText( + 'Answer/Suggestions', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + SizedBox( + height: 5, + ), + AppText( + '${widget.myReferredPatientModel.referredDoctorRemarks}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ), + // Form( + // key: _formKey, + // child: TextFields( + // maxLines: 2, + // minLines: 2, + // hintText: 'Answer the patient', + // initialValue: widget.myReferredPatientModel.referredDoctorRemarks ?? '', + // readOnly: _isLoading, + // validator: (value) { + // if (value.isEmpty) + // return "please enter answer"; + // else + // return null; + // }, + // ), + // ), + SizedBox(height: 10.0), + if (error != null && error.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Theme.of(context) + .errorColor + .withOpacity(0.06), + ), + padding: EdgeInsets.symmetric( + vertical: 8.0, horizontal: 12.0), + child: Row( + children: [ + Expanded( + child: Texts(error ?? "", + style: "bodyText1", + color: Theme.of(context) + .errorColor)), + ], + ), + ), + SizedBox(height: 10.0), + ], + ), + SizedBox(height: 10.0), + Container( + width: double.infinity, + child: Button( + onTap: () async { + final form = _formKey.currentState; + if (form.validate()) { + setState(() { + _isLoading = true; + }); + try { + await Provider.of(context, listen: false).replay(answerController.text.toString(), widget.myReferredPatientModel); + // await Provider.of(context, listen: false).replay(answerController.text.toString(), widget.myReferredPatientModel);//myReferredPatientModel + setState(() { + _isLoading = false; + }); + } catch (e) { + setState(() { + error = e.toString(); + _isLoading = false; + }); + } + } + }, + title: 'Verify', + loading: _isLoading, + ), + ) + ], + ) + ], + ), + ) + ], + ), + ), + ); + } +} \ No newline at end of file