diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 11eda48..9f2ee76 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -14,6 +14,8 @@
+
+
{
),
],
),
- /*Column(
+ Column(
children: [
GestureDetector(
child: Container(
@@ -160,23 +161,23 @@ class _DashboardState extends State {
shape: BoxShape.circle,
image: DecorationImage(
image: AssetImage(
- "images/reports.png"), // picked file
+ "images/myconnections.png"), // picked file
fit: BoxFit.fitWidth)),
),
onTap: () {
- *//*Navigator.push(
+ Navigator.push(
context,
MaterialPageRoute(
- builder: (context) => const AllReports()),
- );*//*
+ builder: (context) => const PatientDashboard()),
+ );
},
),
Text(
- 'Records',
+ 'Patient Dashboard',
style: dashboardTextStyle(),
),
],
- ),*/
+ ),
],
),
),
@@ -622,6 +623,34 @@ class _DashboardState extends State {
);
},
),
+ Divider(
+ color: Colors.grey,
+ ),
+ ListTile(
+ title: Row(
+ children: [
+ Image(
+ image: const AssetImage('images/editprofile.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ const SizedBox(
+ width: 10,
+ ),
+ const SizedBox(
+ width: 10,
+ ),
+ Text('Video Call', style: drawerListItemsTextStyle()),
+ ],
+ ),
+ onTap: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => const UpdateProfile()),
+ );
+ },
+ ),
/*Divider(
color: Colors.grey,
),
diff --git a/lib/common/settings.dart b/lib/common/settings.dart
index 31dea47..367008d 100644
--- a/lib/common/settings.dart
+++ b/lib/common/settings.dart
@@ -199,6 +199,48 @@ InputDecoration textFormFieldDecoration(IconData icon, var text) {
);
}
+InputDecoration textFormFieldDecorationGrey(IconData icon, var text) {
+ return InputDecoration(
+ prefixIcon: Icon(
+ icon,
+ color: greyColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: greyColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: greyColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: greyColor),
+ ),
+ labelText: text,
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ );
+}
+
+InputDecoration textFormFieldDecorationInsideApp(IconData icon, var text) {
+ return InputDecoration(
+ prefixIcon: Icon(
+ icon,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: text,
+ labelStyle: TextStyle(
+ color: primaryColor, //<-- SEE HERE
+ ),
+ );
+}
+
InputDecoration textFormFieldDecorationBMI(IconData icon, var text) {
return InputDecoration(
//filled: true,
@@ -216,7 +258,7 @@ InputDecoration textFormFieldDecorationBMI(IconData icon, var text) {
),
labelText: text,
labelStyle: TextStyle(
- //color: Colors.black, //<-- SEE HERE
+ color: Colors.grey, //<-- SEE HERE
),
);
}
@@ -283,9 +325,37 @@ class AppSettings {
static String generateQRCodeUrl = host + 'generate-qrcode-doctor';
static String getAllConectedPatientsDataUrl = host + 'customerDetails';
static String getRecordsDataUrl = host + 'getAllRecords';
+ static String deleteRecordUrl = host + 'deleteRecord';
static String getDynamicCodeUrl = host + 'records';
static String dynamicCodeVerificationUrl = host + 'verifyDynamicCode';
-
+ static String getPatientInformationBasedOnMobileNumberUrl = host + 'getInfoCustomerDataPhone';
+ static String getBmiHistoryUrl = host + 'usersbmi';
+ static String getBpHistoryUrl = host + 'usersbp';
+ static String getSugarHistoryUrl = host + 'userssugar';
+ static String bmiCaluculateUrl = host + 'insertBMI';
+ static String bpCaluculateUrl = host + 'insertBP';
+ static String sugarCaluculateUrl = host + 'insertSugar';
+ static String deleteBMIDetailsUrl = host + 'deleteBMI';
+ static String deleteBPDetailsUrl = host + 'deleteBP';
+ static String deleteSugarDetailsUrl = host + 'deleteSugar';
+ static String findingsUploadPicUrl = host + 'uploads-findings-prescription';
+ static String addFindingsUrl = host + 'update-uploads-findingsPictureId-prescription';
+ static String addReportsUrl = host + 'update-uploads-reportsPictureId-prescription';
+ static String addPrescriptionsUrl = host + 'update-uploads-prescriptionPictureId-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 deleteRecordsUrl = host + 'delete-url';
+ static String updateRecordsUrl = host + 'records';
+ static String deleteFindingsUrl = host + 'delete-uploads-findings';
+ static String deletePrescriptionsUrl = host + 'delete-prescription';
+ static String deleteReportsUrl = host + 'delete-report';
+ static String getAllConnectedDoctorsDataUrl = host + 'connected-doctors';
+ static String addRecordsUrl = host + 'add-record';
+ static String addPrescriptionUrl = host + 'add-prescription-details';
+ static String getAllReportProblemDetalisUrl = host + 'userreport';
static File? updatedImage;
@@ -615,6 +685,37 @@ class AppSettings {
}
}
+ static Future deleteRecord(recordId) async {
+ var uri = Uri.parse(deleteRecordUrl + '/' + recordId);
+
+ try {
+ var response = await http.delete(uri, headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ return true;
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.delete(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ }
+
+
+
static Future getDynamicCode(payload) async {
var uri = Uri.parse(getDynamicCodeUrl );
//uri = uri.replace(query: 'customerId=$customerId');
@@ -662,6 +763,742 @@ class AppSettings {
}
}
+ static Future getPatientInformationBasedOnMobileNumber(phoneNumber) async {
+ var uri = Uri.parse(getPatientInformationBasedOnMobileNumberUrl + '/' + phoneNumber);
+ //uri = uri.replace(query: 'customerId=$customerId');
+
+ var response = await http.get(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.get(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future getBmiHistory(var customerId) async {
+ var uri = Uri.parse(getBmiHistoryUrl + '/' + customerId);
+
+ var response = await http.get(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.get(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future getBPHistory(var customerId) async {
+ var uri = Uri.parse(getBpHistoryUrl + '/' + customerId);
+
+ var response = await http.get(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.get(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future getSugarHistory(var customerId) async {
+ var uri = Uri.parse(getSugarHistoryUrl + '/' + customerId);
+
+ var response = await http.get(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.get(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future calculateBmi(payload,customerId) async {
+ var uri = Uri.parse(bmiCaluculateUrl + '/' + customerId);
+
+ 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.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future calculateBP(payload,customerId) async {
+ var uri = Uri.parse(bpCaluculateUrl + '/' + customerId);
+
+ 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.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future calculateSugar(payload,customerId) async {
+ var uri = Uri.parse(sugarCaluculateUrl + '/' + customerId);
+
+ 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.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future deleteBMIDetails(bmiId,customerId) async {
+ var uri = Uri.parse(deleteBMIDetailsUrl + '/' + customerId+'/'+ bmiId);
+
+ try {
+ var response = await http.delete(uri, headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ return true;
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.delete(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ }
+
+ static Future deleteBPDetails(bmiId,customerId) async {
+ var uri = Uri.parse(deleteBPDetailsUrl + '/' + customerId+'/'+ bmiId);
+
+ try {
+ var response = await http.delete(uri, headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ return true;
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.delete(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ }
+
+ static Future deleteSugarDetails(bmiId,customerId) async {
+ var uri = Uri.parse(deleteSugarDetailsUrl + '/' + customerId+'/'+ bmiId);
+
+ try {
+ var response = await http.delete(uri, headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ return true;
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.delete(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ }
+
+ /*upload and update findings*/
+
+ static Future uploadFindingsGallery(file,customerId) async {
+
+ var request = http.MultipartRequest(
+ 'POST', Uri.parse(findingsUploadPicUrl + '/' + 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 uploadFindingsCamera(file,customerId) async {
+ var request = http.MultipartRequest('POST', Uri.parse(findingsUploadPicUrl + '/' + customerId));
+ request.files.add(await http.MultipartFile.fromPath('picture', file.path));
+ var res = await request.send();
+ var response = await http.Response.fromStream(res);
+ return response.body;
+ }
+
+ static Future addFindingsGallery(file,pictureId,customerId) async {
+
+ var request = http.MultipartRequest(
+ 'PUT', Uri.parse(addFindingsUrl + '/' + customerId+"/"+pictureId));
+ 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 addFindingsCamera(file,pictureId,customerId) async {
+ var request = http.MultipartRequest('PUT', Uri.parse(addFindingsUrl + '/' + customerId+"/"+pictureId));
+ 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 updateFindingsGallery(file,var recordId,customerId) async {
+
+ var request = http.MultipartRequest(
+ 'POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
+ if (file.length > 0) {
+ for (var i = 0; i < file.length; i++) {
+ request.files.add(await http.MultipartFile.fromPath('picture', file[i].path));
+ }}
+ // request.files.add(await http.MultipartFile.fromPath('picture', images.toString().replaceAll('[', '').replaceAll(']','')));
+ var res = await request.send();
+ var response = await http.Response.fromStream(res);
+ return response.body;
+ }
+
+ static Future updateFindingsCamera(file,var recordId,customerId) async {
+ var request = http.MultipartRequest('POST', Uri.parse(updateFindingsUploadPicUrl + '/' + customerId+'/'+recordId));
+ request.files.add(await http.MultipartFile.fromPath('picture', file.path));
+ var res = await request.send();
+ var response = await http.Response.fromStream(res);
+ return response.body;
+ }
+
+ /*End*/
+
+
+ /*upload and update Reports*/
+
+ static Future uploadReportsGallery(file,customerId) 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 uploadReportsCamera(file,customerId) 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 addReportsGallery(file,pictureId,customerId) async {
+
+ var request = http.MultipartRequest(
+ 'PUT', Uri.parse(addReportsUrl + '/' + customerId+"/"+pictureId));
+ 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 addReportsCamera(file,pictureId,customerId) async {
+ var request = http.MultipartRequest('PUT', Uri.parse(addReportsUrl + '/' + customerId+"/"+pictureId));
+ 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 updateReportsGallery(file,var recordId,customerId) 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 updateReportsCamera(file,var recordId,customerId) 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 uploadPrescriptionsGallery(file,customerId) 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 uploadPrescriptionsCamera(file,customerId) 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 addPrescriptionsGallery(file,pictureId,customerId) async {
+
+ var request = http.MultipartRequest(
+ 'PUT', Uri.parse(addPrescriptionsUrl + '/' + customerId+"/"+pictureId));
+ 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 addPrescriptionsCamera(file,pictureId,customerId) async {
+ var request = http.MultipartRequest('PUT', Uri.parse(addPrescriptionsUrl + '/' + customerId+"/"+pictureId));
+ 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 updatePrescriptionsGallery(file,var recordId,customerId) async {
+
+ var request = http.MultipartRequest(
+ '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));
+ }}
+ // 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 updatePrescriptionsCamera(file,var recordId,customerId) 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 deleteRecordsNew(payload, recordId,customerId) 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 '';
+ }
+ }
+
+ static Future updateRecord(payload,recordId) async {
+ var uri = Uri.parse(updateRecordsUrl + '/' + recordId);
+ var response = await http.put(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ try {
+ var _response = json.decode(response.body);
+ print(_response);
+ return true;
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.put(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ static Future deleteFindings(fileName,findingsId,customerId) async {
+ var uri = Uri.parse(deleteFindingsUrl + '/' + customerId+'/'+findingsId+'/'+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 deletePrescriptions(fileName,prescriptionId,customerId) async {
+ var uri = Uri.parse(deletePrescriptionsUrl + '/' + customerId+'/'+prescriptionId+'/'+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 deleteReports(fileName,reportsId,customerId) async {
+ var uri = Uri.parse(deleteReportsUrl + '/' + customerId+'/'+reportsId+'/'+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 getAllConnectedDoctors(customerId) async {
+ var uri = Uri.parse(getAllConnectedDoctorsDataUrl + '/' + customerId);
+ //uri = uri.replace(query: 'customerId=$customerId');
+
+ var response = await http.get(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.get(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
+ static Future addRecords(payload,customerId) async {
+ var uri = Uri.parse(addRecordsUrl + '/' + customerId);
+ var response = await http.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ try {
+ var _response = json.decode(response.body);
+ print(_response);
+ return true;
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ static Future uploadImageHTTPForPrescriptions(file,customerId) 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 addPrescription(payload,customerId) async {
+ var uri = Uri.parse(addPrescriptionUrl + '/' + customerId);
+ var response = await http.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+
+ if (response.statusCode == 200) {
+ try {
+ var _response = json.decode(response.body);
+ print(_response);
+ return true;
+ } catch (e) {
+ print(e);
+ return false;
+ }
+ } else if (response.statusCode == 401) {
+ bool status = await AppSettings.resetToken();
+ if (status) {
+ response = await http.post(uri,
+ body: json.encode(payload), headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ static Future getAllReportProblemDetalis(customerId) async {
+ var uri = Uri.parse(getAllReportProblemDetalisUrl+'/'+customerId);
+ //uri = uri.replace(query: 'customerId=$customerId');
+
+ var response = await http.get(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.get(uri, headers: await buildRequestHeaders());
+ if (response.statusCode == 200) {
+ return response.body;
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ } else {
+ return '';
+ }
+ }
+
/*Apis ends here*/
diff --git a/lib/models/all_problems_model.dart b/lib/models/all_problems_model.dart
new file mode 100644
index 0000000..0904ca3
--- /dev/null
+++ b/lib/models/all_problems_model.dart
@@ -0,0 +1,33 @@
+import 'package:intl/intl.dart';
+
+class AllProblemsModel {
+ String problem='';
+ String audio='';
+ String description='';
+ String video='';
+ String date='';
+ String problemId='';
+ List picture = [];
+ String image='';
+ bool isAudioButtonEnabled=false;
+ DateTime dateForFilter=new DateTime.now();
+ String dateNew='';
+
+ AllProblemsModel();
+
+ factory AllProblemsModel.fromJson(Map json){
+ AllProblemsModel rtvm = new AllProblemsModel();
+
+ rtvm.problem = json['name'] ?? '';
+ rtvm.audio = json['audio'] ?? '';
+ rtvm.description = json['description'] ?? '';
+ rtvm.video = json['video'] ?? '';
+ rtvm.date = json['date'] ?? '';
+ rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.date);
+ rtvm.problemId = json['reportId'] ?? '';
+ rtvm.picture = json['picture'] ?? [];
+ rtvm.image=json['picture'][0]['url']??'';
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/models/bmi_history_model.dart b/lib/models/bmi_history_model.dart
new file mode 100644
index 0000000..4a51b2a
--- /dev/null
+++ b/lib/models/bmi_history_model.dart
@@ -0,0 +1,55 @@
+import 'package:flutter/material.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:intl/intl.dart';
+
+
+class BmiHistoryModel {
+ String bmiValue = '';
+ String height= '';
+ String weight= '';
+ String date= '';
+ String actualDate= '';
+ String displayDate='';
+ DateTime dateForFilter=new DateTime.now();
+ String bmiInfoId = '';
+ String bmiText = '';
+ Color bmiTextColor = Colors.black;
+ var number1;
+ var number2;
+
+ BmiHistoryModel();
+
+ factory BmiHistoryModel.fromJson(Map json){
+ BmiHistoryModel rtvm = new BmiHistoryModel();
+
+ rtvm.bmiValue = json['bmivalue'].toString() ?? '';
+ rtvm.bmiInfoId = json['bmiinfoid'].toString() ?? '';
+ rtvm.height = json['height'].toString() ?? '';
+ rtvm.weight = json['weight'].toString() ?? '';
+ rtvm.number1 = double.parse( rtvm.bmiValue);
+ rtvm.number2 = double.parse( rtvm.bmiValue);
+ rtvm.date = json['createdAt'].toString() ?? '';
+ rtvm.actualDate = json['date'].toString() ?? '';
+ rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.actualDate);
+ if(double.parse(rtvm.bmiValue)<18.5){
+ rtvm.bmiText='Underweight';
+ rtvm.bmiTextColor=Colors.red;
+ }
+ else if(double.parse(rtvm.bmiValue)>=18.5&&double.parse(rtvm.bmiValue)<=24.9){
+ rtvm.bmiText='Normal weight';
+ rtvm.bmiTextColor=buttonColors;
+ }
+ else if(double.parse(rtvm.bmiValue)>=25&&double.parse(rtvm.bmiValue)<=29.9){
+ rtvm.bmiText='Overweight';
+ rtvm.bmiTextColor=Colors.red;
+ }
+ else if(double.parse(rtvm.bmiValue)>=30){
+ rtvm.bmiText='Obesity';
+ rtvm.bmiTextColor=Colors.red;
+ }
+
+
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/models/bp_history_model.dart b/lib/models/bp_history_model.dart
new file mode 100644
index 0000000..49ab801
--- /dev/null
+++ b/lib/models/bp_history_model.dart
@@ -0,0 +1,34 @@
+import 'package:flutter/material.dart';
+import 'package:intl/intl.dart';
+
+
+class BPHistoryModel {
+ String bpText = '';
+ String systolic= '';
+ String diastolic= '';
+ String date= '';
+ String bpId= '';
+ String displayDate='';
+ String actualDate='';
+ DateTime dateForFilter=new DateTime.now();
+
+
+ BPHistoryModel();
+
+ factory BPHistoryModel.fromJson(Map json){
+ BPHistoryModel rtvm = new BPHistoryModel();
+
+ rtvm.bpText = json['bpCategory'].toString() ?? '';
+ rtvm.systolic = json['Systolic'].toString() ?? '';
+ rtvm.diastolic = json['Diastolic'].toString() ?? '';
+ rtvm.date = json['createdAt'].toString() ?? '';
+ rtvm.actualDate = json['date'].toString() ?? '';
+ rtvm.bpId= json['bpinfoid'].toString() ?? '';
+
+ rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.actualDate);
+
+
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/models/get_connected_doctors_model.dart b/lib/models/get_connected_doctors_model.dart
new file mode 100644
index 0000000..53d6ea1
--- /dev/null
+++ b/lib/models/get_connected_doctors_model.dart
@@ -0,0 +1,30 @@
+
+
+class GetConnectedDoctorsModel {
+ String doctor_name='';
+ String doctor_id='';
+ String specialization='';
+ String qualification='';
+ String practiceplace1='';
+ String practiceplace2='';
+ String practiceplace3='';
+ String hospital_name='';
+
+
+
+
+
+ GetConnectedDoctorsModel();
+
+ factory GetConnectedDoctorsModel.fromJson(Map json){
+ GetConnectedDoctorsModel rtvm = new GetConnectedDoctorsModel();
+ rtvm.doctor_name = json['doctorName'] ?? '';
+ rtvm.specialization = json['specialization'] ?? '';
+ rtvm.qualification = json['qualification'] ?? '';
+ rtvm.doctor_id = json['doctorId'] ?? '';
+ rtvm.hospital_name = json['placeOfPractice'][0]['hospitalName'] ?? '';
+
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/models/prescriptions_model.dart b/lib/models/prescriptions_model.dart
new file mode 100644
index 0000000..651e5c7
--- /dev/null
+++ b/lib/models/prescriptions_model.dart
@@ -0,0 +1,40 @@
+import 'package:flutter/material.dart';
+import 'package:doctor/common/settings.dart';
+
+class PrescriptionsModel {
+ String prescription_name = '';
+ String patient_name='';
+ String prescription_url='';
+ String age='';
+ String gender='';
+ String patient_type='';
+ List prescriptionUrls=[];
+
+
+ PrescriptionsModel();
+
+ factory PrescriptionsModel.fromJson(Map json){
+ PrescriptionsModel rtvm = new PrescriptionsModel();
+
+ rtvm.prescriptionUrls=json['precription']??[];
+
+ /*rtvm.prescription_name = json['name'] ?? '';
+ rtvm.patient_type = json['patientType'] ?? '';
+ rtvm.prescription_url = json['pictureUrl'][0] ?? '';
+
+ if(rtvm.patient_type.toString().toLowerCase()=='self'){
+ rtvm.age=AppSettings.age;
+ rtvm.gender=AppSettings.gender;
+ rtvm.patient_name=AppSettings.userName;
+ }
+
+ else{
+ rtvm.age=json['others']['age'].toString();
+ rtvm.gender=json['others']['gender'];
+ rtvm.patient_name=json['others']['name'];
+ }*/
+
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/models/reports_model.dart b/lib/models/reports_model.dart
new file mode 100644
index 0000000..c379b30
--- /dev/null
+++ b/lib/models/reports_model.dart
@@ -0,0 +1,45 @@
+import 'package:flutter/material.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:intl/intl.dart';
+
+class ReportsModel {
+ String patient_name='';
+ String age='';
+ String gender='';
+ String patient_type='';
+ String problem='';
+ String doctorName='';
+ String hospitalName='';
+ String date='';
+ String recordId='';
+ List findingsImages = [];
+ List reportImages = [];
+ List prescriptionImages = [];
+ DateTime dateForFilter=new DateTime.now();
+
+ ReportsModel();
+
+ factory ReportsModel.fromJson(Map json){
+ ReportsModel rtvm = new ReportsModel();
+
+ rtvm.patient_type = json['patientType'] ?? '';
+ rtvm.doctorName = json['doctorName'] ?? '';
+ rtvm.hospitalName = json['hospitalName'] ?? '';
+ rtvm.problem = json['problem'] ?? '';
+ rtvm.date = json['date'] ?? '';
+ rtvm.recordId = json['recordId'] ?? '';
+ rtvm.findingsImages = json['findings'] ?? [];
+ rtvm.reportImages = json['reports'] ?? [];
+ rtvm.prescriptionImages = json['prescription'] ?? [];
+ rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.date);
+
+ if(rtvm.patient_type.toString().toLowerCase()!='self'){
+ rtvm.age=json['others']['age'].toString();
+ rtvm.gender=json['others']['gender'];
+ rtvm.patient_name=json['others']['name'];
+ }
+
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/models/sugar_history_model.dart b/lib/models/sugar_history_model.dart
new file mode 100644
index 0000000..ea09a4a
--- /dev/null
+++ b/lib/models/sugar_history_model.dart
@@ -0,0 +1,62 @@
+import 'package:flutter/material.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:intl/intl.dart';
+
+
+class SugarHistoryModel {
+ String sugartText = '';
+ String sugarValue = '';
+ String fasting= '';
+ String postPrandial= '';
+ String date= '';
+ String displayDate='';
+ String actualDate='';
+ String sugarInfoId='';
+ DateTime dateForFilter=new DateTime.now();
+ Color sugarValueColor=Colors.black;
+
+
+ SugarHistoryModel();
+
+ factory SugarHistoryModel.fromJson(Map json){
+ SugarHistoryModel rtvm = new SugarHistoryModel();
+
+
+ rtvm.sugartText = json['sugarCategory'].toString() ?? '';
+ rtvm.sugarValue = json['sugarValue'].toString() ?? '';
+ rtvm.fasting = json['fasting'].toString() ?? '';
+ rtvm.postPrandial = json['postPrandial'].toString() ?? '';
+ rtvm.date = json['createdAt'].toString() ?? '';
+ rtvm.actualDate = json['date'].toString() ?? '';
+ rtvm.sugarInfoId = json['sugarinfoid'].toString() ?? '';
+
+ if(rtvm.sugartText.toUpperCase().toUpperCase()=='VERY HIGH BLOOD SUGAR'){
+ rtvm.sugarValueColor=Colors.red;
+ }
+ else if(rtvm.sugartText.toUpperCase().toUpperCase()=='HIGH BLOOD SUGAR'){
+ rtvm.sugarValueColor=Colors.red;
+ }
+ else if(rtvm.sugartText.toUpperCase().toUpperCase()=='PREDIABETES (IMPAIRED FASTING GLUCOSE)'){
+ rtvm.sugarValueColor=Colors.red;
+ }
+ else if(rtvm.sugartText.toUpperCase().toUpperCase()=='VERY LOW BLOOD SUGAR'){
+ rtvm.sugarValueColor=Colors.red;
+ }
+ else if(rtvm.sugartText.toUpperCase().toUpperCase()=='LOW BLOOD SUGAR'){
+ rtvm.sugarValueColor=Colors.red;
+ }
+ else if(rtvm.sugartText.toUpperCase().toUpperCase()=='NORMAL BLOOD SUGAR (HEALTHY RANGE)'){
+ rtvm.sugarValueColor=buttonColors;
+ }
+ else{
+ rtvm.sugarValueColor=Colors.black;
+ }
+
+ //DateTime tempDate = new DateFormat("yyyy-MM-dd hh:mm:ss").parse(rtvm.date);
+ rtvm.dateForFilter = DateFormat('dd-MM-yyyy').parse(rtvm.actualDate);
+
+
+ return rtvm;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/patient_dashboard/BMI/bmi_caluculator.dart b/lib/patient_dashboard/BMI/bmi_caluculator.dart
new file mode 100644
index 0000000..f659026
--- /dev/null
+++ b/lib/patient_dashboard/BMI/bmi_caluculator.dart
@@ -0,0 +1,539 @@
+import 'dart:convert';
+import 'package:intl/intl.dart';
+import 'package:flutter/material.dart';
+import 'package:doctor/patient_dashboard/BMI/bmi_history.dart';
+import 'package:doctor/common/settings.dart';
+
+class BMICalculator extends StatefulWidget {
+ String? customerId;
+ BMICalculator({this.customerId});
+
+ @override
+ State createState() => _BMICalculatorState();
+}
+
+class _BMICalculatorState extends State {
+ TextEditingController heightController = TextEditingController();
+ TextEditingController inchesController = TextEditingController();
+ TextEditingController cmsController = TextEditingController();
+ TextEditingController weightController = TextEditingController();
+ TextEditingController ageController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+
+ String bmiValue = '';
+ String bmiText = '';
+ Color bmiTextColor = Colors.black;
+ var heightUnitItems = [
+ 'feet',
+ 'cm',
+ ];
+ var heightUnits = 'feet';
+ var weightUnitItems = [
+ 'kg',
+ ];
+ var weightUnits = 'kg';
+
+ @override
+ void initState() {
+ ageController.text = AppSettings.age;
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Calculate BMI'),
+ body: SingleChildScrollView(
+ child: Container(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ TextFormField(
+ cursorColor: greyColor,
+ controller: ageController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.person,
+ color: primaryColor,
+ ),
+ suffixText: "Yrs",
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Age',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ SizedBox(height: 10),
+ DropdownButtonFormField(
+ // Initial Value
+ value: heightUnits,
+ isExpanded: true,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.ac_unit_outlined,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Select Height units',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+
+ hint: Text('Units'),
+ // Down Arrow Icon
+ //icon: const Icon(Icons.keyboard_arrow_down),
+
+ // Array list of items
+ items: heightUnitItems.map((String items) {
+ return DropdownMenuItem(
+ value: items,
+ child: Text(
+ items,
+ style: TextStyle(
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ));
+ }).toList(),
+ // After selecting the desired option,it will
+ // change button value to selected value
+ onChanged: (String? newValue) {
+ setState(() {
+ heightUnits = newValue!;
+ });
+ },
+ ),
+ SizedBox(height: 10),
+ Visibility(
+ visible: heightUnits == 'feet',
+ child: Container(
+ //height: 60,
+ child: Row(
+ children: [
+ Expanded(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: heightController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.height,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Feets',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+ Expanded(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: inchesController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.height,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Inches',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+ ],
+ ),
+ ),
+ ),
+ Visibility(
+ visible: heightUnits == 'cm',
+ child: Container(
+ //height: 60,
+ child: Row(
+ children: [
+ Expanded(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: cmsController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.height,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Enter height in cms',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ //height: 40,
+ padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
+ child: Row(
+ children: [
+ Expanded(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: weightController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.line_weight_outlined,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Weight',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+ Expanded(
+ child: DropdownButtonFormField(
+ // Initial Value
+ value: weightUnits,
+ isExpanded: true,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.ac_unit_outlined,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Units',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+
+ hint: Text('Units'),
+ // Down Arrow Icon
+ //icon: const Icon(Icons.keyboard_arrow_down),
+
+ // Array list of items
+ items: weightUnitItems.map((String items) {
+ return DropdownMenuItem(
+ value: items,
+ child: Text(
+ items,
+ style: TextStyle(
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ));
+ }).toList(),
+ // After selecting the desired option,it will
+ // change button value to selected value
+ onChanged: (String? newValue) {
+ setState(() {
+ weightUnits = newValue!;
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: dateInput,
+ decoration: textFormFieldDecorationBMI(
+ Icons.calendar_today, 'Enter Date'),
+ readOnly: true,
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ dateInput.text =
+ formattedDate; //set output date to TextField value.
+ });
+ } else {}
+ },
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .05,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ if (ageController.text != '' &&
+ heightController.text != '' ||
+ cmsController.text != '' &&
+ weightController.text != '' &&
+ dateInput.text != '') {
+ if (int.parse(heightController.text) > 7) {
+ AppSettings.longFailedToast(
+ 'Please enter feet below 8 feets');
+ } else if (int.parse(inchesController.text) > 12) {
+ AppSettings.longFailedToast(
+ 'Please enter inches below 12');
+ } else if (int.parse(heightController.text) == 0 &&
+ int.parse(inchesController.text) < 6) {
+ AppSettings.longFailedToast(
+ 'Please enter inches above 6');
+ } else {
+ AppSettings.preLoaderDialog(context);
+ var payload = new Map();
+
+ if (heightUnits.toString().toLowerCase() ==
+ 'feet') {
+ cmsController.text = '';
+ } else {
+ heightController.text = '';
+ inchesController.text = '';
+ }
+
+ payload["age"] =
+ int.parse(ageController.text.toString());
+ payload["feet"] = heightController.text.toString();
+ payload["inches"] =
+ inchesController.text.toString();
+ payload["height"] = cmsController.text.toString();
+ payload["weight"] =
+ weightController.text.toString();
+ payload["heightUnit"] = heightUnits.toString();
+ payload["weightUnit"] = weightUnits.toString();
+ payload["date"] = dateInput.text.toString();
+
+ try {
+ var value =
+ await AppSettings.calculateBmi(payload,widget.customerId);
+ var valueResponse = jsonDecode(value);
+ Navigator.of(context, rootNavigator: true).pop();
+ heightController.clear();
+ cmsController.clear();
+ inchesController.clear();
+ weightController.clear();
+ dateInput.clear();
+ setState(() {
+ bmiValue = valueResponse['userDetails']
+ ['bmivalue']
+ .toString();
+ if (double.parse(bmiValue) < 18.5) {
+ bmiText = 'Underweight';
+ bmiTextColor=Colors.red;
+ } else if (double.parse(bmiValue) >= 18.5 &&
+ double.parse(bmiValue) <= 24.9) {
+ bmiText = 'Normal weight';
+ bmiTextColor=buttonColors;
+ } else if (double.parse(bmiValue) >= 25 &&
+ double.parse(bmiValue) <= 29.9) {
+ bmiText = 'Overweight';
+ bmiTextColor=Colors.red;
+ } else if (double.parse(bmiValue) >= 30) {
+ bmiText = 'Obesity';
+ bmiTextColor=Colors.red;
+ }
+ });
+ } catch (e) {
+ Navigator.of(context, rootNavigator: true).pop();
+ AppSettings.longFailedToast(
+ 'Calculating BMI failed');
+ }
+ }
+ } else {
+ AppSettings.longFailedToast(
+ 'Please enter valid details');
+ }
+ },
+ child: const Text('Calculate BMI'),
+ )),
+ SizedBox(height: 20),
+ Container(
+ child: Row(
+ children: [
+ Text(
+ 'Your BMI value: $bmiValue',
+ style:
+ TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
+ ),
+ SizedBox(
+ width: 10,
+ ),
+ Text(bmiText,
+ style: TextStyle(
+ color: bmiTextColor, fontWeight: FontWeight.bold,fontSize: 20)),
+ ],
+ )),
+ SizedBox(height: 30),
+ Container(
+ child: Text(
+ 'Underweight = <18.5',
+ style: bmiTextStyle(),
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ child:
+ Text('Normal weight = 18.5–24.9', style: bmiTextStyle()),
+ ),
+ SizedBox(height: 10),
+ Container(
+ child: Text('Overweight = 25–29.9', style: bmiTextStyle()),
+ ),
+ SizedBox(height: 10),
+ Container(
+ child: Text('Obesity = BMI of 30 or greater',
+ style: bmiTextStyle()),
+ ),
+ SizedBox(height: 20),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Column(
+ children: [
+ IconButton(
+ onPressed: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => BMIHistory(customerId: widget.customerId,)),
+ );
+ },
+ icon: Icon(
+ Icons.history,
+ color: primaryColor,
+ size: 40,
+ ),
+ ),
+ SizedBox(height: 10),
+ Padding(
+ padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
+ child: Container(
+ child: Text('History',
+ style: TextStyle(
+ color: Colors.black,
+ fontSize: 12,
+ fontWeight: FontWeight.bold,
+ )),
+ ),
+ )
+ ],
+ ),
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ Navigator.pop(context);
+ },
+ child: const Text('Cancel'),
+ )
+ ],
+ )
+ ],
+ ),
+ )),
+ ));
+ }
+}
diff --git a/lib/patient_dashboard/BMI/bmi_history.dart b/lib/patient_dashboard/BMI/bmi_history.dart
new file mode 100644
index 0000000..ff8d882
--- /dev/null
+++ b/lib/patient_dashboard/BMI/bmi_history.dart
@@ -0,0 +1,424 @@
+import 'dart:convert';
+import 'package:doctor/patient_dashboard/BMI/bmi_caluculator.dart';
+import 'package:flutter/material.dart';
+import 'package:doctor/models/bmi_history_model.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:flutter_slidable/flutter_slidable.dart';
+
+class BMIHistory extends StatefulWidget {
+ String? customerId;
+ BMIHistory({this.customerId});
+
+
+ @override
+ State createState() => _BMIHistoryState();
+}
+
+class _BMIHistoryState extends State {
+ bool isLoading = false;
+ List bmiHistoryList = [];
+ List FilteredList = [];
+ var dateItems = [
+ 'All',
+ 'last 7 days',
+ 'last one month',
+ 'last one year',
+ ];
+ var dateItemsVariable = 'All';
+
+ Future getBmiHistoryDetails(var selectedRange) async {
+ isLoading = true;
+ var response1 = await AppSettings.getBmiHistory(widget.customerId);
+ print(response1);
+ setState(() {
+ bmiHistoryList = ((jsonDecode(response1)) as List).map((dynamic model) {
+ return BmiHistoryModel.fromJson(model);
+ }).toList();
+
+ var now = new DateTime.now();
+ var now_1w = now.subtract(Duration(days: 7));
+ var now_1m = new DateTime(now.year, now.month - 1, now.day);
+ var now_1y = new DateTime(now.year - 1, now.month, now.day);
+
+ if (selectedRange.toString().toUpperCase() == 'LAST 7 DAYS') {
+ FilteredList = bmiHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1w.isBefore(date);
+ //reportsList=reportsListOriginal.reversed.toList();
+ }).toList();
+ }
+ else if (selectedRange.toString().toUpperCase() == 'LAST ONE MONTH') {
+ FilteredList = bmiHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1m.isBefore(date);
+ }).toList();
+ }
+ else if (selectedRange.toString().toUpperCase() == 'LAST ONE YEAR') {
+ FilteredList = bmiHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1y.isBefore(date);
+ }).toList();
+ }
+ else {
+ FilteredList = bmiHistoryList;
+ }
+
+ isLoading = false;
+ });
+ }
+
+ @override
+ void initState() {
+ getBmiHistoryDetails(dateItemsVariable);
+ super.initState();
+ }
+
+ deleteBmiHistory(bmiId) async{
+
+ AppSettings.preLoaderDialog(context);
+ bool status = await AppSettings.deleteBMIDetails(bmiId,widget.customerId);
+
+ if(status){
+ Navigator.of(context, rootNavigator: true).pop();
+
+ AppSettings.longSuccessToast("BMI record deleted successfully");
+ await getBmiHistoryDetails(dateItemsVariable);
+ }
+ else{
+ Navigator.of(context, rootNavigator: true).pop();
+
+ AppSettings.longFailedToast("BMI record deletion failed");
+ }
+
+
+
+ }
+
+ Widget renderzUi() {
+ if (FilteredList.length != 0) {
+ FilteredList.sort((a, b) => a.actualDate.compareTo(b.actualDate));
+ return Column(crossAxisAlignment: CrossAxisAlignment.end, children: [
+ Padding(
+ padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
+ child: DropdownButtonFormField(
+ // Initial Value
+ value: dateItemsVariable,
+ isExpanded: true,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Select Date Range',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+
+ hint: Text('Units'),
+ // Down Arrow Icon
+ //icon: const Icon(Icons.keyboard_arrow_down),
+
+ // Array list of items
+ items: dateItems.map((String items) {
+ return DropdownMenuItem(
+ value: items,
+ child: Text(
+ items,
+ style: TextStyle(
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ));
+ }).toList(),
+ // After selecting the desired option,it will
+ // change button value to selected value
+ onChanged: (String? newValue) {
+ setState(() {
+ dateItemsVariable = newValue!;
+ });
+ getBmiHistoryDetails(dateItemsVariable);
+ },
+ ),
+ ),
+ IconButton(
+ onPressed: () {
+ /*Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => BmiChart()),
+ );*/
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new BmiChart(myObject: FilteredList)));*/
+ // showBMIAdddialog();
+ },
+ icon: Icon(
+ Icons.auto_graph,
+ color: primaryColor,
+ ),
+ ),
+ Expanded(
+ child: ListView.builder(
+ padding: EdgeInsets.all(0),
+ itemCount: FilteredList.length,
+ itemBuilder: (BuildContext context, int index) {
+ return Slidable(
+ key: const ValueKey(0),
+ endActionPane: ActionPane(
+ // A motion is a widget used to control how the pane animates.
+ motion: ScrollMotion(),
+
+ dragDismissible: false,
+ // A pane can dismiss the Slidable.
+ dismissible: DismissiblePane(onDismissed: () {
+ deleteBmiHistory(FilteredList[index].bmiInfoId);
+ }),
+
+ // All actions are defined in the children parameter.
+ children: [
+ // A SlidableAction can have an icon and/or a label.
+ SlidableAction(
+ backgroundColor: Color(0xFFFE4A49),
+ foregroundColor: Colors.white,
+ icon: Icons.delete,
+ label: 'Delete',
+ onPressed: (BuildContext context) {
+ deleteBmiHistory(FilteredList[index].bmiInfoId);
+ },
+ ),
+ /*SlidableAction(
+ onPressed: doNothing,
+ backgroundColor: Color(0xFF21B7CA),
+ foregroundColor: Colors.white,
+ icon: Icons.share,
+ label: 'Share',
+ ),*/
+ ],
+ ),
+ child: Card(
+ color: Colors.white,
+ child: Padding(
+ padding: EdgeInsets.all(8),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Container(
+ width: MediaQuery.of(context).size.width * .55,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image: const AssetImage(
+ 'images/height.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index]
+ .height
+ .toString()
+ .toUpperCase() +
+ ' cms',
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image: const AssetImage(
+ 'images/weight.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index]
+ .weight
+ .toString()
+ .toUpperCase() +
+ ' Kgs',
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image:
+ const AssetImage('images/date.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index]
+ .actualDate
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image: const AssetImage(
+ 'images/bmi.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index]
+ .bmiValue
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image: const AssetImage(
+ 'images/bmi.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index].bmiText
+ .toString()
+ .toUpperCase(),
+ style: TextStyle(
+ fontSize: 12,
+ fontWeight: FontWeight.bold,color: FilteredList[index].bmiTextColor
+ )),
+ )
+ ],
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+
+ })),
+ ]);
+ }
+ else {
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .25,
+ ),
+ Text('No Data'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => BMICalculator(customerId:widget.customerId))).then((value) {
+ getBmiHistoryDetails(dateItemsVariable);
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ));
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Body Mass Index'),
+ body: isLoading
+ ? Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ )
+ : renderzUi(),
+ floatingActionButton: Visibility(
+ visible:FilteredList.length!=0,
+ child: CircleAvatar(
+ backgroundColor: buttonColors,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.black,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => BMICalculator(customerId: widget.customerId,))).then((value) {
+ getBmiHistoryDetails(dateItemsVariable);
+ });
+ },
+ ),
+ /* Padding(
+ padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
+ child: Text(
+ 'Add Tanks ',
+ style: TextStyle(color: Colors.white),
+ ),
+ )*/
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/BP/bp_calculator.dart b/lib/patient_dashboard/BP/bp_calculator.dart
new file mode 100644
index 0000000..1807ed4
--- /dev/null
+++ b/lib/patient_dashboard/BP/bp_calculator.dart
@@ -0,0 +1,228 @@
+import 'dart:convert';
+import 'package:flutter/material.dart';
+import 'package:doctor/patient_dashboard/BP/bp_history.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:intl/intl.dart';
+
+class BPCalculator extends StatefulWidget {
+ String? customerId;
+ BPCalculator({this.customerId});
+
+ @override
+ State createState() => _BPCalculatorState();
+}
+
+class _BPCalculatorState extends State {
+
+ TextEditingController systoloicController = TextEditingController();
+ TextEditingController diastolicController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ String bpValue = '';
+ String bpText = '';
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Blood Pressure'),
+ body: SingleChildScrollView(
+ child: Container(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ TextFormField(
+ cursorColor: greyColor,
+ controller: systoloicController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.upload,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Enter systolic value',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ SizedBox(height: 10),
+ TextFormField(
+ cursorColor: greyColor,
+ controller: diastolicController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.download,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Enter diastolic value',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: dateInput,
+ decoration: textFormFieldDecorationBMI(
+ Icons.calendar_today, 'Enter Date'),
+ readOnly: true,
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ dateInput.text =
+ formattedDate; //set output date to TextField value.
+ });
+ } else {}
+ },
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ width: double.infinity,
+ height:
+ MediaQuery.of(context).size.height * .05,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ if (systoloicController.text != '' &&
+ diastolicController.text != ''&&dateInput.text!='') {
+
+ if(int.parse(systoloicController.text)>int.parse(diastolicController.text)){
+ AppSettings.preLoaderDialog(context);
+ var payload = new Map();
+
+ payload["Systolic"] = double.parse(systoloicController.text.toString());
+ payload["Diastolic"] = double.parse(diastolicController.text.toString());
+ payload["date"] =dateInput.text.toString();
+
+ var value = await AppSettings.calculateBP(payload,widget.customerId);
+ var valueResponse = jsonDecode(value);
+ print(valueResponse);
+ setState(() {
+ bpValue = valueResponse['userDetails']['bpCategory'].toString();
+ });
+ systoloicController.clear();
+ diastolicController.clear();
+ dateInput.clear();
+ Navigator.of(context,rootNavigator: true).pop();
+ }
+ else{
+ AppSettings.longFailedToast('Please enter diastolic value less than systolic value');
+ }
+ }
+ else{
+ AppSettings.longFailedToast('Please enter valid details');
+ }
+ },
+ child: const Text('Check BP'),
+ )),
+ SizedBox(height: 20),
+ Container(
+ child: Row(
+ children: [
+ Text(bpValue,style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 15),),
+ ],
+ )
+ ),
+ SizedBox(height: 20),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Column(
+ children: [
+ IconButton(
+ onPressed: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => BPHistory(customerId: widget.customerId,)),
+ );
+ },
+ icon: Icon(
+ Icons.history,
+ color: primaryColor,
+ size: 40,
+ ),
+ ),
+ SizedBox(height: 10),
+ Padding(padding: EdgeInsets.fromLTRB(10,0,0,0),
+ child: Container(
+ child: Text('History',style:TextStyle(color:Colors.black,fontSize: 12,fontWeight: FontWeight.bold,)),
+ ),)
+ ],
+ ),
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ Navigator.pop(context);
+ },
+ child: const Text('Cancel'),
+ )
+ ],
+ )
+
+
+ ],
+ ),
+ )
+ ),
+ )
+ );
+ }
+}
diff --git a/lib/patient_dashboard/BP/bp_history.dart b/lib/patient_dashboard/BP/bp_history.dart
new file mode 100644
index 0000000..d7d76ed
--- /dev/null
+++ b/lib/patient_dashboard/BP/bp_history.dart
@@ -0,0 +1,372 @@
+import 'dart:convert';
+import 'package:flutter/material.dart';
+import 'package:doctor/patient_dashboard/BP/bp_calculator.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/models/bp_history_model.dart';
+import 'package:flutter_slidable/flutter_slidable.dart';
+
+class BPHistory extends StatefulWidget {
+ String? customerId;
+ BPHistory({this.customerId});
+
+ @override
+ State createState() => _BPHistoryState();
+}
+
+class _BPHistoryState extends State {
+ bool isLoading = false;
+ List BpHistoryList = [];
+ List FilteredList = [];
+ var dateItems = [
+ 'All',
+ 'last 7 days',
+ 'last one month',
+ 'last one year',
+ ];
+ var dateItemsVariable = 'All';
+
+ Future getBPHistoryDetails(var selectedRange) async {
+ isLoading = true;
+ var response1 = await AppSettings.getBPHistory(widget.customerId);
+ print(response1);
+ setState(() {
+ BpHistoryList = ((jsonDecode(response1)) as List).map((dynamic model) {
+ return BPHistoryModel.fromJson(model);
+ }).toList();
+
+ var now = new DateTime.now();
+ var now_1w = now.subtract(Duration(days: 7));
+ var now_1m = new DateTime(now.year, now.month - 1, now.day);
+ var now_1y = new DateTime(now.year - 1, now.month, now.day);
+
+ if (selectedRange.toString().toUpperCase() == 'LAST 7 DAYS') {
+ FilteredList = BpHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1w.isBefore(date);
+ }).toList();
+ } else if (selectedRange.toString().toUpperCase() == 'LAST ONE MONTH') {
+ FilteredList = BpHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1m.isBefore(date);
+ }).toList();
+ } else if (selectedRange.toString().toUpperCase() == 'LAST ONE YEAR') {
+ FilteredList = BpHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1y.isBefore(date);
+ }).toList();
+ } else {
+ FilteredList = BpHistoryList;
+ }
+
+ isLoading = false;
+ });
+ }
+
+ @override
+ void initState() {
+ getBPHistoryDetails(dateItemsVariable);
+ super.initState();
+ }
+
+ deleteBpRecord(bpId) async {
+ AppSettings.preLoaderDialog(context);
+ bool status = await AppSettings.deleteBPDetails(bpId,widget.customerId);
+
+ if (status) {
+ Navigator.of(context, rootNavigator: true).pop();
+
+ AppSettings.longSuccessToast("BP record deleted successfully");
+ await getBPHistoryDetails(dateItemsVariable);
+ } else {
+ Navigator.of(context, rootNavigator: true).pop();
+
+ AppSettings.longFailedToast("BP record deletion failed");
+ }
+ }
+
+ Widget renderzUi() {
+ if (FilteredList.length != 0) {
+ FilteredList.sort((a, b) => b.actualDate.compareTo(a.actualDate));
+ return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
+ Padding(
+ padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
+ child: DropdownButtonFormField(
+ // Initial Value
+ value: dateItemsVariable,
+ isExpanded: true,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Select Date Range',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+
+ hint: Text('Units'),
+ // Down Arrow Icon
+ //icon: const Icon(Icons.keyboard_arrow_down),
+
+ // Array list of items
+ items: dateItems.map((String items) {
+ return DropdownMenuItem(
+ value: items,
+ child: Text(
+ items,
+ style: TextStyle(
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ));
+ }).toList(),
+ // After selecting the desired option,it will
+ // change button value to selected value
+ onChanged: (String? newValue) {
+ setState(() {
+ dateItemsVariable = newValue!;
+ });
+ getBPHistoryDetails(dateItemsVariable);
+ },
+ ),
+ ),
+ IconButton(
+ onPressed: () {
+ /* Navigator.push(
+ context,
+ MaterialPageRoute(builder: (context) => Bpchart()),
+ );*/
+ // showBMIAdddialog();
+ },
+ icon: Icon(
+ Icons.auto_graph,
+ color: primaryColor,
+ ),
+ ),
+ Expanded(
+ child: ListView.builder(
+ padding: EdgeInsets.all(0),
+ itemCount: FilteredList.length,
+ itemBuilder: (BuildContext context, int index) {
+ return Slidable(
+ key: const ValueKey(0),
+ endActionPane: ActionPane(
+ // A motion is a widget used to control how the pane animates.
+ motion: ScrollMotion(),
+
+ dragDismissible: false,
+ // A pane can dismiss the Slidable.
+ dismissible: DismissiblePane(onDismissed: () {
+ deleteBpRecord(FilteredList[index].bpId);
+ }),
+
+ // All actions are defined in the children parameter.
+ children: [
+ // A SlidableAction can have an icon and/or a label.
+ SlidableAction(
+ backgroundColor: Color(0xFFFE4A49),
+ foregroundColor: Colors.white,
+ icon: Icons.delete,
+ label: 'Delete',
+ onPressed: (BuildContext context) {
+ deleteBpRecord(FilteredList[index].bpId);
+ },
+ ),
+ ],
+ ),
+ child: Card(
+ color: Colors.white,
+ child: Padding(
+ padding: EdgeInsets.all(8),
+ child: Container(
+ //width: MediaQuery.of(context).size.width * .55,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ /* Image(
+ image: const AssetImage('images/height.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),*/
+ Text(
+ 'Systolic',
+ style: TextStyle(color: primaryColor),
+ ),
+ SizedBox(
+ width: 5,
+ ),
+ Padding(
+ padding: EdgeInsets.all(1),
+ child: Text(
+ FilteredList[index]
+ .systolic
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'Diastolic',
+ style: TextStyle(color: primaryColor),
+ ),
+ Padding(
+ padding: EdgeInsets.all(1),
+ child: Text(
+ FilteredList[index]
+ .diastolic
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image: const AssetImage(
+ 'images/height.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index]
+ .bpText
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Image(
+ image:
+ const AssetImage('images/date.png'),
+ height: 25,
+ width: 25,
+ fit: BoxFit.fill),
+ Padding(
+ padding: EdgeInsets.all(5),
+ child: Text(
+ FilteredList[index]
+ .actualDate
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ )
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ ));
+ })),
+ ]);
+ } else {
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .25,
+ ),
+ Text('No data'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => BPCalculator(customerId: widget.customerId,))).then((value) {
+ getBPHistoryDetails(dateItemsVariable);
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ));
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Blood Pressure'),
+ body: isLoading
+ ? Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ )
+ : renderzUi(),
+ floatingActionButton: Visibility(
+ visible:FilteredList.length!=0,
+ child: CircleAvatar(
+ backgroundColor: buttonColors,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.black,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => BPCalculator(customerId: widget.customerId,))).then((value) {
+ getBPHistoryDetails(dateItemsVariable);
+ });
+ },
+ ),
+ /* Padding(
+ padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
+ child: Text(
+ 'Add Tanks ',
+ style: TextStyle(color: Colors.white),
+ ),
+ )*/
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/Reports/add_reports.dart b/lib/patient_dashboard/Reports/add_reports.dart
new file mode 100644
index 0000000..07c7473
--- /dev/null
+++ b/lib/patient_dashboard/Reports/add_reports.dart
@@ -0,0 +1,1274 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/common/zoom_image.dart';
+import 'package:doctor/models/get_connected_doctors_model.dart';
+import 'package:intl/intl.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:multi_image_picker/multi_image_picker.dart';
+
+class AddReports extends StatefulWidget {
+ String? customerId;
+ String? patName;
+ String? patAge;
+ String? patGender;
+ AddReports({this.customerId,this.patName,this.patAge,this.patGender});
+
+
+ @override
+ State createState() => _AddReportsState();
+}
+
+class _AddReportsState extends State {
+
+ TextEditingController doctorNameController = TextEditingController();
+ TextEditingController hospitalNameController = TextEditingController();
+ TextEditingController problemController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ TextEditingController patientNameController = TextEditingController();
+ TextEditingController patientAgeController = TextEditingController();
+ final ImagePicker _picker = ImagePicker();
+ String Url = '';
+ final ImagePicker imagePicker = ImagePicker();
+ List imageFileList = [];
+ List imageFileListReports = [];
+ List imageFileListPrescriptions = [];
+ List uiFindingsImages = [];
+ List uiReportsImages = [];
+ List uiPrescriptionImages = [];
+ Map findings={};
+ List images = [];
+ String _error = 'No Error Dectected';
+ String apiMultiImages = '';
+ String findingPictureId = '';
+ String reportsPictureId = '';
+ String prescriptionPictureId = '';
+ Map reports={};
+ Map prescriptions={};
+ String? prescriptionFor;
+ String? problemCategory;
+ String? gender;
+ var doctorNameVariable;
+ List connectedDoctorsListOriginal = [];
+
+ Future getAllConnectedDoctors() async {
+ try {
+ var response = await AppSettings.getAllConnectedDoctors(widget.customerId);
+
+ setState(() {
+ connectedDoctorsListOriginal = ((jsonDecode(response)['doctors']) as List)
+ .map((dynamic model) {
+ return GetConnectedDoctorsModel.fromJson(model);
+ }).toList();
+ //connectedDoctorsListOriginal=connectedDoctorsListOriginal.reversed.toList();
+ //dateItemsVariable=connectedDoctorsListOriginal[0].doctor_name;
+ });
+ } catch (e) {
+ AppSettings.longFailedToast('There is an issue please wait some time');
+ }
+ }
+
+ @override
+ void initState() {
+ getAllConnectedDoctors();
+ super.initState();
+ }
+
+ Future pickImageFromGallery() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.uploadFindingsGallery(imageFileList,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings'];
+ findings=jsonDecode(res)['findingsPictureUpload'];
+ findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId'];
+
+ });
+ }
+
+ 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.uploadFindingsCamera(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings'];
+ findings=jsonDecode(res)['findingsPictureUpload'];
+ findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForAddFindings() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.addFindingsGallery(imageFileList,findingPictureId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings'];
+ findings=jsonDecode(res)['findingsPictureUpload'];
+ findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId'];
+
+ });
+ }
+
+ Future takeImageFromCameraForAddFindings() 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.addFindingsCamera(image,findingPictureId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['findingsPictureUpload']['findings'];
+ findings=jsonDecode(res)['findingsPictureUpload'];
+ findingPictureId=jsonDecode(res)['findingsPictureUpload']['findingsPictureId'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future takeImageFromCameraForReports() async {
+ try {
+ final image = await _picker.pickImage(source: ImageSource.camera);
+ if (image == null) return;
+ final imageTemp = File(image.path);
+ AppSettings.preLoaderDialog(context);
+ var res = await AppSettings.uploadReportsCamera(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports'];
+ reports=jsonDecode(res)['reportsPictureUpload'];
+ reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForReports() async {
+ imageFileListReports = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileListReports.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.uploadReportsGallery(imageFileListReports,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports'];
+ reports=jsonDecode(res)['reportsPictureUpload'];
+ reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId'];
+ });
+ }
+
+ Future takeImageFromCameraForAddReports() 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.addReportsCamera(image,reportsPictureId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports'];
+ reports=jsonDecode(res)['reportsPictureUpload'];
+ reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForAddReports() async {
+ imageFileListReports = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileListReports.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.addReportsGallery(imageFileListReports,reportsPictureId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages = jsonDecode(res)['reportsPictureUpload']['reports'];
+ reports=jsonDecode(res)['reportsPictureUpload'];
+ reportsPictureId=jsonDecode(res)['reportsPictureUpload']['reportsPictureId'];
+ });
+ }
+
+ 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.uploadPrescriptionsCamera(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+
+ uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription'];
+ prescriptions=jsonDecode(res)['prescriptionsPictureUpload'];
+ prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId'];
+
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForPrescriptions() async {
+ // imageFileListPrescriptions = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileListPrescriptions.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.uploadPrescriptionsGallery(
+ imageFileListPrescriptions,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription'];
+ prescriptions=jsonDecode(res)['prescriptionsPictureUpload'];
+ prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId']??'';
+ });
+ }
+
+ Future takeImageFromCameraForAddPrescriptions() 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.addPrescriptionsCamera(image,prescriptionPictureId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription'];
+ prescriptions=jsonDecode(res)['prescriptionsPictureUpload'];
+ prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForAddPrescriptions() async {
+ imageFileListPrescriptions = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileListPrescriptions.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.addPrescriptionsGallery(imageFileListPrescriptions,prescriptionPictureId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiPrescriptionImages = jsonDecode(res)['prescriptionsPictureUpload']['precription'];
+ prescriptions=jsonDecode(res)['prescriptionsPictureUpload'];
+ prescriptionPictureId=jsonDecode(res)['prescriptionsPictureUpload']['prescriptionPictureId'];
+ });
+ }
+
+ Future onWillPop() async {
+ final shouldPop = await showDialog(context: context, builder: (context) {
+ return AlertDialog(
+ title: const Text('Do you want to leave this page',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment: MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(false);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ );
+ },
+ );
+ return shouldPop!;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return WillPopScope(
+ onWillPop: () async => onWillPop(),
+ child: Scaffold(
+ appBar: AppSettings.appBar('Add Record'),
+ body: SingleChildScrollView(
+ child: Container(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ child: connectedDoctorsListOriginal.length!=0?DropdownButtonFormField(
+ value: doctorNameVariable,
+ isExpanded: true,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.person,
+ color: greyColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Select Doctor',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+
+ hint: Text('Please Select Doctor'),
+ // Down Arrow Icon
+ //icon: const Icon(Icons.keyboard_arrow_down),
+
+ // Array list of items
+ items: connectedDoctorsListOriginal.map((items) {
+ return DropdownMenuItem(
+ value: items,
+ child: Text(
+ items.doctor_name,
+ style: TextStyle(
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ));
+ }).toList(),
+ // After selecting the desired option,it will
+ // change button value to selected value
+ onChanged: ( newValue) {
+ setState(() {
+ doctorNameVariable = newValue;
+ });
+ },
+ ):
+ IconButton(
+ onPressed: () {
+ /*Navigator.push(context, MaterialPageRoute(builder: (context) => AddDoctor())).then((value) {
+ getAllConnectedDoctors();
+ });*/
+ },
+ icon: Icon(
+ Icons.add,
+ color: primaryColor,
+ size: 40,
+ ),
+ ),),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: problemController,
+ textCapitalization: TextCapitalization.words,
+ decoration: textFormFieldDecorationGrey(
+ Icons.report_problem, 'Enter Problem'),
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: dateInput,
+ decoration: textFormFieldDecorationGrey(
+ Icons.calendar_today, 'Enter Date'),
+ readOnly: true,
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ dateInput.text =
+ formattedDate; //set output date to TextField value.
+ });
+ } else {}
+ },
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Text('Select Problem Category',
+ style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 14),),
+ Row(
+ children: [
+ Expanded(
+ child: RadioListTile(
+ title: Text("General"),
+ value: "general",
+ groupValue: problemCategory,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ problemCategory = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title: Text("Confidential"),
+ value: "confidential",
+ groupValue: problemCategory,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ problemCategory = value.toString();
+ });
+ },
+ ),
+ ),
+ ],
+ ),
+ Text('Select Problem For',
+ style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 14),),
+ Row(
+ children: [
+ Expanded(
+ child: RadioListTile(
+ title: Text("For Yourself"),
+ value: "self",
+ groupValue: prescriptionFor,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ prescriptionFor = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title: Text("For Family"),
+ value: "others",
+ groupValue: prescriptionFor,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ prescriptionFor = value.toString();
+ });
+ },
+ ),
+ ),
+ ],
+ ),
+ Visibility(
+ visible:
+ prescriptionFor.toString().toLowerCase() == 'others',
+ child: Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: patientNameController,
+ decoration: textFormFieldDecoration(
+ Icons.person, 'Enter patient name'),
+ ),
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Visibility(
+ visible:
+ prescriptionFor.toString().toLowerCase() == 'others',
+ child: Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ keyboardType: TextInputType.number,
+ controller: patientAgeController,
+ decoration: textFormFieldDecoration(
+ Icons.person, 'Enter patient age'),
+ ),
+ ),
+ ),
+ Visibility(
+ visible:
+ prescriptionFor.toString().toLowerCase() == 'others',
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: RadioListTile(
+ title: Text("Male", style: TextStyle(fontSize: 10)),
+ value: "male",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title: Text(
+ "Female",
+ style: TextStyle(fontSize: 10),
+ ),
+ value: "female",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title:
+ Text("Others", style: TextStyle(fontSize: 10)),
+ value: "other",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+
+ /*findings*/
+ Visibility(
+ visible: uiFindingsImages.length == 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCamera();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGallery();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select Findings'),
+ ),
+ ),
+ Visibility(
+ visible: uiFindingsImages.length > 0,
+ child: Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: uiFindingsImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:uiFindingsImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ uiFindingsImages[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 = uiFindingsImages[index]['url'].split('/').last;
+ try{
+ var response = await AppSettings.deleteFindings(fileName,findingPictureId,widget.customerId);
+ print(jsonDecode(response));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(response)['findingsPictureUpload']['findings'];
+ });
+ }
+ catch(e){
+ Navigator.of(context, rootNavigator: true).pop();
+ AppSettings.longFailedToast('Image deletion failed');
+ }
+
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ )),
+ Visibility(
+ visible: uiFindingsImages.length != 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForAddFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForAddFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Add Findings'),
+ ),
+ ),
+
+ /*reports*/
+ Visibility(
+ visible: uiReportsImages.length == 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select Reports'),
+ ),
+ ),
+ Visibility(
+ visible: uiReportsImages.length > 0,
+ child: Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: uiReportsImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:uiReportsImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ uiReportsImages[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 = uiReportsImages[index]['url'].split('/').last;
+ var response = await AppSettings.deleteReports(fileName,reportsPictureId,widget.customerId);
+ print(jsonDecode(response));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages = jsonDecode(response)['reportsPictureUpload']['reports'];
+ });
+
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ )
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ )),
+ Visibility(
+ visible: uiReportsImages.length != 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForAddReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForAddReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Add Reports'),
+ ),
+ ),
+
+ /*prescriptions*/
+ Visibility(
+ visible: uiPrescriptionImages.length == 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForPrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForPrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select Prescriptions'),
+ ),
+ ),
+ Visibility(
+ visible: uiPrescriptionImages.length > 0,
+ child: Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: uiPrescriptionImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:uiPrescriptionImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ 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,prescriptionPictureId,widget.customerId);
+ print(jsonDecode(response));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiPrescriptionImages = jsonDecode(response)['prescriptionsPictureUpload']['precription'];
+ });
+
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ )
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ )),
+ Visibility(
+ visible: uiPrescriptionImages.length != 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForAddPrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForAddPrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Add Prescriptions'),
+ ),
+ ),
+
+ Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .06,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ if (doctorNameVariable!=''&&problemController.text != '' &&
+ dateInput.text != '' &&
+ prescriptionFor != ''&&problemCategory!='') {
+ 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 = widget.patName!;
+ _age = widget.patAge!;
+ _gender = widget.patGender!;
+ }
+ AppSettings.preLoaderDialog(context);
+ bool isOnline =
+ await AppSettings.internetConnectivity();
+ if (isOnline) {
+ var payload = new Map();
+ payload["problem"] =
+ problemController.text.toString();
+ payload["doctorName"] = doctorNameVariable.doctor_name.toString();
+ payload["hospitalName"] = doctorNameVariable.hospital_name.toString();
+ payload["doctorId"] = doctorNameVariable.doctor_id.toString();
+ payload["date"] = dateInput.text.toString();
+ payload["findings_date"] = '';
+ payload["reports_date"] = '';
+ payload["prescription_date"] = '';
+ payload["patientType"] = prescriptionFor.toString();
+ payload["problemCategory"] = problemCategory.toString();
+ payload["others"] = {
+ "name": _name,
+ "age": int.parse(_age),
+ "gender": _gender.toString().toLowerCase()
+ };
+ payload["findings"] = uiFindingsImages;
+ payload["reports"] = uiReportsImages;
+ payload["prescription"] = uiPrescriptionImages;
+
+ bool uploadStatus = await AppSettings.addRecords(payload,widget.customerId);
+
+ try {
+ if (uploadStatus) {
+ Navigator.of(context, rootNavigator: true)
+ .pop();
+ AppSettings.longSuccessToast(
+ 'Record added successfully');
+ Navigator.pop(context);
+ } else {
+ Navigator.of(context, rootNavigator: true)
+ .pop();
+ AppSettings.longFailedToast(
+ 'Fail to add record details');
+ }
+ } catch (e) {
+ print(e);
+ Navigator.of(context, rootNavigator: true)
+ .pop();
+ AppSettings.longFailedToast(
+ 'Fail to add record details');
+ }
+ } else {
+ AppSettings.longFailedToast(
+ 'Please check internet');
+ }
+ } else {
+ AppSettings.longFailedToast(
+ 'Please enter valid details');
+ }
+ },
+ child: const Text('Submit'),
+ )),
+ ],
+ ),
+ ),
+ ),
+ ))
+ );
+ }
+
+}
diff --git a/lib/patient_dashboard/Reports/all-records_onclick_new.dart b/lib/patient_dashboard/Reports/all-records_onclick_new.dart
new file mode 100644
index 0000000..d43a3e7
--- /dev/null
+++ b/lib/patient_dashboard/Reports/all-records_onclick_new.dart
@@ -0,0 +1,1813 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:flutter/services.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:flutter/material.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/common/zoom_image.dart';
+
+class AllRecordsOnClick extends StatefulWidget {
+ var recordDetails;
+ var initialIndex;
+ var customerId;
+
+ AllRecordsOnClick({this.recordDetails,this.initialIndex,this.customerId});
+
+ @override
+ State createState() => _AllRecordsOnClickState();
+}
+
+class _AllRecordsOnClickState extends State
+ with TickerProviderStateMixin {
+ //late TabController _controller;
+ /*final List topTabs = [
+ Tab(
+ child: Text(
+ 'Findings',
+ style: TextStyle(fontSize: 12),
+ )),
+ Tab(
+ child: Text(
+ 'Reports',
+ style: TextStyle(fontSize: 12),
+ )),
+ Tab(
+ child: Text(
+ 'Prescriptions',
+ style: TextStyle(fontSize: 12),
+ )),
+ ];*/
+ final ImagePicker imagePicker = ImagePicker();
+ List imageFileList = [];
+ final ImagePicker _picker = ImagePicker();
+
+ @override
+ void initState() {
+ //_controller = TabController(vsync: this, initialIndex: widget.initialIndex, length: topTabs.length);
+ super.initState();
+ }
+
+ Future pickImageFromGalleryForUpdateFindings() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.updateFindingsGallery(
+ imageFileList, widget.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ widget.recordDetails.findingsImages = jsonDecode(res)['findings'];
+ });
+ }
+
+ Future takeImageFromCameraForUpdateFindings() 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.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ widget.recordDetails.findingsImages = jsonDecode(res)['findings'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForUpdateReports() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.updateReportsGallery(
+ imageFileList, widget.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ widget.recordDetails.reportImages = jsonDecode(res)['reports'];
+ });
+ }
+
+ Future takeImageFromCameraForUpdateReports() 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.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ widget.recordDetails.reportImages = jsonDecode(res)['reports'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForUpdatePrescriptions() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.updatePrescriptionsGallery(
+ imageFileList, widget.recordDetails.recordId,widget);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ widget.recordDetails.prescriptionImages = jsonDecode(res)['prescription'];
+ });
+ }
+
+ Future takeImageFromCameraForUpdatePrescriptions() 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.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ widget.recordDetails.prescriptionImages =
+ jsonDecode(res)['prescription'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+
+ Widget renderUiForFindings() {
+ if (widget.recordDetails.findingsImages.length != 0) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Expanded(
+ child: GridView.builder(
+ itemCount: widget.recordDetails.findingsImages.length,
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ crossAxisSpacing: 2.0,
+ mainAxisSpacing: 2.0,
+ ),
+ itemBuilder: (BuildContext context, int index) {
+ return GestureDetector(
+ onTap: () {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(
+ imageName: 'Findings',
+ imageDetails: widget.recordDetails
+ .findingsImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ widget.recordDetails.findingsImages[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.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = widget.recordDetails
+ .findingsImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload = new Map();
+ payload["urlType"] = 'findings';
+ payload["url"] = widget.recordDetails
+ .findingsImages[index]['url'];
+
+ // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId);
+ try {
+ var res =
+ await AppSettings.deleteRecordsNew(
+ payload,
+ widget.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ widget.recordDetails.findingsImages =
+ jsonDecode(res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ /* color: Colors.pinkAccent,
+ width: 35,
+ height: 35,*/
+ ),
+ )
+ ]),
+ ),
+
+ //Image.network(widget.imageDetails[index]['url']),
+ );
+ },
+ )),
+ Padding(
+ padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
+ child: CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ } else {
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .25,
+ ),
+ Text('Click below icon to add new findings'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ));
+ }
+ }
+
+ Widget renderUiForReports() {
+ if (widget.recordDetails.reportImages.length != 0) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Expanded(
+ child: GridView.builder(
+ itemCount: widget.recordDetails.reportImages.length,
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ crossAxisSpacing: 2.0,
+ mainAxisSpacing: 2.0,
+ ),
+ itemBuilder: (BuildContext context, int index) {
+ return GestureDetector(
+ onTap: () {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(
+ imageName: 'Findings',
+ imageDetails: widget
+ .recordDetails.reportImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ widget.recordDetails.reportImages[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.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = widget.recordDetails
+ .reportImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload = new Map();
+ payload["urlType"] = 'reports';
+ payload["url"] = widget.recordDetails
+ .reportImages[index]['url'];
+
+ try {
+ var res =
+ await AppSettings.deleteRecordsNew(
+ payload,
+ widget.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ widget.recordDetails.reportImages =
+ jsonDecode(res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ /* color: Colors.pinkAccent,
+ width: 35,
+ height: 35,*/
+ ),
+ )
+ ]),
+ ),
+
+ //Image.network(widget.imageDetails[index]['url']),
+ );
+ },
+ )),
+ Padding(
+ padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
+ child: CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ } else {
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .25,
+ ),
+ Text('Click below icon to add new Report'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ));
+ }
+ }
+
+ Widget renderUiForPrescriptions() {
+ if (widget.recordDetails.prescriptionImages.length != 0) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Expanded(
+ child: GridView.builder(
+ itemCount: widget.recordDetails.prescriptionImages.length,
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ crossAxisSpacing: 2.0,
+ mainAxisSpacing: 2.0,
+ ),
+ itemBuilder: (BuildContext context, int index) {
+ return GestureDetector(
+ onTap: () {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(
+ imageName: 'Prescripitons',
+ imageDetails: widget.recordDetails
+ .prescriptionImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ widget.recordDetails.prescriptionImages[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.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = widget.recordDetails
+ .prescriptionImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload =
+ new Map();
+ payload["urlType"] = 'prescription';
+ payload["url"] = widget.recordDetails
+ .prescriptionImages[index]['url'];
+
+ try {
+ var res = await AppSettings
+ .deleteRecordsNew(
+ payload,
+ widget
+ .recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ widget.recordDetails
+ .prescriptionImages =
+ jsonDecode(
+ res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+
+ //Image.network(widget.imageDetails[index]['url']),
+ );
+ },
+ ),
+ ),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Padding(
+ padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
+ child: CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.shopping_cart,
+ color: Colors.white,
+ ),
+ onPressed: () {
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new OrderMedicines(
+ prescriptionDetails: widget.recordDetails)));*/
+ //signup screen
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ Padding(
+ padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
+ child: CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ )
+ ],
+ );
+ } else {
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .25,
+ ),
+ Text('Click below icon to add new Prescriptions'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ));
+ }
+ }
+
+ Widget prescriptions(var obj){
+ if(obj.prescriptionImages.length!=0){
+ return Container(
+ //color: secondaryColor,
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: Row(
+ children: [
+ Expanded(child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.prescriptionImages.length,
+ itemBuilder: (context, index) {
+ return Row(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.prescriptionImages[index]['url']);
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj.prescriptionImages[index]['url'])));},
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.prescriptionImages[index]['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ child: Stack(children: [
+ Positioned(
+ right: 0,
+ child: Container(
+ child: IconButton(
+ iconSize: 30,
+ icon: const Icon(
+ Icons.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = obj.prescriptionImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload =
+ new Map();
+ payload["urlType"] = 'prescription';
+ payload["url"] = obj.prescriptionImages[index]['url'];
+
+ try {
+ var res = await AppSettings.deleteRecordsNew(payload, obj.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast("Image deleted Successfully");
+ setState(() {
+ obj.prescriptionImages =
+ jsonDecode(
+ res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ ),
+ )
+
+ ],
+ );
+ }),),
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.green,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+
+
+
+ },
+ ),
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.shopping_cart,
+ color: primaryColor,
+ ),
+ onPressed: () {
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new OrderMedicines(
+ prescriptionDetails: widget.recordDetails)));*/
+ //signup screen
+ },
+ ),
+ ],
+ )
+
+ ],
+ )
+ );
+ }
+ else{
+ return GestureDetector(
+ onTap: (){
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdatePrescriptions();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: Row(
+ children: [
+ Icon(
+ Icons.add,
+ color: Colors.green,
+ size: 40,
+ ),
+ Text('Add Prescriptions',style: textButtonStyle(),)
+ ],
+ ),
+ );
+ }
+
+
+
+ }
+
+ Widget findings(var obj){
+ if(obj.findingsImages.length!=0){
+ return Container(
+ //color: secondaryColor,
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: Row(
+ children: [
+ Expanded(child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.findingsImages.length,
+ itemBuilder: (context, index) {
+ return Row(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.prescriptionImages[index]['url']);
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:obj.findingsImages[index]['url'])));},
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.findingsImages[index]['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ child: Stack(children: [
+ Positioned(
+ right: 0,
+ child: Container(
+ child: IconButton(
+ iconSize: 30,
+ icon: const Icon(
+ Icons.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = widget.recordDetails
+ .findingsImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload = new Map();
+ payload["urlType"] = 'findings';
+ payload["url"] = widget.recordDetails
+ .findingsImages[index]['url'];
+
+ // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId);
+ try {
+ var res =
+ await AppSettings.deleteRecordsNew(
+ payload,
+ widget.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ widget.recordDetails.findingsImages =
+ jsonDecode(res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ /* color: Colors.pinkAccent,
+ width: 35,
+ height: 35,*/
+ ),
+ )
+ ]),
+ ),
+ ),
+ )
+
+ ],
+ );
+ }),),
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.green,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ )
+
+ ],
+ )
+ );
+ }
+ else{
+ return GestureDetector(
+ onTap: (){
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+
+ },
+ child: Row(
+ children: [
+ Icon(
+ Icons.add,
+ color: Colors.green,
+ size: 40,
+ ),
+ Text('Add Findings',style: textButtonStyle(),)
+ ],
+ ),
+ );
+ }
+
+
+
+ }
+
+ Widget reports(var obj){
+ if(obj.reportImages.length!=0){
+ return Container(
+ //color: secondaryColor,
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: Row(
+ children: [
+ Expanded(child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.reportImages.length,
+ itemBuilder: (context, index) {
+ return Row(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.prescriptionImages[index]['url']);
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:obj.reportImages[index]['url'])));},
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.reportImages[index]['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ child: Stack(children: [
+ Positioned(
+ right: 0,
+ child: Container(
+ child: IconButton(
+ iconSize: 30,
+ icon: const Icon(
+ Icons.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = widget.recordDetails
+ .reportImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload = new Map();
+ payload["urlType"] = 'reports';
+ payload["url"] = widget.recordDetails
+ .reportImages[index]['url'];
+
+ try {
+ var res =
+ await AppSettings.deleteRecordsNew(
+ payload,
+ widget.recordDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ widget.recordDetails.reportImages =
+ jsonDecode(res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ /* color: Colors.pinkAccent,
+ width: 35,
+ height: 35,*/
+ ),
+ )
+ ]),
+ ),
+ ),
+ )
+
+ ],
+ );
+ }),),
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.green,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ )
+
+ ],
+ )
+ );
+ }
+ else{
+ return GestureDetector(
+ onTap: (){
+
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: Row(
+ children: [
+ Icon(
+ Icons.add,
+ color: Colors.green,
+ size: 40,
+ ),
+ Text('Add Reports',style: textButtonStyle(),)
+ ],
+ ),
+ );
+ }
+
+
+
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Records'),
+ body: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ height: MediaQuery.of(context).size.height * .15,
+ width: double.infinity,
+ child: Padding(
+ padding: EdgeInsets.all(0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'Problem: ' +
+ widget.recordDetails.problem.toString().toUpperCase(),
+ style: problemTextStyle()),
+ Text(widget.recordDetails.doctorName.toString().toUpperCase(),
+ style: valuesTextStyle()),
+ Text(
+ widget.recordDetails.hospitalName
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ Text(widget.recordDetails.date.toString().toUpperCase(),
+ style: valuesTextStyle()),
+ Text('Patient details: ', style: problemTextStyle()),
+ Text(
+ widget.recordDetails.patient_name
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ Row(
+ children: [
+ Text(widget.recordDetails.gender.toString().toUpperCase(),
+ style: valuesTextStyle()),
+ SizedBox(
+ width: MediaQuery.of(context).size.width * .05,
+ ),
+ Text(
+ widget.recordDetails.age.toString().toUpperCase() +
+ " Yrs",
+ style: valuesTextStyle()),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ Text('Findings',style: TextStyle(color: Colors.red,fontSize: 16,fontWeight: FontWeight.bold),),
+ findings(widget.recordDetails),
+ Text('Reports',style: TextStyle(color: Colors.red,fontSize: 16,fontWeight: FontWeight.bold),),
+ reports(widget.recordDetails),
+ Text('Prescriptions',style: TextStyle(color: Colors.red,fontSize: 16,fontWeight: FontWeight.bold),),
+ prescriptions(widget.recordDetails)
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/Reports/allreports.dart b/lib/patient_dashboard/Reports/allreports.dart
new file mode 100644
index 0000000..38df6f8
--- /dev/null
+++ b/lib/patient_dashboard/Reports/allreports.dart
@@ -0,0 +1,1294 @@
+import 'dart:convert';
+
+import 'package:carousel_slider/carousel_slider.dart';
+import 'package:flutter/material.dart';
+import 'package:doctor/patient_dashboard/Reports/add_reports.dart';
+import 'package:doctor/patient_dashboard/Reports/update_report.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/common/zoom_image.dart';
+import 'package:doctor/models/reports_model.dart';
+import 'package:doctor/patient_dashboard/Reports/all-records_onclick_new.dart';
+import 'package:intl/intl.dart';
+
+class AllReports extends StatefulWidget {
+ String? customerId;
+ String? patName;
+ String? patAge;
+ String? patGender;
+ AllReports({this.customerId,this.patName,this.patAge,this.patGender});
+
+ @override
+ State createState() => _AllReportsState();
+}
+
+class _AllReportsState extends State {
+
+
+ List reportsList = [];
+ List reportsListOriginal = [];
+ bool isReportsDataLoading = false;
+ bool isSereverIssue = false;
+ TextEditingController searchController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ TextEditingController fromdateController = TextEditingController();
+ TextEditingController todateController = TextEditingController();
+ DateTime fromDate=DateTime.now();
+ String dropdownSearchType = 'Problem';
+ String? searchBy;
+ var typeOfSearchItems = [
+ 'Problem',
+ 'Doctor',
+ 'Date',
+ ];
+ final List imgList = [
+ 'images/mobilebg.png',
+ 'images/mobilebg2.png',
+ 'images/mobilebg3.png'
+ ];
+ List images = ['img1', 'img2', 'img3'];
+
+ Future getAllRecords() async {
+ isReportsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ 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 getRecordsByProblemName(var problem) async {
+
+ isReportsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ 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 getRecordsByDoctorName(var doctor) async {
+
+ isReportsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ setState(() {
+ reportsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ 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) {
+ setState(() {
+ isReportsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ Future getRecordsByDate(var date) async {
+
+ isReportsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ setState(() {
+ reportsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return ReportsModel.fromJson(model);
+ }).toList();
+ reportsList=reportsListOriginal.reversed.toList();
+ reportsList= reportsListOriginal.where(
+ (x) => x.date.toString().toLowerCase().contains(date.toString().toLowerCase())
+ ).toList();
+ isReportsDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isReportsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ Future getRecordsByDateRange(var fromDate,var toDate) async {
+ isReportsDataLoading = true;
+
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ setState(() {
+ reportsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return ReportsModel.fromJson(model);
+ }).toList();
+ reportsList=reportsListOriginal.reversed.toList();
+ var dateToCheck = DateTime.now().add(Duration(days: -1));
+
+ reportsList = reportsListOriginal.reversed.where((product) {
+ final date = product.dateForFilter;
+ final startDate =DateFormat('dd-MM-yyyy').parse(fromDate);
+ final endDate = DateFormat('dd-MM-yyyy').parse(toDate);
+ return date.isAfter(startDate) && date.isBefore(endDate);
+
+ //reportsList=reportsListOriginal.reversed.toList();
+ }).toList();
+
+ /*if( dateToCheck.isAfter(startDate) && dateToCheck.isBefore(endDate))
+ {
+ print("dateToCheck is between now and lastYear");
+ }
+ else
+ {
+ print("dateToCheck is not between now and lastYear");
+ }*/
+
+
+ isReportsDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isReportsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ getAllRecords();
+ var now = new DateTime.now();
+ String formattedDate = DateFormat('dd-MM-yyyy').format(now);
+ fromdateController.text=formattedDate;
+ todateController.text=formattedDate;
+ super.initState();
+ }
+
+ Widget findings(var obj){
+ return Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.findingsImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ /*showPicDialog(obj.findingsImages[index]['url']);*/
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:obj.findingsImages[index]['url'])));
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.findingsImages[index]['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ );
+ }
+
+ Widget reports(var obj){
+
+ return Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.reportImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.reportImages[index]['url']);
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:obj.reportImages[index]['url'])));
+
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.reportImages[index]
+ ['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ );
+
+ }
+
+ Widget prescriptions(var obj){
+
+ return Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.prescriptionImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.prescriptionImages[index]['url']);
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj.prescriptionImages[index]['url'])));
+
+
+
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.prescriptionImages[index]
+ ['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ );
+
+ }
+
+ Widget _filtereddata(){
+ if(reportsList.length!=0){
+
+
+
+ reportsList.sort((a, b) => b.date.compareTo(a.date));
+ return ListView.separated(
+ padding: EdgeInsets.all(0),
+ itemCount: reportsList.length,
+ separatorBuilder: (context, index) {
+ if ((index + 1) % 2 == 0) {
+ return CarouselSlider(
+ options: CarouselOptions(
+ height: MediaQuery.of(context).size.height * .200,
+ aspectRatio: 16 / 9,
+ viewportFraction: 0.8,
+ initialPage: 0,
+ enableInfiniteScroll: true,
+ reverse: false,
+ autoPlay: true,
+ autoPlayInterval: Duration(seconds: 3),
+ autoPlayAnimationDuration: Duration(milliseconds: 800),
+ autoPlayCurve: Curves.ease,
+ enlargeCenterPage: true,
+ enlargeFactor: 0.2,
+ scrollDirection: Axis.horizontal,
+ ),
+ items: imgList.map((i) {
+ return Builder(
+ builder: (BuildContext context) {
+ return Container(
+ height: MediaQuery.of(context).size.height * .250,
+ width: double.infinity,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(0),
+ ),
+ //color: Colors.red,
+ child: FittedBox(
+ child: Image(
+ image: AssetImage(i),
+ ),
+ fit: BoxFit.fill,
+ ));
+ },
+ );
+ }).toList(),
+ );
+ } else {
+ return Container();
+ }
+ },
+ itemBuilder: (BuildContext context, int index) {
+ if(reportsList[index].patient_type.toString().toLowerCase()=='self'){
+ reportsList[index].age=widget.patAge!;
+ reportsList[index].gender=widget.patGender!;
+ reportsList[index].patient_name=widget.patName!;
+ }
+ else{
+ reportsList[index].age=reportsList[index].age;
+ reportsList[index].gender=reportsList[index].gender;
+ reportsList[index].patient_name=reportsList[index].patient_name;
+ }
+ return GestureDetector(
+ onTap: (){
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
+ getAllRecords();
+ });
+ },
+ child: Card(
+
+ //color: prescriptionsList[index].cardColor,
+ child: Padding(
+ padding:EdgeInsets.all(8) ,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+
+ Container(
+ width: MediaQuery.of(context).size.width * .55,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Problem: '+reportsList[index].problem.toString().toUpperCase(),style: problemTextStyle()),
+ Text(reportsList[index].doctorName.toString().toUpperCase(),style: valuesTextStyle()),
+ Text(reportsList[index].hospitalName.toString().toUpperCase(),style: valuesTextStyle()),
+ Text(reportsList[index].date.toString().toUpperCase(),style: valuesTextStyle()),
+ Text('Patient details: ',style: problemTextStyle()),
+ Text(reportsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()),
+ Row(
+ children: [
+ Text(reportsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()),
+ SizedBox(width:MediaQuery.of(context).size.width * .05,),
+ Text(reportsList[index].age.toString().toUpperCase()+" Yrs",style: valuesTextStyle()),
+ ],
+ ),
+
+
+ ],
+ ),
+
+
+ ),
+
+
+ Expanded(child:IconButton(
+ icon: const Icon(Icons.edit,color: primaryColor,),
+ onPressed: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new UpdateReport(reportDetails:reportsList[index]))).then((value) {
+ getAllRecords();
+ });
+ },
+ ),),
+ Expanded(child:IconButton(
+ icon: const Icon(Icons.delete,color: primaryColor,),
+
+ onPressed: () async{
+ showDialog(
+ //if set to true allow to close popup by tapping out of the popup
+ //barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title: const Text('Do you want to delete Record?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment: MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: ()async {
+
+ bool deleteTankStatus = await AppSettings.deleteRecord(reportsList[index].recordId);
+
+
+ if(deleteTankStatus){
+ getAllRecords();
+ AppSettings.longSuccessToast('Record deleted successfully');
+ Navigator.of(context).pop(true);
+
+ }
+ else{
+ AppSettings.longFailedToast('Record deletion failed');
+ Navigator.of(context).pop(true);
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+
+
+
+ },
+ ),)
+
+ ],
+
+ ),
+
+ Row(
+ children: [
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
+ getAllRecords();
+ });
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
+ getAllRecords();
+ });*/
+ },
+ child: Text('Findings: '+reportsList[index].findingsImages.length.toString(),style:textButtonStyleReports(),),
+ ),
+ SizedBox(
+ width:MediaQuery.of(context).size.width * .05,
+ ),
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
+ getAllRecords();
+ });
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 1,))).then((value) {
+ getAllRecords();
+ });*/
+
+ },
+ child: Text('Reports: '+reportsList[index].reportImages.length.toString(),style:textButtonStyleReports()),
+ ),
+ SizedBox(
+ width:MediaQuery.of(context).size.width * .05,
+ ),
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllRecordsOnClick(recordDetails:reportsList[index],initialIndex: 0,))).then((value) {
+ getAllRecords();
+ });
+
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new AllReportsTab(recordDetails:reportsList[index],initialIndex: 2,))).then((value) {
+ getAllRecords();
+ });*/
+
+ },
+ child: Text('Prescriptions: '+reportsList[index].prescriptionImages.length.toString(),style:textButtonStyleReports()),
+ ),
+ ],
+ ),
+
+
+
+ Visibility(
+ visible: false,
+ child: Text('Findings',style: headingsTextStyle()),),
+ Visibility(
+ visible: false,
+ child: findings(reportsList[index])),
+ Visibility(
+ visible: false,
+ child: Text('Reports',style: headingsTextStyle()),),
+ Visibility(
+ visible: false,
+ child:reports(reportsList[index]) ),
+ Visibility(
+ visible: false,
+ child: Text('Prescriptions',style: headingsTextStyle()),),
+ Visibility(
+ visible:false,
+ child:prescriptions(reportsList[index]) ),
+ ],
+ ),
+ ),
+ ),
+ );
+ });
+ }
+ 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!;
+ });
+ },
+ ),
+ ),*/
+ Container(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Padding(padding: EdgeInsets.fromLTRB(10,10,0,0),
+ child: Text('Please select search option',style: TextStyle(color: Colors.red,fontWeight: FontWeight.bold,fontSize: 16),),),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: RadioListTile(
+ title: Text("Problem", style: TextStyle(fontSize: 10)),
+ value: "problem",
+ groupValue: searchBy,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ searchBy = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title: Text(
+ "Doctor",
+ style: TextStyle(fontSize: 10),
+ ),
+ value: "doctor",
+ groupValue: searchBy,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ searchBy = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title:
+ Text("Date", style: TextStyle(fontSize: 10)),
+ value: "date",
+ groupValue: searchBy,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ searchBy = value.toString();
+ });
+ },
+ ),
+ ),
+ ],
+ ),
+ ],
+ )
+
+ ),
+ Visibility(
+ visible:searchBy.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: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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:searchBy.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: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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
+ ),
+ ),
+ ),)
+ ),),
+ Visibility(
+ visible:searchBy.toString().toLowerCase()=='date',
+ child: Container(
+ //height: 60,
+ padding: EdgeInsets.all(5),
+ child: Row(
+ children: [
+ Expanded(
+ child: TextField(
+
+ cursorColor: primaryColor,
+ controller: fromdateController,
+ onChanged: (string) {
+ if(string.length>=1){
+ //getRecordsByDate(string);
+ }
+ else{
+ getAllRecords();
+ }
+ },
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate = DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ fromDate=pickedDate;
+ fromdateController.text = formattedDate; //set output date to TextField value.
+ });
+ getRecordsByDateRange(fromdateController.text,todateController.text);
+ } else {}
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ suffixIcon: fromdateController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ fromdateController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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: 'From date',
+
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+ Expanded(
+ child: TextField(
+
+ cursorColor: primaryColor,
+ controller: todateController,
+ onChanged: (string) {
+ if(string.length>=1){
+ //getRecordsByDate(string);
+ }
+ else{
+ getAllRecords();
+ }
+ },
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: fromDate,
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ todateController.text = formattedDate; //set output date to TextField value.
+ });
+ getRecordsByDateRange(fromdateController.text,todateController.text);
+ } else {}
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ suffixIcon: todateController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ todateController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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: 'To date',
+
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+
+ ],
+ ),
+ ),),
+ /*Visibility(
+ visible:searchBy.toString().toLowerCase()=='date' ,
+ 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){
+ getRecordsByDate(string);
+ }
+ else{
+ getAllRecords();
+ }
+ },
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ searchController.text = formattedDate; //set output date to TextField value.
+ });
+ getRecordsByDate(searchController.text);
+ } else {}
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.search,
+ color: primaryColor,
+ ),
+ suffixIcon: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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 date',
+
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),)
+ ),
+
+
+ ),*/
+ Expanded(child: _filtereddata()),
+
+ ]);
+
+
+ }
+ else{
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(height: MediaQuery.of(context).size.height * .25,),
+ Text('Click below icon to add new Record'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports(customerId:widget.customerId,patName: widget.patName,patAge: widget.patAge,patGender: widget.patGender,))).then((value) {
+ getAllRecords();
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ )
+ );
+ }
+
+
+ }
+
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Records'),
+ body: isReportsDataLoading?Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ ): _allreports(),
+ floatingActionButton: Visibility(
+ visible:reportsListOriginal.length!=0,
+ child: CircleAvatar(
+ backgroundColor: buttonColors,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.black,
+ ),
+ onPressed: () async{
+ /*await Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => AddPrescription()),
+ );*/
+ Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports(customerId:widget.customerId,patName: widget.patName,patAge: widget.patAge,patGender: widget.patGender,))).then((value) {
+ getAllRecords();
+ });
+ //showBoreAddingDialog();
+ },
+ ),
+ /* Padding(
+ padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
+ child: Text(
+ 'Add Tanks ',
+ style: TextStyle(color: Colors.white),
+ ),
+ )*/
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/Reports/update_report.dart b/lib/patient_dashboard/Reports/update_report.dart
new file mode 100644
index 0000000..8b4b592
--- /dev/null
+++ b/lib/patient_dashboard/Reports/update_report.dart
@@ -0,0 +1,1190 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/common/zoom_image.dart';
+import 'package:intl/intl.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:multi_image_picker/multi_image_picker.dart';
+
+class UpdateReport extends StatefulWidget {
+ var reportDetails;
+ var customerId;
+
+ UpdateReport({this.reportDetails,this.customerId});
+
+ @override
+ State createState() => _UpdateReportState();
+}
+
+class _UpdateReportState extends State {
+ TextEditingController doctorNameController = TextEditingController();
+ TextEditingController hospitalNameController = TextEditingController();
+ TextEditingController problemController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ TextEditingController patientNameController = TextEditingController();
+ TextEditingController patientAgeController = TextEditingController();
+ final ImagePicker _picker = ImagePicker();
+ String Url = '';
+ final ImagePicker imagePicker = ImagePicker();
+ List imageFileList = [];
+ List imageFileListReports = [];
+ List imageFileListPrescriptions = [];
+ List uiFindingsImages = [];
+ List uiReportsImages = [];
+ List uiPrescriptionImages = [];
+
+ List images = [];
+ String _error = 'No Error Dectected';
+ String apiMultiImages = '';
+ String? prescriptionFor;
+ String? gender;
+
+
+ Future pickImageFromGalleryForUpdate() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.updatePrescriptionsGallery(imageFileList,widget.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiPrescriptionImages = 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.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiPrescriptionImages = jsonDecode(res)['prescription'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForUpdateReports() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.updateReportsGallery(imageFileList,widget.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages= jsonDecode(res)['reports'];
+ });
+ }
+
+ Future takeImageFromCameraForUpdateReports() 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.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiReportsImages = jsonDecode(res)['reports'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Future pickImageFromGalleryForUpdateFindings() async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res =
+ await AppSettings.updateFindingsGallery(imageFileList, widget.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['findings'];
+ });
+ }
+
+ Future takeImageFromCameraForUpdateFindings() 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.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['findings'];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ void detials(){
+ prescriptionFor=widget.reportDetails.patient_type;
+ doctorNameController.text=widget.reportDetails.doctorName;
+ hospitalNameController.text=widget.reportDetails.hospitalName;
+ problemController.text = widget.reportDetails.problem;
+ dateInput.text = widget.reportDetails.date;
+ patientNameController.text =widget.reportDetails.patient_name;
+ patientAgeController.text = widget.reportDetails.age;
+ gender=widget.reportDetails.gender;
+ uiFindingsImages=widget.reportDetails.findingsImages;
+ uiReportsImages =widget.reportDetails.reportImages;
+ uiPrescriptionImages =widget.reportDetails.prescriptionImages;
+
+ }
+
+
+ @override
+ void initState() {
+
+
+ detials();
+ super.initState();
+ }
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Update Report'),
+ body: SingleChildScrollView(
+ child: Container(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: doctorNameController,
+ textCapitalization: TextCapitalization.words,
+ decoration: textFormFieldDecoration(
+ Icons.person, 'Enter Doctor name'),
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: hospitalNameController,
+ textCapitalization: TextCapitalization.words,
+ decoration: textFormFieldDecoration(
+ Icons.location_city_outlined, 'Enter Hospital name'),
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: problemController,
+ textCapitalization: TextCapitalization.words,
+ decoration: textFormFieldDecoration(
+ Icons.report_problem, 'Enter Problem'),
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: dateInput,
+ decoration: textFormFieldDecoration(
+ Icons.calendar_today, 'Enter Date'),
+ readOnly: true,
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ dateInput.text =
+ formattedDate; //set output date to TextField value.
+ });
+ } else {}
+ },
+ ),
+ ),
+ Row(
+ children: [
+ Expanded(
+ child: RadioListTile(
+ title: Text("For Yourself"),
+ value: "self",
+ groupValue: prescriptionFor,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ prescriptionFor = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title: Text("For Family"),
+ value: "others",
+ groupValue: prescriptionFor,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ prescriptionFor = value.toString();
+ });
+ },
+ ),
+ ),
+ ],
+ ),
+ Visibility(
+ visible:
+ prescriptionFor.toString().toLowerCase() == 'others',
+ child: Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: patientNameController,
+ decoration: textFormFieldDecoration(
+ Icons.person, 'Enter patient name'),
+ ),
+ ),
+ ),
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .02,
+ ),
+ Visibility(
+ visible:
+ prescriptionFor.toString().toLowerCase() == 'others',
+ child: Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ keyboardType: TextInputType.number,
+ controller: patientAgeController,
+ decoration: textFormFieldDecoration(
+ Icons.person, 'Enter patient age'),
+ ),
+ ),
+ ),
+ Visibility(
+ visible:
+ prescriptionFor.toString().toLowerCase() == 'others',
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: RadioListTile(
+ title: Text("Male", style: TextStyle(fontSize: 10)),
+ value: "male",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title: Text(
+ "Female",
+ style: TextStyle(fontSize: 10),
+ ),
+ value: "female",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),
+ ),
+ Expanded(
+ child: RadioListTile(
+ title:
+ Text("Others", style: TextStyle(fontSize: 10)),
+ value: "other",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value) {
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),
+ ),
+ ],
+ ),
+ ),
+ /*findings*/
+ Visibility(
+ visible: uiFindingsImages.length == 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select Findings'),
+ ),
+ ),
+ Visibility(
+ visible: uiFindingsImages.length > 0,
+ child: Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: uiFindingsImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:uiFindingsImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ uiFindingsImages[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.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+
+ var payload = new Map();
+ payload["urlType"] = 'findings';
+ payload["url"] = uiFindingsImages[index]['url'];
+
+ // bool deleteStatus = await AppSettings.deleteRecordsNew(payload,widget.recordId);
+ try {
+ var res =
+ await AppSettings.deleteRecordsNew(
+ payload,
+ widget.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ uiFindingsImages = jsonDecode(res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ )),
+ Visibility(
+ visible: uiFindingsImages.length != 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateFindings();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Add Findings'),
+ ),
+ ),
+
+ /*reports*/
+ Visibility(
+ visible: uiReportsImages.length == 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select Reports'),
+ ),
+ ),
+ Visibility(
+ visible: uiReportsImages.length > 0,
+ child: Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: uiReportsImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:uiReportsImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ uiReportsImages[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.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ var payload = new Map();
+ payload["urlType"] = 'reports';
+ payload["url"] = uiReportsImages[index]['url'];
+
+ try {
+ var res =
+ await AppSettings.deleteRecordsNew(
+ payload,
+ widget.reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ uiReportsImages =
+ jsonDecode(res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ )
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ )),
+ Visibility(
+ visible: uiReportsImages.length != 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary:buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdateReports();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Add Reports'),
+ ),
+ ),
+
+ /*prescriptions*/
+ Visibility(
+ visible: uiPrescriptionImages.length == 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdate();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdate();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select Prescriptions'),
+ ),
+ ),
+ Visibility(
+ visible: uiPrescriptionImages.length > 0,
+ child: Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: uiPrescriptionImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: () {
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:uiPrescriptionImages[index]['url'])));
+ /*gridOntap(index);*/
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ 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.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+
+ var payload =
+ new Map();
+ payload["urlType"] = 'prescription';
+ payload["url"] = uiPrescriptionImages[index]['url'];
+
+ try {
+ var res = await AppSettings
+ .deleteRecordsNew(
+ payload,
+ widget
+ .reportDetails.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast(
+ "Image deleted Successfully");
+ setState(() {
+ uiPrescriptionImages=
+ jsonDecode(
+ res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ )
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ )),
+ Visibility(
+ visible: uiPrescriptionImages.length != 0,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdate();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width:
+ MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdate();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Add Prescriptions'),
+ ),
+ ),
+
+ /*button*/
+ Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .06,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ if (doctorNameController.text != '' &&
+ problemController.text != '' &&
+ dateInput.text != '' &&
+ prescriptionFor != '') {
+ String _name = '';
+ String _age = '';
+ String? _gender = '';
+
+ if (prescriptionFor.toString().toLowerCase() ==
+ 'others') {
+ if (patientNameController != '' &&
+ patientAgeController.text != '' &&
+ gender != '') {
+ _name = patientNameController.text;
+ _age = patientAgeController.text;
+ _gender = gender;
+ } else {
+ AppSettings.longFailedToast(
+ 'Please enter details');
+ }
+ } else {
+
+ }
+ AppSettings.preLoaderDialog(context);
+ bool isOnline =
+ await AppSettings.internetConnectivity();
+ if (isOnline) {
+
+
+ var payload = new Map();
+ payload["problem"] =
+ problemController.text.toString();
+ payload["doctorName"] =
+ doctorNameController.text.toString();
+ payload["hospitalName"] =
+ hospitalNameController.text.toString();
+ payload["date"] = dateInput.text.toString();
+ payload["findings_date"] = '';
+ payload["reports_date"] = '';
+ payload["prescription_date"] = '';
+ payload["patientType"] =
+ prescriptionFor.toString();
+ payload["others"] = {
+ "name": _name,
+ "age": int.parse(_age),
+ "gender": _gender.toString().toLowerCase()
+ };
+ payload["findings"] = uiFindingsImages;
+ payload["reports"] = uiReportsImages;
+ payload["prescription"] = uiPrescriptionImages;
+
+ bool uploadStatus =
+ await AppSettings.updateRecord(payload,widget.reportDetails.recordId);
+
+ try {
+ if (uploadStatus) {
+ Navigator.of(context, rootNavigator: true)
+ .pop();
+ AppSettings.longSuccessToast(
+ 'Record updated successfully');
+ Navigator.pop(context);
+ } else {
+ Navigator.of(context, rootNavigator: true)
+ .pop();
+ AppSettings.longFailedToast(
+ 'Fail to update record details');
+ }
+ } catch (e) {
+ print(e);
+ Navigator.of(context, rootNavigator: true)
+ .pop();
+ AppSettings.longFailedToast(
+ 'Fail to add record details');
+ }
+ } else {
+ AppSettings.longFailedToast(
+ 'Please check internet');
+ }
+ } else {
+ AppSettings.longFailedToast(
+ 'Please enter valid details');
+ }
+ },
+ child: const Text('Update Report'),
+ )),
+ ],
+ ),
+ ),
+ ),
+ ));
+ }
+}
diff --git a/lib/patient_dashboard/Sugar/sugar_calculator.dart b/lib/patient_dashboard/Sugar/sugar_calculator.dart
new file mode 100644
index 0000000..cbdb755
--- /dev/null
+++ b/lib/patient_dashboard/Sugar/sugar_calculator.dart
@@ -0,0 +1,257 @@
+import 'dart:convert';
+import 'package:flutter/material.dart';
+import 'package:doctor/patient_dashboard/Sugar/sugar_history.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:intl/intl.dart';
+
+
+class SugarCalculator extends StatefulWidget {
+ String? customerId;
+ SugarCalculator({this.customerId});
+
+ @override
+ State createState() => _SugarCalculatorState();
+}
+
+class _SugarCalculatorState extends State {
+
+ TextEditingController fastingValueController = TextEditingController();
+ TextEditingController postParandialValueController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ String sugarValue = '';
+ Color sugarValueColor = Colors.black;
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Diabetes'),
+ body: SingleChildScrollView(
+ child: Container(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ TextFormField(
+ cursorColor: greyColor,
+ controller: fastingValueController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.person,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Enter fasting blood sugar value',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ SizedBox(height: 10),
+ TextFormField(
+ cursorColor: greyColor,
+ controller: postParandialValueController,
+ textCapitalization: TextCapitalization.characters,
+ keyboardType: TextInputType.number,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.person,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Enter PostPrandial value',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ SizedBox(height: 10),
+ SizedBox(height: 10),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: dateInput,
+ decoration: textFormFieldDecorationBMI(
+ Icons.calendar_today, 'Enter Date'),
+ readOnly: true,
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ dateInput.text =
+ formattedDate; //set output date to TextField value.
+ });
+ } else {}
+ },
+ ),
+ ),
+ SizedBox(height: 10),
+ Container(
+ width: double.infinity,
+ height:
+ MediaQuery.of(context).size.height * .05,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ if (fastingValueController.text != '' &&
+ postParandialValueController.text != ''&& dateInput.text!='') {
+
+ if(int.parse(fastingValueController.text)>int.parse(postParandialValueController.text)){
+ AppSettings.longFailedToast('Please enter post parandial value is higher than fasting blood sugar value details');
+ }
+ else{
+ AppSettings.preLoaderDialog(context);
+ var payload = new Map();
+
+ payload["fasting"] = double.parse(fastingValueController.text.toString());
+ payload["postPrandial"] = double.parse(postParandialValueController.text.toString());
+ payload["date"] = dateInput.text.toString();
+
+ var value = await AppSettings.calculateSugar(payload,widget.customerId);
+ var valueResponse = jsonDecode(value);
+ print(valueResponse);
+ setState(() {
+ sugarValue = valueResponse['userSugarDetails']['sugarCategory'].toString();
+ if(sugarValue.toUpperCase().toUpperCase()=='VERY HIGH BLOOD SUGAR'){
+ sugarValueColor=Colors.red;
+ }
+ else if(sugarValue.toUpperCase().toUpperCase()=='HIGH BLOOD SUGAR'){
+ sugarValueColor=Colors.red;
+ }
+ else if(sugarValue.toUpperCase().toUpperCase()=='PREDIABETES (IMPAIRED FASTING GLUCOSE)'){
+ sugarValueColor=Colors.red;
+ }
+ else if(sugarValue.toUpperCase().toUpperCase()=='VERY LOW BLOOD SUGAR'){
+ sugarValueColor=Colors.red;
+ }
+ else if(sugarValue.toUpperCase().toUpperCase()=='LOW BLOOD SUGAR'){
+ sugarValueColor=Colors.red;
+ }
+ else if(sugarValue.toUpperCase().toUpperCase()=='NORMAL BLOOD SUGAR (HEALTHY RANGE)'){
+ sugarValueColor=buttonColors;
+ }
+
+ });
+ fastingValueController.clear();
+ postParandialValueController.clear();
+ dateInput.clear();
+ Navigator.of(context,rootNavigator: true).pop();
+ }
+
+
+ }
+ else{
+ AppSettings.longFailedToast('Please enter valid details');
+ }
+ },
+ child: const Text('Check Diabetes'),
+ )),
+ SizedBox(height: 10),
+ Container(
+ child: Row(
+ children: [
+ Text(sugarValue,style: TextStyle(color: sugarValueColor,fontWeight: FontWeight.bold,fontSize: 20),),
+ Visibility(
+ visible:sugarValue!='' ,
+ child: Icon(
+ Icons.emoji_emotions_outlined,
+ color: buttonColors,
+ size: 40,
+ ),)
+ ],
+ )
+ ),
+ SizedBox(height: 20),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Column(
+ children: [
+ IconButton(
+ onPressed: () {
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => SugarHistory(customerId: widget.customerId,)),
+ );
+ },
+ icon: Icon(
+ Icons.history,
+ color: primaryColor,
+ size: 40,
+ ),
+ ),
+ SizedBox(height: 10),
+ Padding(padding: EdgeInsets.fromLTRB(10,0,0,0),
+ child: Container(
+ child: Text('History',style:TextStyle(color:Colors.black,fontSize: 12,fontWeight: FontWeight.bold,)),
+ ),)
+ ],
+ ),
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async {
+ Navigator.pop(context);
+ },
+ child: const Text('Cancel'),
+ )
+ ],
+ )
+
+
+ ],
+ ),
+ )
+ ),
+ )
+ );
+ }
+}
diff --git a/lib/patient_dashboard/Sugar/sugar_history.dart b/lib/patient_dashboard/Sugar/sugar_history.dart
new file mode 100644
index 0000000..d8685ee
--- /dev/null
+++ b/lib/patient_dashboard/Sugar/sugar_history.dart
@@ -0,0 +1,354 @@
+import 'dart:convert';
+import 'package:flutter/material.dart';
+import 'package:doctor/patient_dashboard/Sugar/sugar_calculator.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/models/sugar_history_model.dart';
+import 'package:flutter_slidable/flutter_slidable.dart';
+
+class SugarHistory extends StatefulWidget {
+ String? customerId;
+ SugarHistory({this.customerId});
+
+ @override
+ State createState() => _SugarHistoryState();
+}
+
+class _SugarHistoryState extends State {
+ bool isLoading = false;
+ List sugarHistoryList = [];
+ List FilteredList = [];
+ var dateItems = [
+ 'All',
+ 'last 7 days',
+ 'last one month',
+ 'last one year',
+ ];
+ var dateItemsVariable = 'All';
+
+ Future getSugarHistoryDetails(var selectedRange) async {
+ isLoading = true;
+ var response1 = await AppSettings.getSugarHistory(widget.customerId);
+ print(response1);
+ setState(() {
+ sugarHistoryList = ((jsonDecode(response1)) as List).map((dynamic model) {
+ return SugarHistoryModel.fromJson(model);
+ }).toList();
+
+ var now = new DateTime.now();
+ var now_1w = now.subtract(Duration(days: 7));
+ var now_1m = new DateTime(now.year, now.month - 1, now.day);
+ var now_1y = new DateTime(now.year - 1, now.month, now.day);
+
+ if (selectedRange.toString().toUpperCase() == 'LAST 7 DAYS') {
+ FilteredList = sugarHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1w.isBefore(date);
+ }).toList();
+ } else if (selectedRange.toString().toUpperCase() == 'LAST ONE MONTH') {
+ FilteredList = sugarHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1m.isBefore(date);
+ }).toList();
+ } else if (selectedRange.toString().toUpperCase() == 'LAST ONE YEAR') {
+ FilteredList = sugarHistoryList.where((product) {
+ final date = product.dateForFilter;
+ return now_1y.isBefore(date);
+ }).toList();
+ } else {
+ FilteredList = sugarHistoryList;
+ }
+
+ isLoading = false;
+ });
+ }
+
+ @override
+ void initState() {
+ getSugarHistoryDetails(dateItemsVariable);
+ super.initState();
+ }
+
+ deleteSugarRecord(sugarInfoId) async {
+ AppSettings.preLoaderDialog(context);
+ bool status = await AppSettings.deleteSugarDetails(sugarInfoId,widget.customerId);
+
+ if (status) {
+ Navigator.of(context, rootNavigator: true).pop();
+
+ AppSettings.longSuccessToast("BP record deleted successfully");
+ await getSugarHistoryDetails(dateItemsVariable);
+ } else {
+ Navigator.of(context, rootNavigator: true).pop();
+
+ AppSettings.longFailedToast("BP record deletion failed");
+ }
+ }
+
+ Widget renderzUi() {
+ if (FilteredList.length != 0) {
+ FilteredList.sort((a, b) => b.actualDate.compareTo(a.actualDate));
+ return Column(crossAxisAlignment: CrossAxisAlignment.end, children: [
+ Padding(
+ padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
+ child: DropdownButtonFormField(
+ // Initial Value
+ value: dateItemsVariable,
+ isExpanded: true,
+ decoration: const InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor)),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: primaryColor),
+ ),
+ labelText: 'Select Date Range',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+
+ hint: Text('Units'),
+ // Down Arrow Icon
+ //icon: const Icon(Icons.keyboard_arrow_down),
+
+ // Array list of items
+ items: dateItems.map((String items) {
+ return DropdownMenuItem(
+ value: items,
+ child: Text(
+ items,
+ style: TextStyle(
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ));
+ }).toList(),
+ // After selecting the desired option,it will
+ // change button value to selected value
+ onChanged: (String? newValue) {
+ setState(() {
+ dateItemsVariable = newValue!;
+ });
+ getSugarHistoryDetails(dateItemsVariable);
+ },
+ ),
+ ),
+ Expanded(
+ child: ListView.builder(
+ padding: EdgeInsets.all(0),
+ itemCount: FilteredList.length,
+ itemBuilder: (BuildContext context, int index) {
+ return Slidable(
+ key: const ValueKey(0),
+ endActionPane: ActionPane(
+ // A motion is a widget used to control how the pane animates.
+ motion: ScrollMotion(),
+
+ dragDismissible: false,
+ // A pane can dismiss the Slidable.
+ dismissible: DismissiblePane(onDismissed: () {
+ deleteSugarRecord(FilteredList[index].sugarInfoId);
+ }),
+
+ // All actions are defined in the children parameter.
+ children: [
+ // A SlidableAction can have an icon and/or a label.
+ SlidableAction(
+ backgroundColor: Color(0xFFFE4A49),
+ foregroundColor: Colors.white,
+ icon: Icons.delete,
+ label: 'Delete',
+ onPressed: (BuildContext context) {
+ deleteSugarRecord(FilteredList[index].sugarInfoId);
+ },
+ ),
+ ],
+ ),
+ child: Card(
+ color: Colors.white,
+ child: Padding(
+ padding: EdgeInsets.all(8),
+ child:
+ Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'Fasting Sugar Value',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ 'PostPrandial Sugar Value',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ 'Sugar Status',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ 'Date',
+ style: labelTextStyle(),
+ ),
+ ],
+ ),
+ SizedBox(width:MediaQuery.of(context).size.width * .01,),
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ ],
+ ),
+ SizedBox(width:MediaQuery.of(context).size.width * .01,),
+ Expanded(child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ FilteredList[index]
+ .fasting
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ FilteredList[index]
+ .postPrandial
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ FilteredList[index]
+ .sugartText
+ .toString()
+ .toUpperCase(),
+ style: TextStyle(
+ color: FilteredList[index]
+ .sugarValueColor,
+ fontSize: 12,
+ fontWeight: FontWeight.bold,
+ overflow: TextOverflow.ellipsis,
+ )),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ FilteredList[index]
+ .actualDate
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ ],
+ ),)
+ ],
+ ),
+ ),
+ ));
+ })),
+ ]);
+ } else {
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(
+ height: MediaQuery.of(context).size.height * .25,
+ ),
+ Text('No data'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => SugarCalculator(customerId:widget.customerId))).then((value) {
+ getSugarHistoryDetails(dateItemsVariable);
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ ));
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Diabetes'),
+ body: isLoading
+ ? Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ )
+ : renderzUi(),
+ floatingActionButton: Visibility(
+ visible:FilteredList.length!=0,
+ child: CircleAvatar(
+ backgroundColor: buttonColors,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.black,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => SugarCalculator(customerId: widget.customerId,))).then((value) {
+ getSugarHistoryDetails(dateItemsVariable);
+ });
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/patient_dashboard.dart b/lib/patient_dashboard/patient_dashboard.dart
new file mode 100644
index 0000000..cbdf2f6
--- /dev/null
+++ b/lib/patient_dashboard/patient_dashboard.dart
@@ -0,0 +1,159 @@
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/patient_dashboard/patient_dshboard_details.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
+import 'package:flutter/services.dart';
+
+class PatientDashboard extends StatefulWidget {
+ const PatientDashboard({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _PatientDashboardState();
+}
+
+class _PatientDashboardState extends State {
+
+ bool isScannerVisible=true;
+ TextEditingController mobileNumberController = TextEditingController();
+ final List images = [
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ 'https://via.placeholder.com/150',
+ ];
+
+
+ Future scanQR() async {
+ String barcodeScanRes;
+ // Platform messages may fail, so we use a try/catch PlatformException.
+ try {
+ barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
+ '#ff6666', 'Cancel', true, ScanMode.QR);
+ print(barcodeScanRes);
+ setState(() {
+
+ });
+ } on PlatformException {
+ barcodeScanRes = 'Failed to get platform version.';
+ }}
+
+
+ Future onWillPop() async {
+ final shouldPop = await showDialog(context: context, builder: (context) {
+ return AlertDialog(
+ title: const Text('Do you want to leave this page',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment: MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(false);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ );
+ },
+ );
+ return shouldPop!;
+ }
+ @override
+ Widget build(BuildContext context) {
+ return WillPopScope(
+ onWillPop: () async => onWillPop(),
+ child: Scaffold(
+ appBar: AppSettings.appBar('Patient Dashboard'),
+ body: SafeArea(
+ child: SingleChildScrollView(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ children: [
+ SizedBox(
+ height:MediaQuery.of(context).size.height * .02,
+ ),
+ Visibility(
+ visible: isScannerVisible,
+ child:Center(
+ child: Container(
+
+ child: Column(
+ children: [
+ IconButton(
+ onPressed: (){
+ scanQR();
+ },
+ icon: Icon(
+ Icons.qr_code_scanner,
+ color: primaryColor,
+ ),
+ ),
+ Text('Scan Qr Code',style: TextStyle(fontSize: 12,color: primaryColor),)
+ ],
+ )
+ ),
+ ),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .02,),
+ Container(
+ child: TextFormField(
+ cursorColor: primaryColor,
+ controller: mobileNumberController,
+ keyboardType: TextInputType.number,
+ textCapitalization: TextCapitalization.characters,
+ decoration: textFormFieldDecorationInsideApp(Icons.phone,'Enter mobile number'),
+ ),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .02,),
+ Container(
+ width:double.infinity,
+ height: MediaQuery.of(context).size.height * .06,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ if(mobileNumberController.text!=''){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => PatientDashboardDetails(mobileNumber: mobileNumberController.text.toString(),)),
+ );
+ }
+ else{
+ AppSettings.longFailedToast('Please enter details');
+ }
+ },
+ child: Text('Go to details'),
+ )),
+
+
+ ]
+ ))) ) ),
+ );
+
+ }
+}
diff --git a/lib/patient_dashboard/patient_dshboard_details.dart b/lib/patient_dashboard/patient_dshboard_details.dart
new file mode 100644
index 0000000..2a571ef
--- /dev/null
+++ b/lib/patient_dashboard/patient_dshboard_details.dart
@@ -0,0 +1,245 @@
+import 'dart:convert';
+
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/patient_dashboard/BMI/bmi_history.dart';
+import 'package:doctor/patient_dashboard/BP/bp_history.dart';
+import 'package:doctor/patient_dashboard/Reports/allreports.dart';
+import 'package:doctor/patient_dashboard/Sugar/sugar_history.dart';
+import 'package:doctor/patient_dashboard/prescriptions/prescriptions.dart';
+import 'package:doctor/patient_dashboard/problems/all_problems.dart';
+import 'package:flutter/material.dart';
+
+class PatientDashboardDetails extends StatefulWidget {
+ String? mobileNumber;
+ PatientDashboardDetails({this.mobileNumber});
+
+ @override
+ State createState() => _PatientDashboardDetailsState();
+}
+
+class _PatientDashboardDetailsState extends State {
+
+ bool isDataLoading=false;
+ bool isSereverIssue=false;
+ String? customerId;
+ String? patientName;
+ String? patientAge;
+ String? patientGender;
+ String? patientContactNumber;
+ final List images = [
+ 'images/bp.png',
+ 'images/sugar.png',
+ 'images/bmi.png',
+ 'images/health_records.png',
+ 'images/prescriptions.png',
+ 'images/medicines.png',
+ 'images/new_problem.png',
+ 'images/get_checkup.png',
+ 'images/resources.png',
+ ];
+ final List labels = [
+ 'Bp',
+ 'Sugar',
+ 'BMI',
+ 'Health Records',
+ 'Prescriptions',
+ 'Medicines',
+ 'New Problem',
+ 'Get Checkup',
+ 'Resources',
+ ];
+ Map patDetails={};
+
+ Future getPatientInformation() async {
+ isDataLoading=true;
+ try {
+ var response = await AppSettings.getPatientInformationBasedOnMobileNumber(widget.mobileNumber);
+ print(jsonDecode(response));
+ setState(() {
+ customerId=jsonDecode(response)[0]['customerId'];
+ patientName=jsonDecode(response)[0]['profile']['firstName'];
+ patientAge=jsonDecode(response)[0]['age'].toString();
+ patientGender=jsonDecode(response)[0]['gender'];
+ patientContactNumber=jsonDecode(response)[0]['profile']['contactNumber'];
+ isDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ getPatientInformation();
+ super.initState();
+ }
+
+
+ _onTap(int index){
+ if(index==0){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => BPHistory(customerId:customerId,)),
+ );
+ }
+ else if(index==1){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => SugarHistory(customerId:customerId,)),
+ );
+ }
+ else if(index==2){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => BMIHistory(customerId:customerId,)),
+ );
+ }
+ else if(index==3){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => AllReports(customerId:customerId,patName: patientName,patAge: patientAge,patGender: patientGender,)),
+ );
+ }
+ else if(index==4){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => Prescriptions(customerId:customerId,patName: patientName,patAge: patientAge,patGender: patientGender,)),
+ );
+ }
+ else if(index==6){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => AllProblemsReportMyself(customerId:customerId,patName: patientName,patAge: patientAge,patGender: patientGender,)),
+ );
+ }
+ else if(index==7){
+ Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => AllProblemsReportMyself(customerId:customerId,patName: patientName,patAge: patientAge,patGender: patientGender,)),
+ );
+ }
+ }
+
+
+Widget _dashboard(){
+ return Column(
+ children: [
+ Padding(padding: EdgeInsets.all(10),
+ child: Align(child: Text('Patient Information',style: TextStyle(color: primaryColor,fontSize: 16),),
+ alignment: Alignment.topLeft),),
+ Padding(padding: EdgeInsets.all(10),
+ child: Card(child: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Name'),
+ Text('Age'),
+ Text('Gender'),
+ Text('Contact Number')
+ ],
+ ),
+ SizedBox(
+ width:MediaQuery.of(context).size.width * .02,
+ ),
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(':'),
+ Text(':'),
+ Text(':'),
+ Text(':')
+ ],
+ ),
+ SizedBox(
+ width:MediaQuery.of(context).size.width * .02,
+ ),
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(patientName!),
+ Text(patientAge!),
+ Text(patientGender!),
+ Text(patientContactNumber!)
+ ],
+ ),
+ ],
+ ),),),
+ Expanded(child: Container(
+
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: GridView.builder(
+ itemCount: images.length,
+ gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
+ crossAxisCount: 3,
+ crossAxisSpacing: 4.0,
+ mainAxisSpacing: 4.0,
+ ),
+ itemBuilder: (BuildContext context, int index) {
+ return GestureDetector(
+ onTap: () {
+ _onTap(index);
+ },
+ child: Column(
+ children: [
+ Expanded(child: Container(
+ decoration: BoxDecoration(
+ color: secondaryColor,
+ shape: BoxShape.rectangle,
+ borderRadius: BorderRadius.circular(30),
+ image: DecorationImage(
+ image: AssetImage(images[index],) , // picked file
+ fit: BoxFit.fitWidth)),
+ //color: secondaryColor,
+
+ )),
+ Padding(padding: EdgeInsets.all(10),
+ child: Text(labels[index]),),
+ /*Divider(
+ color: Colors.grey,
+ height: 1.0,
+ ),*/
+ ],
+ )
+ );
+ },
+ ),
+ )
+ ))
+ ],
+ );
+}
+
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+
+ appBar: AppSettings.appBar('Patient Dashboard Details'),
+ body: Container(
+ child: isDataLoading?Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ ): _dashboard(),
+ ),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/prescriptions/add_prescriptions.dart b/lib/patient_dashboard/prescriptions/add_prescriptions.dart
new file mode 100644
index 0000000..ed66213
--- /dev/null
+++ b/lib/patient_dashboard/prescriptions/add_prescriptions.dart
@@ -0,0 +1,418 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/patient_dashboard/prescriptions/prescriptions.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:photo_view/photo_view.dart';
+import 'package:pinch_zoom/pinch_zoom.dart';
+
+class AddPrescription extends StatefulWidget {
+ String? customerId;
+ String? patName;
+ String? patAge;
+ String? patGender;
+ AddPrescription({this.customerId,this.patName,this.patAge,this.patGender});
+
+
+ @override
+ State createState() => _AddPrescriptionState();
+}
+
+class _AddPrescriptionState extends State {
+
+ final ImagePicker _picker = ImagePicker();
+ String Url = '';
+ final _transformationController = TransformationController();
+ TapDownDetails _doubleTapDetails=TapDownDetails();
+ TextEditingController prescriptionNameController = TextEditingController();
+ TextEditingController patientNameController = TextEditingController();
+ TextEditingController patientAgeController = TextEditingController();
+ String? prescriptionFor;
+ String? gender;
+
+ Future pickImageFromGallery() async {
+ try {
+ final image = await _picker.pickImage(source: ImageSource.gallery);
+ if (image == null) return;
+ final imageTemp = File(image.path);
+
+ AppSettings.preLoaderDialog(context);
+ var res = await AppSettings.uploadImageHTTPForPrescriptions(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ Url = jsonDecode(res)['pictures'][0];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ 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.uploadImageHTTPForPrescriptions(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ Url = jsonDecode(res)['pictures'][0];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ Widget zoomPhoto(var imageUrl){
+ return Container(
+ width: MediaQuery.of(context).size.width * .18,
+ height: MediaQuery.of(context).size.height * .10,
+ child: PhotoView(
+ imageProvider: NetworkImage(imageUrl) as ImageProvider,
+ )
+ );
+ }
+
+
+ showPicDialog(var imageUrl){
+ return showDialog(
+ context: context,
+ barrierDismissible: false,
+ builder: (BuildContext context) {
+ return StatefulBuilder(
+ builder: (BuildContext context, StateSetter setState) {
+ return AlertDialog(
+ title: const Text(''),
+ content: SingleChildScrollView(
+ child: ListBody(
+ children: [
+ Container(
+ width: MediaQuery.of(context).size.width * .10,
+ height: MediaQuery.of(context).size.height * .50,
+ child: PhotoView(
+ imageProvider: NetworkImage(imageUrl) as ImageProvider,
+ maxScale: PhotoViewComputedScale.contained * 4.0,
+ minScale: PhotoViewComputedScale.contained,
+ initialScale: PhotoViewComputedScale.contained,
+ basePosition: Alignment.center,
+
+ )
+ )
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(
+ child: Text('Close', style: textButtonStyle()),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ );
+ });
+ },
+ );
+ }
+
+ void _handleDoubleTap() {
+ if (_transformationController.value != Matrix4.identity()) {
+ _transformationController.value = Matrix4.identity();
+ } else {
+ final position = _doubleTapDetails.localPosition;
+ // For a 3x zoom
+ _transformationController.value = Matrix4.identity()
+ ..translate(-position.dx * 2, -position.dy * 2)
+ ..scale(3.0);
+ // Fox a 2x zoom
+ // ..translate(-position.dx, -position.dy)
+ // ..scale(2.0);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Add Prescription'),
+ body:SingleChildScrollView(
+ child: Container(
+ child: Padding(
+ padding: EdgeInsets.all(10),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCamera();
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width * .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGallery();
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+ },
+ child: const Text('Select image'),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Visibility(
+ visible: Url != '',
+ child: GestureDetector(
+ child:
+ /*,*/
+ /*Container(
+ width: MediaQuery.of(context).size.width * .18,
+ height: MediaQuery.of(context).size.height * .10,
+ child: PhotoView(
+ imageProvider: NetworkImage(Url) as ImageProvider,
+ maxScale: PhotoViewComputedScale.contained * 4.0,
+ minScale: PhotoViewComputedScale.contained,
+ initialScale: PhotoViewComputedScale.contained,
+ basePosition: Alignment.center,
+
+ )
+ ),*/
+ Container(
+ width: MediaQuery.of(context).size.width * .18,
+ height: MediaQuery.of(context).size.height * .10,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(Url) as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ ),
+ onTap: (){
+ showPicDialog(Url);
+ },
+ )
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .02,),
+ Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: prescriptionNameController,
+ decoration: textFormFieldDecoration(Icons.edit,'Enter Prescription name'),
+
+ ),
+ ),
+ Row(
+ children: [
+
+ Expanded(child: RadioListTile(
+ title: Text("For Yourself"),
+ value: "self",
+ groupValue: prescriptionFor,
+ activeColor: primaryColor,
+ onChanged: (value){
+ setState(() {
+ prescriptionFor = value.toString();
+ });
+ },
+ ),),
+ Expanded(child: RadioListTile(
+ title: Text("For Family"),
+ value: "others",
+ groupValue: prescriptionFor,
+ activeColor: primaryColor,
+ onChanged: (value){
+ setState(() {
+ prescriptionFor = value.toString();
+ });
+ },
+ ),),
+ ],
+ ),
+ Visibility(
+ visible:prescriptionFor.toString().toLowerCase()=='others' ,
+ child: Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ controller: patientNameController,
+ decoration: textFormFieldDecoration(Icons.person,'Enter patient name'),
+
+ ),
+ ),),
+ SizedBox(height:MediaQuery.of(context).size.height * .02,),
+ Visibility(
+ visible:prescriptionFor.toString().toLowerCase()=='others' ,
+ child: Container(
+ child: TextFormField(
+ cursorColor: greyColor,
+ keyboardType: TextInputType.number,
+ controller: patientAgeController,
+ decoration: textFormFieldDecoration(Icons.person,'Enter patient age'),
+
+ ),
+ ),),
+ Visibility(
+ visible:prescriptionFor.toString().toLowerCase()=='others' ,
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+
+ Expanded(child: RadioListTile(
+ title: Text("Male",style: TextStyle(fontSize: 10)),
+ value: "male",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value){
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),),
+ Expanded(child: RadioListTile(
+ title: Text("Female",style: TextStyle(fontSize: 10),),
+ value: "female",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value){
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),),
+ Expanded(child: RadioListTile(
+ title: Text("Others",style: TextStyle(fontSize: 10)),
+ value: "other",
+ groupValue: gender,
+ activeColor: primaryColor,
+ onChanged: (value){
+ setState(() {
+ gender = value.toString();
+ });
+ },
+ ),),
+ ],
+ ),),
+ SizedBox(height:MediaQuery.of(context).size.height * .02,),
+ Container(
+ width:double.infinity,
+ height: MediaQuery.of(context).size.height * .06,
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: buttonColors, // background
+ onPrimary: Colors.black, // foreground
+ ),
+ onPressed: () async{
+ if(Url!=''&& prescriptionNameController.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=widget.patName!;
+ _age=widget.patAge!;
+ _gender=widget.patGender!;
+ }
+ AppSettings.preLoaderDialog(context);
+ bool isOnline = await AppSettings.internetConnectivity();
+ if(isOnline){
+ var payload = new Map();
+ payload["name"] = prescriptionNameController.text.toString();
+ payload["pictureUrl"] = Url.toString();
+ payload["patientType"] = prescriptionFor.toString();
+ payload["others"] ={
+ "name": _name,
+ "age": int.parse(_age),
+ "gender": _gender.toString().toLowerCase()
+ };
+ bool uploadStatus = await AppSettings.addPrescription(payload,widget.customerId);
+
+ try{
+ if(uploadStatus){
+ Navigator.of(context,rootNavigator: true).pop();
+ AppSettings.longSuccessToast('Prescription added successfully');
+ Navigator.pop(context);
+ /* await Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => Prescriptions()),
+ );*/
+ }
+ else{
+ Navigator.of(context,rootNavigator: true).pop();
+ AppSettings.longFailedToast('Fail to add prescription details');
+ }
+ }
+ catch(e){
+ print(e);
+ Navigator.of(context,rootNavigator: true).pop();
+ AppSettings.longFailedToast('Fail to add prescription details');
+ }
+
+
+ }
+ else{
+ AppSettings.longFailedToast('Please check internet');
+ }
+ }
+ else{
+ AppSettings.longFailedToast('Please upload image');
+ }
+
+
+ },
+ child: const Text('Upload'),
+ )),
+
+
+ ],
+ ),
+ )) ,
+ )
+ );
+ }
+}
diff --git a/lib/patient_dashboard/prescriptions/prescriptions.dart b/lib/patient_dashboard/prescriptions/prescriptions.dart
new file mode 100644
index 0000000..bf5da82
--- /dev/null
+++ b/lib/patient_dashboard/prescriptions/prescriptions.dart
@@ -0,0 +1,976 @@
+import 'dart:convert';
+import 'dart:io';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:doctor/patient_dashboard//Reports/add_reports.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/common/zoom_image.dart';
+import 'package:doctor/models/reports_model.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:photo_view/photo_view.dart';
+import 'package:intl/intl.dart';
+
+class Prescriptions extends StatefulWidget {
+ String? customerId;
+ String? patName;
+ String? patAge;
+ String? patGender;
+ Prescriptions({this.customerId,this.patName,this.patAge,this.patGender});
+
+ @override
+ State createState() => _PrescriptionsState();
+}
+
+class _PrescriptionsState extends State {
+ final ImagePicker _picker = ImagePicker();
+ String Url = '';
+ List reportsList = [];
+ List reportsListOriginal = [];
+ bool isPharmacyDataLoading = false;
+ bool isPrescriptionsDataLoading = false;
+ bool isSereverIssue = false;
+ double lat = 0;
+ double lng = 0;
+ String userAddress = '';
+ String dropdownArea = '2';
+ var AreaItems = ['2', '5', '10', '25', '50', '100'];
+ List pharmaciesCheckboxes = [];
+ bool isLoading=false;
+ final ImagePicker imagePicker = ImagePicker();
+ List imageFileList = [];
+ List uiPrescriptionImages = [];
+ TextEditingController searchController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ String dropdownSearchType = 'Problem';
+ var typeOfSearchItems = [
+ 'Problem',
+ 'Doctor',
+ 'Date',
+ ];
+
+
+
+ Future getAllRecords() async {
+ isPrescriptionsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ setState(() {
+ reportsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return ReportsModel.fromJson(model);
+ }).toList();
+ reportsList=reportsListOriginal.reversed.toList();
+ isPrescriptionsDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isPrescriptionsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ Future getRecordsByProblemName(var problem) async {
+
+ isPrescriptionsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ 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();
+ isPrescriptionsDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isPrescriptionsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ Future getRecordsByDoctorName(var doctor) async {
+
+ isPrescriptionsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ setState(() {
+ reportsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return ReportsModel.fromJson(model);
+ }).toList();
+ reportsList=reportsListOriginal.reversed.toList();
+ reportsList= reportsListOriginal.where(
+ (x) => x.doctorName.toString().toLowerCase().contains(doctor.toString().toLowerCase())
+ ).toList();
+ isPrescriptionsDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isPrescriptionsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ Future getRecordsByDate(var date) async {
+
+ isPrescriptionsDataLoading=true;
+ try {
+ var response = await AppSettings.getAllRecords(widget.customerId);
+
+ setState(() {
+ reportsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return ReportsModel.fromJson(model);
+ }).toList();
+ reportsList=reportsListOriginal.reversed.toList();
+ reportsList= reportsListOriginal.where(
+ (x) => x.date.toString().toLowerCase().contains(date.toString().toLowerCase())
+ ).toList();
+ isPrescriptionsDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isPrescriptionsDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ @override
+ void initState() {
+ getAllRecords();
+ super.initState();
+ }
+
+ Future pickImageFromGallery() async {
+ try {
+ final image = await _picker.pickImage(source: ImageSource.gallery);
+ if (image == null) return;
+ final imageTemp = File(image.path);
+
+ AppSettings.preLoaderDialog(context);
+ var res = await AppSettings.uploadImageHTTPForPrescriptions(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ Url = jsonDecode(res)['pictures'][0];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+ 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.uploadImageHTTPForPrescriptions(image,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ setState(() {
+ Url = jsonDecode(res)['pictures'][0];
+ });
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+
+ Future pickImageFromGalleryForUpdate(var recordId) async {
+ imageFileList = [];
+ final List? selectedImages = await imagePicker.pickMultiImage();
+ AppSettings.preLoaderDialog(context);
+ if (selectedImages!.isNotEmpty) {
+ imageFileList.addAll(selectedImages);
+ }
+
+ var res = await AppSettings.updatePrescriptionsGallery(imageFileList,recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ getAllRecords();
+ }
+
+ Future takeImageFromCameraForUpdate(var recordId) 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,recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ getAllRecords();
+
+ } on PlatformException catch (e) {
+ print('Failed to pick image: $e');
+ }
+ }
+
+
+ showPicDialog(var imageUrl){
+ return showDialog(
+ context: context,
+ barrierDismissible: false,
+ builder: (BuildContext context) {
+ return StatefulBuilder(
+ builder: (BuildContext context, StateSetter setState) {
+ return AlertDialog(
+ title: const Text(''),
+ content: SingleChildScrollView(
+ child: ListBody(
+ children: [
+ Container(
+ width: MediaQuery.of(context).size.width * .10,
+ height: MediaQuery.of(context).size.height * .50,
+ child: PhotoView(
+ imageProvider: NetworkImage(imageUrl) as ImageProvider,
+ maxScale: PhotoViewComputedScale.contained * 4.0,
+ minScale: PhotoViewComputedScale.contained,
+ initialScale: PhotoViewComputedScale.contained,
+ basePosition: Alignment.center,
+
+ )
+ )
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(
+ child: Text('Close', style: textButtonStyle()),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ );
+ });
+ },
+ );
+ }
+
+ Widget prescriptions(var obj){
+ if(obj.prescriptionImages.length!=0){
+ return Container(
+ //color: secondaryColor,
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: Row(
+ children: [
+ Expanded(child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.prescriptionImages.length,
+ itemBuilder: (context, index) {
+ return Row(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.prescriptionImages[index]['url']);
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Prescriptions',imageDetails:obj.prescriptionImages[index]['url'])));},
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.prescriptionImages[index]['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ child: Stack(children: [
+ Positioned(
+ right: 0,
+ child: Container(
+ child: IconButton(
+ iconSize: 30,
+ icon: const Icon(
+ Icons.delete,
+ color: Colors.red,
+ ),
+ onPressed: () async {
+ showDialog(
+ barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title:
+ const Text('Do you want to delete image?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment:
+ MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: () async {
+ AppSettings.preLoaderDialog(context);
+
+ String fileName = obj.prescriptionImages[index]['url']
+ .split('/')
+ .last;
+
+ var payload =
+ new Map();
+ payload["urlType"] = 'prescription';
+ payload["url"] = obj.prescriptionImages[index]['url'];
+
+ try {
+ var res = await AppSettings.deleteRecordsNew(payload, obj.recordId,widget.customerId);
+ print(jsonDecode(res));
+ Navigator.of(context, rootNavigator: true).pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longSuccessToast("Image deleted Successfully");
+ setState(() {
+ obj.prescriptionImages =
+ jsonDecode(
+ res)['remainingUrls'];
+ });
+ } catch (e) {
+ print(e);
+ Navigator.of(context,
+ rootNavigator: true)
+ .pop();
+ Navigator.of(context).pop(true);
+ AppSettings.longFailedToast(
+ "Image deletion failed");
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ),
+ )
+ ]),
+ ),
+ ),
+ )
+
+ ],
+ );
+ }),),
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.green,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdate(obj.recordId);
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdate(obj.recordId);
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+
+
+
+ },
+ )
+
+ ],
+ )
+ );
+ }
+ else{
+ return Row(
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.green,
+ ),
+ onPressed: () async {
+ showModalBottomSheet(
+ context: context,
+ builder: (BuildContext context) {
+ return SizedBox(
+ height: 200,
+ child: Center(
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ GestureDetector(
+ child: Icon(
+ Icons.camera_alt_outlined,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await takeImageFromCameraForUpdate(obj.recordId);
+ Navigator.pop(context);
+ },
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width *
+ .20,
+ ),
+ GestureDetector(
+ child: Icon(
+ Icons.photo,
+ size: 100,
+ color: primaryColor,
+ ),
+ onTap: () async {
+ await pickImageFromGalleryForUpdate(obj.recordId);
+ Navigator.pop(context);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ });
+
+
+
+ },
+ ),
+ Text('Add Prescriptions',style: textButtonStyle(),)
+ ],
+ );
+ }
+
+
+
+ }
+
+ Widget _filtereddata(){
+ if (reportsList.length != 0) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Expanded(child:ListView.builder(
+ padding: EdgeInsets.all(0),
+ itemCount: reportsList.length,
+ itemBuilder: (BuildContext context, int index) {
+ if(reportsList[index].patient_type.toString().toLowerCase()=='self'){
+ reportsList[index].age=widget.patAge!;
+ reportsList[index].gender=widget.patGender!;
+ reportsList[index].patient_name=widget.patName!;
+ }
+ else{
+ reportsList[index].age=reportsList[index].age;
+ reportsList[index].gender=reportsList[index].gender;
+ reportsList[index].patient_name=reportsList[index].patient_name;
+ }
+
+ return Visibility(
+ visible: true,
+ child: Card(
+
+ //color: prescriptionsList[index].cardColor,
+ child: Padding(
+ padding:EdgeInsets.all(8) ,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+
+ Container(
+ width: MediaQuery.of(context).size.width * .55,
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text('Problem: '+reportsList[index].problem.toString().toUpperCase(),style: problemTextStyle()),
+ Text(reportsList[index].doctorName.toString().toUpperCase(),style: valuesTextStyle()),
+ Text(reportsList[index].hospitalName.toString().toUpperCase(),style: valuesTextStyle()),
+ Text(reportsList[index].date.toString().toUpperCase(),style: valuesTextStyle()),
+ Text('Patient Details: ',style: problemTextStyle()),
+ Text(reportsList[index].patient_name.toString().toUpperCase(),style: valuesTextStyle()),
+ Row(
+ children: [
+ Text(reportsList[index].gender.toString().toUpperCase(),style: valuesTextStyle()),
+ SizedBox(width:MediaQuery.of(context).size.width * .05,),
+ Text(reportsList[index].age.toString().toUpperCase()+" Yrs",style: valuesTextStyle()),
+ ],
+ ),
+
+
+ ],
+ ),
+
+
+ ),
+ ],
+
+ ),
+
+ SizedBox(height:MediaQuery.of(context).size.height * .02,),
+
+ prescriptions(reportsList[index]),
+
+ ],
+ ),
+ ),
+ ));
+ }) ),
+ ]);
+ }
+ else{
+ return Padding(padding: EdgeInsets.fromLTRB(60,10,60,10),
+ child: Column(
+ children: [
+ Text('No prescriptions found related to your search'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: Colors.red,
+ radius: 30,
+ child: const Icon(
+ Icons.info,
+ color: Colors.white,
+ ),
+ )
+ ],
+ ),);
+ }
+ }
+
+ Widget _allPrescriptions(){
+
+ 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: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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
+ ),
+ ),
+ ),)
+ ),),
+ Visibility(
+ visible:dropdownSearchType.toString().toLowerCase()=='date' ,
+ 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){
+ getRecordsByDate(string);
+ }
+ else{
+ getAllRecords();
+ }
+ },
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ searchController.text = formattedDate; //set output date to TextField value.
+ });
+ getRecordsByDate(searchController.text);
+ } else {}
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.search,
+ color: primaryColor,
+ ),
+ suffixIcon: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllRecords();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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 date',
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),)
+ ),
+
+
+ ),
+ Expanded(child: _filtereddata()),
+ Padding(
+ padding: EdgeInsets.fromLTRB(8, 8, 8, 8),
+ child: CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async{
+ /*await Navigator.push(
+ context,
+ MaterialPageRoute(
+ builder: (context) => AddPrescription()),
+ );*/
+ Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports(customerId:widget.customerId,patName: widget.patName,patAge: widget.patAge,patGender: widget.patGender,))).then((value) {
+ getAllRecords();
+ });
+ //showBoreAddingDialog();
+ },
+ ),
+ /* Padding(
+ padding: EdgeInsets.fromLTRB(5, 0, 5, 5),
+ child: Text(
+ 'Add Tanks ',
+ style: TextStyle(color: Colors.white),
+ ),
+ )*/
+ ],
+ ),
+ ),
+ ),
+ ]);
+
+
+ }
+ else{
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(height: MediaQuery.of(context).size.height * .25,),
+ Text('Click below icon to add new Record'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.add,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ Navigator.push(context, MaterialPageRoute(builder: (context) => AddReports(customerId:widget.customerId,patName: widget.patName,patAge: widget.patAge,patGender: widget.patGender,))).then((value) {
+ getAllRecords();
+ });
+ },
+ ),
+ )
+ ],
+ ),
+ )
+ );
+ }
+
+
+ }
+
+ /**/
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Prescriptions'),
+ body: isPrescriptionsDataLoading?Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ ): _allPrescriptions(),
+ );
+ }
+}
diff --git a/lib/patient_dashboard/problems/all_problems.dart b/lib/patient_dashboard/problems/all_problems.dart
new file mode 100644
index 0000000..25fda6b
--- /dev/null
+++ b/lib/patient_dashboard/problems/all_problems.dart
@@ -0,0 +1,1058 @@
+import 'dart:convert';
+import 'package:flutter/material.dart';
+import 'package:doctor/common/settings.dart';
+import 'package:doctor/common/zoom_image.dart';
+import 'package:doctor/models/all_problems_model.dart';
+import 'package:doctor/patient_dashboard/problems/video_file.dart';
+import 'package:photo_view/photo_view.dart';
+import 'package:intl/intl.dart';
+import 'package:flutter_sound/flutter_sound.dart';
+import 'package:assets_audio_player/assets_audio_player.dart';
+
+class AllProblemsReportMyself extends StatefulWidget {
+ String? customerId;
+ String? patName;
+ String? patAge;
+ String? patGender;
+ AllProblemsReportMyself({this.customerId,this.patName,this.patAge,this.patGender});
+
+ @override
+ State createState() => _AllProblemsReportMyselfState();
+}
+
+class _AllProblemsReportMyselfState extends State {
+
+
+ List allProblemsList = [];
+ List allProblemsListOriginal = [];
+ bool isProblemDataLoading = false;
+ bool isSereverIssue = false;
+ TextEditingController searchController = TextEditingController();
+ TextEditingController dateInput = TextEditingController();
+ TextEditingController fromdateController = TextEditingController();
+ TextEditingController todateController = TextEditingController();
+ String dropdownSearchType = 'All';
+ bool isAudioButtonPressed=false;
+ bool _playAudio=false;
+ final recordingPlayer = AssetsAudioPlayer();
+ var typeOfSearchItems = [
+ 'All',
+ 'Problem',
+ 'Date',
+ ];
+
+ Future getAllProblemsReportMyself() async {
+ isProblemDataLoading=true;
+ try {
+ var response = await AppSettings.getAllReportProblemDetalis(widget.customerId);
+
+ setState(() {
+ allProblemsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return AllProblemsModel.fromJson(model);
+ }).toList();
+ allProblemsList=allProblemsListOriginal.reversed.toList();
+ isProblemDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isProblemDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+ Future getAllProblemsReportMyselfByProblem(var problem) async {
+
+ isProblemDataLoading=true;
+ try {
+ var response = await AppSettings.getAllReportProblemDetalis(widget.customerId);
+
+ setState(() {
+ allProblemsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return AllProblemsModel.fromJson(model);
+ }).toList();
+ allProblemsList=allProblemsListOriginal.reversed.toList();
+ allProblemsList= allProblemsListOriginal.where(
+ (x) => x.problem.toString().toLowerCase().contains(problem.toString().toLowerCase())
+ ).toList();
+ isProblemDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isProblemDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+
+ Future getAllProblemsReportMyselfByDateRange(var fromDate,var toDate) async {
+ isProblemDataLoading = true;
+
+ try {
+ var response = await AppSettings.getAllReportProblemDetalis(widget.customerId);
+
+ setState(() {
+ allProblemsListOriginal = ((jsonDecode(response)) as List)
+ .map((dynamic model) {
+ return AllProblemsModel.fromJson(model);
+ }).toList();
+ allProblemsList=allProblemsListOriginal.reversed.toList();
+ var dateToCheck = DateTime.now().add(Duration(days: -1));
+
+ allProblemsList = allProblemsListOriginal.where((product) {
+ final date = product.dateForFilter;
+ final startDate =DateFormat('dd-MM-yyyy').parse(fromDate);
+ final endDate = DateFormat('dd-MM-yyyy').parse(toDate);
+ return date.isAfter(startDate) && date.isBefore(endDate);
+ //reportsList=reportsListOriginal.reversed.toList();
+ }).toList();
+
+ /*if( dateToCheck.isAfter(startDate) && dateToCheck.isBefore(endDate))
+ {
+ print("dateToCheck is between now and lastYear");
+ }
+ else
+ {
+ print("dateToCheck is not between now and lastYear");
+ }*/
+
+
+ isProblemDataLoading = false;
+ });
+ } catch (e) {
+ setState(() {
+ isProblemDataLoading = false;
+ isSereverIssue = true;
+ });
+ }
+ }
+
+
+ @override
+ void initState() {
+ getAllProblemsReportMyself();
+ var now = new DateTime.now();
+ String formattedDate = DateFormat('dd-MM-yyyy').format(now);
+ fromdateController.text=formattedDate;
+ todateController.text=formattedDate;
+ super.initState();
+ }
+
+
+ showPicDialog(var imageUrl){
+ return showDialog(
+ context: context,
+ barrierDismissible: false,
+ builder: (BuildContext context) {
+ return StatefulBuilder(
+ builder: (BuildContext context, StateSetter setState) {
+ return AlertDialog(
+ title: const Text(''),
+ content: SingleChildScrollView(
+ child: ListBody(
+ children: [
+ Container(
+ width: MediaQuery.of(context).size.width * .10,
+ height: MediaQuery.of(context).size.height * .50,
+ child: PhotoView(
+ imageProvider: NetworkImage(imageUrl) as ImageProvider,
+ maxScale: PhotoViewComputedScale.contained * 4.0,
+ minScale: PhotoViewComputedScale.contained,
+ initialScale: PhotoViewComputedScale.contained,
+ basePosition: Alignment.center,
+
+ )
+ )
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(
+ child: Text('Close', style: textButtonStyle()),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ );
+ });
+ },
+ );
+ }
+
+
+ Widget findings(var obj){
+ return Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.findingsImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ /*showPicDialog(obj.findingsImages[index]['url']);*/
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Findings',imageDetails:obj.findingsImages[index]['url'])));
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width *
+ .30,
+ height:
+ MediaQuery.of(context).size.height *
+ .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.findingsImages[index]['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ );
+ }
+
+ Widget reports(var obj){
+
+ return Container(
+ width: double.infinity,
+ height: MediaQuery.of(context).size.height * .20,
+ child: ListView.builder(
+ scrollDirection: Axis.horizontal,
+ itemCount: obj.reportImages.length,
+ itemBuilder: (context, index) {
+ return Column(
+ children: [
+ Card(
+ child: GestureDetector(
+ onTap: (){
+ //showPicDialog(obj.reportImages[index]['url']);
+
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Reports',imageDetails:obj.reportImages[index]['url'])));
+
+ },
+ child: Container(
+ width: MediaQuery.of(context).size.width * .30,
+ height: MediaQuery.of(context).size.height * .15,
+ decoration: BoxDecoration(
+ shape: BoxShape.rectangle,
+ image: DecorationImage(
+ image: NetworkImage(
+ obj.reportImages[index]
+ ['url'])
+ as ImageProvider, // picked file
+ fit: BoxFit.fill)),
+ ),
+ ),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.remove,color: Colors.red,),
+
+ onPressed: () async{
+
+ },
+ ),)*/
+ ],
+ );
+ }),
+ );
+
+ }
+
+
+
+ Future playFunc(var audio) async {
+ recordingPlayer.open(
+ Audio.file(audio),
+ autoStart: true,
+ showNotification: true,
+ );
+ }
+
+ Future stopPlayFunc() async {
+ recordingPlayer.stop();
+ }
+
+ Widget _filtereddata(){
+ if(allProblemsList.length!=0){
+ return ListView.builder(
+ itemCount: allProblemsList.length,
+ itemBuilder: (BuildContext context, int index) {
+ return GestureDetector(
+ onTap: (){
+
+ },
+ child: Card(
+
+ //color: prescriptionsList[index].cardColor,
+ child: Padding(
+ padding:EdgeInsets.all(8) ,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+
+ Container(
+ width: MediaQuery.of(context).size.width * .60,
+ child:
+ Column(
+ children: [
+ Row(
+ children: [
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ 'Problem',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ 'Description',
+ style: labelTextStyle(),
+ ),
+
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ 'Date',
+ style: labelTextStyle(),
+ ),
+ ],
+ ),
+ SizedBox(width:MediaQuery.of(context).size.width * .01,),
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ ':',
+ style: labelTextStyle(),
+ ),
+ ],
+ ),
+ SizedBox(width:MediaQuery.of(context).size.width * .01,),
+ Expanded(child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ allProblemsList[index]
+ .problem
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ allProblemsList[index].description
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ SizedBox(height:MediaQuery.of(context).size.height * .01,),
+ Text(
+ allProblemsList[index]
+ .date
+ .toString()
+ .toUpperCase(),
+ style: valuesTextStyle()),
+ ],
+ ),)
+ ],
+ ),
+ Row(
+ children: [
+ Visibility(
+ visible: allProblemsList[index].audio!='',
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ setState(() {
+
+
+ if(!allProblemsList[index].isAudioButtonEnabled){
+ setState(() {
+ allProblemsList[index].isAudioButtonEnabled=true;
+ });
+ }
+ else{
+ setState(() {
+ allProblemsList[index].isAudioButtonEnabled=false;
+ });
+ }
+ });
+ },
+ child: const Text('Audio'),
+ ),),
+ Visibility(
+ visible: allProblemsList[index].audio!='',
+ child: SizedBox(
+ width:MediaQuery.of(context).size.width * .01,
+ ) ,),
+ Visibility(
+ visible: allProblemsList[index].video!='',
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ProblemVideo(videoUrl:allProblemsList[index].video)));
+
+ },
+ child: const Text('Video'),
+ ),),
+
+ Visibility(
+ visible: allProblemsList[index].video!='',
+ child: SizedBox(
+ width:MediaQuery.of(context).size.width * .01,
+ ) ,),
+ Visibility(
+ visible: allProblemsList[index].image!='',
+ child: ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ primary: primaryColor, // background
+ onPrimary: Colors.white, // foreground
+ ),
+ onPressed: () async {
+ Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new ImageZoomPage(imageName:'Problem Picture',imageDetails:allProblemsList[index].image)));
+
+ },
+ child: const Text('Image'),
+ ),),
+
+ ],
+ ),
+ Visibility(
+ visible: allProblemsList[index].isAudioButtonEnabled,
+ child:Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ ElevatedButton.icon(
+ style:
+ ElevatedButton.styleFrom(elevation: 9.0, primary: Colors.red),
+ onPressed: () {
+ setState(() {
+ _playAudio = !_playAudio;
+ });
+ if (_playAudio) playFunc(allProblemsList[index].audio);
+ if (!_playAudio) stopPlayFunc();
+ },
+ icon: _playAudio
+ ? Icon(
+ Icons.stop,
+ )
+ : Icon(Icons.play_arrow),
+ label: _playAudio
+ ? Text(
+ "Stop",
+ style: TextStyle(
+ fontSize: 28,
+ ),
+ )
+ : Text(
+ "Play",
+ style: TextStyle(
+ fontSize: 28,
+ ),
+ ),
+ ),
+ ],
+ )
+ )
+
+ ],
+ )
+ ),
+
+
+ Visibility(
+ visible:false,
+ child: Expanded(child:IconButton(
+ icon: const Icon(Icons.edit,color: primaryColor,),
+ onPressed: () {
+
+ /*Navigator.push(
+ context,
+ new MaterialPageRoute(
+ builder: (__) => new UpdateReport(reportDetails:allProblemsList[index]))).then((value) {
+ getAllProblemsReportMyself();
+ });*/
+ },
+ ),),
+ ),
+ /*Expanded(child:IconButton(
+ icon: const Icon(Icons.delete,color: primaryColor,),
+
+ onPressed: () async{
+ showDialog(
+ //if set to true allow to close popup by tapping out of the popup
+ //barrierDismissible: false,
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title: const Text('Do you want to delete Record?',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ actionsAlignment: MainAxisAlignment.spaceBetween,
+ actions: [
+ TextButton(
+ onPressed: ()async {
+
+ bool deleteTankStatus = await AppSettings.deleteReportMySelfProblem(allProblemsList[index].problemId);
+
+
+ if(deleteTankStatus){
+ getAllProblemsReportMyself();
+ AppSettings.longSuccessToast('Problem deleted successfully');
+ Navigator.of(context).pop(true);
+
+ }
+ else{
+ AppSettings.longFailedToast('Problem deletion failed');
+ Navigator.of(context).pop(true);
+ }
+ },
+ child: const Text('Yes',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ TextButton(
+ onPressed: () {
+ Navigator.of(context).pop(true);
+ },
+ child: const Text('No',
+ style: TextStyle(
+ color: primaryColor,
+ fontSize: 20,
+ )),
+ ),
+ ],
+ ),
+ );
+
+
+
+ },
+ ),)*/
+
+ ],
+
+ ),
+
+ ],
+ ),
+ ),
+ ),
+ );
+ });
+ }
+ else{
+ return Padding(padding: EdgeInsets.fromLTRB(60,10,60,10),
+ child: Column(
+ children: [
+ Text('No problems 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(allProblemsListOriginal.length!=0){
+
+ return Padding(padding:EdgeInsets.all(10),
+ child:Column(
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ Container(
+ 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!;
+ });
+ },
+ ),
+ ),
+ SizedBox(height: MediaQuery.of(context).size.height * .01,),
+ Visibility(
+ visible:dropdownSearchType.toString().toLowerCase()=='problem' ,
+ child: Container(
+ height: MediaQuery.of(context).size.height * .07,
+ child: Center(child: TextField(
+
+ cursorColor: primaryColor,
+ controller: searchController,
+ onChanged: (string) {
+ if(string.length>=1){
+ getAllProblemsReportMyselfByProblem(string);
+ }
+ else{
+ getAllProblemsReportMyself();
+ }
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.search,
+ color: primaryColor,
+ ),
+ /*suffixIcon: Icon(
+ Icons.clear,
+ color: greyColor,
+ ),*/
+ suffixIcon: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllProblemsReportMyself();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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,
+ child: Center(child: TextField(
+
+ cursorColor: primaryColor,
+ controller: searchController,
+ onChanged: (string) {
+ if(string.length>=1){
+ //getRecordsByDoctorName(string);
+ }
+ else{
+ getAllProblemsReportMyself();
+ }
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.search,
+ color: primaryColor,
+ ),
+ /*suffixIcon: Icon(
+ Icons.clear,
+ color: greyColor,
+ ),*/
+ suffixIcon: searchController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ searchController.text='';
+ });
+ getAllProblemsReportMyself();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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
+ ),
+ ),
+ ),)
+ ),),
+ Visibility(
+ visible:dropdownSearchType.toString().toLowerCase()=='date',
+ child: Container(
+ //height: 60,
+ child: Row(
+ children: [
+ Expanded(
+ child: TextField(
+
+ cursorColor: primaryColor,
+ controller: fromdateController,
+ onChanged: (string) {
+ if(string.length>=1){
+ //getRecordsByDate(string);
+ }
+ else{
+ getAllProblemsReportMyself();
+ }
+ },
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ fromdateController.text = formattedDate; //set output date to TextField value.
+ });
+ getAllProblemsReportMyselfByDateRange(fromdateController.text,todateController.text);
+ } else {}
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ suffixIcon: fromdateController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ fromdateController.text='';
+ });
+ getAllProblemsReportMyself();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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: 'From date',
+
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+ Expanded(
+ child: TextField(
+
+ cursorColor: primaryColor,
+ controller: todateController,
+ onChanged: (string) {
+ if(string.length>=1){
+ //getRecordsByDate(string);
+ }
+ else{
+ getAllProblemsReportMyself();
+ }
+ },
+ onTap: () async {
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: DateTime.now(),
+ firstDate: DateTime(1950),
+ lastDate: DateTime.now(),
+ builder: (BuildContext context, Widget? child) {
+ return Theme(
+ data: ThemeData.dark().copyWith(
+ colorScheme: ColorScheme.dark(
+ primary: buttonColors,
+ onPrimary: Colors.white,
+ surface: buttonColors,
+ onSurface: Colors.white,
+ ),
+ dialogBackgroundColor: primaryColor,
+ ),
+ child: child!,
+ );
+ },
+ );
+
+ if (pickedDate != null) {
+ print(
+ pickedDate); //pickedDate output format => 2021-03-10 00:00:00.000
+ String formattedDate =
+ DateFormat('dd-MM-yyyy').format(pickedDate);
+ print(
+ formattedDate); //formatted date output using intl package => 2021-03-16
+ setState(() {
+ todateController.text = formattedDate; //set output date to TextField value.
+ });
+ getAllProblemsReportMyselfByDateRange(fromdateController.text,todateController.text);
+ } else {}
+ },
+ decoration: InputDecoration(
+ prefixIcon: Icon(
+ Icons.calendar_month,
+ color: primaryColor,
+ ),
+ suffixIcon: todateController.text!=''?IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.red,
+ ),
+ onPressed: () {
+ setState(() {
+ todateController.text='';
+ });
+ getAllProblemsReportMyself();
+ },
+ ):IconButton(
+ icon: Icon(
+ Icons.clear,
+ color: Colors.transparent,
+ ),
+ onPressed: () {
+ },
+ ),
+ 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: 'To date',
+
+ labelStyle: TextStyle(
+ color: greyColor, //<-- SEE HERE
+ ),
+ ),
+ ),
+ ),
+ SizedBox(width: 5),
+
+ ],
+ ),
+ ),),
+ Expanded(child: _filtereddata()),
+ ]));
+
+
+ }
+ else{
+ return Center(
+ child: Padding(
+ padding: EdgeInsets.fromLTRB(0, 40, 0, 0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ SizedBox(height: MediaQuery.of(context).size.height * .25,),
+ Text('No Data found'),
+ SizedBox(
+ height: 20,
+ ),
+ CircleAvatar(
+ backgroundColor: primaryColor,
+ radius: 40,
+ child: IconButton(
+ iconSize: 40,
+ icon: const Icon(
+ Icons.info,
+ color: Colors.white,
+ ),
+ onPressed: () async {
+ /*Navigator.push(context, MaterialPageRoute(builder: (context) => ReportMySelf())).then((value) {
+ getAllProblemsReportMyself();
+ });*/
+ },
+ ),
+ )
+ ],
+ ),
+ )
+ );
+ }
+
+
+ }
+
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('New Problems'),
+ body: isProblemDataLoading?Center(
+ child: CircularProgressIndicator(
+ color: primaryColor,
+ strokeWidth: 5.0,
+ ),
+ ): _allreports(),
+ );
+ }
+}
+
diff --git a/lib/patient_dashboard/problems/video_file.dart b/lib/patient_dashboard/problems/video_file.dart
new file mode 100644
index 0000000..88d7269
--- /dev/null
+++ b/lib/patient_dashboard/problems/video_file.dart
@@ -0,0 +1,59 @@
+import 'package:flutter/material.dart';
+import 'package:video_player/video_player.dart';
+import 'package:flick_video_player/flick_video_player.dart';
+
+class ProblemVideo extends StatefulWidget {
+ var videoUrl;
+ ProblemVideo({this.videoUrl});
+
+ @override
+ State createState() => _ProblemVideoState();
+}
+
+class _ProblemVideoState extends State {
+
+ late VideoPlayerController _controller;
+ late Future _initializeVideoPlayerFuture;
+ late FlickManager flickManager;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = VideoPlayerController.networkUrl(
+ Uri.parse(widget.videoUrl,),
+ );
+ flickManager = FlickManager(
+ videoPlayerController:
+ VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl,),)
+ );
+ _initializeVideoPlayerFuture = _controller.initialize();
+ _controller.setLooping(false);
+ }
+ @override
+ void dispose() {
+ // Ensure disposing of the VideoPlayerController to free up resources.
+ _controller.dispose();
+ flickManager.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Container(
+ height: MediaQuery.of(context).size.height * .30,
+ width: double.infinity,
+ child:FlickVideoPlayer(
+ flickManager: flickManager,
+ flickVideoWithControls: FlickVideoWithControls(
+ videoFit: BoxFit.fill,
+ controls: FlickPortraitControls(
+ progressBarSettings:
+ FlickProgressBarSettings(playedColor: Colors.green),
+ ),
+ ),
+
+ ),
+
+ );
+ }
+}
diff --git a/lib/video_call/video_call.dart b/lib/video_call/video_call.dart
new file mode 100644
index 0000000..fbad608
--- /dev/null
+++ b/lib/video_call/video_call.dart
@@ -0,0 +1,19 @@
+import 'package:doctor/common/settings.dart';
+import 'package:flutter/material.dart';
+
+class VideoCall extends StatefulWidget {
+ const VideoCall({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _VideoCallState();
+}
+
+class _VideoCallState extends State {
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppSettings.appBar('Video Call'),
+ body: Container(),
+ );
+ }
+}
diff --git a/pubspec.lock b/pubspec.lock
index 56010e5..9f33314 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -370,6 +370,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ flutter_barcode_scanner:
+ dependency: "direct main"
+ description:
+ name: flutter_barcode_scanner
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.0.0"
flutter_cupertino_datetime_picker:
dependency: "direct main"
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 09f4875..7fd4a28 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -61,6 +61,7 @@ dependencies:
flutter_launcher_icons: ^0.11.0
share: ^2.0.4
flutter_share: ^2.0.0
+ flutter_barcode_scanner: ^2.0.0
dev_dependencies:
flutter_test: