display appoinbtments in tool body
This commit is contained in:
@@ -1,19 +1,27 @@
|
|||||||
|
import 'package:Mzansi_Innovation_Hub/mih_apis/mih_mzansi_calendar_apis.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_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';
|
||||||
|
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/arguments.dart';
|
||||||
|
import 'package:Mzansi_Innovation_Hub/mih_packages/appointment/builder/build_appointment_list.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
|
|
||||||
import '../../mih_apis/mih_api_calls.dart';
|
import '../../mih_apis/mih_api_calls.dart';
|
||||||
import '../../mih_components/mih_calendar.dart';
|
import '../../mih_components/mih_calendar.dart';
|
||||||
import '../../mih_components/mih_layout/mih_action.dart';
|
import '../../mih_components/mih_layout/mih_action.dart';
|
||||||
import '../../mih_components/mih_layout/mih_body.dart';
|
|
||||||
import '../../mih_components/mih_layout/mih_header.dart';
|
import '../../mih_components/mih_layout/mih_header.dart';
|
||||||
import '../../mih_components/mih_layout/mih_layout_builder.dart';
|
|
||||||
import '../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
import '../../mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import '../../mih_env/env.dart';
|
import '../../mih_env/env.dart';
|
||||||
import '../../mih_objects/access_request.dart';
|
import '../../mih_objects/access_request.dart';
|
||||||
import '../../mih_objects/app_user.dart';
|
import '../../mih_objects/app_user.dart';
|
||||||
import '../../mih_objects/patient_queue.dart';
|
import '../../mih_objects/patient_queue.dart';
|
||||||
import 'builder/build_appointment_list.dart';
|
|
||||||
|
|
||||||
class Appointments extends StatefulWidget {
|
class Appointments extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
@@ -30,6 +38,14 @@ class Appointments extends StatefulWidget {
|
|||||||
class _PatientAccessRequestState extends State<Appointments> {
|
class _PatientAccessRequestState extends State<Appointments> {
|
||||||
TextEditingController filterController = TextEditingController();
|
TextEditingController filterController = TextEditingController();
|
||||||
TextEditingController appointmentDateController = TextEditingController();
|
TextEditingController appointmentDateController = TextEditingController();
|
||||||
|
final TextEditingController _appointmentTitleController =
|
||||||
|
TextEditingController();
|
||||||
|
final TextEditingController _appointmentDescriptionIDController =
|
||||||
|
TextEditingController();
|
||||||
|
final TextEditingController _appointmentDateController =
|
||||||
|
TextEditingController();
|
||||||
|
final TextEditingController _appointmentTimeController =
|
||||||
|
TextEditingController();
|
||||||
String baseUrl = AppEnviroment.baseApiUrl;
|
String baseUrl = AppEnviroment.baseApiUrl;
|
||||||
|
|
||||||
String errorCode = "";
|
String errorCode = "";
|
||||||
@@ -42,20 +58,26 @@ class _PatientAccessRequestState extends State<Appointments> {
|
|||||||
|
|
||||||
late Future<List<AccessRequest>> accessRequestResults;
|
late Future<List<AccessRequest>> accessRequestResults;
|
||||||
late Future<List<PatientQueue>> personalQueueResults;
|
late Future<List<PatientQueue>> personalQueueResults;
|
||||||
|
late Future<List<Appointment>> personalAppointmentResults;
|
||||||
|
|
||||||
Widget displayQueueList(List<PatientQueue> patientQueueList) {
|
Widget displayAppointmentList(List<Appointment> appointmentList) {
|
||||||
if (patientQueueList.isNotEmpty) {
|
if (appointmentList.isNotEmpty) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: BuildAppointmentList(
|
child: BuildAppointmentList(
|
||||||
patientQueue: patientQueueList,
|
appointmentList: appointmentList,
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.signedInUser,
|
||||||
|
titleController: _appointmentTitleController,
|
||||||
|
descriptionIDController: _appointmentDescriptionIDController,
|
||||||
|
dateController: _appointmentDateController,
|
||||||
|
timeController: _appointmentTimeController,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 35.0),
|
padding: const EdgeInsets.only(top: 35.0),
|
||||||
child: Center(
|
child: Align(
|
||||||
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
"No Appointments for $selectedDay",
|
"No Appointments for $selectedDay",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -70,8 +92,122 @@ class _PatientAccessRequestState extends State<Appointments> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addAppointmentWindow() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) {
|
||||||
|
return MIHWindow(
|
||||||
|
fullscreen: false,
|
||||||
|
windowTitle: "Add Appointment",
|
||||||
|
windowTools: [],
|
||||||
|
onWindowTapClose: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
_appointmentDateController.clear();
|
||||||
|
_appointmentTimeController.clear();
|
||||||
|
_appointmentTitleController.clear();
|
||||||
|
_appointmentDescriptionIDController.clear();
|
||||||
|
},
|
||||||
|
windowBody: [
|
||||||
|
SizedBox(
|
||||||
|
// width: 500,
|
||||||
|
child: MIHTextField(
|
||||||
|
controller: _appointmentTitleController,
|
||||||
|
hintText: "Title",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
SizedBox(
|
||||||
|
// width: 500,
|
||||||
|
child: MIHDateField(
|
||||||
|
controller: _appointmentDateController,
|
||||||
|
lableText: "Date",
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
SizedBox(
|
||||||
|
// width: 500,
|
||||||
|
child: MIHTimeField(
|
||||||
|
controller: _appointmentTimeController,
|
||||||
|
lableText: "Time",
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
SizedBox(
|
||||||
|
// width: 500,
|
||||||
|
height: 250,
|
||||||
|
child: MIHMLTextField(
|
||||||
|
controller: _appointmentDescriptionIDController,
|
||||||
|
hintText: "Description",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
SizedBox(
|
||||||
|
width: 500,
|
||||||
|
height: 50,
|
||||||
|
child: MIHButton(
|
||||||
|
onTap: () {
|
||||||
|
addAppointmentCall();
|
||||||
|
},
|
||||||
|
buttonText: "Add",
|
||||||
|
buttonColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
textColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isAppointmentInputValid() {
|
||||||
|
if (_appointmentTitleController.text.isEmpty ||
|
||||||
|
_appointmentDescriptionIDController.text.isEmpty ||
|
||||||
|
_appointmentDateController.text.isEmpty ||
|
||||||
|
_appointmentTimeController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAppointmentCall() {
|
||||||
|
if (isAppointmentInputValid()) {
|
||||||
|
MihMzansiCalendarApis.addPersonalAppointment(
|
||||||
|
widget.signedInUser,
|
||||||
|
widget.signedInUser.app_id,
|
||||||
|
_appointmentTitleController.text,
|
||||||
|
_appointmentDescriptionIDController.text,
|
||||||
|
_appointmentDateController.text,
|
||||||
|
_appointmentTimeController.text,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MIHErrorMessage(errorType: "Input Error");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
checkforchange();
|
||||||
|
}
|
||||||
|
|
||||||
void checkforchange() {
|
void checkforchange() {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
personalAppointmentResults =
|
||||||
|
MihMzansiCalendarApis.getPersonalAppointments(
|
||||||
|
widget.signedInUser.app_id,
|
||||||
|
selectedDay,
|
||||||
|
);
|
||||||
personalQueueResults = MIHApiCalls.fetchPersonalAppointmentsAPICall(
|
personalQueueResults = MIHApiCalls.fetchPersonalAppointmentsAPICall(
|
||||||
selectedDay,
|
selectedDay,
|
||||||
widget.signedInUser.app_id,
|
widget.signedInUser.app_id,
|
||||||
@@ -109,50 +245,80 @@ class _PatientAccessRequestState extends State<Appointments> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MIHBody getBody() {
|
Widget getBody() {
|
||||||
return MIHBody(
|
return Stack(
|
||||||
borderOn: true,
|
children: [
|
||||||
bodyItems: [
|
Column(
|
||||||
MIHCalendar(
|
|
||||||
calendarWidth: 500,
|
|
||||||
rowHeight: 35,
|
|
||||||
setDate: (value) {
|
|
||||||
setState(() {
|
|
||||||
selectedDay = value;
|
|
||||||
appointmentDateController.text = selectedDay;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
Divider(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
children: [
|
||||||
FutureBuilder(
|
// const Text(
|
||||||
future: personalQueueResults,
|
// "Appointments",
|
||||||
builder: (context, snapshot) {
|
// style: TextStyle(
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
// fontWeight: FontWeight.bold,
|
||||||
return const Expanded(
|
// fontSize: 25,
|
||||||
child: Center(child: Mihloadingcircle()));
|
// ),
|
||||||
} else if (snapshot.connectionState == ConnectionState.done &&
|
// ),
|
||||||
snapshot.hasData) {
|
MIHCalendar(
|
||||||
return displayQueueList(snapshot.requireData);
|
calendarWidth: 500,
|
||||||
} else {
|
rowHeight: 35,
|
||||||
return Center(
|
setDate: (value) {
|
||||||
child: Text(
|
setState(() {
|
||||||
"Error pulling appointments",
|
selectedDay = value;
|
||||||
style: TextStyle(
|
appointmentDateController.text = selectedDay;
|
||||||
fontSize: 25,
|
});
|
||||||
color: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.errorColor()),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
|
// Divider(
|
||||||
|
// color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
// ),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
FutureBuilder(
|
||||||
|
future: personalAppointmentResults,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Expanded(
|
||||||
|
child: Center(child: Mihloadingcircle()));
|
||||||
|
} else if (snapshot.connectionState ==
|
||||||
|
ConnectionState.done &&
|
||||||
|
snapshot.hasData) {
|
||||||
|
return displayAppointmentList(snapshot.requireData);
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: Text(
|
||||||
|
"Error pulling appointments",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.errorColor()),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(50),
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
child: IconButton(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
onPressed: () {
|
||||||
|
addAppointmentWindow();
|
||||||
|
},
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.add,
|
||||||
|
size: 50,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
))
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -161,6 +327,10 @@ class _PatientAccessRequestState extends State<Appointments> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
filterController.dispose();
|
filterController.dispose();
|
||||||
appointmentDateController.dispose();
|
appointmentDateController.dispose();
|
||||||
|
_appointmentDateController.dispose();
|
||||||
|
_appointmentTimeController.dispose();
|
||||||
|
_appointmentTitleController.dispose();
|
||||||
|
_appointmentDescriptionIDController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,6 +338,11 @@ class _PatientAccessRequestState extends State<Appointments> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
appointmentDateController.addListener(checkforchange);
|
appointmentDateController.addListener(checkforchange);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
personalAppointmentResults =
|
||||||
|
MihMzansiCalendarApis.getPersonalAppointments(
|
||||||
|
widget.signedInUser.app_id,
|
||||||
|
selectedDay,
|
||||||
|
);
|
||||||
personalQueueResults = MIHApiCalls.fetchPersonalAppointmentsAPICall(
|
personalQueueResults = MIHApiCalls.fetchPersonalAppointmentsAPICall(
|
||||||
selectedDay,
|
selectedDay,
|
||||||
widget.signedInUser.app_id,
|
widget.signedInUser.app_id,
|
||||||
@@ -178,16 +353,9 @@ class _PatientAccessRequestState extends State<Appointments> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MIHLayoutBuilder(
|
return MihAppToolBody(
|
||||||
actionButton: getActionButton(),
|
borderOn: true,
|
||||||
header: getHeader(),
|
bodyItem: getBody(),
|
||||||
secondaryActionButton: null,
|
|
||||||
body: getBody(),
|
|
||||||
actionDrawer: null,
|
|
||||||
secondaryActionDrawer: null,
|
|
||||||
bottomNavBar: null,
|
|
||||||
pullDownToRefresh: false,
|
|
||||||
onPullDown: () async {},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user