File frontend added to app

This commit is contained in:
2024-06-25 13:47:40 +02:00
parent ad805fdca1
commit 0a83d08492
62 changed files with 497 additions and 64 deletions

View File

@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/objects/files.dart';
class BuildFilesList extends StatefulWidget {
final List<PFile> files;
const BuildFilesList({
super.key,
required this.files,
});
@override
State<BuildFilesList> createState() => _BuildFilesListState();
}
int indexOn = 0;
class _BuildFilesListState extends State<BuildFilesList> {
@override
Widget build(BuildContext context) {
return SizedBox(
height: 290.0,
child: ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, int index) {
return const Divider();
},
itemCount: widget.files.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
widget.files[index].file_name,
),
subtitle: Text(widget.files[index].insert_date),
trailing: const Icon(Icons.arrow_forward),
onTap: () {
//Insert Display function here
},
);
},
),
);
}
}

View File

@@ -30,15 +30,22 @@ class _BuildNotesListState extends State<BuildNotesList> {
title: Text(
widget.notes[index].note_name,
),
subtitle: Text(widget.notes[index].note_text),
subtitle: Text(
"${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: Text(widget.notes[index].note_name),
content: Text(
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}"),
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: () {

View File

@@ -0,0 +1,67 @@
import 'package:flutter/material.dart';
class MyDateField extends StatefulWidget {
final controller;
final String LableText;
//final bool editable;
const MyDateField({
super.key,
required this.controller,
required this.LableText,
//required this.editable,
});
@override
State<MyDateField> createState() => _MyDateFieldState();
}
class _MyDateFieldState extends State<MyDateField> {
// bool makeEditable() {
Future<void> _selectDate(BuildContext context) async {
DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2100),
);
if (picked != null) {
setState(() {
widget.controller.text = picked.toString().split(" ")[0];
});
}
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: TextField(
controller: widget.controller,
readOnly: true,
obscureText: false,
decoration: InputDecoration(
labelText: widget.LableText,
prefixIcon: const Icon(Icons.calendar_today),
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),
),
),
onTap: () {
_selectDate(context);
},
),
);
}
}

View File

@@ -0,0 +1,205 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/buildFilesList.dart';
import 'package:patient_manager/components/myDateInput.dart';
import 'package:patient_manager/objects/files.dart';
import 'package:http/http.dart' as http;
Future<List<PFile>> fetchNotes(String endpoint) async {
final response = await http.get(Uri.parse(endpoint));
print(response.statusCode);
//print(response.body);
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<PFile> files =
List<PFile>.from(l.map((model) => PFile.fromJson(model)));
return files;
} else {
throw Exception('failed to load patients');
}
}
class PatientFiles extends StatefulWidget {
final int patientIndex;
const PatientFiles({super.key, required this.patientIndex});
@override
State<PatientFiles> createState() => _PatientFilesState();
}
class _PatientFilesState extends State<PatientFiles> {
String endpoint = "http://localhost:80/files/patients/";
String apiUrlAddNote = "http://localhost:80/notes/insert/";
final startDateController = TextEditingController();
final endDateTextController = TextEditingController();
late Future<List<PFile>> futueFiles;
Future<void> addPatientNoteAPICall() async {
var response = await http.post(
Uri.parse(apiUrlAddNote),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"note_name": startDateController.text,
"note_text": endDateTextController.text,
"patient_id": widget.patientIndex,
}),
);
if (response.statusCode == 201) {
setState(() {
futueFiles = fetchNotes(endpoint + widget.patientIndex.toString());
});
// Navigator.of(context)
// .pushNamed('/patient-manager', arguments: widget.userEmail);
String message = "Successfully added Files";
messagePopUp(message);
} else {
messagePopUp("error");
}
}
void messagePopUp(error) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(error),
);
},
);
}
@override
void initState() {
futueFiles = fetchNotes(endpoint + widget.patientIndex.toString());
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: futueFiles,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
} else if (snapshot.hasData) {
final filesList = snapshot.data!;
return Flexible(
flex: 1,
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(
Radius.circular(10),
),
),
child: Padding(
padding: const EdgeInsets.only(top: 5.0),
child: Column(children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Files",
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("Create Medical Certificate"),
],
),
content: SizedBox(
height: 250,
child: Column(
children: [
const SizedBox(height: 50.0),
SizedBox(
width: 700,
child: MyDateField(
controller: startDateController,
LableText: "From",
),
),
const SizedBox(height: 25.0),
SizedBox(
width: 700,
child: MyDateField(
controller: endDateTextController,
LableText: "Up to Including",
),
),
],
),
),
actions: [
TextButton(
onPressed: () {
//addPatientNoteAPICall();
Navigator.pop(context);
//print(widget.patientIndex);
},
child: const Text(
"Generate",
style: TextStyle(
fontWeight: FontWeight.bold),
),
),
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text("Cancel"),
)
],
),
);
},
icon: const Icon(Icons.sick_outlined),
),
IconButton(
onPressed: () {},
icon: const Icon(Icons.medication_outlined),
)
],
),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: Divider(),
),
const SizedBox(height: 10),
BuildFilesList(files: filesList),
]),
),
),
),
),
);
} else {
return const Center(
child: Text("Error Loading Files"),
);
}
},
);
}
}

View File

@@ -12,6 +12,7 @@ Future<List<Note>> fetchNotes(String endpoint) async {
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<Note> notes = List<Note>.from(l.map((model) => Note.fromJson(model)));
print("Here notes");
return notes;
} else {
throw Exception('failed to load patients');

View File

@@ -0,0 +1,25 @@
class PFile {
final int idpatient_files;
final String file_path;
final String file_name;
final int patient_id;
final String insert_date;
const PFile(
this.idpatient_files,
this.file_path,
this.file_name,
this.patient_id,
this.insert_date,
);
factory PFile.fromJson(dynamic json) {
return PFile(
json['idpatient_files'],
json['file_path'],
json['file_name'],
json['patient_id'],
json['insert_date'],
);
}
}

View File

@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/components/patientDetails.dart';
import 'package:patient_manager/components/myAppBar.dart';
import 'package:patient_manager/components/patientFiles.dart';
import 'package:patient_manager/components/patientNotes.dart';
import 'package:patient_manager/objects/patients.dart';
@@ -31,7 +32,7 @@ class _PatientViewState extends State<PatientView> {
PatientNotes(
patientIndex: widget.selectedPatient.idpatients,
),
PatientNotes(
PatientFiles(
patientIndex: widget.selectedPatient.idpatients,
)
],

View File

@@ -30,7 +30,7 @@ class _SignInState extends State<SignIn> {
}
} on AuthException catch (error) {
loginError(error.message);
emailController.clear();
//emailController.clear();
passwordController.clear();
}
}

View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Define the port
PORT=9000
PORT=8080
# Check if the port is in use and release it if necessary.
echo "Checking if port $PORT is in use..."

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
database/binlog.000022 Normal file

Binary file not shown.

BIN
database/binlog.000023 Normal file

Binary file not shown.

BIN
database/binlog.000024 Normal file

Binary file not shown.

BIN
database/binlog.000025 Normal file

Binary file not shown.

BIN
database/binlog.000026 Normal file

Binary file not shown.

BIN
database/binlog.000027 Normal file

Binary file not shown.

BIN
database/binlog.000028 Normal file

Binary file not shown.

BIN
database/binlog.000029 Normal file

Binary file not shown.

BIN
database/binlog.000030 Normal file

Binary file not shown.

BIN
database/binlog.000031 Normal file

Binary file not shown.

BIN
database/binlog.000032 Normal file

Binary file not shown.

BIN
database/binlog.000033 Normal file

Binary file not shown.

BIN
database/binlog.000034 Normal file

Binary file not shown.

BIN
database/binlog.000035 Normal file

Binary file not shown.

View File

@@ -141,8 +141,8 @@
4243767282,0
4243767281,0
4294967293,0
4294967279,86
4294967279,202
4294967279,86
4294967279,87
4294967279,426
4294967279,427
@@ -162,136 +162,135 @@
4294967279,207
4294967279,208
4294967279,209
4294967279,432
4294967279,94
4294967279,432
4294967279,95
4294967279,96
4294967279,434
4294967279,210
4294967279,211
4294967279,434
4294967279,435
4294967279,212
4294967279,97
4294967279,98
4294967279,212
4294967279,213
4294967279,99
4294967279,474
4294967279,437
4294967279,99
4294967279,100
4294967279,277
4294967279,214
4294967279,215
4294967279,277
4294967279,218
4294967279,216
4294967279,101
4294967279,102
4294967279,216
4294967279,217
4294967279,103
4294967279,220
4294967279,463
4294967279,103
4294967279,104
4294967279,471
4294967279,219
4294967279,221
4294967279,471
4294967279,223
4294967279,225
4294967279,105
4294967279,106
4294967279,225
4294967279,107
4294967279,227
4294967279,511
4294967279,108
4294967279,232
4294967279,109
4294967279,229
4294967279,234
4294967279,227
4294967279,511
4294967279,229
4294967279,231
4294967279,236
4294967279,110
4294967279,233
4294967279,109
4294967279,110
4294967279,111
4294967279,235
4294967279,438
4294967279,112
4294967279,236
4294967279,438
4294967279,239
4294967279,113
4294967279,237
4294967279,241
4294967279,235
4294967279,237
4294967279,238
4294967279,243
4294967279,240
4294967279,113
4294967279,114
4294967279,115
4294967279,240
4294967279,242
4294967279,116
4294967279,243
4294967279,245
4294967279,247
4294967279,116
4294967279,117
4294967279,249
4294967279,242
4294967279,244
4294967279,246
4294967279,249
4294967279,251
4294967279,248
4294967279,117
4294967279,118
4294967279,119
4294967279,248
4294967279,250
4294967279,120
4294967279,251
4294967279,253
4294967279,439
4294967279,120
4294967279,121
4294967279,440
4294967279,250
4294967279,252
4294967279,254
4294967279,440
4294967279,441
4294967279,255
4294967279,121
4294967279,122
4294967279,123
4294967279,256
4294967279,449
4294967279,255
4294967279,450
4294967279,442
4294967279,124
4294967279,125
4294967279,320
4294967279,126
4294967279,441
4294967279,449
4294967279,450
4294967279,451
4294967279,459
4294967279,127
4294967279,452
4294967279,256
4294967279,442
4294967279,320
4294967279,443
4294967279,444
4294967279,453
4294967279,258
4294967279,125
4294967279,126
4294967279,127
4294967279,128
4294967279,129
4294967279,445
4294967279,130
4294967279,459
4294967279,453
4294967279,452
4294967279,444
4294967279,454
4294967279,131
4294967278,428
4294967279,445
4294967279,258
4294967279,129
4294967279,446
4294967279,130
4294967279,131
4294967278,257
4294967278,428
4294967278,280
4294967279,132
4294967278,4
4294967278,258
4294967278,413
4294967278,261
4294967278,262
4294967278,5
4294967278,262
4294967278,6
4294967278,7
4294967278,8
4294967278,293
4294967278,8
4294967278,281
4294967278,282
4294967278,291
4294967278,263
4294967278,291
4294967278,264
4294967278,265
4294967278,266
4294967278,9
4294967278,266
4294967278,10
4294967278,11
4294967278,12
4294967278,283

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

85
temp.pdf Normal file
View File

@@ -0,0 +1,85 @@
%PDF-1.3
%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com
1 0 obj
<<
/F1 2 0 R /F2 3 0 R
>>
endobj
2 0 obj
<<
/BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font
>>
endobj
3 0 obj
<<
/BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding /Name /F2 /Subtype /Type1 /Type /Font
>>
endobj
4 0 obj
<<
/BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] /Height 100 /Length 1025 /Subtype /Image
/Type /XObject /Width 100
>>
stream
Gb"/`bAuB'$j6,$5OI6(.;K2G.':\dJiCr;Gk?H4FFs=pRRncIR22B/nOV>_3d5K!P>rOCFsNsE?*A6lRm61B<kN?Rn\2Vq3jXgQf"[&Nd[=PdpWMh=qmaCQV-Tt*Bm:R!6A'Gm<E;>?eLldiR<HsubGqXm&1]o-g,e;tMeEpkVgZaGpZ6[\foD\+n_O31lumgGgm/\iI5b1[*M*:De#_p5GFl,"o?17h3rb\djm,)]]9\0<dMQQ'Ad,m?]+rrRYMlmLNORKD3NZmrEQtd5,*U_ZVQ&qCEa7Wc[XMAEeZ2j/'X;2G"mmfCNsemW.BqVm^?a!S-*A"?FEj?:KtpW$-I_c9W5ZsF\mJKaFElGAn+6;;g`hGd3Q&-PX"S)(>p=8390Pd,X+-(pVEKf@;]@1Q69[h#X8`I+@i0&K9&0duFEC^SRkd37Q'I=f\X/RU4.-G%H=,D5rLI4DCNGf,eLrGU5M>9TT743:4$/FRk=K02g5#-.-!3TMf,:GQ]+:\)\hB"5L>sZ-4<<.(=@"%+n%5"+e'-:7h1la;@J[-4,3oIq6398OUa%dYqILBV?\D[>Z%q%N8d/_WmP))P:fb4q=UDLrE)WKCfg;%Wc1/QYr`W@S!+dJ=a@\Z0B[aiGI6+jCe!_j-eLW4W1LcW0%5Y9;V,H3M,M1W%78m67hO0XJO%NPUPOD7r3oi>[[Ai32/nN#6r%_;O(G0*/K!8b%j69l4[V3Lp_"g^+Cc20/RAAY;-JG$B+o>iipWJH_>PBuPVfuA:\-=Gh3uALJ/h8!TXE\Q5,0_Z*:ASo]mC:>H<]pE#lK7:G;^r_!g?Hbgl*Df)PSKh"@\qmh.df'GK\[l>CV2)#m*#,lMmBXtn&`_<NA=l8FbZmFr>;M/=`L!g'j2=LlV`$Nl:g1(PSKgriq&G:Sgnjr!nSeCYB;$*CMI(?<EWU5XJlXhko:N+^5W@rg%Ve`a\#@o!bI&qlsa[bme1BsWiX>m@[0^B_R^iHiL8u5II4Ys-W=&nhNLqEc<iO0)*n~>endstream
endobj
5 0 obj
<<
/Contents 9 0 R /MediaBox [ 0 0 595.2756 841.8898 ] /Parent 8 0 R /Resources <<
/Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /XObject <<
/FormXob.09be740384c9e55854408d2289092f07 4 0 R
>>
>> /Rotate 0 /Trans <<
>>
/Type /Page
>>
endobj
6 0 obj
<<
/PageMode /UseNone /Pages 8 0 R /Type /Catalog
>>
endobj
7 0 obj
<<
/Author (anonymous) /CreationDate (D:20240625114453+00'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20240625114453+00'00') /Producer (ReportLab PDF Library - www.reportlab.com)
/Subject (unspecified) /Title (untitled) /Trapped /False
>>
endobj
8 0 obj
<<
/Count 1 /Kids [ 5 0 R ] /Type /Pages
>>
endobj
9 0 obj
<<
/Filter [ /ASCII85Decode /FlateDecode ] /Length 440
>>
stream
GasbV?Vc;.'ZJu*'^&=f`nITnHW7Ic%k^?'#PZ;AE@A1$`Plb6_-uV6(/n,(\bC<n]se]o0&#bs"l'BBk7j.HjIk;k&9jKJn'!dT+F"Oo/.+^3$2*=<M'4?RY[Bl9&L36A6G,QgrQlAul"KDdM_T6[EJLrdgEK9`gre=b\c"AU(jb%J5S1Nh`3*c]+/=tkbYOU3C9YEYh.&GY$gc=HNKad>:J;l-ZSf+qVMDJTh\KIrd#hMQnS0F5Yu]t?kp02;UtT:]ldp-?mBeL.f=H"TB]&YO)c`i<Cq#+E"q1GS4o$VA0?Op81i9Ak$DLH9eR`fJaL5E2o35[HUbd#&3V:A.]mH!*mr804$$;PI<dE`9Y,`q`nO^$K&LWd0B8I%K38g=F>K5ZU,V1;TVV6A6/e&9dq8Oe[9:=gQQ)1KrhhS<#A0"b@^&UIF[j_~>endstream
endobj
xref
0 10
0000000000 65535 f
0000000073 00000 n
0000000114 00000 n
0000000221 00000 n
0000000333 00000 n
0000001549 00000 n
0000001815 00000 n
0000001883 00000 n
0000002179 00000 n
0000002238 00000 n
trailer
<<
/ID
[<e1d4c65132325a1d566ff363713a4818><e1d4c65132325a1d566ff363713a4818>]
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
/Info 7 0 R
/Root 6 0 R
/Size 10
>>
startxref
2768
%%EOF