diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin index fb5b0e24..1ab39bc9 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin and b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/buckets/.tracker.bin differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/tmp/.trash/226941b2-df46-401d-88d2-7c472e978183 b/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/tmp/.trash/226941b2-df46-401d-88d2-7c472e978183 deleted file mode 100644 index 67222404..00000000 Binary files a/File_Storage/Mzanzi_Innovation_Hub/.minio.sys/tmp/.trash/226941b2-df46-401d-88d2-7c472e978183 and /dev/null differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yasien Meth-2024-06-25.pdf/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yasien Meth-2024-06-25.pdf/xl.meta new file mode 100644 index 00000000..795ac38c Binary files /dev/null and b/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yasien Meth-2024-06-25.pdf/xl.meta differ diff --git a/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yaso Meth-24-06-2024.pdf/xl.meta b/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yaso Meth-24-06-2024.pdf/xl.meta index 2f708c0b..877d2efb 100644 Binary files a/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yaso Meth-24-06-2024.pdf/xl.meta and b/File_Storage/Mzanzi_Innovation_Hub/mih/Med-Cert-Yaso Meth-24-06-2024.pdf/xl.meta differ diff --git a/Frontend/patient_manager/lib/components/medCertInput.dart b/Frontend/patient_manager/lib/components/medCertInput.dart new file mode 100644 index 00000000..0d98a7da --- /dev/null +++ b/Frontend/patient_manager/lib/components/medCertInput.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; +import 'package:patient_manager/components/myDateInput.dart'; + +class Medcertinput extends StatefulWidget { + final startDateController; + final endDateTextController; + final retDateTextController; + const Medcertinput({ + super.key, + required this.startDateController, + required this.endDateTextController, + required this.retDateTextController, + }); + + @override + State createState() => _MedcertinputState(); +} + +class _MedcertinputState extends State { + @override + Widget build(BuildContext context) { + return SizedBox( + height: 250, + child: Column( + children: [ + const SizedBox(height: 50.0), + SizedBox( + width: 700, + child: MyDateField( + controller: widget.startDateController, + LableText: "From", + ), + ), + const SizedBox(height: 25.0), + SizedBox( + width: 700, + child: MyDateField( + controller: widget.endDateTextController, + LableText: "Up to Including", + ), + ), + const SizedBox(height: 25.0), + SizedBox( + width: 700, + child: MyDateField( + controller: widget.retDateTextController, + LableText: "Return", + ), + ), + ], + ), + ); + } +} diff --git a/Frontend/patient_manager/lib/components/patientFiles.dart b/Frontend/patient_manager/lib/components/patientFiles.dart index 43ec16ed..fa0e9765 100644 --- a/Frontend/patient_manager/lib/components/patientFiles.dart +++ b/Frontend/patient_manager/lib/components/patientFiles.dart @@ -3,62 +3,122 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:patient_manager/components/buildFilesList.dart'; +import 'package:patient_manager/components/medCertInput.dart'; import 'package:patient_manager/components/myDateInput.dart'; +import 'package:patient_manager/main.dart'; +import 'package:patient_manager/objects/AppUser.dart'; +import 'package:patient_manager/objects/Patient2.dart'; import 'package:patient_manager/objects/files.dart'; import 'package:http/http.dart' as http; -Future> 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 files = - List.from(l.map((model) => PFile.fromJson(model))); - return files; - } else { - throw Exception('failed to load patients'); - } -} +import '../objects/patients.dart'; class PatientFiles extends StatefulWidget { final int patientIndex; - const PatientFiles({super.key, required this.patientIndex}); + final Patient selectedPatient; + const PatientFiles({ + super.key, + required this.patientIndex, + required this.selectedPatient, + }); @override State createState() => _PatientFilesState(); } class _PatientFilesState extends State { - String endpoint = "http://localhost:80/files/patients/"; - String apiUrlAddNote = "http://localhost:80/notes/insert/"; + String endpointFiles = "http://localhost:80/files/patients/"; + String endpointUser = "http://localhost:80/docOffices/user/"; + String endpointGenFiles = "http://localhost:80/files/generate/"; + String endpointInsertFiles = "http://localhost:80/files/insert/"; + final startDateController = TextEditingController(); final endDateTextController = TextEditingController(); + final retDateTextController = TextEditingController(); late Future> futueFiles; + late String userEmail = ""; + late AppUser appUser; - Future addPatientNoteAPICall() async { - var response = await http.post( - Uri.parse(apiUrlAddNote), + Future generateMedCert() async { + var response1 = await http.post( + Uri.parse(endpointGenFiles), headers: { "Content-Type": "application/json; charset=UTF-8" }, body: jsonEncode({ - "note_name": startDateController.text, - "note_text": endDateTextController.text, - "patient_id": widget.patientIndex, + "fullName": + "${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}", + "docfname": "${appUser.title} ${appUser.fname} ${appUser.lname}", + "startDate": startDateController.text, + "endDate": endDateTextController.text, + "returnDate": retDateTextController.text, }), ); - 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); + print(response1.statusCode); + String fileName = + "Med-Cert-${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}-${startDateController.text}"; + if (response1.statusCode == 200) { + var response2 = await http.post( + Uri.parse(endpointInsertFiles), + headers: { + "Content-Type": "application/json; charset=UTF-8" + }, + body: jsonEncode({ + "file_path": fileName, + "file_name": fileName, + "patient_id": widget.patientIndex + }), + ); + print(response2.statusCode); + if (response2.statusCode == 201) { + setState(() { + futueFiles = + fetchFiles(endpointFiles + widget.patientIndex.toString()); + }); + String message = "Successfully added file"; + messagePopUp(message); + } else { + messagePopUp("error response 2"); + } } else { - messagePopUp("error"); + messagePopUp("error respose 1"); + } + } + + Future getUserDetails() async { + await getUserEmail(); + var response = await http.get(Uri.parse(endpointUser + userEmail)); + //print(response.body); + if (response.statusCode == 200) { + appUser = + AppUser.fromJson(jsonDecode(response.body) as Map); + } else { + throw Exception('Failed to load user'); + } + } + + Future getUserEmail() async { + final res = await client.auth.getUser(); + if (res.user!.email != null) { + //print("emai not null"); + userEmail = res.user!.email!; + //print(userEmail); + } + } + + Future> fetchFiles(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 files = + List.from(l.map((model) => PFile.fromJson(model))); + return files; + } else { + throw Exception('failed to load patients'); } } @@ -75,8 +135,9 @@ class _PatientFilesState extends State { @override void initState() { - futueFiles = fetchNotes(endpoint + widget.patientIndex.toString()); - + futueFiles = fetchFiles(endpointFiles + widget.patientIndex.toString()); + //patientDetails = getPatientDetails() as Patient; + getUserDetails(); super.initState(); } @@ -128,33 +189,18 @@ class _PatientFilesState extends State { 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", - ), - ), - ], - ), + content: Medcertinput( + startDateController: startDateController, + endDateTextController: + endDateTextController, + retDateTextController: + retDateTextController, ), actions: [ TextButton( onPressed: () { - //addPatientNoteAPICall(); + //getPatientDetails(); + generateMedCert(); Navigator.pop(context); //print(widget.patientIndex); }, diff --git a/Frontend/patient_manager/lib/components/patientNotes.dart b/Frontend/patient_manager/lib/components/patientNotes.dart index 59fd55f5..0174359b 100644 --- a/Frontend/patient_manager/lib/components/patientNotes.dart +++ b/Frontend/patient_manager/lib/components/patientNotes.dart @@ -12,7 +12,7 @@ Future> fetchNotes(String endpoint) async { if (response.statusCode == 200) { Iterable l = jsonDecode(response.body); List notes = List.from(l.map((model) => Note.fromJson(model))); - print("Here notes"); + //print("Here notes"); return notes; } else { throw Exception('failed to load patients'); diff --git a/Frontend/patient_manager/lib/objects/AppUser.dart b/Frontend/patient_manager/lib/objects/AppUser.dart index e48058b0..774fd808 100644 --- a/Frontend/patient_manager/lib/objects/AppUser.dart +++ b/Frontend/patient_manager/lib/objects/AppUser.dart @@ -1,15 +1,39 @@ class AppUser { - final int idusers; - final String email; + final int idUser; + final String UserName; final int docOffice_id; + final String fname; + final String lname; + final String title; - const AppUser( - this.idusers, - this.email, - this.docOffice_id, - ); + const AppUser({ + required this.idUser, + required this.UserName, + required this.docOffice_id, + required this.fname, + required this.lname, + required this.title, + }); - factory AppUser.fromJson(dynamic json) { - return AppUser(json['idusers'], json['email'], json['docOffice_id']); + factory AppUser.fromJson(Map json) { + return switch (json) { + { + 'idUser': int idUser, + 'UserName': String UserName, + 'docOffice_id': int docOffice_id, + 'fname': String fname, + 'lname': String lname, + 'title': String title, + } => + AppUser( + idUser: idUser, + UserName: UserName, + docOffice_id: docOffice_id, + fname: fname, + lname: lname, + title: title, + ), + _ => throw const FormatException('Failed to load album.'), + }; } } diff --git a/Frontend/patient_manager/lib/objects/Patient2.dart b/Frontend/patient_manager/lib/objects/Patient2.dart new file mode 100644 index 00000000..a80bd500 --- /dev/null +++ b/Frontend/patient_manager/lib/objects/Patient2.dart @@ -0,0 +1,47 @@ +class Patient2 { + final int idpatients; + final String id_no; + final String first_name; + final String last_name; + final String email; + final String cell_no; + final String medical_aid_name; + final String medical_aid_no; + final String medical_aid_scheme; + final String address; + final int doc_office_id; + + const Patient2( + this.idpatients, + this.id_no, + this.first_name, + this.last_name, + this.email, + this.cell_no, + this.medical_aid_name, + this.medical_aid_no, + this.medical_aid_scheme, + this.address, + this.doc_office_id, + ); + + factory Patient2.fromJson(dynamic json) { + return Patient2( + json['idpatients'], + json['id_no'], + json['first_name'], + json['last_name'], + json['email'], + json['cell_no'], + json['medical_aid_name'], + json['medical_aid_no'], + json['medical_aid_scheme'], + json['address'], + json['docOffice_id'], + ); + } + + String getIDNum() { + return id_no; + } +} diff --git a/Frontend/patient_manager/lib/pages/patientView.dart b/Frontend/patient_manager/lib/pages/patientView.dart index ce2ff30d..7f1117dc 100644 --- a/Frontend/patient_manager/lib/pages/patientView.dart +++ b/Frontend/patient_manager/lib/pages/patientView.dart @@ -34,6 +34,7 @@ class _PatientViewState extends State { ), PatientFiles( patientIndex: widget.selectedPatient.idpatients, + selectedPatient: widget.selectedPatient, ) ], ) diff --git a/backend/routers/__pycache__/docOffices.cpython-310.pyc b/backend/routers/__pycache__/docOffices.cpython-310.pyc index c92f5812..2b7959a2 100644 Binary files a/backend/routers/__pycache__/docOffices.cpython-310.pyc and b/backend/routers/__pycache__/docOffices.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/patients.cpython-310.pyc b/backend/routers/__pycache__/patients.cpython-310.pyc index f25c6e4d..3b7aafc7 100644 Binary files a/backend/routers/__pycache__/patients.cpython-310.pyc and b/backend/routers/__pycache__/patients.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/patients_files.cpython-310.pyc b/backend/routers/__pycache__/patients_files.cpython-310.pyc index e8a8e682..74fda05a 100644 Binary files a/backend/routers/__pycache__/patients_files.cpython-310.pyc and b/backend/routers/__pycache__/patients_files.cpython-310.pyc differ diff --git a/backend/routers/__pycache__/users.cpython-310.pyc b/backend/routers/__pycache__/users.cpython-310.pyc index 48ed4568..26f2ca55 100644 Binary files a/backend/routers/__pycache__/users.cpython-310.pyc and b/backend/routers/__pycache__/users.cpython-310.pyc differ diff --git a/database/#ib_16384_0.dblwr b/database/#ib_16384_0.dblwr index 6e1eae9c..3ccce746 100644 Binary files a/database/#ib_16384_0.dblwr and b/database/#ib_16384_0.dblwr differ diff --git a/database/#innodb_redo/#ib_redo18 b/database/#innodb_redo/#ib_redo18 index 70457a6c..3c14db27 100644 Binary files a/database/#innodb_redo/#ib_redo18 and b/database/#innodb_redo/#ib_redo18 differ diff --git a/database/binlog.000035 b/database/binlog.000035 index ae772bdf..c62a7d84 100644 Binary files a/database/binlog.000035 and b/database/binlog.000035 differ diff --git a/database/ibdata1 b/database/ibdata1 index 40317fe1..2d30e40c 100644 Binary files a/database/ibdata1 and b/database/ibdata1 differ diff --git a/database/mysql.ibd b/database/mysql.ibd index 257b5f7c..e2cf4cd5 100644 Binary files a/database/mysql.ibd and b/database/mysql.ibd differ diff --git a/database/patient_manager/patient_files.ibd b/database/patient_manager/patient_files.ibd index 4b308f27..7729497d 100644 Binary files a/database/patient_manager/patient_files.ibd and b/database/patient_manager/patient_files.ibd differ diff --git a/database/undo_001 b/database/undo_001 index 8fff12a8..d332e2c5 100644 Binary files a/database/undo_001 and b/database/undo_001 differ diff --git a/database/undo_002 b/database/undo_002 index 5effa03d..f0731ad0 100644 Binary files a/database/undo_002 and b/database/undo_002 differ diff --git a/temp.pdf b/temp.pdf index 5c1f6cb6..6d68807f 100644 --- a/temp.pdf +++ b/temp.pdf @@ -17,17 +17,17 @@ endobj endobj 4 0 obj << -/BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] /Height 100 /Length 1025 /Subtype /Image +/BitsPerComponent 8 /ColorSpace /DeviceRGB /Filter [ /ASCII85Decode /FlateDecode ] /Height 100 /Length 1071 /Subtype /Image /Type /XObject /Width 100 >> stream -Gb"/`bAuB'$j6,$5OI6(.;K2G.':\dJiCr;Gk?H4FFs=pRRncIR22B/nOV>_3d5K!P>rOCFsNsE?*A6lRm61B?eLldiRp=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!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8 0 R /Resources << /Font 1 0 R /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /XObject << -/FormXob.09be740384c9e55854408d2289092f07 4 0 R +/FormXob.dedcbf51b54970828e09ce961fd66ee7 4 0 R >> >> /Rotate 0 /Trans << @@ -42,7 +42,7 @@ endobj 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) +/Author (anonymous) /CreationDate (D:20240625151653+00'00') /Creator (ReportLab PDF Library - www.reportlab.com) /Keywords () /ModDate (D:20240625151653+00'00') /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (unspecified) /Title (untitled) /Trapped /False >> endobj @@ -53,10 +53,10 @@ endobj endobj 9 0 obj << -/Filter [ /ASCII85Decode /FlateDecode ] /Length 440 +/Filter [ /ASCII85Decode /FlateDecode ] /Length 445 >> stream -GasbV?Vc;.'ZJu*'^&=f`nITnHW7Ic%k^?'#PZ;AE@A1$`Plb6_-uV6(/n,(\bC:J;l-ZSf+qVMDJTh\KIrd#hMQnS0F5Yu]t?kp02;UtT:]ldp-?mBeL.f=H"TB]&YO)c`iK5ZU,V1;TVV6A6/e&9dq8Oe[9:=gQQ)1KrhhS<#A0"b@^&UIF[j_~>endstream +Gas2F:K)m"&B4*cMK`$48s>LS8%%a6)69OW6'!i*MaF-Lm.B$?[+2O,3b0A;g#%.g$O(5tg>>=*gi*\"'U4/]TUtJ#hdaNo1Z.F,iPiOS69d^P;`BTn#e\(Zo*6NX0Z(Iqn9=B&?Q'"k*K?Ut0h-=;cXP.1RZ!uWXfP3f[9Fl:U$"$("G(EMYOWV!1)cm"DI?M%_<^dRDXr>RK[6ktC=H-2/2nD1GG3&o5V$qfp#Z#;Tb1K_YQSTZ\6-jJZ;FbB3oS!oWD]g?oeEPe9'ZO]V+Z`+k-I;)T$!dPR4MW$&B#Wlt,"0"^^a]bX]il&=u#g-)a'?OeAmS'jLT,eBVL.%Tendstream endobj xref 0 10 @@ -65,15 +65,15 @@ xref 0000000114 00000 n 0000000221 00000 n 0000000333 00000 n -0000001549 00000 n -0000001815 00000 n -0000001883 00000 n -0000002179 00000 n -0000002238 00000 n +0000001595 00000 n +0000001861 00000 n +0000001929 00000 n +0000002225 00000 n +0000002284 00000 n trailer << /ID -[] +[<6b30cc1ade908a7927c384b5f230df56><6b30cc1ade908a7927c384b5f230df56>] % ReportLab generated PDF document -- digest (http://www.reportlab.com) /Info 7 0 R @@ -81,5 +81,5 @@ trailer /Size 10 >> startxref -2768 +2819 %%EOF