app files restructure

This commit is contained in:
2024-11-14 11:46:50 +02:00
parent c07f0c25c5
commit 469a4b0383
312 changed files with 592 additions and 546 deletions

View File

@@ -0,0 +1,183 @@
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_core/theme.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import "package:universal_html/html.dart" as html;
import 'package:http/http.dart' as http;
import '../../../main.dart';
import '../../../mih_objects/arguments.dart';
class BuildFileView extends StatefulWidget {
final String link;
final String path;
const BuildFileView({
super.key,
required this.link,
required this.path,
});
@override
State<BuildFileView> createState() => _BuildFileViewState();
}
class _BuildFileViewState extends State<BuildFileView> {
late PdfViewerController pdfViewerController = PdfViewerController();
//late TextEditingController currentPageController = TextEditingController();
double startZoomLevel = 1;
String getExtType(String path) {
//print(pdfLink.split(".")[1]);
return path.split(".").last;
}
String getFileName(String path) {
//print(pdfLink.split(".")[1]);
return path.split("/").last;
}
void printDocument() async {
print("Printing ${widget.path.split("/").last}");
http.Response response = await http.get(Uri.parse(widget.link));
var pdfData = response.bodyBytes;
Navigator.of(context).pushNamed(
'/file-veiwer/print-preview',
arguments: PrintPreviewArguments(
pdfData,
getFileName(
widget.path,
),
),
);
}
@override
void dispose() {
pdfViewerController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// double width = MediaQuery.sizeOf(context).width;
//double height = MediaQuery.sizeOf(context).height;
if (getExtType(widget.path).toLowerCase() == "pdf") {
//print(widget.pdfLink);
return Expanded(
child: Stack(
fit: StackFit.expand,
children: [
SfPdfViewerTheme(
data: SfPdfViewerThemeData(
backgroundColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
child: SfPdfViewer.network(
widget.link,
controller: pdfViewerController,
interactionMode: PdfInteractionMode.pan,
),
),
Positioned(
bottom: 10,
right: 10,
width: 50,
height: 50,
child: IconButton.filled(
iconSize: 35,
padding: const EdgeInsets.all(0),
onPressed: () {
printDocument();
},
icon: Icon(
Icons.print,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
),
Positioned(
bottom: 10,
left: 10,
width: 50,
height: 50,
child: IconButton.filled(
iconSize: 35,
padding: const EdgeInsets.all(0),
onPressed: () {
html.window.open(
widget.link,
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
'download');
},
icon: Icon(
Icons.download,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
),
],
),
);
} else {
return Expanded(
// height: height,
// padding: const EdgeInsets.all(10.0),
child: Stack(
fit: StackFit.expand,
children: [
InteractiveViewer(
//constrained: true,
//clipBehavior: Clip.antiAlias,
maxScale: 5.0,
//minScale: 0.,
child: Image.network(widget.link),
),
Positioned(
bottom: 10,
right: 10,
width: 50,
height: 50,
child: IconButton.filled(
iconSize: 35,
padding: const EdgeInsets.all(0),
onPressed: () {
//expandImage(width, height);
Navigator.of(context).pushNamed(
'/file-veiwer',
arguments: FileViewArguments(
widget.link,
widget.path,
),
);
},
icon: Icon(
Icons.fullscreen,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
),
Positioned(
bottom: 10,
left: 10,
width: 50,
height: 50,
child: IconButton.filled(
iconSize: 35,
padding: const EdgeInsets.all(0),
onPressed: () {
html.window.open(
widget.link,
// '${AppEnviroment.baseFileUrl}/mih/$filePath',
'download');
},
icon: Icon(
Icons.download,
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
),
],
),
);
}
}
}

View File

@@ -0,0 +1,398 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:supertokens_flutter/http.dart' as http;
import '../../../main.dart';
import '../../../mih_components/mih_layout/mih_window.dart';
import '../../../mih_components/mih_pop_up_messages/mih_delete_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
import '../../../mih_env/env.dart';
import '../../../mih_objects/app_user.dart';
import '../../../mih_objects/arguments.dart';
import '../../../mih_objects/business.dart';
import '../../../mih_objects/business_user.dart';
import '../../../mih_objects/files.dart';
import '../../../mih_objects/patients.dart';
import 'build_file_view.dart';
class BuildFilesList extends StatefulWidget {
final AppUser signedInUser;
final List<PFile> files;
final Patient selectedPatient;
final Business? business;
final BusinessUser? businessUser;
final String type;
const BuildFilesList({
super.key,
required this.files,
required this.signedInUser,
required this.selectedPatient,
required this.business,
required this.businessUser,
required this.type,
});
@override
State<BuildFilesList> createState() => _BuildFilesListState();
}
class _BuildFilesListState extends State<BuildFilesList> {
int indexOn = 0;
final baseAPI = AppEnviroment.baseApiUrl;
final basefile = AppEnviroment.baseFileUrl;
String fileUrl = "";
Future<String> getFileUrlApiCall(String filePath) async {
var url = "$baseAPI/minio/pull/file/${AppEnviroment.getEnv()}/$filePath";
//print(url);
var response = await http.get(Uri.parse(url));
// print("here1");
//print(response.statusCode);
if (response.statusCode == 200) {
//print("here2");
String body = response.body;
//print(body);
//print("here3");
var decodedData = jsonDecode(body);
//print("Dedoced: ${decodedData['minioURL']}");
return decodedData['minioURL'];
//AppUser u = AppUser.fromJson(decodedData);
// print(u.email);
//return "AlometThere";
} else {
throw Exception("Error: GetUserData status code ${response.statusCode}");
}
//print(url);
// var response = await http.get(Uri.parse(url));
// // print("here1");
// //print(response.statusCode);
// if (response.statusCode == 200) {
// //print("here2");
// String body = response.body;
// //print(body);
// //print("here3");
// var decodedData = jsonDecode(body);
// //print("Dedoced: ${decodedData['minioURL']}");
// return decodedData['minioURL'];
// //AppUser u = AppUser.fromJson(decodedData);
// // print(u.email);
// //return "AlometThere";
// } else {
// throw Exception("Error: GetUserData status code ${response.statusCode}");
// }
}
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/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{"file_path": filePath}),
);
//print("Here4");
//print(response.statusCode);
if (response.statusCode == 200) {
//SQL delete
var response2 = await http.delete(
Uri.parse("$baseAPI/files/delete/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{"idpatient_files": fileID}),
);
if (response2.statusCode == 200) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
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(() {});
String message =
"The File has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments.";
successPopUp(message);
} else {
internetConnectionPopUp();
}
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void deleteFilePopUp(String filePath, int fileID) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHDeleteMessage(
deleteType: "File",
onTap: () async {
await deleteFileApiCall(filePath, fileID);
},
),
);
}
void viewFilePopUp(String fileName, String filePath, int fileID, String url) {
bool hasAccessToDelete = false;
if (widget.type == "business") {
hasAccessToDelete = true;
}
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: true,
windowTitle: fileName,
windowBody: [
BuildFileView(
link: url,
path: filePath,
//pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
),
const SizedBox(
height: 10,
)
],
windowTools: [
Visibility(
visible: hasAccessToDelete,
child: IconButton(
onPressed: () {
deleteFilePopUp(filePath, fileID);
},
icon: Icon(
size: 35,
Icons.delete,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
),
],
onWindowTapClose: () {
Navigator.pop(context);
},
),
);
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (context) => Dialog(
// child: Stack(
// children: [
// Container(
// padding: const EdgeInsets.all(10.0),
// width: 800.0,
// //height: 475.0,
// decoration: BoxDecoration(
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
// borderRadius: BorderRadius.circular(25.0),
// border: Border.all(
// color:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// width: 5.0),
// ),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: [
// const SizedBox(
// height: 25,
// ),
// Text(
// fileName,
// textAlign: TextAlign.center,
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// fontSize: 35.0,
// fontWeight: FontWeight.bold,
// ),
// ),
// const SizedBox(height: 25.0),
// Expanded(
// child: BuildFileView(
// link: url,
// path: filePath,
// //pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
// )),
// const SizedBox(height: 30.0),
// SizedBox(
// width: 300,
// height: 50,
// child: MIHButton(
// onTap: () {
// html.window.open(
// url,
// // '${AppEnviroment.baseFileUrl}/mih/$filePath',
// 'download');
// },
// buttonText: "Dowload",
// buttonColor: MzanziInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// textColor:
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
// ),
// )
// ],
// ),
// ),
// Positioned(
// top: 5,
// right: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// Navigator.pop(context);
// },
// icon: Icon(
// Icons.close,
// color: MzanziInnovationHub.of(context)!.theme.errorColor(),
// size: 35,
// ),
// ),
// ),
// Positioned(
// top: 5,
// left: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// deleteFilePopUp(filePath, fileID);
// },
// icon: Icon(
// Icons.delete,
// color:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// ),
// ),
// ),
// ],
// ),
// ),
// );
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.files.isNotEmpty) {
return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.files.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(
widget.files[index].file_name,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
widget.files[index].insert_date,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
// trailing: Icon(
// Icons.arrow_forward,
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// ),
onTap: () async {
await getFileUrlApiCall(widget.files[index].file_path)
.then((urlHere) {
//print(url);
setState(() {
fileUrl = urlHere;
});
});
viewFilePopUp(
widget.files[index].file_name,
widget.files[index].file_path,
widget.files[index].idpatient_files,
fileUrl);
},
);
},
);
} else {
return const Center(
child: Text(
"No Documents Available",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
);
}
}
}

View File

@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import '../../../main.dart';
import '../../../mih_objects/medicine.dart';
class BuildMedicinesList extends StatefulWidget {
final TextEditingController contoller;
final List<Medicine> medicines;
//final searchString;
const BuildMedicinesList({
super.key,
required this.contoller,
required this.medicines,
//required this.searchString,
});
@override
State<BuildMedicinesList> createState() => _BuildMedicinesListState();
}
class _BuildMedicinesListState extends State<BuildMedicinesList> {
int indexOn = 0;
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.medicines.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
return ListTile(
title: Text(
widget.medicines[index].name,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
"${widget.medicines[index].unit} - ${widget.medicines[index].form}",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
setState(() {
widget.contoller.text =
"${widget.medicines[index].name}%t${widget.medicines[index].unit}%t${widget.medicines[index].form}";
Navigator.of(context).pop();
});
},
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
},
);
}
}

View File

@@ -0,0 +1,397 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:supertokens_flutter/http.dart' as http;
import '../../../main.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_multiline_text_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import '../../../mih_components/mih_layout/mih_window.dart';
import '../../../mih_components/mih_pop_up_messages/mih_delete_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
import '../../../mih_env/env.dart';
import '../../../mih_objects/app_user.dart';
import '../../../mih_objects/arguments.dart';
import '../../../mih_objects/business.dart';
import '../../../mih_objects/business_user.dart';
import '../../../mih_objects/notes.dart';
import '../../../mih_objects/patients.dart';
class BuildNotesList extends StatefulWidget {
final AppUser signedInUser;
final List<Note> notes;
final Patient selectedPatient;
final Business? business;
final BusinessUser? businessUser;
final String type;
const BuildNotesList({
super.key,
required this.notes,
required this.signedInUser,
required this.selectedPatient,
required this.business,
required this.businessUser,
required this.type,
});
@override
State<BuildNotesList> createState() => _BuildNotesListState();
}
class _BuildNotesListState extends State<BuildNotesList> {
final noteTitleController = TextEditingController();
final noteTextController = TextEditingController();
final businessNameController = TextEditingController();
final userNameController = TextEditingController();
final dateController = TextEditingController();
int indexOn = 0;
final baseAPI = AppEnviroment.baseApiUrl;
Future<void> deleteNoteApiCall(int NoteId) async {
var response = await http.delete(
Uri.parse("$baseAPI/notes/delete/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{"idpatient_notes": NoteId}),
);
//print("Here4");
//print(response.statusCode);
if (response.statusCode == 200) {
Navigator.of(context).pop();
Navigator.of(context).pop();
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"));
}
setState(() {});
String message =
"The note has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments.";
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void deletePatientPopUp(int NoteId) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHDeleteMessage(
deleteType: "Note",
onTap: () {
deleteNoteApiCall(NoteId);
},
),
);
}
void viewNotePopUp(Note selectednote) {
setState(() {
noteTitleController.text = selectednote.note_name;
noteTextController.text = selectednote.note_text;
businessNameController.text = selectednote.doc_office;
userNameController.text = selectednote.doctor;
dateController.text = selectednote.insert_date;
});
bool hasAccessToDelete = false;
if (widget.type == "business" &&
selectednote.doc_office == widget.business!.Name) {
hasAccessToDelete = true;
}
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: true,
windowTitle: selectednote.note_name,
windowTools: [
Visibility(
visible: hasAccessToDelete,
child: IconButton(
onPressed: () {
deletePatientPopUp(selectednote.idpatient_notes);
},
icon: Icon(
Icons.delete,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
),
],
onWindowTapClose: () {
Navigator.pop(context);
},
windowBody: [
MIHTextField(
controller: businessNameController,
hintText: "Office",
editable: false,
required: false,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: userNameController,
hintText: "Created By",
editable: false,
required: false,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: dateController,
hintText: "Created Date",
editable: false,
required: false,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: noteTitleController,
hintText: "Note Title",
editable: false,
required: false,
),
const SizedBox(height: 10.0),
Expanded(
child: MIHMLTextField(
controller: noteTextController,
hintText: "Note Details",
editable: false,
required: false,
),
),
],
),
);
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (context) => Dialog(
// child: Stack(
// children: [
// Container(
// padding: const EdgeInsets.all(15.0),
// width: 700.0,
// //height: 475.0,
// decoration: BoxDecoration(
// color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
// borderRadius: BorderRadius.circular(25.0),
// border: Border.all(
// color:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// width: 5.0),
// ),
// child: Column(
// mainAxisSize: MainAxisSize.max,
// children: [
// const SizedBox(
// height: 25,
// ),
// Text(
// selectednote.note_name,
// textAlign: TextAlign.center,
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!
// .theme
// .secondaryColor(),
// fontSize: 35.0,
// fontWeight: FontWeight.bold,
// ),
// ),
// const SizedBox(height: 25.0),
// SizedBox(
// width: 700,
// child: MIHTextField(
// controller: businessNameController,
// hintText: "Office",
// editable: false,
// required: false,
// ),
// ),
// const SizedBox(height: 10.0),
// SizedBox(
// width: 700,
// child: MIHTextField(
// controller: userNameController,
// hintText: "Created By",
// editable: false,
// required: false,
// ),
// ),
// const SizedBox(height: 10.0),
// SizedBox(
// width: 700,
// child: MIHTextField(
// controller: dateController,
// hintText: "Created Date",
// editable: false,
// required: false,
// ),
// ),
// const SizedBox(height: 10.0),
// SizedBox(
// width: 700,
// child: MIHTextField(
// controller: noteTitleController,
// hintText: "Note Title",
// editable: false,
// required: false,
// ),
// ),
// const SizedBox(height: 10.0),
// Expanded(
// child: MIHMLTextField(
// controller: noteTextController,
// hintText: "Note Details",
// editable: false,
// required: false,
// ),
// ),
// //const SizedBox(height: 25.0),
// // SizedBox(
// // width: 300,
// // height: 100,
// // child: MIHButton(
// // onTap: () {
// // Navigator.pop(context);
// // },
// // buttonText: "Close",
// // buttonColor: Colors.blueAccent,
// // textColor: Colors.white,
// // ),
// // )
// ],
// ),
// ),
// Positioned(
// top: 5,
// right: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// Navigator.pop(context);
// },
// icon: Icon(
// Icons.close,
// color: MzanziInnovationHub.of(context)!.theme.errorColor(),
// size: 35,
// ),
// ),
// ),
// Positioned(
// top: 5,
// left: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// deletePatientPopUp(selectednote.idpatient_notes);
// },
// icon: Icon(
// Icons.delete,
// color:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// ),
// ),
// ),
// ],
// ),
// ),
// );
}
@override
void dispose() {
noteTextController.dispose();
businessNameController.dispose();
userNameController.dispose();
dateController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.notes.isNotEmpty) {
return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, int index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.notes.length,
itemBuilder: (context, index) {
String notePreview = widget.notes[index].note_text;
if (notePreview.length > 30) {
notePreview = "${notePreview.substring(0, 30)} ...";
}
return ListTile(
title: Text(
"${widget.notes[index].note_name}\n${widget.notes[index].doc_office} - ${widget.notes[index].doctor}",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
"${widget.notes[index].insert_date}:\n$notePreview",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
), //Text(widget.notes[index].note_text),
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onTap: () {
viewNotePopUp(widget.notes[index]);
},
);
},
);
} else {
return const Center(
child: Text(
"No Notes Available",
style: TextStyle(fontSize: 25, color: Colors.grey),
textAlign: TextAlign.center,
),
);
}
}
}

View File

@@ -0,0 +1,452 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:supertokens_flutter/http.dart' as http;
import '../../../main.dart';
import '../../../mih_apis/mih_api_calls.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_button.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_date_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_time_input.dart';
import '../../../mih_components/mih_layout/mih_window.dart';
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_warning_message.dart';
import '../../../mih_env/env.dart';
import '../../../mih_objects/app_user.dart';
import '../../../mih_objects/arguments.dart';
import '../../../mih_objects/business.dart';
import '../../../mih_objects/patient_access.dart';
import '../../../mih_objects/patients.dart';
class BuildPatientAccessList extends StatefulWidget {
final List<PatientAccess> patientAccesses;
final AppUser signedInUser;
final Business? business;
final BusinessArguments arguments;
const BuildPatientAccessList({
super.key,
required this.patientAccesses,
required this.signedInUser,
required this.business,
required this.arguments,
});
@override
State<BuildPatientAccessList> createState() => _BuildPatientsListState();
}
class _BuildPatientsListState extends State<BuildPatientAccessList> {
TextEditingController dateController = TextEditingController();
TextEditingController timeController = TextEditingController();
TextEditingController idController = TextEditingController();
TextEditingController fnameController = TextEditingController();
TextEditingController lnameController = TextEditingController();
final baseAPI = AppEnviroment.baseApiUrl;
Future<void> addPatientAppointmentAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/queue/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.business!.business_id,
"app_id": widget.patientAccesses[index].app_id,
"date": dateController.text,
"time": timeController.text,
"access": "pending",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
String message =
"The appointment has been successfully booked!\n\nAn approval request as been sent to the patient.Once the access request has been approved, you will be able to access the patientAccesses profile. ou can check the status of your request in patient queue under the appointment.";
// "${fnameController.text} ${lnameController.text} patient profiole has been successfully added!\n";
Navigator.pop(context);
Navigator.pop(context);
setState(() {
dateController.text = "";
timeController.text = "";
});
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
successPopUp(message);
addAccessReviewNotificationAPICall(index);
} else {
internetConnectionPopUp();
}
}
Future<void> addAccessReviewNotificationAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/notifications/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"app_id": widget.patientAccesses[index].app_id,
"notification_type": "New Appointment Booked",
"notification_message":
"A new Appointment has been booked by ${widget.arguments.business!.Name} for the ${dateController.text} ${timeController.text}. Please approve the Access Review request.",
"action_path": "/access-review",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void submitApointment(int index) {
MIHApiCalls.addAppointmentAPICall(
widget.arguments.business!.business_id,
widget.patientAccesses[index].app_id,
dateController.text,
timeController.text,
widget.arguments,
context,
);
//addPatientAppointmentAPICall(index);
}
bool isAppointmentFieldsFilled() {
if (dateController.text.isEmpty || timeController.text.isEmpty) {
return false;
} else {
return true;
}
}
void appointmentPopUp(int index) {
var firstLetterFName = widget.patientAccesses[index].fname;
var firstLetterLName = widget.patientAccesses[index].lname;
setState(() {
idController.text = widget.patientAccesses[index].id_no;
fnameController.text = firstLetterFName;
lnameController.text = firstLetterLName;
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: false,
windowTitle: "Patient Appointment",
windowTools: const [],
onWindowTapClose: () {
Navigator.pop(context);
},
windowBody: [
MIHTextField(
controller: idController,
hintText: "ID No.",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHDateField(
controller: dateController,
lableText: "Date",
required: true,
),
const SizedBox(height: 10.0),
MIHTimeField(
controller: timeController,
lableText: "Time",
required: true,
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Book",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
//print("here1");
bool filled = isAppointmentFieldsFilled();
//print("fields filled: $filled");
if (filled) {
//print("here2");
submitApointment(index);
//print("here3");
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
},
),
)
],
),
);
}
void noAccessWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "No Access");
},
);
}
bool hasAccessToProfile(int index) {
var hasAccess = false;
if (widget.patientAccesses[index].status == "approved") {
hasAccess = true;
} else {
hasAccess = false;
}
return hasAccess;
}
void patientProfileChoicePopUp(int index, Patient? patientProfile) async {
var firstLetterFName = widget.patientAccesses[index].fname;
var firstLetterLName = widget.patientAccesses[index].lname;
setState(() {
idController.text = widget.patientAccesses[index].id_no;
fnameController.text = firstLetterFName;
lnameController.text = firstLetterLName;
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: false,
windowTitle: "Patient Profile",
windowTools: const [],
onWindowTapClose: () {
Navigator.pop(context);
},
windowBody: [
MIHTextField(
controller: idController,
hintText: "ID No.",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 30.0),
Wrap(runSpacing: 10, spacing: 10, children: [
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Book Appointment",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
print("Book an Appointment!!!");
appointmentPopUp(index);
// //print("here1");
// bool filled = isAppointmentFieldsFilled();
// //print("fields filled: $filled");
// if (filled) {
// //print("here2");
// submitApointment(index);
// //print("here3");
// } else {
// showDialog(
// context: context,
// builder: (context) {
// return const MIHErrorMessage(errorType: "Input Error");
// },
// );
// }
},
),
),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "View Patient Profile",
buttonColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
Navigator.of(context).pop();
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
patientProfile,
widget.arguments.businessUser,
widget.business,
"business",
));
},
),
),
])
],
),
);
}
Widget displayAccessTile(int index) {
var firstName = widget.patientAccesses[index].fname;
var lastName = widget.patientAccesses[index].lname;
String access = widget.patientAccesses[index].status.toUpperCase();
TextSpan accessWithColour;
var hasAccess = false;
hasAccess = hasAccessToProfile(index);
//print(hasAccess);
if (access == "APPROVED") {
accessWithColour = TextSpan(
text: "$access\n",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.successColor()));
} else if (access == "PENDING") {
accessWithColour = TextSpan(
text: "$access\n",
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.messageTextColor()));
} else {
accessWithColour = TextSpan(
text: "$access\n",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.errorColor()));
}
return ListTile(
title: Text(
"$firstName $lastName",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: RichText(
text: TextSpan(
text: "ID No.: ${widget.patientAccesses[index].id_no}\n",
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
const TextSpan(text: "Access: "),
accessWithColour,
]),
),
onTap: () async {
Patient? p;
if (hasAccess) {
await MIHApiCalls.fetchPatientByAppId(
widget.patientAccesses[index].app_id)
.then((result) {
setState(() {
p = result;
});
});
patientProfileChoicePopUp(index, p);
} else {
noAccessWarning();
}
},
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
}
@override
void dispose() {
dateController.dispose();
timeController.dispose();
idController.dispose();
fnameController.dispose();
lnameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.patientAccesses.length,
itemBuilder: (context, index) {
//final patient = widget.patientAccesses[index].id_no.contains(widget.searchString);
//print(index);
return displayAccessTile(index);
},
);
}
}

View File

@@ -0,0 +1,670 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:supertokens_flutter/http.dart' as http;
import '../../../main.dart';
import '../../../mih_apis/mih_api_calls.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_button.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_date_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_time_input.dart';
import '../../../mih_components/mih_layout/mih_window.dart';
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_warning_message.dart';
import '../../../mih_env/env.dart';
import '../../../mih_objects/app_user.dart';
import '../../../mih_objects/arguments.dart';
import '../../../mih_objects/business.dart';
import '../../../mih_objects/patients.dart';
class BuildPatientsList extends StatefulWidget {
final List<Patient> patients;
final AppUser signedInUser;
final Business? business;
final BusinessArguments arguments;
const BuildPatientsList({
super.key,
required this.patients,
required this.signedInUser,
required this.business,
required this.arguments,
});
@override
State<BuildPatientsList> createState() => _BuildPatientsListState();
}
class _BuildPatientsListState extends State<BuildPatientsList> {
TextEditingController dateController = TextEditingController();
TextEditingController timeController = TextEditingController();
TextEditingController idController = TextEditingController();
TextEditingController fnameController = TextEditingController();
TextEditingController lnameController = TextEditingController();
TextEditingController accessStatusController = TextEditingController();
final baseAPI = AppEnviroment.baseApiUrl;
Future<void> addPatientAppointmentAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/queue/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.business!.business_id,
"app_id": widget.patients[index].app_id,
"date": dateController.text,
"time": timeController.text,
"access": "pending",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
String message =
"The appointment has been successfully booked!\n\nAn approval request as been sent to the patient.Once the access request has been approved, you will be able to access the patients profile. ou can check the status of your request in patient queue under the appointment.";
// "${fnameController.text} ${lnameController.text} patient profiole has been successfully added!\n";
Navigator.pop(context);
Navigator.pop(context);
setState(() {
dateController.text = "";
timeController.text = "";
});
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
successPopUp(message);
addAccessReviewNotificationAPICall(index);
} else {
internetConnectionPopUp();
}
}
Future<void> addPatientAccessAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/access-requests/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.business!.business_id,
"app_id": widget.patients[index].app_id,
"date": dateController.text,
"time": timeController.text,
"access": "pending",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
String message =
"The appointment has been successfully booked!\n\nAn approval request as been sent to the patient.Once the access request has been approved, you will be able to access the patients profile. ou can check the status of your request in patient queue under the appointment.";
// "${fnameController.text} ${lnameController.text} patient profiole has been successfully added!\n";
Navigator.pop(context);
Navigator.pop(context);
setState(() {
dateController.text = "";
timeController.text = "";
});
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
successPopUp(message);
addAccessReviewNotificationAPICall(index);
} else {
internetConnectionPopUp();
}
}
Future<void> addAccessReviewNotificationAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/notifications/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"app_id": widget.patients[index].app_id,
"notification_type": "New Appointment Booked",
"notification_message":
"A new Appointment has been booked by ${widget.arguments.business!.Name} for the ${dateController.text} ${timeController.text}. Please approve the Access Review request.",
"action_path": "/access-review",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void submitApointment(int index) {
MIHApiCalls.addAppointmentAPICall(
widget.arguments.business!.business_id,
widget.patients[index].app_id,
dateController.text,
timeController.text,
widget.arguments,
context,
);
//addPatientAppointmentAPICall(index);
}
bool isAppointmentFieldsFilled() {
if (dateController.text.isEmpty || timeController.text.isEmpty) {
return false;
} else {
return true;
}
}
void appointmentPopUp(int index) {
var firstLetterFName = widget.patients[index].first_name[0];
var firstLetterLName = widget.patients[index].last_name[0];
var fnameStar = '*' * 8;
var lnameStar = '*' * 8;
setState(() {
idController.text = widget.patients[index].id_no;
fnameController.text = firstLetterFName + fnameStar;
lnameController.text = firstLetterLName + lnameStar;
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: false,
windowTitle: "Patient Appointment",
windowTools: const [],
onWindowTapClose: () {
Navigator.pop(context);
},
windowBody: [
MIHTextField(
controller: idController,
hintText: "ID No.",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHDateField(
controller: dateController,
lableText: "Date",
required: true,
),
const SizedBox(height: 10.0),
MIHTimeField(
controller: timeController,
lableText: "Time",
required: true,
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Book",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
//print("here1");
bool filled = isAppointmentFieldsFilled();
//print("fields filled: $filled");
if (filled) {
//print("here2");
submitApointment(index);
//print("here3");
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
},
),
)
],
),
);
}
void noAccessWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "No Access");
},
);
}
Future<bool> hasAccessToProfile(int index) async {
var hasAccess = false;
await MIHApiCalls.checkBusinessAccessToPatient(
widget.business!.business_id, widget.patients[index].app_id)
.then((results) {
if (results.isEmpty) {
setState(() {
hasAccess = false;
});
} else if (results[0].status == "approved") {
setState(() {
hasAccess = true;
});
} else {
setState(() {
hasAccess = false;
});
}
});
return hasAccess;
}
Future<String> getAccessStatusOfProfile(int index) async {
var accessStatus = "";
await MIHApiCalls.checkBusinessAccessToPatient(
widget.business!.business_id, widget.patients[index].app_id)
.then((results) {
if (results.isEmpty) {
setState(() {
accessStatus = "";
});
} else {
setState(() {
accessStatus = results[0].status;
});
}
});
return accessStatus;
}
void patientProfileChoicePopUp(int index) async {
var hasAccess = false;
String accessStatus = "";
await hasAccessToProfile(index).then((result) {
setState(() {
hasAccess = result;
});
});
await getAccessStatusOfProfile(index).then((result) {
setState(() {
accessStatus = result;
});
});
// print(accessStatus);
// print(hasAccess);
var firstLetterFName = widget.patients[index].first_name[0];
var firstLetterLName = widget.patients[index].last_name[0];
var fnameStar = '*' * 8;
var lnameStar = '*' * 8;
if (accessStatus == "") {
accessStatus = "No Access";
}
setState(() {
idController.text = widget.patients[index].id_no;
fnameController.text = firstLetterFName + fnameStar;
lnameController.text = firstLetterLName + lnameStar;
accessStatusController.text = accessStatus.toUpperCase();
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: false,
windowTitle: "Patient Profile",
windowTools: const [],
onWindowTapClose: () {
Navigator.pop(context);
},
windowBody: [
MIHTextField(
controller: idController,
hintText: "ID No.",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: accessStatusController,
hintText: "Access Status",
editable: false,
required: true,
),
const SizedBox(height: 20.0),
Visibility(
visible: !hasAccess,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
"Important Notice: Requesting Patient Profile Access",
style: TextStyle(
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
),
Text(
"You are about to request access to a patient's profile. Please be aware of the following important points:",
style: TextStyle(
fontWeight: FontWeight.normal,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
),
SizedBox(
width: 600,
child: Text(
"1. Permanent Access: Once the patient accepts your access request, it will become permanent.",
style: TextStyle(
fontWeight: FontWeight.normal,
color:
MzanziInnovationHub.of(context)!.theme.errorColor(),
),
),
),
SizedBox(
width: 600,
child: Text(
"2. Shared Information: Any updates you make to the patient's profile will be visible to others who have access to the profile.",
style: TextStyle(
fontWeight: FontWeight.normal,
color:
MzanziInnovationHub.of(context)!.theme.errorColor(),
),
),
),
SizedBox(
width: 600,
child: Text(
"3. Irreversible Access: Once granted, you cannot revoke your access to the patient's profile.",
style: TextStyle(
fontWeight: FontWeight.normal,
color:
MzanziInnovationHub.of(context)!.theme.errorColor(),
),
),
),
Text(
"By pressing the \"Request Access\" button you accept the above terms.",
style: TextStyle(
fontWeight: FontWeight.bold,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
),
),
],
),
),
const SizedBox(height: 20.0),
Wrap(runSpacing: 10, spacing: 10, children: [
Visibility(
visible: hasAccess,
child: SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Book Appointment",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
if (hasAccess) {
appointmentPopUp(index);
} else {
noAccessWarning();
}
},
),
),
),
Visibility(
visible: hasAccess,
child: SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "View Patient Profile",
buttonColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
if (hasAccess) {
Navigator.of(context)
.pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
widget.patients[index],
widget.arguments.businessUser,
widget.business,
"business",
));
} else {
noAccessWarning();
}
},
),
),
),
Visibility(
visible: !hasAccess && accessStatus != "pending",
child: SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Request Access",
buttonColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
print("Send access Request...");
MIHApiCalls.addPatientAccessAPICall(
widget.business!.business_id,
widget.patients[index].app_id,
"patient",
widget.business!.Name,
widget.arguments,
context,
);
},
),
),
),
Visibility(
visible: !hasAccess && accessStatus == "pending",
child: const SizedBox(
width: 500,
//height: 50,
child: Text(
"Patient has not approved access to their profile. Once access has been approved you can book and appointment or view their profile."),
),
),
])
],
),
);
}
Widget isMainMember(int index) {
//var matchRE = RegExp(r'^[a-z]+$');
var firstLetterFName = widget.patients[index].first_name[0];
var firstLetterLName = widget.patients[index].last_name[0];
var fnameStar = '*' * 8;
var lnameStar = '*' * 8;
if (widget.patients[index].medical_aid_main_member == "Yes") {
return Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"$firstLetterFName$fnameStar $firstLetterLName$lnameStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
const SizedBox(
width: 10,
),
Icon(
Icons.star_border_rounded,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
],
);
} else {
return Text(
"$firstLetterFName$fnameStar $firstLetterLName$lnameStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
}
}
Widget hasMedicalAid(int index) {
var medAidNoStar = '*' * 8;
if (widget.patients[index].medical_aid == "Yes") {
return ListTile(
title: isMainMember(index),
subtitle: Text(
"ID No.: ${widget.patients[index].id_no}\nMedical Aid No.: $medAidNoStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
patientProfileChoicePopUp(index);
// setState(() {
// appointmentPopUp(index);
// // Add popup to add patienmt to queue
// // Navigator.of(context).pushNamed('/patient-manager/patient',
// // arguments: PatientViewArguments(
// // widget.signedInUser, widget.patients[index], "business"));
// });
},
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
} else {
return ListTile(
title: isMainMember(index),
subtitle: Text(
"ID No.: ${widget.patients[index].id_no}\nMedical Aid No.: $medAidNoStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
patientProfileChoicePopUp(index);
// setState(() {
// appointmentPopUp(index);
// // Navigator.of(context).pushNamed('/patient-manager/patient',
// // arguments: PatientViewArguments(
// // widget.signedInUser, widget.patients[index], "business"));
// });
},
trailing: Icon(
Icons.add,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
}
}
@override
void dispose() {
dateController.dispose();
timeController.dispose();
idController.dispose();
fnameController.dispose();
lnameController.dispose();
accessStatusController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.patients.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
return hasMedicalAid(index);
},
);
}
}

View File

@@ -0,0 +1,843 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:supertokens_flutter/http.dart' as http;
import '../../../main.dart';
import '../../../mih_apis/mih_api_calls.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_button.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_date_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import '../../../mih_components/mih_inputs_and_buttons/mih_time_input.dart';
import '../../../mih_components/mih_layout/mih_window.dart';
import '../../../mih_components/mih_pop_up_messages/mih_delete_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_error_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_success_message.dart';
import '../../../mih_components/mih_pop_up_messages/mih_warning_message.dart';
import '../../../mih_env/env.dart';
import '../../../mih_objects/app_user.dart';
import '../../../mih_objects/arguments.dart';
import '../../../mih_objects/business.dart';
import '../../../mih_objects/business_user.dart';
import '../../../mih_objects/patient_queue.dart';
import '../../../mih_objects/patients.dart';
class BuildPatientQueueList extends StatefulWidget {
final List<PatientQueue> patientQueue;
final AppUser signedInUser;
final Business? business;
final BusinessUser? businessUser;
const BuildPatientQueueList({
super.key,
required this.patientQueue,
required this.signedInUser,
required this.business,
required this.businessUser,
});
@override
State<BuildPatientQueueList> createState() => _BuildPatientsListState();
}
class _BuildPatientsListState extends State<BuildPatientQueueList> {
String baseAPI = AppEnviroment.baseApiUrl;
TextEditingController dateController = TextEditingController();
TextEditingController timeController = TextEditingController();
TextEditingController idController = TextEditingController();
TextEditingController fnameController = TextEditingController();
TextEditingController lnameController = TextEditingController();
TextEditingController daysExtensionController = TextEditingController();
int counter = 0;
Future<void> updateAccessAPICall(int index, String accessType) async {
var response = await http.put(
Uri.parse("$baseAPI/access-requests/update/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.business!.business_id,
"app_id": widget.patientQueue[index].app_id,
"date_time": widget.patientQueue[index].date_time,
"access": accessType,
}),
);
if (response.statusCode == 200) {
//Navigator.of(context).pushNamed('/home');
addCancelledAppointmentNotificationAPICall(index);
// Navigator.of(context).pop();
// Navigator.of(context).pop();
// Navigator.of(context).pushNamed(
// '/patient-manager',
// arguments: BusinessArguments(
// widget.signedInUser,
// widget.businessUser,
// widget.business,
// ),
// );
// String message =
// "The appointment for ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name} at ${widget.patientQueue[index].date_time} has been successfully canceled.";
// successPopUp(message);
} else {
internetConnectionPopUp();
}
}
// Future<void> extendAccessAPICall(int index, String revokeDate) async {
// var response = await http.put(
// Uri.parse("$baseAPI/access-requests/extension/"),
// headers: <String, String>{
// "Content-Type": "application/json; charset=UTF-8"
// },
// body: jsonEncode(<String, dynamic>{
// "business_id": widget.business!.business_id,
// "app_id": widget.patientQueue[index].app_id,
// "date_time": widget.patientQueue[index].date_time,
// "revoke_date": revokeDate,
// }),
// );
// if (response.statusCode == 200) {
// addAccessExtensionNotificationAPICall(index, revokeDate);
// //addCancelledAppointmentNotificationAPICall(index);
// } else {
// internetConnectionPopUp();
// }
// }
Future<void> updateApointmentAPICall(int index) async {
var response = await http.put(
Uri.parse("$baseAPI/queue/appoointment/update/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"idpatient_queue": widget.patientQueue[index].idpatient_queue,
"date": dateController.text,
"time": timeController.text,
}),
);
if (response.statusCode == 200) {
//Navigator.of(context).pushNamed('/home');
addRescheduledAppointmentNotificationAPICall(index);
// Navigator.of(context).pop();
// Navigator.of(context).pop();
// Navigator.of(context).pop();
// Navigator.of(context).pushNamed(
// '/patient-manager',
// arguments: BusinessArguments(
// widget.signedInUser,
// widget.businessUser,
// widget.business,
// ),
// );
// String message =
// "The appointment has been rescheduled for ${dateController.text} ${timeController.text}.\n\nJust a heads up: We've reset your access to the patient's profile and it will have to be approved again.";
// successPopUp(message);
} else {
internetConnectionPopUp();
}
}
Future<Patient> fetchPatients(String app_id) async {
//print("pat man drawer: " + endpointUserData + widget.userEmail);
var response = await http.get(Uri.parse("$baseAPI/patients/$app_id"));
// print(response.statusCode);
// print(response.body);
if (response.statusCode == 200) {
// print("here");
String body = response.body;
var decodedData = jsonDecode(body);
Patient u = Patient.fromJson(decodedData);
// print(u.email);
//setState(() {
//_widgetOptions = setLayout(u);
//});
return u;
} else {
throw Exception("Error: GetUserData status code ${response.statusCode}");
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void deleteFilePopUp(int index) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHDeleteMessage(
deleteType: "appointment",
onTap: () async {
await updateAccessAPICall(index, "cancelled");
},
),
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void viewConfirmationPopUp(int index) {
String subtitle =
"Appointment: ${widget.patientQueue[index].date_time.substring(0, 16).replaceAll("T", " ")}\n";
subtitle += "ID No.: ${widget.patientQueue[index].id_no}\n";
subtitle +=
"Patient: ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name}\n";
// subtitle +=
// "Patient: ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name}\n\n";
//subtitle += "Business Type: ${widget.patientQueue[index].last_name}\n\n";
subtitle +=
"Would you like to view the patient's profile before the appointment or cancel the appointment now?\n";
//"You are about to approve an access request to your patient profile.\nPlease be aware that once approved, ${widget.accessRequests[index].Name} will have access to your profile information until ${widget.accessRequests[index].revoke_date.substring(0, 16).replaceAll("T", " ")}.\nIf you are unsure about an upcoming appointment with ${widget.accessRequests[index].Name}, please contact ${widget.accessRequests[index].contact_no} for clarification before approving this request.\n";
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: false,
windowTitle: "Appointment Confirmation",
windowBody: [
const SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Text(
subtitle,
textAlign: TextAlign.left,
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
fontSize: 15,
//fontWeight: FontWeight.bold,
),
),
),
Wrap(
runSpacing: 10,
spacing: 10,
children: [
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
//updateAccessAPICall(index, "cancelled");
var appointmentDateTime = widget
.patientQueue[index].date_time
.substring(0, 16)
.split("T");
var firstName = "";
var lastName = "";
firstName = widget.patientQueue[index].first_name;
lastName = widget.patientQueue[index].last_name;
setState(() {
idController.text = widget.patientQueue[index].id_no;
fnameController.text = firstName;
lnameController.text = lastName;
dateController.text = appointmentDateTime[0];
timeController.text = appointmentDateTime[1];
});
manageAppointmentPopUp(index);
},
buttonText: "Manage Appointment",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
//updateAccessAPICall(index, "approved");
Patient selectedPatient;
fetchPatients(widget.patientQueue[index].app_id).then(
(result) {
setState(() {
selectedPatient = result;
Navigator.of(context).pop();
Navigator.of(context)
.pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
selectedPatient,
widget.businessUser,
widget.business,
"business",
));
});
},
);
},
buttonText: "View Patient Profile",
buttonColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
),
const SizedBox(
height: 10,
),
],
windowTools: const [],
onWindowTapClose: () {
Navigator.pop(context);
}),
);
}
Future<void> addCancelledAppointmentNotificationAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/notifications/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"app_id": widget.patientQueue[index].app_id,
"notification_type": "Appointment Cancelled",
"notification_message":
"Your appointment with ${widget.business!.Name} for the ${widget.patientQueue[index].date_time.replaceAll("T", " ")} has been cancelled.",
"action_path": "/access-review",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: BusinessArguments(
widget.signedInUser,
widget.businessUser,
widget.business,
),
);
String message =
"The appointment for ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name} at ${widget.patientQueue[index].date_time} has been successfully canceled.";
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
Future<void> addRescheduledAppointmentNotificationAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/notifications/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"app_id": widget.patientQueue[index].app_id,
"notification_type": "Rescheduled Appointment",
"notification_message":
"Your appointment with ${widget.business!.Name} for the ${widget.patientQueue[index].date_time.replaceAll("T", " ").substring(0, widget.patientQueue[index].date_time.length - 3)} has been rescheduled to the ${dateController.text} ${timeController.text}.",
"action_path": "/access-review",
}),
);
if (response.statusCode == 201) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: BusinessArguments(
widget.signedInUser,
widget.businessUser,
widget.business,
),
);
String message =
"The appointment for ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name} at ${widget.patientQueue[index].date_time} has been successfully canceled.";
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
// Future<void> addAccessExtensionNotificationAPICall(
// int index, String revokeDate) async {
// var response = await http.post(
// Uri.parse("$baseAPI/notifications/insert/"),
// headers: <String, String>{
// "Content-Type": "application/json; charset=UTF-8"
// },
// body: jsonEncode(<String, dynamic>{
// "app_id": widget.patientQueue[index].app_id,
// "notification_type": "Access Extension Request",
// "notification_message":
// "${widget.business!.Name} - access expiry date extension for appointment: ${widget.patientQueue[index].date_time.split("T")[0]}. Expiry Date: from ${widget.patientQueue[index].revoke_date.split("T")[0]} to ${revokeDate.split(" ")[0]}.",
// "action_path": "/access-review",
// }),
// );
// if (response.statusCode == 201) {
// Navigator.of(context).pop();
// Navigator.of(context).pop();
// Navigator.of(context).pushNamed(
// '/patient-manager',
// arguments: BusinessArguments(
// widget.signedInUser,
// widget.businessUser,
// widget.business,
// ),
// );
// String message =
// "you have successfully requested an extension on the expirey date. The request has been sent tp ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name} to review and approve the request";
// successPopUp(message);
// } else {
// internetConnectionPopUp();
// }
// }
void manageAppointmentPopUp(int index) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHWindow(
fullscreen: false,
windowTitle: "Manage Appointment",
windowBody: [
MIHTextField(
controller: idController,
hintText: "ID No.",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
const SizedBox(height: 10.0),
MIHDateField(
controller: dateController,
lableText: "Date",
required: true,
),
const SizedBox(height: 10.0),
MIHTimeField(
controller: timeController,
lableText: "Time",
required: true,
),
const SizedBox(height: 30.0),
Wrap(
runSpacing: 10,
spacing: 10,
children: [
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
//add mihapicall for deleting appointment
MIHApiCalls.deleteApointmentAPICall(
widget.patientQueue[index].idpatient_queue,
widget.patientQueue[index].app_id,
widget.patientQueue[index].date_time,
BusinessArguments(
widget.signedInUser,
widget.businessUser,
widget.business,
),
context,
);
//updateAccessAPICall(index, "cancelled");
},
buttonText: "Cancel Appointment",
buttonColor:
MzanziInnovationHub.of(context)!.theme.errorColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () {
MIHApiCalls.updateApointmentAPICall(
widget.patientQueue[index].idpatient_queue,
widget.patientQueue[index].app_id,
widget.business!.Name,
widget.patientQueue[index].date_time,
dateController.text,
timeController.text,
BusinessArguments(
widget.signedInUser,
widget.businessUser,
widget.business,
),
context,
);
},
buttonText: "Update Appointment",
buttonColor:
MzanziInnovationHub.of(context)!.theme.successColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
),
const SizedBox(
height: 10,
),
],
windowTools: const [],
onWindowTapClose: () {
Navigator.pop(context);
}),
);
}
Widget displayQueue(int index) {
String title =
widget.patientQueue[index].date_time.split('T')[1].substring(0, 5);
String line234 = "";
// var nowDate = DateTime.now();
// var expireyDate = DateTime.parse(widget.patientQueue[index].revoke_date);
line234 +=
"Name: ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name}\nID No.: ${widget.patientQueue[index].id_no}\nMedical Aid No: ";
if (widget.patientQueue[index].medical_aid_no == "") {
line234 += "No Medical Aid";
} else {
// subtitle +=
// "\nMedical Aid No: ";
line234 += widget.patientQueue[index].medical_aid_no;
}
// String line5 = "\nAccess Request: ";
// String access = "";
// if (expireyDate.isBefore(nowDate) &&
// widget.patientQueue[index].access != "cacelled") {
// access += "EXPIRED";
// } else {
// access += widget.patientQueue[index].access.toUpperCase();
// }
// TextSpan accessWithColour;
// if (access == "APPROVED") {
// accessWithColour = TextSpan(
// text: access,
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!.theme.successColor()));
// } else if (access == "PENDING") {
// accessWithColour = TextSpan(
// text: access,
// style: TextStyle(
// color:
// MzanziInnovationHub.of(context)!.theme.messageTextColor()));
// } else {
// accessWithColour = TextSpan(
// text: access,
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!.theme.errorColor()));
// }
// String line6 = "";
// line6 +=
// "\nAccess Expiration date: ${widget.patientQueue[index].revoke_date.substring(0, 16).replaceAll("T", " ")}";
return ListTile(
title: Text(
"Appointment: $title",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: RichText(
text: TextSpan(
text: line234,
style: DefaultTextStyle.of(context).style,
// children: [
// TextSpan(text: line5),
// accessWithColour,
// TextSpan(text: line6),
// ]
),
),
// Text(
// subtitle,
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// ),
// ),
onTap: () {
// var todayDate = DateTime.now();
// var revokeDate = DateTime.parse(widget.patientQueue[index].revoke_date);
// // print(
// // "Todays: $todayDate\nRevoke Date: $revokeDate\nHas revoke date passed: ${revokeDate.isBefore(todayDate)}");
// if (revokeDate.isBefore(todayDate)) {
// expiredAccessWarning();
// } else if (widget.patientQueue[index].access == "approved") {
// viewConfirmationPopUp(index);
// // Patient selectedPatient;
// // fetchPatients(widget.patientQueue[index].app_id).then(
// // (result) {
// // setState(() {
// // selectedPatient = result;
// // Navigator.of(context).pushNamed('/patient-manager/patient',
// // arguments: PatientViewArguments(
// // widget.signedInUser,
// // selectedPatient,
// // widget.businessUser,
// // widget.business,
// // "business",
// // ));
// // });
// // },
// // );
// } else if (widget.patientQueue[index].access == "declined") {
// accessDeclinedWarning();
// } else if (widget.patientQueue[index].access == "cancelled") {
// appointmentCancelledWarning();
// } else {
viewConfirmationPopUp(index);
//noAccessWarning();
// }
},
//leading: getExtendAccessButton(access),
//trailing: getExtendAccessButton(access, index),
// Icon(
// Icons.arrow_forward,
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// ),
);
}
bool isAccessExpired(String accessType) {
if (accessType == "EXPIRED") {
return true;
} else {
return false;
}
}
// Widget getExtendAccessButton(String accessType, int index) {
// if (isAccessExpired(accessType)) {
// return IconButton(
// icon: const Icon(Icons.cached),
// onPressed: () {
// setState(() {
// daysExtensionController.text = counter.toString();
// });
// reapplyForAccess(index);
// },
// );
// } else {
// return Icon(
// Icons.arrow_forward,
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// );
// }
// }
// void reapplyForAccess(int index) {
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (context) => MIHWindow(
// fullscreen: false,
// windowTitle: "Extend Access",
// windowTools: const [],
// onWindowTapClose: () {
// Navigator.pop(context);
// },
// windowBody: [
// Text(
// "Current Expiration Date : ${widget.patientQueue[index].revoke_date.replaceAll("T", " ")}",
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// fontSize: 15,
// fontWeight: FontWeight.normal,
// ),
// ),
// const SizedBox(height: 5),
// Text(
// "Select the number of days you would like to extend the access by.",
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// fontSize: 15,
// fontWeight: FontWeight.normal,
// ),
// ),
// const SizedBox(height: 5),
// Text(
// "Once you click \"Apply\", an access review request will be triggered to the patient.",
// style: TextStyle(
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// fontSize: 15,
// fontWeight: FontWeight.normal,
// ),
// ),
// const SizedBox(height: 30),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// IconButton.filled(
// onPressed: () {
// if (counter > 0) {
// counter--;
// setState(() {
// daysExtensionController.text = counter.toString();
// });
// }
// },
// icon: const Icon(Icons.remove),
// ),
// const SizedBox(width: 15),
// SizedBox(
// width: 100,
// child: MIHTextField(
// controller: daysExtensionController,
// hintText: "Days",
// editable: false,
// required: true,
// ),
// ),
// const SizedBox(width: 15),
// IconButton.filled(
// onPressed: () {
// counter++;
// setState(() {
// daysExtensionController.text = counter.toString();
// });
// },
// icon: const Icon(Icons.add),
// ),
// ],
// ),
// const SizedBox(height: 30),
// SizedBox(
// width: 300,
// height: 50,
// child: MIHButton(
// onTap: () {
// print(
// "Revoke Date (String): ${widget.patientQueue[index].revoke_date}");
// var revokeDate = DateTime.parse(widget
// .patientQueue[index].revoke_date
// .replaceAll("T", " "));
// var newRevokeDate = revokeDate.add(
// Duration(days: int.parse(daysExtensionController.text)));
// print("Revoke Date (DateTime): $revokeDate");
// print("New Revoke Date (DateTime): $newRevokeDate");
// print(
// "${widget.business!.Name} would like to extend the access expirey date for your appointment on the ${widget.patientQueue[index].date_time}.\nNew Expirey Date: $revokeDate",
// );
// extendAccessAPICall(index, "$newRevokeDate");
// },
// buttonText: "Apply",
// buttonColor:
// MzanziInnovationHub.of(context)!.theme.secondaryColor(),
// textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
// ),
// ),
// ],
// ),
// );
// }
void noAccessWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "No Access");
},
);
}
void accessDeclinedWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "Access Declined");
},
);
}
void appointmentCancelledWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "Appointment Canelled");
},
);
}
void expiredAccessWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "Expired Access");
},
);
}
@override
void dispose() {
daysExtensionController.dispose();
dateController.dispose();
timeController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.patientQueue.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
return displayQueue(index);
},
);
}
}