upload prescriptions done

dev
Sneha 1 year ago
parent 233a8bf7e5
commit 895626d5b5

@ -45,7 +45,7 @@ class _AddReportsState extends State<AddReports> {
imageFileList.addAll(selectedImages); imageFileList.addAll(selectedImages);
} }
var res = await AppSettings.uploadImageForFindings(imageFileList); var res = await AppSettings.uploadFindingsGallery(imageFileList);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
@ -59,7 +59,7 @@ class _AddReportsState extends State<AddReports> {
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageForFindingsCamera(image); var res = await AppSettings.uploadFindingsCamera(image);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
@ -69,7 +69,38 @@ class _AddReportsState extends State<AddReports> {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
} }
/*Future pickImageFromGalleryForUpdate() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.updateFindingsGallery(imageFileList,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['findings'];
});
}
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.updateFindingsCamera(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');
}
}*/
Future takeImageFromCameraForReports() async { Future takeImageFromCameraForReports() async {
try { try {
@ -104,18 +135,17 @@ class _AddReportsState extends State<AddReports> {
}); });
} }
Future takeImageFromCameraForPrescriptions() async { Future takeImageFromCameraForPrescriptions() async {
try { try {
final image = await _picker.pickImage(source: ImageSource.camera); final image = await _picker.pickImage(source: ImageSource.camera);
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageForFindingsCamera(image); var res = await AppSettings.uploadPrescriptionsCamera(image);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
uiFindingsImages = jsonDecode(res)['findings']; uiPrescriptionImages = jsonDecode(res)['precription'];
}); });
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
@ -123,14 +153,15 @@ class _AddReportsState extends State<AddReports> {
} }
Future pickImageFromGalleryForPrescriptions() async { Future pickImageFromGalleryForPrescriptions() async {
imageFileListPrescriptions = []; // imageFileListPrescriptions = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage(); final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) { if (selectedImages!.isNotEmpty) {
imageFileListPrescriptions.addAll(selectedImages); imageFileListPrescriptions.addAll(selectedImages);
} }
var res = await AppSettings.uploadImageForPrescriptions(imageFileListPrescriptions); var res = await AppSettings.uploadPrescriptionsGallery(
imageFileListPrescriptions);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
@ -138,8 +169,6 @@ class _AddReportsState extends State<AddReports> {
}); });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -233,96 +262,118 @@ class _AddReportsState extends State<AddReports> {
), ),
Row( Row(
children: [ children: [
Expanded(
Expanded(child: RadioListTile( child: RadioListTile(
title: Text("For Yourself"), title: Text("For Yourself"),
value: "self", value: "self",
groupValue: prescriptionFor, groupValue: prescriptionFor,
activeColor: primaryColor, activeColor: primaryColor,
onChanged: (value){ onChanged: (value) {
setState(() { setState(() {
prescriptionFor = value.toString(); prescriptionFor = value.toString();
}); });
}, },
),), ),
Expanded(child: RadioListTile( ),
Expanded(
child: RadioListTile(
title: Text("For Family"), title: Text("For Family"),
value: "others", value: "others",
groupValue: prescriptionFor, groupValue: prescriptionFor,
activeColor: primaryColor, activeColor: primaryColor,
onChanged: (value){ onChanged: (value) {
setState(() { setState(() {
prescriptionFor = value.toString(); prescriptionFor = value.toString();
}); });
}, },
),), ),
),
], ],
), ),
Visibility( Visibility(
visible:prescriptionFor.toString().toLowerCase()=='others' , visible:
prescriptionFor.toString().toLowerCase() == 'others',
child: Container( child: Container(
child: TextFormField( child: TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
controller: patientNameController, controller: patientNameController,
decoration: textFormFieldDecoration(Icons.person,'Enter patient name'), decoration: textFormFieldDecoration(
Icons.person, 'Enter patient name'),
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * .02,
), ),
),),
SizedBox(height:MediaQuery.of(context).size.height * .02,),
Visibility( Visibility(
visible:prescriptionFor.toString().toLowerCase()=='others' , visible:
prescriptionFor.toString().toLowerCase() == 'others',
child: Container( child: Container(
child: TextFormField( child: TextFormField(
cursorColor: greyColor, cursorColor: greyColor,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
controller: patientAgeController, controller: patientAgeController,
decoration: textFormFieldDecoration(Icons.person,'Enter patient age'), decoration: textFormFieldDecoration(
Icons.person, 'Enter patient age'),
),
),
), ),
),),
Visibility( Visibility(
visible:prescriptionFor.toString().toLowerCase()=='others' , visible:
prescriptionFor.toString().toLowerCase() == 'others',
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Expanded(
Expanded(child: RadioListTile( child: RadioListTile(
title: Text("Male",style: TextStyle(fontSize: 10)), title: Text("Male", style: TextStyle(fontSize: 10)),
value: "male", value: "male",
groupValue: gender, groupValue: gender,
activeColor: primaryColor, activeColor: primaryColor,
onChanged: (value){ onChanged: (value) {
setState(() { setState(() {
gender = value.toString(); gender = value.toString();
}); });
}, },
),), ),
Expanded(child: RadioListTile( ),
title: Text("Female",style: TextStyle(fontSize: 10),), Expanded(
child: RadioListTile(
title: Text(
"Female",
style: TextStyle(fontSize: 10),
),
value: "female", value: "female",
groupValue: gender, groupValue: gender,
activeColor: primaryColor, activeColor: primaryColor,
onChanged: (value){ onChanged: (value) {
setState(() { setState(() {
gender = value.toString(); gender = value.toString();
}); });
}, },
),), ),
Expanded(child: RadioListTile( ),
title: Text("Others",style: TextStyle(fontSize: 10)), Expanded(
child: RadioListTile(
title:
Text("Others", style: TextStyle(fontSize: 10)),
value: "other", value: "other",
groupValue: gender, groupValue: gender,
activeColor: primaryColor, activeColor: primaryColor,
onChanged: (value){ onChanged: (value) {
setState(() { setState(() {
gender = value.toString(); gender = value.toString();
}); });
}, },
),), ),
),
], ],
),), ),
ElevatedButton( ),
Visibility(
visible: uiFindingsImages.length == 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: primaryColor, // background primary: primaryColor, // background
onPrimary: Colors.white, // foreground onPrimary: Colors.white, // foreground
@ -349,7 +400,8 @@ class _AddReportsState extends State<AddReports> {
}, },
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * width:
MediaQuery.of(context).size.width *
.20, .20,
), ),
GestureDetector( GestureDetector(
@ -371,6 +423,7 @@ class _AddReportsState extends State<AddReports> {
}, },
child: const Text('Select Findings'), child: const Text('Select Findings'),
), ),
),
Visibility( Visibility(
visible: uiFindingsImages.length > 0, visible: uiFindingsImages.length > 0,
child: Container( child: Container(
@ -384,8 +437,11 @@ class _AddReportsState extends State<AddReports> {
children: [ children: [
Card( Card(
child: Container( child: Container(
width: MediaQuery.of(context).size.width * .30, width: MediaQuery.of(context).size.width *
height: MediaQuery.of(context).size.height * .15, .30,
height:
MediaQuery.of(context).size.height *
.15,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
image: DecorationImage( image: DecorationImage(
@ -407,7 +463,62 @@ class _AddReportsState extends State<AddReports> {
); );
}), }),
)), )),
ElevatedButton( Visibility(
visible: uiFindingsImages.length != 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red, // 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('Add Findings'),
),
),
Visibility(
visible: uiReportsImages.length == 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: primaryColor, // background primary: primaryColor, // background
onPrimary: Colors.white, // foreground onPrimary: Colors.white, // foreground
@ -434,7 +545,8 @@ class _AddReportsState extends State<AddReports> {
}, },
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * width:
MediaQuery.of(context).size.width *
.20, .20,
), ),
GestureDetector( GestureDetector(
@ -456,6 +568,7 @@ class _AddReportsState extends State<AddReports> {
}, },
child: const Text('Select Reports'), child: const Text('Select Reports'),
), ),
),
Visibility( Visibility(
visible: uiReportsImages.length > 0, visible: uiReportsImages.length > 0,
child: Container( child: Container(
@ -469,8 +582,11 @@ class _AddReportsState extends State<AddReports> {
children: [ children: [
Card( Card(
child: Container( child: Container(
width: MediaQuery.of(context).size.width * .30, width: MediaQuery.of(context).size.width *
height: MediaQuery.of(context).size.height * .15, .30,
height:
MediaQuery.of(context).size.height *
.15,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
image: DecorationImage( image: DecorationImage(
@ -492,7 +608,62 @@ class _AddReportsState extends State<AddReports> {
); );
}), }),
)), )),
ElevatedButton( Visibility(
visible: uiReportsImages.length != 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red, // 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('Add Reports'),
),
),
Visibility(
visible: uiPrescriptionImages.length == 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: primaryColor, // background primary: primaryColor, // background
onPrimary: Colors.white, // foreground onPrimary: Colors.white, // foreground
@ -519,7 +690,8 @@ class _AddReportsState extends State<AddReports> {
}, },
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * width:
MediaQuery.of(context).size.width *
.20, .20,
), ),
GestureDetector( GestureDetector(
@ -541,7 +713,7 @@ class _AddReportsState extends State<AddReports> {
}, },
child: const Text('Select Prescriptions'), child: const Text('Select Prescriptions'),
), ),
),
Visibility( Visibility(
visible: uiPrescriptionImages.length > 0, visible: uiPrescriptionImages.length > 0,
child: Container( child: Container(
@ -555,16 +727,44 @@ class _AddReportsState extends State<AddReports> {
children: [ children: [
Card( Card(
child: Container( child: Container(
width: MediaQuery.of(context).size.width * .30, width: MediaQuery.of(context).size.width *
height: MediaQuery.of(context).size.height * .15, .30,
height:
MediaQuery.of(context).size.height *
.15,
decoration: BoxDecoration( decoration: BoxDecoration(
shape: BoxShape.rectangle, shape: BoxShape.rectangle,
image: DecorationImage( image: DecorationImage(
image: NetworkImage( image: NetworkImage(
uiPrescriptionImages[index] uiPrescriptionImages[index]['url'])
['url'])
as ImageProvider, // picked file as ImageProvider, // picked file
fit: BoxFit.fill)), 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 = uiPrescriptionImages[index]['url'].split('/').last;
var response = await AppSettings.deletePrescriptions(fileName);
print(jsonDecode(response));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiPrescriptionImages = jsonDecode(response)['precription'];
});
},
),
),
)
]),
), ),
), ),
/*Expanded(child:IconButton( /*Expanded(child:IconButton(
@ -578,89 +778,149 @@ class _AddReportsState extends State<AddReports> {
); );
}), }),
)), )),
Visibility(
visible: uiPrescriptionImages.length != 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red, // 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('Add Prescriptions'),
),
),
Container( Container(
width:double.infinity, width: double.infinity,
height: MediaQuery.of(context).size.height * .06, height: MediaQuery.of(context).size.height * .06,
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: buttonColors, // background primary: buttonColors, // background
onPrimary: Colors.black, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () async{ onPressed: () async {
if (doctorNameController.text != '' &&
if(doctorNameController.text!=''&& problemController.text!=''&& dateInput.text!=''&&prescriptionFor!=''){ problemController.text != '' &&
dateInput.text != '' &&
String _name=''; prescriptionFor != '') {
String _age=''; String _name = '';
String? _gender=''; String _age = '';
String? _gender = '';
if(prescriptionFor.toString().toLowerCase()=='others'){
if(patientNameController!=''&& patientAgeController.text!=''&&gender!=''){ if (prescriptionFor.toString().toLowerCase() ==
_name=patientNameController.text; 'others') {
_age=patientAgeController.text; if (patientNameController != '' &&
_gender=gender; patientAgeController.text != '' &&
} gender != '') {
else{ _name = patientNameController.text;
AppSettings.longFailedToast('Please enter details'); _age = patientAgeController.text;
} _gender = gender;
} else {
AppSettings.longFailedToast(
'Please enter details');
} }
else{ } else {
_name=AppSettings.userName; _name = AppSettings.userName;
_age=AppSettings.age; _age = AppSettings.age;
_gender=AppSettings.gender; _gender = AppSettings.gender;
} }
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
bool isOnline = await AppSettings.internetConnectivity(); bool isOnline =
if(isOnline){ await AppSettings.internetConnectivity();
if (isOnline) {
var payload = new Map<String, dynamic>(); var payload = new Map<String, dynamic>();
payload["problem"] = problemController.text.toString(); payload["problem"] =
payload["doctorName"] = doctorNameController.text.toString(); problemController.text.toString();
payload["hospitalName"] = hospitalNameController.text.toString(); payload["doctorName"] =
doctorNameController.text.toString();
payload["hospitalName"] =
hospitalNameController.text.toString();
payload["date"] = dateInput.text.toString(); payload["date"] = dateInput.text.toString();
payload["findings_date"] = ''; payload["findings_date"] = '';
payload["reports_date"] = ''; payload["reports_date"] = '';
payload["prescription_date"] = ''; payload["prescription_date"] = '';
payload["patientType"] = prescriptionFor.toString(); payload["patientType"] =
payload["others"] ={ prescriptionFor.toString();
payload["others"] = {
"name": _name, "name": _name,
"age": int.parse(_age), "age": int.parse(_age),
"gender": _gender.toString().toLowerCase() "gender": _gender.toString().toLowerCase()
}; };
payload["findings"] =uiFindingsImages; payload["findings"] = uiFindingsImages;
payload["reports"] =uiReportsImages; payload["reports"] = uiReportsImages;
payload["prescription"] =uiPrescriptionImages; payload["prescription"] = uiPrescriptionImages;
bool uploadStatus = await AppSettings.addRecords(payload); bool uploadStatus =
await AppSettings.addRecords(payload);
try{ try {
if(uploadStatus){ if (uploadStatus) {
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true)
AppSettings.longSuccessToast('Record added successfully'); .pop();
AppSettings.longSuccessToast(
'Record added successfully');
Navigator.pop(context); Navigator.pop(context);
} else {
Navigator.of(context, rootNavigator: true)
.pop();
AppSettings.longFailedToast(
'Fail to add record details');
} }
else{ } catch (e) {
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('Fail to add record details');
}
}
catch(e){
print(e); print(e);
Navigator.of(context,rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true)
AppSettings.longFailedToast('Fail to add record details'); .pop();
} AppSettings.longFailedToast(
'Fail to add record details');
}
else{
AppSettings.longFailedToast('Please check internet');
} }
} else {
AppSettings.longFailedToast(
'Please check internet');
} }
else{ } else {
AppSettings.longFailedToast('Please enter valid details'); AppSettings.longFailedToast(
'Please enter valid details');
} }
}, },
child: const Text('Submit'), child: const Text('Submit'),

@ -24,8 +24,63 @@ class _AllReportsState extends State<AllReports> {
List<ReportsModel> reportsListOriginal = []; List<ReportsModel> reportsListOriginal = [];
bool isReportsDataLoading = false; bool isReportsDataLoading = false;
bool isSereverIssue = false; bool isSereverIssue = false;
TextEditingController searchController = TextEditingController();
String dropdownSearchType = 'Problem';
var typeOfSearchItems = [
'Problem',
'Doctor',
'Date',
];
Future<void> getAllRecords() 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;
});
}
}
Future<void> getRecordsByProblemName(var problem) 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();
reportsList= reportsListOriginal.where(
(x) => x.problem.toString().toLowerCase().contains(problem.toString().toLowerCase())
).toList();
isReportsDataLoading = false;
});
} catch (e) {
setState(() {
isReportsDataLoading = false;
isSereverIssue = true;
});
}
}
Future<void> getRecordsByDoctorName(var doctor) async {
Future<void> gaetAllRecords() async {
isReportsDataLoading=true; isReportsDataLoading=true;
try { try {
var response = await AppSettings.getAllRecords(); var response = await AppSettings.getAllRecords();
@ -36,6 +91,9 @@ class _AllReportsState extends State<AllReports> {
return ReportsModel.fromJson(model); return ReportsModel.fromJson(model);
}).toList(); }).toList();
reportsList=reportsListOriginal.reversed.toList(); reportsList=reportsListOriginal.reversed.toList();
reportsList= reportsListOriginal.where(
(x) => x.doctorName.toString().toLowerCase().contains(doctor.toString().toLowerCase())
).toList();
isReportsDataLoading = false; isReportsDataLoading = false;
}); });
} catch (e) { } catch (e) {
@ -48,7 +106,7 @@ class _AllReportsState extends State<AllReports> {
@override @override
void initState() { void initState() {
gaetAllRecords(); getAllRecords();
super.initState(); super.initState();
} }
@ -244,14 +302,9 @@ class _AllReportsState extends State<AllReports> {
} }
Widget _filtereddata(){
Widget _allreports(){
if(reportsList.length!=0){ if(reportsList.length!=0){
return Column( return ListView.builder(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
padding: EdgeInsets.all(0), padding: EdgeInsets.all(0),
itemCount: reportsList.length, itemCount: reportsList.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
@ -325,7 +378,7 @@ class _AllReportsState extends State<AllReports> {
if(deleteTankStatus){ if(deleteTankStatus){
gaetAllRecords(); getAllRecords();
AppSettings.longSuccessToast('Record deleted successfully'); AppSettings.longSuccessToast('Record deleted successfully');
Navigator.of(context).pop(true); Navigator.of(context).pop(true);
@ -376,7 +429,7 @@ class _AllReportsState extends State<AllReports> {
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) { builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) {
gaetAllRecords(); getAllRecords();
}); });
}, },
child: Text('Findings: '+reportsList[index].findingsImages.length.toString()), child: Text('Findings: '+reportsList[index].findingsImages.length.toString()),
@ -393,7 +446,9 @@ class _AllReportsState extends State<AllReports> {
Navigator.push( Navigator.push(
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages))); builder: (__) => new ReportImages(imageDetails:reportsList[index].reportImages,recordId:reportsList[index].recordId ,))).then((value) {
getAllRecords();
});
}, },
child: Text('Reports: '+reportsList[index].reportImages.length.toString()), child: Text('Reports: '+reportsList[index].reportImages.length.toString()),
@ -411,7 +466,7 @@ class _AllReportsState extends State<AllReports> {
context, context,
new MaterialPageRoute( new MaterialPageRoute(
builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index]))).then((value) { builder: (__) => new PrescriptionImages(imageDetails:reportsList[index].prescriptionImages,recordId: reportsList[index].recordId,familyDetails:reportsList[index]))).then((value) {
gaetAllRecords(); getAllRecords();
}); });
}, },
@ -444,7 +499,200 @@ class _AllReportsState extends State<AllReports> {
), ),
), ),
); );
}) ), });
}
else{
return Padding(padding: EdgeInsets.fromLTRB(60,10,60,10),
child: Column(
children: [
Text('No records found related to your search'),
SizedBox(
height: 20,
),
CircleAvatar(
backgroundColor: Colors.red,
radius: 30,
child: const Icon(
Icons.info,
color: Colors.white,
),
)
],
),);
}
}
Widget _allreports(){
if(reportsListOriginal.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
child: DropdownButtonFormField(
// Initial Value
value: dropdownSearchType,
isExpanded: true,
decoration: const InputDecoration(
prefixIcon: Icon(
Icons.search,
color: greyColor,
),
border: OutlineInputBorder(
borderSide: BorderSide(color: greyColor)),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: greyColor),
),
labelText: 'Search By',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
hint: Text('Select Search Type'),
// Down Arrow Icon
icon: const Icon(Icons.keyboard_arrow_down),
// Array list of items
items: typeOfSearchItems.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(() {
dropdownSearchType = newValue!;
});
},
),
),
Visibility(
visible:dropdownSearchType.toString().toLowerCase()=='problem' ,
child: Container(
height: MediaQuery.of(context).size.height * .07,
padding: EdgeInsets.all(5),
child: Center(child: TextField(
cursorColor: primaryColor,
controller: searchController,
onChanged: (string) {
if(string.length>=1){
getRecordsByProblemName(string);
}
else{
getAllRecords();
}
},
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search,
color: primaryColor,
),
/*suffixIcon: Icon(
Icons.clear,
color: greyColor,
),*/
suffixIcon: IconButton(
icon: Icon(
Icons.clear,
color: Colors.red,
),
onPressed: () {
setState(() {
searchController.text='';
});
getAllRecords();
},
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
//labelText: 'Search by phone number',
hintText: 'Search by problem',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),)
),),
Visibility(
visible:dropdownSearchType.toString().toLowerCase()=='doctor' ,
child: Container(
height: MediaQuery.of(context).size.height * .07,
padding: EdgeInsets.all(5),
child: Center(child: TextField(
cursorColor: primaryColor,
controller: searchController,
onChanged: (string) {
if(string.length>=1){
getRecordsByDoctorName(string);
}
else{
getAllRecords();
}
},
decoration: InputDecoration(
prefixIcon: Icon(
Icons.search,
color: primaryColor,
),
/*suffixIcon: Icon(
Icons.clear,
color: greyColor,
),*/
suffixIcon: IconButton(
icon: Icon(
Icons.clear,
color: Colors.red,
),
onPressed: () {
setState(() {
searchController.text='';
});
getAllRecords();
},
),
border: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: primaryColor),
borderRadius: BorderRadius.circular(30),
),
//labelText: 'Search by phone number',
hintText: 'Search by doctor',
labelStyle: TextStyle(
color: greyColor, //<-- SEE HERE
),
),
),)
),),
Expanded(child: _filtereddata()),
Padding( Padding(
padding: EdgeInsets.fromLTRB(8, 8, 8, 8), padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
child: CircleAvatar( child: CircleAvatar(
@ -466,7 +714,7 @@ class _AllReportsState extends State<AllReports> {
builder: (context) => AddPrescription()), builder: (context) => AddPrescription()),
);*/ );*/
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) { Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
gaetAllRecords(); getAllRecords();
}); });
//showBoreAddingDialog(); //showBoreAddingDialog();
}, },
@ -483,6 +731,8 @@ class _AllReportsState extends State<AllReports> {
), ),
), ),
]); ]);
} }
else{ else{
return Center( return Center(
@ -507,7 +757,7 @@ class _AllReportsState extends State<AllReports> {
), ),
onPressed: () async { onPressed: () async {
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) { Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
gaetAllRecords(); getAllRecords();
}); });
}, },
), ),

@ -27,7 +27,7 @@ class _FindingImagesState extends State<FindingImages> {
List uiFindingsImages = []; List uiFindingsImages = [];
final ImagePicker _picker = ImagePicker(); final ImagePicker _picker = ImagePicker();
Future pickImageFromGallery() async { /* Future pickImageFromGallery() async {
imageFileList = []; imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage(); final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
@ -35,23 +35,7 @@ class _FindingImagesState extends State<FindingImages> {
imageFileList.addAll(selectedImages); imageFileList.addAll(selectedImages);
} }
var res = await AppSettings.uploadImageForFindings(imageFileList); var res = await AppSettings.updateFindingsGallery(imageFileList,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['findings'];
});
}
Future pickImageFromGalleryForUpdate() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.uploadImageForFindingsUpdate(imageFileList,widget.recordId);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
@ -65,7 +49,7 @@ class _FindingImagesState extends State<FindingImages> {
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageForFindingsFromCamera(image); var res = await AppSettings.updateFindingsCamera(image,widget.recordId);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
@ -74,6 +58,22 @@ class _FindingImagesState extends State<FindingImages> {
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
}*/
Future pickImageFromGalleryForUpdate() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.updateFindingsGallery(imageFileList,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['findings'];
});
} }
Future takeImageFromCameraForUpdate() async { Future takeImageFromCameraForUpdate() async {
@ -82,7 +82,7 @@ class _FindingImagesState extends State<FindingImages> {
if (image == null) return; if (image == null) return;
final imageTemp = File(image.path); final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageForFindingsUpdateFromCamera(image,widget.recordId); var res = await AppSettings.updateFindingsCamera(image,widget.recordId);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
@ -148,22 +148,21 @@ class _FindingImagesState extends State<FindingImages> {
payload["urlType"] = 'findings'; payload["urlType"] = 'findings';
payload["url"] = widget.imageDetails[index]['url']; payload["url"] = widget.imageDetails[index]['url'];
bool deleteStatus = await AppSettings.deleteRecords(payload,widget.recordId); // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId);
try{
if(deleteStatus){ var res = await AppSettings.deleteRecordsNew(payload,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
AppSettings.longSuccessToast("Image deleted Successfully"); AppSettings.longSuccessToast("Image deleted Successfully");
//AllReportsState().getAllRecords(); setState(() {
Navigator.pop(context); widget.imageDetails = jsonDecode(res)['remainingUrls'];
});
} }
else{ catch(e){
print(e);
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
AppSettings.longFailedToast("Image deletion failed"); AppSettings.longFailedToast("Image deletion failed");
} }
}, },
), ),
/* color: Colors.pinkAccent, /* color: Colors.pinkAccent,
@ -186,7 +185,7 @@ class _FindingImagesState extends State<FindingImages> {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox(height: MediaQuery.of(context).size.height * .25,), SizedBox(height: MediaQuery.of(context).size.height * .25,),
Text('Click below icon to add new Report'), Text('Click below icon to add new findings'),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
@ -216,7 +215,7 @@ class _FindingImagesState extends State<FindingImages> {
color: primaryColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await takeImageFromCamera(); await takeImageFromCameraForUpdate();
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
@ -231,7 +230,7 @@ class _FindingImagesState extends State<FindingImages> {
color: primaryColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await pickImageFromGallery(); await pickImageFromGalleryForUpdate();
Navigator.pop(context); Navigator.pop(context);
}, },
), ),

@ -1,6 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/Reports/allreports.dart'; import 'package:healthcare_user/Reports/allreports.dart';
import 'package:healthcare_user/Reports/order_medicines_new.dart'; import 'package:healthcare_user/Reports/order_medicines_new.dart';
import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/settings.dart';
@ -24,8 +26,9 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
final ImagePicker imagePicker = ImagePicker(); final ImagePicker imagePicker = ImagePicker();
List imageFileList = []; List imageFileList = [];
List uiPrescriptionImages = []; List uiPrescriptionImages = [];
final ImagePicker _picker = ImagePicker();
Future pickImageFromGallery() async { /*Future pickImageFromGallery() async {
imageFileList = []; imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage(); final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context); AppSettings.preLoaderDialog(context);
@ -33,14 +36,65 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
imageFileList.addAll(selectedImages); imageFileList.addAll(selectedImages);
} }
var res = await AppSettings.uploadImageForPrescriptions(imageFileList); var res = await AppSettings.uploadPrescriptionsGallery(imageFileList);
print(jsonDecode(res)); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop(); Navigator.of(context, rootNavigator: true).pop();
setState(() { setState(() {
widget.imageDetails = jsonDecode(res)['findings']; widget.imageDetails = jsonDecode(res)['precription'];
}); });
} }
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.uploadPrescriptionsCamera(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['precription'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}*/
Future pickImageFromGalleryForUpdate() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.updatePrescriptionsGallery(imageFileList,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['prescription'];
});
}
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.updatePrescriptionsCamera(image,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['prescription'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
Widget renderUi() { Widget renderUi() {
if (widget.imageDetails.length != 0) { if (widget.imageDetails.length != 0) {
return Column( return Column(
@ -94,26 +148,22 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
.last; .last;
var payload = new Map<String, dynamic>(); var payload = new Map<String, dynamic>();
payload["urlType"] = 'prescriptions'; payload["urlType"] = 'prescription';
payload["url"] = payload["url"] = widget.imageDetails[index]['url'];
widget.imageDetails[index]['url'];
bool deleteStatus = try{
await AppSettings.deleteRecords( var res = await AppSettings.deleteRecordsNew(payload,widget.recordId);
payload, widget.recordId); print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
if (deleteStatus) { AppSettings.longSuccessToast("Image deleted Successfully");
Navigator.of(context, rootNavigator: true) setState(() {
.pop(); widget.imageDetails = jsonDecode(res)['remainingUrls'];
AppSettings.longSuccessToast( });
"Image deleted Successfully"); }
//AllReportsState().getAllRecords(); catch(e){
Navigator.pop(context); print(e);
} else { Navigator.of(context, rootNavigator: true).pop();
Navigator.of(context, rootNavigator: true) AppSettings.longFailedToast("Image deletion failed");
.pop();
AppSettings.longFailedToast(
"Image deletion failed");
} }
}, },
), ),
@ -184,7 +234,7 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
//await takeImageFromCamera(); await takeImageFromCameraForUpdate();
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
@ -199,7 +249,7 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await pickImageFromGallery(); await pickImageFromGalleryForUpdate();
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
@ -249,12 +299,13 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
//await takeImageFromCamera(); await takeImageFromCameraForUpdate();
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
SizedBox( SizedBox(
width: MediaQuery.of(context).size.width * .20, width: MediaQuery.of(context).size.width *
.20,
), ),
GestureDetector( GestureDetector(
child: Icon( child: Icon(
@ -263,7 +314,7 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor, color: primaryColor,
), ),
onTap: () async { onTap: () async {
await pickImageFromGallery(); await pickImageFromGalleryForUpdate();
Navigator.pop(context); Navigator.pop(context);
}, },
), ),
@ -272,6 +323,9 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
), ),
); );
}); });
}, },
), ),
) )

@ -1,16 +1,93 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/common/settings.dart'; import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/common/zoom_image.dart'; import 'package:healthcare_user/common/zoom_image.dart';
import 'package:image_picker/image_picker.dart';
class ReportImages extends StatefulWidget { class ReportImages extends StatefulWidget {
var imageDetails; var imageDetails;
ReportImages({this.imageDetails}); var recordId;
ReportImages({this.imageDetails,this.recordId});
@override @override
State<ReportImages> createState() => _ReportImagesState(); State<ReportImages> createState() => _ReportImagesState();
} }
class _ReportImagesState extends State<ReportImages> { class _ReportImagesState extends State<ReportImages> {
final ImagePicker imagePicker = ImagePicker();
List imageFileList = [];
List uiFindingsImages = [];
final ImagePicker _picker = ImagePicker();
/*Future pickImageFromGallery() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.uploadReportsGallery(imageFileList);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['reports'];
});
}
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.uploadReportsCamera(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['reports'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}*/
Future pickImageFromGalleryForUpdate() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.updateReportsGallery(imageFileList,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['reports'];
});
}
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.updateReportsCamera(image,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
widget.imageDetails = jsonDecode(res)['reports'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
}
}
Widget renderUi() { Widget renderUi() {
@ -55,9 +132,28 @@ class _ReportImagesState extends State<ReportImages> {
), ),
onPressed: () async { onPressed: () async {
AppSettings.preLoaderDialog(context);
String fileName = widget.imageDetails[index]['url'].split('/').last;
var payload = new Map<String, dynamic>();
payload["urlType"] = 'reports';
payload["url"] = widget.imageDetails[index]['url'];
try{
var res = await AppSettings.deleteRecordsNew(payload,widget.recordId);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
AppSettings.longSuccessToast("Image deleted Successfully");
setState(() {
widget.imageDetails = jsonDecode(res)['remainingUrls'];
});
}
catch(e){
print(e);
Navigator.of(context, rootNavigator: true).pop();
AppSettings.longFailedToast("Image deletion failed");
}
}, },
), ),
/* color: Colors.pinkAccent, /* color: Colors.pinkAccent,
@ -95,11 +191,46 @@ class _ReportImagesState extends State<ReportImages> {
color: Colors.white, color: Colors.white,
), ),
onPressed: () async { onPressed: () async {
/*Navigator.push( showModalBottomSheet<void>(
context, context: context,
MaterialPageRoute( builder: (BuildContext context) {
builder: (context) => const Login()), 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 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);
},
),
],
),
),
);
});
}, },
), ),
) )
@ -127,6 +258,48 @@ class _ReportImagesState extends State<ReportImages> {
color: Colors.white, color: Colors.white,
), ),
onPressed: () async { 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 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);
},
),
],
),
),
);
});
}, },
),) ),)

@ -236,10 +236,12 @@ class AppSettings {
static String getSugarHistoryUrl = host + 'userssugar'; static String getSugarHistoryUrl = host + 'userssugar';
static String addMedicineTimingsUrl = host + 'medicine-timing'; static String addMedicineTimingsUrl = host + 'medicine-timing';
static String getMedicineTimingsUrl = host + 'getmedicineztiming'; static String getMedicineTimingsUrl = host + 'getmedicineztiming';
static String prescriptionUploadPicUrl = host + 'uploads-precription';
static String findingsUploadPicUrl = host + 'uploads-findings-prescription'; static String findingsUploadPicUrl = host + 'uploads-findings-prescription';
static String updateFindingsUploadPicUrl = host + 'update-uploads-findings-prescription'; static String updateFindingsUploadPicUrl = host + 'update-uploads-findings-prescription';
static String updateReportsUploadPicUrl = host + 'update-uploads-reports-prescription';
static String reportsUploadPicUrl = host + 'uploads-reports-prescription'; static String reportsUploadPicUrl = host + 'uploads-reports-prescription';
static String prescriptionUploadPicUrl = host + 'uploads-prescription-prescription';
static String updatePrescriptionPicUrl = host + 'update-uploads-prescription-prescription';
static String recordPrescriptionsUploadPicUrl = host + 'uploads-prescription-prescription'; static String recordPrescriptionsUploadPicUrl = host + 'uploads-prescription-prescription';
static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist'; static String getAllpharmaciesDataUrl = host + 'getAllPharmacylist';
static String getAllQuotationRequestsUrl = host + 'userprecription'; static String getAllQuotationRequestsUrl = host + 'userprecription';
@ -252,6 +254,7 @@ class AppSettings {
static String getRecordsDataUrl = host + 'getAllRecords'; static String getRecordsDataUrl = host + 'getAllRecords';
static String deleteRecordUrl = host + 'deleteRecord'; static String deleteRecordUrl = host + 'deleteRecord';
static String deleteFindingsUrl = host + 'uploads-findings-prescription'; static String deleteFindingsUrl = host + 'uploads-findings-prescription';
static String deletePrescriptionsUrl = host + 'uploads-prescription-prescription';
static String deleteRecordsUrl = host + 'delete-url'; static String deleteRecordsUrl = host + 'delete-url';
@ -720,7 +723,9 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> uploadImageForFindings(file) async { /*upload and update findings*/
static Future<String> uploadFindingsGallery(file) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
'POST', Uri.parse(findingsUploadPicUrl + '/' + customerId)); 'POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
@ -734,8 +739,7 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> uploadFindingsCamera(file) async {
static Future<String> uploadImageForFindingsFromCamera(file) async {
var request = http.MultipartRequest('POST', Uri.parse(findingsUploadPicUrl + '/' + customerId)); var request = http.MultipartRequest('POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path)); request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send(); var res = await request.send();
@ -743,7 +747,7 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> uploadImageForFindingsUpdate(file,var recordId) async { static Future<String> updateFindingsGallery(file,var recordId) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
'POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId)); 'POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
@ -757,7 +761,7 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> uploadImageForFindingsUpdateFromCamera(file,var recordId) async { static Future<String> updateFindingsCamera(file,var recordId) async {
var request = http.MultipartRequest('POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId)); var request = http.MultipartRequest('POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path)); request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send(); var res = await request.send();
@ -765,7 +769,12 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> uploadImageForReports(file) async { /*End*/
/*upload and update Reports*/
static Future<String> uploadReportsGallery(file) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
'POST', Uri.parse(reportsUploadPicUrl + '/' + customerId)); 'POST', Uri.parse(reportsUploadPicUrl + '/' + customerId));
@ -779,11 +788,67 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> uploadReportsCamera(file) async {
var request = http.MultipartRequest('POST', Uri.parse(reportsUploadPicUrl + '/' + 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<String> updateReportsGallery(file,var recordId) async {
var request = http.MultipartRequest(
'POST', Uri.parse(updateReportsUploadPicUrl + '/' + 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<String> updateReportsCamera(file,var recordId) async {
var request = http.MultipartRequest('POST', Uri.parse(updateReportsUploadPicUrl + '/' + 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;
}
/*End*/
/*upload and update Prescriptions*/
static Future<String> uploadPrescriptionsGallery(file) async {
var request = http.MultipartRequest(
'POST', Uri.parse(prescriptionUploadPicUrl + '/' + customerId));
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<String> uploadPrescriptionsCamera(file) async {
var request = http.MultipartRequest('POST', Uri.parse(prescriptionUploadPicUrl + '/' + 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<String> uploadImageForPrescriptions(file) async { static Future<String> updatePrescriptionsGallery(file,var recordId) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
'POST', Uri.parse(recordPrescriptionsUploadPicUrl + '/' + customerId)); 'POST', Uri.parse(updatePrescriptionPicUrl + '/' + customerId+'/'+recordId));
if (file.length > 0) { if (file.length > 0) {
for (var i = 0; i < file.length; i++) { 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', file[i].path));
@ -794,6 +859,38 @@ class AppSettings {
return response.body; return response.body;
} }
static Future<String> updatePrescriptionsCamera(file,var recordId) async {
var request = http.MultipartRequest('POST', Uri.parse(updatePrescriptionPicUrl + '/' + 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;
}
/*End*/
static Future<String> uploadImageForReports(file) async {
var request = http.MultipartRequest(
'POST', Uri.parse(reportsUploadPicUrl + '/' + customerId));
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<String> uploadImageForFindingsCamera(file) async { static Future<String> uploadImageForFindingsCamera(file) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
@ -805,6 +902,8 @@ class AppSettings {
} }
static Future<String> uploadVideoInReportMySelf(file) async { static Future<String> uploadVideoInReportMySelf(file) async {
var request = http.MultipartRequest( var request = http.MultipartRequest(
'POST', Uri.parse(reportMySelfVideoUploadUrl + '/' + customerId)); 'POST', Uri.parse(reportMySelfVideoUploadUrl + '/' + customerId));
@ -1116,6 +1215,35 @@ class AppSettings {
} }
} }
static Future<String> deletePrescriptions(fileName) async {
var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+fileName);
try {
var response = await http.delete(uri, headers: await buildRequestHeaders());
if (response.statusCode == 200) {
return response.body;
} 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 response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
} catch (e) {
print(e);
return '';
}
}
static Future<bool> deleteRecords(payload, recordId) async { static Future<bool> deleteRecords(payload, recordId) async {
var uri = Uri.parse(deleteRecordsUrl + '/' + customerId+'/'+recordId); var uri = Uri.parse(deleteRecordsUrl + '/' + customerId+'/'+recordId);
@ -1148,6 +1276,37 @@ class AppSettings {
static Future<String> deleteRecordsNew(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 response.body;
} 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 response.body;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
} catch (e) {
print(e);
return '';
}
}

Loading…
Cancel
Save