change UP to cater for new med aid fields

This commit is contained in:
2024-07-08 15:10:31 +02:00
parent c14c87c0af
commit 8cb311e285
19 changed files with 789 additions and 507 deletions

View File

@@ -3,12 +3,12 @@ import 'package:patient_manager/objects/patients.dart';
class BuildPatientsList extends StatefulWidget {
final List<Patient> patients;
final searchString;
//final searchString;
const BuildPatientsList({
super.key,
required this.patients,
required this.searchString,
//required this.searchString,
});
@override
@@ -16,6 +16,22 @@ class BuildPatientsList extends StatefulWidget {
}
class _BuildPatientsListState extends State<BuildPatientsList> {
Widget isMainMember(int index) {
if (widget.patients[index].medical_aid_main_member == "Yes") {
return Row(
mainAxisSize: MainAxisSize.max,
children: [
const Icon(Icons.star_border_rounded),
Text(
"${widget.patients[index].first_name} ${widget.patients[index].last_name}"),
],
);
} else {
return Text(
"${widget.patients[index].first_name} ${widget.patients[index].last_name}");
}
}
@override
Widget build(BuildContext context) {
return ListView.separated(
@@ -26,20 +42,18 @@ class _BuildPatientsListState extends State<BuildPatientsList> {
itemBuilder: (context, index) {
//final patient = widget.patients[index].id_no.contains(widget.searchString);
//print(index);
return widget.patients[index].id_no.contains(widget.searchString)
? ListTile(
title: Text(
"${widget.patients[index].first_name} ${widget.patients[index].last_name}"),
subtitle: Text(widget.patients[index].id_no),
onTap: () {
setState(() {
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: widget.patients[index]);
});
},
trailing: const Icon(Icons.arrow_forward),
)
: null;
return ListTile(
title: isMainMember(index),
subtitle: Text(
"ID No.: ${widget.patients[index].id_no}\nMedical Aid No.: ${widget.patients[index].medical_aid_no}"),
onTap: () {
setState(() {
Navigator.of(context).pushNamed('/patient-manager/patient',
arguments: widget.patients[index]);
});
},
trailing: const Icon(Icons.arrow_forward),
);
},
);
}

View File

@@ -5,7 +5,7 @@ class MyDropdownField extends StatefulWidget {
final String hintText;
final bool required;
final List<String> dropdownOptions;
final void Function(String?)? onSelect;
//final bool editable;
const MyDropdownField({
@@ -14,6 +14,7 @@ class MyDropdownField extends StatefulWidget {
required this.hintText,
required this.dropdownOptions,
required this.required,
this.onSelect,
});
@override
@@ -89,6 +90,7 @@ class _MyDropdownFieldState extends State<MyDropdownField> {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: DropdownMenu(
//onSelected: widget.onSelect,
menuHeight: 300,
controller: widget.controller,
expandedInsets: EdgeInsets.zero,

View File

@@ -16,14 +16,14 @@ class PatManAppDrawer extends StatefulWidget {
class _PatManAppDrawerState extends State<PatManAppDrawer> {
String endpointUserData = "http://localhost:80/users/profile/";
late AppUser signedInUser;
late Future<AppUser> signedInUser;
Future<AppUser> getUserDetails() async {
//print("pat man drawer: " + endpointUserData + widget.userEmail);
var response =
await http.get(Uri.parse(endpointUserData + widget.userEmail));
//print(response.statusCode);
//print(response.body);
print(response.statusCode);
print(response.body);
if (response.statusCode == 200) {
return AppUser.fromJson(
jsonDecode(response.body) as Map<String, dynamic>);
@@ -34,14 +34,14 @@ class _PatManAppDrawerState extends State<PatManAppDrawer> {
@override
void initState() {
//signedInUser = getUserDetails();
signedInUser = getUserDetails();
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: getUserDetails(),
future: signedInUser,
builder: (BuildContext context, AsyncSnapshot<AppUser> snapshot) {
return Drawer(
child: ListView(
@@ -51,61 +51,80 @@ class _PatManAppDrawerState extends State<PatManAppDrawer> {
decoration: const BoxDecoration(
color: Colors.blueAccent,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
"Signed Is As:",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
const SizedBox(
height: 50.0,
),
Row(
child: SizedBox(
height: 400,
child: Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"Name: ",
style: TextStyle(fontWeight: FontWeight.bold),
"Signed Is As:",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
const SizedBox(
height: 50.0,
),
Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
const Text(
"Name: ",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 15),
Text(
"${snapshot.data?.fname} ${snapshot.data?.lname}"),
],
),
),
Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
const Text(
"Email: ",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 16),
Text("${snapshot.data?.email}"),
],
),
),
const SizedBox(width: 15),
Text("${snapshot.data?.fname} ${snapshot.data?.lname}"),
],
),
Row(
children: [
const Text(
"Email: ",
style: TextStyle(fontWeight: FontWeight.bold),
),
const SizedBox(width: 16),
Text("${snapshot.data?.email}"),
],
),
],
),
),
),
ListTile(
title: const Row(
children: [
Icon(Icons.home_outlined),
SizedBox(width: 25.0),
Text("Home"),
],
title: const Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(Icons.home_outlined),
SizedBox(width: 25.0),
Text("Home"),
],
),
),
onTap: () {
Navigator.of(context).pushNamed('/home');
},
),
ListTile(
title: const Row(
children: [
Icon(Icons.perm_identity),
SizedBox(width: 25.0),
Text("Profile"),
],
title: const Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(Icons.perm_identity),
SizedBox(width: 25.0),
Text("Profile"),
],
),
),
onTap: () {
//signedInUser = snapshot.data!;
@@ -115,12 +134,15 @@ class _PatManAppDrawerState extends State<PatManAppDrawer> {
},
),
ListTile(
title: const Row(
children: [
Icon(Icons.logout),
SizedBox(width: 25.0),
Text("Sign Out"),
],
title: const Expanded(
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Icon(Icons.logout),
SizedBox(width: 25.0),
Text("Sign Out"),
],
),
),
onTap: () {
client.auth.signOut();

View File

@@ -20,6 +20,9 @@ class _PatientDetailsState extends State<PatientDetails> {
final medNameController = TextEditingController();
final medSchemeController = TextEditingController();
final addressController = TextEditingController();
final medAidController = TextEditingController();
final medMainMemController = TextEditingController();
final medAidCodeController = TextEditingController();
double? headingFontSize = 35.0;
double? bodyFonstSize = 20.0;
@@ -43,6 +46,12 @@ class _PatientDetailsState extends State<PatientDetails> {
TextEditingValue(text: widget.selectedPatient.medical_aid_scheme);
addressController.value =
TextEditingValue(text: widget.selectedPatient.address);
medAidController.value =
TextEditingValue(text: widget.selectedPatient.medical_aid);
medMainMemController.value = TextEditingValue(
text: widget.selectedPatient.medical_aid_main_member);
medAidCodeController.value =
TextEditingValue(text: widget.selectedPatient.medical_aid_code);
});
super.initState();
}
@@ -157,6 +166,20 @@ class _PatientDetailsState extends State<PatientDetails> {
children: [
Row(
children: [
Expanded(
child: MyTextField(
controller: medAidController,
hintText: "Has Medical Aid",
editable: false,
required: false),
),
Expanded(
child: MyTextField(
controller: medMainMemController,
hintText: "Main Member",
editable: false,
required: false),
),
Expanded(
child: MyTextField(
controller: medNoController,
@@ -164,6 +187,18 @@ class _PatientDetailsState extends State<PatientDetails> {
editable: false,
required: false),
),
],
),
const SizedBox(height: 10),
Row(
children: [
Expanded(
child: MyTextField(
controller: medAidCodeController,
hintText: "Code",
editable: false,
required: false),
),
Expanded(
child: MyTextField(
controller: medNameController,
@@ -178,18 +213,6 @@ class _PatientDetailsState extends State<PatientDetails> {
editable: false,
required: false),
),
// PatientDetailItem(
// category: "No. ",
// value: widget.selectedPatient.medical_aid_no,
// ),
// PatientDetailItem(
// category: "Name ",
// value: widget.selectedPatient.medical_aid_name,
// ),
// PatientDetailItem(
// category: "Scheme ",
// value: widget.selectedPatient.medical_aid_scheme,
// ),
],
),
],