update med sert generator

This commit is contained in:
2024-08-20 12:49:38 +02:00
parent aa6af23b68
commit 480a46524d
2 changed files with 48 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:patient_manager/components/builders/BuildFileView.dart'; import 'package:patient_manager/components/builders/BuildFileView.dart';
import 'package:patient_manager/components/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart'; import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart'; import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart'; import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
@@ -10,6 +11,8 @@ import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart'; import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart'; import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart'; import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/business.dart';
import 'package:patient_manager/objects/businessUser.dart';
import 'package:patient_manager/objects/files.dart'; import 'package:patient_manager/objects/files.dart';
import 'package:patient_manager/objects/patients.dart'; import 'package:patient_manager/objects/patients.dart';
import 'package:supertokens_flutter/http.dart' as http; import 'package:supertokens_flutter/http.dart' as http;
@@ -19,11 +22,16 @@ class BuildFilesList extends StatefulWidget {
final AppUser signedInUser; final AppUser signedInUser;
final List<PFile> files; final List<PFile> files;
final Patient selectedPatient; final Patient selectedPatient;
final Business? business;
final BusinessUser? businessUser;
const BuildFilesList({ const BuildFilesList({
super.key, super.key,
required this.files, required this.files,
required this.signedInUser, required this.signedInUser,
required this.selectedPatient, required this.selectedPatient,
required this.business,
required this.businessUser,
}); });
@override @override
@@ -86,6 +94,12 @@ class _BuildFilesListState extends State<BuildFilesList> {
} }
Future<void> deleteFileApiCall(String filePath, int fileID) async { Future<void> deleteFileApiCall(String filePath, int fileID) async {
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle();
},
);
// delete file from minio // delete file from minio
var response = await http.delete( var response = await http.delete(
Uri.parse("$baseAPI/minio/delete/file/"), Uri.parse("$baseAPI/minio/delete/file/"),
@@ -109,9 +123,26 @@ class _BuildFilesListState extends State<BuildFilesList> {
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pushNamed('/patient-manager/patient', Navigator.of(context).pop();
arguments: PatientViewArguments(widget.signedInUser, print(widget.business);
widget.selectedPatient, null, null, "business")); if (widget.business == null) {
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
widget.selectedPatient,
widget.businessUser,
widget.business,
"personal"));
} else {
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
widget.selectedPatient,
widget.businessUser,
widget.business,
"business"));
}
// Navigator.of(context) // Navigator.of(context)
// .pushNamed('/patient-profile', arguments: widget.signedInUser); // .pushNamed('/patient-profile', arguments: widget.signedInUser);
// setState(() {}); // setState(() {});
@@ -153,8 +184,8 @@ class _BuildFilesListState extends State<BuildFilesList> {
barrierDismissible: false, barrierDismissible: false,
builder: (context) => MIHDeleteMessage( builder: (context) => MIHDeleteMessage(
deleteType: "File", deleteType: "File",
onTap: () { onTap: () async {
deleteFileApiCall(filePath, fileID); await deleteFileApiCall(filePath, fileID);
}, },
), ),
); );
@@ -203,6 +234,7 @@ class _BuildFilesListState extends State<BuildFilesList> {
path: filePath, path: filePath,
//pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath', //pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
)), )),
const SizedBox(height: 30.0),
SizedBox( SizedBox(
width: 300, width: 300,
height: 50, height: 50,

View File

@@ -91,6 +91,10 @@ class _PatientFilesState extends State<PatientFiles> {
"docfname": "docfname":
"DR. ${widget.signedInUser.fname} ${widget.signedInUser.lname}", "DR. ${widget.signedInUser.fname} ${widget.signedInUser.lname}",
"startDate": startDateController.text, "startDate": startDateController.text,
"busName": widget.business!.Name,
"busAddr": "*TO BE ADDED IN THE FUTURE*",
"busNo": widget.business!.contact_no,
"busEmail": widget.business!.bus_email,
"endDate": endDateTextController.text, "endDate": endDateTextController.text,
"returnDate": retDateTextController.text, "returnDate": retDateTextController.text,
"logo_path": widget.business!.logo_path, "logo_path": widget.business!.logo_path,
@@ -115,7 +119,7 @@ class _PatientFilesState extends State<PatientFiles> {
"app_id": widget.selectedPatient.app_id "app_id": widget.selectedPatient.app_id
}), }),
); );
print(response2.statusCode); //print(response2.statusCode);
if (response2.statusCode == 201) { if (response2.statusCode == 201) {
setState(() { setState(() {
startDateController.clear(); startDateController.clear();
@@ -125,6 +129,7 @@ class _PatientFilesState extends State<PatientFiles> {
}); });
// end loading circle // end loading circle
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pop();
String message = 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."; "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); successPopUp(message);
@@ -288,10 +293,10 @@ class _PatientFilesState extends State<PatientFiles> {
.secondaryColor(), .secondaryColor(),
textColor: textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(), MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () { onTap: () async {
if (isMedCertFieldsFilled()) { if (isMedCertFieldsFilled()) {
generateMedCert(); await generateMedCert();
Navigator.pop(context); //Navigator.pop(context);
} else { } else {
showDialog( showDialog(
context: context, context: context,
@@ -653,6 +658,8 @@ class _PatientFilesState extends State<PatientFiles> {
files: filesList, files: filesList,
signedInUser: widget.signedInUser, signedInUser: widget.signedInUser,
selectedPatient: widget.selectedPatient, selectedPatient: widget.selectedPatient,
business: widget.business,
businessUser: widget.businessUser,
), ),
]), ]),
), ),