rename container folders
This commit is contained in:
@@ -0,0 +1,578 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_access_controls_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildMihPatientSearchList extends StatefulWidget {
|
||||
const BuildMihPatientSearchList({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildMihPatientSearchList> createState() => _BuildPatientsListState();
|
||||
}
|
||||
|
||||
class _BuildPatientsListState extends State<BuildMihPatientSearchList> {
|
||||
TextEditingController dateController = TextEditingController();
|
||||
TextEditingController timeController = TextEditingController();
|
||||
TextEditingController idController = TextEditingController();
|
||||
TextEditingController fnameController = TextEditingController();
|
||||
TextEditingController lnameController = TextEditingController();
|
||||
TextEditingController accessStatusController = TextEditingController();
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
|
||||
Future<bool> hasAccessToProfile(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, int index) async {
|
||||
var hasAccess = false;
|
||||
await MihAccessControlsServices.checkBusinessAccessToPatient(
|
||||
profileProvider.business!.business_id,
|
||||
patientManagerProvider.patientSearchResults[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(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, int index) async {
|
||||
var accessStatus = "";
|
||||
await MihAccessControlsServices.checkBusinessAccessToPatient(
|
||||
profileProvider.business!.business_id,
|
||||
patientManagerProvider.patientSearchResults[index].app_id)
|
||||
.then((results) {
|
||||
if (results.isEmpty) {
|
||||
setState(() {
|
||||
accessStatus = "";
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
accessStatus = results[0].status;
|
||||
});
|
||||
}
|
||||
});
|
||||
return accessStatus;
|
||||
}
|
||||
|
||||
Future<void> refreshMyPatientList(MzansiProfileProvider mzansiProfileProvider,
|
||||
PatientManagerProvider patientManagerProvider) async {
|
||||
await MihPatientServices().getPatientAccessListOfBusiness(
|
||||
patientManagerProvider, mzansiProfileProvider.business!.business_id);
|
||||
}
|
||||
|
||||
void patientProfileChoicePopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
int index,
|
||||
) async {
|
||||
var hasAccess = false;
|
||||
String accessStatus = "";
|
||||
await hasAccessToProfile(profileProvider, patientManagerProvider, index)
|
||||
.then((result) {
|
||||
setState(() {
|
||||
hasAccess = result;
|
||||
});
|
||||
});
|
||||
await getAccessStatusOfProfile(
|
||||
profileProvider, patientManagerProvider, index)
|
||||
.then((result) {
|
||||
setState(() {
|
||||
accessStatus = result;
|
||||
});
|
||||
});
|
||||
if (accessStatus == "") {
|
||||
accessStatus = "No Access";
|
||||
}
|
||||
String patientIdNo =
|
||||
patientManagerProvider.patientSearchResults[index].id_no;
|
||||
String displayedIdNo;
|
||||
|
||||
if (patientIdNo.length >= 6) {
|
||||
var idStars = '*' * (patientIdNo.length - 6);
|
||||
displayedIdNo = "${patientIdNo.substring(0, 6)}$idStars";
|
||||
} else {
|
||||
displayedIdNo = "${patientIdNo}******";
|
||||
}
|
||||
setState(() {
|
||||
idController.text = displayedIdNo;
|
||||
fnameController.text =
|
||||
patientManagerProvider.patientSearchResults[index].first_name;
|
||||
lnameController.text =
|
||||
patientManagerProvider.patientSearchResults[index].last_name;
|
||||
accessStatusController.text = accessStatus.toUpperCase();
|
||||
});
|
||||
//print(accessStatus);
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Patient Profile",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: idController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "ID No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: fnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "First Name",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: lnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Surname",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: accessStatusController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Access Status",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Visibility(
|
||||
visible: !hasAccess,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Important Notice: Requesting Patient Profile Access",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
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: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
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: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
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: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
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: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"By pressing the \"Request Access\" button you accept the above terms.\n",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// const SizedBox(height: 15.0),
|
||||
Center(
|
||||
child: Wrap(
|
||||
alignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
Visibility(
|
||||
visible: hasAccess,
|
||||
child: Center(
|
||||
child: MihButton(
|
||||
onPressed: () async {
|
||||
if (hasAccess) {
|
||||
await MihPatientServices().getPatientDetails(
|
||||
patientManagerProvider
|
||||
.patientSearchResults[index].app_id,
|
||||
patientManagerProvider);
|
||||
context.pop();
|
||||
context.pushNamed(
|
||||
'patientManagerPatient',
|
||||
);
|
||||
// context.pushNamed(
|
||||
// 'patientPatient',
|
||||
// extra: patientManagerProvider
|
||||
// .patientSearchResults![index].app_id,
|
||||
// );
|
||||
// Navigator.of(context)
|
||||
// .pushNamed('/patient-manager/patient',
|
||||
// arguments: PatientViewArguments(
|
||||
// widget.signedInUser,
|
||||
// widget.patients[index],
|
||||
// widget.businessUser,
|
||||
// widget.business,
|
||||
// "business",
|
||||
// ));
|
||||
} else {
|
||||
MihAlertServices().warningAlert(
|
||||
"Access Pending",
|
||||
"Your access request is currently being reviewed.\nOnce approved, you'll be able to view patient data.\nPlease follow up with the patient to approve your access request.",
|
||||
context,
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"View Profile",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !hasAccess && accessStatus == "No Access",
|
||||
child: Center(
|
||||
child: MihButton(
|
||||
onPressed: () async {
|
||||
await MihAccessControlsServices
|
||||
.addPatientAccessAPICall(
|
||||
profileProvider.business!.business_id,
|
||||
patientManagerProvider
|
||||
.patientSearchResults[index].app_id,
|
||||
"patient",
|
||||
profileProvider.business!.Name,
|
||||
patientManagerProvider.personalMode,
|
||||
BusinessArguments(
|
||||
profileProvider.user!,
|
||||
profileProvider.businessUser,
|
||||
profileProvider.business,
|
||||
),
|
||||
context,
|
||||
);
|
||||
refreshMyPatientList(
|
||||
profileProvider, patientManagerProvider);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Request Access",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: !hasAccess && accessStatus == "declined",
|
||||
child: Center(
|
||||
child: MihButton(
|
||||
onPressed: () async {
|
||||
await MihAccessControlsServices
|
||||
.reapplyPatientAccessAPICall(
|
||||
profileProvider.business!.business_id,
|
||||
patientManagerProvider
|
||||
.patientSearchResults[index].app_id,
|
||||
patientManagerProvider.personalMode,
|
||||
BusinessArguments(
|
||||
profileProvider.user!,
|
||||
profileProvider.businessUser,
|
||||
profileProvider.business,
|
||||
),
|
||||
context,
|
||||
);
|
||||
refreshMyPatientList(
|
||||
profileProvider, patientManagerProvider);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Re-apply",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
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(
|
||||
PatientManagerProvider patientManagerProvider, int index) {
|
||||
if (patientManagerProvider
|
||||
.patientSearchResults[index].medical_aid_main_member ==
|
||||
"Yes") {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
// "$firstLetterFName$fnameStar $firstLetterLName$lnameStar",
|
||||
"${patientManagerProvider.patientSearchResults[index].first_name} ${patientManagerProvider.patientSearchResults[index].last_name}",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Icon(
|
||||
Icons.star_border_rounded,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Text(
|
||||
// "$firstLetterFName$fnameStar $firstLetterLName$lnameStar",
|
||||
"${patientManagerProvider.patientSearchResults[index].first_name} ${patientManagerProvider.patientSearchResults[index].last_name}",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget hasMedicalAid(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
int index,
|
||||
) {
|
||||
String patientIdNo =
|
||||
patientManagerProvider.patientSearchResults[index].id_no;
|
||||
String displayedIdNo;
|
||||
var medAidNoStar = '*' * 8;
|
||||
if (patientIdNo.length >= 6) {
|
||||
var idStars = '*' * (patientIdNo.length - 6);
|
||||
displayedIdNo = "${patientIdNo.substring(0, 6)}$idStars";
|
||||
} else {
|
||||
// If ID is shorter than 6 characters, just show it with stars
|
||||
displayedIdNo = "${patientIdNo}******";
|
||||
}
|
||||
|
||||
if (patientManagerProvider.patientSearchResults[index].medical_aid ==
|
||||
"Yes") {
|
||||
return ListTile(
|
||||
title: isMainMember(patientManagerProvider, index),
|
||||
subtitle: Text(
|
||||
"ID No.: $displayedIdNo\nMedical Aid No.: $medAidNoStar",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
patientProfileChoicePopUp(
|
||||
profileProvider, patientManagerProvider, 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: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return ListTile(
|
||||
title: isMainMember(patientManagerProvider, index),
|
||||
subtitle: Text(
|
||||
"ID No.: $displayedIdNo\nMedical Aid No.: $medAidNoStar",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
patientProfileChoicePopUp(
|
||||
profileProvider, patientManagerProvider, index);
|
||||
// setState(() {
|
||||
// appointmentPopUp(index);
|
||||
// // Navigator.of(context).pushNamed('/patient-manager/patient',
|
||||
// // arguments: PatientViewArguments(
|
||||
// // widget.signedInUser, widget.patients[index], "business"));
|
||||
// });
|
||||
},
|
||||
trailing: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
dateController.dispose();
|
||||
timeController.dispose();
|
||||
idController.dispose();
|
||||
fnameController.dispose();
|
||||
lnameController.dispose();
|
||||
accessStatusController.dispose();
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
patientManagerProvider.setPatientSearchResults(patientSearchResults: []);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: patientManagerProvider.patientSearchResults.length,
|
||||
itemBuilder: (context, index) {
|
||||
KenLogger.success(
|
||||
"Search Results Count: ${patientManagerProvider.patientSearchResults.length}");
|
||||
return hasMedicalAid(
|
||||
profileProvider, patientManagerProvider, index);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_calendar_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_date_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_time_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildMyPatientListList extends StatefulWidget {
|
||||
const BuildMyPatientListList({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildMyPatientListList> createState() => _BuildPatientsListState();
|
||||
}
|
||||
|
||||
class _BuildPatientsListState extends State<BuildMyPatientListList> {
|
||||
TextEditingController dateController = TextEditingController();
|
||||
TextEditingController timeController = TextEditingController();
|
||||
TextEditingController idController = TextEditingController();
|
||||
TextEditingController fnameController = TextEditingController();
|
||||
TextEditingController lnameController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
|
||||
Future<void> submitApointment(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, int index) async {
|
||||
//To-Do: Add the appointment to the database
|
||||
// print("To-Do: Add the appointment to the database");
|
||||
String description =
|
||||
"Date: ${dateController.text}\nTime: ${timeController.text}\n";
|
||||
description += "Medical Practice: ${profileProvider.business!.Name}\n";
|
||||
description += "Contact Number: ${profileProvider.business!.contact_no}";
|
||||
int statusCode;
|
||||
statusCode = await MihMzansiCalendarApis.addPatientAppointment(
|
||||
profileProvider.user!,
|
||||
false,
|
||||
patientManagerProvider.myPaitentList![index].app_id,
|
||||
profileProvider.business!.business_id,
|
||||
"${patientManagerProvider.myPaitentList![index].fname} ${patientManagerProvider.myPaitentList![index].lname} - Doctors Visit",
|
||||
description,
|
||||
dateController.text,
|
||||
timeController.text,
|
||||
context,
|
||||
);
|
||||
if (statusCode == 201) {
|
||||
context.pop();
|
||||
successPopUp("Successfully Added Appointment",
|
||||
"You appointment has been successfully added to your calendar.");
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.pop();
|
||||
setState(() {
|
||||
dateController.clear();
|
||||
timeController.clear();
|
||||
idController.clear();
|
||||
fnameController.clear();
|
||||
lnameController.clear();
|
||||
});
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
bool isAppointmentFieldsFilled() {
|
||||
if (dateController.text.isEmpty || timeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void appointmentPopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
int index,
|
||||
double width,
|
||||
) {
|
||||
var firstLetterFName = patientManagerProvider.myPaitentList![index].fname;
|
||||
var firstLetterLName = patientManagerProvider.myPaitentList![index].lname;
|
||||
setState(() {
|
||||
idController.text = patientManagerProvider.myPaitentList![index].id_no;
|
||||
fnameController.text = firstLetterFName;
|
||||
lnameController.text = firstLetterLName;
|
||||
});
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Patient Appointment",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.056)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: idController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "ID No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: fnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "First Name",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: lnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Surname",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihDateField(
|
||||
controller: dateController,
|
||||
labelText: "Date",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTimeField(
|
||||
controller: timeController,
|
||||
labelText: "Time",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30.0),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
bool filled = isAppointmentFieldsFilled();
|
||||
if (filled) {
|
||||
submitApointment(
|
||||
profileProvider, patientManagerProvider, index);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Book Appointment",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void noAccessWarning(
|
||||
PatientManagerProvider patientManagerProvider, int index) {
|
||||
if (patientManagerProvider.myPaitentList![index].status == "pending") {
|
||||
MihAlertServices().warningAlert(
|
||||
"Access Pending",
|
||||
"Your access request is currently being reviewed.\nOnce approved, you'll be able to view patient data.\nPlease follow up with the patient to approve your access request.",
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
MihAlertServices().errorBasicAlert(
|
||||
"Access Declined",
|
||||
"Your request to access the patient's profile has been denied. Please contact the patient directly to inquire about the reason for this restriction.",
|
||||
context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool hasAccessToProfile(
|
||||
PatientManagerProvider patientManagerProvider, int index) {
|
||||
var hasAccess = false;
|
||||
|
||||
if (patientManagerProvider.myPaitentList![index].status == "approved") {
|
||||
hasAccess = true;
|
||||
} else {
|
||||
hasAccess = false;
|
||||
}
|
||||
return hasAccess;
|
||||
}
|
||||
|
||||
void patientProfileChoicePopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
int index,
|
||||
double width,
|
||||
) async {
|
||||
var firstLetterFName = patientManagerProvider.myPaitentList![index].fname;
|
||||
var firstLetterLName = patientManagerProvider.myPaitentList![index].lname;
|
||||
setState(() {
|
||||
idController.text = patientManagerProvider.myPaitentList![index].id_no;
|
||||
fnameController.text = firstLetterFName;
|
||||
lnameController.text = firstLetterLName;
|
||||
});
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Patient Profile",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: idController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "ID No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: fnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "First Name",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: lnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Surname",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 30.0),
|
||||
Center(
|
||||
child: Wrap(
|
||||
runAlignment: WrapAlignment.center,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
alignment: WrapAlignment.center,
|
||||
runSpacing: 10,
|
||||
spacing: 10,
|
||||
children: [
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
appointmentPopUp(profileProvider,
|
||||
patientManagerProvider, index, width);
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Book Appointment",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
MihButton(
|
||||
onPressed: () async {
|
||||
await MihPatientServices().getPatientDetails(
|
||||
patientManagerProvider.myPaitentList![index].app_id,
|
||||
patientManagerProvider);
|
||||
context.pop();
|
||||
context.pushNamed(
|
||||
'patientManagerPatient',
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"View Medical Records",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayMyPatientTile(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
int index,
|
||||
double width,
|
||||
) {
|
||||
var firstName = "";
|
||||
var lastName = "";
|
||||
String access =
|
||||
patientManagerProvider.myPaitentList![index].status.toUpperCase();
|
||||
TextSpan accessWithColour;
|
||||
var hasAccess = false;
|
||||
hasAccess = hasAccessToProfile(patientManagerProvider, index);
|
||||
//print(hasAccess);
|
||||
if (access == "APPROVED") {
|
||||
firstName = patientManagerProvider.myPaitentList![index].fname;
|
||||
lastName = patientManagerProvider.myPaitentList![index].lname;
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
} else if (access == "PENDING") {
|
||||
firstName =
|
||||
"${patientManagerProvider.myPaitentList![index].fname[0]}********";
|
||||
lastName =
|
||||
"${patientManagerProvider.myPaitentList![index].lname[0]}********";
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getGreyColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
} else {
|
||||
firstName =
|
||||
"${patientManagerProvider.myPaitentList![index].fname[0]}********";
|
||||
lastName =
|
||||
"${patientManagerProvider.myPaitentList![index].lname[0]}********";
|
||||
accessWithColour = TextSpan(
|
||||
text: "$access\n",
|
||||
style: TextStyle(
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")));
|
||||
}
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
"$firstName $lastName",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
text:
|
||||
"ID No.: ${patientManagerProvider.myPaitentList![index].id_no}\n",
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
children: <TextSpan>[
|
||||
const TextSpan(text: "Access: "),
|
||||
accessWithColour,
|
||||
]),
|
||||
),
|
||||
onTap: () async {
|
||||
if (hasAccess) {
|
||||
await MihPatientServices()
|
||||
.getPatientDetails(
|
||||
patientManagerProvider.myPaitentList![index].app_id,
|
||||
patientManagerProvider)
|
||||
.then((result) {});
|
||||
await MihUserServices()
|
||||
.getMIHUserDetails(
|
||||
patientManagerProvider.myPaitentList![index].app_id, context)
|
||||
.then((user) async {
|
||||
user;
|
||||
String url = await MihFileApi.getMinioFileUrl(user!.pro_pic_path);
|
||||
patientManagerProvider.setSelectedPatientProfilePicUrl(url);
|
||||
});
|
||||
patientProfileChoicePopUp(
|
||||
profileProvider, patientManagerProvider, index, width);
|
||||
} else {
|
||||
noAccessWarning(patientManagerProvider, index);
|
||||
}
|
||||
},
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
dateController.dispose();
|
||||
timeController.dispose();
|
||||
idController.dispose();
|
||||
fnameController.dispose();
|
||||
lnameController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: patientManagerProvider.myPaitentList!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return displayMyPatientTile(
|
||||
profileProvider, patientManagerProvider, index, screenWidth);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BuildWaitingRoomList extends StatefulWidget {
|
||||
const BuildWaitingRoomList({super.key});
|
||||
|
||||
@override
|
||||
State<BuildWaitingRoomList> createState() => _BuildWaitingRoomListState();
|
||||
}
|
||||
|
||||
class _BuildWaitingRoomListState extends State<BuildWaitingRoomList> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
|
||||
class PatManagerTile extends StatefulWidget {
|
||||
final PatManagerArguments arguments;
|
||||
final double packageSize;
|
||||
const PatManagerTile({
|
||||
super.key,
|
||||
required this.arguments,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatManagerTile> createState() => _PatManagerTileState();
|
||||
}
|
||||
|
||||
class _PatManagerTileState extends State<PatManagerTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
authenticateUser: true,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'patientManager',
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/patient-manager',
|
||||
// arguments: widget.arguments,
|
||||
// );
|
||||
},
|
||||
appName: "Patient Manager",
|
||||
appIcon: Icon(
|
||||
MihIcons.patientManager,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
textColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/patients.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/list_builders/build_mih_patient_search_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihPatientSearch extends StatefulWidget {
|
||||
const MihPatientSearch({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MihPatientSearch> createState() => _MihPatientSearchState();
|
||||
}
|
||||
|
||||
class _MihPatientSearchState extends State<MihPatientSearch> {
|
||||
TextEditingController _mihPatientSearchController = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
final FocusNode _searchFocusNode = FocusNode();
|
||||
bool hasSearchedBefore = false;
|
||||
String _mihPatientSearchString = "";
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
Widget getPatientSearch(double width) {
|
||||
return Consumer<PatientManagerProvider>(
|
||||
builder: (BuildContext context,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return Column(mainAxisSize: MainAxisSize.max, children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: _mihPatientSearchController,
|
||||
hintText: "Search Patient ID/ Aid No.",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
submitPatientSearch(patientManagerProvider);
|
||||
},
|
||||
onClearIconTap: () {
|
||||
setState(() {
|
||||
_mihPatientSearchController.clear();
|
||||
_mihPatientSearchString = "";
|
||||
});
|
||||
patientManagerProvider
|
||||
.setPatientSearchResults(patientSearchResults: []);
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
),
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
|
||||
displayPatientList(patientManagerProvider, _mihPatientSearchString),
|
||||
]);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<Patient> filterSearchResults(List<Patient> patList, String query) {
|
||||
List<Patient> templist = [];
|
||||
//print(query);
|
||||
for (var item in patList) {
|
||||
if (item.id_no.contains(_mihPatientSearchString) ||
|
||||
item.medical_aid_no.contains(_mihPatientSearchString)) {
|
||||
//print(item.medical_aid_no);
|
||||
templist.add(item);
|
||||
}
|
||||
}
|
||||
return templist;
|
||||
}
|
||||
|
||||
Widget displayPatientList(
|
||||
PatientManagerProvider patientManagerProvider, String searchString) {
|
||||
if (patientManagerProvider.patientSearchResults.isNotEmpty) {
|
||||
return Expanded(
|
||||
child: BuildMihPatientSearchList(),
|
||||
);
|
||||
} else if (patientManagerProvider.patientSearchResults.isEmpty &&
|
||||
searchString != "") {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Let's try refining your search",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.patientProfile,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Search for a Patient of Mzansi to add to your Patient List",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(
|
||||
text:
|
||||
"You can search using their ID Number or Medical Aid No."),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> submitPatientSearch(
|
||||
PatientManagerProvider patientManagerProvider) async {
|
||||
if (_mihPatientSearchController.text != "") {
|
||||
setState(() {
|
||||
_mihPatientSearchString = _mihPatientSearchController.text;
|
||||
hasSearchedBefore = true;
|
||||
});
|
||||
await MihPatientServices.searchPatients(
|
||||
patientManagerProvider, _mihPatientSearchString);
|
||||
}
|
||||
}
|
||||
|
||||
//Patient Access Widgets/ Functions
|
||||
List<PatientAccess> filterAccessResults(
|
||||
List<PatientAccess> patAccList, String query) {
|
||||
List<PatientAccess> templist = [];
|
||||
//print(query);
|
||||
for (var item in patAccList) {
|
||||
if (item.id_no.contains(query)) {
|
||||
//print(item.medical_aid_no);
|
||||
templist.add(item);
|
||||
}
|
||||
}
|
||||
return templist;
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
_mihPatientSearchController.dispose();
|
||||
_focusNode.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size size = MediaQuery.sizeOf(context);
|
||||
final double width = size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getPatientSearch(width),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/list_builders/build_my_patient_list_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyPatientList extends StatefulWidget {
|
||||
const MyPatientList({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MyPatientList> createState() => _MyPatientListState();
|
||||
}
|
||||
|
||||
class _MyPatientListState extends State<MyPatientList> {
|
||||
TextEditingController _myPatientSearchController = TextEditingController();
|
||||
final FocusNode _searchFocusNode = FocusNode();
|
||||
bool hasSearchedBefore = false;
|
||||
String _myPatientIdSearchString = "";
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
|
||||
Widget myPatientListTool(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, double width) {
|
||||
return Column(mainAxisSize: MainAxisSize.max, children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: width / 20),
|
||||
child: MihSearchBar(
|
||||
controller: _myPatientSearchController,
|
||||
hintText: "Search Patient ID",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
setState(() async {
|
||||
_myPatientIdSearchString = _myPatientSearchController.text;
|
||||
await MihPatientServices().getPatientAccessListOfBusiness(
|
||||
patientManagerProvider,
|
||||
profileProvider.business!.business_id);
|
||||
});
|
||||
},
|
||||
onClearIconTap: () {
|
||||
setState(() {
|
||||
_myPatientSearchController.clear();
|
||||
_myPatientIdSearchString = "";
|
||||
});
|
||||
getMyPatientList(profileProvider, patientManagerProvider);
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
),
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
displayMyPatientList(patientManagerProvider),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget displayMyPatientList(PatientManagerProvider patientManagerProvider) {
|
||||
if (patientManagerProvider.myPaitentList!.isNotEmpty) {
|
||||
return Expanded(child: BuildMyPatientListList());
|
||||
}
|
||||
if (hasSearchedBefore && _myPatientIdSearchString.isNotEmpty) {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.iDontKnow,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"Let's try refining your search",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.patientProfile,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"You dont have access to any Patients Profile",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.search,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
" to use Patient Search to request access to their profile."),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.only(top: 35.0),
|
||||
// child: Center(
|
||||
// child: Text(
|
||||
// "No Patients matching search",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// color: MihColors.getGreyColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
// textAlign: TextAlign.center,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
List<PatientAccess> filterAccessResults(
|
||||
List<PatientAccess> patAccList, String query) {
|
||||
List<PatientAccess> templist = [];
|
||||
for (var item in patAccList) {
|
||||
if (item.id_no.contains(query)) {
|
||||
templist.add(item);
|
||||
}
|
||||
}
|
||||
return templist;
|
||||
}
|
||||
|
||||
Future<void> getMyPatientList(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider) async {
|
||||
await MihPatientServices().getPatientAccessListOfBusiness(
|
||||
patientManagerProvider, profileProvider.business!.business_id);
|
||||
setState(() {
|
||||
hasSearchedBefore = true;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_myPatientSearchController.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
_focusNode.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Size size = MediaQuery.sizeOf(context);
|
||||
final double width = size.width;
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem:
|
||||
myPatientListTool(profileProvider, patientManagerProvider, width),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,558 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_calendar_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_calendar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_date_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_time_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/appointment.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/calendar/builder/build_appointment_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class WaitingRoom extends StatefulWidget {
|
||||
const WaitingRoom({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<WaitingRoom> createState() => _WaitingRoomState();
|
||||
}
|
||||
|
||||
class _WaitingRoomState extends State<WaitingRoom> {
|
||||
TextEditingController selectedAppointmentDateController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentTitleController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentDescriptionIDController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentDateController =
|
||||
TextEditingController();
|
||||
final TextEditingController _appointmentTimeController =
|
||||
TextEditingController();
|
||||
final TextEditingController _patientController = TextEditingController();
|
||||
String baseUrl = AppEnviroment.baseApiUrl;
|
||||
|
||||
late Future<List<Appointment>> businessAppointmentResults;
|
||||
late Future<List<Appointment>> appointmentResults;
|
||||
bool inWaitingRoom = true;
|
||||
bool isLoading = true;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
// Business Appointment Tool
|
||||
Widget getBusinessAppointmentsTool(double width) {
|
||||
return Consumer3<MzansiProfileProvider, PatientManagerProvider,
|
||||
MihCalendarProvider>(
|
||||
builder: (BuildContext context,
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
Widget? child) {
|
||||
if (isLoading) {
|
||||
return const Center(
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
}
|
||||
return Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
MIHCalendar(
|
||||
calendarWidth: 500,
|
||||
rowHeight: 35,
|
||||
setDate: (value) {
|
||||
mihCalendarProvider.setSelectedDay(value);
|
||||
setState(() {
|
||||
selectedAppointmentDateController.text = value;
|
||||
});
|
||||
}),
|
||||
// Divider(
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
displayAppointmentList(mihCalendarProvider)
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Add Appointment",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
// addAppointmentWindow();
|
||||
appointmentTypeSelection(profileProvider,
|
||||
patientManagerProvider, mihCalendarProvider, width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayAppointmentList(MihCalendarProvider mihCalendarProvider) {
|
||||
if (mihCalendarProvider.businessAppointments!.isNotEmpty) {
|
||||
return Expanded(
|
||||
child: BuildAppointmentList(
|
||||
inWaitingRoom: true,
|
||||
titleController: _appointmentTitleController,
|
||||
descriptionIDController: _appointmentDescriptionIDController,
|
||||
patientIdController: _patientController,
|
||||
dateController: _appointmentDateController,
|
||||
timeController: _appointmentTimeController,
|
||||
),
|
||||
);
|
||||
}
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Icon(
|
||||
MihIcons.calendar,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No Appointments for ${mihCalendarProvider.selectedDay}",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text:
|
||||
" to add an appointment or select a different date"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
// return Expanded(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(top: 35.0),
|
||||
// child: Align(
|
||||
// alignment: Alignment.center,
|
||||
// child: Text(
|
||||
// "No Appointments for $selectedDay",
|
||||
// style: TextStyle(
|
||||
// fontSize: 25,
|
||||
// color: MihColors.getGreyColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
// textAlign: TextAlign.center,
|
||||
// softWrap: true,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
void appointmentTypeSelection(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
MihCalendarProvider mihCalendarProvider,
|
||||
double width) {
|
||||
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 MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Appointment Type",
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
Text(
|
||||
question,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
patientManagerProvider.setPatientManagerIndex(1);
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Existing Patient",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
patientManagerProvider.setPatientManagerIndex(2);
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Existing MIH User",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
addAppointmentWindow(
|
||||
profileProvider, mihCalendarProvider, width);
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Skeleton Appointment",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void addAppointmentWindow(MzansiProfileProvider profileProvider,
|
||||
MihCalendarProvider mihCalendarProvider, double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Add Appointment",
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
_appointmentDateController.clear();
|
||||
_appointmentTimeController.clear();
|
||||
_appointmentTitleController.clear();
|
||||
_appointmentDescriptionIDController.clear();
|
||||
_patientController.clear();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _appointmentTitleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Appointment Title",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihDateField(
|
||||
controller: _appointmentDateController,
|
||||
labelText: "Date",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTimeField(
|
||||
controller: _appointmentTimeController,
|
||||
labelText: "Time",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
height: 250,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: _appointmentDescriptionIDController,
|
||||
multiLineInput: true,
|
||||
requiredText: true,
|
||||
hintText: "Description",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addAppointmentCall(
|
||||
profileProvider, mihCalendarProvider);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Add",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> addAppointmentCall(MzansiProfileProvider profileProvider,
|
||||
MihCalendarProvider mihCalendarProvider) async {
|
||||
if (isAppointmentInputValid()) {
|
||||
int statusCode;
|
||||
statusCode = await MihMzansiCalendarApis.addBusinessAppointment(
|
||||
profileProvider.user!,
|
||||
profileProvider.business!,
|
||||
profileProvider.businessUser!,
|
||||
true,
|
||||
_appointmentTitleController.text,
|
||||
_appointmentDescriptionIDController.text,
|
||||
_appointmentDateController.text,
|
||||
_appointmentTimeController.text,
|
||||
mihCalendarProvider,
|
||||
context,
|
||||
);
|
||||
|
||||
if (statusCode == 201) {
|
||||
context.pop();
|
||||
successPopUp("Successfully Added Appointment",
|
||||
"You appointment has been successfully added to your calendar.");
|
||||
_loadInitialAppointments();
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
checkforchange();
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
setState(() {
|
||||
_appointmentDateController.clear();
|
||||
_appointmentTimeController.clear();
|
||||
_appointmentTitleController.clear();
|
||||
_appointmentDescriptionIDController.clear();
|
||||
});
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
bool isAppointmentInputValid() {
|
||||
if (_appointmentDescriptionIDController.text.isEmpty ||
|
||||
_appointmentDateController.text.isEmpty ||
|
||||
_appointmentTimeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void checkforchange() {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
_loadInitialAppointments();
|
||||
}
|
||||
|
||||
Future<void> _loadInitialAppointments() async {
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
MihCalendarProvider mihCalendarProvider =
|
||||
context.read<MihCalendarProvider>();
|
||||
await MihMzansiCalendarApis.getBusinessAppointments(
|
||||
mzansiProfileProvider.business!.business_id,
|
||||
false,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
selectedAppointmentDateController.dispose();
|
||||
_appointmentDateController.dispose();
|
||||
_appointmentTimeController.dispose();
|
||||
_appointmentTitleController.dispose();
|
||||
_appointmentDescriptionIDController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
selectedAppointmentDateController.addListener(checkforchange);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadInitialAppointments();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBusinessAppointmentsTool(screenWidth),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_calendar_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/package_tools/mih_patient_search.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/package_tools/my_patient_list.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/package_tools/waiting_room.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_data_helper_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_calendar_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatManager extends StatefulWidget {
|
||||
const PatManager({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatManager> createState() => _PatManagerState();
|
||||
}
|
||||
|
||||
class _PatManagerState extends State<PatManager> {
|
||||
bool _isLoadingInitialData = true;
|
||||
late final WaitingRoom _waitingRoom;
|
||||
late final MyPatientList _myPatientList;
|
||||
late final MihPatientSearch _mihPatientSearch;
|
||||
|
||||
Future<void> _loadInitialData() async {
|
||||
setState(() {
|
||||
_isLoadingInitialData = true;
|
||||
});
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
MihCalendarProvider mihCalendarProvider =
|
||||
context.read<MihCalendarProvider>();
|
||||
if (mzansiProfileProvider.user == null) {
|
||||
await MihDataHelperServices().loadUserDataWithBusinessesData(
|
||||
mzansiProfileProvider,
|
||||
);
|
||||
}
|
||||
patientManagerProvider.setPersonalMode(false);
|
||||
if (mzansiProfileProvider.business != null) {
|
||||
await MihMzansiCalendarApis.getBusinessAppointments(
|
||||
mzansiProfileProvider.business!.business_id,
|
||||
false,
|
||||
mihCalendarProvider.selectedDay,
|
||||
mihCalendarProvider,
|
||||
);
|
||||
await MihPatientServices().getPatientAccessListOfBusiness(
|
||||
patientManagerProvider, mzansiProfileProvider.business!.business_id);
|
||||
}
|
||||
setState(() {
|
||||
_isLoadingInitialData = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_waitingRoom = WaitingRoom();
|
||||
_myPatientList = MyPatientList();
|
||||
_mihPatientSearch = MihPatientSearch();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadInitialData();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<PatientManagerProvider>(
|
||||
builder:
|
||||
(BuildContext context, PatientManagerProvider value, Widget? child) {
|
||||
if (_isLoadingInitialData) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Mihloadingcircle(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return MihPackage(
|
||||
appActionButton: getActionButton(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex:
|
||||
context.watch<PatientManagerProvider>().patientManagerIndex,
|
||||
onIndexChange: (newValue) {
|
||||
context
|
||||
.read<PatientManagerProvider>()
|
||||
.setPatientManagerIndex(newValue);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getActionButton() {
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
patientManagerProvider.setPatientProfileIndex(0);
|
||||
patientManagerProvider.setPatientManagerIndex(0);
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.calendar_month)] = () {
|
||||
context.read<PatientManagerProvider>().setPatientManagerIndex(0);
|
||||
};
|
||||
temp[const Icon(Icons.check_box_outlined)] = () {
|
||||
context.read<PatientManagerProvider>().setPatientManagerIndex(1);
|
||||
};
|
||||
|
||||
temp[const Icon(Icons.search)] = () {
|
||||
context
|
||||
.read<PatientManagerProvider>()
|
||||
.setPatientSearchResults(patientSearchResults: []);
|
||||
context.read<PatientManagerProvider>().setPatientManagerIndex(2);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex:
|
||||
context.watch<PatientManagerProvider>().patientManagerIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
return [
|
||||
_waitingRoom,
|
||||
_myPatientList,
|
||||
_mihPatientSearch,
|
||||
];
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Waiting Room",
|
||||
"My Patients",
|
||||
"Search Patients",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,557 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_claim_statement_generation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_icd10_code_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_date_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_radio_options.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/icd10_code.dart.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/icd10_search_window.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class ClaimStatementWindow extends StatefulWidget {
|
||||
const ClaimStatementWindow({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ClaimStatementWindow> createState() => _ClaimStatementWindowState();
|
||||
}
|
||||
|
||||
class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
||||
final TextEditingController _docTypeController = TextEditingController();
|
||||
final TextEditingController _fullNameController = TextEditingController();
|
||||
final TextEditingController _idController = TextEditingController();
|
||||
final TextEditingController _medAidController = TextEditingController();
|
||||
final TextEditingController _medAidNoController = TextEditingController();
|
||||
final TextEditingController _medAidCodeController = TextEditingController();
|
||||
final TextEditingController _medAidNameController = TextEditingController();
|
||||
final TextEditingController _medAidSchemeController = TextEditingController();
|
||||
final TextEditingController _providerNameController = TextEditingController();
|
||||
final TextEditingController _practiceNoController = TextEditingController();
|
||||
final TextEditingController _vatNoController = TextEditingController();
|
||||
final TextEditingController _serviceDateController = TextEditingController();
|
||||
final TextEditingController _serviceDescController = TextEditingController();
|
||||
final TextEditingController _serviceDescOptionsController =
|
||||
TextEditingController();
|
||||
final TextEditingController _prcedureNameController = TextEditingController();
|
||||
// final TextEditingController _procedureDateController =
|
||||
// TextEditingController();
|
||||
final TextEditingController _proceedureAdditionalInfoController =
|
||||
TextEditingController();
|
||||
final TextEditingController _icd10CodeController = TextEditingController();
|
||||
final TextEditingController _amountController = TextEditingController();
|
||||
final TextEditingController _preauthNoController = TextEditingController();
|
||||
final ValueNotifier<String> serviceDesc = ValueNotifier("");
|
||||
final ValueNotifier<String> medAid = ValueNotifier("");
|
||||
List<ICD10Code> icd10codeList = [];
|
||||
final FocusNode _searchFocusNode = FocusNode();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
void icd10SearchWindow(List<ICD10Code> codeList) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => ICD10SearchWindow(
|
||||
icd10CodeController: _icd10CodeController,
|
||||
icd10codeList: codeList,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getWindowBody(double width) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihRadioOptions(
|
||||
controller: _docTypeController,
|
||||
hintText: "Document Type",
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
requiredText: true,
|
||||
radioOptions: const ["Claim", "Statement"],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: Text(
|
||||
"Service Details",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
const SizedBox(height: 10),
|
||||
MihDateField(
|
||||
controller: _serviceDateController,
|
||||
labelText: "Date of Service",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihRadioOptions(
|
||||
controller: _serviceDescController,
|
||||
hintText: "Serviced Description",
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
requiredText: true,
|
||||
radioOptions: const [
|
||||
"Consultation",
|
||||
"Procedure",
|
||||
"Other",
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: serviceDesc,
|
||||
builder:
|
||||
(BuildContext context, String value, Widget? child) {
|
||||
Widget returnWidget;
|
||||
switch (value) {
|
||||
case 'Consultation':
|
||||
returnWidget = Column(
|
||||
key: const ValueKey(
|
||||
'consultation_fields'), // Added key
|
||||
children: [
|
||||
MihRadioOptions(
|
||||
key: const ValueKey(
|
||||
'consultation_type_dropdown'),
|
||||
controller: _serviceDescOptionsController,
|
||||
hintText: "Consultation Type",
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
requiredText: true,
|
||||
radioOptions: const [
|
||||
"General Consultation",
|
||||
"Follow-Up Consultation",
|
||||
"Specialist Consultation",
|
||||
"Emergency Consultation",
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
break;
|
||||
case 'Procedure':
|
||||
returnWidget = Column(
|
||||
key:
|
||||
const ValueKey('procedure_fields'), // Added key
|
||||
children: [
|
||||
MihTextFormField(
|
||||
key: const ValueKey(
|
||||
'procedure_name_field'), // Added key
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: _prcedureNameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Procedure Name",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
key: const ValueKey(
|
||||
'procedure_additional_info_field'), // Added key
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: _proceedureAdditionalInfoController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Additional Procedure Information",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
],
|
||||
);
|
||||
break;
|
||||
case 'Other':
|
||||
returnWidget = Column(
|
||||
key: const ValueKey('other_fields'), // Added key
|
||||
children: [
|
||||
MihTextFormField(
|
||||
key: const ValueKey(
|
||||
'other_service_description_field'), // Added key
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: _serviceDescOptionsController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Service Description Details",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
break;
|
||||
default:
|
||||
returnWidget = const SizedBox(
|
||||
key: const ValueKey('empty_fields')); // Added key
|
||||
}
|
||||
return returnWidget;
|
||||
},
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text("ICD-10 Code & Description",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
)),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
MihSearchBar(
|
||||
controller: _icd10CodeController,
|
||||
hintText: "ICD-10 Search",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onPrefixIconTap: () {
|
||||
MIHIcd10CodeApis.getIcd10Codes(
|
||||
_icd10CodeController.text, context)
|
||||
.then((result) {
|
||||
icd10SearchWindow(result);
|
||||
});
|
||||
},
|
||||
onClearIconTap: () {
|
||||
_icd10CodeController.clear();
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: _amountController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
numberMode: true,
|
||||
hintText: "Service Cost",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Center(
|
||||
child: Text(
|
||||
"Additional Infomation",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
const SizedBox(height: 10),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: _preauthNoController,
|
||||
multiLineInput: false,
|
||||
requiredText: false,
|
||||
hintText: "Pre-authorisation No.",
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
if (isInputValid()) {
|
||||
MIHClaimStatementGenerationApi()
|
||||
.generateClaimStatement(
|
||||
profileProvider,
|
||||
patientManagerProvider,
|
||||
ClaimStatementGenerationArguments(
|
||||
_docTypeController.text,
|
||||
patientManagerProvider
|
||||
.selectedPatient!.app_id,
|
||||
_fullNameController.text,
|
||||
_idController.text,
|
||||
_medAidController.text,
|
||||
_medAidNoController.text,
|
||||
_medAidCodeController.text,
|
||||
_medAidNameController.text,
|
||||
_medAidSchemeController.text,
|
||||
profileProvider.business!.Name,
|
||||
"*To-Be Added*",
|
||||
profileProvider.business!.contact_no,
|
||||
profileProvider.business!.bus_email,
|
||||
_providerNameController.text,
|
||||
_practiceNoController.text,
|
||||
_vatNoController.text,
|
||||
_serviceDateController.text,
|
||||
_serviceDescController.text,
|
||||
_serviceDescOptionsController.text,
|
||||
_prcedureNameController.text,
|
||||
_proceedureAdditionalInfoController.text,
|
||||
_icd10CodeController.text,
|
||||
_amountController.text,
|
||||
_preauthNoController.text,
|
||||
profileProvider.business!.logo_path,
|
||||
profileProvider.businessUser!.sig_path,
|
||||
),
|
||||
AppEnviroment.getEnv(),
|
||||
context);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Generate",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void serviceDescriptionSelected() {
|
||||
String selectedType = _serviceDescController.text;
|
||||
serviceDesc.value = selectedType;
|
||||
if (selectedType == 'Consultation') {
|
||||
_prcedureNameController.clear();
|
||||
_proceedureAdditionalInfoController.clear();
|
||||
} else if (selectedType == 'Procedure') {
|
||||
_serviceDescOptionsController.clear();
|
||||
} else if (selectedType == 'Other') {
|
||||
_prcedureNameController.clear();
|
||||
_proceedureAdditionalInfoController.clear();
|
||||
} else {
|
||||
_prcedureNameController.clear();
|
||||
_proceedureAdditionalInfoController.clear();
|
||||
_serviceDescOptionsController.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void hasMedAid() {
|
||||
if (_medAidController.text.isNotEmpty) {
|
||||
} else {
|
||||
medAid.value = "";
|
||||
}
|
||||
}
|
||||
|
||||
bool isInputValid() {
|
||||
if (_docTypeController.text.isEmpty ||
|
||||
_serviceDateController.text.isEmpty ||
|
||||
_icd10CodeController.text.isEmpty ||
|
||||
_amountController.text.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
switch (_serviceDescController.text) {
|
||||
case 'Consultation':
|
||||
case 'Other':
|
||||
if (_serviceDescOptionsController.text.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 'Procedure':
|
||||
if (_prcedureNameController.text.isEmpty ||
|
||||
_proceedureAdditionalInfoController.text.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
String getUserTitle(MzansiProfileProvider profileProvider) {
|
||||
if (profileProvider.businessUser!.title == "Doctor") {
|
||||
return "Dr.";
|
||||
} else {
|
||||
return profileProvider.businessUser!.title;
|
||||
}
|
||||
}
|
||||
|
||||
String getTodayDate() {
|
||||
DateTime today = DateTime.now();
|
||||
return DateFormat('yyyy-MM-dd').format(today);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_docTypeController.dispose();
|
||||
_fullNameController.dispose();
|
||||
_idController.dispose();
|
||||
_medAidController.dispose();
|
||||
_medAidNoController.dispose();
|
||||
_medAidCodeController.dispose();
|
||||
_medAidNameController.dispose();
|
||||
_medAidSchemeController.dispose();
|
||||
_providerNameController.dispose();
|
||||
_practiceNoController.dispose();
|
||||
_vatNoController.dispose();
|
||||
_serviceDateController.dispose();
|
||||
_serviceDescController.dispose();
|
||||
_serviceDescOptionsController.dispose();
|
||||
_prcedureNameController.dispose();
|
||||
// _procedureDateController.dispose();
|
||||
_proceedureAdditionalInfoController.dispose();
|
||||
_icd10CodeController.dispose();
|
||||
_preauthNoController.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
serviceDesc.dispose();
|
||||
medAid.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
_serviceDescController.text = "Consultation";
|
||||
_serviceDescController.addListener(serviceDescriptionSelected);
|
||||
serviceDesc.value = "Consultation";
|
||||
_medAidController.addListener(hasMedAid);
|
||||
_fullNameController.text =
|
||||
"${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}";
|
||||
_idController.text = patientManagerProvider.selectedPatient!.id_no;
|
||||
_medAidController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid;
|
||||
_medAidNameController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_name;
|
||||
_medAidCodeController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_code;
|
||||
_medAidNoController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_no;
|
||||
_medAidSchemeController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_scheme;
|
||||
_serviceDateController.text = getTodayDate();
|
||||
_providerNameController.text =
|
||||
"${getUserTitle(profileProvider)} ${profileProvider.user!.fname} ${profileProvider.user!.lname}";
|
||||
_practiceNoController.text = profileProvider.business!.practice_no;
|
||||
_vatNoController.text = profileProvider.business!.vat_no;
|
||||
hasMedAid();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Generate Claim/ Statement Document",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: getWindowBody(screenWidth),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/icd10_code.dart.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_icd10_code_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ICD10SearchWindow extends StatefulWidget {
|
||||
final TextEditingController icd10CodeController;
|
||||
final List<ICD10Code> icd10codeList;
|
||||
const ICD10SearchWindow({
|
||||
super.key,
|
||||
required this.icd10CodeController,
|
||||
required this.icd10codeList,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ICD10SearchWindow> createState() => _ICD10SearchWindowState();
|
||||
}
|
||||
|
||||
class _ICD10SearchWindowState extends State<ICD10SearchWindow> {
|
||||
Widget getWindowBody() {
|
||||
return Column(
|
||||
children: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: widget.icd10CodeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
numberMode: true,
|
||||
hintText: "ICD-10 Code Searched",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Text(
|
||||
"Search for ICD-10 Codes",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
BuildICD10CodeList(
|
||||
icd10CodeController: widget.icd10CodeController,
|
||||
icd10codeList: widget.icd10codeList,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "ICD-10 Search",
|
||||
onWindowTapClose: () {
|
||||
// medicineController.clear();
|
||||
// quantityController.clear();
|
||||
// dosageController.clear();
|
||||
// timesDailyController.clear();
|
||||
// noDaysController.clear();
|
||||
// noRepeatsController.clear();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: getWindowBody(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import 'dart:convert';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/medicine.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_med_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MedicineSearch extends StatefulWidget {
|
||||
final TextEditingController searchVlaue;
|
||||
const MedicineSearch({
|
||||
super.key,
|
||||
required this.searchVlaue,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MedicineSearch> createState() => _MedicineSearchState();
|
||||
}
|
||||
|
||||
class _MedicineSearchState extends State<MedicineSearch> {
|
||||
final String endpointMeds = "${AppEnviroment.baseApiUrl}/users/medicine/";
|
||||
|
||||
//TextEditingController searchController = TextEditingController();
|
||||
|
||||
late Future<List<Medicine>> futueMeds;
|
||||
//String searchString = "";
|
||||
|
||||
Future<List<Medicine>> getMedList(String endpoint) async {
|
||||
final response = await http.get(Uri.parse(endpoint));
|
||||
if (response.statusCode == 200) {
|
||||
Iterable l = jsonDecode(response.body);
|
||||
List<Medicine> medicines =
|
||||
List<Medicine>.from(l.map((model) => Medicine.fromJson(model)));
|
||||
// List<Medicine> meds = [];
|
||||
// medicines.forEach((element) => meds.add(element.name));
|
||||
return medicines;
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
throw Exception('failed to load medicine');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
futueMeds = getMedList(endpointMeds + widget.searchVlaue.text);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Select Medicine",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
FutureBuilder(
|
||||
future: futueMeds,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const SizedBox(
|
||||
height: 400,
|
||||
child: Mihloadingcircle(),
|
||||
);
|
||||
} else if (snapshot.hasData && snapshot.data!.isNotEmpty) {
|
||||
final medsList = snapshot.data!;
|
||||
return SizedBox(
|
||||
height: 400,
|
||||
child: BuildMedicinesList(
|
||||
contoller: widget.searchVlaue,
|
||||
medicines: medsList,
|
||||
//searchString: searchString,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return const SizedBox(
|
||||
height: 400,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No Match Found\nPlease close and manually capture medicine",
|
||||
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,518 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_toggle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MihEditPatientDetailsWindow extends StatefulWidget {
|
||||
const MihEditPatientDetailsWindow({super.key});
|
||||
|
||||
@override
|
||||
State<MihEditPatientDetailsWindow> createState() =>
|
||||
_MihEditPatientDetailsWindowState();
|
||||
}
|
||||
|
||||
class _MihEditPatientDetailsWindowState
|
||||
extends State<MihEditPatientDetailsWindow> {
|
||||
var idController = TextEditingController();
|
||||
final fnameController = TextEditingController();
|
||||
final lnameController = TextEditingController();
|
||||
final cellController = TextEditingController();
|
||||
final emailController = TextEditingController();
|
||||
final medNoController = TextEditingController();
|
||||
final medNameController = TextEditingController();
|
||||
final medSchemeController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final medAidController = TextEditingController();
|
||||
final medMainMemController = TextEditingController();
|
||||
final medAidCodeController = TextEditingController();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
late bool medAidPosition;
|
||||
late bool medMainMemberPosition;
|
||||
final ValueNotifier<bool> medRequired = ValueNotifier(false);
|
||||
|
||||
Future<void> updatePatientApiCall(
|
||||
PatientManagerProvider patientManagerProvider) async {
|
||||
var statusCode = await MihPatientServices().updatePatientService(
|
||||
patientManagerProvider.selectedPatient!.app_id,
|
||||
idController.text,
|
||||
fnameController.text,
|
||||
lnameController.text,
|
||||
emailController.text,
|
||||
cellController.text,
|
||||
medAidController.text,
|
||||
medMainMemController.text,
|
||||
medNoController.text,
|
||||
medAidCodeController.text,
|
||||
medNameController.text,
|
||||
medSchemeController.text,
|
||||
addressController.text,
|
||||
patientManagerProvider,
|
||||
);
|
||||
if (statusCode == 200) {
|
||||
successPopUp(
|
||||
"Successfully Updated Profile!",
|
||||
"${fnameController.text} ${lnameController.text}'s information has been updated successfully! Their medical records and details are now current.",
|
||||
);
|
||||
} else {
|
||||
MihAlertServices().errorBasicAlert(
|
||||
"Error Updating Profile",
|
||||
"There was an error updating your profile. Please try again later.",
|
||||
context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayForm(
|
||||
PatientManagerProvider patientManagerProvider, double width) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Personal",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25.0,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: idController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "ID No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: fnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "First Name",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: lnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Surname",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: cellController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Cell No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: emailController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Email",
|
||||
validator: (value) {
|
||||
return MihValidationServices().validateEmail(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
height: 100,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: addressController,
|
||||
multiLineInput: true,
|
||||
requiredText: true,
|
||||
hintText: "Address",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
Center(
|
||||
child: Text(
|
||||
"Medical Aid Details",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25.0,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
||||
const SizedBox(height: 10.0),
|
||||
MihToggle(
|
||||
hintText: "Medical Aid",
|
||||
initialPostion: medAidPosition,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onChange: (value) {
|
||||
if (value) {
|
||||
setState(() {
|
||||
medAidController.text = "Yes";
|
||||
medAidPosition = value;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
medAidController.text = "No";
|
||||
medAidPosition = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: medRequired,
|
||||
builder: (BuildContext context, bool value, Widget? child) {
|
||||
return Visibility(
|
||||
visible: value,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10.0),
|
||||
MihToggle(
|
||||
hintText: "Main Member",
|
||||
initialPostion: medMainMemberPosition,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onChange: (value) {
|
||||
if (value) {
|
||||
setState(() {
|
||||
medMainMemController.text = "Yes";
|
||||
medMainMemberPosition = value;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
medMainMemController.text = "No";
|
||||
medMainMemberPosition = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: medNoController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "No.",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: medAidCodeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Code",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: medNameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Name",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: medSchemeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Plan",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
updatePatientApiCall(patientManagerProvider);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Update",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void isRequired() {
|
||||
if (medAidController.text == "Yes") {
|
||||
medRequired.value = true;
|
||||
} else if (medAidController.text == "No") {
|
||||
medRequired.value = false;
|
||||
} else {}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
idController.dispose();
|
||||
fnameController.dispose();
|
||||
lnameController.dispose();
|
||||
cellController.dispose();
|
||||
emailController.dispose();
|
||||
medNoController.dispose();
|
||||
medNameController.dispose();
|
||||
medSchemeController.dispose();
|
||||
addressController.dispose();
|
||||
medAidController.dispose();
|
||||
medAidCodeController.removeListener(isRequired);
|
||||
medMainMemController.dispose();
|
||||
medAidCodeController.dispose();
|
||||
medRequired.dispose();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
medAidController.addListener(isRequired);
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
setState(() {
|
||||
idController.text = patientManagerProvider.selectedPatient!.id_no;
|
||||
fnameController.text = patientManagerProvider.selectedPatient!.first_name;
|
||||
lnameController.text = patientManagerProvider.selectedPatient!.last_name;
|
||||
cellController.text = patientManagerProvider.selectedPatient!.cell_no;
|
||||
emailController.text = patientManagerProvider.selectedPatient!.email;
|
||||
medNameController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_name;
|
||||
medNoController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_no;
|
||||
medSchemeController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_scheme;
|
||||
addressController.text = patientManagerProvider.selectedPatient!.address;
|
||||
medAidController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid;
|
||||
medMainMemController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_main_member;
|
||||
medAidCodeController.text =
|
||||
patientManagerProvider.selectedPatient!.medical_aid_code;
|
||||
});
|
||||
if (medAidController.text == "Yes") {
|
||||
medAidPosition = true;
|
||||
} else {
|
||||
medAidPosition = false;
|
||||
medAidController.text = "No";
|
||||
}
|
||||
if (medMainMemController.text == "Yes") {
|
||||
medMainMemberPosition = true;
|
||||
} else {
|
||||
medMainMemberPosition = false;
|
||||
medMainMemController.text = "No";
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Edit Patient Details",
|
||||
onWindowTapClose: () {
|
||||
context.pop();
|
||||
},
|
||||
windowBody: getBody(size.width),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Consumer<PatientManagerProvider>(
|
||||
builder: (BuildContext context,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return KeyboardListener(
|
||||
focusNode: _focusNode,
|
||||
autofocus: true,
|
||||
onKeyEvent: (event) async {
|
||||
if (event is KeyDownEvent &&
|
||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
updatePatientApiCall(patientManagerProvider);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: displayForm(patientManagerProvider, width),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,580 @@
|
||||
import 'dart:convert';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_numeric_stepper.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_search_bar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/medicine_search.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.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_objects/patients.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/perscription.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class PrescripInput extends StatefulWidget {
|
||||
final TextEditingController medicineController;
|
||||
final TextEditingController quantityController;
|
||||
final TextEditingController dosageController;
|
||||
final TextEditingController timesDailyController;
|
||||
final TextEditingController noDaysController;
|
||||
final TextEditingController noRepeatsController;
|
||||
final TextEditingController outputController;
|
||||
final Patient selectedPatient;
|
||||
final AppUser signedInUser;
|
||||
final Business? business;
|
||||
final BusinessUser? businessUser;
|
||||
final String env;
|
||||
const PrescripInput({
|
||||
super.key,
|
||||
required this.medicineController,
|
||||
required this.quantityController,
|
||||
required this.dosageController,
|
||||
required this.timesDailyController,
|
||||
required this.noDaysController,
|
||||
required this.noRepeatsController,
|
||||
required this.outputController,
|
||||
required this.selectedPatient,
|
||||
required this.signedInUser,
|
||||
required this.business,
|
||||
required this.businessUser,
|
||||
required this.env,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PrescripInput> createState() => _PrescripInputState();
|
||||
}
|
||||
|
||||
class _PrescripInputState extends State<PrescripInput> {
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
final FocusNode _searchFocusNode = FocusNode();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
List<Perscription> perscriptionObjOutput = [];
|
||||
late double width;
|
||||
late double height;
|
||||
|
||||
final numberOptions = [
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"16",
|
||||
"17",
|
||||
"18",
|
||||
"19",
|
||||
"20",
|
||||
"21",
|
||||
"22",
|
||||
"23",
|
||||
"24",
|
||||
"25",
|
||||
"26",
|
||||
"27",
|
||||
"28",
|
||||
"29",
|
||||
"30"
|
||||
];
|
||||
|
||||
Future<void> generatePerscription(
|
||||
PatientManagerProvider patManProvider,
|
||||
) async {
|
||||
//start loading circle
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
DateTime now = DateTime.now();
|
||||
// DateTime date = new DateTime(now.year, now.month, now.day);
|
||||
String fileName =
|
||||
"Perscription-${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}-${now.toString().substring(0, 19)}.pdf"
|
||||
.replaceAll(RegExp(r' '), '-');
|
||||
var response1 = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/minio/generate/perscription/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"app_id": widget.selectedPatient.app_id,
|
||||
"env": widget.env,
|
||||
"patient_full_name":
|
||||
"${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}",
|
||||
"fileName": fileName,
|
||||
"id_no": widget.selectedPatient.id_no,
|
||||
"docfname":
|
||||
"DR. ${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
||||
"busName": widget.business!.Name,
|
||||
"busAddr": "*TO BE ADDED IN THE FUTURE*",
|
||||
"busNo": widget.business!.contact_no,
|
||||
"busEmail": widget.business!.bus_email,
|
||||
"logo_path": widget.business!.logo_path,
|
||||
"sig_path": widget.businessUser!.sig_path,
|
||||
"data": perscriptionObjOutput,
|
||||
}),
|
||||
);
|
||||
//print(response1.statusCode);
|
||||
if (response1.statusCode == 200) {
|
||||
var response2 = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/patient_files/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"file_path":
|
||||
"${widget.selectedPatient.app_id}/patient_files/$fileName",
|
||||
"file_name": fileName,
|
||||
"app_id": widget.selectedPatient.app_id
|
||||
}),
|
||||
);
|
||||
//print(response2.statusCode);
|
||||
if (response2.statusCode == 201) {
|
||||
//To do
|
||||
widget.medicineController.clear();
|
||||
widget.dosageController.clear();
|
||||
widget.timesDailyController.clear();
|
||||
widget.noDaysController.clear();
|
||||
widget.timesDailyController.clear();
|
||||
widget.noRepeatsController.clear();
|
||||
widget.quantityController.clear();
|
||||
widget.outputController.clear();
|
||||
// futueFiles = fetchFiles();
|
||||
// end loading circle
|
||||
context.pop();
|
||||
context.pop();
|
||||
String message =
|
||||
"The perscription $fileName has been successfully generated and added to ${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}'s record. You can now access and download it for their use.";
|
||||
|
||||
await MihPatientServices().getPatientDocuments(patManProvider);
|
||||
MihAlertServices().successBasicAlert(
|
||||
"Success!",
|
||||
message,
|
||||
context,
|
||||
);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
void getMedsPopUp(TextEditingController medSearch) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MedicineSearch(
|
||||
searchVlaue: medSearch,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
bool isFieldsFilled() {
|
||||
if (widget.medicineController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void updatePerscriptionList() {
|
||||
String name;
|
||||
String unit;
|
||||
String form;
|
||||
List<String> medNameList = widget.medicineController.text.split("%t");
|
||||
if (medNameList.length == 1) {
|
||||
name = medNameList[0];
|
||||
unit = "";
|
||||
form = "";
|
||||
} else {
|
||||
name = medNameList[0];
|
||||
unit = medNameList[1];
|
||||
form = medNameList[2];
|
||||
}
|
||||
int quantityCalc = calcQuantity(
|
||||
widget.dosageController.text,
|
||||
widget.timesDailyController.text,
|
||||
widget.noDaysController.text,
|
||||
medNameList[2].toLowerCase());
|
||||
Perscription tempObj = Perscription(
|
||||
name: name,
|
||||
unit: unit,
|
||||
form: form,
|
||||
fullForm: getFullDoagesForm(form),
|
||||
quantity: "$quantityCalc",
|
||||
dosage: widget.dosageController.text,
|
||||
times: widget.timesDailyController.text,
|
||||
days: widget.noDaysController.text,
|
||||
repeats: widget.noRepeatsController.text,
|
||||
);
|
||||
perscriptionObjOutput.add(tempObj);
|
||||
}
|
||||
|
||||
String getPerscTitle(int index) {
|
||||
return "${perscriptionObjOutput[index].name} - ${perscriptionObjOutput[index].form}";
|
||||
}
|
||||
|
||||
String getPerscSubtitle(int index) {
|
||||
if (perscriptionObjOutput[index].form.toLowerCase() == "syr") {
|
||||
String unit = perscriptionObjOutput[index].unit.toLowerCase();
|
||||
if (perscriptionObjOutput[index].unit.toLowerCase().contains("ml")) {
|
||||
unit = "ml";
|
||||
}
|
||||
return "${perscriptionObjOutput[index].dosage} $unit, ${perscriptionObjOutput[index].times} time(s) daily, for ${perscriptionObjOutput[index].days} day(s)\nQuantity: ${perscriptionObjOutput[index].quantity}\nNo. of repeats: ${perscriptionObjOutput[index].repeats}";
|
||||
} else {
|
||||
return "${perscriptionObjOutput[index].dosage} ${perscriptionObjOutput[index].fullForm}(s), ${perscriptionObjOutput[index].times} time(s) daily, for ${perscriptionObjOutput[index].days} day(s)\nQuantity: ${perscriptionObjOutput[index].quantity}\nNo. of repeats: ${perscriptionObjOutput[index].repeats}";
|
||||
}
|
||||
}
|
||||
|
||||
String getFullDoagesForm(String abr) {
|
||||
var dosageFormList = {
|
||||
"liq": "liquid",
|
||||
"tab": "tablet",
|
||||
"cap": "capsule",
|
||||
"cps": "capsule",
|
||||
"oin": "ointment",
|
||||
"lit": "lotion",
|
||||
"lot": "lotion",
|
||||
"inj": "injection",
|
||||
"syr": "syrup",
|
||||
"dsp": "effervescent tablet",
|
||||
"eft": "effervescent tablet",
|
||||
"ear": "drops",
|
||||
"drp": "drops",
|
||||
"opd": "drops",
|
||||
"udv": "vial",
|
||||
"sus": "suspension",
|
||||
"susp": "suspension",
|
||||
"cal": "calasthetic",
|
||||
"sol": "solution",
|
||||
"sln": "solution",
|
||||
"neb": "nebuliser",
|
||||
"inh": "inhaler",
|
||||
"spo": "inhaler",
|
||||
"inf": "infusion",
|
||||
"chg": "chewing Gum",
|
||||
"vac": "vacutainer",
|
||||
"vag": "vaginal gel",
|
||||
"jel": "gel",
|
||||
"eyo": "eye ointment",
|
||||
"vat": "vaginal cream",
|
||||
"poi": "injection",
|
||||
"ped": "powder",
|
||||
"pow": "powder",
|
||||
"por": "powder",
|
||||
"sac": "sachet",
|
||||
"sup": "suppository",
|
||||
"cre": "cream",
|
||||
"ptd": "patch",
|
||||
"ect": "tablet",
|
||||
"nas": "spray",
|
||||
};
|
||||
String form;
|
||||
if (dosageFormList[abr.toLowerCase()] == null) {
|
||||
form = abr;
|
||||
} else {
|
||||
form = dosageFormList[abr.toLowerCase()]!;
|
||||
}
|
||||
return form;
|
||||
}
|
||||
|
||||
int calcQuantity(String dosage, String times, String days, String form) {
|
||||
var dosageFormList = [
|
||||
"tab",
|
||||
"cap",
|
||||
"cps",
|
||||
"dsp",
|
||||
"eft",
|
||||
"udv",
|
||||
"chg",
|
||||
"sac",
|
||||
"sup",
|
||||
"ptd",
|
||||
"ect",
|
||||
];
|
||||
if (dosageFormList.contains(form)) {
|
||||
return int.parse(dosage) * int.parse(times) * int.parse(days);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayMedInput() {
|
||||
return Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Column(
|
||||
children: [
|
||||
Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
"Medication",
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
MihSearchBar(
|
||||
controller: widget.medicineController,
|
||||
hintText: "Search Medicine",
|
||||
prefixIcon: Icons.search,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onPrefixIconTap: () {
|
||||
getMedsPopUp(widget.medicineController);
|
||||
},
|
||||
onClearIconTap: () {
|
||||
widget.medicineController.clear();
|
||||
},
|
||||
searchFocusNode: _searchFocusNode,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihNumericStepper(
|
||||
controller: widget.dosageController,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintText: "Dosage",
|
||||
requiredText: true,
|
||||
minValue: 1,
|
||||
// maxValue: 5,
|
||||
validationOn: true,
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihNumericStepper(
|
||||
controller: widget.timesDailyController,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintText: "Times Daily",
|
||||
requiredText: true,
|
||||
minValue: 1,
|
||||
// maxValue: 5,
|
||||
validationOn: true,
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihNumericStepper(
|
||||
controller: widget.noDaysController,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintText: "No. Days",
|
||||
requiredText: true,
|
||||
minValue: 1,
|
||||
// maxValue: 5,
|
||||
validationOn: true,
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihNumericStepper(
|
||||
controller: widget.noRepeatsController,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
hintText: "No.Repeats",
|
||||
requiredText: true,
|
||||
minValue: 0,
|
||||
// maxValue: 5,
|
||||
validationOn: true,
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
if (isFieldsFilled()) {
|
||||
setState(() {
|
||||
updatePerscriptionList();
|
||||
widget.medicineController.clear();
|
||||
widget.quantityController.text = "1";
|
||||
widget.dosageController.text = "1";
|
||||
widget.timesDailyController.text = "1";
|
||||
widget.noDaysController.text = "1";
|
||||
widget.noRepeatsController.text = "0";
|
||||
});
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Add",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget displayPerscList(PatientManagerProvider patManProvider) {
|
||||
return Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 550,
|
||||
height: 325,
|
||||
decoration: BoxDecoration(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
border: Border.all(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 3.0),
|
||||
),
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Divider(),
|
||||
);
|
||||
},
|
||||
itemCount: perscriptionObjOutput.length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
return ListTile(
|
||||
title: Text(
|
||||
getPerscTitle(index),
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
getPerscSubtitle(index),
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
//onTap: () {},
|
||||
trailing: IconButton(
|
||||
icon: Icon(
|
||||
Icons.delete_forever_outlined,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
perscriptionObjOutput.removeAt(index);
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
MihButton(
|
||||
onPressed: () async {
|
||||
if (perscriptionObjOutput.isNotEmpty) {
|
||||
//print(jsonEncode(perscriptionObjOutput));
|
||||
await generatePerscription(patManProvider);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Generate",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_focusNode.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
//futueMeds = getMedList(endpointMeds);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var size = MediaQuery.of(context).size;
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
return Consumer<PatientManagerProvider>(
|
||||
builder: (BuildContext context, PatientManagerProvider patManProvider,
|
||||
Widget? child) {
|
||||
return Wrap(
|
||||
direction: Axis.horizontal,
|
||||
alignment: WrapAlignment.center,
|
||||
spacing: 10,
|
||||
runSpacing: 10,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(width: 500, child: displayMedInput()),
|
||||
displayPerscList(patManProvider),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_downloader/fl_downloader.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_file_viewer_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_file_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
import 'package:http/http.dart' as http2;
|
||||
import "package:universal_html/html.dart" as html;
|
||||
|
||||
class BuildClaimStatementFileList extends StatefulWidget {
|
||||
const BuildClaimStatementFileList({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildClaimStatementFileList> createState() =>
|
||||
_BuildClaimStatementFileListState();
|
||||
}
|
||||
|
||||
class _BuildClaimStatementFileListState
|
||||
extends State<BuildClaimStatementFileList> {
|
||||
int indexOn = 0;
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
final basefile = AppEnviroment.baseFileUrl;
|
||||
String fileUrl = "";
|
||||
int progress = 0;
|
||||
late StreamSubscription progressStream;
|
||||
|
||||
Future<String> getFileUrlApiCall(String filePath) async {
|
||||
String teporaryFileUrl = "";
|
||||
await MihFileApi.getMinioFileUrl(
|
||||
filePath,
|
||||
).then((value) {
|
||||
teporaryFileUrl = value;
|
||||
});
|
||||
return teporaryFileUrl;
|
||||
}
|
||||
|
||||
String getFileName(String path) {
|
||||
//print(pdfLink.split(".")[1]);
|
||||
return path.split("/").last;
|
||||
}
|
||||
|
||||
void printDocument(String link, String path) async {
|
||||
http2.Response response = await http.get(Uri.parse(link));
|
||||
var pdfData = response.bodyBytes;
|
||||
context.pop();
|
||||
context.pushNamed(
|
||||
'printPreview',
|
||||
extra: PrintPreviewArguments(
|
||||
pdfData,
|
||||
getFileName(path),
|
||||
),
|
||||
);
|
||||
// Navigator.of(context).pushNamed(
|
||||
// '/file-veiwer/print-preview',
|
||||
// arguments: PrintPreviewArguments(
|
||||
// pdfData,
|
||||
// getFileName(path),
|
||||
// ),
|
||||
// );
|
||||
}
|
||||
|
||||
void nativeFileDownload(String fileLink) async {
|
||||
var permission = await FlDownloader.requestPermission();
|
||||
if (permission == StoragePermissionStatus.granted) {
|
||||
try {
|
||||
mihLoadingPopUp();
|
||||
await FlDownloader.download(fileLink);
|
||||
Navigator.of(context).pop();
|
||||
} on Exception catch (error) {
|
||||
Navigator.of(context).pop();
|
||||
print(error);
|
||||
}
|
||||
} else {
|
||||
print("denied");
|
||||
}
|
||||
}
|
||||
|
||||
void viewFilePopUp(PatientManagerProvider patientManagerProvider,
|
||||
String fileName, String filePath, int fileID, String url) {
|
||||
bool hasAccessToDelete = false;
|
||||
if (!patientManagerProvider.personalMode) {
|
||||
hasAccessToDelete = true;
|
||||
}
|
||||
|
||||
List<SpeedDialChild>? menuList = [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.download,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Download",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
if (MzansiInnovationHub.of(context)!.theme.getPlatform() == "Web") {
|
||||
html.window.open(url, 'download');
|
||||
} else {
|
||||
nativeFileDownload(url);
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
menuList.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.print,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Print",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
printDocument(url, filePath);
|
||||
},
|
||||
),
|
||||
);
|
||||
menuList.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.fullscreen,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Full Screen",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
context.pop();
|
||||
context.pushNamed(
|
||||
'fileViewer',
|
||||
);
|
||||
// printDocument(url, filePath);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (hasAccessToDelete) {
|
||||
menuList.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Delete Document",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
// deleteFilePopUp(filePath, fileID);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: fileName,
|
||||
windowBody: Column(
|
||||
children: [
|
||||
BuildFileView(
|
||||
link: url,
|
||||
path: filePath,
|
||||
//pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
)
|
||||
],
|
||||
),
|
||||
menuOptions: menuList,
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void mihLoadingPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
FlDownloader.initialize();
|
||||
progressStream = FlDownloader.progressStream.listen((event) {
|
||||
if (event.status == DownloadStatus.successful) {
|
||||
setState(() {
|
||||
progress = event.progress;
|
||||
});
|
||||
//Navigator.of(context).pop();
|
||||
print("Progress $progress%: Success Downloading");
|
||||
FlDownloader.openFile(filePath: event.filePath);
|
||||
} else if (event.status == DownloadStatus.failed) {
|
||||
print("Progress $progress%: Error Downloading");
|
||||
} else if (event.status == DownloadStatus.running) {
|
||||
print("Progress $progress%: Download Running");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
if (patientManagerProvider.patientClaimsDocuments!.isNotEmpty) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: patientManagerProvider.patientClaimsDocuments!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
Icons.picture_as_pdf,
|
||||
size: 50,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
title: Text(
|
||||
patientManagerProvider
|
||||
.patientClaimsDocuments![index].file_name,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
patientManagerProvider
|
||||
.patientClaimsDocuments![index].insert_date,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward,
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
onTap: () async {
|
||||
MihFileViewerProvider fileViewerProvider =
|
||||
context.read<MihFileViewerProvider>();
|
||||
await getFileUrlApiCall(patientManagerProvider
|
||||
.patientClaimsDocuments![index].file_path)
|
||||
.then((urlHere) {
|
||||
//print(url);
|
||||
fileViewerProvider.setFilePath(patientManagerProvider
|
||||
.patientClaimsDocuments![index].file_path);
|
||||
fileViewerProvider.setFileLink(urlHere);
|
||||
});
|
||||
|
||||
viewFilePopUp(
|
||||
patientManagerProvider,
|
||||
patientManagerProvider
|
||||
.patientClaimsDocuments![index].file_name,
|
||||
patientManagerProvider
|
||||
.patientClaimsDocuments![index].file_path,
|
||||
patientManagerProvider.patientClaimsDocuments![index]
|
||||
.idclaim_statement_file,
|
||||
fileViewerProvider.fileLink);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
Icon(
|
||||
MihIcons.mihRing,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
Icon(
|
||||
Icons.file_open_outlined,
|
||||
size: 110,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"No Claims or Statements have been added to this profile.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Visibility(
|
||||
visible: !patientManagerProvider.personalMode,
|
||||
child: Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to generate the first document"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
import 'dart:async';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:syncfusion_flutter_core/theme.dart';
|
||||
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:fl_downloader/fl_downloader.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;
|
||||
|
||||
int progress = 0;
|
||||
late StreamSubscription progressStream;
|
||||
|
||||
void mihLoadingPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void nativeFileDownload(String fileLink) async {
|
||||
var permission = await FlDownloader.requestPermission();
|
||||
if (permission == StoragePermissionStatus.granted) {
|
||||
try {
|
||||
mihLoadingPopUp();
|
||||
await FlDownloader.download(fileLink);
|
||||
Navigator.of(context).pop();
|
||||
} on Exception catch (error) {
|
||||
Navigator.of(context).pop();
|
||||
print(error);
|
||||
}
|
||||
} else {
|
||||
print("denied");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
pdfViewerController.dispose();
|
||||
progressStream.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
FlDownloader.initialize();
|
||||
progressStream = FlDownloader.progressStream.listen((event) {
|
||||
if (event.status == DownloadStatus.successful) {
|
||||
setState(() {
|
||||
progress = event.progress;
|
||||
});
|
||||
//Navigator.of(context).pop();
|
||||
print("Progress $progress%: Success Downloading");
|
||||
FlDownloader.openFile(filePath: event.filePath);
|
||||
} else if (event.status == DownloadStatus.failed) {
|
||||
print("Progress $progress%: Error Downloading");
|
||||
} else if (event.status == DownloadStatus.running) {
|
||||
print("Progress $progress%: Download Running");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// double width = MediaQuery.sizeOf(context).width;
|
||||
//double height = MediaQuery.sizeOf(context).height;
|
||||
debugPrint(widget.link);
|
||||
if (getExtType(widget.path).toLowerCase() == "pdf") {
|
||||
return SizedBox(
|
||||
height: 500,
|
||||
child: SfPdfViewerTheme(
|
||||
data: SfPdfViewerThemeData(
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
child: SfPdfViewer.network(
|
||||
widget.link,
|
||||
controller: pdfViewerController,
|
||||
interactionMode: PdfInteractionMode.pan,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 500,
|
||||
child: InteractiveViewer(
|
||||
//constrained: true,
|
||||
//clipBehavior: Clip.antiAlias,
|
||||
maxScale: 5.0,
|
||||
//minScale: 0.,
|
||||
child: Image.network(widget.link),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_downloader/fl_downloader.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mih_file_viewer_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_file_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
import 'package:http/http.dart' as http2;
|
||||
import "package:universal_html/html.dart" as html;
|
||||
|
||||
class BuildFilesList extends StatefulWidget {
|
||||
const BuildFilesList({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildFilesList> createState() => _BuildFilesListState();
|
||||
}
|
||||
|
||||
class _BuildFilesListState extends State<BuildFilesList> {
|
||||
int indexOn = 0;
|
||||
final baseAPI = AppEnviroment.baseApiUrl;
|
||||
final basefile = AppEnviroment.baseFileUrl;
|
||||
String fileUrl = "";
|
||||
int progress = 0;
|
||||
late StreamSubscription progressStream;
|
||||
|
||||
Future<String> getFileUrlApiCall(String filePath) async {
|
||||
String teporaryFileUrl = "";
|
||||
await MihFileApi.getMinioFileUrl(
|
||||
filePath,
|
||||
).then((value) {
|
||||
teporaryFileUrl = value;
|
||||
});
|
||||
return teporaryFileUrl;
|
||||
}
|
||||
|
||||
String getFileName(String path) {
|
||||
//print(pdfLink.split(".")[1]);
|
||||
return path.split("/").last;
|
||||
}
|
||||
|
||||
void printDocument(String link, String path) async {
|
||||
http2.Response response = await http.get(Uri.parse(link));
|
||||
var pdfData = response.bodyBytes;
|
||||
context.pop();
|
||||
context.pushNamed(
|
||||
'printPreview',
|
||||
extra: PrintPreviewArguments(
|
||||
pdfData,
|
||||
getFileName(path),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void nativeFileDownload(String fileLink) async {
|
||||
var permission = await FlDownloader.requestPermission();
|
||||
if (permission == StoragePermissionStatus.granted) {
|
||||
try {
|
||||
mihLoadingPopUp();
|
||||
await FlDownloader.download(fileLink);
|
||||
Navigator.of(context).pop();
|
||||
} on Exception catch (error) {
|
||||
Navigator.of(context).pop();
|
||||
print(error);
|
||||
}
|
||||
} else {
|
||||
print("denied");
|
||||
}
|
||||
}
|
||||
|
||||
void viewFilePopUp(PatientManagerProvider patientManagerProvider,
|
||||
String fileName, String filePath, int fileID, String url) {
|
||||
bool hasAccessToDelete = false;
|
||||
if (!patientManagerProvider.personalMode) {
|
||||
hasAccessToDelete = true;
|
||||
}
|
||||
|
||||
List<SpeedDialChild>? menuList = [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.download,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Download",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
if (MzansiInnovationHub.of(context)!.theme.getPlatform() == "Web") {
|
||||
html.window.open(url, 'download');
|
||||
} else {
|
||||
nativeFileDownload(url);
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
if (filePath.split(".").last.toLowerCase() == "pdf") {
|
||||
menuList.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.print,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Print",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
printDocument(url, filePath);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
menuList.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.fullscreen,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Full Screen",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
context.pop();
|
||||
context.pushNamed(
|
||||
'fileViewer',
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
// }
|
||||
if (hasAccessToDelete) {
|
||||
menuList.add(
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Delete Document",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
// deleteFilePopUp(filePath, fileID);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: fileName,
|
||||
windowBody: BuildFileView(
|
||||
link: url,
|
||||
path: filePath,
|
||||
//pdfLink: '${AppEnviroment.baseFileUrl}/mih/$filePath',
|
||||
),
|
||||
menuOptions: menuList,
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void mihLoadingPopUp() {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget getFileIcon(String extension) {
|
||||
switch (extension) {
|
||||
case ("pdf"):
|
||||
return Icon(
|
||||
Icons.picture_as_pdf,
|
||||
size: 50,
|
||||
color: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
case ("jpeg"):
|
||||
return Icon(
|
||||
FontAwesomeIcons.image,
|
||||
size: 50,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
case ("jpg"):
|
||||
return Icon(
|
||||
FontAwesomeIcons.image,
|
||||
size: 50,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
case ("png"):
|
||||
return Icon(
|
||||
FontAwesomeIcons.image,
|
||||
size: 50,
|
||||
color: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
case ("gif"):
|
||||
return Icon(
|
||||
FontAwesomeIcons.image,
|
||||
size: 50,
|
||||
color: MihColors.getOrangeColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
default:
|
||||
return Icon(
|
||||
Icons.image_not_supported,
|
||||
size: 50,
|
||||
color: MihColors.getSilverColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
FlDownloader.initialize();
|
||||
progressStream = FlDownloader.progressStream.listen((event) {
|
||||
if (event.status == DownloadStatus.successful) {
|
||||
setState(() {
|
||||
progress = event.progress;
|
||||
});
|
||||
//Navigator.of(context).pop();
|
||||
print("Progress $progress%: Success Downloading");
|
||||
FlDownloader.openFile(filePath: event.filePath);
|
||||
} else if (event.status == DownloadStatus.failed) {
|
||||
print("Progress $progress%: Error Downloading");
|
||||
} else if (event.status == DownloadStatus.running) {
|
||||
print("Progress $progress%: Download Running");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
if (patientManagerProvider.patientDocuments!.isNotEmpty) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: patientManagerProvider.patientDocuments!.length,
|
||||
itemBuilder: (context, index) {
|
||||
String fileExtension = patientManagerProvider
|
||||
.patientDocuments![index].file_name
|
||||
.split(".")
|
||||
.last
|
||||
.toLowerCase();
|
||||
KenLogger.success(fileExtension);
|
||||
return ListTile(
|
||||
leading: getFileIcon(fileExtension),
|
||||
title: Text(
|
||||
patientManagerProvider.patientDocuments![index].file_name,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
patientManagerProvider.patientDocuments![index].insert_date,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
// trailing: Icon(
|
||||
// Icons.arrow_forward,
|
||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// ),
|
||||
onTap: () async {
|
||||
MihFileViewerProvider fileViewerProvider =
|
||||
context.read<MihFileViewerProvider>();
|
||||
await getFileUrlApiCall(patientManagerProvider
|
||||
.patientDocuments![index].file_path)
|
||||
.then((urlHere) {
|
||||
//print(url);
|
||||
fileViewerProvider.setFilePath(patientManagerProvider
|
||||
.patientDocuments![index].file_path);
|
||||
fileViewerProvider.setFileLink(urlHere);
|
||||
});
|
||||
viewFilePopUp(
|
||||
patientManagerProvider,
|
||||
patientManagerProvider.patientDocuments![index].file_name,
|
||||
patientManagerProvider.patientDocuments![index].file_path,
|
||||
patientManagerProvider
|
||||
.patientDocuments![index].idpatient_files,
|
||||
fileViewerProvider.fileLink);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
Icon(
|
||||
MihIcons.mihRing,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
Icon(
|
||||
Icons.file_present,
|
||||
size: 110,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
"No Documents have been added to this profile.",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to add "),
|
||||
!patientManagerProvider.personalMode
|
||||
? TextSpan(
|
||||
text: " or generate a the first document")
|
||||
: TextSpan(text: " the first document"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/icd10_code.dart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BuildICD10CodeList extends StatefulWidget {
|
||||
final TextEditingController icd10CodeController;
|
||||
final List<ICD10Code> icd10codeList;
|
||||
|
||||
const BuildICD10CodeList({
|
||||
super.key,
|
||||
required this.icd10CodeController,
|
||||
required this.icd10codeList,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BuildICD10CodeList> createState() => _BuildPatientsListState();
|
||||
}
|
||||
|
||||
class _BuildPatientsListState extends State<BuildICD10CodeList> {
|
||||
String baseAPI = AppEnviroment.baseApiUrl;
|
||||
int counter = 0;
|
||||
|
||||
Widget displayCode(int index) {
|
||||
String title = "ICD-10 Code: ${widget.icd10codeList[index].icd10}";
|
||||
String description =
|
||||
"Description: ${widget.icd10codeList[index].description}";
|
||||
return ListTile(
|
||||
title: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: RichText(
|
||||
text: TextSpan(
|
||||
text: description,
|
||||
style: DefaultTextStyle.of(context).style,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
//select code
|
||||
setState(() {
|
||||
widget.icd10CodeController.text =
|
||||
"${widget.icd10codeList[index].icd10} - ${widget.icd10codeList[index].description}";
|
||||
});
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
separatorBuilder: (BuildContext context, index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: widget.icd10codeList.length,
|
||||
itemBuilder: (context, index) {
|
||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||
//print(index);
|
||||
return displayCode(index);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/medicine.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.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: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
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: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
"${widget.medicines[index].unit} - ${widget.medicines[index].form}",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
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: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/notes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class BuildNotesList extends StatefulWidget {
|
||||
const BuildNotesList({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@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(
|
||||
PatientManagerProvider patientManagerProvider, int NoteId) async {
|
||||
int statusCode = await MihPatientServices()
|
||||
.deletePatientConsultaionNote(NoteId, patientManagerProvider);
|
||||
//print("Here4");
|
||||
//print(response.statusCode);
|
||||
if (statusCode == 200) {
|
||||
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("Successfuly Deleted", message);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
void deletePatientPopUp(
|
||||
PatientManagerProvider patientManagerProvider, int NoteId) {
|
||||
MihAlertServices().deleteConfirmationAlert(
|
||||
"This note will be deleted permanently. Are you certain you want to delete it?",
|
||||
() {
|
||||
deleteNoteApiCall(patientManagerProvider, NoteId);
|
||||
},
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
void viewNotePopUp(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, 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 (!patientManagerProvider.personalMode &&
|
||||
selectednote.doc_office == profileProvider.business!.Name) {
|
||||
hasAccessToDelete = true;
|
||||
}
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Note Details",
|
||||
menuOptions: hasAccessToDelete
|
||||
? [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Delete Note",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
deletePatientPopUp(
|
||||
patientManagerProvider, selectednote.idpatient_notes);
|
||||
},
|
||||
),
|
||||
]
|
||||
: null,
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: businessNameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Office",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: userNameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Created By",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: dateController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Created Date",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: noteTitleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Note Title",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
height: 250,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: noteTextController,
|
||||
multiLineInput: true,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Note Details",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
noteTextController.dispose();
|
||||
businessNameController.dispose();
|
||||
userNameController.dispose();
|
||||
dateController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
if (patientManagerProvider.consultationNotes!.isNotEmpty) {
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
},
|
||||
itemCount: patientManagerProvider.consultationNotes!.length,
|
||||
itemBuilder: (context, index) {
|
||||
String notePreview =
|
||||
patientManagerProvider.consultationNotes![index].note_text;
|
||||
if (notePreview.length > 30) {
|
||||
notePreview = "${notePreview.substring(0, 30)} ...";
|
||||
}
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
Icons.note,
|
||||
size: 50,
|
||||
color: MihColors.getGoldColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
title: Text(
|
||||
"${patientManagerProvider.consultationNotes![index].note_name}\n${patientManagerProvider.consultationNotes![index].doc_office} - ${patientManagerProvider.consultationNotes![index].doctor}",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
"${patientManagerProvider.consultationNotes![index].insert_date}:\n$notePreview",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
), //Text(widget.notes[index].note_text),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
onTap: () {
|
||||
viewNotePopUp(
|
||||
profileProvider,
|
||||
patientManagerProvider,
|
||||
patientManagerProvider.consultationNotes![index],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
const SizedBox(height: 50),
|
||||
Stack(
|
||||
alignment: AlignmentDirectional.center,
|
||||
children: [
|
||||
Icon(
|
||||
MihIcons.mihRing,
|
||||
size: 165,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
Icon(
|
||||
Icons.article_outlined,
|
||||
size: 110,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"No Notes have been added to this profile.",
|
||||
textAlign: TextAlign.center,
|
||||
overflow: TextOverflow.visible,
|
||||
style: TextStyle(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 25),
|
||||
Visibility(
|
||||
visible: !patientManagerProvider.personalMode,
|
||||
child: Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
children: [
|
||||
TextSpan(text: "Press "),
|
||||
WidgetSpan(
|
||||
alignment: PlaceholderAlignment.middle,
|
||||
child: Icon(
|
||||
Icons.menu,
|
||||
size: 20,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
TextSpan(text: " to add the first note"),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tile.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_icons.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientProfileTile extends StatefulWidget {
|
||||
final double packageSize;
|
||||
|
||||
const PatientProfileTile({
|
||||
super.key,
|
||||
required this.packageSize,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatientProfileTile> createState() => _PatientProfileTileState();
|
||||
}
|
||||
|
||||
class _PatientProfileTileState extends State<PatientProfileTile> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageTile(
|
||||
authenticateUser: true,
|
||||
onTap: () async {
|
||||
PatientManagerProvider patManProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
patManProvider.setPersonalMode(true);
|
||||
context.goNamed("patientProfile");
|
||||
},
|
||||
appName: "Patient Profile",
|
||||
appIcon: Icon(
|
||||
MihIcons.patientProfile,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
// size: widget.packageSize,
|
||||
),
|
||||
iconSize: widget.packageSize,
|
||||
textColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/claim_statement_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_claim_statement_files_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientClaimOrStatement extends StatefulWidget {
|
||||
const PatientClaimOrStatement({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatientClaimOrStatement> createState() =>
|
||||
_PatientClaimOrStatementState();
|
||||
}
|
||||
|
||||
class _PatientClaimOrStatementState extends State<PatientClaimOrStatement> {
|
||||
void claimOrStatementWindow() {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => ClaimStatementWindow(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody() {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return Stack(
|
||||
children: [
|
||||
BuildClaimStatementFileList(),
|
||||
Visibility(
|
||||
visible: !patientManagerProvider.personalMode,
|
||||
child: Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.file_copy,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Generate Claim/ Statement",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onTap: () {
|
||||
claimOrStatementWindow();
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:ken_logger/ken_logger.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientConsultation extends StatefulWidget {
|
||||
const PatientConsultation({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatientConsultation> createState() => _PatientConsultationState();
|
||||
}
|
||||
|
||||
class _PatientConsultationState extends State<PatientConsultation> {
|
||||
final titleController = TextEditingController();
|
||||
final noteTextController = TextEditingController();
|
||||
final officeController = TextEditingController();
|
||||
final dateController = TextEditingController();
|
||||
final doctorController = TextEditingController();
|
||||
final ValueNotifier<int> _counter = ValueNotifier<int>(0);
|
||||
String endpoint = "${AppEnviroment.baseApiUrl}/notes/patients/";
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
Future<void> addPatientNoteAPICall(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patManProvider,
|
||||
) async {
|
||||
int statuscode = await MihPatientServices().addPatientNoteAPICall(
|
||||
titleController.text,
|
||||
noteTextController.text,
|
||||
profileProvider,
|
||||
patManProvider,
|
||||
);
|
||||
if (statuscode == 201) {
|
||||
context.pop();
|
||||
MihAlertServices().successBasicAlert(
|
||||
"Success!",
|
||||
"Note added successfully.",
|
||||
context,
|
||||
);
|
||||
titleController.clear();
|
||||
noteTextController.clear();
|
||||
officeController.clear();
|
||||
dateController.clear();
|
||||
doctorController.clear();
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
void addNotePopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patManProvider,
|
||||
double width,
|
||||
) {
|
||||
DateTime now = DateTime.now();
|
||||
DateTime date = DateTime(now.year, now.month, now.day);
|
||||
var title = "";
|
||||
KenLogger.success("Business User: ${profileProvider.businessUser}");
|
||||
if (profileProvider.businessUser?.title == "Doctor") {
|
||||
title = "Dr.";
|
||||
}
|
||||
setState(() {
|
||||
officeController.text = profileProvider.business!.Name;
|
||||
doctorController.text =
|
||||
"$title ${profileProvider.user!.fname} ${profileProvider.user!.lname}";
|
||||
dateController.text = date.toString().substring(0, 10);
|
||||
});
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Add Note",
|
||||
onWindowTapClose: () {
|
||||
context.pop(context);
|
||||
titleController.clear();
|
||||
noteTextController.clear();
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: officeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Office",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: doctorController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Created By",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: dateController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Created Date",
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: titleController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Note Title",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
height: 250,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
controller: noteTextController,
|
||||
multiLineInput: true,
|
||||
requiredText: true,
|
||||
hintText: "Note Details",
|
||||
validator: (value) {
|
||||
return MihValidationServices().validateLength(value, 512);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
child: ValueListenableBuilder(
|
||||
builder:
|
||||
(BuildContext context, int value, Widget? child) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
"$value",
|
||||
style: TextStyle(
|
||||
color: getNoteDetailLimitColor(),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
"/512",
|
||||
style: TextStyle(
|
||||
color: getNoteDetailLimitColor(),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
valueListenable: _counter,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addPatientNoteAPICall(
|
||||
profileProvider, patManProvider);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Add Note",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool isFieldsFilled() {
|
||||
if (titleController.text.isEmpty ||
|
||||
noteTextController.text.isEmpty ||
|
||||
_counter.value >= 512) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Color getNoteDetailLimitColor() {
|
||||
if (_counter.value <= 512) {
|
||||
return MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
} else {
|
||||
return MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
titleController.dispose();
|
||||
noteTextController.dispose();
|
||||
doctorController.dispose();
|
||||
dateController.dispose();
|
||||
officeController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
noteTextController.addListener(() {
|
||||
setState(() {
|
||||
_counter.value = noteTextController.text.characters.length;
|
||||
});
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return Stack(
|
||||
children: [
|
||||
BuildNotesList(),
|
||||
Visibility(
|
||||
visible: !patientManagerProvider.personalMode,
|
||||
child: Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Add Note",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onTap: () {
|
||||
// addConsultationNotePopUp();
|
||||
addNotePopUp(
|
||||
profileProvider, patientManagerProvider, width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,574 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_date_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/prescip_input.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientDocuments extends StatefulWidget {
|
||||
const PatientDocuments({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatientDocuments> createState() => _PatientDocumentsState();
|
||||
}
|
||||
|
||||
class _PatientDocumentsState extends State<PatientDocuments> {
|
||||
final selectedFileController = TextEditingController();
|
||||
final startDateController = TextEditingController();
|
||||
final endDateTextController = TextEditingController();
|
||||
final retDateTextController = TextEditingController();
|
||||
final medicineController = TextEditingController();
|
||||
final quantityController = TextEditingController();
|
||||
final dosageController = TextEditingController();
|
||||
final timesDailyController = TextEditingController();
|
||||
final noDaysController = TextEditingController();
|
||||
final noRepeatsController = TextEditingController();
|
||||
final outputController = TextEditingController();
|
||||
late PlatformFile? selected;
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _formKey2 = GlobalKey<FormState>();
|
||||
late String env;
|
||||
|
||||
Future<void> submitDocUploadForm(
|
||||
PatientManagerProvider patientManagerProvider) async {
|
||||
if (isFileFieldsFilled()) {
|
||||
await uploadSelectedFile(patientManagerProvider, selected);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addPatientFileLocationToDB(
|
||||
PatientManagerProvider patientManagerProvider, PlatformFile? file) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
int statusCode =
|
||||
await MihPatientServices().addPatientFile(file, patientManagerProvider);
|
||||
if (statusCode == 201) {
|
||||
setState(() {
|
||||
selectedFileController.clear();
|
||||
});
|
||||
var fname = file!.name.replaceAll(RegExp(r' '), '-');
|
||||
// end loading circle
|
||||
Navigator.of(context).pop();
|
||||
String message =
|
||||
"The file $fname has been successfully generated and added to ${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}'s record. You can now access and download it for their use.";
|
||||
successPopUp("Successfully Uplouded File", message);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> uploadSelectedFile(
|
||||
PatientManagerProvider patientManagerProvider, PlatformFile? file) async {
|
||||
var response = await MihFileApi.uploadFile(
|
||||
patientManagerProvider.selectedPatient!.app_id,
|
||||
env,
|
||||
"patient_files",
|
||||
file,
|
||||
context,
|
||||
);
|
||||
if (response == 200) {
|
||||
await addPatientFileLocationToDB(patientManagerProvider, file);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> generateMedCert(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider) async {
|
||||
//start loading circle
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
int statusCodeCetificateGeneration =
|
||||
await MihPatientServices().generateMedicalCertificate(
|
||||
startDateController.text,
|
||||
endDateTextController.text,
|
||||
retDateTextController.text,
|
||||
profileProvider,
|
||||
patientManagerProvider,
|
||||
);
|
||||
DateTime now = DateTime.now();
|
||||
String fileName =
|
||||
"Med-Cert-${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}-${now.toString().substring(0, 19)}.pdf"
|
||||
.replaceAll(RegExp(r' '), '-');
|
||||
if (statusCodeCetificateGeneration == 200) {
|
||||
context.pop(); //Loading removal
|
||||
String message =
|
||||
"The medical certificate $fileName has been successfully generated and added to ${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}'s record. You can now access and download it for their use.";
|
||||
await MihPatientServices().getPatientDocuments(patientManagerProvider);
|
||||
successPopUp("Successfully Generated Certificate", message);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
void uploudFilePopUp(
|
||||
PatientManagerProvider patientManagerProvider, double width) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Upload File",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||
: const EdgeInsets.symmetric(horizontal: 0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: selectedFileController,
|
||||
hintText: "Selected File",
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
MihButton(
|
||||
onPressed: () async {
|
||||
FilePickerResult? result =
|
||||
await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['jpg', 'png', 'pdf'],
|
||||
withData: true,
|
||||
);
|
||||
if (result == null) return;
|
||||
final selectedFile = result.files.first;
|
||||
print("Selected file: $selectedFile");
|
||||
setState(() {
|
||||
selected = selectedFile;
|
||||
});
|
||||
setState(() {
|
||||
selectedFileController.text = selectedFile.name;
|
||||
});
|
||||
},
|
||||
buttonColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
child: Text(
|
||||
"Attach",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
submitDocUploadForm(patientManagerProvider);
|
||||
// uploadSelectedFile(selected);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Add File",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void medCertPopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Create Medical Certificate",
|
||||
onWindowTapClose: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey2,
|
||||
formFields: [
|
||||
MihDateField(
|
||||
controller: startDateController,
|
||||
labelText: "From",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihDateField(
|
||||
controller: endDateTextController,
|
||||
labelText: "Up to Including",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihDateField(
|
||||
controller: retDateTextController,
|
||||
labelText: "Return",
|
||||
required: true,
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
// Medcertinput(
|
||||
// startDateController: startDateController,
|
||||
// endDateTextController: endDateTextController,
|
||||
// retDateTextController: retDateTextController,
|
||||
// ),
|
||||
const SizedBox(height: 15.0),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () async {
|
||||
if (_formKey2.currentState!.validate()) {
|
||||
await generateMedCert(
|
||||
profileProvider, patientManagerProvider);
|
||||
//Navigator.pop(context);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Generate",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void prescritionPopUp(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Create Prescription",
|
||||
onWindowTapClose: () {
|
||||
medicineController.clear();
|
||||
quantityController.text = "1";
|
||||
dosageController.text = "1";
|
||||
timesDailyController.text = "1";
|
||||
noDaysController.text = "1";
|
||||
noRepeatsController.text = "0";
|
||||
Navigator.pop(context);
|
||||
},
|
||||
windowBody: Column(
|
||||
children: [
|
||||
PrescripInput(
|
||||
medicineController: medicineController,
|
||||
quantityController: quantityController,
|
||||
dosageController: dosageController,
|
||||
timesDailyController: timesDailyController,
|
||||
noDaysController: noDaysController,
|
||||
noRepeatsController: noRepeatsController,
|
||||
outputController: outputController,
|
||||
selectedPatient: patientManagerProvider.selectedPatient!,
|
||||
signedInUser: profileProvider.user!,
|
||||
business: profileProvider.business,
|
||||
businessUser: profileProvider.businessUser,
|
||||
env: env,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool isFileFieldsFilled() {
|
||||
if (selectedFileController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool isMedCertFieldsFilled() {
|
||||
if (startDateController.text.isEmpty ||
|
||||
endDateTextController.text.isEmpty ||
|
||||
retDateTextController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Widget getMenu(MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, double width) {
|
||||
if (patientManagerProvider.personalMode) {
|
||||
return Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.attach_file,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Attach Document",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
uploudFilePopUp(patientManagerProvider, width);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.attach_file,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Add Document",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
uploudFilePopUp(patientManagerProvider, width);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.sick_outlined,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Generate Medical Certificate",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
medCertPopUp(profileProvider, patientManagerProvider);
|
||||
},
|
||||
),
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.medication,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
label: "Generate Prescription",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onTap: () {
|
||||
prescritionPopUp(profileProvider, patientManagerProvider);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
startDateController.dispose();
|
||||
endDateTextController.dispose();
|
||||
retDateTextController.dispose();
|
||||
selectedFileController.dispose();
|
||||
medicineController.dispose();
|
||||
quantityController.dispose();
|
||||
dosageController.dispose();
|
||||
timesDailyController.dispose();
|
||||
noDaysController.dispose();
|
||||
noRepeatsController.dispose();
|
||||
outputController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (AppEnviroment.getEnv() == "Prod") {
|
||||
env = "Prod";
|
||||
} else {
|
||||
env = "Dev";
|
||||
}
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return Stack(
|
||||
children: [
|
||||
BuildFilesList(),
|
||||
getMenu(profileProvider, patientManagerProvider, width),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_circle_avatar.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_window.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tool_body.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_floating_menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_single_child_scroll.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/mih_edit_patient_details_window.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientInfo extends StatefulWidget {
|
||||
const PatientInfo({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatientInfo> createState() => _PatientInfoState();
|
||||
}
|
||||
|
||||
class _PatientInfoState extends State<PatientInfo> {
|
||||
double textFieldWidth = 300;
|
||||
late String medAid;
|
||||
late bool medAidPosition;
|
||||
|
||||
String getDisplayText(
|
||||
PatientManagerProvider patientManagerProvider, String originalText) {
|
||||
int textLength = originalText.length >= 13 ? 13 : 6;
|
||||
String displayText = "";
|
||||
if (patientManagerProvider.hidePatientDetails) {
|
||||
for (int i = 0; i < textLength; i++) {
|
||||
displayText += "●";
|
||||
}
|
||||
} else {
|
||||
displayText = originalText;
|
||||
}
|
||||
return displayText;
|
||||
}
|
||||
|
||||
Widget buildPatientInfoCard(PatientManagerProvider patientManagerProvider) {
|
||||
TextStyle titleStyle = TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
TextStyle subtitleStyle = TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
TextStyle subtitleHeadingStyle = TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Patient Details Card",
|
||||
onWindowTapClose: null,
|
||||
backgroundColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
foregroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
windowBody: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}",
|
||||
style: titleStyle,
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "ID No: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(patientManagerProvider,
|
||||
patientManagerProvider.selectedPatient!.id_no),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Cell No: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(
|
||||
patientManagerProvider,
|
||||
patientManagerProvider
|
||||
.selectedPatient!.cell_no),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Email: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(patientManagerProvider,
|
||||
patientManagerProvider.selectedPatient!.email),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Address: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(patientManagerProvider,
|
||||
patientManagerProvider.selectedPatient!.address),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildMedAidInfoCard(PatientManagerProvider patientManagerProvider) {
|
||||
TextStyle titleStyle = TextStyle(
|
||||
fontSize: 30,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
TextStyle subtitleStyle = TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
TextStyle subtitleHeadingStyle = TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
);
|
||||
return MihPackageWindow(
|
||||
fullscreen: false,
|
||||
windowTitle: "Medical Aid Card",
|
||||
onWindowTapClose: null,
|
||||
backgroundColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
foregroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
windowBody: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${patientManagerProvider.selectedPatient!.medical_aid_name} - ${patientManagerProvider.selectedPatient!.medical_aid_scheme}",
|
||||
style: titleStyle,
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Main Member: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(
|
||||
patientManagerProvider,
|
||||
patientManagerProvider
|
||||
.selectedPatient!.medical_aid_main_member),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "No: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(
|
||||
patientManagerProvider,
|
||||
patientManagerProvider
|
||||
.selectedPatient!.medical_aid_no),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
RichText(
|
||||
text: TextSpan(
|
||||
children: <TextSpan>[
|
||||
TextSpan(
|
||||
text: "Code: ",
|
||||
style: subtitleHeadingStyle,
|
||||
),
|
||||
TextSpan(
|
||||
text: getDisplayText(
|
||||
patientManagerProvider,
|
||||
patientManagerProvider
|
||||
.selectedPatient!.medical_aid_code),
|
||||
style: subtitleStyle,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void initialiseControllers(PatientManagerProvider patientManagerProvider) {
|
||||
medAid = patientManagerProvider.selectedPatient!.medical_aid;
|
||||
if (medAid == "Yes") {
|
||||
medAidPosition = true;
|
||||
} else {
|
||||
medAidPosition = false;
|
||||
}
|
||||
}
|
||||
|
||||
void showEditPatientWindow() {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) {
|
||||
return MihEditPatientDetailsWindow();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return MihPackageToolBody(
|
||||
borderOn: false,
|
||||
innerHorizontalPadding: 10,
|
||||
bodyItem: getBody(screenWidth),
|
||||
);
|
||||
}
|
||||
|
||||
Widget getBody(double width) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
initialiseControllers(patientManagerProvider);
|
||||
return Stack(
|
||||
children: [
|
||||
MihSingleChildScroll(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
MihCircleAvatar(
|
||||
imageFile:
|
||||
patientManagerProvider.selectedPatientProfilePicture,
|
||||
width: 160,
|
||||
editable: false,
|
||||
fileNameController: null,
|
||||
userSelectedfile: null,
|
||||
frameColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
backgroundColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
onChange: () {},
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
buildPatientInfoCard(patientManagerProvider),
|
||||
const SizedBox(height: 10),
|
||||
if (patientManagerProvider.selectedPatient!.medical_aid ==
|
||||
"Yes")
|
||||
buildMedAidInfoCard(patientManagerProvider),
|
||||
],
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 5,
|
||||
top: 5,
|
||||
child: MihButton(
|
||||
width: 40,
|
||||
height: 40,
|
||||
onPressed: () {
|
||||
patientManagerProvider.setHidePatientDetails(
|
||||
!patientManagerProvider.hidePatientDetails);
|
||||
},
|
||||
buttonColor: patientManagerProvider.hidePatientDetails
|
||||
? MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")
|
||||
: MihColors.getRedColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
child: Icon(
|
||||
patientManagerProvider.hidePatientDetails
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: patientManagerProvider.personalMode,
|
||||
child: Positioned(
|
||||
right: 10,
|
||||
bottom: 10,
|
||||
child: MihFloatingMenu(
|
||||
icon: Icons.add,
|
||||
animatedIcon: AnimatedIcons.menu_close,
|
||||
children: [
|
||||
SpeedDialChild(
|
||||
child: Icon(
|
||||
Icons.edit,
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
label: "Edit Profile",
|
||||
labelBackgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
labelStyle: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
backgroundColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onTap: () {
|
||||
showEditPatientWindow();
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,506 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/main.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_button.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_form.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_text_form_field.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_toggle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientSetupForm extends StatefulWidget {
|
||||
const PatientSetupForm({super.key});
|
||||
|
||||
@override
|
||||
State<PatientSetupForm> createState() => _PatientSetupFormState();
|
||||
}
|
||||
|
||||
class _PatientSetupFormState extends State<PatientSetupForm> {
|
||||
final idController = TextEditingController();
|
||||
final fnameController = TextEditingController();
|
||||
final lnameController = TextEditingController();
|
||||
final cellController = TextEditingController();
|
||||
final emailController = TextEditingController();
|
||||
final medNoController = TextEditingController();
|
||||
final medNameController = TextEditingController();
|
||||
final medSchemeController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final medAidController = TextEditingController();
|
||||
final medMainMemController = TextEditingController();
|
||||
final medAidCodeController = TextEditingController();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final FocusNode _focusNode = FocusNode();
|
||||
late bool medAidPosition;
|
||||
late bool medMainMemberPosition;
|
||||
final ValueNotifier<bool> medRequired = ValueNotifier(false);
|
||||
|
||||
Future<void> addPatientService(
|
||||
MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider,
|
||||
) async {
|
||||
int statusCode = await MihPatientServices().addPatientService(
|
||||
idController.text,
|
||||
fnameController.text,
|
||||
lnameController.text,
|
||||
emailController.text,
|
||||
cellController.text,
|
||||
medAidController.text,
|
||||
medMainMemController.text,
|
||||
medNoController.text,
|
||||
medAidCodeController.text,
|
||||
medNameController.text,
|
||||
medSchemeController.text,
|
||||
addressController.text,
|
||||
profileProvider,
|
||||
patientManagerProvider,
|
||||
);
|
||||
if (statusCode == 201) {
|
||||
String message =
|
||||
"${fnameController.text} ${lnameController.text} patient profile has been successfully added!\n";
|
||||
successPopUp("Successfully created Patient Profile", message);
|
||||
} else {
|
||||
MihAlertServices().internetConnectionAlert(context);
|
||||
}
|
||||
}
|
||||
|
||||
void successPopUp(String title, String message) {
|
||||
MihAlertServices().successAdvancedAlert(
|
||||
title,
|
||||
message,
|
||||
[
|
||||
MihButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
context.goNamed(
|
||||
'patientProfile',
|
||||
);
|
||||
},
|
||||
buttonColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
elevation: 10,
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Dismiss",
|
||||
style: TextStyle(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
void isRequired() {
|
||||
//print("listerner triggered");
|
||||
if (medAidController.text == "Yes") {
|
||||
medRequired.value = true;
|
||||
} else {
|
||||
medRequired.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Widget displayForm(double width) {
|
||||
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
return SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding:
|
||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||
child: Column(
|
||||
children: [
|
||||
MihForm(
|
||||
formKey: _formKey,
|
||||
formFields: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"Personal",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25.0,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: idController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "ID No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: fnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "First Name",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: lnameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Surname",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: cellController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Cell No.",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: emailController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
readOnly: true,
|
||||
hintText: "Email",
|
||||
validator: (value) {
|
||||
return MihValidationServices().validateEmail(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
height: 100,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
controller: addressController,
|
||||
multiLineInput: true,
|
||||
requiredText: true,
|
||||
hintText: "Address",
|
||||
validator: (value) {
|
||||
return MihValidationServices().isEmpty(value);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15.0),
|
||||
Center(
|
||||
child: Text(
|
||||
"Medical Aid Details",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 25.0,
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark")),
|
||||
const SizedBox(height: 10.0),
|
||||
MihToggle(
|
||||
hintText: "Medical Aid",
|
||||
initialPostion: medAidPosition,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
onChange: (value) {
|
||||
if (value) {
|
||||
setState(() {
|
||||
medAidController.text = "Yes";
|
||||
medAidPosition = value;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
medAidController.text = "No";
|
||||
medAidPosition = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
ValueListenableBuilder(
|
||||
valueListenable: medRequired,
|
||||
builder:
|
||||
(BuildContext context, bool value, Widget? child) {
|
||||
return Visibility(
|
||||
visible: value,
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 10.0),
|
||||
MihToggle(
|
||||
hintText: "Main Member",
|
||||
initialPostion: medMainMemberPosition,
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
secondaryFillColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
onChange: (value) {
|
||||
if (value) {
|
||||
setState(() {
|
||||
medMainMemController.text = "Yes";
|
||||
medMainMemberPosition = value;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
medMainMemController.text = "No";
|
||||
medMainMemberPosition = value;
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: medNoController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "No.",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: medAidCodeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Code",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: medNameController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Name",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
MihTextFormField(
|
||||
fillColor: MihColors.getSecondaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
inputColor: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!
|
||||
.theme
|
||||
.mode ==
|
||||
"Dark"),
|
||||
controller: medSchemeController,
|
||||
multiLineInput: false,
|
||||
requiredText: true,
|
||||
hintText: "Plan",
|
||||
validator: (validationValue) {
|
||||
if (value) {
|
||||
return MihValidationServices()
|
||||
.isEmpty(validationValue);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 10.0),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 20.0),
|
||||
Center(
|
||||
child: MihButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
addPatientService(
|
||||
profileProvider, patientManagerProvider);
|
||||
} else {
|
||||
MihAlertServices().inputErrorAlert(context);
|
||||
}
|
||||
},
|
||||
buttonColor: MihColors.getGreenColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
width: 300,
|
||||
child: Text(
|
||||
"Add",
|
||||
style: TextStyle(
|
||||
color: MihColors.getPrimaryColor(
|
||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||
"Dark"),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30.0),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
idController.dispose();
|
||||
fnameController.dispose();
|
||||
lnameController.dispose();
|
||||
cellController.dispose();
|
||||
emailController.dispose();
|
||||
medNoController.dispose();
|
||||
medNameController.dispose();
|
||||
medSchemeController.dispose();
|
||||
addressController.dispose();
|
||||
medAidController.dispose();
|
||||
medAidCodeController.removeListener(isRequired);
|
||||
medRequired.dispose();
|
||||
medMainMemController.dispose();
|
||||
medAidCodeController.dispose();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
medAidController.addListener(isRequired);
|
||||
MzansiProfileProvider profileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
setState(() {
|
||||
fnameController.text = profileProvider.user!.fname;
|
||||
lnameController.text = profileProvider.user!.lname;
|
||||
emailController.text = profileProvider.user!.email;
|
||||
medAidPosition = false;
|
||||
medMainMemberPosition = false;
|
||||
medAidController.text = "No";
|
||||
medMainMemController.text = "No";
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
return displayForm(screenWidth);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/mzansi_profile_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_claim_or_statement.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_claim_statement_generation_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_data_helper_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientProfile extends StatefulWidget {
|
||||
const PatientProfile({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PatientProfile> createState() => _PatientProfileState();
|
||||
}
|
||||
|
||||
class _PatientProfileState extends State<PatientProfile> {
|
||||
bool _isLoadingInitialData = true;
|
||||
late final PatientInfo _patientInfo;
|
||||
late final PatientConsultation _patienConsultation;
|
||||
late final PatientDocuments _patientDocuments;
|
||||
late final PatientClaimOrStatement _patientClaimOrStatement;
|
||||
|
||||
Future<void> _loadInitialData() async {
|
||||
setState(() {
|
||||
_isLoadingInitialData = true;
|
||||
});
|
||||
MzansiProfileProvider mzansiProfileProvider =
|
||||
context.read<MzansiProfileProvider>();
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
if (mzansiProfileProvider.user == null) {
|
||||
await MihDataHelperServices().loadUserDataOnly(
|
||||
mzansiProfileProvider,
|
||||
);
|
||||
}
|
||||
if (patientManagerProvider.selectedPatient == null) {
|
||||
await MihPatientServices().getPatientDetails(
|
||||
mzansiProfileProvider.user!.app_id, patientManagerProvider);
|
||||
}
|
||||
if (patientManagerProvider.selectedPatient!.app_id !=
|
||||
mzansiProfileProvider.user!.app_id &&
|
||||
patientManagerProvider.personalMode) {
|
||||
await MihPatientServices().getPatientDetails(
|
||||
mzansiProfileProvider.user!.app_id, patientManagerProvider);
|
||||
}
|
||||
if (patientManagerProvider.selectedPatient == null) {
|
||||
context.goNamed("patientProfileSetup");
|
||||
return;
|
||||
}
|
||||
if (patientManagerProvider.personalMode) {
|
||||
patientManagerProvider.setSelectedPatientProfilePicUrl(
|
||||
mzansiProfileProvider.userProfilePicUrl!);
|
||||
} else {
|
||||
AppUser? patientUserDetails = await MihUserServices().getMIHUserDetails(
|
||||
patientManagerProvider.selectedPatient!.app_id, context);
|
||||
String patientProPicUrl =
|
||||
await MihFileApi.getMinioFileUrl(patientUserDetails!.pro_pic_path);
|
||||
patientManagerProvider.setSelectedPatientProfilePicUrl(patientProPicUrl);
|
||||
}
|
||||
patientManagerProvider.setPersonalMode(mzansiProfileProvider.personalHome);
|
||||
if (patientManagerProvider.selectedPatient != null) {
|
||||
await MihPatientServices()
|
||||
.getPatientConsultationNotes(patientManagerProvider);
|
||||
await MihPatientServices().getPatientDocuments(patientManagerProvider);
|
||||
await MIHClaimStatementGenerationApi.getClaimStatementFilesByPatient(
|
||||
patientManagerProvider);
|
||||
}
|
||||
setState(() {
|
||||
_isLoadingInitialData = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_patientInfo = PatientInfo();
|
||||
_patienConsultation = PatientConsultation();
|
||||
_patientDocuments = PatientDocuments();
|
||||
_patientClaimOrStatement = PatientClaimOrStatement();
|
||||
_loadInitialData();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<PatientManagerProvider>(
|
||||
builder: (BuildContext context,
|
||||
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||
if (_isLoadingInitialData) {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Mihloadingcircle(),
|
||||
),
|
||||
);
|
||||
}
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex:
|
||||
context.watch<PatientManagerProvider>().patientProfileIndex,
|
||||
onIndexChange: (newValue) {
|
||||
context
|
||||
.read<PatientManagerProvider>()
|
||||
.setPatientProfileIndex(newValue);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
if (!patientManagerProvider.personalMode) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
}
|
||||
patientManagerProvider.setPatientProfileIndex(0);
|
||||
patientManagerProvider.setHidePatientDetails(true);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.perm_identity)] = () {
|
||||
patientManagerProvider.setPatientProfileIndex(0);
|
||||
};
|
||||
temp[const Icon(Icons.article_outlined)] = () {
|
||||
patientManagerProvider.setPatientProfileIndex(1);
|
||||
};
|
||||
temp[const Icon(Icons.file_present)] = () {
|
||||
patientManagerProvider.setPatientProfileIndex(2);
|
||||
};
|
||||
temp[const Icon(Icons.file_open_outlined)] = () {
|
||||
patientManagerProvider.setPatientProfileIndex(3);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: patientManagerProvider.patientProfileIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
return [
|
||||
_patientInfo,
|
||||
_patienConsultation,
|
||||
_patientDocuments,
|
||||
_patientClaimOrStatement,
|
||||
];
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Details",
|
||||
"Notes",
|
||||
"Documents",
|
||||
"Claims",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_action.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_package_components/mih_package_tools.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_providers/patient_manager_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_setup_form.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PatientSetUp extends StatefulWidget {
|
||||
const PatientSetUp({super.key});
|
||||
|
||||
@override
|
||||
State<PatientSetUp> createState() => _PatientSetUpState();
|
||||
}
|
||||
|
||||
class _PatientSetUpState extends State<PatientSetUp> {
|
||||
late final PatientSetupForm _patientSetupForm;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_patientSetupForm = PatientSetupForm();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MihPackage(
|
||||
appActionButton: getAction(),
|
||||
appTools: getTools(),
|
||||
appBody: getToolBody(),
|
||||
appToolTitles: getToolTitle(),
|
||||
selectedbodyIndex:
|
||||
context.watch<PatientManagerProvider>().patientProfileIndex,
|
||||
onIndexChange: (newValue) {
|
||||
context.read<PatientManagerProvider>().setPatientProfileIndex(newValue);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageAction getAction() {
|
||||
return MihPackageAction(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
iconSize: 35,
|
||||
onTap: () {
|
||||
context.goNamed(
|
||||
'mihHome',
|
||||
);
|
||||
FocusScope.of(context).unfocus();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
MihPackageTools getTools() {
|
||||
PatientManagerProvider patientManagerProvider =
|
||||
context.read<PatientManagerProvider>();
|
||||
Map<Widget, void Function()?> temp = {};
|
||||
temp[const Icon(Icons.medical_services)] = () {
|
||||
patientManagerProvider.setPatientProfileIndex(0);
|
||||
};
|
||||
return MihPackageTools(
|
||||
tools: temp,
|
||||
selcetedIndex: patientManagerProvider.patientProfileIndex,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> getToolBody() {
|
||||
return [
|
||||
_patientSetupForm,
|
||||
];
|
||||
}
|
||||
|
||||
List<String> getToolTitle() {
|
||||
List<String> toolTitles = [
|
||||
"Set Up Patient Profile",
|
||||
];
|
||||
return toolTitles;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user