You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
527 lines
20 KiB
527 lines
20 KiB
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/report_images.dart';
|
|
import 'package:healthcare_user/common/settings.dart';
|
|
import 'package:healthcare_user/common/zoom_image.dart';
|
|
import 'package:healthcare_user/models/reports_model.dart';
|
|
import 'package:photo_view/photo_view.dart';
|
|
|
|
class AllReports extends StatefulWidget {
|
|
const AllReports({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<AllReports> createState() => _AllReportsState();
|
|
}
|
|
|
|
class _AllReportsState extends State<AllReports> {
|
|
|
|
|
|
List<ReportsModel> reportsList = [];
|
|
List<ReportsModel> reportsListOriginal = [];
|
|
bool isReportsDataLoading = false;
|
|
bool isSereverIssue = false;
|
|
|
|
Future<void> gaetAllRecords() async {
|
|
isReportsDataLoading=true;
|
|
try {
|
|
var response = await AppSettings.getAllRecords();
|
|
|
|
setState(() {
|
|
reportsListOriginal = ((jsonDecode(response)) as List)
|
|
.map((dynamic model) {
|
|
return ReportsModel.fromJson(model);
|
|
}).toList();
|
|
reportsList=reportsListOriginal.reversed.toList();
|
|
isReportsDataLoading = false;
|
|
});
|
|
} catch (e) {
|
|
setState(() {
|
|
isReportsDataLoading = false;
|
|
isSereverIssue = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
gaetAllRecords();
|
|
super.initState();
|
|
}
|
|
|
|
|
|
showPicDialog(var imageUrl){
|
|
return showDialog(
|
|
context: context,
|
|
barrierDismissible: false,
|
|
builder: (BuildContext context) {
|
|
return StatefulBuilder(
|
|
builder: (BuildContext context, StateSetter setState) {
|
|
return AlertDialog(
|
|
title: const Text(''),
|
|
content: SingleChildScrollView(
|
|
child: ListBody(
|
|
children: <Widget>[
|
|
Container(
|
|
width: MediaQuery.of(context).size.width * .10,
|
|
height: MediaQuery.of(context).size.height * .50,
|
|
child: PhotoView(
|
|
imageProvider: NetworkImage(imageUrl) as ImageProvider,
|
|
maxScale: PhotoViewComputedScale.contained * 4.0,
|
|
minScale: PhotoViewComputedScale.contained,
|
|
initialScale: PhotoViewComputedScale.contained,
|
|
basePosition: Alignment.center,
|
|
|
|
)
|
|
)
|
|
],
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text('Close', style: textButtonStyle()),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
});
|
|
},
|
|
);
|
|
}
|
|
|
|
|
|
Widget findings(var obj){
|
|
return Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * .20,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: obj.findingsImages.length,
|
|
itemBuilder: (context, index) {
|
|
return Column(
|
|
children: [
|
|
Card(
|
|
child: GestureDetector(
|
|
onTap: (){
|
|
/*showPicDialog(obj.findingsImages[index]['url']);*/
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:obj.findingsImages[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.findingsImages[index]['url'])
|
|
as ImageProvider, // picked file
|
|
fit: BoxFit.fill)),
|
|
),
|
|
),
|
|
),
|
|
/*Expanded(child:IconButton(
|
|
icon: const Icon(Icons.remove,color: Colors.red,),
|
|
|
|
onPressed: () async{
|
|
|
|
},
|
|
),)*/
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
|
|
Widget reports(var obj){
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * .20,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: obj.reportImages.length,
|
|
itemBuilder: (context, index) {
|
|
return Column(
|
|
children: [
|
|
Card(
|
|
child: GestureDetector(
|
|
onTap: (){
|
|
//showPicDialog(obj.reportImages[index]['url']);
|
|
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:obj.reportImages[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.reportImages[index]
|
|
['url'])
|
|
as ImageProvider, // picked file
|
|
fit: BoxFit.fill)),
|
|
),
|
|
),
|
|
),
|
|
/*Expanded(child:IconButton(
|
|
icon: const Icon(Icons.remove,color: Colors.red,),
|
|
|
|
onPressed: () async{
|
|
|
|
},
|
|
),)*/
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
|
|
}
|
|
|
|
Widget prescriptions(var obj){
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
height: MediaQuery.of(context).size.height * .20,
|
|
child: ListView.builder(
|
|
scrollDirection: Axis.horizontal,
|
|
itemCount: obj.prescriptionImages.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.prescriptionImages[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.prescriptionImages[index]
|
|
['url'])
|
|
as ImageProvider, // picked file
|
|
fit: BoxFit.fill)),
|
|
),
|
|
),
|
|
),
|
|
/*Expanded(child:IconButton(
|
|
icon: const Icon(Icons.remove,color: Colors.red,),
|
|
|
|
onPressed: () async{
|
|
|
|
},
|
|
),)*/
|
|
],
|
|
);
|
|
}),
|
|
);
|
|
|
|
}
|
|
|
|
|
|
Widget _allreports(){
|
|
|
|
if(reportsList.length!=0){
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
Expanded(child:ListView.builder(
|
|
padding: EdgeInsets.all(0),
|
|
itemCount: reportsList.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
return Card(
|
|
|
|
//color: prescriptionsList[index].cardColor,
|
|
child: Padding(
|
|
padding:EdgeInsets.all(8) ,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
|
|
Container(
|
|
width: MediaQuery.of(context).size.width * .55,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('Problem: '+reportsList[index].problem.toString().toUpperCase(),style: problemTextStyle()),
|
|
Text(reportsList[index].doctorName.toString().toUpperCase(),style: valuesTextStyle()),
|
|
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()),
|
|
],
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Expanded(child:IconButton(
|
|
icon: const Icon(Icons.edit,color: primaryColor,),
|
|
onPressed: () {
|
|
|
|
|
|
},
|
|
),),
|
|
Expanded(child:IconButton(
|
|
icon: const Icon(Icons.delete,color: primaryColor,),
|
|
|
|
onPressed: () async{
|
|
showDialog(
|
|
//if set to true allow to close popup by tapping out of the popup
|
|
//barrierDismissible: false,
|
|
context: context,
|
|
builder: (BuildContext context) => AlertDialog(
|
|
title: const Text('Do you want to delete Record?',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 20,
|
|
)),
|
|
actionsAlignment: MainAxisAlignment.spaceBetween,
|
|
actions: [
|
|
TextButton(
|
|
onPressed: ()async {
|
|
|
|
bool deleteTankStatus = await AppSettings.deleteRecord(reportsList[index].recordId);
|
|
|
|
|
|
if(deleteTankStatus){
|
|
gaetAllRecords();
|
|
AppSettings.longSuccessToast('Record deleted successfully');
|
|
Navigator.of(context).pop(true);
|
|
|
|
}
|
|
else{
|
|
AppSettings.longFailedToast('Record deletion failed');
|
|
Navigator.of(context).pop(true);
|
|
}
|
|
},
|
|
child: const Text('Yes',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 20,
|
|
)),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop(true);
|
|
},
|
|
child: const Text('No',
|
|
style: TextStyle(
|
|
color: primaryColor,
|
|
fontSize: 20,
|
|
)),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
|
|
|
|
},
|
|
),)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Row(
|
|
children: [
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: primaryColor, // background
|
|
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)));
|
|
},
|
|
child: Text('Findings: '+reportsList[index].findingsImages.length.toString()),
|
|
),
|
|
SizedBox(
|
|
width:MediaQuery.of(context).size.width * .05,
|
|
),
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: primaryColor, // background
|
|
onPrimary: Colors.white, // foreground
|
|
),
|
|
onPressed: () async {
|
|
Navigator.push(
|
|
context,
|
|
new MaterialPageRoute(
|
|
builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages)));
|
|
|
|
},
|
|
child: Text('Reports: '+reportsList[index].reportImages.length.toString()),
|
|
),
|
|
SizedBox(
|
|
width:MediaQuery.of(context).size.width * .05,
|
|
),
|
|
ElevatedButton(
|
|
style: ElevatedButton.styleFrom(
|
|
primary: primaryColor, // background
|
|
onPrimary: Colors.white, // foreground
|
|
),
|
|
onPressed: () async {
|
|
},
|
|
child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString()),
|
|
),
|
|
],
|
|
),
|
|
|
|
|
|
|
|
Visibility(
|
|
visible: false,
|
|
child: Text('Findings',style: headingsTextStyle()),),
|
|
Visibility(
|
|
visible: false,
|
|
child: findings(reportsList[index])),
|
|
Visibility(
|
|
visible: false,
|
|
child: Text('Reports',style: headingsTextStyle()),),
|
|
Visibility(
|
|
visible: false,
|
|
child:reports(reportsList[index]) ),
|
|
Visibility(
|
|
visible: false,
|
|
child: Text('Prescriptions',style: headingsTextStyle()),),
|
|
Visibility(
|
|
visible:false,
|
|
child:prescriptions(reportsList[index]) ),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}) ),
|
|
Padding(
|
|
padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
|
|
child: CircleAvatar(
|
|
backgroundColor: primaryColor,
|
|
radius: 40,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
IconButton(
|
|
iconSize: 40,
|
|
icon: const Icon(
|
|
Icons.add,
|
|
color: Colors.white,
|
|
),
|
|
onPressed: () async{
|
|
/*await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (context) => AddPrescription()),
|
|
);*/
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
|
|
gaetAllRecords();
|
|
});
|
|
//showBoreAddingDialog();
|
|
},
|
|
),
|
|
/* Padding(
|
|
padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
|
|
child: Text(
|
|
'Add Tanks ',
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
)*/
|
|
],
|
|
),
|
|
),
|
|
),
|
|
]);
|
|
}
|
|
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 Record'),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
CircleAvatar(
|
|
backgroundColor: primaryColor,
|
|
radius: 40,
|
|
child: IconButton(
|
|
iconSize: 40,
|
|
icon: const Icon(
|
|
Icons.add,
|
|
color: Colors.white,
|
|
),
|
|
onPressed: () async {
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
|
|
gaetAllRecords();
|
|
});
|
|
},
|
|
),
|
|
)
|
|
],
|
|
),
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppSettings.appBar('Reports'),
|
|
body: isReportsDataLoading?Center(
|
|
child: CircularProgressIndicator(
|
|
color: primaryColor,
|
|
strokeWidth: 5.0,
|
|
),
|
|
): _allreports(),
|
|
);
|
|
}
|
|
}
|