From d6404a7a3492a31d2a645fbbe5c2e35b91474910 Mon Sep 17 00:00:00 2001 From: taha Date: Wed, 7 Oct 2026 16:41:12 +0300 Subject: [PATCH] removed lab attachments --- .../laboratory_result/lab_result_widget.dart | 462 ++++--------- .../laboratory_result_page.dart | 1 - .../laboratory_result_widget.dart | 629 +++++------------- .../all_lab_special_result_page.dart | 1 - .../special_lab_result_details_page.dart | 306 +-------- 5 files changed, 342 insertions(+), 1057 deletions(-) diff --git a/lib/screens/patients/profile/lab_result/laboratory_result/lab_result_widget.dart b/lib/screens/patients/profile/lab_result/laboratory_result/lab_result_widget.dart index b590c8a5..9d3755dd 100644 --- a/lib/screens/patients/profile/lab_result/laboratory_result/lab_result_widget.dart +++ b/lib/screens/patients/profile/lab_result/laboratory_result/lab_result_widget.dart @@ -1,7 +1,6 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/model/labs/lab_result.dart'; import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart'; -import 'package:doctor_app_flutter/core/viewModel/labs_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/patients/profile/lab_result/laboratory_result/flow_chart_page.dart'; @@ -18,20 +17,17 @@ class LabResultWidget extends StatelessWidget { final PatientLabOrders patientLabOrder; final PatiantInformtion patient; final bool isInpatient; - final LabsViewModel model; - LabResultWidget({Key? key, required this.filterName, required this.patientLabResultList, required this.patientLabOrder, required this.patient, required this.isInpatient, required this.model}) - : super(key: key); + LabResultWidget({Key? key, required this.filterName, required this.patientLabResultList, required this.patientLabOrder, required this.patient, required this.isInpatient}) : super(key: key); + late ProjectViewModel projectViewModel; @override Widget build(BuildContext context) { - Provider.of(context); + projectViewModel = Provider.of(context); return Container( width: double.infinity, - padding: EdgeInsets.symmetric(horizontal: 8), child: Column( - mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ // if (!isInpatient) @@ -40,240 +36,183 @@ class LabResultWidget extends StatelessWidget { children: [ Row( children: [ - Visibility( - visible: filterName.isNotEmpty, + AppText( + filterName, + fontSize: SizeConfig.textMultiplier! * 2.0, + fontWeight: FontWeight.w700, + ), + ], + ), + ], + ), + SizedBox( + height: 8, + ), + Row( + children: [ + Expanded( + child: Container( + child: Center( child: AppText( - filterName, - fontSize: SizeConfig.textMultiplier! * 1.6, + TranslationBase.of(context).description, + color: Colors.black, + fontSize: SizeConfig.textMultiplier! * 2.0, fontWeight: FontWeight.w700, ), ), - ], + ), + ), + Expanded( + child: Container( + child: Center( + child: AppText( + TranslationBase.of(context).value, + color: Colors.black, + fontSize: SizeConfig.textMultiplier! * 2.0, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + Expanded( + child: Container( + child: Center( + child: AppText( + TranslationBase.of(context).range, + fontSize: SizeConfig.textMultiplier! * 2.0, + fontWeight: FontWeight.w700, + ), + ), + ), ), + Expanded( + child: Container(), + ) ], ), + Divider( + color: Colors.grey.shade500, + thickness: 1, + ), SizedBox( - height: 16, + height: 12, ), ListView.builder( itemCount: patientLabResultList.length, scrollDirection: Axis.vertical, - physics: const NeverScrollableScrollPhysics(), + physics: ScrollPhysics(), shrinkWrap: true, itemBuilder: (context, index) { return Column( - mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 8,), - Visibility( - visible: index == 0, - child: Column( + Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Color(0X55F2F2F2), + borderRadius: BorderRadius.all( + Radius.circular(8.0), + ), + ), + child: Row( children: [ - Visibility( - visible: patientLabResultList[index].PackageShortDescription != null && patientLabResultList[index].PackageShortDescription?.isNotEmpty == true , - child:Column( - children: [ - AppText( - patientLabResultList[index].PackageShortDescription??"", - fontSize: SizeConfig.textMultiplier! * 1.3, - fontWeight: FontWeight.w400, - color: Colors.black87, - isCopyable: true, - ), - SizedBox( - height: 8, - ), - - ], - ) ), - Visibility( - visible: (patientLabResultList.any((lab) => lab.IsLabTestAttachment ?? false)) && (patientLabResultList.any((lab) => lab.IsPackage ?? false)), - child: Center( - child: InkWell( - onTap: () async { - final labWithAttachment = patientLabResultList[index]; - var labAccessNumber = labWithAttachment.LabAccessionNo; - - showUploadedDocumentsBottomSheet( - context, - documents: labWithAttachment.UploadedDocuments, - fileName: labWithAttachment.FileNameWithExtensionList, - labAccessNumber: labAccessNumber, - projectID: int.parse(labWithAttachment.projectID!), - setupID: labWithAttachment.setupID, - ); - }, - child: Container( - width: double.infinity, - - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 24), - decoration: BoxDecoration( - color: Colors.red.shade50, - borderRadius: BorderRadius.circular(16), + Expanded( + child: Container( + padding: EdgeInsets.all(10), + child: Center( + child: AppText( + patientLabResultList[index].description!, + textAlign: TextAlign.center, + fontSize: SizeConfig.textMultiplier! * 1.8, + isCopyable: true, + ), + ), + ), + ), + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (patientLabResultList[index].checkResultStatus() != 0) + Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.red.shade700, + ), + child: Icon( + patientLabResultList[index].checkResultStatus() == 1 ? Icons.arrow_upward : Icons.arrow_downward, + color: Colors.white, + size: 16, + ), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.description_outlined, - color: Colors.red.shade700, - size: 20, - ), - SizedBox(width: 8), - AppText( - TranslationBase.of(context).showAttachment, - color: Colors.red.shade700, - fontSize: SizeConfig.textMultiplier! * 1.4, + Expanded( + child: Container( + alignment: Alignment.center, + padding: EdgeInsets.symmetric(vertical: 10, horizontal: 4), + child: Center( + child: AppText( + patientLabResultList[index].resultValue ?? "" + " " + "${patientLabResultList[index].uOM ?? ""}", + textAlign: TextAlign.center, + isCopyable: true, + fontSize: SizeConfig.textMultiplier! * 1.8, ), - ], + ), ), ), - ), + ], ), ), - SizedBox(height: 8,) - ], - ), - ), - - // Label (e.g. "Diagnosis:") - bold + underlined, like the screenshot - Row( - children: [ - Expanded( - child: AppText( - patientLabResultList[index].description!, - fontSize: SizeConfig.textMultiplier! * 1.9, - - color: Colors.black, - ), - ), - SizedBox( - width: 8, - ), - // Value - plain text below the label - AppText( - (patientLabResultList[index].resultValue ?? "") + (patientLabResultList[index].uOM != null ? " ${patientLabResultList[index].uOM}" : ""), - fontSize: SizeConfig.textMultiplier! * 1.8, - fontWeight: FontWeight.w400, - color: Colors.black87, - isCopyable: true, - ), - ], - ), - - Visibility( - visible: patientLabResultList[index].TestShortDescription != null , - child:Column( - children: [ - SizedBox( - height: 20, - ), - AppText( - patientLabResultList[index].TestShortDescription??"", - fontSize: SizeConfig.textMultiplier! * 1.3, - fontWeight: FontWeight.w400, - color: Colors.black87, - isCopyable: true, - ), - SizedBox( - height: 8, - ), - ], - ) ), - SizedBox( - height: 16, - ), - Center( - child: InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: FlowChartPage( - filterName: patientLabResultList.first.description!, - patientLabOrder: patientLabOrder, - patient: patient, - isInpatient: isInpatient, + Expanded( + child: Container( + padding: EdgeInsets.all(10), + // color: Colors.white, + child: Center( + child: AppText( + patientLabResultList[index].referanceRange!, + textAlign: TextAlign.center, + fontSize: SizeConfig.textMultiplier! * 1.8, + isCopyable: true, + ), ), ), - ); - }, - child: Container( - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 24), - decoration: BoxDecoration( - color: Colors.red.shade50, - borderRadius: BorderRadius.circular(16), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.show_chart, - color: Colors.red.shade700, - size: 20, - ), - SizedBox(width: 8), - AppText( - TranslationBase.of(context).showMoreBtn, - color: Colors.red.shade700, - fontSize: SizeConfig.textMultiplier! * 1.4, + Expanded( + child: Container( + child: InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: FlowChartPage( + filterName: patientLabResultList[index].description!, + patientLabOrder: patientLabOrder, + patient: patient, + isInpatient: isInpatient, + ), + ), + ); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText( + TranslationBase.of(context).showMoreBtn, + textDecoration: TextDecoration.underline, + color: Colors.red.shade700, + fontSize: SizeConfig.textMultiplier! * 1.8, + fontWeight: FontWeight.w700, + ), + ], + ), ), - ], + ), ), - ), + ], ), ), SizedBox( height: 16, ), - Visibility( - visible: (patientLabResultList[index].IsLabTestAttachment== true ) && (patientLabResultList[index].IsPackage == false), - child: Center( - child: InkWell( - onTap: () async { - final labWithAttachment = patientLabResultList.firstWhere( - (lab) => lab.IsLabTestAttachment ?? false, - ); - var labAccessNumber = labWithAttachment.LabAccessionNo; - - showUploadedDocumentsBottomSheet( - context, - documents: labWithAttachment.UploadedDocuments, - fileName: labWithAttachment.FileNameWithExtensionList, - labAccessNumber: labAccessNumber, - projectID: int.parse(labWithAttachment.projectID!), - setupID: labWithAttachment.setupID, - ); - }, - child: Container( - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 24), - decoration: BoxDecoration( - color: Colors.red.shade50, - borderRadius: BorderRadius.circular(16), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.description_outlined, - color: Colors.red.shade700, - size: 20, - ), - SizedBox(width: 8), - AppText( - TranslationBase.of(context).showAttachment, - color: Colors.red.shade700, - fontSize: SizeConfig.textMultiplier! * 1.4, - ), - ], - ), - ), - ), - ), - ), ], ); }), @@ -366,113 +305,4 @@ class LabResultWidget extends StatelessWidget { }); return tableRow; } - - void showUploadedDocumentsBottomSheet( - BuildContext context, { - List? documents, - List? fileName, - String? labAccessNumber, - int? projectID, - String? setupID, - }) { - const double kItemHeight = 66.0; // ListTile with contentPadding: 10 - final double screenHeight = MediaQuery.of(context).size.height; - final double maxSheetHeight = screenHeight * 0.5; - final double minSheetHeight = (kItemHeight + 100).clamp(0, maxSheetHeight); - - showModalBottomSheet( - context: context, - isScrollControlled: true, // lets the sheet respect custom height constraints - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - ), - builder: (BuildContext context) { - return ConstrainedBox( - constraints: BoxConstraints( - minHeight: minSheetHeight, - maxHeight: maxSheetHeight, - ), - child: SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // Drag handle - Container( - margin: const EdgeInsets.symmetric(vertical: 8), - width: 40, - height: 4, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(2), - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - child: Align( - alignment: AlignmentDirectional.centerStart, - child: Text( - TranslationBase.of(context).selectAnAttachment, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - Flexible( - child: Padding( - padding: const EdgeInsets.all(16), - child: Material( - color: const Color(0X55F2F2F2), - child: ListView.separated( - shrinkWrap: true, - padding: EdgeInsets.zero, - itemCount: documents?.length ?? fileName?.length ?? 0, - separatorBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: const Divider(height: 1, color: Colors.grey), - ), - itemBuilder: (context, index) { - final docName = documents?[index].fileName ?? fileName?[index]; - - return ListTile( - contentPadding: const EdgeInsets.all(10), - title: Text( - docName ?? "Unnamed Document", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - trailing: const Icon( - Icons.chevron_right, - color: Colors.grey, - ), - onTap: () async { - Navigator.pop(context); - if (documents?.isNotEmpty == true) { - await model.getLabAttachments(patient, uploadedDocument: documents![index], projectID: projectID, setupID: setupID); - model.openPDF(); - } - if (fileName?.isNotEmpty == true) { - await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, FileName: fileName![index], projectID: projectID, setupID: setupID); - model.openPDF(); - } - }, - ); - }, - ), - ), - ), - ), - const SizedBox(height: 8), - ], - ), - ), - ); - }, - ); - } } diff --git a/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_page.dart b/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_page.dart index c26feab9..b3fe1adc 100644 --- a/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_page.dart +++ b/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_page.dart @@ -47,7 +47,6 @@ class _LaboratoryResultPageState extends State { LaboratoryResultWidget( onTap: () async {}, billNo: widget.patientLabOrders.invoiceNo!, - details: model.patientLabSpecialResult, orderNo: widget.patientLabOrders.orderNo!, patientLabOrder: widget.patientLabOrders, patient: widget.patient, diff --git a/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_widget.dart b/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_widget.dart index 445d7922..d9cffc97 100644 --- a/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_widget.dart +++ b/lib/screens/patients/profile/lab_result/laboratory_result/laboratory_result_widget.dart @@ -14,13 +14,12 @@ import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; - import 'package:provider/provider.dart'; class LaboratoryResultWidget extends StatefulWidget { final GestureTapCallback? onTap; final String? billNo; - final List? details; + final String? details; final String? orderNo; final PatientLabOrders? patientLabOrder; final PatiantInformtion? patient; @@ -36,7 +35,6 @@ class LaboratoryResultWidget extends StatefulWidget { class _LaboratoryResultWidgetState extends State { bool _isShowMoreGeneral = true; bool _isShowMore = true; - int expandedIndex = 0; late ProjectViewModel projectViewModel; @override @@ -48,493 +46,186 @@ class _LaboratoryResultWidgetState extends State { // patientLabOrder: widget.patientLabOrder, // patient: widget.patient, // isInpatient: widget.isInpatient), - builder: (_, model, w) => SingleChildScrollView( - child: NetworkBaseView( - baseViewModel: model, - child: SafeArea( - child: Container( - margin: EdgeInsets.all(4), - child: Column( + builder: (_, model, w) => NetworkBaseView( + baseViewModel: model, + child: Container( + margin: EdgeInsets.all(15), + child: Column( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - - if (model.mappedLabResultList.isNotEmpty) - Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(16.0), - ), - ), - - child: Column( - children: [ - InkWell( - onTap: () { - setState( - () { - _isShowMoreGeneral = !_isShowMoreGeneral; - }, - ); + SizedBox( + height: 12, + ), + if (model.labResultLists.isNotEmpty) + Container( + child: Column( + children: [ + InkWell( + onTap: () { + setState( + () { + _isShowMoreGeneral = !_isShowMoreGeneral; }, - child: Container( - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.only(left: 5, right: 5), - // decoration: BoxDecoration( - // shape: BoxShape.rectangle, - // color: Colors.white, - // borderRadius: BorderRadius.all( - // Radius.circular(5.0), - // ), - // ), - child: Row( - children: [ - Expanded( - child: Container( - margin: EdgeInsets.only(left: 0, right: 0), - child: AppText( - TranslationBase.of(context).generalResult, - fontSize: SizeConfig.textMultiplier! * 2.3, - bold: false, - ))), - Container( - width: 25, - height: 25, - child: Icon( - _isShowMoreGeneral ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, - color: Colors.grey[800], - size: 22, - ), - ) - ], - ), + ); + }, + child: Container( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(5.0), ), ), - if (_isShowMoreGeneral) - AnimatedContainer( - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.only(left: 5, right: 5), - // decoration: BoxDecoration( - // shape: BoxShape.rectangle, - // color: Colors.white, - // borderRadius: BorderRadius.only( - // bottomLeft: Radius.circular(5.0), - // bottomRight: Radius.circular(5.0), - // ), - // ), - duration: Duration(milliseconds: 7000), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // ListView.builder( - // itemCount: model.mappedLabResultList.length, - // scrollDirection: Axis.vertical, - // physics: ScrollPhysics(), - // shrinkWrap: true, - // itemBuilder: (context, index) { - // return LabResultWidget( - // patientLabOrder: widget.patientLabOrder!, - // filterName: model.labResultLists[index].filterName, - // patientLabResultList: model.labResultLists[index].patientLabResultList, - // patient: widget.patient!, - // isInpatient: widget.isInpatient!, - // model: model, - // ); - // }), - mappedListDisplay(model) - ], - ), - ), - ], - ), - ) - else if (widget.details == null) - Container( - child: ErrorMessage( - error: TranslationBase.of(context).noDataAvailable, + child: Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 0, right: 0), + child: AppText( + TranslationBase.of(context).generalResult, + fontSize: SizeConfig.textMultiplier! * 2.3, + bold: false, + ))), + Container( + width: 25, + height: 25, + child: Icon( + _isShowMoreGeneral ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, + color: Colors.grey[800], + size: 22, + ), + ) + ], + ), + ), ), - ), - SizedBox( - height: 15, - ), - if (widget.details?.isNotEmpty == true) - Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - color: Colors.white, - borderRadius: BorderRadius.all( - Radius.circular(16.0), - )), - child: Column( - children: [ - InkWell( - onTap: () { - setState(() { - _isShowMore = !_isShowMore; - }); - }, - child: Container( - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.only(left: 5, right: 5), - child: Row( - children: [ - Expanded( - child: Container( - margin: EdgeInsets.only(left: 0, right: 0), - child: AppText( - TranslationBase.of(context).specialResult, - fontSize: SizeConfig.textMultiplier! * 2.3, - bold: false, - ))), - Container( - width: 25, - height: 25, - child: Icon( - _isShowMore ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, - color: Colors.grey[800], - size: 22, - ), - ) - ], - ), + if (_isShowMoreGeneral) + AnimatedContainer( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(5.0), + bottomRight: Radius.circular(5.0), ), ), - if (_isShowMore) - AnimatedContainer( - padding: EdgeInsets.all(10.0), - margin: EdgeInsets.only(left: 5, right: 5), - // decoration: BoxDecoration( - // shape: BoxShape.rectangle, - // color: Colors.white, - // borderRadius: BorderRadius.only( - // bottomLeft: Radius.circular(5.0), - // bottomRight: Radius.circular(5.0), - // )), - duration: Duration(milliseconds: 7000), - child: ListView.separated( - separatorBuilder: (context, index) => Divider( - color: Colors.grey[300], - thickness: 1, - ), - itemCount: widget.details?.length ?? 0, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, index) { - String? resultData; - try { - resultData = (widget.details?[index])?.resultDataHTML?.toString(); - } catch (_) { - resultData = null; - } - final displayData = (resultData == null || resultData.trim().isEmpty) - ? TranslationBase.of(context).noDataAvailable - : resultData.trim(); - - return buildLabDetailItem(context, index, displayData, model); - }, - ), + duration: Duration(milliseconds: 7000), + child: Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ListView.builder( + itemCount: model.labResultLists.length, + scrollDirection: Axis.vertical, + physics: ScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return LabResultWidget( + patientLabOrder: widget.patientLabOrder!, + filterName: model.labResultLists[index].filterName, + patientLabResultList: model.labResultLists[index].patientLabResultList, + patient: widget.patient!, + isInpatient: widget.isInpatient!, + ); + }), + ], ), - - ], - ), - ), - ], - ), - ], - ), - ), - ), - ), - ), - ); - } - Widget buildLabDetailItem(BuildContext context, int index, String displayData, LabsViewModel model) { - return Card( - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16.0), - ), - elevation: 8, - child: Padding( - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - !Utils.isTextHtml(displayData) - ? AppText(displayData) - : HtmlWidget(displayData), - Visibility( - visible: widget.details?[index].IsLabTestAttachment ?? false, - child: Column( - children: [ - SizedBox(height: 8,), - InkWell( - onTap: () async { - var labAccessNumber = widget.details?[index].LabAccessionNo; - // if (widget.details?[index].FileNameWithExtensionList?.isNotEmpty == true || widget.details?[index].FileNameWithExtensionList?.length == 1) { - // await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, FileName: widget.details?[index].FileNameWithExtensionList?.first); - // model.openPDF(); - // return; - // } - // - // if (widget.details?[index].UploadedDocuments?.isNotEmpty == true || widget.details?[index].UploadedDocuments?.length == 1) { - // await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, uploadedDocument: widget.details?[index].UploadedDocuments?.first); - // model.openPDF(); - // return; - // } - - showUploadedDocumentsBottomSheet( - context, - model, - documents: widget.details?[index].UploadedDocuments, - fileName: widget.details?[index].FileNameWithExtensionList, - labAccessNumber: labAccessNumber, - projectID: int.parse(widget.details?[index].ProjectID ?? "0"), - setupID: widget.details?[index].SetupID); - }, - child: Container( - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 24), - decoration: BoxDecoration( - color: Colors.red.shade50, - borderRadius: BorderRadius.circular(16), - ), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.description_outlined, - color: Colors.red.shade700, - size: 20, - ), - SizedBox(width: 8), - AppText( - TranslationBase.of(context).showAttachment, - color: Colors.red.shade700, - fontSize: SizeConfig.textMultiplier! * 1.4, - ), - ], - ), - ), - ), - ], - ), - ), - ], - ), - ), - ); - } - - void showUploadedDocumentsBottomSheet( - BuildContext context, LabsViewModel model, { - List? documents, - List? fileName, - String? labAccessNumber, - int? projectID, - String? setupID, - }) { - const double kItemHeight = 66.0; // ListTile with contentPadding: 10 - final double screenHeight = MediaQuery.of(context).size.height; - final double maxSheetHeight = screenHeight * 0.5; - final double minSheetHeight = (kItemHeight + 100).clamp(0, maxSheetHeight); - - showModalBottomSheet( - context: context, - isScrollControlled: true, // lets the sheet respect custom height constraints - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - ), - builder: (BuildContext context) { - return ConstrainedBox( - constraints: BoxConstraints( - minHeight: minSheetHeight, - maxHeight: maxSheetHeight, - ), - child: SafeArea( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // Drag handle - Container( - margin: const EdgeInsets.symmetric(vertical: 8), - width: 40, - height: 4, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(2), - ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - child: Align( - alignment: AlignmentDirectional.centerStart, - child: Text( - TranslationBase.of(context).selectAnAttachment, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - Flexible( - child: Padding( - padding: const EdgeInsets.all(16), - child: Material( - color: const Color(0X55F2F2F2), - child: ListView.separated( - shrinkWrap: true, - padding: EdgeInsets.zero, - itemCount: documents?.length ?? fileName?.length ?? 0, - separatorBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: const Divider(height: 1, color: Colors.grey), - ), - itemBuilder: (context, index) { - final docName = documents?[index].fileName ?? fileName?[index]; - - return ListTile( - contentPadding: const EdgeInsets.all(10), - title: Text( - docName ?? "Unnamed Document", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - trailing: const Icon( - Icons.chevron_right, - color: Colors.grey, ), - onTap: () async { - Navigator.pop(context); - if (documents?.isNotEmpty == true) { - await model.getLabAttachments(widget.patient!, uploadedDocument: documents![index], projectID: projectID, setupID: setupID); - model.openPDF(); - } - if (fileName?.isNotEmpty == true) { - await model.getLabAttachments(widget.patient!, labAccessNumber: labAccessNumber, FileName: fileName![index], projectID: projectID, setupID: setupID); - model.openPDF(); - } - }, - ); - }, + ], + ), + ) + else if (widget.details == null) + Container( + child: ErrorMessage( + error: TranslationBase.of(context).noDataAvailable, ), ), + SizedBox( + height: 15, ), - ), - const SizedBox(height: 8), - ], - ), - ), - ); - }, - ); - } - - mappedListDisplay(LabsViewModel model) { - final packageEntries = model.mappedLabResultList.entries.toList(); - return ListView.separated( - separatorBuilder: (_, __) => Padding(padding: EdgeInsets.all(4), - child: Divider( - height: 2, - ) ,), - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - shrinkWrap: true, - itemCount: packageEntries.length, - itemBuilder: (context, packageIndex) { - final packageName = packageEntries[packageIndex].key; - final labResults = packageEntries[packageIndex].value; - final isExpanded = expandedIndex == packageIndex; - - return InkWell( - onTap: () { - setState(() { - if (isExpanded) { - expandedIndex = -1; // Collapse if already expanded - } else - expandedIndex = packageIndex; - }); - }, - child: Card( - color: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16.0), - ), - elevation: 2, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - children: [ - Row( - children: [ - Expanded( + if (widget.details != null && widget.details!.isNotEmpty) + Column( + children: [ + InkWell( + onTap: () { + setState(() { + _isShowMore = !_isShowMore; + }); + }, child: Container( - margin: EdgeInsets.only(left: 0, right: 0), - child: AppText( - packageName, - fontSize: SizeConfig.textMultiplier! * 1.8, - bold: false, - ))), - // Arrow rotates smoothly between down/up instead of snapping - AnimatedRotation( - turns: isExpanded ? 0.5 : 0.0, - duration: const Duration(milliseconds: 250), - curve: Curves.easeInOut, - child: Container( - width: 25, - height: 25, - child: Icon( - Icons.keyboard_arrow_down, - color: Colors.grey[800], - size: 22, + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.all( + Radius.circular(5.0), + )), + child: Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 0, right: 0), + child: AppText( + TranslationBase.of(context).specialResult, + fontSize: SizeConfig.textMultiplier! * 2.3, + bold: false, + ))), + Container( + width: 25, + height: 25, + child: Icon( + _isShowMore ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down, + color: Colors.grey[800], + size: 22, + ), + ) + ], + ), ), ), - ) - ], - ), - - - // Animated expand/collapse of the lab result content - AnimatedSize( - duration: const Duration(milliseconds: 250), - curve: Curves.easeInOut, - alignment: Alignment.topCenter, - child: AnimatedCrossFade( - duration: const Duration(milliseconds: 250), - sizeCurve: Curves.easeInOut, - firstCurve: Curves.easeIn, - secondCurve: Curves.easeIn, - crossFadeState: isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, - firstChild: const SizedBox(width: double.infinity, height: 0), - secondChild: Column( - mainAxisSize: MainAxisSize.min, - children: [ - LabResultWidget( - patientLabOrder: widget.patientLabOrder!, - filterName: "", - patientLabResultList: labResults, - patient: widget.patient!, - isInpatient: widget.isInpatient!, - model: model, + if (_isShowMore) + AnimatedContainer( + padding: EdgeInsets.all(10.0), + margin: EdgeInsets.only(left: 5, right: 5), + decoration: BoxDecoration( + shape: BoxShape.rectangle, + color: Colors.white, + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(5.0), + bottomRight: Radius.circular(5.0), + )), + duration: Duration(milliseconds: 7000), + child: Container( + width: double.infinity, + child: !Utils.isTextHtml(widget.details!) + ? AppText( + widget.details ?? TranslationBase.of(context).noDataAvailable, + ) + : HtmlWidget( + widget.details ?? TranslationBase.of(context).noDataAvailable, + ), ), - ], - ), + ), + SizedBox( + height: 10, + ), + ], ), - ), ], ), - ), + ], ), - ); - }, + ), + ), ); } } diff --git a/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart b/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart index 2a6de730..66845db1 100644 --- a/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart +++ b/lib/screens/patients/profile/lab_result/special_result/all_lab_special_result_page.dart @@ -153,7 +153,6 @@ class _AllLabSpecialResultState extends State { resultData: model.allSpecialLabList[index] .resultDataHTML!, patient: patient!, - labResult: model.allSpecialLabList[index], ), ), ), diff --git a/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart b/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart index 674798ea..e13da80d 100644 --- a/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart +++ b/lib/screens/patients/profile/lab_result/special_result/special_lab_result_details_page.dart @@ -1,34 +1,24 @@ -import 'package:doctor_app_flutter/core/model/labs/all_special_lab_result_model.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientMedicalReportViewModel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/labs_view_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; -import 'package:doctor_app_flutter/utils/extenstions_utils.dart'; import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_service_title.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; -// import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; - -import '../../../../../config/size_config.dart'; -import '../../../../../core/model/labs/lab_result.dart'; -import '../../../../../widgets/shared/app_texts_widget.dart'; class SpecialLabResultDetailsPage extends StatelessWidget { final String resultData; final PatiantInformtion patient; - final AllSpecialLabResultModel labResult; - - const SpecialLabResultDetailsPage({Key? key, required this.resultData, required this.patient, required this.labResult}) : super(key: key); + const SpecialLabResultDetailsPage({Key? key, required this.resultData, required this.patient}) + : super(key: key); @override Widget build(BuildContext context) { - return BaseView( + return BaseView( builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, @@ -36,271 +26,47 @@ class SpecialLabResultDetailsPage extends StatelessWidget { appBar: PatientProfileAppBar( patient, ), - body: NetworkBaseView( - baseViewModel: model, - child: Container( - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ServiceTitle( - title: TranslationBase.of(context).special + " " + TranslationBase.of(context).lab, - subTitle: TranslationBase.of(context).result, - ), - Row( - children: [ - Expanded( - child: Column( - children: [ - (resultData != null && resultData.isNotEmpty) - ? Card( - color: Colors.white, - margin: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(16.0), - ), - elevation: 4, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - - Visibility( - visible: labResult.testDescription != null && (labResult.testDescription as String).isNotEmpty , - child:Column( - children: [ - SizedBox( - height: 8, - ), - AppText( - labResult.testDescription ??"", - fontSize: SizeConfig.textMultiplier! * 1.6, - fontWeight: FontWeight.w700, - color: Colors.black87, - isCopyable: true, - ), - SizedBox( - height: 8, - ), - ], - ) ), - Visibility( - visible: labResult.testShortDescription != null && (labResult.testShortDescription as String).isNotEmpty , - child:Column( - children: [ - SizedBox( - height: 8, - ), - AppText( - labResult.testShortDescription ??"", - fontSize: SizeConfig.textMultiplier! * 1.3, - fontWeight: FontWeight.w400, - color: Colors.black87, - isCopyable: true, - ), - SizedBox( - height: 8, - ), - ], - ) ), - // Html(data: resultData ?? ""), - HtmlWidget(resultData ?? ""), - - Visibility( - visible: labResult.IsLabTestAttachment ?? false, - child: Column( - children: [ - SizedBox( - height: 12, - ), - InkWell( - onTap: () async { - var labAccessNumber = labResult.LabAccessionNo; - // if (patientLabResultList[index].FileNameWithExtensionList?.isNotEmpty == true || patientLabResultList[index].FileNameWithExtensionList?.length == 1) { - // await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, FileName: patientLabResultList[index].FileNameWithExtensionList?.first); - // model.openPDF(); - // return; - // } - // - // if (patientLabResultList[index].UploadedDocuments?.isNotEmpty == true || patientLabResultList[index].UploadedDocuments?.length == 1) { - // await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, uploadedDocument: patientLabResultList[index].UploadedDocuments?.first); - // model.openPDF(); - // return; - // } - - showUploadedDocumentsBottomSheet( - context, - documents: labResult.UploadedDocuments, - fileName: labResult.FileNameWithExtensionList, - labAccessNumber: labAccessNumber, - projectID: int.parse(labResult.projectID!), - // projectID: 160, - setupID: labResult.setupID, - model: model, - ); - }, - child: Container( - width: double.infinity, - padding: EdgeInsets.symmetric(vertical: 14, horizontal: 16), - decoration: BoxDecoration( - color: Colors.red.shade50, - borderRadius: BorderRadius.circular(8), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Icon( - Icons.description_outlined, - color: Colors.red.shade700, - size: 18, - ), - SizedBox(width: 6), - AppText( - TranslationBase.of(context).showAttachment, - color: Colors.red.shade700, - fontSize: SizeConfig.textMultiplier! * 1.4, - fontWeight: FontWeight.w400, - ), - ], - ), - ), - ), - ], - ), - ), - ], - ), - ), - ) - : Container( - child: ErrorMessage( - error: TranslationBase - .of(context) - .noItem, - ), - ), - ], - ), - ), - ], - ), - ], - ), - ), - ), - ), - ), - ); - } - void showUploadedDocumentsBottomSheet( - BuildContext context, { - List? documents, - List? fileName, - String? labAccessNumber, - int? projectID, - String? setupID, - required LabsViewModel model, - }) { - const double kItemHeight = 66.0; // ListTile with contentPadding: 10 - final double screenHeight = MediaQuery.of(context).size.height; - final double maxSheetHeight = screenHeight * 0.5; - final double minSheetHeight = (kItemHeight + 100).clamp(0, maxSheetHeight); - - showModalBottomSheet( - context: context, - isScrollControlled: true, // lets the sheet respect custom height constraints - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - ), - builder: (BuildContext context) { - return ConstrainedBox( - constraints: BoxConstraints( - minHeight: minSheetHeight, - maxHeight: maxSheetHeight, - ), - child: SafeArea( + body: Container( + child: SingleChildScrollView( child: Column( - mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - // Drag handle - Container( - margin: const EdgeInsets.symmetric(vertical: 8), - width: 40, - height: 4, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(2), - ), + ServiceTitle( + title: TranslationBase.of(context).special + + " " + + TranslationBase.of(context).lab, + subTitle: TranslationBase.of(context).result, ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - child: Align( - alignment: AlignmentDirectional.centerStart, - child: Text( - TranslationBase.of(context).selectAnAttachment, - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.bold, - ), - ), - ), - ), - Flexible( - child: Padding( - padding: const EdgeInsets.all(16), - child: Material( - color: const Color(0X55F2F2F2), - child: ListView.separated( - shrinkWrap: true, - padding: EdgeInsets.zero, - itemCount: documents?.length ?? fileName?.length ?? 0, - separatorBuilder: (context, index) => Padding( - padding: const EdgeInsets.all(8.0), - child: const Divider(height: 1, color: Colors.grey), - ), - itemBuilder: (context, index) { - final docName = documents?[index]?.fileName ?? fileName?[index]; - - return ListTile( - contentPadding: const EdgeInsets.all(10), - title: Text( - docName ?? "Unnamed Document", - style: const TextStyle( - fontSize: 15, - fontWeight: FontWeight.w500, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - trailing: const Icon( - Icons.chevron_right, - color: Colors.grey, + resultData != null + ? Container( + width: double.infinity, + margin: + EdgeInsets.symmetric(horizontal: 16, vertical: 16), + padding: + EdgeInsets.symmetric(horizontal: 16, vertical: 16), + decoration: BoxDecoration( + color: Colors.white, + shape: BoxShape.rectangle, + borderRadius: BorderRadius.all(Radius.circular(8)), + border: Border.fromBorderSide( + BorderSide( + color: Colors.white, + width: 1.0, ), - onTap: () async { - Navigator.pop(context); - if (documents?.isNotEmpty == true) { - await model.getLabAttachments(patient, uploadedDocument: documents![index], projectID: projectID, setupID: setupID); - model.openPDF(); - } - if (fileName?.isNotEmpty == true) { - await model.getLabAttachments(patient, labAccessNumber: labAccessNumber, FileName: fileName![index], projectID: projectID, setupID: setupID); - model.openPDF(); - } - }, - ); - }, + ), + ), + child: HtmlWidget(resultData ?? ""), + ) + : Container( + child: ErrorMessage( + error: TranslationBase.of(context).noItem, + ), ), - ), - ), - ), - const SizedBox(height: 8), ], ), ), - ); - }, + ), + ), ); } }