add success message to add patient, edit patient,patient notes, patient files.
update note and file view to match UI. restrict file types in file uploud. add image viewer
This commit is contained in:
44
Frontend/patient_manager/lib/components/BuildFileView.dart
Normal file
44
Frontend/patient_manager/lib/components/BuildFileView.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||
|
||||
class BuildFileView extends StatefulWidget {
|
||||
final String pdfLink;
|
||||
const BuildFileView({super.key, required this.pdfLink});
|
||||
|
||||
@override
|
||||
State<BuildFileView> createState() => _BuildFileViewState();
|
||||
}
|
||||
|
||||
class _BuildFileViewState extends State<BuildFileView> {
|
||||
late PdfViewerController pdfViewerController = PdfViewerController();
|
||||
|
||||
String getExtType(String pdfLink) {
|
||||
//print(pdfLink.split(".")[1]);
|
||||
return pdfLink.split(".")[1];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (getExtType(widget.pdfLink).toLowerCase() == "pdf") {
|
||||
return SizedBox(
|
||||
width: 700,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SfPdfViewer.network(
|
||||
widget.pdfLink,
|
||||
controller: pdfViewerController,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return InteractiveViewer(
|
||||
maxScale: 5.0,
|
||||
//minScale: 0.,
|
||||
child: Image.network(widget.pdfLink),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||
|
||||
class BuildPDFView extends StatefulWidget {
|
||||
final String pdfLink;
|
||||
const BuildPDFView({super.key, required this.pdfLink});
|
||||
|
||||
@override
|
||||
State<BuildPDFView> createState() => _BuildPDFViewState();
|
||||
}
|
||||
|
||||
class _BuildPDFViewState extends State<BuildPDFView> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: 700,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SfPdfViewer.network(widget.pdfLink),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/BuildPdfView.dart';
|
||||
import 'package:patient_manager/components/BuildFileView.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/objects/files.dart';
|
||||
import 'dart:js' as js;
|
||||
//import 'dart:js' as js;
|
||||
import "package:universal_html/html.dart" as html;
|
||||
|
||||
class BuildFilesList extends StatefulWidget {
|
||||
final List<PFile> files;
|
||||
@@ -14,9 +16,78 @@ class BuildFilesList extends StatefulWidget {
|
||||
State<BuildFilesList> createState() => _BuildFilesListState();
|
||||
}
|
||||
|
||||
int indexOn = 0;
|
||||
|
||||
class _BuildFilesListState extends State<BuildFilesList> {
|
||||
int indexOn = 0;
|
||||
|
||||
void viewFilePopUp(String filename) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => Dialog(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
width: 800.0,
|
||||
//height: 475.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(color: Colors.blueAccent, width: 5.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
filename,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
fontSize: 35.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25.0),
|
||||
Expanded(
|
||||
child: BuildFileView(
|
||||
pdfLink: "http://localhost:9000/mih/$filename")),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
height: 100,
|
||||
child: MyButton(
|
||||
onTap: () {
|
||||
html.window.open(
|
||||
'http://localhost:9000/mih/$filename', 'download');
|
||||
},
|
||||
buttonText: "Dowload",
|
||||
buttonColor: Colors.blueAccent,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.red,
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
@@ -35,36 +106,7 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
||||
subtitle: Text(widget.files[index].insert_date),
|
||||
trailing: const Icon(Icons.arrow_forward),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(widget.files[index].file_name),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
js.context.callMethod('open', [
|
||||
'http://localhost:9000/mih/${widget.files[index].file_name}'
|
||||
]);
|
||||
//print(object)
|
||||
},
|
||||
icon: const Icon(Icons.download),
|
||||
),
|
||||
],
|
||||
),
|
||||
content: BuildPDFView(
|
||||
pdfLink:
|
||||
"http://localhost:9000/mih/${widget.files[index].file_name}"),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Close"))
|
||||
],
|
||||
),
|
||||
);
|
||||
viewFilePopUp(widget.files[index].file_name);
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/myMLTextInput.dart';
|
||||
//import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/objects/notes.dart';
|
||||
|
||||
class BuildNotesList extends StatefulWidget {
|
||||
@@ -12,9 +14,87 @@ class BuildNotesList extends StatefulWidget {
|
||||
State<BuildNotesList> createState() => _BuildNotesListState();
|
||||
}
|
||||
|
||||
int indexOn = 0;
|
||||
|
||||
class _BuildNotesListState extends State<BuildNotesList> {
|
||||
final noteTextController = TextEditingController();
|
||||
int indexOn = 0;
|
||||
|
||||
void viewNotePopUp(String title, String note) {
|
||||
setState(() {
|
||||
noteTextController.text = note;
|
||||
});
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => Dialog(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
width: 700.0,
|
||||
//height: 475.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(color: Colors.blueAccent, width: 5.0),
|
||||
),
|
||||
child: Column(
|
||||
//mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Colors.blueAccent,
|
||||
fontSize: 35.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25.0),
|
||||
Expanded(
|
||||
child: MyMLTextField(
|
||||
controller: noteTextController,
|
||||
hintText: "Note Details",
|
||||
editable: false,
|
||||
required: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25.0),
|
||||
// SizedBox(
|
||||
// width: 300,
|
||||
// height: 100,
|
||||
// child: MyButton(
|
||||
// onTap: () {
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// buttonText: "Close",
|
||||
// buttonColor: Colors.blueAccent,
|
||||
// textColor: Colors.white,
|
||||
// ),
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 5,
|
||||
right: 5,
|
||||
width: 50,
|
||||
height: 50,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.red,
|
||||
size: 35,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
@@ -34,27 +114,29 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
||||
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}"), //Text(widget.notes[index].note_text),
|
||||
trailing: const Icon(Icons.arrow_forward),
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Center(child: Text(widget.notes[index].note_name)),
|
||||
content: SizedBox(
|
||||
width: 700,
|
||||
height: 250,
|
||||
child: Text(
|
||||
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}",
|
||||
style: TextStyle(fontSize: 16),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text("Close"))
|
||||
],
|
||||
),
|
||||
);
|
||||
viewNotePopUp(widget.notes[index].note_name,
|
||||
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}");
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (context) => AlertDialog(
|
||||
// title: Center(child: Text(widget.notes[index].note_name)),
|
||||
// content: SizedBox(
|
||||
// width: 700,
|
||||
// height: 250,
|
||||
// child: Text(
|
||||
// "${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}",
|
||||
// style: TextStyle(fontSize: 16),
|
||||
// ),
|
||||
// ),
|
||||
// actions: [
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// child: const Text("Close"))
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/buildFilesList.dart';
|
||||
import 'package:patient_manager/components/medCertInput.dart';
|
||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/main.dart';
|
||||
@@ -47,6 +48,16 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
late PlatformFile selected;
|
||||
|
||||
Future<void> generateMedCert() async {
|
||||
//start loading circle
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
var response1 = await http.post(
|
||||
Uri.parse(endpointGenFiles),
|
||||
headers: <String, String>{
|
||||
@@ -85,8 +96,11 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
futueFiles =
|
||||
fetchFiles(endpointFiles + widget.patientIndex.toString());
|
||||
});
|
||||
String message = "Successfully added file";
|
||||
messagePopUp(message);
|
||||
// end loading circle
|
||||
Navigator.of(context).pop();
|
||||
String message =
|
||||
"The medical certificate $fileName has been successfully generated and added to ${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}'s record. You can now access and download it for their use.";
|
||||
successPopUp(message);
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -97,12 +111,22 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
|
||||
Future<void> uploadSelectedFile(PlatformFile file) async {
|
||||
//var strem = new http.ByteStream.fromBytes(file.bytes.)
|
||||
//start loading circle
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
var request = http.MultipartRequest('POST', Uri.parse(endpointFileUpload));
|
||||
request.headers['Content-Type'] = 'multipart/form-data';
|
||||
request.files.add(await http.MultipartFile.fromBytes('file', file.bytes!,
|
||||
filename: file.name.replaceAll(RegExp(r' '), '-')));
|
||||
var response1 = await request.send();
|
||||
print(response1.statusCode);
|
||||
//print(response1.statusCode);
|
||||
if (response1.statusCode == 200) {
|
||||
var response2 = await http.post(
|
||||
Uri.parse(endpointInsertFiles),
|
||||
@@ -115,15 +139,18 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
"patient_id": widget.patientIndex
|
||||
}),
|
||||
);
|
||||
print(response2.statusCode);
|
||||
//print(response2.statusCode);
|
||||
if (response2.statusCode == 201) {
|
||||
setState(() {
|
||||
selectedFileController.clear();
|
||||
futueFiles =
|
||||
fetchFiles(endpointFiles + widget.patientIndex.toString());
|
||||
});
|
||||
String message = "Successfully added file";
|
||||
messagePopUp(message);
|
||||
// end loading circle
|
||||
Navigator.of(context).pop();
|
||||
String message =
|
||||
"The medical certificate ${file.name.replaceAll(RegExp(r' '), '-')} has been successfully generated and added to ${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}'s record. You can now access and download it for their use.";
|
||||
successPopUp(message);
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
@@ -170,6 +197,18 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MySuccessMessage(
|
||||
successType: "Success",
|
||||
successMessage: message,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void messagePopUp(error) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -232,7 +271,7 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonText: "Add Note",
|
||||
buttonText: "Generate",
|
||||
buttonColor: Colors.blueAccent,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
@@ -295,7 +334,10 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
child: MyButton(
|
||||
onTap: () async {
|
||||
FilePickerResult? result =
|
||||
await FilePicker.platform.pickFiles();
|
||||
await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['jpg', 'pdf'],
|
||||
);
|
||||
if (result == null) return;
|
||||
final selectedFile = result.files.first;
|
||||
setState(() {
|
||||
@@ -335,7 +377,7 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonText: "Add Note",
|
||||
buttonText: "Add File",
|
||||
buttonColor: Colors.blueAccent,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/buildNotesList.dart';
|
||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/components/myMLTextInput.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
import 'package:patient_manager/components/mybutton.dart';
|
||||
import 'package:patient_manager/objects/notes.dart';
|
||||
@@ -56,13 +57,26 @@ class _PatientNotesState extends State<PatientNotes> {
|
||||
});
|
||||
// Navigator.of(context)
|
||||
// .pushNamed('/patient-manager', arguments: widget.userEmail);
|
||||
String message = "Successfully added Note";
|
||||
messagePopUp(message);
|
||||
String message =
|
||||
"Your note has been successfully added to the patients medical record. You can now view it alongside their other important information.";
|
||||
successPopUp(message);
|
||||
} else {
|
||||
internetConnectionPopUp();
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String message) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return MySuccessMessage(
|
||||
successType: "Success",
|
||||
successMessage: message,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void internetConnectionPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user