change UP to cater for new med aid fields
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/myDropdownInput.dart';
|
||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
@@ -31,9 +32,14 @@ class _AddPatientState extends State<AddPatient> {
|
||||
final medNameController = TextEditingController();
|
||||
final medSchemeController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final medAidController = TextEditingController();
|
||||
final medMainMemController = TextEditingController();
|
||||
final medAidCodeController = TextEditingController();
|
||||
|
||||
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
||||
final apiUrl = "http://localhost:80/patients/insert/";
|
||||
late int futureDocOfficeId;
|
||||
late bool medRequired;
|
||||
|
||||
Future getOfficeIdByUser(String endpoint) async {
|
||||
final response = await http.get(Uri.parse(endpoint));
|
||||
@@ -52,18 +58,35 @@ class _AddPatientState extends State<AddPatient> {
|
||||
}
|
||||
|
||||
bool isFieldsFilled() {
|
||||
if (idController.text.isEmpty ||
|
||||
fnameController.text.isEmpty ||
|
||||
lnameController.text.isEmpty ||
|
||||
cellController.text.isEmpty ||
|
||||
emailController.text.isEmpty ||
|
||||
medNoController.text.isEmpty ||
|
||||
medNameController.text.isEmpty ||
|
||||
medSchemeController.text.isEmpty ||
|
||||
addressController.text.isEmpty) {
|
||||
return false;
|
||||
if (medRequired) {
|
||||
if (idController.text.isEmpty ||
|
||||
fnameController.text.isEmpty ||
|
||||
lnameController.text.isEmpty ||
|
||||
cellController.text.isEmpty ||
|
||||
emailController.text.isEmpty ||
|
||||
medNoController.text.isEmpty ||
|
||||
medNameController.text.isEmpty ||
|
||||
medSchemeController.text.isEmpty ||
|
||||
addressController.text.isEmpty ||
|
||||
medAidController.text.isEmpty ||
|
||||
medMainMemController.text.isEmpty ||
|
||||
medAidCodeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} 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,
|
||||
"email": emailController.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_code": medAidCodeController.text,
|
||||
"medical_aid_name": medNameController.text,
|
||||
"medical_aid_scheme": medSchemeController.text,
|
||||
"address": addressController.text,
|
||||
"doc_office_id": futureDocOfficeId,
|
||||
@@ -131,182 +157,252 @@ class _AddPatientState extends State<AddPatient> {
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const MyAppBar(barTitle: "Add Patient"),
|
||||
body: Padding(
|
||||
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,
|
||||
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: [
|
||||
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: [
|
||||
Expanded(
|
||||
child: MyTextField(
|
||||
controller: idController,
|
||||
hintText: "13 digit ID Number or Passport",
|
||||
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: 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: lnameController,
|
||||
hintText: "Last Name",
|
||||
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: cellController,
|
||||
hintText: "Cell Number",
|
||||
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(
|
||||
children: [
|
||||
Expanded(
|
||||
child: MyTextField(
|
||||
controller: emailController,
|
||||
hintText: "Email",
|
||||
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()) {
|
||||
addPatientAPICall();
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MyErrorMessage(
|
||||
errorType: "Input Error");
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
buttonText: "Add",
|
||||
buttonColor: Colors.blueAccent,
|
||||
textColor: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
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",
|
||||
//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 'package:flutter/material.dart';
|
||||
import 'package:patient_manager/components/myDropdownInput.dart';
|
||||
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||
import 'package:patient_manager/components/mySuccessMessage.dart';
|
||||
import 'package:patient_manager/components/myTextInput.dart';
|
||||
@@ -33,11 +34,16 @@ class _EditPatientState extends State<EditPatient> {
|
||||
final medNameController = TextEditingController();
|
||||
final medSchemeController = TextEditingController();
|
||||
final addressController = TextEditingController();
|
||||
final medAidController = TextEditingController();
|
||||
final medMainMemController = TextEditingController();
|
||||
final medAidCodeController = TextEditingController();
|
||||
|
||||
final docOfficeIdApiUrl = "http://localhost:80/users/profile/";
|
||||
final apiUrlEdit = "http://localhost:80/patients/update/";
|
||||
final apiUrlDelete = "http://localhost:80/patients/delete/";
|
||||
late int futureDocOfficeId;
|
||||
late String userEmail;
|
||||
late bool medRequired;
|
||||
|
||||
Future getOfficeIdByUser(String endpoint) async {
|
||||
final response = await http.get(Uri.parse(endpoint));
|
||||
@@ -74,8 +80,11 @@ class _EditPatientState extends State<EditPatient> {
|
||||
"last_name": lnameController.text,
|
||||
"email": emailController.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_code": medAidCodeController.text,
|
||||
"medical_aid_name": medNameController.text,
|
||||
"medical_aid_scheme": medSchemeController.text,
|
||||
"address": addressController.text,
|
||||
"doc_office_id": futureDocOfficeId,
|
||||
@@ -271,24 +280,286 @@ class _EditPatientState extends State<EditPatient> {
|
||||
}
|
||||
|
||||
bool isFieldsFilled() {
|
||||
if (idController.text.isEmpty ||
|
||||
fnameController.text.isEmpty ||
|
||||
lnameController.text.isEmpty ||
|
||||
cellController.text.isEmpty ||
|
||||
emailController.text.isEmpty ||
|
||||
medNoController.text.isEmpty ||
|
||||
medNameController.text.isEmpty ||
|
||||
medSchemeController.text.isEmpty ||
|
||||
addressController.text.isEmpty) {
|
||||
return false;
|
||||
if (medRequired) {
|
||||
if (idController.text.isEmpty ||
|
||||
fnameController.text.isEmpty ||
|
||||
lnameController.text.isEmpty ||
|
||||
cellController.text.isEmpty ||
|
||||
emailController.text.isEmpty ||
|
||||
medNoController.text.isEmpty ||
|
||||
medNameController.text.isEmpty ||
|
||||
medSchemeController.text.isEmpty ||
|
||||
addressController.text.isEmpty ||
|
||||
medAidController.text.isEmpty ||
|
||||
medMainMemController.text.isEmpty ||
|
||||
medAidCodeController.text.isEmpty) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} 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
|
||||
void initState() {
|
||||
getLoginUserEmail();
|
||||
medAidController.addListener(isRequired);
|
||||
setState(() {
|
||||
idController.value = TextEditingValue(text: widget.selectedPatient.id_no);
|
||||
fnameController.value =
|
||||
@@ -307,7 +578,14 @@ class _EditPatientState extends State<EditPatient> {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -315,190 +593,7 @@ class _EditPatientState extends State<EditPatient> {
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const MyAppBar(barTitle: "Edit Patient"),
|
||||
body: 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: 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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
body: displayForm(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,17 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
Future<List<Patient>> fetchPatients(String endpoint) async {
|
||||
//print("Patien manager page: $endpoint");
|
||||
final response = await http.get(Uri.parse(endpoint));
|
||||
//print(response.statusCode);
|
||||
// print("Here");
|
||||
// print(response.body);
|
||||
// print(response.statusCode);
|
||||
if (response.statusCode == 200) {
|
||||
//print("Here1");
|
||||
Iterable l = jsonDecode(response.body);
|
||||
//print("Here2");
|
||||
List<Patient> patients =
|
||||
List<Patient>.from(l.map((model) => Patient.fromJson(model)));
|
||||
// print("Here3");
|
||||
// print(patients);
|
||||
return patients;
|
||||
} else {
|
||||
throw Exception('failed to load patients');
|
||||
@@ -43,9 +49,16 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
}
|
||||
|
||||
List<Patient> filterSearchResults(List<Patient> mainList, String query) {
|
||||
return mainList
|
||||
.where((tempList) => tempList.id_no.contains(query.toLowerCase()))
|
||||
.toList();
|
||||
List<Patient> templist = [];
|
||||
//print(query);
|
||||
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) {
|
||||
@@ -57,6 +70,7 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
bottom: 25,
|
||||
),
|
||||
child: Container(
|
||||
height: 500,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
@@ -64,7 +78,7 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
),
|
||||
child: BuildPatientsList(
|
||||
patients: patientsList,
|
||||
searchString: searchString,
|
||||
//searchString: searchString,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -76,6 +90,7 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
bottom: 25,
|
||||
),
|
||||
child: Container(
|
||||
height: 500,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(25.0),
|
||||
@@ -83,7 +98,7 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
"Enter ID of Patient",
|
||||
"Enter ID or Medical Aid No. of Patient",
|
||||
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
@@ -92,46 +107,53 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget patientSearch() {
|
||||
return Column(children: [
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
MySearchField(
|
||||
controller: searchController,
|
||||
hintText: "ID Search",
|
||||
required: false,
|
||||
editable: true,
|
||||
onTap: () {},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
searchString = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: futurePatients,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasData) {
|
||||
List<Patient> patientsList;
|
||||
if (searchString == "") {
|
||||
patientsList = snapshot.data!;
|
||||
} else {
|
||||
patientsList = filterSearchResults(snapshot.data!, searchString);
|
||||
}
|
||||
Widget patientSearch(double w, double h) {
|
||||
return SizedBox(
|
||||
width: w,
|
||||
height: h,
|
||||
child: Column(mainAxisSize: MainAxisSize.max, children: [
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
MySearchField(
|
||||
controller: searchController,
|
||||
hintText: "ID or Medical Aid No. Search",
|
||||
required: false,
|
||||
editable: true,
|
||||
onTap: () {},
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
searchString = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
//spacer
|
||||
const SizedBox(height: 10),
|
||||
FutureBuilder(
|
||||
future: futurePatients,
|
||||
builder: (context, snapshot) {
|
||||
//print("patient Liust ${snapshot.data}");
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (snapshot.hasData) {
|
||||
List<Patient> patientsList;
|
||||
if (searchString == "") {
|
||||
patientsList = [];
|
||||
} else {
|
||||
patientsList =
|
||||
filterSearchResults(snapshot.data!, searchString);
|
||||
//print(patientsList);
|
||||
}
|
||||
|
||||
return Expanded(
|
||||
child: displayList(patientsList, searchString),
|
||||
);
|
||||
} else {
|
||||
return const PatManAppDrawer(userEmail: "Error pulling email");
|
||||
}
|
||||
},
|
||||
),
|
||||
]);
|
||||
return Expanded(
|
||||
child: displayList(patientsList, searchString),
|
||||
);
|
||||
} else {
|
||||
return const Center(child: Text("Error pulling email"));
|
||||
}
|
||||
},
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -142,6 +164,8 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
return Scaffold(
|
||||
appBar: const MyAppBar(barTitle: "Patient Manager"),
|
||||
drawer: PatManAppDrawer(userEmail: widget.userEmail),
|
||||
@@ -167,13 +191,7 @@ class _PatientManagerState extends State<PatientManager> {
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: patientSearch(),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: patientSearch(screenWidth, screenHeight),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user