Reconfig app

This commit is contained in:
2024-09-17 14:58:59 +02:00
parent ee1d42b94d
commit 5256694747
54 changed files with 802 additions and 916 deletions

View File

@@ -1,7 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/MIH_Packages/MIH_Home/homeTileGrid.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

@@ -1,14 +1,14 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Tile.dart';
import 'package:patient_manager/components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/components/mihAppDrawer.dart';
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihWarningMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Tile.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_AppDrawer.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihWarningMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
@@ -149,10 +149,31 @@ class _HomeTileGridState extends State<HomeTileGrid> {
}
void setAppsBusiness(List<MIHTile> tileList) {
// tileList.add(MIHTile(
// onTap: () {
// Navigator.of(context).pushNamed(
// '/business-profile',
// arguments: BusinessArguments(
// widget.signedInUser,
// widget.businessUser,
// widget.business,
// ),
// );
// },
// tileName: "Manage Business",
// tileIcon: Icon(
// Icons.business,
// color: getSec(),
// size: 200,
// ),
// p: getPrim(),
// s: getSec(),
// ));
//if (widget.businessUser!.access == "Full") {
tileList.add(MIHTile(
onTap: () {
Navigator.of(context).pushNamed(
'/business-profile',
'/business-profile/manage',
arguments: BusinessArguments(
widget.signedInUser,
widget.businessUser,
@@ -160,7 +181,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
),
);
},
tileName: "Manage Business",
tileName: "Business Profile",
tileIcon: Icon(
Icons.business,
color: getSec(),
@@ -169,28 +190,7 @@ class _HomeTileGridState extends State<HomeTileGrid> {
p: getPrim(),
s: getSec(),
));
if (widget.businessUser!.access == "Full") {
tileList.add(MIHTile(
onTap: () {
Navigator.of(context).pushNamed(
'/business-profile/manage',
arguments: BusinessArguments(
widget.signedInUser,
widget.businessUser,
widget.business,
),
);
},
tileName: "Manage Team",
tileIcon: Icon(
Icons.people_outline,
color: getSec(),
size: 200,
),
p: getPrim(),
s: getSec(),
));
}
//}
if (widget.business!.type == "Doctors Office") {
tileList.add(MIHTile(
onTap: () {

View File

@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Tile.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Tile.dart';
import 'package:patient_manager/main.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

View File

@@ -1,9 +1,9 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/accessRequest.dart';

View File

@@ -1,13 +1,13 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/MIH_Packages/access_review/builder/buildAccessRequestList.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/accessRequest.dart';

View File

@@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:supabase_auth_ui/supabase_auth_ui.dart';

View File

@@ -2,12 +2,12 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihPassInput.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihPassInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
//import 'package:patient_manager/objects/sessionST.dart';

View File

@@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/inputsAndButtons/mihPassInput.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihPassInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:supabase_auth_ui/supabase_auth_ui.dart';

View File

@@ -2,12 +2,12 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Tile.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihPassInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Tile.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihPassInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:supabase_auth_ui/supabase_auth_ui.dart';

View File

@@ -1,484 +0,0 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/builders/buildEmployeeList.dart';
import 'package:patient_manager/components/builders/buildUserList.dart';
import 'package:patient_manager/components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/businessEmployee.dart';
import 'package:supertokens_flutter/http.dart' as http;
class ManageBusinessProfile extends StatefulWidget {
final BusinessArguments arguments;
const ManageBusinessProfile({
super.key,
required this.arguments,
});
@override
State<ManageBusinessProfile> createState() => _ManageBusinessProfileState();
}
class _ManageBusinessProfileState extends State<ManageBusinessProfile> {
final FocusNode _focusNode = FocusNode();
final baseAPI = AppEnviroment.baseApiUrl;
final TextEditingController searchController = TextEditingController();
String userSearch = "";
String errorCode = "";
String errorBody = "";
int selectionIndex = 0;
late Future<List<BusinessEmployee>> employeeList;
late Future<List<AppUser>> userSearchResults;
Future<List<BusinessEmployee>> fetchEmployees() async {
//print("Patien manager page: $endpoint");
final response = await http.get(Uri.parse(
"${AppEnviroment.baseApiUrl}/business-user/employees/${widget.arguments.businessUser!.business_id}"));
errorCode = response.statusCode.toString();
errorBody = response.body;
if (response.statusCode == 200) {
//print("Here1");
Iterable l = jsonDecode(response.body);
//print("Here2");
List<BusinessEmployee> patientQueue = List<BusinessEmployee>.from(
l.map((model) => BusinessEmployee.fromJson(model)));
//print("Here3");
//print(patientQueue);
return patientQueue;
} else {
throw Exception('failed to load employees');
}
}
Future<List<AppUser>> fetchUsers(String search) async {
//TODO
final response = await http
.get(Uri.parse("${AppEnviroment.baseApiUrl}/users/search/$search"));
errorCode = response.statusCode.toString();
errorBody = response.body;
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<AppUser> users =
List<AppUser>.from(l.map((model) => AppUser.fromJson(model)));
return users;
} else {
throw Exception('failed to load patients');
}
}
Widget employeesview(double w, double h) {
return SizedBox(
width: w,
height: h - 157,
child: Column(mainAxisSize: MainAxisSize.max, children: [
const Text(
"Business Team",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
const SizedBox(height: 15),
FutureBuilder(
future: employeeList,
builder: (context, snapshot) {
//print("patient Queue List ${snapshot.hasData}");
if (snapshot.connectionState == ConnectionState.waiting) {
return Expanded(
child: Container(
height: 500,
decoration: BoxDecoration(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
width: 3.0),
),
child: const Mihloadingcircle(),
),
);
} else if (snapshot.connectionState == ConnectionState.done) {
//List<BusinessEmployee> employeeListResults;
// if (searchString == "") {
// patientQueueList = [];
// } else {
// print(patientQueueList);
// }
return Expanded(
child: displayEmployeeList(snapshot.requireData),
);
} else {
return Expanded(
child: Container(
//height: 500,
decoration: BoxDecoration(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
width: 3.0),
),
child: Center(
child: Text(
"$errorCode: Error pulling Patients Data\n${AppEnviroment.baseApiUrl}/business-user/users/${widget.arguments.businessUser!.business_id}\n$errorBody",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!
.theme
.errorColor()),
textAlign: TextAlign.center,
),
),
),
);
}
},
),
]),
);
}
Widget displayEmployeeList(List<BusinessEmployee> employeeList) {
if (employeeList.isNotEmpty) {
return Container(
height: 500,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 3.0,
),
),
child: BuildEmployeeList(
employees: employeeList,
arguments: widget.arguments,
),
);
}
return Container(
//height: 500,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 3.0),
),
child: Center(
child: Text(
"",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!.theme.messageTextColor()),
textAlign: TextAlign.center,
),
),
);
}
Widget displayUserList(List<AppUser> userList) {
if (userList.isNotEmpty) {
return Container(
height: 500,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 3.0,
),
),
child: BuildUserList(
users: userList,
arguments: widget.arguments,
),
);
}
return Container(
//height: 500,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 3.0),
),
child: Center(
child: Text(
"Enter Username or Email to search",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!.theme.messageTextColor()),
textAlign: TextAlign.center,
),
),
);
}
void submitUserForm() {
if (searchController.text != "") {
setState(() {
userSearch = searchController.text;
userSearchResults = fetchUsers(userSearch);
});
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
}
Widget userSearchView(double w, double h) {
return KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
submitUserForm();
}
},
child: SizedBox(
width: w,
height: h - 157,
child: Column(mainAxisSize: MainAxisSize.max, children: [
const SizedBox(height: 5),
const Text(
"User Search",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
//spacer
const SizedBox(height: 10),
MIHSearchField(
controller: searchController,
hintText: "Username or Email Search",
required: true,
editable: true,
onTap: () {
submitUserForm();
},
),
//spacer
const SizedBox(height: 10),
FutureBuilder(
future: userSearchResults,
builder: (context, snapshot) {
//print("patient Liust ${snapshot.data}");
if (snapshot.connectionState == ConnectionState.waiting) {
return Expanded(
child: Container(
//height: 500,
decoration: BoxDecoration(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
width: 3.0),
),
child: const Mihloadingcircle(),
),
);
} else if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
List<AppUser> patientsList;
if (userSearch == "") {
patientsList = [];
} else {
patientsList = snapshot.data!;
//print(patientsList);
}
return Expanded(
child: displayUserList(patientsList),
);
} else {
return Expanded(
child: Container(
//height: 500,
decoration: BoxDecoration(
color:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
width: 3.0),
),
child: Center(
child: Text(
"$errorCode: Error pulling Patients Data\n/patients/search/$userSearch\n$errorBody",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!
.theme
.errorColor()),
textAlign: TextAlign.center,
),
),
),
);
}
},
),
]),
),
);
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void emailError() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Invalid Email");
},
);
}
Widget showSelection(
int selectionIndex, double screenWidth, double screenHeight) {
if (selectionIndex == 0) {
return SizedBox(
//width: 660,
child: employeesview(screenWidth, screenHeight),
);
} else {
return userSearchView(screenWidth, screenHeight);
}
}
@override
void dispose() {
searchController.dispose();
_focusNode.dispose();
super.dispose();
}
@override
void initState() {
userSearchResults = fetchUsers("abc");
employeeList = fetchEmployees();
super.initState();
}
@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenHeight = MediaQuery.of(context).size.height;
return Scaffold(
// appBar: const MIHAppBar(
// barTitle: "Business Profile",
// propicFile: null,
// ),
//drawer: MIHAppDrawer(signedInUser: widget.arguments.signedInUser),
body: SafeArea(
child: Stack(
children: [
SingleChildScrollView(
padding: const EdgeInsets.all(15),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
//const SizedBox(height: 20),
SizedBox(
width: screenWidth,
child: Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.end,
children: [
IconButton(
onPressed: () {
setState(() {
selectionIndex = 0;
});
},
icon: const Icon(
Icons.people_outline,
size: 35,
),
),
IconButton(
onPressed: () {
setState(() {
selectionIndex = 1;
});
},
icon: const Icon(
Icons.add,
size: 35,
),
),
],
),
),
showSelection(selectionIndex, screenWidth, screenHeight),
],
),
),
Positioned(
top: 10,
left: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back),
),
),
],
),
),
);
}
}

View File

@@ -0,0 +1,318 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/businessEmployee.dart';
import 'package:supertokens_flutter/http.dart' as http;
class BuildEmployeeList extends StatefulWidget {
final List<BusinessEmployee> employees;
final BusinessArguments arguments;
const BuildEmployeeList({
super.key,
required this.employees,
required this.arguments,
});
@override
State<BuildEmployeeList> createState() => _BuildEmployeeListState();
}
class _BuildEmployeeListState extends State<BuildEmployeeList> {
TextEditingController accessController = TextEditingController();
TextEditingController typeController = TextEditingController();
TextEditingController fnameController = TextEditingController();
TextEditingController lnameController = TextEditingController();
final baseAPI = AppEnviroment.baseApiUrl;
Future<void> updateEmployeeAPICall(int index) async {
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle();
},
);
var response = await http.put(
Uri.parse("$baseAPI/business-user/employees/update/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.employees[index].business_id,
"app_id": widget.employees[index].app_id,
"title": typeController.text,
"access": accessController.text,
}),
);
if (response.statusCode == 200) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
//setState(() {});
Navigator.of(context).pushNamed(
'/business-profile/manage',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
String message = "Your employees details have been updated.";
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
Future<void> deleteNoteApiCall(int index) async {
var response = await http.delete(
Uri.parse("$baseAPI/business-user/employees/delete/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.employees[index].business_id,
"app_id": widget.employees[index].app_id,
}),
);
//print("Here4");
//print(response.statusCode);
if (response.statusCode == 200) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed(
'/business-profile/manage',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
String message =
"The employee has been deleted successfully. This means it will no longer have access to your business profile";
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void updateEmployeePopUp(int index) {
setState(() {
accessController.text = widget.employees[index].access;
typeController.text = widget.employees[index].title;
fnameController.text = widget.employees[index].fname;
lnameController.text = widget.employees[index].lname;
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Employee Details",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: typeController,
hintText: "Title",
dropdownOptions: const ["Doctor", "Assistant"],
required: true,
editable: true,
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: accessController,
hintText: "Access",
dropdownOptions: const ["Full", "Partial"],
required: true,
editable: true,
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Update",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
onTap: () {
updateEmployeeAPICall(index);
},
),
)
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
Positioned(
top: 5,
left: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
showDeleteWarning(index);
},
icon: Icon(
Icons.delete,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
size: 35,
),
),
),
],
),
),
);
}
void showDeleteWarning(int index) {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => MIHDeleteMessage(
deleteType: "Employee",
onTap: () {
deleteNoteApiCall(index);
}));
}
@override
void dispose() {
accessController.dispose();
typeController.dispose();
fnameController.dispose();
lnameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.employees.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
var isMe = "";
if (widget.arguments.signedInUser.app_id ==
widget.employees[index].app_id) {
isMe = "(You)";
}
return ListTile(
title: Text(
"${widget.employees[index].fname} ${widget.employees[index].lname} - ${widget.employees[index].title} $isMe"),
subtitle: Text(
"${widget.employees[index].username}\n${widget.employees[index].email}\nAccess: ${widget.employees[index].access}",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
updateEmployeePopUp(index);
},
);
},
);
}
}

View File

@@ -0,0 +1,262 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:supertokens_flutter/http.dart' as http;
class BuildUserList extends StatefulWidget {
final List<AppUser> users;
final BusinessArguments arguments;
const BuildUserList({
super.key,
required this.users,
required this.arguments,
});
@override
State<BuildUserList> createState() => _BuildUserListState();
}
class _BuildUserListState extends State<BuildUserList> {
TextEditingController accessController = TextEditingController();
TextEditingController typeController = TextEditingController();
TextEditingController fnameController = TextEditingController();
TextEditingController lnameController = TextEditingController();
final baseAPI = AppEnviroment.baseApiUrl;
Future<void> createBusinessUserAPICall(int index) async {
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle();
},
);
var response = await http.post(
Uri.parse("$baseAPI/business-user/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.arguments.business!.business_id,
"app_id": widget.users[index].app_id,
"signature": "",
"sig_path": "",
"title": typeController.text,
"access": accessController.text,
}),
);
if (response.statusCode == 201) {
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed(
'/business-profile/manage',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
String message =
"${widget.users[index].username} is now apart of your team with ${accessController.text} access to ${widget.arguments.business!.Name}";
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
String hideEmail(String email) {
var firstLetter = email[0];
var end = email.split("@")[1];
return "$firstLetter********@$end";
}
void addEmployeePopUp(int index) {
setState(() {
//accessController.text = widget.users[index].access;
//typeController.text = widget.users[index].title;
// var fnameInitial = widget.users[index].fname[0];
// var lnameInitial = widget.users[index].lname[0];
fnameController.text = widget.users[index].username;
lnameController.text = hideEmail(widget.users[index].email);
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Add Employee",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
MIHTextField(
controller: fnameController,
hintText: "Username Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Email",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: typeController,
hintText: "Title",
dropdownOptions: const ["Doctor", "Assistant"],
required: true,
editable: true,
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: accessController,
hintText: "Access",
dropdownOptions: const ["Full", "Partial"],
required: true,
editable: true,
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Add",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
onTap: () {
createBusinessUserAPICall(index);
},
),
)
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
),
),
);
}
@override
void dispose() {
accessController.dispose();
typeController.dispose();
fnameController.dispose();
lnameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
shrinkWrap: true,
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.users.length,
itemBuilder: (context, index) {
var isYou = "";
if (widget.arguments.signedInUser.app_id ==
widget.users[index].app_id) {
isYou = "(You)";
}
return ListTile(
title: Text("@${widget.users[index].username} $isYou"),
subtitle: Text(
"Email: ${hideEmail(widget.users[index].email)}",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
addEmployeePopUp(index);
},
);
},
);
}
}

View File

@@ -3,13 +3,13 @@ import 'dart:convert';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.dart';
@@ -17,20 +17,20 @@ import 'package:supertokens_flutter/http.dart' as http;
import 'package:supertokens_flutter/supertokens.dart';
import 'package:http/http.dart' as http2;
class ProfileBusinessUpdate extends StatefulWidget {
class BusinessDetails extends StatefulWidget {
final BusinessArguments arguments;
const ProfileBusinessUpdate({
const BusinessDetails({
super.key,
required this.arguments,
});
@override
State<ProfileBusinessUpdate> createState() => _ProfileBusinessUpdateState();
State<BusinessDetails> createState() => _BusinessDetailsState();
}
class BusinessUserScreenArguments {}
class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
class _BusinessDetailsState extends State<BusinessDetails> {
final FocusNode _focusNode = FocusNode();
final baseAPI = AppEnviroment.baseApiUrl;
@@ -317,206 +317,185 @@ class _ProfileBusinessUpdateState extends State<ProfileBusinessUpdate> {
@override
Widget build(BuildContext context) {
return Scaffold(
// appBar: const MIHAppBar(
// barTitle: "Business Profile",
// propicFile: null,
// ),
//drawer: MIHAppDrawer(signedInUser: widget.arguments.signedInUser),
body: SafeArea(
child: Stack(
children: [
KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
//print(business_id);
submitForm(business_id);
}
},
child: SingleChildScrollView(
padding: const EdgeInsets.all(15),
return SafeArea(
child: KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
//print(business_id);
submitForm(business_id);
}
},
child: SingleChildScrollView(
child: Column(
children: [
Visibility(
visible: isFullAccess(),
child: Column(
children: [
Visibility(
visible: isFullAccess(),
child: Column(
children: [
const Text(
"Business Profile",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
const SizedBox(height: 25.0),
MIHTextField(
controller: regController,
hintText: "Registration No.",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: nameController,
hintText: "Business Name",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: typeController,
hintText: "Business Type",
dropdownOptions: const ["Doctors Office", "Other"],
required: true,
editable: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: contactController,
hintText: "Contact Number",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: emailController,
hintText: "Email",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHFileField(
controller: logonameController,
hintText: "Logo",
editable: false,
required: true,
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'png', 'pdf'],
);
if (result == null) return;
final selectedFile = result.files.first;
setState(() {
selectedLogo = selectedFile;
});
setState(() {
logonameController.text = selectedFile.name;
});
},
),
const SizedBox(height: 15.0),
Divider(
color: MzanziInnovationHub.of(context)
?.theme
.secondaryColor(),
),
],
const Text(
"Business Profile",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
Column(
children: [
//const SizedBox(height: 15.0),
const Text(
"My Business User",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
const SizedBox(height: 25.0),
MIHDropdownField(
controller: titleController,
hintText: "Title",
dropdownOptions: const ["Doctor", "Assistant"],
required: true,
editable: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHFileField(
controller: signtureController,
hintText: "Signature",
editable: false,
required: true,
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'png', 'pdf'],
);
if (result == null) return;
final selectedFile = result.files.first;
setState(() {
selectedSignature = selectedFile;
});
setState(() {
signtureController.text = selectedFile.name;
});
},
),
const SizedBox(height: 15.0),
MIHDropdownField(
controller: accessController,
hintText: "Access",
dropdownOptions: const ["Full", "Partial"],
required: true,
editable: false,
),
const SizedBox(height: 30.0),
SizedBox(
width: 500.0,
height: 50.0,
child: MIHButton(
buttonText: "Update",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
onTap: () {
//print(business_id);
submitForm(business_id);
},
),
),
],
Divider(
color: MzanziInnovationHub.of(context)
?.theme
.secondaryColor(),
),
const SizedBox(height: 10.0),
MIHTextField(
controller: regController,
hintText: "Registration No.",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: nameController,
hintText: "Business Name",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: typeController,
hintText: "Business Type",
dropdownOptions: const ["Doctors Office", "Other"],
required: true,
editable: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: contactController,
hintText: "Contact Number",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: emailController,
hintText: "Email",
editable: true,
required: true,
),
const SizedBox(height: 10.0),
MIHFileField(
controller: logonameController,
hintText: "Logo",
editable: false,
required: true,
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'png', 'pdf'],
);
if (result == null) return;
final selectedFile = result.files.first;
setState(() {
selectedLogo = selectedFile;
});
setState(() {
logonameController.text = selectedFile.name;
});
},
),
const SizedBox(height: 15.0),
],
),
),
),
Positioned(
top: 10,
left: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.of(context).pop();
},
icon: const Icon(Icons.arrow_back),
Column(
children: [
//const SizedBox(height: 15.0),
const Text(
"My Business User",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
Divider(
color:
MzanziInnovationHub.of(context)?.theme.secondaryColor(),
),
const SizedBox(height: 10.0),
MIHDropdownField(
controller: titleController,
hintText: "Title",
dropdownOptions: const ["Doctor", "Assistant"],
required: true,
editable: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHFileField(
controller: signtureController,
hintText: "Signature",
editable: false,
required: true,
onPressed: () async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'png', 'pdf'],
);
if (result == null) return;
final selectedFile = result.files.first;
setState(() {
selectedSignature = selectedFile;
});
setState(() {
signtureController.text = selectedFile.name;
});
},
),
const SizedBox(height: 15.0),
MIHDropdownField(
controller: accessController,
hintText: "Access",
dropdownOptions: const ["Full", "Partial"],
required: true,
editable: false,
),
const SizedBox(height: 30.0),
SizedBox(
width: 500.0,
height: 50.0,
child: MIHButton(
buttonText: "Update",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor:
MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
//print(business_id);
submitForm(business_id);
},
),
),
],
),
)
],
],
),
),
),
);

View File

@@ -0,0 +1,445 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/MIH_Packages/manage_business/businessDetails.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/MIH_Packages/manage_business/builder/buildEmployeeList.dart';
import 'package:patient_manager/MIH_Packages/manage_business/builder/buildUserList.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/businessEmployee.dart';
import 'package:supertokens_flutter/http.dart' as http;
class ManageBusinessProfile extends StatefulWidget {
final BusinessArguments arguments;
const ManageBusinessProfile({
super.key,
required this.arguments,
});
@override
State<ManageBusinessProfile> createState() => _ManageBusinessProfileState();
}
class _ManageBusinessProfileState extends State<ManageBusinessProfile> {
final FocusNode _focusNode = FocusNode();
final baseAPI = AppEnviroment.baseApiUrl;
final TextEditingController searchController = TextEditingController();
String userSearch = "";
String errorCode = "";
String errorBody = "";
int selectionIndex = 0;
late Future<List<BusinessEmployee>> employeeList;
late Future<List<AppUser>> userSearchResults;
Future<List<BusinessEmployee>> fetchEmployees() async {
//print("Patien manager page: $endpoint");
final response = await http.get(Uri.parse(
"${AppEnviroment.baseApiUrl}/business-user/employees/${widget.arguments.businessUser!.business_id}"));
errorCode = response.statusCode.toString();
errorBody = response.body;
if (response.statusCode == 200) {
//print("Here1");
Iterable l = jsonDecode(response.body);
//print("Here2");
List<BusinessEmployee> patientQueue = List<BusinessEmployee>.from(
l.map((model) => BusinessEmployee.fromJson(model)));
//print("Here3");
//print(patientQueue);
return patientQueue;
} else {
throw Exception('failed to load employees');
}
}
Future<List<AppUser>> fetchUsers(String search) async {
//TODO
final response = await http
.get(Uri.parse("${AppEnviroment.baseApiUrl}/users/search/$search"));
errorCode = response.statusCode.toString();
errorBody = response.body;
if (response.statusCode == 200) {
Iterable l = jsonDecode(response.body);
List<AppUser> users =
List<AppUser>.from(l.map((model) => AppUser.fromJson(model)));
return users;
} else {
throw Exception('failed to load patients');
}
}
Widget employeesview() {
return Column(mainAxisSize: MainAxisSize.max, children: [
const Text(
"Business Team",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 25,
),
),
Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
FutureBuilder(
future: employeeList,
builder: (context, snapshot) {
//print("patient Queue List ${snapshot.hasData}");
if (snapshot.connectionState == ConnectionState.waiting) {
return const Mihloadingcircle();
} else if (snapshot.connectionState == ConnectionState.done) {
//List<BusinessEmployee> employeeListResults;
// if (searchString == "") {
// patientQueueList = [];
// } else {
// print(patientQueueList);
// }
return displayEmployeeList(snapshot.requireData);
} else {
return Center(
child: Text(
"$errorCode: Error pulling Patients Data\n${AppEnviroment.baseApiUrl}/business-user/users/${widget.arguments.businessUser!.business_id}\n$errorBody",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!.theme.errorColor()),
textAlign: TextAlign.center,
),
);
}
},
),
]);
}
Widget displayEmployeeList(List<BusinessEmployee> employeeList) {
if (employeeList.isNotEmpty) {
return BuildEmployeeList(
employees: employeeList,
arguments: widget.arguments,
);
}
return Center(
child: Text(
"",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!.theme.messageTextColor()),
textAlign: TextAlign.center,
),
);
}
Widget displayUserList(List<AppUser> userList) {
if (userList.isNotEmpty) {
return BuildUserList(
users: userList,
arguments: widget.arguments,
);
}
return Center(
child: Text(
"Enter Username or Email to search",
style: TextStyle(
fontSize: 25,
color: MzanziInnovationHub.of(context)!.theme.messageTextColor()),
textAlign: TextAlign.center,
),
);
}
void submitUserForm() {
if (searchController.text != "") {
setState(() {
userSearch = searchController.text;
userSearchResults = fetchUsers(userSearch);
});
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
}
Widget userSearchView() {
return KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
submitUserForm();
}
},
child: Column(mainAxisSize: MainAxisSize.max, children: [
const Text(
"User Search",
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold),
),
//spacer
Divider(color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
const SizedBox(height: 10),
MIHSearchField(
controller: searchController,
hintText: "Username or Email Search",
required: true,
editable: true,
onTap: () {
submitUserForm();
},
),
//spacer
const SizedBox(height: 10),
FutureBuilder(
future: userSearchResults,
builder: (context, snapshot) {
//print("patient Liust ${snapshot.data}");
if (snapshot.connectionState == ConnectionState.waiting) {
return const Mihloadingcircle();
} else if (snapshot.connectionState == ConnectionState.done &&
snapshot.hasData) {
List<AppUser> patientsList;
if (userSearch == "") {
patientsList = [];
} else {
patientsList = snapshot.data!;
//print(patientsList);
}
return displayUserList(patientsList);
} else {
return Center(
child: Text(
"$errorCode: Error pulling Patients Data\n/patients/search/$userSearch\n$errorBody",
style: TextStyle(
fontSize: 25,
color:
MzanziInnovationHub.of(context)!.theme.errorColor()),
textAlign: TextAlign.center,
),
);
}
},
),
]),
);
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void emailError() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Invalid Email");
},
);
}
Widget showSelection(int selectionIndex) {
if (selectionIndex == 0) {
return BusinessDetails(arguments: widget.arguments);
} else if (selectionIndex == 1) {
return employeesview();
} else {
return userSearchView();
}
}
MIHAction getActionButton() {
return MIHAction(
icon: Icons.arrow_back,
iconSize: 35,
onTap: () {
Navigator.of(context).pushNamedAndRemoveUntil('/', (route) => false);
},
);
}
MIHHeader getHeader() {
bool isFullAccess = false;
if (widget.arguments.businessUser!.access == "Full") {
isFullAccess = true;
}
return MIHHeader(
headerAlignment: MainAxisAlignment.end,
headerItems: [
IconButton(
onPressed: () {
setState(() {
selectionIndex = 0;
});
},
icon: const Icon(
Icons.business,
size: 35,
),
),
Visibility(
visible: isFullAccess,
child: IconButton(
onPressed: () {
setState(() {
selectionIndex = 1;
});
},
icon: const Icon(
Icons.people_outline,
size: 35,
),
),
),
Visibility(
visible: isFullAccess,
child: IconButton(
onPressed: () {
setState(() {
selectionIndex = 2;
});
},
icon: const Icon(
Icons.add,
size: 35,
),
),
),
],
);
}
MIHBody getBody() {
return MIHBody(
borderOn: true,
bodyItems: [
showSelection(selectionIndex),
],
);
}
@override
void dispose() {
searchController.dispose();
_focusNode.dispose();
super.dispose();
}
@override
void initState() {
userSearchResults = fetchUsers("abc");
employeeList = fetchEmployees();
super.initState();
}
@override
Widget build(BuildContext context) {
return MIHLayoutBuilder(
actionButton: getActionButton(),
header: getHeader(),
body: getBody(),
);
// return Scaffold(
// // appBar: const MIHAppBar(
// // barTitle: "Business Profile",
// // propicFile: null,
// // ),
// //drawer: MIHAppDrawer(signedInUser: widget.arguments.signedInUser),
// body: SafeArea(
// child: Stack(
// children: [
// SingleChildScrollView(
// padding: const EdgeInsets.all(15),
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// mainAxisSize: MainAxisSize.max,
// children: [
// //const SizedBox(height: 20),
// SizedBox(
// width: screenWidth,
// child: Row(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.end,
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// IconButton(
// onPressed: () {
// setState(() {
// selectionIndex = 0;
// });
// },
// icon: const Icon(
// Icons.people_outline,
// size: 35,
// ),
// ),
// IconButton(
// onPressed: () {
// setState(() {
// selectionIndex = 1;
// });
// },
// icon: const Icon(
// Icons.add,
// size: 35,
// ),
// ),
// ],
// ),
// ),
// showSelection(selectionIndex, screenWidth, screenHeight),
// ],
// ),
// ),
// Positioned(
// top: 10,
// left: 5,
// width: 50,
// height: 50,
// child: IconButton(
// onPressed: () {
// Navigator.of(context).pop();
// },
// icon: const Icon(Icons.arrow_back),
// ),
// ),
// ],
// ),
// ),
// );
}
}

View File

@@ -2,13 +2,13 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

@@ -3,16 +3,16 @@ import 'dart:convert';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.dart';

View File

@@ -1,7 +1,7 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.dart';

View File

@@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/builder/BuildFileView.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

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

View File

@@ -1,18 +1,18 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihMLTextInput.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihDeleteMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihMLTextInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/business.dart';
import 'package:patient_manager/objects/businessUser.dart';
//import 'package:patient_manager/components/mybutton.dart';
//import 'package:patient_manager/MIH_Components/mybutton.dart';
import 'package:patient_manager/objects/notes.dart';
import 'package:patient_manager/objects/patients.dart';
import 'package:supertokens_flutter/http.dart' as http;

View File

@@ -0,0 +1,366 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDateInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTimeInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/business.dart';
import 'package:patient_manager/objects/patients.dart';
import 'package:supertokens_flutter/http.dart' as http;
class BuildPatientsList extends StatefulWidget {
final List<Patient> patients;
final AppUser signedInUser;
final Business? business;
final BusinessArguments arguments;
const BuildPatientsList({
super.key,
required this.patients,
required this.signedInUser,
required this.business,
required this.arguments,
});
@override
State<BuildPatientsList> createState() => _BuildPatientsListState();
}
class _BuildPatientsListState extends State<BuildPatientsList> {
TextEditingController dateController = TextEditingController();
TextEditingController timeController = TextEditingController();
TextEditingController idController = TextEditingController();
TextEditingController fnameController = TextEditingController();
TextEditingController lnameController = TextEditingController();
final baseAPI = AppEnviroment.baseApiUrl;
Future<void> addPatientAppointmentAPICall(int index) async {
var response = await http.post(
Uri.parse("$baseAPI/queue/insert/"),
headers: <String, String>{
"Content-Type": "application/json; charset=UTF-8"
},
body: jsonEncode(<String, dynamic>{
"business_id": widget.business!.business_id,
"app_id": widget.patients[index].app_id,
"date": dateController.text,
"time": timeController.text,
"access": "pending",
}),
);
if (response.statusCode == 201) {
// Navigator.pushNamed(context, '/patient-manager/patient',
// arguments: widget.signedInUser);
String message =
"The appointment has been successfully booked!\n\nAn approval request as been sent to the patient.Once the access request has been approved, you will be able to access the patients profile. ou can check the status of your request in patient queue under the appointment.";
// "${fnameController.text} ${lnameController.text} patient profiole has been successfully added!\n";
Navigator.pop(context);
Navigator.pop(context);
setState(() {
dateController.text = "";
timeController.text = "";
});
Navigator.of(context).pushNamed(
'/patient-manager',
arguments: BusinessArguments(
widget.arguments.signedInUser,
widget.arguments.businessUser,
widget.arguments.business,
),
);
successPopUp(message);
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void submitApointment(int index) {
addPatientAppointmentAPICall(index);
}
bool isAppointmentFieldsFilled() {
if (dateController.text.isEmpty || timeController.text.isEmpty) {
return false;
} else {
return true;
}
}
void appointmentPopUp(int index) {
var firstLetterFName = widget.patients[index].first_name[0];
var firstLetterLName = widget.patients[index].last_name[0];
var fnameStar = '*' * 8;
var lnameStar = '*' * 8;
setState(() {
idController.text = widget.patients[index].id_no;
fnameController.text = firstLetterFName + fnameStar;
lnameController.text = firstLetterLName + lnameStar;
});
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => Dialog(
child: Stack(
children: [
Container(
padding: const EdgeInsets.all(10.0),
width: 700.0,
//height: 475.0,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
width: 5.0),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Patient Appointment",
textAlign: TextAlign.center,
style: TextStyle(
color: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
fontSize: 35.0,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 25.0),
MIHTextField(
controller: idController,
hintText: "ID No.",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: fnameController,
hintText: "First Name",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHTextField(
controller: lnameController,
hintText: "Surname",
editable: false,
required: true,
),
const SizedBox(height: 10.0),
MIHDateField(
controller: dateController,
LableText: "Date",
required: true,
),
const SizedBox(height: 10.0),
MIHTimeField(
controller: timeController,
LableText: "Time",
required: true,
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Book",
buttonColor: MzanziInnovationHub.of(context)!
.theme
.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!
.theme
.primaryColor(),
onTap: () {
//print("here1");
bool filled = isAppointmentFieldsFilled();
//print("fields filled: $filled");
if (filled) {
//print("here2");
submitApointment(index);
//print("here3");
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(
errorType: "Input Error");
},
);
}
},
),
)
],
),
),
),
Positioned(
top: 5,
right: 5,
width: 50,
height: 50,
child: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.close,
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
size: 35,
),
),
),
],
),
),
);
}
Widget isMainMember(int index) {
//var matchRE = RegExp(r'^[a-z]+$');
var firstLetterFName = widget.patients[index].first_name[0];
var firstLetterLName = widget.patients[index].last_name[0];
var fnameStar = '*' * 8;
var lnameStar = '*' * 8;
if (widget.patients[index].medical_aid_main_member == "Yes") {
return Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
"$firstLetterFName$fnameStar $firstLetterLName$lnameStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
const SizedBox(
width: 10,
),
Icon(
Icons.star_border_rounded,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
],
);
} else {
return Text(
"$firstLetterFName$fnameStar $firstLetterLName$lnameStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
}
}
Widget hasMedicalAid(int index) {
var medAidNoStar = '*' * 8;
if (widget.patients[index].medical_aid == "Yes") {
return ListTile(
title: isMainMember(index),
subtitle: Text(
"ID No.: ${widget.patients[index].id_no}\nMedical Aid No.: $medAidNoStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
setState(() {
appointmentPopUp(index);
// Add popup to add patienmt to queue
// Navigator.of(context).pushNamed('/patient-manager/patient',
// arguments: PatientViewArguments(
// widget.signedInUser, widget.patients[index], "business"));
});
},
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
} else {
return ListTile(
title: isMainMember(index),
subtitle: Text(
"ID No.: ${widget.patients[index].id_no}\nMedical Aid No.: $medAidNoStar",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
setState(() {
appointmentPopUp(index);
// Navigator.of(context).pushNamed('/patient-manager/patient',
// arguments: PatientViewArguments(
// widget.signedInUser, widget.patients[index], "business"));
});
},
trailing: Icon(
Icons.add,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
}
}
@override
void dispose() {
dateController.dispose();
timeController.dispose();
idController.dispose();
fnameController.dispose();
lnameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.patients.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
return hasMedicalAid(index);
},
);
}
}

View File

@@ -0,0 +1,181 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihWarningMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/business.dart';
import 'package:patient_manager/objects/businessUser.dart';
import 'package:patient_manager/objects/patientQueue.dart';
import 'package:patient_manager/objects/patients.dart';
import 'package:supertokens_flutter/http.dart' as http;
class BuildPatientQueueList extends StatefulWidget {
final List<PatientQueue> patientQueue;
final AppUser signedInUser;
final Business? business;
final BusinessUser? businessUser;
const BuildPatientQueueList({
super.key,
required this.patientQueue,
required this.signedInUser,
required this.business,
required this.businessUser,
});
@override
State<BuildPatientQueueList> createState() => _BuildPatientsListState();
}
class _BuildPatientsListState extends State<BuildPatientQueueList> {
String baseAPI = AppEnviroment.baseApiUrl;
Future<Patient> fetchPatients(String app_id) async {
//print("pat man drawer: " + endpointUserData + widget.userEmail);
var response = await http.get(Uri.parse("$baseAPI/patients/$app_id"));
// print(response.statusCode);
// print(response.body);
if (response.statusCode == 200) {
// print("here");
String body = response.body;
var decodedData = jsonDecode(body);
Patient u = Patient.fromJson(decodedData);
// print(u.email);
//setState(() {
//_widgetOptions = setLayout(u);
//});
return u;
} else {
throw Exception("Error: GetUserData status code ${response.statusCode}");
}
}
Widget displayQueue(int index) {
String fname = widget.patientQueue[index].first_name[0] + "********";
String lname = widget.patientQueue[index].last_name[0] + "********";
String title =
widget.patientQueue[index].date_time.split('T')[1].substring(0, 5);
String subtitle = "";
var nowDate = DateTime.now();
var expireyDate = DateTime.parse(widget.patientQueue[index].revoke_date);
if (widget.patientQueue[index].access != "approved" ||
expireyDate.isBefore(nowDate)) {
subtitle += "Name: $fname $lname\n";
subtitle += "ID No.: ${widget.patientQueue[index].id_no}\n";
subtitle += "Medical Aid No: ********";
//subtitle += "********";
} else {
subtitle +=
"Name: ${widget.patientQueue[index].first_name} ${widget.patientQueue[index].last_name}\nID No.: ${widget.patientQueue[index].id_no}\nMedical Aid No: ";
if (widget.patientQueue[index].medical_aid_no == "") {
subtitle += "No Medical Aid";
} else {
// subtitle +=
// "\nMedical Aid No: ";
subtitle += widget.patientQueue[index].medical_aid_no;
}
}
if (expireyDate.isBefore(nowDate)) {
subtitle += "\nAccess Request: EXPIRED";
} else {
subtitle +=
"\nAccess Request: ${widget.patientQueue[index].access.toUpperCase()}";
}
subtitle +=
"\nAccess Expiration date: ${widget.patientQueue[index].revoke_date.substring(0, 16).replaceAll("T", " ")}";
return ListTile(
title: Text(
"Appointment: $title",
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
subtitle,
style: TextStyle(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
onTap: () {
var todayDate = DateTime.now();
var revokeDate = DateTime.parse(widget.patientQueue[index].revoke_date);
// print(
// "Todays: $todayDate\nRevoke Date: $revokeDate\nHas revoke date passed: ${revokeDate.isBefore(todayDate)}");
if (revokeDate.isBefore(todayDate)) {
expiredAccessWarning();
} else if (widget.patientQueue[index].access != "pending") {
Patient selectedPatient;
fetchPatients(widget.patientQueue[index].app_id).then(
(result) {
setState(() {
selectedPatient = result;
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
selectedPatient,
widget.businessUser,
widget.business,
"business",
));
});
},
);
} else {
noAccessWarning();
}
},
trailing: Icon(
Icons.arrow_forward,
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
);
}
void noAccessWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "No Access");
},
);
}
void expiredAccessWarning() {
showDialog(
context: context,
builder: (context) {
return const MIHWarningMessage(warningType: "Expired Access");
},
);
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
}
@override
Widget build(BuildContext context) {
return ListView.separated(
separatorBuilder: (BuildContext context, index) {
return Divider(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
);
},
itemCount: widget.patientQueue.length,
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
return displayQueue(index);
},
);
}
}

View File

@@ -2,12 +2,12 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart';
//import 'package:patient_manager/components/mihAppDrawer.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
//import 'package:patient_manager/MIH_Components/mihAppDrawer.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';

View File

@@ -2,11 +2,11 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

@@ -4,13 +4,13 @@ import 'dart:convert';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/builder/buildFilesList.dart';
import 'package:patient_manager/components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/components/medCertInput.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/components/prescipInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihFileInput.dart';
import 'package:patient_manager/MIH_Components/medCertInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/prescipInput.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

@@ -4,15 +4,15 @@ import 'package:intl/intl.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/components/builders/buildPatientList.dart';
import 'package:patient_manager/components/builders/buildPatientQueueList.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/inputsAndButtons/mihDateInput.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/builder/buildPatientList.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/builder/buildPatientQueueList.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDateInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/patientQueue.dart';
import 'package:supertokens_flutter/http.dart' as http;
import 'package:patient_manager/components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/patients.dart';

View File

@@ -2,12 +2,12 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/builder/buildNotesList.dart';
import 'package:patient_manager/components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihMLTextInput.dart';
import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihMLTextInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihTextInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';

View File

@@ -4,10 +4,10 @@ import 'package:flutter/material.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientDetails.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientFiles.dart';
import 'package:patient_manager/MIH_Packages/patient_profile/patientNotes.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Action.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Body.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_Header.dart';
import 'package:patient_manager/MIH_Components/MIH_Layout/MIH_LayoutBuilder.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/arguments.dart';

View File

@@ -0,0 +1,588 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:patient_manager/MIH_Components/medicineSearch.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihDropdownInput.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihLoadingCircle.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihErrorMessage.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihSearchInput.dart';
import 'package:patient_manager/MIH_Components/inputsAndButtons/mihButton.dart';
import 'package:patient_manager/MIH_Components/popUpMessages/mihSuccessMessage.dart';
import 'package:patient_manager/env/env.dart';
import 'package:patient_manager/main.dart';
import 'package:patient_manager/objects/appUser.dart';
import 'package:patient_manager/objects/arguments.dart';
import 'package:patient_manager/objects/business.dart';
import 'package:patient_manager/objects/businessUser.dart';
import 'package:patient_manager/objects/patients.dart';
import 'package:patient_manager/objects/perscription.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;
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,
});
@override
State<PrescripInput> createState() => _PrescripInputState();
}
class _PrescripInputState extends State<PrescripInput> {
final FocusNode _focusNode = FocusNode();
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() async {
//start loading circle
showDialog(
context: context,
builder: (context) {
return const Mihloadingcircle();
},
);
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,
"fullName":
"${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}",
"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);
DateTime now = new DateTime.now();
DateTime date = new DateTime(now.year, now.month, now.day);
String fileName =
"Perscription-${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}-${date.toString().substring(0, 10)}.pdf";
if (response1.statusCode == 200) {
var response2 = await http.post(
Uri.parse("${AppEnviroment.baseApiUrl}/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) {
setState(() {
//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
Navigator.of(context).pop();
Navigator.of(context).pop();
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: PatientViewArguments(
widget.signedInUser,
widget.selectedPatient,
widget.businessUser,
widget.business,
"business",
));
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.";
successPopUp(message);
} else {
internetConnectionPopUp();
}
} else {
internetConnectionPopUp();
}
}
void internetConnectionPopUp() {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Internet Connection");
},
);
}
void successPopUp(String message) {
showDialog(
context: context,
builder: (context) {
return MIHSuccessMessage(
successType: "Success",
successMessage: message,
);
},
);
}
void getMedsPopUp(TextEditingController medSearch) {
showDialog(
context: context,
builder: (context) {
return MedicineSearch(
searchVlaue: medSearch,
);
},
);
}
bool isFieldsFilled() {
if (widget.medicineController.text.isEmpty ||
// widget.quantityController.text.isEmpty ||
widget.dosageController.text.isEmpty ||
widget.timesDailyController.text.isEmpty ||
widget.noDaysController.text.isEmpty ||
widget.noRepeatsController.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: [
KeyboardListener(
focusNode: _focusNode,
autofocus: true,
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
getMedsPopUp(widget.medicineController);
}
},
child: SizedBox(
width: 300,
child: MIHSearchField(
controller: widget.medicineController,
hintText: "Medicine",
required: true,
editable: true,
onTap: () {
getMedsPopUp(widget.medicineController);
},
),
),
),
const SizedBox(height: 10.0),
// SizedBox(
// width: 300,
// child: MIHDropdownField(
// controller: widget.quantityController,
// hintText: "Quantity",
// dropdownOptions: numberOptions,
// required: true,
// editable: true,
// ),
// ),
// const SizedBox(height: 10.0),
SizedBox(
width: 300,
child: MIHDropdownField(
controller: widget.dosageController,
hintText: "Dosage",
dropdownOptions: numberOptions,
required: true,
editable: true,
),
),
const SizedBox(height: 10.0),
SizedBox(
width: 300,
child: MIHDropdownField(
controller: widget.timesDailyController,
hintText: "Times Daily",
dropdownOptions: numberOptions,
required: true,
editable: true,
),
),
const SizedBox(height: 10.0),
SizedBox(
width: 300,
child: MIHDropdownField(
controller: widget.noDaysController,
hintText: "No. Days",
dropdownOptions: numberOptions,
required: true,
editable: true,
),
),
const SizedBox(height: 10.0),
SizedBox(
width: 300,
child: MIHDropdownField(
controller: widget.noRepeatsController,
hintText: "No. Repeats",
dropdownOptions: numberOptions,
required: true,
editable: true,
),
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
buttonText: "Add",
buttonColor:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
onTap: () {
if (isFieldsFilled()) {
// int quantity;
// int.parse(widget.dosageController.text) *
// int.parse(widget.timesDailyController.text) *
// int.parse(widget.noDaysController.text);
setState(() {
//widget.quantityController.text = "$quantity";
updatePerscriptionList();
widget.medicineController.clear();
widget.quantityController.clear();
widget.dosageController.clear();
widget.timesDailyController.clear();
widget.noDaysController.clear();
widget.noRepeatsController.clear();
});
//addPatientAPICall();
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
},
),
)
],
);
}
Widget displayPerscList() {
return Column(
children: [
Container(
width: 550,
height: 350,
decoration: BoxDecoration(
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
borderRadius: BorderRadius.circular(25.0),
border: Border.all(
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
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:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
subtitle: Text(
getPerscSubtitle(index),
style: TextStyle(
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
),
//onTap: () {},
trailing: IconButton(
icon: Icon(
Icons.delete_forever_outlined,
color:
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
),
onPressed: () {
setState(() {
perscriptionObjOutput.removeAt(index);
});
},
),
);
},
),
),
const SizedBox(height: 30.0),
SizedBox(
width: 300,
height: 50,
child: MIHButton(
onTap: () async {
if (perscriptionObjOutput.isNotEmpty) {
//print(jsonEncode(perscriptionObjOutput));
await generatePerscription();
Navigator.pop(context);
} else {
showDialog(
context: context,
builder: (context) {
return const MIHErrorMessage(errorType: "Input Error");
},
);
}
},
buttonText: "Generate",
buttonColor: MzanziInnovationHub.of(context)!.theme.successColor(),
textColor: MzanziInnovationHub.of(context)!.theme.primaryColor(),
),
)
],
);
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
void initState() {
//futueMeds = getMedList(endpointMeds);
super.initState();
}
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
setState(() {
width = size.width;
height = size.height;
});
return Container(
//width: ,
height: (height / 3) * 1.5,
child: SingleChildScrollView(
child: Wrap(
direction: Axis.horizontal,
alignment: WrapAlignment.center,
spacing: 10,
runSpacing: 10,
// mainAxisAlignment: MainAxisAlignment.center,
// mainAxisSize: MainAxisSize.max,
// crossAxisAlignment: CrossAxisAlignment.center,
children: [
displayMedInput(),
displayPerscList(),
],
),
),
);
}
}