new Pat manager files
This commit is contained in:
@@ -8,15 +8,12 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_layout/mih_window.dart'
|
||||
import 'package:Mzansi_Innovation_Hub/mih_components/mih_package/mih-app_tool_body.dart';
|
||||
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/arguments.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_objects/business.dart';
|
||||
import 'package:Mzansi_Innovation_Hub/mih_packages/calendar/builder/build_appointment_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../main.dart';
|
||||
|
||||
import '../../mih_components/mih_calendar.dart';
|
||||
import '../../mih_components/mih_layout/mih_action.dart';
|
||||
import '../../mih_components/mih_layout/mih_header.dart';
|
||||
import '../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import '../../mih_env/env.dart';
|
||||
import '../../mih_objects/app_user.dart';
|
||||
@@ -38,8 +35,8 @@ class Appointments extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PatientAccessRequestState extends State<Appointments> {
|
||||
TextEditingController filterController = TextEditingController();
|
||||
TextEditingController appointmentDateController = TextEditingController();
|
||||
TextEditingController selectedAppointmentDateController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentTitleController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentDescriptionIDController =
|
||||
@@ -50,12 +47,6 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
TextEditingController();
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
String errorCode = "";
|
||||
String errorBody = "";
|
||||
String datefilter = "";
|
||||
String accessFilter = "";
|
||||
bool forceRefresh = false;
|
||||
late String selectedDropdown;
|
||||
String selectedDay = DateTime.now().toString().split(" ")[0];
|
||||
|
||||
late Future<List<Appointment>> personalAppointmentResults;
|
||||
@@ -68,8 +59,12 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
child: BuildAppointmentList(
|
||||
appointmentList: appointmentList,
|
||||
signedInUser: widget.signedInUser,
|
||||
business: widget.business,
|
||||
personalSelected: widget.personalSelected,
|
||||
inWaitingRoom: false,
|
||||
titleController: _appointmentTitleController,
|
||||
descriptionIDController: _appointmentDescriptionIDController,
|
||||
patientIdController: null,
|
||||
dateController: _appointmentDateController,
|
||||
timeController: _appointmentTimeController,
|
||||
),
|
||||
@@ -227,6 +222,7 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
if (widget.personalSelected == false) {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
@@ -238,36 +234,6 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
});
|
||||
}
|
||||
|
||||
MIHAction getActionButton() {
|
||||
return MIHAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
Navigator.of(context).popAndPushNamed(
|
||||
'/',
|
||||
arguments: AuthArguments(true, false),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MIHHeader getHeader() {
|
||||
return const MIHHeader(
|
||||
headerAlignment: MainAxisAlignment.center,
|
||||
headerItems: [
|
||||
Text(
|
||||
"Appointments",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -286,7 +252,7 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
setDate: (value) {
|
||||
setState(() {
|
||||
selectedDay = value;
|
||||
appointmentDateController.text = selectedDay;
|
||||
selectedAppointmentDateController.text = selectedDay;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
@@ -348,8 +314,7 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
filterController.dispose();
|
||||
appointmentDateController.dispose();
|
||||
selectedAppointmentDateController.dispose();
|
||||
_appointmentDateController.dispose();
|
||||
_appointmentTimeController.dispose();
|
||||
_appointmentTitleController.dispose();
|
||||
@@ -359,11 +324,12 @@ class _PatientAccessRequestState extends State<Appointments> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
appointmentDateController.addListener(checkforchange);
|
||||
selectedAppointmentDateController.addListener(checkforchange);
|
||||
setState(() {
|
||||
if (widget.personalSelected == false) {
|
||||
appointmentResults = MihMzansiCalendarApis.getBusinessAppointments(
|
||||
widget.business!.business_id,
|
||||
false,
|
||||
selectedDay,
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -11,13 +11,18 @@ import 'package:Mzansi_Innovation_Hub/mih_components/mih_pop_up_messages/mih_err
|
||||
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:flutter/material.dart';
|
||||
|
||||
class BuildAppointmentList extends StatefulWidget {
|
||||
final List<Appointment> appointmentList;
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final bool personalSelected;
|
||||
final bool inWaitingRoom;
|
||||
final TextEditingController titleController;
|
||||
final TextEditingController descriptionIDController;
|
||||
final TextEditingController? patientIdController;
|
||||
final TextEditingController dateController;
|
||||
final TextEditingController timeController;
|
||||
|
||||
@@ -25,8 +30,12 @@ class BuildAppointmentList extends StatefulWidget {
|
||||
super.key,
|
||||
required this.appointmentList,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.personalSelected,
|
||||
required this.inWaitingRoom,
|
||||
required this.titleController,
|
||||
required this.descriptionIDController,
|
||||
required this.patientIdController,
|
||||
required this.dateController,
|
||||
required this.timeController,
|
||||
});
|
||||
@@ -37,6 +46,7 @@ class BuildAppointmentList extends StatefulWidget {
|
||||
|
||||
class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
TextEditingController patientIdController = TextEditingController();
|
||||
TextEditingController dateController = TextEditingController();
|
||||
TextEditingController timeController = TextEditingController();
|
||||
TextEditingController idController = TextEditingController();
|
||||
@@ -122,7 +132,11 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
.split('T')[1]
|
||||
.substring(0, 5);
|
||||
});
|
||||
appointmentDetailsWindow(index);
|
||||
if (widget.inWaitingRoom == false) {
|
||||
appointmentDetailsWindow(index);
|
||||
} else {
|
||||
waitingRiinAppointmentDetailsWindow(index);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -233,6 +247,120 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
);
|
||||
}
|
||||
|
||||
void waitingRiinAppointmentDetailsWindow(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MIHWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Appointment Details",
|
||||
windowTools: [
|
||||
Visibility(
|
||||
visible: canEditAppointment(index),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
deleteAppointmentConfirmationWindow(index);
|
||||
},
|
||||
icon: const Icon(Icons.delete),
|
||||
),
|
||||
),
|
||||
],
|
||||
onWindowTapClose: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.dateController.clear();
|
||||
widget.timeController.clear();
|
||||
widget.titleController.clear();
|
||||
widget.descriptionIDController.clear();
|
||||
},
|
||||
windowBody: [
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.titleController,
|
||||
hintText: "Title",
|
||||
editable: false,
|
||||
required: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.titleController,
|
||||
hintText: "Patient ID Number",
|
||||
editable: false,
|
||||
required: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.dateController,
|
||||
hintText: "Date",
|
||||
editable: false,
|
||||
required: false,
|
||||
)),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
child: MIHTextField(
|
||||
controller: widget.timeController,
|
||||
hintText: "Time",
|
||||
editable: false,
|
||||
required: false,
|
||||
)),
|
||||
const SizedBox(height: 10),
|
||||
SizedBox(
|
||||
// width: 500,
|
||||
height: 250,
|
||||
child: MIHMLTextField(
|
||||
controller: widget.descriptionIDController,
|
||||
hintText: "Description",
|
||||
editable: false,
|
||||
required: false,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Visibility(
|
||||
visible: canEditAppointment(index),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
height: 50,
|
||||
child: MIHButton(
|
||||
onTap: () {
|
||||
appointmentUpdateWindow(index);
|
||||
},
|
||||
buttonText: "Edit",
|
||||
buttonColor:
|
||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||
textColor:
|
||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: 500,
|
||||
// height: 50,
|
||||
// child: MIHButton(
|
||||
// onTap: () {
|
||||
// addAppointmentCall();
|
||||
// checkforchange();
|
||||
// },
|
||||
// buttonText: "Add",
|
||||
// buttonColor:
|
||||
// MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||
// textColor:
|
||||
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void appointmentUpdateWindow(int index) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@@ -379,6 +507,7 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
if (isAppointmentInputValid()) {
|
||||
MihMzansiCalendarApis.updatePersonalAppointment(
|
||||
widget.signedInUser,
|
||||
widget.business,
|
||||
widget.appointmentList[index].idappointments,
|
||||
widget.titleController.text,
|
||||
widget.descriptionIDController.text,
|
||||
@@ -405,7 +534,19 @@ class _BuildAppointmentListState extends State<BuildAppointmentList> {
|
||||
}
|
||||
|
||||
bool canEditAppointment(int index) {
|
||||
if (widget.appointmentList[index].business_id == "") {
|
||||
if (widget.personalSelected == true &&
|
||||
widget.appointmentList[index].app_id == widget.signedInUser.app_id &&
|
||||
widget.appointmentList[index].business_id == "") {
|
||||
return true;
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.appointmentList[index].business_id ==
|
||||
widget.business!.business_id &&
|
||||
widget.appointmentList[index].app_id.isEmpty) {
|
||||
return true;
|
||||
} else if (widget.personalSelected == false &&
|
||||
widget.appointmentList[index].business_id ==
|
||||
widget.business!.business_id &&
|
||||
widget.appointmentList[index].app_id.isNotEmpty) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user