From 610ae3c1fb8bc2f43d0d0751db6323f4ffcf9af2 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 8 Jun 2020 16:51:34 +0300 Subject: [PATCH] add in patient prescription details screen --- .../prescription_report_for_in_patient.dart | 14 +- lib/providers/patients_provider.dart | 1 + lib/routes.dart | 6 +- lib/screens/auth/verify_account_screen.dart | 2 - ...n_patient_prescription_details_screen.dart | 200 ++++++++++++++++++ .../prescription_in_patinets_widget.dart | 7 +- 6 files changed, 220 insertions(+), 10 deletions(-) create mode 100644 lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart diff --git a/lib/models/patient/prescription_report_for_in_patient.dart b/lib/models/patient/prescription_report_for_in_patient.dart index d4452e32..9b88279e 100644 --- a/lib/models/patient/prescription_report_for_in_patient.dart +++ b/lib/models/patient/prescription_report_for_in_patient.dart @@ -1,3 +1,5 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; + class PrescriptionReportForInPatient { int admissionNo; int authorizedBy; @@ -25,7 +27,7 @@ class PrescriptionReportForInPatient { int orderNo; int patientID; String pharmacyRemarks; - String prescriptionDatetime; + DateTime prescriptionDatetime; int prescriptionNo; String processedBy; int projectID; @@ -38,11 +40,11 @@ class PrescriptionReportForInPatient { int routeId; Null routeN; Null setupID; - String startDatetime; + DateTime startDatetime; int status; String statusDescription; Null statusDescriptionN; - String stopDatetime; + DateTime stopDatetime; int unitofMeasurement; String unitofMeasurementDescription; Null unitofMeasurementDescriptionN; @@ -123,7 +125,7 @@ class PrescriptionReportForInPatient { orderNo = json['OrderNo']; patientID = json['PatientID']; pharmacyRemarks = json['PharmacyRemarks']; - prescriptionDatetime = json['PrescriptionDatetime']; + prescriptionDatetime = Helpers.convertStringToDate(json['PrescriptionDatetime']); prescriptionNo = json['PrescriptionNo']; processedBy = json['ProcessedBy']; projectID = json['ProjectID']; @@ -136,11 +138,11 @@ class PrescriptionReportForInPatient { routeId = json['RouteId']; routeN = json['RouteN']; setupID = json['SetupID']; - startDatetime = json['StartDatetime']; + startDatetime = Helpers.convertStringToDate(json['StartDatetime']) ; status = json['Status']; statusDescription = json['StatusDescription']; statusDescriptionN = json['StatusDescriptionN']; - stopDatetime = json['StopDatetime']; + stopDatetime = Helpers.convertStringToDate(json['StopDatetime']); unitofMeasurement = json['UnitofMeasurement']; unitofMeasurementDescription = json['UnitofMeasurementDescription']; unitofMeasurementDescriptionN = json['UnitofMeasurementDescriptionN']; diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 9bf8d34b..99b5f607 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -273,6 +273,7 @@ class PatientsProvider with ChangeNotifier { isLoading = false; }, onFailure: (String error, int statusCode) { isError = true; + isLoading = false; this.error = error; }, body: patient); notifyListeners(); diff --git a/lib/routes.dart b/lib/routes.dart index a24cfe52..b90a7e58 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,4 +1,6 @@ +import 'package:doctor_app_flutter/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart'; + import './screens/QR_reader_screen.dart'; import './screens/auth/change_password_screen.dart'; import './screens/auth/login_screen.dart'; @@ -58,6 +60,7 @@ const String PATIENT_ORDERS = 'patients/patient_orders'; const String PATIENT_INSURANCE_APPROVALS = 'patients/patient_insurance_approvals'; const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; const String BODY_MEASUREMENTS = 'patients/body-measurements'; +const String IN_PATIENT_PRESCRIPTIONS_DETAILS = 'patients/prescription-details'; var routes = { HOME: (_) => LandingPage(), @@ -89,5 +92,6 @@ var routes = { PATIENT_ORDERS: (_) => PatientsOrdersScreen(), PATIENT_INSURANCE_APPROVALS: (_) => InsuranceApprovalsScreen(), VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), - BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen() + BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen(), + IN_PATIENT_PRESCRIPTIONS_DETAILS:(_)=> InpatientPrescriptionDetailsScreen() }; diff --git a/lib/screens/auth/verify_account_screen.dart b/lib/screens/auth/verify_account_screen.dart index 61d58306..b7eee5df 100644 --- a/lib/screens/auth/verify_account_screen.dart +++ b/lib/screens/auth/verify_account_screen.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:flutter/material.dart'; import '../../lookups/auth_lookup.dart'; diff --git a/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart b/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart new file mode 100644 index 00000000..30a57b15 --- /dev/null +++ b/lib/screens/patients/profile/prescriptions/in_patient_prescription_details_screen.dart @@ -0,0 +1,200 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; +import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class InpatientPrescriptionDetailsScreen extends StatefulWidget { + @override + _InpatientPrescriptionDetailsScreenState createState() => + _InpatientPrescriptionDetailsScreenState(); +} + +class _InpatientPrescriptionDetailsScreenState + extends State { + bool _showDetails = false; + bool _isLoading = false; + final _formKey = GlobalKey(); + String error; + TextEditingController answerController; + bool _isInit = true; + PrescriptionReportForInPatient prescription; + + @override + void initState() { +// answerController = new TextEditingController(text: widget.myReferralPatientModel.referredDoctorRemarks ?? ''); + super.initState(); + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + prescription = routeArgs['prescription']; + } + _isInit = false; + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: 'perscription info', + body: CardWithBgWidgetNew( + widget: Container( + child: ListView( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + prescription.itemDescription, + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down)), + ], + ), + !_showDetails + ? Container() + : AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 5, + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + Table( + border: TableBorder.symmetric( + inside: BorderSide(width: 0.5), + ), + children: [ + buildTableRow( + des: '${prescription.direction}', + key: 'Direction'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Refill'), + buildTableRow( + des: '${prescription.dose}', + key: 'Dose'), + buildTableRow( + des: '${prescription.unitofMeasurement}', + key: 'UOM'), + buildTableRow( + des: '${Helpers.getDate(prescription.startDatetime) }', + key: 'Start Date'), + buildTableRow( + des: '${Helpers.getDate(prescription.stopDatetime)}', + key: 'Stop Date'), + buildTableRow( + des: '${prescription.noOfDoses}', + key: 'No of Doses'), + buildTableRow( + des: '${prescription.route}', + key: 'Route'), + buildTableRow( + des: '${prescription.comments}', + key: 'Comments'), + buildTableRow( + des: '${prescription.pharmacyRemarks}', + key: 'Pharmacy Remarks'), + buildTableRow( + des: '${Helpers.getDate(prescription.prescriptionDatetime)}', + key: 'Prescription Date'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Status'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Created By'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Processed By'), + buildTableRow( + des: '${prescription.refillID}', + key: 'Authorized By'), + ], + ), + Divider( + color: Color(0xFF000000), + height: 0.5, + ), + SizedBox( + height: 5, + ), + ], + ), + ) + ], + ), + ), + ), + ); + } + + TableRow buildTableRow({des, key}) { + print('$key: $des'); + return TableRow(children: [ + Container( + margin: EdgeInsets.all(2.5), + padding: EdgeInsets.all(5), + child: Row( + children: [ + Expanded( + child: Container( + child: AppText( + key, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + ), + ), + Expanded( + child: Container( + margin: + EdgeInsets.only(left: 4, top: 2.5, right: 2.5, bottom: 2.5), + padding: EdgeInsets.all(5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + AppText( + '${des}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + textAlign: TextAlign.center, + ) + ], + ), + ), + ), + ], + ), + ), + ]); + } +} diff --git a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart index 75eef63c..cafa6290 100644 --- a/lib/widgets/patients/profile/prescription_in_patinets_widget.dart +++ b/lib/widgets/patients/profile/prescription_in_patinets_widget.dart @@ -1,5 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/models/patient/prescription_report_for_in_patient.dart'; +import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; @@ -26,7 +27,11 @@ class PrescriptionInPatientWidget extends StatelessWidget { itemCount: prescriptionReportForInPatientList.length, itemBuilder: (BuildContext context, int index) { return InkWell( - onTap: () {}, + onTap: () { + Navigator.of(context).pushNamed(IN_PATIENT_PRESCRIPTIONS_DETAILS, arguments: { + 'prescription': prescriptionReportForInPatientList[index] + }); + }, child: CardWithBgWidgetNew( widget: Column( crossAxisAlignment: CrossAxisAlignment.start,