parent
8c257cab86
commit
9630a77681
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 6.4 KiB |
@ -0,0 +1,674 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:multi_image_picker/multi_image_picker.dart';
|
||||
|
||||
class AddReports extends StatefulWidget {
|
||||
const AddReports({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<AddReports> createState() => _AddReportsState();
|
||||
}
|
||||
|
||||
class _AddReportsState extends State<AddReports> {
|
||||
TextEditingController doctorNameController = TextEditingController();
|
||||
TextEditingController hospitalNameController = TextEditingController();
|
||||
TextEditingController problemController = TextEditingController();
|
||||
TextEditingController dateInput = TextEditingController();
|
||||
TextEditingController patientNameController = TextEditingController();
|
||||
TextEditingController patientAgeController = TextEditingController();
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
String Url = '';
|
||||
final ImagePicker imagePicker = ImagePicker();
|
||||
List imageFileList = [];
|
||||
List imageFileListReports = [];
|
||||
List imageFileListPrescriptions = [];
|
||||
List uiFindingsImages = [];
|
||||
List uiReportsImages = [];
|
||||
List uiPrescriptionImages = [];
|
||||
|
||||
List<Asset> images = <Asset>[];
|
||||
String _error = 'No Error Dectected';
|
||||
String apiMultiImages = '';
|
||||
String? prescriptionFor;
|
||||
String? gender;
|
||||
|
||||
Future pickImageFromGallery() async {
|
||||
imageFileList = [];
|
||||
final List<XFile>? 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(() {
|
||||
uiFindingsImages = 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.uploadImageForFindingsCamera(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
uiFindingsImages = jsonDecode(res)['findings'];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future takeImageFromCameraForReports() 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.uploadImageForFindingsCamera(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
uiReportsImages = jsonDecode(res)['findings'];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future pickImageFromGalleryForReports() async {
|
||||
imageFileListReports = [];
|
||||
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
|
||||
AppSettings.preLoaderDialog(context);
|
||||
if (selectedImages!.isNotEmpty) {
|
||||
imageFileListReports.addAll(selectedImages);
|
||||
}
|
||||
|
||||
var res = await AppSettings.uploadImageForReports(imageFileListReports);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
uiReportsImages = jsonDecode(res)['reports'];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Future takeImageFromCameraForPrescriptions() 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.uploadImageForFindingsCamera(image);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
uiFindingsImages = jsonDecode(res)['findings'];
|
||||
});
|
||||
} on PlatformException catch (e) {
|
||||
print('Failed to pick image: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future pickImageFromGalleryForPrescriptions() async {
|
||||
imageFileListPrescriptions = [];
|
||||
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
|
||||
AppSettings.preLoaderDialog(context);
|
||||
if (selectedImages!.isNotEmpty) {
|
||||
imageFileListPrescriptions.addAll(selectedImages);
|
||||
}
|
||||
|
||||
var res = await AppSettings.uploadImageForPrescriptions(imageFileListPrescriptions);
|
||||
print(jsonDecode(res));
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
setState(() {
|
||||
uiPrescriptionImages = jsonDecode(res)['precription'];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Reports'),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: doctorNameController,
|
||||
textCapitalization: TextCapitalization.words,
|
||||
decoration: textFormFieldDecoration(
|
||||
Icons.person, 'Enter Doctor name'),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * .02,
|
||||
),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: hospitalNameController,
|
||||
textCapitalization: TextCapitalization.words,
|
||||
decoration: textFormFieldDecoration(
|
||||
Icons.location_city_outlined, 'Enter Hospital name'),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * .02,
|
||||
),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: problemController,
|
||||
textCapitalization: TextCapitalization.words,
|
||||
decoration: textFormFieldDecoration(
|
||||
Icons.report_problem, 'Enter Problem'),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: MediaQuery.of(context).size.height * .02,
|
||||
),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: dateInput,
|
||||
decoration: textFormFieldDecoration(
|
||||
Icons.calendar_today, 'Enter Date'),
|
||||
readOnly: true,
|
||||
onTap: () async {
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(1950),
|
||||
lastDate: DateTime.now(),
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Theme(
|
||||
data: ThemeData.dark().copyWith(
|
||||
colorScheme: ColorScheme.dark(
|
||||
primary: buttonColors,
|
||||
onPrimary: Colors.white,
|
||||
surface: buttonColors,
|
||||
onSurface: Colors.white,
|
||||
),
|
||||
dialogBackgroundColor: primaryColor,
|
||||
),
|
||||
child: child!,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (pickedDate != null) {
|
||||
print(
|
||||
pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
|
||||
String formattedDate =
|
||||
DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
print(
|
||||
formattedDate); //formatted date output using intl package => 2021-03-16
|
||||
setState(() {
|
||||
dateInput.text =
|
||||
formattedDate; //set output date to TextField value.
|
||||
});
|
||||
} else {}
|
||||
},
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("For Yourself"),
|
||||
value: "self",
|
||||
groupValue: prescriptionFor,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
prescriptionFor = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("For Family"),
|
||||
value: "others",
|
||||
groupValue: prescriptionFor,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
prescriptionFor = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
],
|
||||
),
|
||||
Visibility(
|
||||
visible:prescriptionFor.toString().toLowerCase()=='others' ,
|
||||
child: Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: patientNameController,
|
||||
decoration: textFormFieldDecoration(Icons.person,'Enter patient name'),
|
||||
|
||||
),
|
||||
),),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Visibility(
|
||||
visible:prescriptionFor.toString().toLowerCase()=='others' ,
|
||||
child: Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
keyboardType: TextInputType.number,
|
||||
controller: patientAgeController,
|
||||
decoration: textFormFieldDecoration(Icons.person,'Enter patient age'),
|
||||
|
||||
),
|
||||
),),
|
||||
Visibility(
|
||||
visible:prescriptionFor.toString().toLowerCase()=='others' ,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("Male",style: TextStyle(fontSize: 10)),
|
||||
value: "male",
|
||||
groupValue: gender,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
gender = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("Female",style: TextStyle(fontSize: 10),),
|
||||
value: "female",
|
||||
groupValue: gender,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
gender = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
Expanded(child: RadioListTile(
|
||||
title: Text("Others",style: TextStyle(fontSize: 10)),
|
||||
value: "other",
|
||||
groupValue: gender,
|
||||
activeColor: primaryColor,
|
||||
onChanged: (value){
|
||||
setState(() {
|
||||
gender = value.toString();
|
||||
});
|
||||
},
|
||||
),),
|
||||
],
|
||||
),),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: primaryColor, // background
|
||||
onPrimary: Colors.white, // foreground
|
||||
),
|
||||
onPressed: () async {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Text('Select Findings'),
|
||||
),
|
||||
Visibility(
|
||||
visible: uiFindingsImages.length > 0,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: MediaQuery.of(context).size.height * .20,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: uiFindingsImages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
children: [
|
||||
Card(
|
||||
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(
|
||||
uiFindingsImages[index]
|
||||
['url'])
|
||||
as ImageProvider, // picked file
|
||||
fit: BoxFit.fill)),
|
||||
),
|
||||
),
|
||||
/*Expanded(child:IconButton(
|
||||
icon: const Icon(Icons.remove,color: Colors.red,),
|
||||
|
||||
onPressed: () async{
|
||||
|
||||
},
|
||||
),)*/
|
||||
],
|
||||
);
|
||||
}),
|
||||
)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: primaryColor, // background
|
||||
onPrimary: Colors.white, // foreground
|
||||
),
|
||||
onPressed: () async {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.camera_alt_outlined,
|
||||
size: 100,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await takeImageFromCameraForReports();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width *
|
||||
.20,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.photo,
|
||||
size: 100,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await pickImageFromGalleryForReports();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Text('Select Reports'),
|
||||
),
|
||||
Visibility(
|
||||
visible: uiReportsImages.length > 0,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: MediaQuery.of(context).size.height * .20,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: uiReportsImages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
children: [
|
||||
Card(
|
||||
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(
|
||||
uiReportsImages[index]
|
||||
['url'])
|
||||
as ImageProvider, // picked file
|
||||
fit: BoxFit.fill)),
|
||||
),
|
||||
),
|
||||
/*Expanded(child:IconButton(
|
||||
icon: const Icon(Icons.remove,color: Colors.red,),
|
||||
|
||||
onPressed: () async{
|
||||
|
||||
},
|
||||
),)*/
|
||||
],
|
||||
);
|
||||
}),
|
||||
)),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
primary: primaryColor, // background
|
||||
onPrimary: Colors.white, // foreground
|
||||
),
|
||||
onPressed: () async {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 200,
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.camera_alt_outlined,
|
||||
size: 100,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await takeImageFromCameraForPrescriptions();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width *
|
||||
.20,
|
||||
),
|
||||
GestureDetector(
|
||||
child: Icon(
|
||||
Icons.photo,
|
||||
size: 100,
|
||||
color: primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
await pickImageFromGalleryForPrescriptions();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
child: const Text('Select Prescriptions'),
|
||||
),
|
||||
|
||||
Visibility(
|
||||
visible: uiPrescriptionImages.length > 0,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: MediaQuery.of(context).size.height * .20,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: uiPrescriptionImages.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
children: [
|
||||
Card(
|
||||
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(
|
||||
uiPrescriptionImages[index]
|
||||
['url'])
|
||||
as ImageProvider, // picked file
|
||||
fit: BoxFit.fill)),
|
||||
),
|
||||
),
|
||||
/*Expanded(child:IconButton(
|
||||
icon: const Icon(Icons.remove,color: Colors.red,),
|
||||
|
||||
onPressed: () async{
|
||||
|
||||
},
|
||||
),)*/
|
||||
],
|
||||
);
|
||||
}),
|
||||
)),
|
||||
|
||||
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(doctorNameController.text!=''&& problemController.text!=''&& dateInput.text!=''&&prescriptionFor!=''){
|
||||
|
||||
String _name='';
|
||||
String _age='';
|
||||
String? _gender='';
|
||||
|
||||
if(prescriptionFor.toString().toLowerCase()=='others'){
|
||||
if(patientNameController!=''&& patientAgeController.text!=''&&gender!=''){
|
||||
_name=patientNameController.text;
|
||||
_age=patientAgeController.text;
|
||||
_gender=gender;
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please enter details');
|
||||
}
|
||||
}
|
||||
else{
|
||||
_name=AppSettings.userName;
|
||||
_age=AppSettings.age;
|
||||
_gender=AppSettings.gender;
|
||||
}
|
||||
AppSettings.preLoaderDialog(context);
|
||||
bool isOnline = await AppSettings.internetConnectivity();
|
||||
if(isOnline){
|
||||
|
||||
var payload = new Map<String, dynamic>();
|
||||
payload["problem"] = problemController.text.toString();
|
||||
payload["doctorName"] = doctorNameController.text.toString();
|
||||
payload["hospitalName"] = hospitalNameController.text.toString();
|
||||
payload["date"] = dateInput.text.toString();
|
||||
payload["findings_date"] = '';
|
||||
payload["reports_date"] = '';
|
||||
payload["prescription_date"] = '';
|
||||
payload["patientType"] = prescriptionFor.toString();
|
||||
payload["others"] ={
|
||||
"name": _name,
|
||||
"age": int.parse(_age),
|
||||
"gender": _gender.toString().toLowerCase()
|
||||
};
|
||||
payload["findings"] =uiFindingsImages;
|
||||
payload["reports"] =uiReportsImages;
|
||||
payload["prescription"] =uiPrescriptionImages;
|
||||
|
||||
bool uploadStatus = await AppSettings.addRecords(payload);
|
||||
|
||||
try{
|
||||
if(uploadStatus){
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longSuccessToast('Record added successfully');
|
||||
Navigator.pop(context);
|
||||
}
|
||||
else{
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longFailedToast('Fail to add record details');
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
print(e);
|
||||
Navigator.of(context,rootNavigator: true).pop();
|
||||
AppSettings.longFailedToast('Fail to add record details');
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please check internet');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
AppSettings.longFailedToast('Please enter valid details');
|
||||
}
|
||||
},
|
||||
child: const Text('Submit'),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
@ -0,0 +1,526 @@
|
||||
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(),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:healthcare_user/common/zoom_image.dart';
|
||||
|
||||
class FindingImages extends StatefulWidget {
|
||||
var imageDetails;
|
||||
FindingImages({this.imageDetails});
|
||||
|
||||
|
||||
@override
|
||||
State<FindingImages> createState() => _FindingImagesState();
|
||||
}
|
||||
|
||||
class _FindingImagesState extends State<FindingImages> {
|
||||
@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: [
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: Container(
|
||||
child: IconButton(
|
||||
iconSize: 30,
|
||||
icon: const Icon(
|
||||
Icons.cancel,
|
||||
color: Colors.red,
|
||||
),
|
||||
onPressed: () async {
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
),
|
||||
/* color: Colors.pinkAccent,
|
||||
width: 35,
|
||||
height: 35,*/
|
||||
),
|
||||
)]),
|
||||
),
|
||||
|
||||
//Image.network(widget.imageDetails[index]['url']),
|
||||
);
|
||||
},
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:healthcare_user/common/zoom_image.dart';
|
||||
|
||||
class ReportImages extends StatefulWidget {
|
||||
var imageDetails;
|
||||
ReportImages({this.imageDetails});
|
||||
|
||||
@override
|
||||
State<ReportImages> createState() => _ReportImagesState();
|
||||
}
|
||||
|
||||
class _ReportImagesState extends State<ReportImages> {
|
||||
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 {},
|
||||
),
|
||||
/* 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 {
|
||||
/*Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const Login()),
|
||||
);*/
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Report Images'),
|
||||
body: Container(padding: EdgeInsets.all(12.0), child: renderUi()),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:healthcare_user/models/bmi_history_model.dart';
|
||||
|
||||
|
||||
class BmiChart extends StatefulWidget {
|
||||
var myObject;
|
||||
BmiChart({
|
||||
this.myObject
|
||||
});
|
||||
|
||||
@override
|
||||
State<BmiChart> createState() => _BmiChartState();
|
||||
}
|
||||
|
||||
class _BmiChartState extends State<BmiChart> {
|
||||
|
||||
|
||||
_getSeriesData() {
|
||||
List<charts.Series<BmiHistoryModel, DateTime>> series = [
|
||||
charts.Series(
|
||||
id: "Sales",
|
||||
data: widget.myObject,
|
||||
domainFn: (BmiHistoryModel series, _) => series.dateForFilter,
|
||||
measureFn: (BmiHistoryModel series, _) => series.number2,
|
||||
colorFn: (BmiHistoryModel series, _) => charts.MaterialPalette.blue.shadeDefault
|
||||
)
|
||||
];
|
||||
return series;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('BMI Chart'),
|
||||
body: Container(
|
||||
|
||||
child:new charts.TimeSeriesChart(_getSeriesData(), animate: true,),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
class SalesData {
|
||||
final int year;
|
||||
final int sales;
|
||||
|
||||
SalesData(this.year, this.sales);
|
||||
}
|
||||
|
||||
final data = [
|
||||
new SalesData(0, 1500000),
|
||||
new SalesData(1, 1735000),
|
||||
new SalesData(2, 1678000),
|
||||
new SalesData(3, 1890000),
|
||||
new SalesData(4, 1907000),
|
||||
new SalesData(5, 2300000),
|
||||
new SalesData(6, 2360000),
|
||||
new SalesData(7, 1980000),
|
||||
new SalesData(8, 2654000),
|
||||
new SalesData(9, 2789070),
|
||||
new SalesData(10, 3020000),
|
||||
new SalesData(11, 3245900),
|
||||
new SalesData(12, 4098500),
|
||||
new SalesData(13, 4500000),
|
||||
new SalesData(14, 4456500),
|
||||
new SalesData(15, 3900500),
|
||||
new SalesData(16, 5123400),
|
||||
new SalesData(17, 5589000),
|
||||
new SalesData(18, 5940000),
|
||||
new SalesData(19, 6367000),
|
||||
];
|
||||
|
||||
|
||||
_getSeriesData() {
|
||||
List<charts.Series<SalesData, int>> series = [
|
||||
charts.Series(
|
||||
id: "Sales",
|
||||
data: data,
|
||||
domainFn: (SalesData series, _) => series.year,
|
||||
measureFn: (SalesData series, _) => series.sales,
|
||||
colorFn: (SalesData series, _) => charts.MaterialPalette.blue.shadeDefault
|
||||
)
|
||||
];
|
||||
return series;
|
||||
}
|
||||
|
||||
class Bpchart extends StatefulWidget {
|
||||
const Bpchart({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Bpchart> createState() => _BpchartState();
|
||||
}
|
||||
|
||||
class _BpchartState extends State<Bpchart> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Bp chart'),
|
||||
body: Container(
|
||||
child:new charts.LineChart(_getSeriesData(), animate: true,),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
class ImageZoomPage extends StatefulWidget {
|
||||
var imageName;
|
||||
var imageDetails;
|
||||
ImageZoomPage({this.imageName,this.imageDetails});
|
||||
|
||||
|
||||
@override
|
||||
State<ImageZoomPage> createState() => _ImageZoomPageState();
|
||||
}
|
||||
|
||||
class _ImageZoomPageState extends State<ImageZoomPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar(widget.imageName),
|
||||
body: Container(
|
||||
//width: MediaQuery.of(context).size.width * .10,
|
||||
//height: MediaQuery.of(context).size.height * .50,
|
||||
child: PhotoView(
|
||||
imageProvider: NetworkImage(widget.imageDetails) as ImageProvider,
|
||||
maxScale: PhotoViewComputedScale.contained * 4.0,
|
||||
minScale: PhotoViewComputedScale.contained,
|
||||
initialScale: PhotoViewComputedScale.contained,
|
||||
basePosition: Alignment.center,
|
||||
|
||||
)
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
|
||||
class ReportsModel {
|
||||
String patient_name='';
|
||||
String age='';
|
||||
String gender='';
|
||||
String patient_type='';
|
||||
String problem='';
|
||||
String doctorName='';
|
||||
String hospitalName='';
|
||||
String date='';
|
||||
String recordId='';
|
||||
List findingsImages = [];
|
||||
List reportImages = [];
|
||||
List prescriptionImages = [];
|
||||
|
||||
ReportsModel();
|
||||
|
||||
factory ReportsModel.fromJson(Map<String, dynamic> json){
|
||||
ReportsModel rtvm = new ReportsModel();
|
||||
|
||||
rtvm.patient_type = json['patientType'] ?? '';
|
||||
rtvm.doctorName = json['doctorName'] ?? '';
|
||||
rtvm.hospitalName = json['hospitalName'] ?? '';
|
||||
rtvm.problem = json['problem'] ?? '';
|
||||
rtvm.date = json['date'] ?? '';
|
||||
rtvm.recordId = json['recordId'] ?? '';
|
||||
rtvm.findingsImages = json['findings'] ?? [];
|
||||
rtvm.reportImages = json['reports'] ?? [];
|
||||
rtvm.prescriptionImages = json['prescription'] ?? [];
|
||||
|
||||
if(rtvm.patient_type.toString().toLowerCase()=='self'){
|
||||
rtvm.age=AppSettings.age;
|
||||
rtvm.gender=AppSettings.gender;
|
||||
rtvm.patient_name=AppSettings.userName;
|
||||
}
|
||||
else{
|
||||
rtvm.age=json['others']['age'].toString();
|
||||
rtvm.gender=json['others']['gender'];
|
||||
rtvm.patient_name=json['others']['name'];
|
||||
}
|
||||
|
||||
return rtvm;
|
||||
}
|
||||
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:healthcare_user/common/settings.dart';
|
||||
|
||||
class Reports extends StatefulWidget {
|
||||
const Reports({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<Reports> createState() => _ReportsState();
|
||||
}
|
||||
|
||||
class _ReportsState extends State<Reports> {
|
||||
|
||||
TextEditingController doctorNameController = TextEditingController();
|
||||
TextEditingController hospitalNameController = TextEditingController();
|
||||
TextEditingController problemController = TextEditingController();
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppSettings.appBar('Reports'),
|
||||
body: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: doctorNameController,
|
||||
decoration: textFormFieldDecoration(Icons.person,'Enter Doctor name'),
|
||||
),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: hospitalNameController,
|
||||
decoration: textFormFieldDecoration(Icons.location_city_outlined,'Enter Hospital name'),
|
||||
),
|
||||
),
|
||||
SizedBox(height:MediaQuery.of(context).size.height * .02,),
|
||||
Container(
|
||||
child: TextFormField(
|
||||
cursorColor: greyColor,
|
||||
controller: problemController,
|
||||
decoration: textFormFieldDecoration(Icons.edit,'Enter Problem'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue