add radio button to claim generation
This commit is contained in:
@@ -22,17 +22,32 @@ class MihRadioOptions extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MihRadioOptionsState extends State<MihRadioOptions> {
|
class _MihRadioOptionsState extends State<MihRadioOptions> {
|
||||||
late String _currentSelection;
|
// late String _currentSelection;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
setState(() {
|
if (widget.controller.text.isEmpty && widget.radioOptions.isNotEmpty) {
|
||||||
_currentSelection = widget.radioOptions[0];
|
widget.controller.text = widget.radioOptions[0];
|
||||||
});
|
}
|
||||||
|
// else{
|
||||||
|
// int index = widget.radioOptions
|
||||||
|
// .indexWhere((element) => element == option);
|
||||||
|
// _currentSelection = widget.radioOptions[index];
|
||||||
|
// widget.controller.text = option;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// _currentSelection = widget.radioOptions[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget displayRadioOptions() {
|
// The method to handle a change in selection.
|
||||||
|
void _onChanged(String? value) {
|
||||||
|
if (value != null) {
|
||||||
|
widget.controller.text = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget displayRadioOptions(String selection) {
|
||||||
return Material(
|
return Material(
|
||||||
elevation: 4.0,
|
elevation: 4.0,
|
||||||
borderRadius: BorderRadius.circular(8.0),
|
borderRadius: BorderRadius.circular(8.0),
|
||||||
@@ -45,12 +60,7 @@ class _MihRadioOptionsState extends State<MihRadioOptions> {
|
|||||||
children: widget.radioOptions.map((option) {
|
children: widget.radioOptions.map((option) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
_onChanged(option);
|
||||||
int index = widget.radioOptions
|
|
||||||
.indexWhere((element) => element == option);
|
|
||||||
_currentSelection = widget.radioOptions[index];
|
|
||||||
widget.controller.text = option;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -67,13 +77,8 @@ class _MihRadioOptionsState extends State<MihRadioOptions> {
|
|||||||
),
|
),
|
||||||
Radio<String>(
|
Radio<String>(
|
||||||
value: option,
|
value: option,
|
||||||
groupValue: _currentSelection,
|
groupValue: selection,
|
||||||
onChanged: (value) {
|
onChanged: _onChanged,
|
||||||
setState(() {
|
|
||||||
_currentSelection = value!;
|
|
||||||
widget.controller.text = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
activeColor: widget.secondaryFillColor,
|
activeColor: widget.secondaryFillColor,
|
||||||
fillColor: WidgetStateProperty.resolveWith<Color?>(
|
fillColor: WidgetStateProperty.resolveWith<Color?>(
|
||||||
(Set<WidgetState> states) {
|
(Set<WidgetState> states) {
|
||||||
@@ -94,6 +99,10 @@ class _MihRadioOptionsState extends State<MihRadioOptions> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return AnimatedBuilder(
|
||||||
|
animation: widget.controller,
|
||||||
|
builder: (context, child) {
|
||||||
|
final currentSelection = widget.controller.text;
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@@ -123,8 +132,9 @@ class _MihRadioOptionsState extends State<MihRadioOptions> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
displayRadioOptions(),
|
displayRadioOptions(currentSelection),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_apis/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_apis/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_apis/mih_claim_statement_generation_api.dart';
|
import 'package:mzansi_innovation_hub/mih_apis/mih_claim_statement_generation_api.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_apis/mih_icd10_code_api.dart';
|
import 'package:mzansi_innovation_hub/mih_apis/mih_icd10_code_api.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_apis/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_apis/mih_validation_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_date_input.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_date_input.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_dropdown_input.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_radio_options.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_search_bar.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
@@ -93,13 +91,15 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
MihForm(
|
MihForm(
|
||||||
formKey: _formKey,
|
formKey: _formKey,
|
||||||
formFields: [
|
formFields: [
|
||||||
MIHDropdownField(
|
MihRadioOptions(
|
||||||
controller: _docTypeController,
|
controller: _docTypeController,
|
||||||
hintText: "Document Type",
|
hintText: "Document Type",
|
||||||
dropdownOptions: const ["Claim", "Statement"],
|
fillColor:
|
||||||
required: true,
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
editable: true,
|
secondaryFillColor:
|
||||||
enableSearch: false,
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
requiredText: true,
|
||||||
|
radioOptions: const ["Claim", "Statement"],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Center(
|
Center(
|
||||||
@@ -124,17 +124,19 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
required: true,
|
required: true,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
MIHDropdownField(
|
MihRadioOptions(
|
||||||
controller: _serviceDescController,
|
controller: _serviceDescController,
|
||||||
hintText: "Service Decription",
|
hintText: "Serviced Description",
|
||||||
dropdownOptions: const [
|
fillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
secondaryFillColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
requiredText: true,
|
||||||
|
radioOptions: const [
|
||||||
"Consultation",
|
"Consultation",
|
||||||
"Procedure",
|
"Procedure",
|
||||||
"Other",
|
"Other",
|
||||||
],
|
],
|
||||||
required: true,
|
|
||||||
editable: true,
|
|
||||||
enableSearch: false,
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
ValueListenableBuilder(
|
ValueListenableBuilder(
|
||||||
@@ -144,29 +146,37 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
switch (value) {
|
switch (value) {
|
||||||
case 'Consultation':
|
case 'Consultation':
|
||||||
returnWidget = Column(
|
returnWidget = Column(
|
||||||
|
key: const ValueKey('consultation_fields'), // Added key
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
MihRadioOptions(
|
||||||
child: MIHDropdownField(
|
key: const ValueKey('consultation_type_dropdown'),
|
||||||
controller: _serviceDescOptionsController,
|
controller: _serviceDescOptionsController,
|
||||||
hintText: "Consultation Type",
|
hintText: "Consultation Type",
|
||||||
dropdownOptions: const [
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
secondaryFillColor: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
requiredText: true,
|
||||||
|
radioOptions: const [
|
||||||
"General Consultation",
|
"General Consultation",
|
||||||
"Follow-Up Consultation",
|
"Follow-Up Consultation",
|
||||||
"Specialist Consultation",
|
"Specialist Consultation",
|
||||||
"Emergency Consultation",
|
"Emergency Consultation",
|
||||||
],
|
],
|
||||||
required: true,
|
|
||||||
editable: true,
|
|
||||||
enableSearch: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
break;
|
||||||
case 'Procedure':
|
case 'Procedure':
|
||||||
returnWidget = Column(
|
returnWidget = Column(
|
||||||
|
key: const ValueKey('procedure_fields'), // Added key
|
||||||
children: [
|
children: [
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
|
key: const ValueKey(
|
||||||
|
'procedure_name_field'), // Added key
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.secondaryColor(),
|
.secondaryColor(),
|
||||||
@@ -183,6 +193,8 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
|
key: const ValueKey(
|
||||||
|
'procedure_additional_info_field'), // Added key
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.secondaryColor(),
|
.secondaryColor(),
|
||||||
@@ -192,7 +204,7 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
controller: _proceedureAdditionalInfoController,
|
controller: _proceedureAdditionalInfoController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: true,
|
||||||
hintText: "Additional Information",
|
hintText: "Additional Procedure Information",
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
return MihValidationServices().isEmpty(value);
|
return MihValidationServices().isEmpty(value);
|
||||||
},
|
},
|
||||||
@@ -200,10 +212,14 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
break;
|
||||||
case 'Other':
|
case 'Other':
|
||||||
returnWidget = Column(
|
returnWidget = Column(
|
||||||
|
key: const ValueKey('other_fields'), // Added key
|
||||||
children: [
|
children: [
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
|
key: const ValueKey(
|
||||||
|
'other_service_description_field'), // Added key
|
||||||
fillColor: MzanziInnovationHub.of(context)!
|
fillColor: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.secondaryColor(),
|
.secondaryColor(),
|
||||||
@@ -221,8 +237,10 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
returnWidget = const SizedBox();
|
returnWidget = const SizedBox(
|
||||||
|
key: const ValueKey('empty_fields')); // Added key
|
||||||
}
|
}
|
||||||
return returnWidget;
|
return returnWidget;
|
||||||
},
|
},
|
||||||
@@ -233,7 +251,7 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: Text("ICD-10 Code & Description",
|
child: Text("ICD-10 Code & Description",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: MzanziInnovationHub.of(context)!
|
color: MzanziInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
@@ -384,16 +402,25 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void serviceDescriptionSelected() {
|
void serviceDescriptionSelected() {
|
||||||
if (_serviceDescController.text.isNotEmpty) {
|
String selectedType = _serviceDescController.text;
|
||||||
serviceDesc.value = _serviceDescController.text;
|
serviceDesc.value = selectedType;
|
||||||
|
if (selectedType == 'Consultation') {
|
||||||
|
_prcedureNameController.clear();
|
||||||
|
_proceedureAdditionalInfoController.clear();
|
||||||
|
} else if (selectedType == 'Procedure') {
|
||||||
|
_serviceDescOptionsController.clear();
|
||||||
|
} else if (selectedType == 'Other') {
|
||||||
|
_prcedureNameController.clear();
|
||||||
|
_proceedureAdditionalInfoController.clear();
|
||||||
} else {
|
} else {
|
||||||
serviceDesc.value = "";
|
_prcedureNameController.clear();
|
||||||
|
_proceedureAdditionalInfoController.clear();
|
||||||
|
_serviceDescOptionsController.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hasMedAid() {
|
void hasMedAid() {
|
||||||
if (_medAidController.text.isNotEmpty) {
|
if (_medAidController.text.isNotEmpty) {
|
||||||
medAid.value = _medAidController.text;
|
|
||||||
} else {
|
} else {
|
||||||
medAid.value = "";
|
medAid.value = "";
|
||||||
}
|
}
|
||||||
@@ -403,12 +430,26 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
if (_docTypeController.text.isEmpty ||
|
if (_docTypeController.text.isEmpty ||
|
||||||
_serviceDateController.text.isEmpty ||
|
_serviceDateController.text.isEmpty ||
|
||||||
_icd10CodeController.text.isEmpty ||
|
_icd10CodeController.text.isEmpty ||
|
||||||
_amountController.text.isEmpty ||
|
_amountController.text.isEmpty) {
|
||||||
_serviceDescOptionsController.text.isEmpty) {
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
switch (_serviceDescController.text) {
|
||||||
|
case 'Consultation':
|
||||||
|
case 'Other':
|
||||||
|
if (_serviceDescOptionsController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Procedure':
|
||||||
|
if (_prcedureNameController.text.isEmpty ||
|
||||||
|
_proceedureAdditionalInfoController.text.isEmpty) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getUserTitle() {
|
String getUserTitle() {
|
||||||
@@ -446,12 +487,18 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
_icd10CodeController.dispose();
|
_icd10CodeController.dispose();
|
||||||
_preauthNoController.dispose();
|
_preauthNoController.dispose();
|
||||||
_searchFocusNode.dispose();
|
_searchFocusNode.dispose();
|
||||||
|
serviceDesc.dispose();
|
||||||
|
medAid.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
_serviceDescController.text = "Consultation";
|
||||||
_serviceDescController.addListener(serviceDescriptionSelected);
|
_serviceDescController.addListener(serviceDescriptionSelected);
|
||||||
|
serviceDesc.value = "Consultation";
|
||||||
_medAidController.addListener(hasMedAid);
|
_medAidController.addListener(hasMedAid);
|
||||||
_fullNameController.text =
|
_fullNameController.text =
|
||||||
"${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}";
|
"${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}";
|
||||||
@@ -466,7 +513,7 @@ class _ClaimStatementWindowState extends State<ClaimStatementWindow> {
|
|||||||
"${getUserTitle()} ${widget.signedInUser.fname} ${widget.signedInUser.lname}";
|
"${getUserTitle()} ${widget.signedInUser.fname} ${widget.signedInUser.lname}";
|
||||||
_practiceNoController.text = widget.business!.practice_no;
|
_practiceNoController.text = widget.business!.practice_no;
|
||||||
_vatNoController.text = widget.business!.vat_no;
|
_vatNoController.text = widget.business!.vat_no;
|
||||||
super.initState();
|
hasMedAid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
Reference in New Issue
Block a user