diff --git a/lib/Reports/allreports.dart b/lib/Reports/allreports.dart index 385e138..c1d43f4 100644 --- a/lib/Reports/allreports.dart +++ b/lib/Reports/allreports.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:healthcare_user/Reports/add_reports.dart'; import 'package:healthcare_user/Reports/finding_images.dart'; +import 'package:healthcare_user/Reports/prescription_images.dart'; import 'package:healthcare_user/Reports/report_images.dart'; import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/zoom_image.dart'; @@ -278,8 +279,15 @@ class _AllReportsState extends State { Text(reportsList[index].hospitalName.toString().toUpperCase(),style: valuesTextStyle()), Text(reportsList[index].date.toString().toUpperCase(),style: valuesTextStyle()), Text(reportsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()), - Text(reportsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()), - Text(reportsList[index].age.toString().toUpperCase(),style: valuesTextStyle()), + Row( + children: [ + Text(reportsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()), + SizedBox(width:MediaQuery.of(context).size.width * .05,), + Text(reportsList[index].age.toString().toUpperCase()+" Yrs",style: valuesTextStyle()), + ], + ), + + ], ), @@ -364,16 +372,12 @@ class _AllReportsState extends State { onPrimary: Colors.white, // foreground ), onPressed: () async { - /*Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const FindingImages()), - );*/ - Navigator.push( context, new MaterialPageRoute( - builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages))); + builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) { + gaetAllRecords(); + }); }, child: Text('Findings: '+reportsList[index].findingsImages.length.toString()), ), @@ -403,6 +407,13 @@ class _AllReportsState extends State { onPrimary: Colors.white, // foreground ), onPressed: () async { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index]))).then((value) { + gaetAllRecords(); + }); + }, child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString()), ), diff --git a/lib/Reports/finding_images.dart b/lib/Reports/finding_images.dart index 412a463..609bc5f 100644 --- a/lib/Reports/finding_images.dart +++ b/lib/Reports/finding_images.dart @@ -1,10 +1,19 @@ +import 'dart:convert'; +import 'dart:io'; + import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:healthcare_user/Reports/allreports.dart'; import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/zoom_image.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; class FindingImages extends StatefulWidget { var imageDetails; - FindingImages({this.imageDetails}); + var recordId; + + FindingImages({this.imageDetails,this.recordId}); @override @@ -12,68 +21,304 @@ class FindingImages extends StatefulWidget { } class _FindingImagesState extends State { - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppSettings.appBar('Finding Images'), - body:Container( - padding: EdgeInsets.all(12.0), - child: GridView.builder( - itemCount:widget.imageDetails.length, - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - crossAxisSpacing: 2.0, - mainAxisSpacing: 2.0, - ), - itemBuilder: (BuildContext context, int index) { - return GestureDetector( - onTap: () { - - Navigator.push( - context, - new MaterialPageRoute( - builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:widget.imageDetails[index]['url']))); - /*gridOntap(index);*/ - }, - child: Container( - width: MediaQuery.of(context).size.width * .30, - height: MediaQuery.of(context).size.height * .15, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - image: DecorationImage( - image: NetworkImage( - widget.imageDetails[index]['url']) - as ImageProvider, // picked file - fit: BoxFit.fill)), - child: Stack( - children: [ + + final ImagePicker imagePicker = ImagePicker(); + List imageFileList = []; + List uiFindingsImages = []; + final ImagePicker _picker = ImagePicker(); + + Future pickImageFromGallery() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.uploadImageForFindings(imageFileList); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.imageDetails = jsonDecode(res)['findings']; + }); + } + + Future pickImageFromGalleryForUpdate() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.uploadImageForFindingsUpdate(imageFileList,widget.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.imageDetails = jsonDecode(res)['findings']; + }); + } + + Future takeImageFromCamera() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.uploadImageForFindingsFromCamera(image); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.imageDetails = jsonDecode(res)['findings']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + Future takeImageFromCameraForUpdate() async { + try { + final image = await _picker.pickImage(source: ImageSource.camera); + if (image == null) return; + final imageTemp = File(image.path); + AppSettings.preLoaderDialog(context); + var res = await AppSettings.uploadImageForFindingsUpdateFromCamera(image,widget.recordId); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.imageDetails = jsonDecode(res)['findings']; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + + + + + + Widget renderUi() { + + if(widget.imageDetails.length!=0){ + return GridView.builder( + itemCount:widget.imageDetails.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:widget.imageDetails[index]['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + widget.imageDetails[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack( + children: [ Positioned( - right: 0, - child: Container( - child: IconButton( - iconSize: 30, - icon: const Icon( - Icons.cancel, - color: Colors.red, - ), - onPressed: () async { + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.cancel, + color: Colors.red, + ), + onPressed: () async { + AppSettings.preLoaderDialog(context); + String fileName = widget.imageDetails[index]['url'].split('/').last; + var payload = new Map(); + payload["urlType"] = 'findings'; + payload["url"] = widget.imageDetails[index]['url']; - }, - ), - /* color: Colors.pinkAccent, + bool deleteStatus = await AppSettings.deleteRecords(payload,widget.recordId); + + if(deleteStatus){ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast("Image deleted Successfully"); + //AllReportsState().getAllRecords(); + Navigator.pop(context); + } + else{ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast("Image deletion failed"); + } + + + + + }, + ), + /* color: Colors.pinkAccent, width: 35, height: 35,*/ - ), - )]), + ), + )]), + ), + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + ); + } + else{ + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(height: MediaQuery.of(context).size.height * .25,), + Text('Click below icon to add new Report'), + SizedBox( + height: 20, ), + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCamera(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + ) + ); + } + + } + + + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primaryColor, + title: Text("Finding Images"), + actions: [ + Visibility( + visible: widget.imageDetails.length>0, + child: IconButton( + iconSize: 30, + icon: Icon( + Icons.add_task, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + await takeImageFromCameraForUpdate(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * + .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGalleryForUpdate(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + + - //Image.network(widget.imageDetails[index]['url']), - ); }, - )), + ),) + ], + ), + body:Container( + padding: EdgeInsets.all(12.0), + child: renderUi()), ); } } diff --git a/lib/Reports/order_medicines_new.dart b/lib/Reports/order_medicines_new.dart new file mode 100644 index 0000000..1b1efb3 --- /dev/null +++ b/lib/Reports/order_medicines_new.dart @@ -0,0 +1,1014 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:flutter/material.dart'; +import 'package:geolocator/geolocator.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/common/zoom_image.dart'; +import 'package:healthcare_user/google_maps_place_picker_mb/src/models/pick_result.dart'; +import 'package:healthcare_user/google_maps_place_picker_mb/src/place_picker.dart'; +import 'package:healthcare_user/keys.dart'; +import 'package:healthcare_user/models/pharmacies_model.dart'; +import 'package:google_maps_flutter_android/google_maps_flutter_android.dart'; +import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; +import 'package:healthcare_user/prescriptions/get_quotations_request_list.dart'; +import 'package:location/location.dart' as locationmap; + + +class OrderMedicinesPrescriptions extends StatefulWidget { + var prescriptionDetails; + var familyDetails; + OrderMedicinesPrescriptions({this.prescriptionDetails,this.familyDetails}); + + @override + State createState() => _OrderMedicinesPrescriptionsState(); +} + +class _OrderMedicinesPrescriptionsState extends State { + double lat = 0; + double lng = 0; + String userAddress = ''; + String dropdownArea = '2'; + //String dropdownType = 'Tank'; + var AreaItems = ['2', '5', '10', '25', '50', '100']; + List pharmaciesCheckboxes = []; + List pharmaciesCheckboxesInDialog = []; + List selectedPharmacies = []; + bool isLoading = false; + bool isSereverIssue = false; + List pharmaciesList = []; + List FilteredList = []; + + PickResult? selectedPlace; + + bool _mapsInitialized = false; + final String _mapsRenderer = "latest"; + + var kInitialPosition = const LatLng(15.462477, 78.717401); + + locationmap.Location location = locationmap.Location(); + + final GoogleMapsFlutterPlatform mapsImplementation = + GoogleMapsFlutterPlatform.instance; + + void initRenderer() { + if (_mapsInitialized) return; + if (mapsImplementation is GoogleMapsFlutterAndroid) { + switch (_mapsRenderer) { + case "legacy": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.legacy); + break; + case "latest": + (mapsImplementation as GoogleMapsFlutterAndroid) + .initializeWithRenderer(AndroidMapRenderer.latest); + break; + } + } + setState(() { + _mapsInitialized = true; + }); + } + + Future getAllPharmaciesData(var distance) async { + isLoading = true; + selectedPharmacies=[]; + try { + var pharmacyResponse = await AppSettings.getAllpharmacies(); + + setState(() { + pharmaciesList = ((jsonDecode(pharmacyResponse)['data']) as List) + .map((dynamic model) { + return PharmaciesModel.fromJson(model); + }).toList(); + FilteredList = []; + pharmaciesList.forEach((element) async { + var distanceInM; + if (distance == '2') { + distanceInM = 2000; + } else if (distance == '5') { + distanceInM = 5000; + } else if (distance == '10') { + distanceInM = 10000; + } else if (distance == '25') { + distanceInM = 25000; + } else if (distance == '50') { + distanceInM = 50000; + } else if (distance == '100') { + distanceInM = 100000; + } + double distanceInMeters = await Geolocator.distanceBetween( + element.lat, element.lng, lat, lng); + if (distanceInMeters <= distanceInM) { + FilteredList.add(element); + } + }); + + isLoading = false; + }); + } catch (e) { + setState(() { + isLoading = false; + isSereverIssue = true; + }); + } + } + + + + showSelectedPharmaciesDialog(){ + return showDialog( + barrierDismissible: false, + context: context, + builder: (BuildContext context) { + return StatefulBuilder(builder: (context, setState) { + return AlertDialog( + title: Text('Selected Pharmacies'), + content: Container( + height: MediaQuery.of(context).size.height * .50, + width: MediaQuery.of(context).size.width * .70, + child:ListView.separated( + separatorBuilder: (context, index) => const Divider(height: 4.0,color: Colors.black,), + itemCount: selectedPharmacies.length, + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: CheckboxListTile( + title: Padding( + padding: EdgeInsets.fromLTRB(0, 10, 0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + /*Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: selectedPharmacies[index].picture == '' + ? AssetImage("images/logo.png") + : NetworkImage( + selectedPharmacies[index].picture) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + SizedBox( + width: 5, + ),*/ + Expanded( + child: Container( + width: MediaQuery.of(context).size.width * .70, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + selectedPharmacies[index] + .pharmacy_name + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + selectedPharmacies[index] + .contact_number + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + selectedPharmacies[index] + .pharmacy_address + .toUpperCase(), + style: wrapTextStyleBlack()), + Visibility( + visible: + selectedPharmacies[index].description != '', + child: SizedBox( + height: 10, + ), + ), + Visibility( + visible: + selectedPharmacies[index].description != '', + child: Text( + selectedPharmacies[index] + .description + .toUpperCase(), + style: wrapTextStyleBlack()), + ), + SizedBox( + height: 10, + ), + ], + )), + ), + ], + )), + checkColor: Colors.white, + activeColor: primaryColor, + value: selectedPharmacies[index].isPharmacyInDialogChecked, + onChanged: (val) { + setState( + () { + selectedPharmacies[index].isPharmacyInDialogChecked = val!; + }, + ); + if (selectedPharmacies[index].isPharmacyInDialogChecked) { + pharmaciesCheckboxesInDialog.add({ + 'pharmacyId': selectedPharmacies[index].pharmacy_id, + }); + } else { + pharmaciesCheckboxesInDialog.removeWhere((e) => + e['pharmacyId'].toString().toUpperCase() == + selectedPharmacies[index] + .pharmacy_id + .toString() + .toUpperCase()); + } + }, + ), + ); + }, + ), + ), + actions: [ + + Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + padding: const EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async{ + Navigator.pop(context); + }, + child: const Text('Cancel'), + ), + SizedBox(width: 10,), + ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async{ + if(pharmaciesCheckboxesInDialog.length==3){ + AppSettings.preLoaderDialog(context); + var payload = new Map(); + + payload["picture"] = widget.prescriptionDetails[0]['url'].toString(); + payload["pharmacies"] = pharmaciesCheckboxesInDialog; + payload["familyDetails"] = { + "patient_name": widget.familyDetails.patient_name.toString(), + "patient_age": int.parse(widget.familyDetails.age.toString()), + "patient_gender": widget.familyDetails.gender, + "patient_address": userAddress + }; + bool status = await AppSettings.getQuotation(payload); + + if(status){ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast('Quotation request sent successfully'); + pharmaciesCheckboxesInDialog.clear(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const GetQuotationRequestsList()), + ); + } + else{ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast('Get quotation failed try after some time'); + } + + + } + else if(pharmaciesCheckboxesInDialog.length>3){ + AppSettings.longFailedToast('Please select only three pharmacies to get quotation'); + } + else{ + AppSettings.longFailedToast('Please select at least three pharmacies to get quotation'); + } + + + }, + child: const Text('Get quote'), + ) + ], + )), + + + ], + ); + }); + + }); + } + + Widget setupAlertDialoadContainer() { + return Container( + height: MediaQuery.of(context).size.height * .50, + width: MediaQuery.of(context).size.width * .70, + child:ListView.separated( + separatorBuilder: (context, index) => const Divider(height: 4.0,color: Colors.black,), + itemCount: selectedPharmacies.length, + itemBuilder: (BuildContext context, int index) { + return ListTile( + title: Padding( + padding: EdgeInsets.fromLTRB(0, 0, 0, 0), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: selectedPharmacies[index].picture == '' + ? AssetImage("images/logo.png") + : NetworkImage( + selectedPharmacies[index].picture) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + SizedBox( + width: 5, + ), + Expanded( + child: Container( + width: MediaQuery.of(context).size.width * .70, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + selectedPharmacies[index] + .pharmacy_name + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + selectedPharmacies[index] + .contact_number + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + selectedPharmacies[index] + .pharmacy_address + .toUpperCase(), + style: wrapTextStyleBlack()), + Visibility( + visible: + selectedPharmacies[index].description != '', + child: SizedBox( + height: 10, + ), + ), + Visibility( + visible: + selectedPharmacies[index].description != '', + child: Text( + selectedPharmacies[index] + .description + .toUpperCase(), + style: wrapTextStyleBlack()), + ), + SizedBox( + height: 10, + ), + ], + )), + ), + ], + ), + Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + padding: const EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Visibility( + visible:selectedPharmacies[index].isPharmacyInDialogChecked==false, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async{ + selectedPharmacies[index].isPharmacyInDialogChecked=true; + }, + child: const Text('Select'), + ),), + SizedBox(width: 10,), + Visibility( + visible: selectedPharmacies[index].isPharmacyInDialogChecked==true, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: primaryColor, // background + onPrimary: Colors.white, // foreground + ), + onPressed: () async{ + + + }, + child: const Text('Deselect'), + )) + ], + )), + + ], + )), + ); + }, + ), + ); + } + + Widget _pharamciesData() { + if (FilteredList.length != 0) { + return + Container( + color: secondaryColor, + child: Column(crossAxisAlignment: CrossAxisAlignment.end, children: [ + Expanded( + child: GridView.builder( + itemCount: FilteredList.length, + itemBuilder: (context, index) { + return Card( + elevation: 2.0, + child: CheckboxListTile( + title: Padding( + padding: EdgeInsets.fromLTRB(0, 10, 0, 0), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: MediaQuery.of(context).size.width * .18, + height: MediaQuery.of(context).size.height * .10, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: FilteredList[index].picture == '' + ? AssetImage("images/logo.png") + : NetworkImage( + FilteredList[index].picture) + as ImageProvider, // picked file + fit: BoxFit.contain)), + ), + SizedBox( + width: 5, + ), + Expanded( + child: Container( + width: MediaQuery.of(context).size.width * .70, + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + FilteredList[index] + .pharmacy_name + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + FilteredList[index] + .contact_number + .toUpperCase(), + style: wrapTextStyleBlack()), + SizedBox( + height: 10, + ), + Text( + FilteredList[index] + .pharmacy_address + .toUpperCase(), + style: wrapTextStyleBlack()), + Visibility( + visible: + FilteredList[index].description != '', + child: SizedBox( + height: 10, + ), + ), + Visibility( + visible: + FilteredList[index].description != '', + child: Text( + FilteredList[index] + .description + .toUpperCase(), + style: wrapTextStyleBlack()), + ), + SizedBox( + height: 10, + ), + ], + )), + ), + ], + )), + checkColor: Colors.white, + activeColor: primaryColor, + value: FilteredList[index].isChecked, + onChanged: (val) { + setState( + () { + FilteredList[index].isChecked = val!; + }, + ); + if (FilteredList[index].isChecked) { + pharmaciesCheckboxes.add({ + 'pharmacyId': FilteredList[index].pharmacy_id, + }); + selectedPharmacies.add(FilteredList[index]); + } else { + pharmaciesCheckboxes.removeWhere((e) => + e['pharmacyId'].toString().toUpperCase() == + FilteredList[index] + .pharmacy_id + .toString() + .toUpperCase()); + selectedPharmacies.remove(FilteredList[index]); + } + }, + ), + ); + }, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 1, //.size.width * .33, + childAspectRatio: MediaQuery.of(context).size.width / + (MediaQuery.of(context).size.height / 7)), + ), + ), + Padding( + padding: EdgeInsets.all(0), + child: Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .06, + child: ElevatedButton( + style: ElevatedButton.styleFrom( + primary: buttonColors, // background + onPrimary: Colors.black, // foreground + ), + onPressed: () async { + + + if(pharmaciesCheckboxes.length==3){ + AppSettings.preLoaderDialog(context); + var payload = new Map(); + + payload["picture"] = widget.prescriptionDetails[0]['url'].toString(); + payload["pharmacies"] = pharmaciesCheckboxes; + payload["familyDetails"] = { + "patient_name": widget.familyDetails.patient_name.toString()??'', + "patient_age": int.parse(widget.familyDetails.age.toString())??0, + "patient_gender": widget.familyDetails.gender.toString().toLowerCase()??'', + "patient_address": userAddress??'' + }; + bool status = await AppSettings.getQuotation(payload); + + if(status){ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longSuccessToast('Quotation request sent successfully'); + pharmaciesCheckboxes.clear(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const GetQuotationRequestsList()), + ); + } + else{ + Navigator.of(context, rootNavigator: true).pop(); + AppSettings.longFailedToast('Get quotation failed try after some time'); + } + + } + else if(pharmaciesCheckboxes.length>3){ + + showSelectedPharmaciesDialog(); + + } + else{ + AppSettings.longFailedToast('Please select at least three pharmacies to get quotation'); + } + + + }, + child: Text('Get quote'), + )), + ), + ]), + ); + } + else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: isSereverIssue + ? Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image( + image: AssetImage('images/serverissue.png'), + // height: MediaQuery.of(context).size.height * .10, + ), + SizedBox( + height: 20, + ), + Text( + 'There is an issue at server please try after some time',style:serverIssueTextStyle() ,), + ], + ) + : userAddress==''?Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + /*Image( + image: AssetImage('images/resourceblue.pngs'), + // height: MediaQuery.of(context).size.height * .10, + ),*/ + Icon(Icons.location_on_outlined,color: primaryColor,size: 40,), + SizedBox( + height: 20, + ), + Text( + 'Please select location to see near by tankers',style:TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ),), + ], + ): + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + /*Image( + image: AssetImage('images/resourceblue.pngs'), + // height: MediaQuery.of(context).size.height * .10, + ),*/ + Icon( + Icons.info, + color: primaryColor, + size: 40, + ), + SizedBox( + height: 20, + ), + Text( + 'No pharmacies near to your selected locaton', + style: TextStyle( + color: primaryColor, + fontWeight: FontWeight.bold, + ), + ), + ], + ) + )); + } + } + + @override + void initState() { + lat = AppSettings.userLatitude; + lng = AppSettings.userLongitude; + userAddress = AppSettings.userAddress; + getAllPharmaciesData(dropdownArea); + super.initState(); + } + + + Widget prescriptions(var obj){ + + return Container( + width: double.infinity, + height: MediaQuery.of(context).size.height * .20, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: obj.length, + itemBuilder: (context, index) { + return Column( + children: [ + Card( + child: GestureDetector( + onTap: (){ + //showPicDialog(obj.prescriptionImages[index]['url']); + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj[index]['url']))); + + + + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: NetworkImage( + obj[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + ), + ), + ), + /*Expanded(child:IconButton( + icon: const Icon(Icons.remove,color: Colors.red,), + + onPressed: () async{ + + }, + ),)*/ + ], + ); + }), + ); + + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppSettings.appBar('Order Medicines'), + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.all(10), + child: prescriptions(widget.prescriptionDetails),), + Padding( + padding: EdgeInsets.all(10), + child: Row( + children: [ + TextButton( + onPressed: () {}, + child: const Text( + 'Want to order non prescribed items?', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + )), + SizedBox(width: 5,), + TextButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const GetQuotationRequestsList()), + ); + }, + child: const Text( + 'Requests', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + )), + ], + ) + ), + Padding( + padding: EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Your address', + style: labelTextStyle(), + ), + Text( + userAddress, + style: valuesTextStyle(), + ), + Row( + children: [ + TextButton( + child: const Text( + 'Change', + style: TextStyle( + fontSize: 15, + decoration: TextDecoration.underline, + color: primaryColor), + ), + onPressed: () { + location.serviceEnabled().then((value) { + if (value) { + initRenderer(); + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return PlacePicker( + resizeToAvoidBottomInset: false, + hintText: "Find a place ...", + searchingText: "Please wait ...", + selectText: "Select place", + outsideOfPickAreaText: + "Place not in area", + initialPosition: kInitialPosition, + useCurrentLocation: true, + selectInitialPosition: true, + usePinPointingSearch: true, + usePlaceDetailSearch: true, + zoomGesturesEnabled: true, + zoomControlsEnabled: true, + onMapCreated: (GoogleMapController + controller) {}, + onPlacePicked: (PickResult result) { + setState(() { + selectedPlace = result; + lat = selectedPlace! + .geometry!.location.lat; + lng = selectedPlace! + .geometry!.location.lng; + if (selectedPlace! + .types!.length == + 1) { + userAddress = selectedPlace! + .formattedAddress!; + } else { + userAddress = selectedPlace! + .name! + + ', ' + + selectedPlace! + .formattedAddress!; + } + Navigator.of(context).pop(); + getAllPharmaciesData( + dropdownArea); + }); + }, + onMapTypeChanged: + (MapType mapType) {}, + apiKey: Platform.isAndroid + ? APIKeys.androidApiKey + : APIKeys.iosApiKey, + forceAndroidLocationManager: true, + ); + }, + ), + ); + } else { + showGeneralDialog( + context: context, + pageBuilder: (context, x, y) { + return Scaffold( + backgroundColor: + Colors.grey.withOpacity(.5), + body: Center( + child: Container( + width: double.infinity, + height: 150, + padding: + const EdgeInsets.symmetric( + horizontal: 20), + child: Card( + child: Padding( + padding: const EdgeInsets.all( + 10.0), + child: Column( + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + const Text( + "Please enable the location", + style: TextStyle( + fontSize: 18, + fontWeight: + FontWeight.w500, + ), + ), + const SizedBox( + height: 20, + ), + ElevatedButton( + onPressed: () { + Navigator.pop( + context); + }, + child: const Text( + "Cancel"), + ), + ], + ), + ), + ), + ), + ), + ); + }, + ); + } + }); + }, + ), + Icon( + Icons.location_on_outlined, + color: primaryColor, + size: 20, + ), + ], + ) + ], + ), + ), + Expanded( + child: Container( + height: MediaQuery.of(context).size.height * .09, + padding: const EdgeInsets.fromLTRB(10, 10, 0, 0), + child: DropdownButtonFormField( + value: dropdownArea, + isExpanded: true, + decoration: const InputDecoration( + prefixIcon: Icon( + Icons.location_on_outlined, + color: primaryColor, + ), + border: OutlineInputBorder( + borderSide: BorderSide(color: greyColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: greyColor), + ), + labelText: 'distance', + labelStyle: TextStyle( + color: greyColor, //<-- SEE HERE + ), + ), + + hint: Text('Select Area'), + // Down Arrow Icon + icon: const Icon(Icons.keyboard_arrow_down), + + // Array list of items + items: AreaItems.map((String items) { + return DropdownMenuItem( + value: items, + child: Text(items), + ); + }).toList(), + // After selecting the desired option,it will + // change button value to selected value + onChanged: (String? newValue) { + setState(() { + dropdownArea = newValue!; + }); + getAllPharmaciesData(dropdownArea); + }, + ), + ), + ) + ], + ), + ), + Expanded( + child: isLoading + ? Center( + child: CircularProgressIndicator( + color: primaryColor, + strokeWidth: 5.0, + ), + ) + : _pharamciesData(), + ) + ], + )); + } +} diff --git a/lib/Reports/prescription_images.dart b/lib/Reports/prescription_images.dart new file mode 100644 index 0000000..edb1b47 --- /dev/null +++ b/lib/Reports/prescription_images.dart @@ -0,0 +1,283 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:healthcare_user/Reports/allreports.dart'; +import 'package:healthcare_user/Reports/order_medicines_new.dart'; +import 'package:healthcare_user/common/settings.dart'; +import 'package:healthcare_user/common/zoom_image.dart'; +import 'package:healthcare_user/prescriptions/oreder_medicines.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; + +class PrescriptionImages extends StatefulWidget { + var imageDetails; + var recordId; + var familyDetails; + + PrescriptionImages({this.imageDetails, this.recordId,this.familyDetails}); + + @override + State createState() => _PrescriptionImagesState(); +} + +class _PrescriptionImagesState extends State { + final ImagePicker imagePicker = ImagePicker(); + List imageFileList = []; + List uiPrescriptionImages = []; + + Future pickImageFromGallery() async { + imageFileList = []; + final List? selectedImages = await imagePicker.pickMultiImage(); + AppSettings.preLoaderDialog(context); + if (selectedImages!.isNotEmpty) { + imageFileList.addAll(selectedImages); + } + + var res = await AppSettings.uploadImageForPrescriptions(imageFileList); + print(jsonDecode(res)); + Navigator.of(context, rootNavigator: true).pop(); + setState(() { + widget.imageDetails = jsonDecode(res)['findings']; + }); + } + + Widget renderUi() { + if (widget.imageDetails.length != 0) { + return Column( + children: [ + Expanded( + child: GridView.builder( + itemCount: widget.imageDetails.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 2.0, + mainAxisSpacing: 2.0, + ), + itemBuilder: (BuildContext context, int index) { + return GestureDetector( + onTap: () { + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new ImageZoomPage( + imageName: 'Prescripitons', + imageDetails: widget.imageDetails[index] + ['url']))); + /*gridOntap(index);*/ + }, + child: Container( + width: MediaQuery.of(context).size.width * .30, + height: MediaQuery.of(context).size.height * .15, + decoration: BoxDecoration( + shape: BoxShape.rectangle, + image: DecorationImage( + image: + NetworkImage(widget.imageDetails[index]['url']) + as ImageProvider, // picked file + fit: BoxFit.fill)), + child: Stack(children: [ + Positioned( + right: 0, + child: Container( + child: IconButton( + iconSize: 30, + icon: const Icon( + Icons.cancel, + color: Colors.red, + ), + onPressed: () async { + AppSettings.preLoaderDialog(context); + + String fileName = widget.imageDetails[index] + ['url'] + .split('/') + .last; + + var payload = new Map(); + payload["urlType"] = 'prescriptions'; + payload["url"] = + widget.imageDetails[index]['url']; + + bool deleteStatus = + await AppSettings.deleteRecords( + payload, widget.recordId); + + if (deleteStatus) { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longSuccessToast( + "Image deleted Successfully"); + //AllReportsState().getAllRecords(); + Navigator.pop(context); + } else { + Navigator.of(context, rootNavigator: true) + .pop(); + AppSettings.longFailedToast( + "Image deletion failed"); + } + }, + ), + ), + ) + ]), + ), + + //Image.network(widget.imageDetails[index]['url']), + ); + }, + ), + ), + TextButton( + child: const Text( + 'Order Medicines', + style: TextStyle(color: primaryColor), + ), + onPressed: () { + + Navigator.push( + context, + new MaterialPageRoute( + builder: (__) => new OrderMedicinesPrescriptions(prescriptionDetails:widget.imageDetails,familyDetails: widget.familyDetails,))); + //signup screen + }, + ) + + ], + ); + } else { + return Center( + child: Padding( + padding: EdgeInsets.fromLTRB(0, 40, 0, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: MediaQuery.of(context).size.height * .25, + ), + Text('Click below icon to add new Prescriptions'), + SizedBox( + height: 20, + ), + CircleAvatar( + backgroundColor: primaryColor, + radius: 40, + child: IconButton( + iconSize: 40, + icon: const Icon( + Icons.add, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + //await takeImageFromCamera(); + Navigator.pop(context); + }, + ), + SizedBox( + width: + MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + )); + } + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + backgroundColor: primaryColor, + title: Text("Prescriptions"), + actions: [ + Visibility( + visible: widget.imageDetails.length > 0, + child: IconButton( + iconSize: 30, + icon: Icon( + Icons.add_task, + color: Colors.white, + ), + onPressed: () async { + showModalBottomSheet( + context: context, + builder: (BuildContext context) { + return SizedBox( + height: 200, + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + child: Icon( + Icons.camera_alt_outlined, + size: 100, + color: primaryColor, + ), + onTap: () async { + //await takeImageFromCamera(); + Navigator.pop(context); + }, + ), + SizedBox( + width: MediaQuery.of(context).size.width * .20, + ), + GestureDetector( + child: Icon( + Icons.photo, + size: 100, + color: primaryColor, + ), + onTap: () async { + await pickImageFromGallery(); + Navigator.pop(context); + }, + ), + ], + ), + ), + ); + }); + }, + ), + ) + ], + ), + body: Container(padding: EdgeInsets.all(12.0), child: renderUi()), + ); + } +} diff --git a/lib/Reports/report_images.dart b/lib/Reports/report_images.dart index 4dee705..d970ab4 100644 --- a/lib/Reports/report_images.dart +++ b/lib/Reports/report_images.dart @@ -11,6 +11,8 @@ class ReportImages extends StatefulWidget { } class _ReportImagesState extends State { + + Widget renderUi() { if(widget.imageDetails.length!=0){ @@ -51,7 +53,12 @@ class _ReportImagesState extends State { Icons.cancel, color: Colors.red, ), - onPressed: () async {}, + onPressed: () async { + + + + + }, ), /* color: Colors.pinkAccent, width: 35, @@ -107,7 +114,24 @@ class _ReportImagesState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppSettings.appBar('Report Images'), + appBar:AppBar( + backgroundColor: primaryColor, + title: Text("Report Images"), + actions: [ + Visibility( + visible: widget.imageDetails.length>0, + child: IconButton( + iconSize: 30, + icon: Icon( + Icons.add_task, + color: Colors.white, + ), + onPressed: () async { + + }, + ),) + ], + ), body: Container(padding: EdgeInsets.all(12.0), child: renderUi()), ); } diff --git a/lib/common/dashboard.dart b/lib/common/dashboard.dart index 4e7648c..ed8b3a4 100644 --- a/lib/common/dashboard.dart +++ b/lib/common/dashboard.dart @@ -491,7 +491,7 @@ class _DashboardState extends State { TextButton( child: Text('Yes', style: textButtonStyle()), onPressed: () async { - await AppSettings.clearSharedPreferences(); + await AppSettings.clearSharedPrefeences(); await Navigator.pushAndRemoveUntil( context, MaterialPageRoute(builder: (context) => Login()), diff --git a/lib/common/settings.dart b/lib/common/settings.dart index d905300..fd63d22 100644 --- a/lib/common/settings.dart +++ b/lib/common/settings.dart @@ -238,6 +238,7 @@ class AppSettings { static String getMedicineTimingsUrl = host + 'getmedicineztiming'; static String prescriptionUploadPicUrl = host + 'uploads-precription'; static String findingsUploadPicUrl = host + 'uploads-findings-prescription'; + static String updateFindingsUploadPicUrl = host + 'update-uploads-findings-prescription'; static String reportsUploadPicUrl = host + 'uploads-reports-prescription'; static String recordPrescriptionsUploadPicUrl = host + 'uploads-prescription-prescription'; static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist'; @@ -248,9 +249,11 @@ class AppSettings { static String reportMySelfVideoUploadUrl = host + 'reportProblemVideo'; //static String getAllPrescriptionsDataUrl = host + 'usersinglerprecription'; static String getAllPrescriptionsDataUrl = host + 'getAllPrescriptionDetails'; - static String getRecordsDataUrl = host + 'getAllRecords'; static String deleteRecordUrl = host + 'deleteRecord'; + static String deleteFindingsUrl = host + 'uploads-findings-prescription'; + static String deleteRecordsUrl = host + 'delete-url'; + @@ -334,7 +337,7 @@ class AppSettings { } } - static clearSharedPreferences() async { + static clearSharedPrefeences() async { sharedPreferences = await SharedPreferences.getInstance(); await sharedPreferences.clear(); } @@ -731,6 +734,37 @@ class AppSettings { return response.body; } + + static Future uploadImageForFindingsFromCamera(file) async { + var request = http.MultipartRequest('POST', Uri.parse(findingsUploadPicUrl + '/' + customerId)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + + static Future uploadImageForFindingsUpdate(file,var recordId) async { + + var request = http.MultipartRequest( + 'POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId)); + if (file.length > 0) { + for (var i = 0; i < file.length; i++) { + request.files.add(await http.MultipartFile.fromPath('picture', file[i].path)); + }} + // request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']',''))); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + + static Future uploadImageForFindingsUpdateFromCamera(file,var recordId) async { + var request = http.MultipartRequest('POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId)); + request.files.add(await http.MultipartFile.fromPath('picture', file.path)); + var res = await request.send(); + var response = await http.Response.fromStream(res); + return response.body; + } + static Future uploadImageForReports(file) async { var request = http.MultipartRequest( @@ -1052,6 +1086,71 @@ class AppSettings { } } + + static Future deleteFindings(fileName) async { + var uri = Uri.parse(deleteFindingsUrl + '/' + customerId+'/'+fileName); + + try { + var response = await http.delete(uri, headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + return true; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.delete(uri, headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } catch (e) { + print(e); + return false; + } + } + + + static Future deleteRecords(payload, recordId) async { + var uri = Uri.parse(deleteRecordsUrl + '/' + customerId+'/'+recordId); + + try { + var response = await http.post(uri, body: json.encode(payload),headers: await buildRequestHeaders()); + + if (response.statusCode == 200) { + return true; + } else if (response.statusCode == 401) { + bool status = await AppSettings.resetToken(); + if (status) { + response = await http.delete(uri, headers: await buildRequestHeaders()); + if (response.statusCode == 200) { + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } + } catch (e) { + print(e); + return false; + } + } + + + + + + /*Apis ends here*/ //save data local