forked from yaso_meth/mih-project
update med sert generator
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.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/mihErrorMessage.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/objects/appUser.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/patients.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
@@ -19,11 +22,16 @@ class BuildFilesList extends StatefulWidget {
|
||||
final AppUser signedInUser;
|
||||
final List<PFile> files;
|
||||
final Patient selectedPatient;
|
||||
final Business? business;
|
||||
final BusinessUser? businessUser;
|
||||
|
||||
const BuildFilesList({
|
||||
super.key,
|
||||
required this.files,
|
||||
required this.signedInUser,
|
||||
required this.selectedPatient,
|
||||
required this.business,
|
||||
required this.businessUser,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -86,6 +94,12 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
||||
}
|
||||
|
||||
Future<void> deleteFileApiCall(String filePath, int fileID) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
// delete file from minio
|
||||
var response = await http.delete(
|
||||
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).pushNamed('/patient-manager/patient',
|
||||
arguments: PatientViewArguments(widget.signedInUser,
|
||||
widget.selectedPatient, null, null, "business"));
|
||||
Navigator.of(context).pop();
|
||||
print(widget.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)
|
||||
// .pushNamed('/patient-profile', arguments: widget.signedInUser);
|
||||
// setState(() {});
|
||||
@@ -153,8 +184,8 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MIHDeleteMessage(
|
||||
deleteType: "File",
|
||||
onTap: () {
|
||||
deleteFileApiCall(filePath, fileID);
|
||||
onTap: () async {
|
||||
await deleteFileApiCall(filePath, fileID);
|
||||
},
|
||||
),
|
||||
);
|
||||
@@ -203,6 +234,7 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
||||
path: filePath,
|
||||
//pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
|
||||
)),
|
||||
const SizedBox(height: 30.0),
|
||||
SizedBox(
|
||||
width: 300,
|
||||
height: 50,
|
||||
|
||||
@@ -91,6 +91,10 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
"docfname":
|
||||
"DR. ${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
||||
"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,
|
||||
"returnDate": retDateTextController.text,
|
||||
"logo_path": widget.business!.logo_path,
|
||||
@@ -115,7 +119,7 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
"app_id": widget.selectedPatient.app_id
|
||||
}),
|
||||
);
|
||||
print(response2.statusCode);
|
||||
//print(response2.statusCode);
|
||||
if (response2.statusCode == 201) {
|
||||
setState(() {
|
||||
startDateController.clear();
|
||||
@@ -125,6 +129,7 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
});
|
||||
// end loading circle
|
||||
Navigator.of(context).pop();
|
||||
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);
|
||||
@@ -288,10 +293,10 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
.secondaryColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
if (isMedCertFieldsFilled()) {
|
||||
generateMedCert();
|
||||
Navigator.pop(context);
|
||||
await generateMedCert();
|
||||
//Navigator.pop(context);
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -653,6 +658,8 @@ class _PatientFilesState extends State<PatientFiles> {
|
||||
files: filesList,
|
||||
signedInUser: widget.signedInUser,
|
||||
selectedPatient: widget.selectedPatient,
|
||||
business: widget.business,
|
||||
businessUser: widget.businessUser,
|
||||
),
|
||||
]),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user