upload prescriptions done

dev
Sneha 1 year ago
parent 233a8bf7e5
commit 895626d5b5

@ -45,7 +45,7 @@ class _AddReportsState extends State<AddReports> {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.uploadImageForFindings(imageFileList);
var res = await AppSettings.uploadFindingsGallery(imageFileList);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
@ -59,7 +59,7 @@ class _AddReportsState extends State<AddReports> {
if (image == null) return;
final imageTemp = File(image.path);
AppSettings.preLoaderDialog(context);
var res = await AppSettings.uploadImageForFindingsCamera(image);
var res = await AppSettings.uploadFindingsCamera(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
@ -69,7 +69,38 @@ class _AddReportsState extends State<AddReports> {
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 {
try {
@ -104,18 +135,17 @@ class _AddReportsState extends State<AddReports> {
});
}
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);
var res = await AppSettings.uploadPrescriptionsCamera(image);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
uiFindingsImages = jsonDecode(res)['findings'];
uiPrescriptionImages = jsonDecode(res)['precription'];
});
} on PlatformException catch (e) {
print('Failed to pick image: $e');
@ -123,14 +153,15 @@ class _AddReportsState extends State<AddReports> {
}
Future pickImageFromGalleryForPrescriptions() async {
imageFileListPrescriptions = [];
// imageFileListPrescriptions = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
if (selectedImages!.isNotEmpty) {
imageFileListPrescriptions.addAll(selectedImages);
}
var res = await AppSettings.uploadImageForPrescriptions(imageFileListPrescriptions);
var res = await AppSettings.uploadPrescriptionsGallery(
imageFileListPrescriptions);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
setState(() {
@ -138,8 +169,6 @@ class _AddReportsState extends State<AddReports> {
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -233,96 +262,118 @@ class _AddReportsState extends State<AddReports> {
),
Row(
children: [
Expanded(child: RadioListTile(
Expanded(
child: RadioListTile(
title: Text("For Yourself"),
value: "self",
groupValue: prescriptionFor,
activeColor: primaryColor,
onChanged: (value){
onChanged: (value) {
setState(() {
prescriptionFor = value.toString();
});
},
),),
Expanded(child: RadioListTile(
),
),
Expanded(
child: RadioListTile(
title: Text("For Family"),
value: "others",
groupValue: prescriptionFor,
activeColor: primaryColor,
onChanged: (value){
onChanged: (value) {
setState(() {
prescriptionFor = value.toString();
});
},
),),
),
),
],
),
Visibility(
visible:prescriptionFor.toString().toLowerCase()=='others' ,
visible:
prescriptionFor.toString().toLowerCase() == 'others',
child: Container(
child: TextFormField(
cursorColor: greyColor,
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(
visible:prescriptionFor.toString().toLowerCase()=='others' ,
visible:
prescriptionFor.toString().toLowerCase() == 'others',
child: Container(
child: TextFormField(
cursorColor: greyColor,
keyboardType: TextInputType.number,
controller: patientAgeController,
decoration: textFormFieldDecoration(Icons.person,'Enter patient age'),
decoration: textFormFieldDecoration(
Icons.person, 'Enter patient age'),
),
),
),
),),
Visibility(
visible:prescriptionFor.toString().toLowerCase()=='others' ,
visible:
prescriptionFor.toString().toLowerCase() == 'others',
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: RadioListTile(
title: Text("Male",style: TextStyle(fontSize: 10)),
Expanded(
child: RadioListTile(
title: Text("Male", style: TextStyle(fontSize: 10)),
value: "male",
groupValue: gender,
activeColor: primaryColor,
onChanged: (value){
onChanged: (value) {
setState(() {
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",
groupValue: gender,
activeColor: primaryColor,
onChanged: (value){
onChanged: (value) {
setState(() {
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",
groupValue: gender,
activeColor: primaryColor,
onChanged: (value){
onChanged: (value) {
setState(() {
gender = value.toString();
});
},
),),
),
),
],
),),
ElevatedButton(
),
),
Visibility(
visible: uiFindingsImages.length == 0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
@ -349,7 +400,8 @@ class _AddReportsState extends State<AddReports> {
},
),
SizedBox(
width: MediaQuery.of(context).size.width *
width:
MediaQuery.of(context).size.width *
.20,
),
GestureDetector(
@ -371,6 +423,7 @@ class _AddReportsState extends State<AddReports> {
},
child: const Text('Select Findings'),
),
),
Visibility(
visible: uiFindingsImages.length > 0,
child: Container(
@ -384,8 +437,11 @@ class _AddReportsState extends State<AddReports> {
children: [
Card(
child: Container(
width: MediaQuery.of(context).size.width * .30,
height: MediaQuery.of(context).size.height * .15,
width: MediaQuery.of(context).size.width *
.30,
height:
MediaQuery.of(context).size.height *
.15,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
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(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
@ -434,7 +545,8 @@ class _AddReportsState extends State<AddReports> {
},
),
SizedBox(
width: MediaQuery.of(context).size.width *
width:
MediaQuery.of(context).size.width *
.20,
),
GestureDetector(
@ -456,6 +568,7 @@ class _AddReportsState extends State<AddReports> {
},
child: const Text('Select Reports'),
),
),
Visibility(
visible: uiReportsImages.length > 0,
child: Container(
@ -469,8 +582,11 @@ class _AddReportsState extends State<AddReports> {
children: [
Card(
child: Container(
width: MediaQuery.of(context).size.width * .30,
height: MediaQuery.of(context).size.height * .15,
width: MediaQuery.of(context).size.width *
.30,
height:
MediaQuery.of(context).size.height *
.15,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
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(
primary: primaryColor, // background
onPrimary: Colors.white, // foreground
@ -519,7 +690,8 @@ class _AddReportsState extends State<AddReports> {
},
),
SizedBox(
width: MediaQuery.of(context).size.width *
width:
MediaQuery.of(context).size.width *
.20,
),
GestureDetector(
@ -541,7 +713,7 @@ class _AddReportsState extends State<AddReports> {
},
child: const Text('Select Prescriptions'),
),
),
Visibility(
visible: uiPrescriptionImages.length > 0,
child: Container(
@ -555,16 +727,44 @@ class _AddReportsState extends State<AddReports> {
children: [
Card(
child: Container(
width: MediaQuery.of(context).size.width * .30,
height: MediaQuery.of(context).size.height * .15,
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'])
uiPrescriptionImages[index]['url'])
as ImageProvider, // picked file
fit: BoxFit.fill)),
child: Stack(children: [
Positioned(
right: 0,
child: Container(
child: IconButton(
iconSize: 30,
icon: const Icon(
Icons.cancel,
color: Colors.red,
),
onPressed: () async {
AppSettings.preLoaderDialog(context);
String fileName = 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(
@ -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(
width:double.infinity,
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');
}
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;
} else {
_name = AppSettings.userName;
_age = AppSettings.age;
_gender = AppSettings.gender;
}
AppSettings.preLoaderDialog(context);
bool isOnline = await AppSettings.internetConnectivity();
if(isOnline){
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["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"] ={
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;
payload["findings"] = uiFindingsImages;
payload["reports"] = uiReportsImages;
payload["prescription"] = uiPrescriptionImages;
bool uploadStatus = await AppSettings.addRecords(payload);
bool uploadStatus =
await AppSettings.addRecords(payload);
try{
if(uploadStatus){
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longSuccessToast('Record added successfully');
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');
}
else{
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('Fail to add record details');
}
}
catch(e){
} catch (e) {
print(e);
Navigator.of(context,rootNavigator: true).pop();
AppSettings.longFailedToast('Fail to add record details');
}
}
else{
AppSettings.longFailedToast('Please check internet');
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');
} else {
AppSettings.longFailedToast(
'Please enter valid details');
}
},
child: const Text('Submit'),

@ -24,8 +24,63 @@ class _AllReportsState extends State<AllReports> {
List<ReportsModel> reportsListOriginal = [];
bool isReportsDataLoading = 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;
try {
var response = await AppSettings.getAllRecords();
@ -36,6 +91,9 @@ class _AllReportsState extends State<AllReports> {
return ReportsModel.fromJson(model);
}).toList();
reportsList=reportsListOriginal.reversed.toList();
reportsList= reportsListOriginal.where(
(x) => x.doctorName.toString().toLowerCase().contains(doctor.toString().toLowerCase())
).toList();
isReportsDataLoading = false;
});
} catch (e) {
@ -48,7 +106,7 @@ class _AllReportsState extends State<AllReports> {
@override
void initState() {
gaetAllRecords();
getAllRecords();
super.initState();
}
@ -244,14 +302,9 @@ class _AllReportsState extends State<AllReports> {
}
Widget _allreports(){
Widget _filtereddata(){
if(reportsList.length!=0){
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(child:ListView.builder(
return ListView.builder(
padding: EdgeInsets.all(0),
itemCount: reportsList.length,
itemBuilder: (BuildContext context, int index) {
@ -325,7 +378,7 @@ class _AllReportsState extends State<AllReports> {
if(deleteTankStatus){
gaetAllRecords();
getAllRecords();
AppSettings.longSuccessToast('Record deleted successfully');
Navigator.of(context).pop(true);
@ -376,7 +429,7 @@ class _AllReportsState extends State<AllReports> {
context,
new MaterialPageRoute(
builder: (__) => new FindingImages(imageDetails:reportsList[index].findingsImages,recordId: reportsList[index].recordId,))).then((value) {
gaetAllRecords();
getAllRecords();
});
},
child: Text('Findings: '+reportsList[index].findingsImages.length.toString()),
@ -393,7 +446,9 @@ class _AllReportsState extends State<AllReports> {
Navigator.push(
context,
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()),
@ -411,7 +466,7 @@ class _AllReportsState extends State<AllReports> {
context,
new MaterialPageRoute(
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: EdgeInsets.fromLTRB(8, 8, 8, 8),
child: CircleAvatar(
@ -466,7 +714,7 @@ class _AllReportsState extends State<AllReports> {
builder: (context) => AddPrescription()),
);*/
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
gaetAllRecords();
getAllRecords();
});
//showBoreAddingDialog();
},
@ -483,6 +731,8 @@ class _AllReportsState extends State<AllReports> {
),
),
]);
}
else{
return Center(
@ -507,7 +757,7 @@ class _AllReportsState extends State<AllReports> {
),
onPressed: () async {
Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports())).then((value) {
gaetAllRecords();
getAllRecords();
});
},
),

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

@ -1,6 +1,8 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:healthcare_user/Reports/allreports.dart';
import 'package:healthcare_user/Reports/order_medicines_new.dart';
import 'package:healthcare_user/common/settings.dart';
@ -24,8 +26,9 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
final ImagePicker imagePicker = ImagePicker();
List imageFileList = [];
List uiPrescriptionImages = [];
final ImagePicker _picker = ImagePicker();
Future pickImageFromGallery() async {
/*Future pickImageFromGallery() async {
imageFileList = [];
final List<XFile>? selectedImages = await imagePicker.pickMultiImage();
AppSettings.preLoaderDialog(context);
@ -33,14 +36,65 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
imageFileList.addAll(selectedImages);
}
var res = await AppSettings.uploadImageForPrescriptions(imageFileList);
var res = await AppSettings.uploadPrescriptionsGallery(imageFileList);
print(jsonDecode(res));
Navigator.of(context, rootNavigator: true).pop();
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() {
if (widget.imageDetails.length != 0) {
return Column(
@ -94,26 +148,22 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
.last;
var payload = new Map<String, dynamic>();
payload["urlType"] = 'prescriptions';
payload["url"] =
widget.imageDetails[index]['url'];
payload["urlType"] = 'prescription';
payload["url"] = widget.imageDetails[index]['url'];
bool deleteStatus =
await AppSettings.deleteRecords(
payload, widget.recordId);
if (deleteStatus) {
Navigator.of(context, rootNavigator: true)
.pop();
AppSettings.longSuccessToast(
"Image deleted Successfully");
//AllReportsState().getAllRecords();
Navigator.pop(context);
} else {
Navigator.of(context, rootNavigator: true)
.pop();
AppSettings.longFailedToast(
"Image deletion failed");
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");
}
},
),
@ -184,7 +234,7 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor,
),
onTap: () async {
//await takeImageFromCamera();
await takeImageFromCameraForUpdate();
Navigator.pop(context);
},
),
@ -199,7 +249,7 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor,
),
onTap: () async {
await pickImageFromGallery();
await pickImageFromGalleryForUpdate();
Navigator.pop(context);
},
),
@ -249,12 +299,13 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor,
),
onTap: () async {
//await takeImageFromCamera();
await takeImageFromCameraForUpdate();
Navigator.pop(context);
},
),
SizedBox(
width: MediaQuery.of(context).size.width * .20,
width: MediaQuery.of(context).size.width *
.20,
),
GestureDetector(
child: Icon(
@ -263,7 +314,7 @@ class _PrescriptionImagesState extends State<PrescriptionImages> {
color: primaryColor,
),
onTap: () async {
await pickImageFromGallery();
await pickImageFromGalleryForUpdate();
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/services.dart';
import 'package:healthcare_user/common/settings.dart';
import 'package:healthcare_user/common/zoom_image.dart';
import 'package:image_picker/image_picker.dart';
class ReportImages extends StatefulWidget {
var imageDetails;
ReportImages({this.imageDetails});
var recordId;
ReportImages({this.imageDetails,this.recordId});
@override
State<ReportImages> createState() => _ReportImagesState();
}
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() {
@ -55,9 +132,28 @@ class _ReportImagesState extends State<ReportImages> {
),
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,
@ -95,11 +191,46 @@ class _ReportImagesState extends State<ReportImages> {
color: Colors.white,
),
onPressed: () async {
/*Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const Login()),
);*/
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);
},
),
],
),
),
);
});
},
),
)
@ -127,6 +258,48 @@ class _ReportImagesState extends State<ReportImages> {
color: Colors.white,
),
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 addMedicineTimingsUrl = host + 'medicine-timing';
static String getMedicineTimingsUrl = host + 'getmedicineztiming';
static String prescriptionUploadPicUrl = host + 'uploads-precription';
static String findingsUploadPicUrl = host + 'uploads-findings-prescription';
static String updateFindingsUploadPicUrl = host + 'update-uploads-findings-prescription';
static String updateReportsUploadPicUrl = host + 'update-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 getAllpharmaciesDataUrl = host + 'getAllPharmacylist';
static String getAllQuotationRequestsUrl = host + 'userprecription';
@ -252,6 +254,7 @@ class AppSettings {
static String getRecordsDataUrl = host + 'getAllRecords';
static String deleteRecordUrl = host + 'deleteRecord';
static String deleteFindingsUrl = host + 'uploads-findings-prescription';
static String deletePrescriptionsUrl = host + 'uploads-prescription-prescription';
static String deleteRecordsUrl = host + 'delete-url';
@ -720,7 +723,9 @@ class AppSettings {
return response.body;
}
static Future<String> uploadImageForFindings(file) async {
/*upload and update findings*/
static Future<String> uploadFindingsGallery(file) async {
var request = http.MultipartRequest(
'POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
@ -734,8 +739,7 @@ class AppSettings {
return response.body;
}
static Future<String> uploadImageForFindingsFromCamera(file) async {
static Future<String> uploadFindingsCamera(file) async {
var request = http.MultipartRequest('POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send();
@ -743,7 +747,7 @@ class AppSettings {
return response.body;
}
static Future<String> uploadImageForFindingsUpdate(file,var recordId) async {
static Future<String> updateFindingsGallery(file,var recordId) async {
var request = http.MultipartRequest(
'POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
@ -757,7 +761,7 @@ class AppSettings {
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));
request.files.add(await http.MultipartFile.fromPath('picture', file.path));
var res = await request.send();
@ -765,7 +769,12 @@ class AppSettings {
return response.body;
}
static Future<String> uploadImageForReports(file) async {
/*End*/
/*upload and update Reports*/
static Future<String> uploadReportsGallery(file) async {
var request = http.MultipartRequest(
'POST', Uri.parse(reportsUploadPicUrl + '/' + customerId));
@ -779,11 +788,67 @@ class AppSettings {
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(
'POST', Uri.parse(recordPrescriptionsUploadPicUrl + '/' + customerId));
'POST', Uri.parse(updatePrescriptionPicUrl + '/' + 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));
@ -794,6 +859,38 @@ class AppSettings {
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 {
var request = http.MultipartRequest(
@ -805,6 +902,8 @@ class AppSettings {
}
static Future<String> uploadVideoInReportMySelf(file) async {
var request = http.MultipartRequest(
'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 {
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