1) buildmedlist - update data to add unit and form when clicking a medicine
This commit is contained in:
@@ -17,9 +17,9 @@ class BuildMedicinesList extends StatefulWidget {
|
|||||||
State<BuildMedicinesList> createState() => _BuildMedicinesListState();
|
State<BuildMedicinesList> createState() => _BuildMedicinesListState();
|
||||||
}
|
}
|
||||||
|
|
||||||
int indexOn = 0;
|
|
||||||
|
|
||||||
class _BuildMedicinesListState extends State<BuildMedicinesList> {
|
class _BuildMedicinesListState extends State<BuildMedicinesList> {
|
||||||
|
int indexOn = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
@@ -35,7 +35,8 @@ class _BuildMedicinesListState extends State<BuildMedicinesList> {
|
|||||||
"${widget.medicines[index].unit} - ${widget.medicines[index].form}"),
|
"${widget.medicines[index].unit} - ${widget.medicines[index].form}"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
widget.contoller.text = widget.medicines[index].name;
|
widget.contoller.text =
|
||||||
|
"${widget.medicines[index].name}%t${widget.medicines[index].unit}%t${widget.medicines[index].form}";
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -84,18 +84,6 @@ class _MedicineSearchState extends State<MedicineSearch> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25.0),
|
const SizedBox(height: 25.0),
|
||||||
// MySearchField(
|
|
||||||
// controller: searchController,
|
|
||||||
// hintText: "Medicine",
|
|
||||||
// onChanged: (value) {
|
|
||||||
// setState(() {
|
|
||||||
// searchString = value;
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// required: true,
|
|
||||||
// editable: true,
|
|
||||||
// onTap: () {},
|
|
||||||
// ),
|
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: futueMeds,
|
future: futueMeds,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
@@ -106,7 +94,7 @@ class _MedicineSearchState extends State<MedicineSearch> {
|
|||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData && snapshot.data!.isNotEmpty) {
|
||||||
final medsList = snapshot.data!;
|
final medsList = snapshot.data!;
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: 400,
|
height: 400,
|
||||||
@@ -120,7 +108,11 @@ class _MedicineSearchState extends State<MedicineSearch> {
|
|||||||
return const SizedBox(
|
return const SizedBox(
|
||||||
height: 400,
|
height: 400,
|
||||||
child: const Center(
|
child: const Center(
|
||||||
child: Text("Error Loading Medicines"),
|
child: Text(
|
||||||
|
"No Match Found\nPlease close and manually capture medicine",
|
||||||
|
style: TextStyle(fontSize: 25, color: Colors.grey),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:patient_manager/components/medicineSearch.dart';
|
import 'package:patient_manager/components/medicineSearch.dart';
|
||||||
import 'package:patient_manager/components/myDropdownInput.dart';
|
import 'package:patient_manager/components/myDropdownInput.dart';
|
||||||
import 'package:patient_manager/components/myMLTextInput.dart';
|
import 'package:patient_manager/components/myErrorMessage.dart';
|
||||||
import 'package:patient_manager/components/mySearchInput.dart';
|
import 'package:patient_manager/components/mySearchInput.dart';
|
||||||
import 'package:patient_manager/components/mybutton.dart';
|
import 'package:patient_manager/components/mybutton.dart';
|
||||||
|
|
||||||
@@ -30,7 +30,8 @@ class PrescripInput extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PrescripInputState extends State<PrescripInput> {
|
class _PrescripInputState extends State<PrescripInput> {
|
||||||
String searchString = "";
|
//String perscriptionOutput = "";
|
||||||
|
List<List<String>> perscriptionOutput = [];
|
||||||
|
|
||||||
final numberOptions = [
|
final numberOptions = [
|
||||||
"0",
|
"0",
|
||||||
@@ -77,32 +78,55 @@ class _PrescripInputState extends State<PrescripInput> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
bool isFieldsFilled() {
|
||||||
void initState() {
|
if (widget.medicineController.text.isEmpty ||
|
||||||
//futueMeds = getMedList(endpointMeds);
|
widget.quantityController.text.isEmpty ||
|
||||||
super.initState();
|
widget.dosageController.text.isEmpty ||
|
||||||
|
widget.timesDailyController.text.isEmpty ||
|
||||||
|
widget.noDaysController.text.isEmpty ||
|
||||||
|
widget.noRepeatsController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
void updatePerscriptionList() {
|
||||||
Widget build(BuildContext context) {
|
List<String> medNameList = widget.medicineController.text.split("%t");
|
||||||
return SizedBox(
|
List<String> temp = [];
|
||||||
child: Row(
|
temp.add(medNameList[0]); //Name 0
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
temp.add(medNameList[1]); //Unit 1
|
||||||
mainAxisSize: MainAxisSize.max,
|
temp.add(medNameList[2]); //Form 2
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
temp.add(widget.quantityController.text); //Quantity 3
|
||||||
children: [
|
temp.add(widget.quantityController.text); //Dosage 4
|
||||||
Column(
|
temp.add(widget.timesDailyController.text); //Times Daily 5
|
||||||
|
temp.add(widget.noDaysController.text); //No Days 6
|
||||||
|
temp.add(widget.noRepeatsController.text); //No Repeats 7
|
||||||
|
|
||||||
|
perscriptionOutput.add(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getPerscTitle(int index) {
|
||||||
|
return "${perscriptionOutput[index][0]} (${perscriptionOutput[index][1]})";
|
||||||
|
}
|
||||||
|
|
||||||
|
String getPerscSubtitle(int index) {
|
||||||
|
if (perscriptionOutput[index][3].toLowerCase() == "syr") {
|
||||||
|
return "${perscriptionOutput[index][4]} ${perscriptionOutput[index][3]}, ${perscriptionOutput[index][5]} times daily, for ${perscriptionOutput[index][6]}\nQuantity: ${perscriptionOutput[index][3]}\nNo. of repeats ${perscriptionOutput[index][7]}";
|
||||||
|
} else {
|
||||||
|
return "${perscriptionOutput[index][4]} ${perscriptionOutput[index][1]}, ${perscriptionOutput[index][5]} times daily, for ${perscriptionOutput[index][6]}\nQuantity: ${perscriptionOutput[index][3]}\nNo. of repeats ${perscriptionOutput[index][7]}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget displayMedInput() {
|
||||||
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 300,
|
width: 300,
|
||||||
child: MySearchField(
|
child: MySearchField(
|
||||||
controller: widget.medicineController,
|
controller: widget.medicineController,
|
||||||
hintText: "Medicine",
|
hintText: "Medicine",
|
||||||
onChanged: (value) {
|
onChanged: (value) {},
|
||||||
setState(() {
|
|
||||||
searchString = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
required: true,
|
required: true,
|
||||||
editable: true,
|
editable: true,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
@@ -163,25 +187,75 @@ class _PrescripInputState extends State<PrescripInput> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 300,
|
width: 300,
|
||||||
child: MyButton(
|
child: MyButton(
|
||||||
onTap: () {},
|
onTap: () {
|
||||||
|
if (isFieldsFilled()) {
|
||||||
|
setState(() {
|
||||||
|
updatePerscriptionList();
|
||||||
|
widget.medicineController.clear();
|
||||||
|
widget.quantityController.clear();
|
||||||
|
widget.dosageController.clear();
|
||||||
|
widget.timesDailyController.clear();
|
||||||
|
widget.noDaysController.clear();
|
||||||
|
widget.noRepeatsController.clear();
|
||||||
|
});
|
||||||
|
|
||||||
|
//addPatientAPICall();
|
||||||
|
} else {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MyErrorMessage(errorType: "Input Error");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
buttonText: "Add",
|
buttonText: "Add",
|
||||||
buttonColor: Colors.blueAccent,
|
buttonColor: Colors.blueAccent,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
//const SizedBox(height: 50.0),
|
}
|
||||||
Column(
|
|
||||||
|
Widget displayPerscList() {
|
||||||
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
Container(
|
||||||
width: 550,
|
width: 550,
|
||||||
height: 400,
|
height: 400,
|
||||||
child: MyMLTextField(
|
decoration: BoxDecoration(
|
||||||
controller: widget.outputController,
|
color: Colors.white,
|
||||||
hintText: "Prescrion Output",
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
editable: false,
|
border: Border.all(color: Colors.blueAccent, width: 3.0),
|
||||||
required: false,
|
),
|
||||||
|
child: ListView.separated(
|
||||||
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return const Divider();
|
||||||
|
},
|
||||||
|
itemCount: perscriptionOutput.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
//final patient = widget.patients[index].id_no.contains(widget.searchString);
|
||||||
|
return ListTile(
|
||||||
|
title: Text(
|
||||||
|
getPerscTitle(index),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
getPerscSubtitle(index),
|
||||||
|
),
|
||||||
|
//onTap: () {},
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: const Icon(
|
||||||
|
Icons.delete_forever_outlined,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
perscriptionOutput.removeAt(index);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -208,7 +282,25 @@ class _PrescripInputState extends State<PrescripInput> {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
//futueMeds = getMedList(endpointMeds);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
displayMedInput(),
|
||||||
|
displayPerscList(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user