appointment and waiting room update

This commit is contained in:
2025-03-04 12:58:37 +02:00
parent eff4fae83e
commit 23dbe21a2c
9 changed files with 391 additions and 91 deletions

View File

@@ -6,6 +6,7 @@ import 'package:Mzansi_Innovation_Hub/mih_objects/app_user.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/appointment.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/arguments.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business_user.dart';
import 'package:flutter/material.dart';
// import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
// import '../mih_components/mih_pop_up_messages/mih_success_message.dart';
@@ -90,15 +91,15 @@ class MihMzansiCalendarApis {
List<Appointment>.from(l.map((model) => Appointment.fromJson(model)));
//print("Here3");
//print(patientQueue);
if (waitingRoom == true) {
businessAppointments = businessAppointments
.where((element) => element.app_id != "")
.toList();
} else {
businessAppointments = businessAppointments
.where((element) => element.app_id == "")
.toList();
}
// if (waitingRoom == true) {
// businessAppointments = businessAppointments
// .where((element) => element.app_id != "")
// .toList();
// } else {
// businessAppointments = businessAppointments
// .where((element) => element.app_id == "")
// .toList();
// }
return businessAppointments;
} else {
throw Exception('failed to fatch business appointments');
@@ -113,8 +114,12 @@ class MihMzansiCalendarApis {
/// BuildContext context,
///
/// Returns VOID (TRIGGERS NOTIGICATIOPN ON SUCCESS)
static Future<void> deleteLoyaltyCardAPICall(
static Future<void> deleteAppointmentAPICall(
AppUser signedInUser,
bool personalSelected,
Business? business,
BusinessUser? businessUser,
bool inWaitingRoom,
int idappointments,
BuildContext context,
) async {
@@ -130,10 +135,27 @@ class MihMzansiCalendarApis {
if (response.statusCode == 200) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed(
'/calendar',
arguments: signedInUser,
);
if (inWaitingRoom) {
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: PatManagerArguments(
signedInUser,
false,
business,
businessUser,
),
);
} else {
Navigator.of(context).pushNamed(
'/calendar',
arguments: CalendarArguments(
signedInUser,
false,
business,
businessUser,
),
);
}
String message =
"The appointment has been deleted successfully. This means it will no longer be visible in your Calendar.";
successPopUp(message, context);
@@ -191,6 +213,7 @@ class MihMzansiCalendarApis {
signedInUser,
true,
null,
null,
),
);
successPopUp(message, context);
@@ -215,6 +238,8 @@ class MihMzansiCalendarApis {
static Future<void> addBusinessAppointment(
AppUser signedInUser,
Business business,
BusinessUser businessUser,
bool inWaitingRoom,
String title,
String description,
String date,
@@ -244,14 +269,28 @@ class MihMzansiCalendarApis {
"Your appointment \"$title\" for the $date $title has been deleted.";
// Navigator.pop(context);
Navigator.of(context).pushNamed(
'/calendar',
arguments: CalendarArguments(
signedInUser,
false,
business,
),
);
if (inWaitingRoom) {
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: PatManagerArguments(
signedInUser,
false,
business,
businessUser,
),
);
} else {
Navigator.of(context).pushNamed(
'/calendar',
arguments: CalendarArguments(
signedInUser,
false,
business,
businessUser,
),
);
}
successPopUp(message, context);
} else {
Navigator.pop(context);
@@ -329,6 +368,7 @@ class MihMzansiCalendarApis {
static Future<void> updatePersonalAppointment(
AppUser signedInUser,
Business? business,
BusinessUser? businessUser,
int idappointments,
String title,
String description,
@@ -364,6 +404,131 @@ class MihMzansiCalendarApis {
signedInUser,
true,
business,
businessUser,
),
);
successPopUp(message, context);
} else {
Navigator.pop(context);
internetConnectionPopUp(context);
}
}
/// This function is used to update an appointment to users mzansi Calendar.
///
/// Patameters:-
/// AppUser signedInUser,
/// String app_id,
/// int idappointments,
/// String title,
/// String description,
/// String date,
/// String time,
/// BuildContext context,
///
/// Returns VOID (TRIGGERS SUCCESS pop up)
static Future<void> updateBusinessAppointment(
AppUser signedInUser,
Business? business,
BusinessUser? businessUser,
int idappointments,
String title,
String description,
String date,
String time,
BuildContext context,
) async {
loadingPopUp(context);
var response = await http.put(
Uri.parse("${AppEnviroment.baseApiUrl}/appointment/update/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"idappointments": idappointments,
"title": title,
"description": description,
"date": date,
"time": time,
}),
);
if (response.statusCode == 200) {
// Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
String message =
"Your appointment \"$title\" has been updates to the $date $title.";
Navigator.pop(context);
Navigator.of(context).pushNamed(
'/calendar',
arguments: CalendarArguments(
signedInUser,
false,
business,
businessUser,
),
);
successPopUp(message, context);
} else {
Navigator.pop(context);
internetConnectionPopUp(context);
}
}
/// This function is used to update an appointment to users mzansi Calendar.
///
/// Patameters:-
/// AppUser signedInUser,
/// String app_id,
/// int idappointments,
/// String title,
/// String description,
/// String date,
/// String time,
/// BuildContext context,
///
/// Returns VOID (TRIGGERS SUCCESS pop up)
static Future<void> updatePatientAppointment(
AppUser signedInUser,
Business? business,
BusinessUser? businessUser,
int idappointments,
String title,
String description,
String date,
String time,
BuildContext context,
) async {
loadingPopUp(context);
var response = await http.put(
Uri.parse("${AppEnviroment.baseApiUrl}/appointment/update/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"idappointments": idappointments,
"title": title,
"description": description,
"date": date,
"time": time,
}),
);
if (response.statusCode == 200) {
// Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
String message =
"Your appointment \"$title\" has been updates to the $date $title.";
Navigator.pop(context);
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: PatManagerArguments(
signedInUser,
false,
business,
businessUser,
),
);
successPopUp(message, context);

View File

@@ -174,11 +174,13 @@ class CalendarArguments {
final AppUser signedInUser;
final bool personalSelected;
final Business? business;
final BusinessUser? businessUser;
CalendarArguments(
this.signedInUser,
this.personalSelected,
this.business,
this.businessUser,
);
}

View File

@@ -9,6 +9,7 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih-app_tool_bo
import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/appointment.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business_user.dart';
import 'package:Mzansi_Innovation_Hub/mih_packages/calendar/builder/build_appointment_list.dart';
import 'package:flutter/material.dart';
import '../../main.dart';
@@ -21,12 +22,14 @@ import '../../mih_objects/app_user.dart';
class Appointments extends StatefulWidget {
final AppUser signedInUser;
final Business? business;
final BusinessUser? businessUser;
final bool personalSelected;
const Appointments({
super.key,
required this.signedInUser,
required this.business,
required this.businessUser,
required this.personalSelected,
});
@@ -60,6 +63,7 @@ class _PatientAccessRequestState extends State<Appointments> {
appointmentList: appointmentList,
signedInUser: widget.signedInUser,
business: widget.business,
businessUser: widget.businessUser,
personalSelected: widget.personalSelected,
inWaitingRoom: false,
titleController: _appointmentTitleController,
@@ -182,6 +186,8 @@ class _PatientAccessRequestState extends State<Appointments> {
MihMzansiCalendarApis.addBusinessAppointment(
widget.signedInUser,
widget.business!,
widget.businessUser!,
false,
_appointmentTitleController.text,
_appointmentDescriptionIDController.text,
_appointmentDateController.text,

View File

@@ -12,12 +12,14 @@ import 'package:Mzansi_Innovation_Hub/mih_env/env.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/app_user.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/appointment.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business_user.dart';
import 'package:flutter/material.dart';
class BuildAppointmentList extends StatefulWidget {
final List<Appointment> appointmentList;
final AppUser signedInUser;
final Business? business;
final BusinessUser? businessUser;
final bool personalSelected;
final bool inWaitingRoom;
final TextEditingController titleController;
@@ -31,6 +33,7 @@ class BuildAppointmentList extends StatefulWidget {
required this.appointmentList,
required this.signedInUser,
required this.business,
required this.businessUser,
required this.personalSelected,
required this.inWaitingRoom,
required this.titleController,
@@ -505,16 +508,44 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
void updateAppointmentCall(int index) {
if (isAppointmentInputValid()) {
MihMzansiCalendarApis.updatePersonalAppointment(
widget.signedInUser,
widget.business,
widget.appointmentList[index].idappointments,
widget.titleController.text,
widget.descriptionIDController.text,
widget.dateController.text,
widget.timeController.text,
context,
);
if (widget.personalSelected == true) {
MihMzansiCalendarApis.updatePersonalAppointment(
widget.signedInUser,
widget.business,
null,
widget.appointmentList[index].idappointments,
widget.titleController.text,
widget.descriptionIDController.text,
widget.dateController.text,
widget.timeController.text,
context,
);
} else if (widget.personalSelected == false &&
widget.inWaitingRoom == false) {
MihMzansiCalendarApis.updateBusinessAppointment(
widget.signedInUser,
widget.business,
widget.businessUser,
widget.appointmentList[index].idappointments,
widget.titleController.text,
widget.descriptionIDController.text,
widget.dateController.text,
widget.timeController.text,
context,
);
} else {
MihMzansiCalendarApis.updatePatientAppointment(
widget.signedInUser,
widget.business,
widget.businessUser,
widget.appointmentList[index].idappointments,
widget.titleController.text,
widget.descriptionIDController.text,
widget.dateController.text,
widget.timeController.text,
context,
);
}
} else {
showDialog(
context: context,
@@ -526,8 +557,12 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
}
void deleteAppointmentCall(int index) {
MihMzansiCalendarApis.deleteLoyaltyCardAPICall(
MihMzansiCalendarApis.deleteAppointmentAPICall(
widget.signedInUser,
widget.personalSelected,
widget.business,
widget.businessUser,
widget.inWaitingRoom,
widget.appointmentList[index].idappointments,
context,
);

View File

@@ -69,6 +69,7 @@ class _MzansiCalendarState extends State<MzansiCalendar> {
Appointments(
signedInUser: widget.arguments.signedInUser,
business: widget.arguments.business,
businessUser: widget.arguments.businessUser,
personalSelected: widget.arguments.personalSelected,
),
];

View File

@@ -38,6 +38,7 @@ import '../../mih_objects/business_user.dart';
import '../../mih_objects/notification.dart';
import '../test/test.dart';
// ignore: must_be_immutable
class MIHHome extends StatefulWidget {
final AppUser signedInUser;
final BusinessUser? businessUser;
@@ -49,8 +50,8 @@ class MIHHome extends StatefulWidget {
final bool isBusinessUser;
final bool isBusinessUserNew;
final bool isDevActive;
final bool personalSelected;
const MIHHome({
bool personalSelected;
MIHHome({
super.key,
required this.signedInUser,
required this.businessUser,
@@ -253,6 +254,7 @@ class _MIHHomeState extends State<MIHHome> {
widget.signedInUser,
true,
widget.business,
null,
),
);
},
@@ -434,6 +436,7 @@ class _MIHHomeState extends State<MIHHome> {
widget.signedInUser,
false,
widget.business,
widget.businessUser,
),
);
},
@@ -1171,8 +1174,10 @@ class _MIHHomeState extends State<MIHHome> {
text: "Personal",
onPressed: () {
setState(() {
widget.personalSelected = true;
_selectedIndex = 0;
});
print("personal selected: ${widget.personalSelected}");
},
),
GButton(
@@ -1180,8 +1185,10 @@ class _MIHHomeState extends State<MIHHome> {
text: "Business",
onPressed: () {
setState(() {
widget.personalSelected = false;
_selectedIndex = 1;
});
print("personal selected: ${widget.personalSelected}");
},
),
],

View File

@@ -4,7 +4,6 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_calendar.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_button.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_date_input.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_multiline_text_input.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_search_input.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_text_input.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_inputs_and_buttons/mih_time_input.dart';
import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_window.dart';
@@ -15,19 +14,23 @@ import 'package:Mzansi_Innovation_Hub/mih_env/env.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/app_user.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/appointment.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business.dart';
import 'package:Mzansi_Innovation_Hub/mih_objects/business_user.dart';
import 'package:Mzansi_Innovation_Hub/mih_packages/calendar/builder/build_appointment_list.dart';
import 'package:flutter/material.dart';
class WaitingRoom extends StatefulWidget {
final AppUser signedInUser;
final Business? business;
final BusinessUser? businessUser;
final bool personalSelected;
final Function(int) onIndexChange;
const WaitingRoom({
super.key,
required this.signedInUser,
this.business,
required this.business,
required this.businessUser,
required this.personalSelected,
required this.onIndexChange,
});
@override
@@ -52,6 +55,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
late Future<List<Appointment>> businessAppointmentResults;
late Future<List<Appointment>> appointmentResults;
bool inWaitingRoom = true;
// Business Appointment Tool
Widget getBusinessAppointmentsTool() {
@@ -122,7 +126,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
child: IconButton(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
onPressed: () {
addAppointmentWindow();
appointmentTypeSelection();
},
icon: const Icon(
Icons.add,
@@ -141,6 +145,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
appointmentList: appointmentList,
signedInUser: widget.signedInUser,
business: widget.business,
businessUser: widget.businessUser,
personalSelected: widget.personalSelected,
inWaitingRoom: true,
titleController: _appointmentTitleController,
@@ -170,7 +175,89 @@ class _WaitingRoomState extends State<WaitingRoom> {
);
}
void appointmentTypeSelection() {
String question = "What type of appointment would you like to add?";
question +=
"\n\nExisting Patient: Add an appointment for an patient your practice has access to.";
question +=
"\nExisting MIH User: Add an appointment for an existing MIH user your practice does not have access to.";
question +=
"\nSkeleton Appointment: Add an appointment without a patient linked.";
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return MIHWindow(
fullscreen: false,
windowTitle: "Appointment Type",
windowTools: [],
onWindowTapClose: () {
Navigator.of(context).pop();
},
windowBody: [
Text(
question,
style: TextStyle(
fontSize: 20,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor()),
textAlign: TextAlign.left,
),
const SizedBox(height: 15),
SizedBox(
width: 500,
height: 50,
child: MIHButton(
onTap: () {
widget.onIndexChange(1);
Navigator.of(context).pop();
},
buttonText: "Existing Patient",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
const SizedBox(height: 10),
SizedBox(
width: 500,
height: 50,
child: MIHButton(
onTap: () {
widget.onIndexChange(2);
Navigator.of(context).pop();
},
buttonText: "Existing MIH User",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
const SizedBox(height: 10),
SizedBox(
width: 500,
height: 50,
child: MIHButton(
onTap: () {
addAppointmentWindow();
},
buttonText: "Skeleton Appointment",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
),
],
);
},
);
}
void addAppointmentWindow() {
print(widget.personalSelected);
showDialog(
context: context,
barrierDismissible: false,
@@ -198,18 +285,6 @@ class _WaitingRoomState extends State<WaitingRoom> {
),
),
const SizedBox(height: 10),
SizedBox(
child: MIHSearchField(
controller: _patientController,
hintText: "Patient ID Number",
required: false,
editable: true,
onTap: () {
//To-Do: Add search functionality
},
),
),
const SizedBox(height: 10),
SizedBox(
// width: 500,
child: MIHDateField(
@@ -244,9 +319,7 @@ class _WaitingRoomState extends State<WaitingRoom> {
height: 50,
child: MIHButton(
onTap: () {
//To-Do: Add appointment
print("To-Do: Add appointment");
// addAppointmentCall();
addAppointmentCall();
},
buttonText: "Add",
buttonColor:
@@ -267,6 +340,8 @@ class _WaitingRoomState extends State<WaitingRoom> {
MihMzansiCalendarApis.addBusinessAppointment(
widget.signedInUser,
widget.business!,
widget.businessUser!,
true,
_appointmentTitleController.text,
_appointmentDescriptionIDController.text,
_appointmentDateController.text,

View File

@@ -20,6 +20,13 @@ class PatManager extends StatefulWidget {
class _PatManagerState extends State<PatManager> {
int _selcetedIndex = 0;
void updateIndex(int index) {
setState(() {
_selcetedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return MihApp(
@@ -82,7 +89,9 @@ class _PatManagerState extends State<PatManager> {
WaitingRoom(
signedInUser: widget.arguments.signedInUser,
business: widget.arguments.business,
businessUser: widget.arguments.businessUser,
personalSelected: widget.arguments.personalSelected,
onIndexChange: updateIndex,
),
MyPatientList(
signedInUser: widget.arguments.signedInUser,