change UP to cater for new med aid fields
This commit is contained in:
@@ -3,12 +3,12 @@ import 'package:patient_manager/objects/patients.dart';
|
|||||||
|
|
||||||
class BuildPatientsList extends StatefulWidget {
|
class BuildPatientsList extends StatefulWidget {
|
||||||
final List<Patient> patients;
|
final List<Patient> patients;
|
||||||
final searchString;
|
//final searchString;
|
||||||
|
|
||||||
const BuildPatientsList({
|
const BuildPatientsList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.patients,
|
required this.patients,
|
||||||
required this.searchString,
|
//required this.searchString,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -16,6 +16,22 @@ class BuildPatientsList extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BuildPatientsListState extends State<BuildPatientsList> {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
@@ -26,20 +42,18 @@ class _BuildPatientsListState extends State<BuildPatientsList> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||||
//print(index);
|
//print(index);
|
||||||
return widget.patients[index].id_no.contains(widget.searchString)
|
return ListTile(
|
||||||
? ListTile(
|
title: isMainMember(index),
|
||||||
title: Text(
|
subtitle: Text(
|
||||||
"${widget.patients[index].first_name} ${widget.patients[index].last_name}"),
|
"ID No.: ${widget.patients[index].id_no}\nMedical Aid No.: ${widget.patients[index].medical_aid_no}"),
|
||||||
subtitle: Text(widget.patients[index].id_no),
|
onTap: () {
|
||||||
onTap: () {
|
setState(() {
|
||||||
setState(() {
|
Navigator.of(context).pushNamed('/patient-manager/patient',
|
||||||
Navigator.of(context).pushNamed('/patient-manager/patient',
|
arguments: widget.patients[index]);
|
||||||
arguments: widget.patients[index]);
|
});
|
||||||
});
|
},
|
||||||
},
|
trailing: const Icon(Icons.arrow_forward),
|
||||||
trailing: const Icon(Icons.arrow_forward),
|
);
|
||||||
)
|
|
||||||
: null;
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class MyDropdownField extends StatefulWidget {
|
|||||||
final String hintText;
|
final String hintText;
|
||||||
final bool required;
|
final bool required;
|
||||||
final List<String> dropdownOptions;
|
final List<String> dropdownOptions;
|
||||||
|
final void Function(String?)? onSelect;
|
||||||
//final bool editable;
|
//final bool editable;
|
||||||
|
|
||||||
const MyDropdownField({
|
const MyDropdownField({
|
||||||
@@ -14,6 +14,7 @@ class MyDropdownField extends StatefulWidget {
|
|||||||
required this.hintText,
|
required this.hintText,
|
||||||
required this.dropdownOptions,
|
required this.dropdownOptions,
|
||||||
required this.required,
|
required this.required,
|
||||||
|
this.onSelect,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -89,6 +90,7 @@ class _MyDropdownFieldState extends State<MyDropdownField> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||||
child: DropdownMenu(
|
child: DropdownMenu(
|
||||||
|
//onSelected: widget.onSelect,
|
||||||
menuHeight: 300,
|
menuHeight: 300,
|
||||||
controller: widget.controller,
|
controller: widget.controller,
|
||||||
expandedInsets: EdgeInsets.zero,
|
expandedInsets: EdgeInsets.zero,
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ class PatManAppDrawer extends StatefulWidget {
|
|||||||
|
|
||||||
class _PatManAppDrawerState extends State<PatManAppDrawer> {
|
class _PatManAppDrawerState extends State<PatManAppDrawer> {
|
||||||
String endpointUserData = "http://localhost:80/users/profile/";
|
String endpointUserData = "http://localhost:80/users/profile/";
|
||||||
late AppUser signedInUser;
|
late Future<AppUser> signedInUser;
|
||||||
|
|
||||||
Future<AppUser> getUserDetails() async {
|
Future<AppUser> getUserDetails() async {
|
||||||
//print("pat man drawer: " + endpointUserData + widget.userEmail);
|
//print("pat man drawer: " + endpointUserData + widget.userEmail);
|
||||||
var response =
|
var response =
|
||||||
await http.get(Uri.parse(endpointUserData + widget.userEmail));
|
await http.get(Uri.parse(endpointUserData + widget.userEmail));
|
||||||
//print(response.statusCode);
|
print(response.statusCode);
|
||||||
//print(response.body);
|
print(response.body);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
return AppUser.fromJson(
|
return AppUser.fromJson(
|
||||||
jsonDecode(response.body) as Map<String, dynamic>);
|
jsonDecode(response.body) as Map<String, dynamic>);
|
||||||
@@ -34,14 +34,14 @@ class _PatManAppDrawerState extends State<PatManAppDrawer> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
//signedInUser = getUserDetails();
|
signedInUser = getUserDetails();
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: getUserDetails(),
|
future: signedInUser,
|
||||||
builder: (BuildContext context, AsyncSnapshot<AppUser> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<AppUser> snapshot) {
|
||||||
return Drawer(
|
return Drawer(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
@@ -51,61 +51,80 @@ class _PatManAppDrawerState extends State<PatManAppDrawer> {
|
|||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.blueAccent,
|
color: Colors.blueAccent,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: SizedBox(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
height: 400,
|
||||||
children: [
|
child: Expanded(
|
||||||
const Text(
|
child: Column(
|
||||||
"Signed Is As:",
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
style: TextStyle(
|
mainAxisSize: MainAxisSize.min,
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 50.0,
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
"Name: ",
|
"Signed Is As:",
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
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(
|
ListTile(
|
||||||
title: const Row(
|
title: const Expanded(
|
||||||
children: [
|
child: Row(
|
||||||
Icon(Icons.home_outlined),
|
mainAxisSize: MainAxisSize.max,
|
||||||
SizedBox(width: 25.0),
|
children: [
|
||||||
Text("Home"),
|
Icon(Icons.home_outlined),
|
||||||
],
|
SizedBox(width: 25.0),
|
||||||
|
Text("Home"),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed('/home');
|
Navigator.of(context).pushNamed('/home');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Row(
|
title: const Expanded(
|
||||||
children: [
|
child: Row(
|
||||||
Icon(Icons.perm_identity),
|
mainAxisSize: MainAxisSize.max,
|
||||||
SizedBox(width: 25.0),
|
children: [
|
||||||
Text("Profile"),
|
Icon(Icons.perm_identity),
|
||||||
],
|
SizedBox(width: 25.0),
|
||||||
|
Text("Profile"),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
//signedInUser = snapshot.data!;
|
//signedInUser = snapshot.data!;
|
||||||
@@ -115,12 +134,15 @@ class _PatManAppDrawerState extends State<PatManAppDrawer> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Row(
|
title: const Expanded(
|
||||||
children: [
|
child: Row(
|
||||||
Icon(Icons.logout),
|
mainAxisSize: MainAxisSize.max,
|
||||||
SizedBox(width: 25.0),
|
children: [
|
||||||
Text("Sign Out"),
|
Icon(Icons.logout),
|
||||||
],
|
SizedBox(width: 25.0),
|
||||||
|
Text("Sign Out"),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
client.auth.signOut();
|
client.auth.signOut();
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
final medNameController = TextEditingController();
|
final medNameController = TextEditingController();
|
||||||
final medSchemeController = TextEditingController();
|
final medSchemeController = TextEditingController();
|
||||||
final addressController = TextEditingController();
|
final addressController = TextEditingController();
|
||||||
|
final medAidController = TextEditingController();
|
||||||
|
final medMainMemController = TextEditingController();
|
||||||
|
final medAidCodeController = TextEditingController();
|
||||||
double? headingFontSize = 35.0;
|
double? headingFontSize = 35.0;
|
||||||
double? bodyFonstSize = 20.0;
|
double? bodyFonstSize = 20.0;
|
||||||
|
|
||||||
@@ -43,6 +46,12 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
TextEditingValue(text: widget.selectedPatient.medical_aid_scheme);
|
TextEditingValue(text: widget.selectedPatient.medical_aid_scheme);
|
||||||
addressController.value =
|
addressController.value =
|
||||||
TextEditingValue(text: widget.selectedPatient.address);
|
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();
|
super.initState();
|
||||||
}
|
}
|
||||||
@@ -157,6 +166,20 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
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(
|
Expanded(
|
||||||
child: MyTextField(
|
child: MyTextField(
|
||||||
controller: medNoController,
|
controller: medNoController,
|
||||||
@@ -164,6 +187,18 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
editable: false,
|
editable: false,
|
||||||
required: false),
|
required: false),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medAidCodeController,
|
||||||
|
hintText: "Code",
|
||||||
|
editable: false,
|
||||||
|
required: false),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: MyTextField(
|
child: MyTextField(
|
||||||
controller: medNameController,
|
controller: medNameController,
|
||||||
@@ -178,18 +213,6 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
editable: false,
|
editable: false,
|
||||||
required: 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,
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ class Patient {
|
|||||||
final String last_name;
|
final String last_name;
|
||||||
final String email;
|
final String email;
|
||||||
final String cell_no;
|
final String cell_no;
|
||||||
|
final String medical_aid;
|
||||||
final String medical_aid_name;
|
final String medical_aid_name;
|
||||||
final String medical_aid_no;
|
final String medical_aid_no;
|
||||||
|
final String medical_aid_main_member;
|
||||||
|
final String medical_aid_code;
|
||||||
final String medical_aid_scheme;
|
final String medical_aid_scheme;
|
||||||
final String address;
|
final String address;
|
||||||
final int doc_office_id;
|
final int doc_office_id;
|
||||||
@@ -18,8 +21,11 @@ class Patient {
|
|||||||
required this.last_name,
|
required this.last_name,
|
||||||
required this.email,
|
required this.email,
|
||||||
required this.cell_no,
|
required this.cell_no,
|
||||||
|
required this.medical_aid,
|
||||||
required this.medical_aid_name,
|
required this.medical_aid_name,
|
||||||
required this.medical_aid_no,
|
required this.medical_aid_no,
|
||||||
|
required this.medical_aid_main_member,
|
||||||
|
required this.medical_aid_code,
|
||||||
required this.medical_aid_scheme,
|
required this.medical_aid_scheme,
|
||||||
required this.address,
|
required this.address,
|
||||||
required this.doc_office_id,
|
required this.doc_office_id,
|
||||||
@@ -34,8 +40,11 @@ class Patient {
|
|||||||
'last_name': String last_name,
|
'last_name': String last_name,
|
||||||
'email': String email,
|
'email': String email,
|
||||||
'cell_no': String cell_no,
|
'cell_no': String cell_no,
|
||||||
|
'medical_aid': String medical_aid,
|
||||||
'medical_aid_name': String medical_aid_name,
|
'medical_aid_name': String medical_aid_name,
|
||||||
'medical_aid_no': String medical_aid_no,
|
'medical_aid_no': String medical_aid_no,
|
||||||
|
'medical_aid_main_member': String medical_aid_main_member,
|
||||||
|
'medical_aid_code': String medical_aid_code,
|
||||||
'medical_aid_scheme': String medical_aid_scheme,
|
'medical_aid_scheme': String medical_aid_scheme,
|
||||||
'address': String address,
|
'address': String address,
|
||||||
'doc_office_id': int doc_office_id,
|
'doc_office_id': int doc_office_id,
|
||||||
@@ -47,8 +56,11 @@ class Patient {
|
|||||||
last_name: last_name,
|
last_name: last_name,
|
||||||
email: email,
|
email: email,
|
||||||
cell_no: cell_no,
|
cell_no: cell_no,
|
||||||
|
medical_aid: medical_aid,
|
||||||
medical_aid_name: medical_aid_name,
|
medical_aid_name: medical_aid_name,
|
||||||
medical_aid_no: medical_aid_no,
|
medical_aid_no: medical_aid_no,
|
||||||
|
medical_aid_main_member: medical_aid_main_member,
|
||||||
|
medical_aid_code: medical_aid_code,
|
||||||
medical_aid_scheme: medical_aid_scheme,
|
medical_aid_scheme: medical_aid_scheme,
|
||||||
address: address,
|
address: address,
|
||||||
doc_office_id: doc_office_id,
|
doc_office_id: doc_office_id,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:patient_manager/components/myDropdownInput.dart';
|
||||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||||
import 'package:patient_manager/components/myTextInput.dart';
|
import 'package:patient_manager/components/myTextInput.dart';
|
||||||
@@ -31,9 +32,14 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
final medNameController = TextEditingController();
|
final medNameController = TextEditingController();
|
||||||
final medSchemeController = TextEditingController();
|
final medSchemeController = TextEditingController();
|
||||||
final addressController = TextEditingController();
|
final addressController = TextEditingController();
|
||||||
|
final medAidController = TextEditingController();
|
||||||
|
final medMainMemController = TextEditingController();
|
||||||
|
final medAidCodeController = TextEditingController();
|
||||||
|
|
||||||
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
||||||
final apiUrl = "http://localhost:80/patients/insert/";
|
final apiUrl = "http://localhost:80/patients/insert/";
|
||||||
late int futureDocOfficeId;
|
late int futureDocOfficeId;
|
||||||
|
late bool medRequired;
|
||||||
|
|
||||||
Future getOfficeIdByUser(String endpoint) async {
|
Future getOfficeIdByUser(String endpoint) async {
|
||||||
final response = await http.get(Uri.parse(endpoint));
|
final response = await http.get(Uri.parse(endpoint));
|
||||||
@@ -52,18 +58,35 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isFieldsFilled() {
|
bool isFieldsFilled() {
|
||||||
if (idController.text.isEmpty ||
|
if (medRequired) {
|
||||||
fnameController.text.isEmpty ||
|
if (idController.text.isEmpty ||
|
||||||
lnameController.text.isEmpty ||
|
fnameController.text.isEmpty ||
|
||||||
cellController.text.isEmpty ||
|
lnameController.text.isEmpty ||
|
||||||
emailController.text.isEmpty ||
|
cellController.text.isEmpty ||
|
||||||
medNoController.text.isEmpty ||
|
emailController.text.isEmpty ||
|
||||||
medNameController.text.isEmpty ||
|
medNoController.text.isEmpty ||
|
||||||
medSchemeController.text.isEmpty ||
|
medNameController.text.isEmpty ||
|
||||||
addressController.text.isEmpty) {
|
medSchemeController.text.isEmpty ||
|
||||||
return false;
|
addressController.text.isEmpty ||
|
||||||
|
medAidController.text.isEmpty ||
|
||||||
|
medMainMemController.text.isEmpty ||
|
||||||
|
medAidCodeController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
if (idController.text.isEmpty ||
|
||||||
|
fnameController.text.isEmpty ||
|
||||||
|
lnameController.text.isEmpty ||
|
||||||
|
cellController.text.isEmpty ||
|
||||||
|
emailController.text.isEmpty ||
|
||||||
|
addressController.text.isEmpty ||
|
||||||
|
medAidController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,8 +104,11 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
"last_name": lnameController.text,
|
"last_name": lnameController.text,
|
||||||
"email": emailController.text,
|
"email": emailController.text,
|
||||||
"cell_no": cellController.text,
|
"cell_no": cellController.text,
|
||||||
"medical_aid_name": medNameController.text,
|
"medical_aid": medAidController.text,
|
||||||
|
"medical_aid_main_member": medMainMemController.text,
|
||||||
"medical_aid_no": medNoController.text,
|
"medical_aid_no": medNoController.text,
|
||||||
|
"medical_aid_code": medAidCodeController.text,
|
||||||
|
"medical_aid_name": medNameController.text,
|
||||||
"medical_aid_scheme": medSchemeController.text,
|
"medical_aid_scheme": medSchemeController.text,
|
||||||
"address": addressController.text,
|
"address": addressController.text,
|
||||||
"doc_office_id": futureDocOfficeId,
|
"doc_office_id": futureDocOfficeId,
|
||||||
@@ -131,182 +157,252 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
void isRequired() {
|
||||||
Widget build(BuildContext context) {
|
//print("listerner triggered");
|
||||||
return Scaffold(
|
if (medAidController.text == "Yes") {
|
||||||
appBar: const MyAppBar(barTitle: "Add Patient"),
|
setState(() {
|
||||||
body: Padding(
|
medRequired = true;
|
||||||
padding: const EdgeInsets.all(15.0),
|
});
|
||||||
child: SingleChildScrollView(
|
} else {
|
||||||
child: Column(
|
setState(() {
|
||||||
children: [
|
medRequired = false;
|
||||||
const Text(
|
});
|
||||||
"Personal Details",
|
}
|
||||||
textAlign: TextAlign.center,
|
}
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
Widget displayForm() {
|
||||||
fontSize: 25.0,
|
return Padding(
|
||||||
//color: Colors.blueAccent,
|
padding: const EdgeInsets.all(15.0),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
"Personal Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 25.0,
|
||||||
|
//color: Colors.blueAccent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: idController,
|
||||||
|
hintText: "13 digit ID Number or Passport",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
Row(
|
),
|
||||||
children: [
|
const SizedBox(height: 10.0),
|
||||||
Expanded(
|
Row(
|
||||||
child: MyTextField(
|
children: [
|
||||||
controller: idController,
|
Expanded(
|
||||||
hintText: "13 digit ID Number or Passport",
|
child: MyTextField(
|
||||||
editable: true,
|
controller: fnameController,
|
||||||
required: true,
|
hintText: "First Name",
|
||||||
),
|
editable: true,
|
||||||
|
required: true,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: fnameController,
|
|
||||||
hintText: "First Name",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: lnameController,
|
|
||||||
hintText: "Last Name",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: cellController,
|
|
||||||
hintText: "Cell Number",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: emailController,
|
|
||||||
hintText: "Email",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: addressController,
|
|
||||||
hintText: "Address",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15.0),
|
|
||||||
const Text(
|
|
||||||
"Medical Aid Details",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25.0,
|
|
||||||
//color: Colors.blueAccent,
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
const SizedBox(height: 10.0),
|
),
|
||||||
Row(
|
const SizedBox(height: 10.0),
|
||||||
children: [
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: MyTextField(
|
Expanded(
|
||||||
controller: medNoController,
|
child: MyTextField(
|
||||||
hintText: "Medical Aid No.",
|
controller: lnameController,
|
||||||
editable: true,
|
hintText: "Last Name",
|
||||||
required: true,
|
editable: true,
|
||||||
),
|
required: true,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
const SizedBox(height: 10.0),
|
),
|
||||||
Row(
|
const SizedBox(height: 10.0),
|
||||||
children: [
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: MyTextField(
|
Expanded(
|
||||||
controller: medNameController,
|
child: MyTextField(
|
||||||
hintText: "Medical Aid Name",
|
controller: cellController,
|
||||||
editable: true,
|
hintText: "Cell Number",
|
||||||
required: true,
|
editable: true,
|
||||||
),
|
required: true,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
const SizedBox(height: 10.0),
|
),
|
||||||
Row(
|
const SizedBox(height: 10.0),
|
||||||
children: [
|
Row(
|
||||||
Expanded(
|
children: [
|
||||||
child: MyTextField(
|
Expanded(
|
||||||
controller: medSchemeController,
|
child: MyTextField(
|
||||||
hintText: "Medical Aid Scheme",
|
controller: emailController,
|
||||||
editable: true,
|
hintText: "Email",
|
||||||
required: true,
|
editable: true,
|
||||||
),
|
required: true,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
//const SizedBox(height: 10.0),
|
),
|
||||||
Row(
|
const SizedBox(height: 10.0),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Row(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
Expanded(
|
||||||
width: 500.0,
|
child: MyTextField(
|
||||||
height: 100.0,
|
controller: addressController,
|
||||||
child: MyButton(
|
hintText: "Address",
|
||||||
onTap: () {
|
editable: true,
|
||||||
if (isFieldsFilled()) {
|
required: true,
|
||||||
addPatientAPICall();
|
|
||||||
} else {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MyErrorMessage(
|
|
||||||
errorType: "Input Error");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buttonText: "Add",
|
|
||||||
buttonColor: Colors.blueAccent,
|
|
||||||
textColor: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15.0),
|
||||||
|
const Text(
|
||||||
|
"Medical Aid Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 25.0,
|
||||||
|
//color: Colors.blueAccent,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyDropdownField(
|
||||||
|
controller: medAidController,
|
||||||
|
hintText: "Has Medical Aid",
|
||||||
|
//editable: true,
|
||||||
|
onSelect: (_) {
|
||||||
|
isRequired();
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
dropdownOptions: const ["Yes", "No"],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyDropdownField(
|
||||||
|
controller: medMainMemController,
|
||||||
|
hintText: "Main Member",
|
||||||
|
//editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
dropdownOptions: const ["Yes", "No"],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medNoController,
|
||||||
|
hintText: "Medical Aid No.",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medAidCodeController,
|
||||||
|
hintText: "Medical Aid Code",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medNameController,
|
||||||
|
hintText: "Medical Aid Name",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medSchemeController,
|
||||||
|
hintText: "Medical Aid Scheme",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
//const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 500.0,
|
||||||
|
height: 100.0,
|
||||||
|
child: MyButton(
|
||||||
|
onTap: () {
|
||||||
|
if (isFieldsFilled()) {
|
||||||
|
addPatientAPICall();
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MyErrorMessage(
|
||||||
|
errorType: "Input Error");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonText: "Add",
|
||||||
|
buttonColor: Colors.blueAccent,
|
||||||
|
textColor: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
medAidController.addListener(isRequired);
|
||||||
|
setState(() {
|
||||||
|
medAidController.text = "No";
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: const MyAppBar(barTitle: "Add Patient"),
|
||||||
|
body: displayForm(),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:patient_manager/components/myDropdownInput.dart';
|
||||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||||
import 'package:patient_manager/components/myTextInput.dart';
|
import 'package:patient_manager/components/myTextInput.dart';
|
||||||
@@ -33,11 +34,16 @@ class _EditPatientState extends State<EditPatient> {
|
|||||||
final medNameController = TextEditingController();
|
final medNameController = TextEditingController();
|
||||||
final medSchemeController = TextEditingController();
|
final medSchemeController = TextEditingController();
|
||||||
final addressController = TextEditingController();
|
final addressController = TextEditingController();
|
||||||
|
final medAidController = TextEditingController();
|
||||||
|
final medMainMemController = TextEditingController();
|
||||||
|
final medAidCodeController = TextEditingController();
|
||||||
|
|
||||||
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
||||||
final apiUrlEdit = "http://localhost:80/patients/update/";
|
final apiUrlEdit = "http://localhost:80/patients/update/";
|
||||||
final apiUrlDelete = "http://localhost:80/patients/delete/";
|
final apiUrlDelete = "http://localhost:80/patients/delete/";
|
||||||
late int futureDocOfficeId;
|
late int futureDocOfficeId;
|
||||||
late String userEmail;
|
late String userEmail;
|
||||||
|
late bool medRequired;
|
||||||
|
|
||||||
Future getOfficeIdByUser(String endpoint) async {
|
Future getOfficeIdByUser(String endpoint) async {
|
||||||
final response = await http.get(Uri.parse(endpoint));
|
final response = await http.get(Uri.parse(endpoint));
|
||||||
@@ -74,8 +80,11 @@ class _EditPatientState extends State<EditPatient> {
|
|||||||
"last_name": lnameController.text,
|
"last_name": lnameController.text,
|
||||||
"email": emailController.text,
|
"email": emailController.text,
|
||||||
"cell_no": cellController.text,
|
"cell_no": cellController.text,
|
||||||
"medical_aid_name": medNameController.text,
|
"medical_aid": medAidController.text,
|
||||||
|
"medical_aid_main_member": medMainMemController.text,
|
||||||
"medical_aid_no": medNoController.text,
|
"medical_aid_no": medNoController.text,
|
||||||
|
"medical_aid_code": medAidCodeController.text,
|
||||||
|
"medical_aid_name": medNameController.text,
|
||||||
"medical_aid_scheme": medSchemeController.text,
|
"medical_aid_scheme": medSchemeController.text,
|
||||||
"address": addressController.text,
|
"address": addressController.text,
|
||||||
"doc_office_id": futureDocOfficeId,
|
"doc_office_id": futureDocOfficeId,
|
||||||
@@ -271,24 +280,286 @@ class _EditPatientState extends State<EditPatient> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isFieldsFilled() {
|
bool isFieldsFilled() {
|
||||||
if (idController.text.isEmpty ||
|
if (medRequired) {
|
||||||
fnameController.text.isEmpty ||
|
if (idController.text.isEmpty ||
|
||||||
lnameController.text.isEmpty ||
|
fnameController.text.isEmpty ||
|
||||||
cellController.text.isEmpty ||
|
lnameController.text.isEmpty ||
|
||||||
emailController.text.isEmpty ||
|
cellController.text.isEmpty ||
|
||||||
medNoController.text.isEmpty ||
|
emailController.text.isEmpty ||
|
||||||
medNameController.text.isEmpty ||
|
medNoController.text.isEmpty ||
|
||||||
medSchemeController.text.isEmpty ||
|
medNameController.text.isEmpty ||
|
||||||
addressController.text.isEmpty) {
|
medSchemeController.text.isEmpty ||
|
||||||
return false;
|
addressController.text.isEmpty ||
|
||||||
|
medAidController.text.isEmpty ||
|
||||||
|
medMainMemController.text.isEmpty ||
|
||||||
|
medAidCodeController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return true;
|
if (idController.text.isEmpty ||
|
||||||
|
fnameController.text.isEmpty ||
|
||||||
|
lnameController.text.isEmpty ||
|
||||||
|
cellController.text.isEmpty ||
|
||||||
|
emailController.text.isEmpty ||
|
||||||
|
addressController.text.isEmpty ||
|
||||||
|
medAidController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void isRequired() {
|
||||||
|
//print("listerner triggered");
|
||||||
|
if (medAidController.text == "Yes") {
|
||||||
|
setState(() {
|
||||||
|
medRequired = true;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
medRequired = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget displayForm() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(15.0),
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Text(
|
||||||
|
"Personal Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 25.0,
|
||||||
|
//color: Colors.blueAccent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.delete),
|
||||||
|
alignment: Alignment.topRight,
|
||||||
|
onPressed: () {
|
||||||
|
deletePatientPopUp();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: idController,
|
||||||
|
hintText: "13 digit ID Number or Passport",
|
||||||
|
editable: false,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: fnameController,
|
||||||
|
hintText: "First Name",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: lnameController,
|
||||||
|
hintText: "Last Name",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: cellController,
|
||||||
|
hintText: "Cell Number",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: emailController,
|
||||||
|
hintText: "Email",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: addressController,
|
||||||
|
hintText: "Address",
|
||||||
|
editable: true,
|
||||||
|
required: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15.0),
|
||||||
|
const Text(
|
||||||
|
"Medical Aid Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 25.0,
|
||||||
|
//color: Colors.blueAccent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyDropdownField(
|
||||||
|
controller: medAidController,
|
||||||
|
hintText: "Has Medical Aid",
|
||||||
|
onSelect: (_) {
|
||||||
|
isRequired();
|
||||||
|
},
|
||||||
|
//editable: true,
|
||||||
|
required: true,
|
||||||
|
dropdownOptions: const ["Yes", "No"],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyDropdownField(
|
||||||
|
controller: medMainMemController,
|
||||||
|
hintText: "Main Member.",
|
||||||
|
//editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
dropdownOptions: const ["Yes", "No"],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medNoController,
|
||||||
|
hintText: "Medical Aid No.",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medAidCodeController,
|
||||||
|
hintText: "Medical Aid Code",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medNameController,
|
||||||
|
hintText: "Medical Aid Name",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: MyTextField(
|
||||||
|
controller: medSchemeController,
|
||||||
|
hintText: "Medical Aid Scheme",
|
||||||
|
editable: true,
|
||||||
|
required: medRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
//const SizedBox(height: 10.0),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 500.0,
|
||||||
|
height: 100.0,
|
||||||
|
child: MyButton(
|
||||||
|
onTap: () {
|
||||||
|
if (isFieldsFilled()) {
|
||||||
|
updatePatientApiCall();
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MyErrorMessage(
|
||||||
|
errorType: "Input Error");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonText: "Update",
|
||||||
|
buttonColor: Colors.blueAccent,
|
||||||
|
textColor: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
getLoginUserEmail();
|
getLoginUserEmail();
|
||||||
|
medAidController.addListener(isRequired);
|
||||||
setState(() {
|
setState(() {
|
||||||
idController.value = TextEditingValue(text: widget.selectedPatient.id_no);
|
idController.value = TextEditingValue(text: widget.selectedPatient.id_no);
|
||||||
fnameController.value =
|
fnameController.value =
|
||||||
@@ -307,7 +578,14 @@ class _EditPatientState extends State<EditPatient> {
|
|||||||
TextEditingValue(text: widget.selectedPatient.medical_aid_scheme);
|
TextEditingValue(text: widget.selectedPatient.medical_aid_scheme);
|
||||||
addressController.value =
|
addressController.value =
|
||||||
TextEditingValue(text: widget.selectedPatient.address);
|
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();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,190 +593,7 @@ class _EditPatientState extends State<EditPatient> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const MyAppBar(barTitle: "Edit Patient"),
|
appBar: const MyAppBar(barTitle: "Edit Patient"),
|
||||||
body: Padding(
|
body: displayForm(),
|
||||||
padding: const EdgeInsets.all(15.0),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Text(
|
|
||||||
"Personal Details",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25.0,
|
|
||||||
//color: Colors.blueAccent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.delete),
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
onPressed: () {
|
|
||||||
deletePatientPopUp();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: idController,
|
|
||||||
hintText: "13 digit ID Number or Passport",
|
|
||||||
editable: false,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: fnameController,
|
|
||||||
hintText: "First Name",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: lnameController,
|
|
||||||
hintText: "Last Name",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: cellController,
|
|
||||||
hintText: "Cell Number",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: emailController,
|
|
||||||
hintText: "Email",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: addressController,
|
|
||||||
hintText: "Address",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15.0),
|
|
||||||
const Text(
|
|
||||||
"Medical Aid Details",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25.0,
|
|
||||||
//color: Colors.blueAccent,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: medNoController,
|
|
||||||
hintText: "Medical Aid No.",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: medNameController,
|
|
||||||
hintText: "Medical Aid Name",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: MyTextField(
|
|
||||||
controller: medSchemeController,
|
|
||||||
hintText: "Medical Aid Scheme",
|
|
||||||
editable: true,
|
|
||||||
required: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
//const SizedBox(height: 10.0),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 500.0,
|
|
||||||
height: 100.0,
|
|
||||||
child: MyButton(
|
|
||||||
onTap: () {
|
|
||||||
if (isFieldsFilled()) {
|
|
||||||
updatePatientApiCall();
|
|
||||||
} else {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MyErrorMessage(
|
|
||||||
errorType: "Input Error");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buttonText: "Update",
|
|
||||||
buttonColor: Colors.blueAccent,
|
|
||||||
textColor: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,11 +31,17 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
Future<List<Patient>> fetchPatients(String endpoint) async {
|
Future<List<Patient>> fetchPatients(String endpoint) async {
|
||||||
//print("Patien manager page: $endpoint");
|
//print("Patien manager page: $endpoint");
|
||||||
final response = await http.get(Uri.parse(endpoint));
|
final response = await http.get(Uri.parse(endpoint));
|
||||||
//print(response.statusCode);
|
// print("Here");
|
||||||
|
// print(response.body);
|
||||||
|
// print(response.statusCode);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
|
//print("Here1");
|
||||||
Iterable l = jsonDecode(response.body);
|
Iterable l = jsonDecode(response.body);
|
||||||
|
//print("Here2");
|
||||||
List<Patient> patients =
|
List<Patient> patients =
|
||||||
List<Patient>.from(l.map((model) => Patient.fromJson(model)));
|
List<Patient>.from(l.map((model) => Patient.fromJson(model)));
|
||||||
|
// print("Here3");
|
||||||
|
// print(patients);
|
||||||
return patients;
|
return patients;
|
||||||
} else {
|
} else {
|
||||||
throw Exception('failed to load patients');
|
throw Exception('failed to load patients');
|
||||||
@@ -43,9 +49,16 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Patient> filterSearchResults(List<Patient> mainList, String query) {
|
List<Patient> filterSearchResults(List<Patient> mainList, String query) {
|
||||||
return mainList
|
List<Patient> templist = [];
|
||||||
.where((tempList) => tempList.id_no.contains(query.toLowerCase()))
|
//print(query);
|
||||||
.toList();
|
for (var item in mainList) {
|
||||||
|
if (item.id_no.contains(searchString) ||
|
||||||
|
item.medical_aid_no.contains(searchString)) {
|
||||||
|
//print(item.medical_aid_no);
|
||||||
|
templist.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return templist;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget displayList(List<Patient> patientsList, String searchString) {
|
Widget displayList(List<Patient> patientsList, String searchString) {
|
||||||
@@ -57,6 +70,7 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
bottom: 25,
|
bottom: 25,
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
height: 500,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(25.0),
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
@@ -64,7 +78,7 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
),
|
),
|
||||||
child: BuildPatientsList(
|
child: BuildPatientsList(
|
||||||
patients: patientsList,
|
patients: patientsList,
|
||||||
searchString: searchString,
|
//searchString: searchString,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -76,6 +90,7 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
bottom: 25,
|
bottom: 25,
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
height: 500,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(25.0),
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
@@ -83,7 +98,7 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
),
|
),
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
"Enter ID of Patient",
|
"Enter ID or Medical Aid No. of Patient",
|
||||||
style: TextStyle(fontSize: 25, color: Colors.grey),
|
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
@@ -92,46 +107,53 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget patientSearch() {
|
Widget patientSearch(double w, double h) {
|
||||||
return Column(children: [
|
return SizedBox(
|
||||||
//spacer
|
width: w,
|
||||||
const SizedBox(height: 10),
|
height: h,
|
||||||
MySearchField(
|
child: Column(mainAxisSize: MainAxisSize.max, children: [
|
||||||
controller: searchController,
|
//spacer
|
||||||
hintText: "ID Search",
|
const SizedBox(height: 10),
|
||||||
required: false,
|
MySearchField(
|
||||||
editable: true,
|
controller: searchController,
|
||||||
onTap: () {},
|
hintText: "ID or Medical Aid No. Search",
|
||||||
onChanged: (value) {
|
required: false,
|
||||||
setState(() {
|
editable: true,
|
||||||
searchString = value;
|
onTap: () {},
|
||||||
});
|
onChanged: (value) {
|
||||||
},
|
setState(() {
|
||||||
),
|
searchString = value;
|
||||||
//spacer
|
});
|
||||||
const SizedBox(height: 10),
|
},
|
||||||
FutureBuilder(
|
),
|
||||||
future: futurePatients,
|
//spacer
|
||||||
builder: (context, snapshot) {
|
const SizedBox(height: 10),
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
FutureBuilder(
|
||||||
return const Center(child: CircularProgressIndicator());
|
future: futurePatients,
|
||||||
} else if (snapshot.hasData) {
|
builder: (context, snapshot) {
|
||||||
List<Patient> patientsList;
|
//print("patient Liust ${snapshot.data}");
|
||||||
if (searchString == "") {
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
patientsList = snapshot.data!;
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else {
|
} else if (snapshot.hasData) {
|
||||||
patientsList = filterSearchResults(snapshot.data!, searchString);
|
List<Patient> patientsList;
|
||||||
}
|
if (searchString == "") {
|
||||||
|
patientsList = [];
|
||||||
|
} else {
|
||||||
|
patientsList =
|
||||||
|
filterSearchResults(snapshot.data!, searchString);
|
||||||
|
//print(patientsList);
|
||||||
|
}
|
||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: displayList(patientsList, searchString),
|
child: displayList(patientsList, searchString),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return const PatManAppDrawer(userEmail: "Error pulling email");
|
return const Center(child: Text("Error pulling email"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]);
|
]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -142,6 +164,8 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
final screenHeight = MediaQuery.of(context).size.height;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const MyAppBar(barTitle: "Patient Manager"),
|
appBar: const MyAppBar(barTitle: "Patient Manager"),
|
||||||
drawer: PatManAppDrawer(userEmail: widget.userEmail),
|
drawer: PatManAppDrawer(userEmail: widget.userEmail),
|
||||||
@@ -167,13 +191,7 @@ class _PatientManagerState extends State<PatientManager> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Row(
|
body: patientSearch(screenWidth, screenHeight),
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: patientSearch(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user