diff --git a/Frontend/patient_manager/lib/components/buildNotesList.dart b/Frontend/patient_manager/lib/components/buildNotesList.dart index 20263da5..7bf5415c 100644 --- a/Frontend/patient_manager/lib/components/buildNotesList.dart +++ b/Frontend/patient_manager/lib/components/buildNotesList.dart @@ -17,38 +17,41 @@ int indexOn = 0; class _BuildNotesListState extends State { @override Widget build(BuildContext context) { - return ListView.separated( - shrinkWrap: true, - separatorBuilder: (BuildContext context, int index) { - return const Divider(); - }, - itemCount: widget.notes.length, - itemBuilder: (context, index) { - return ListTile( - title: Text( - widget.notes[index].note_name, - ), - subtitle: Text(widget.notes[index].note_text), - trailing: const Icon(Icons.arrow_forward), - onTap: () { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text(widget.notes[index].note_name), - content: Text( - "${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}"), - actions: [ - TextButton( - onPressed: () { - Navigator.pop(context); - }, - child: const Text("Close")) - ], - ), - ); - }, - ); - }, + return Container( + height: 290.0, + child: ListView.separated( + shrinkWrap: true, + separatorBuilder: (BuildContext context, int index) { + return const Divider(); + }, + itemCount: widget.notes.length, + itemBuilder: (context, index) { + return ListTile( + title: Text( + widget.notes[index].note_name, + ), + subtitle: Text(widget.notes[index].note_text), + trailing: const Icon(Icons.arrow_forward), + onTap: () { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text(widget.notes[index].note_name), + content: Text( + "${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}"), + actions: [ + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Close")) + ], + ), + ); + }, + ); + }, + ), ); } } diff --git a/Frontend/patient_manager/lib/components/myMLTextInput.dart b/Frontend/patient_manager/lib/components/myMLTextInput.dart new file mode 100644 index 00000000..7b2eaf1d --- /dev/null +++ b/Frontend/patient_manager/lib/components/myMLTextInput.dart @@ -0,0 +1,53 @@ +import 'package:flutter/material.dart'; + +class MyMLTextField extends StatelessWidget { + final controller; + final String hintText; + final bool editable; + + const MyMLTextField({ + super.key, + required this.controller, + required this.hintText, + required this.editable, + }); + + bool makeEditable() { + if (editable) { + return false; + } else { + return true; + } + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 25.0), + child: TextField( + textAlign: TextAlign.start, + textAlignVertical: TextAlignVertical.top, + expands: true, + maxLines: null, + controller: controller, + readOnly: makeEditable(), + obscureText: false, + decoration: InputDecoration( + fillColor: Colors.white, + filled: true, + hintText: hintText, + hintStyle: TextStyle(color: Colors.blueGrey[400]), + enabledBorder: const OutlineInputBorder( + borderSide: BorderSide( + color: Colors.blueAccent, + width: 2.0, + ), + ), + focusedBorder: const OutlineInputBorder( + borderSide: BorderSide(color: Colors.blue), + ), + ), + ), + ); + } +} diff --git a/Frontend/patient_manager/lib/components/patientNotes.dart b/Frontend/patient_manager/lib/components/patientNotes.dart index 21ec9408..d064277c 100644 --- a/Frontend/patient_manager/lib/components/patientNotes.dart +++ b/Frontend/patient_manager/lib/components/patientNotes.dart @@ -2,6 +2,8 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:patient_manager/components/buildNotesList.dart'; +import 'package:patient_manager/components/myMLTextInput.dart'; +import 'package:patient_manager/components/myTextInput.dart'; import 'package:patient_manager/objects/notes.dart'; import 'package:http/http.dart' as http; @@ -26,8 +28,47 @@ class PatientNotes extends StatefulWidget { class _PatientNotesState extends State { String endpoint = "http://localhost:80/notes/patients/"; + String apiUrlAddNote = "http://localhost:80/notes/insert/"; + final titleController = TextEditingController(); + final noteTextController = TextEditingController(); late Future> futueNotes; + Future addPatientNoteAPICall() async { + var response = await http.post( + Uri.parse(apiUrlAddNote), + headers: { + "Content-Type": "application/json; charset=UTF-8" + }, + body: jsonEncode({ + "note_name": titleController.text, + "note_text": noteTextController.text, + "patient_id": widget.patientIndex, + }), + ); + if (response.statusCode == 201) { + setState(() { + futueNotes = fetchNotes(endpoint + widget.patientIndex.toString()); + }); + // Navigator.of(context) + // .pushNamed('/patient-manager', arguments: widget.userEmail); + String message = "Successfully added Note"; + messagePopUp(message); + } else { + messagePopUp("error"); + } + } + + void messagePopUp(error) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + title: Text(error), + ); + }, + ); + } + @override void initState() { futueNotes = fetchNotes(endpoint + widget.patientIndex.toString()); @@ -43,13 +84,13 @@ class _PatientNotesState extends State { return const CircularProgressIndicator(); } else if (snapshot.hasData) { final notesList = snapshot.data!; - return Expanded( - flex: 1, + return Flexible( child: Padding( padding: const EdgeInsets.all(10.0), child: Card( elevation: 20.0, child: Container( + //height: 300.0, decoration: const BoxDecoration( color: Color.fromARGB(255, 219, 218, 218), borderRadius: BorderRadius.all( @@ -58,22 +99,88 @@ class _PatientNotesState extends State { ), child: Padding( padding: const EdgeInsets.only(top: 5.0), - child: Column(children: [ - const Text( - "Notes", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 35, - fontWeight: FontWeight.bold, + child: Expanded( + child: Column(children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + "Notes", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 35, + fontWeight: FontWeight.bold, + ), + ), + IconButton( + onPressed: () { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Row( + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text("Add Note"), + ], + ), + content: Column( + children: [ + SizedBox( + width: 700, + child: MyTextField( + controller: titleController, + hintText: "Title of Note", + editable: true, + ), + ), + const SizedBox( + height: 25.0, + ), + Expanded( + child: MyMLTextField( + controller: noteTextController, + hintText: "Note Details", + editable: true, + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () { + addPatientNoteAPICall(); + Navigator.pop(context); + //print(widget.patientIndex); + }, + child: const Text( + "Submit", + style: TextStyle( + fontWeight: FontWeight.bold), + ), + ), + TextButton( + onPressed: () { + Navigator.pop(context); + }, + child: const Text("Cancel"), + ) + ], + ), + ); + }, + icon: const Icon(Icons.add), + ) + ], ), - ), - const Padding( - padding: EdgeInsets.symmetric(horizontal: 20.0), - child: Divider(), - ), - const SizedBox(height: 10), - BuildNotesList(notes: notesList), - ]), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 20.0), + child: Divider(), + ), + const SizedBox(height: 10), + BuildNotesList(notes: notesList), + ]), + ), ), ), ), diff --git a/Frontend/patient_manager/lib/pages/patientEdit.dart b/Frontend/patient_manager/lib/pages/patientEdit.dart index e622cb1b..e0785825 100644 --- a/Frontend/patient_manager/lib/pages/patientEdit.dart +++ b/Frontend/patient_manager/lib/pages/patientEdit.dart @@ -207,7 +207,12 @@ class _EditPatientState extends State { onPressed: () { deletePatientApiCall(); }, - child: const Text("Yes"), + child: const Text( + "Yes", + style: TextStyle( + fontWeight: FontWeight.bold, + ), + ), ), TextButton( onPressed: () { diff --git a/database/#ib_16384_0.dblwr b/database/#ib_16384_0.dblwr index 96d2c5fb..58974aa3 100644 Binary files a/database/#ib_16384_0.dblwr and b/database/#ib_16384_0.dblwr differ diff --git a/database/#innodb_redo/#ib_redo10 b/database/#innodb_redo/#ib_redo10 index 96890f48..f5dd5a87 100644 Binary files a/database/#innodb_redo/#ib_redo10 and b/database/#innodb_redo/#ib_redo10 differ diff --git a/database/binlog.000014 b/database/binlog.000014 index 07028e43..477b7cc2 100644 Binary files a/database/binlog.000014 and b/database/binlog.000014 differ diff --git a/database/ibdata1 b/database/ibdata1 index 41b6a88b..3878ebab 100644 Binary files a/database/ibdata1 and b/database/ibdata1 differ diff --git a/database/mysql.ibd b/database/mysql.ibd index 7b47a00b..f2303da3 100644 Binary files a/database/mysql.ibd and b/database/mysql.ibd differ diff --git a/database/patient_manager/patient_notes.ibd b/database/patient_manager/patient_notes.ibd index ffa0da5b..87e706a7 100644 Binary files a/database/patient_manager/patient_notes.ibd and b/database/patient_manager/patient_notes.ibd differ diff --git a/database/undo_001 b/database/undo_001 index c9fa71e0..397f1be6 100644 Binary files a/database/undo_001 and b/database/undo_001 differ diff --git a/database/undo_002 b/database/undo_002 index 20f47e2c..0ed788bd 100644 Binary files a/database/undo_002 and b/database/undo_002 differ