flutter 2 migration

flutter_vervion_2
hussam al-habibeh 5 years ago
parent daf125b995
commit 73f2abbea2

@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]";
const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_LETTERS = "[a-zA-Z &'\"]";
const ONLY_DATE = "[0-9/]"; const ONLY_DATE = "[0-9/]";
const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/';
const BASE_URL = 'https://hmgwebservices.com/'; // const BASE_URL = 'https://hmgwebservices.com/';
// const BASE_URL = 'https://uat.hmgwebservices.com/'; const BASE_URL = 'https://uat.hmgwebservices.com/';
const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh";
const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList";
const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient";

@ -38,7 +38,7 @@ class _AdmissionRequestSecondScreenState extends State<AdmissionRequestSecondScr
final _complicationsController = TextEditingController(); final _complicationsController = TextEditingController();
final _otherProceduresController = TextEditingController(); final _otherProceduresController = TextEditingController();
late DateTime _expectedAdmissionDate; DateTime? _expectedAdmissionDate;
dynamic _selectedFloor; dynamic _selectedFloor;
dynamic _selectedWard; dynamic _selectedWard;
@ -194,7 +194,7 @@ class _AdmissionRequestSecondScreenState extends State<AdmissionRequestSecondScr
if (_expectedAdmissionDate == null) { if (_expectedAdmissionDate == null) {
_expectedAdmissionDate = DateTime.now(); _expectedAdmissionDate = DateTime.now();
} }
_selectDate(context, _expectedAdmissionDate, (picked) { _selectDate(context, _expectedAdmissionDate!, (picked) {
setState(() { setState(() {
_expectedAdmissionDate = picked; _expectedAdmissionDate = picked;
}); });
@ -426,7 +426,7 @@ class _AdmissionRequestSecondScreenState extends State<AdmissionRequestSecondScr
_postPlansEstimatedCostController.text; _postPlansEstimatedCostController.text;
model.admissionRequestData.expectedDays = int.parse(_expectedDaysController.text); model.admissionRequestData.expectedDays = int.parse(_expectedDaysController.text);
model.admissionRequestData.admissionDate = _expectedAdmissionDate.toIso8601String(); model.admissionRequestData.admissionDate = _expectedAdmissionDate!.toIso8601String();
model.admissionRequestData.otherDepartmentInterventions = model.admissionRequestData.otherDepartmentInterventions =
_otherDepartmentsInterventionsController.text; _otherDepartmentsInterventionsController.text;
model.admissionRequestData.admissionLocationID = _selectedFloor['floorID']; model.admissionRequestData.admissionLocationID = _selectedFloor['floorID'];

@ -40,8 +40,8 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
late List<NoteModel> notesList; late List<NoteModel> notesList;
var filteredNotesList; var filteredNotesList;
bool isDischargedPatient = false; bool isDischargedPatient = false;
AuthenticationViewModel? authenticationViewModel; late AuthenticationViewModel authenticationViewModel;
ProjectViewModel? projectViewModel; late ProjectViewModel projectViewModel;
getProgressNoteList(BuildContext context, PatientViewModel model, {bool isLocalBusy = false}) async { getProgressNoteList(BuildContext context, PatientViewModel model, {bool isLocalBusy = false}) async {
final routeArgs = ModalRoute.of(context)!.settings.arguments as Map; final routeArgs = ModalRoute.of(context)!.settings.arguments as Map;
@ -65,8 +65,8 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// authenticationViewModel = Provider.of(context); authenticationViewModel = Provider.of(context);
// projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
final routeArgs = ModalRoute.of(context)!.settings.arguments as Map; final routeArgs = ModalRoute.of(context)!.settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient']; PatiantInformtion patient = routeArgs['patient'];
String arrivalType = routeArgs['arrivalType']; String arrivalType = routeArgs['arrivalType'];
@ -90,308 +90,313 @@ class _ProgressNoteState extends State<ProgressNoteScreen> {
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
if (!isDischargedPatient) if (!isDischargedPatient)
AddNewOrder( // AddNewOrder(
onTap: () { // onTap: () {
Navigator.push( // Navigator.push(
context, // context,
MaterialPageRoute( // MaterialPageRoute(
builder: (context) => UpdateNoteOrder( // builder: (context) => UpdateNoteOrder(
patientModel: model, // patientModel: model,
patient: patient, // patient: patient,
visitType: widget.visitType, // visitType: widget.visitType,
isUpdate: false, // isUpdate: false,
)), // )),
); // );
}, // },
label: widget.visitType == 3 // label: widget.visitType == 3
? TranslationBase.of(context).addNewOrderSheet! // ? TranslationBase.of(context).addNewOrderSheet!
: TranslationBase.of(context).addProgressNote!, // : TranslationBase.of(context).addProgressNote!,
), // ),
Expanded( Expanded(
child: Container( child: Container(
child: ListView.builder( child: ListView.builder(
itemCount: model.patientProgressNoteList.length, itemCount: model.patientProgressNoteList.length,
itemBuilder: (BuildContext ctxt, int index) { itemBuilder: (BuildContext ctxt, int index) {
return FractionallySizedBox( return FractionallySizedBox(
widthFactor: 0.95, widthFactor: 0.95,
child: CardWithBgWidget( child: CardWithBgWidget(
hasBorder: false, hasBorder: false,
bgColor: model.patientProgressNoteList[index].status == 1 && bgColor: model.patientProgressNoteList[index].status == 1 &&
authenticationViewModel!.doctorProfile!.doctorID != authenticationViewModel!.doctorProfile!.doctorID !=
model.patientProgressNoteList[index].createdBy model.patientProgressNoteList[index].createdBy
? Color(0xFFCC9B14) ? Color(0xFFCC9B14)
: model.patientProgressNoteList[index].status == 4 : model.patientProgressNoteList[index].status == 4
? Colors.red.shade700 ? Colors.red.shade700
: model.patientProgressNoteList[index].status == 2 : model.patientProgressNoteList[index].status == 2
? Colors.green[600]! ? Colors.green[600]!
: Color(0xFFCC9B14)!, : Color(0xFFCC9B14)!,
widget: Column( widget: Column(
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (model.patientProgressNoteList[index].status == 1 && if (model.patientProgressNoteList[index].status == 1 &&
authenticationViewModel!.doctorProfile!.doctorID != authenticationViewModel!.doctorProfile!.doctorID !=
model.patientProgressNoteList[index].createdBy) model.patientProgressNoteList[index].createdBy)
AppText( AppText(
TranslationBase.of(context).notePending, TranslationBase.of(context).notePending,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Color(0xFFCC9B14), color: Color(0xFFCC9B14),
fontSize: 12, fontSize: 12,
), ),
if (model.patientProgressNoteList[index].status == 4) if (model.patientProgressNoteList[index].status == 4)
AppText( AppText(
TranslationBase.of(context).noteCanceled, TranslationBase.of(context).noteCanceled,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.red.shade700, color: Colors.red.shade700,
fontSize: 12, fontSize: 12,
), ),
if (model.patientProgressNoteList[index].status == 2) if (model.patientProgressNoteList[index].status == 2)
AppText( AppText(
TranslationBase.of(context).noteVerified, TranslationBase.of(context).noteVerified,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Colors.green[600], color: Colors.green[600],
fontSize: 12, fontSize: 12,
), ),
if (model.patientProgressNoteList[index].status != 2 && if (model.patientProgressNoteList[index].status != 2 &&
model.patientProgressNoteList[index].status != 4 && model.patientProgressNoteList[index].status != 4 &&
authenticationViewModel!.doctorProfile!.doctorID == authenticationViewModel!.doctorProfile!.doctorID ==
model.patientProgressNoteList[index].createdBy) model.patientProgressNoteList[index].createdBy)
Row( Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => UpdateNoteOrder( builder: (context) => UpdateNoteOrder(
note: model.patientProgressNoteList[index], note: model.patientProgressNoteList[index],
patientModel: model, patientModel: model,
patient: patient, patient: patient,
visitType: widget.visitType, visitType: widget.visitType,
isUpdate: true, isUpdate: true,
)), )),
); );
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.grey[600], color: Colors.grey[600],
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
// color:Colors.red[600], // color:Colors.red[600],
child: Row( child: Row(
children: [ children: [
Icon( Icon(
DoctorApp.edit_1, DoctorApp.edit_1,
size: 12, size: 12,
color: Colors.white, color: Colors.white,
), ),
SizedBox( SizedBox(
width: 2, width: 2,
), ),
AppText( AppText(
TranslationBase.of(context).update, TranslationBase.of(context).update,
fontSize: 10, fontSize: 10,
color: Colors.white, color: Colors.white,
), ),
], ],
),
padding: EdgeInsets.all(6),
), ),
padding: EdgeInsets.all(6),
), ),
), SizedBox(
SizedBox( width: 10,
width: 10, ),
), InkWell(
InkWell( onTap: () async {
onTap: () async { showMyDialog(
showMyDialog( context: context,
context: context, actionName: "verify",
actionName: "verify", confirmFun: () async {
confirmFun: () async { GifLoaderDialogUtils.showMyDialog(context);
GifLoaderDialogUtils.showMyDialog(context); UpdateNoteReqModel reqModel = UpdateNoteReqModel(
UpdateNoteReqModel reqModel = UpdateNoteReqModel( admissionNo: int.parse(patient.admissionNo ?? ""),
admissionNo: int.parse(patient.admissionNo ?? ""), cancelledNote: false,
cancelledNote: false, lineItemNo:
lineItemNo: model.patientProgressNoteList[index].lineItemNo, model.patientProgressNoteList[index].lineItemNo,
createdBy: model.patientProgressNoteList[index].createdBy, createdBy: model.patientProgressNoteList[index].createdBy,
notes: model.patientProgressNoteList[index].notes, notes: model.patientProgressNoteList[index].notes,
verifiedNote: true, verifiedNote: true,
patientTypeID: patient.patientType, patientTypeID: patient.patientType,
patientOutSA: false, patientOutSA: false,
); );
await model.updatePatientProgressNote(reqModel); await model.updatePatientProgressNote(reqModel);
await getProgressNoteList(context, model, isLocalBusy: true); await getProgressNoteList(context, model,
GifLoaderDialogUtils.hideDialog(context); isLocalBusy: true);
}); GifLoaderDialogUtils.hideDialog(context);
}, });
child: Container( },
decoration: BoxDecoration( child: Container(
color: Colors.green[600], decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), color: Colors.green[600],
), borderRadius: BorderRadius.circular(10),
// color:Colors.red[600], ),
// color:Colors.red[600],
child: Row( child: Row(
children: [ children: [
Icon( Icon(
FontAwesomeIcons.check, FontAwesomeIcons.check,
size: 12, size: 12,
color: Colors.white, color: Colors.white,
), ),
SizedBox( SizedBox(
width: 2, width: 2,
), ),
AppText( AppText(
TranslationBase.of(context).noteVerify, TranslationBase.of(context).noteVerify,
fontSize: 10, fontSize: 10,
color: Colors.white, color: Colors.white,
), ),
], ],
),
padding: EdgeInsets.all(6),
), ),
padding: EdgeInsets.all(6),
), ),
), SizedBox(
SizedBox( width: 10,
width: 10, ),
), InkWell(
InkWell( onTap: () async {
onTap: () async { showMyDialog(
showMyDialog( context: context,
context: context, actionName: TranslationBase.of(context).cancel!,
actionName: TranslationBase.of(context).cancel!, confirmFun: () async {
confirmFun: () async { GifLoaderDialogUtils.showMyDialog(
GifLoaderDialogUtils.showMyDialog( context,
context, );
); UpdateNoteReqModel reqModel = UpdateNoteReqModel(
UpdateNoteReqModel reqModel = UpdateNoteReqModel( admissionNo: int.parse(patient.admissionNo ?? ""),
admissionNo: int.parse(patient.admissionNo ?? ""), cancelledNote: true,
cancelledNote: true, lineItemNo:
lineItemNo: model.patientProgressNoteList[index].lineItemNo, model.patientProgressNoteList[index].lineItemNo,
createdBy: model.patientProgressNoteList[index].createdBy, createdBy: model.patientProgressNoteList[index].createdBy,
notes: model.patientProgressNoteList[index].notes, notes: model.patientProgressNoteList[index].notes,
verifiedNote: false, verifiedNote: false,
patientTypeID: patient.patientType, patientTypeID: patient.patientType,
patientOutSA: false, patientOutSA: false,
); );
await model.updatePatientProgressNote(reqModel); await model.updatePatientProgressNote(reqModel);
await getProgressNoteList(context, model, isLocalBusy: true); await getProgressNoteList(context, model,
GifLoaderDialogUtils.hideDialog(context); isLocalBusy: true);
}); GifLoaderDialogUtils.hideDialog(context);
}, });
child: Container( },
decoration: BoxDecoration( child: Container(
color: Colors.red[600], decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10), color: Colors.red[600],
), borderRadius: BorderRadius.circular(10),
// color:Colors.red[600], ),
// color:Colors.red[600],
child: Row( child: Row(
children: [ children: [
Icon( Icon(
FontAwesomeIcons.trash, FontAwesomeIcons.trash,
size: 12, size: 12,
color: Colors.white, color: Colors.white,
), ),
SizedBox( SizedBox(
width: 2, width: 2,
), ),
AppText( AppText(
'Cancel', 'Cancel',
fontSize: 10, fontSize: 10,
color: Colors.white, color: Colors.white,
), ),
], ],
),
padding: EdgeInsets.all(6),
), ),
padding: EdgeInsets.all(6),
), ),
), SizedBox(
SizedBox( width: 10,
width: 10, )
) ],
], ),
SizedBox(
height: 10,
), ),
SizedBox( Row(
height: 10, mainAxisAlignment: MainAxisAlignment.spaceBetween,
), crossAxisAlignment: CrossAxisAlignment.start,
Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, Container(
crossAxisAlignment: CrossAxisAlignment.start, width: MediaQuery.of(context).size.width * 0.60,
children: [ child: Column(
Container( crossAxisAlignment: CrossAxisAlignment.start,
width: MediaQuery.of(context).size.width * 0.60, children: [
child: Column( Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( AppText(
crossAxisAlignment: CrossAxisAlignment.start, TranslationBase.of(context).createdBy,
children: [ fontSize: 10,
AppText(
TranslationBase.of(context).createdBy,
fontSize: 10,
),
Expanded(
child: AppText(
model.patientProgressNoteList[index].doctorName ?? '',
fontWeight: FontWeight.w600,
fontSize: 12,
), ),
), Expanded(
], child: AppText(
model.patientProgressNoteList[index].doctorName ?? '',
fontWeight: FontWeight.w600,
fontSize: 12,
),
),
],
),
],
),
),
Column(
children: [
AppText(
model.patientProgressNoteList[index].createdOn != null
? AppDateUtils.getDayMonthYearDateFormatted(
AppDateUtils.getDateTimeFromServerFormat(
model.patientProgressNoteList[index].createdOn ?? ""),
isArabic: projectViewModel!.isArabic)
: AppDateUtils.getDayMonthYearDateFormatted(DateTime.now(),
isArabic: projectViewModel!.isArabic),
fontWeight: FontWeight.w600,
fontSize: 14,
),
AppText(
model.patientProgressNoteList[index].createdOn != null
? AppDateUtils.getHour(
AppDateUtils.getDateTimeFromServerFormat(
model.patientProgressNoteList[index].createdOn ?? ""))
: AppDateUtils.getHour(DateTime.now()),
fontWeight: FontWeight.w600,
fontSize: 14,
), ),
], ],
crossAxisAlignment: CrossAxisAlignment.end,
)
],
),
SizedBox(
height: 8,
),
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Expanded(
child: AppText(
model.patientProgressNoteList[index].notes,
fontSize: 10,
), ),
), ),
Column( ])
children: [ ],
AppText( ),
model.patientProgressNoteList[index].createdOn != null SizedBox(
? AppDateUtils.getDayMonthYearDateFormatted( height: 20,
AppDateUtils.getDateTimeFromServerFormat( ),
model.patientProgressNoteList[index].createdOn ?? ""), ],
isArabic: projectViewModel!.isArabic) ),
: AppDateUtils.getDayMonthYearDateFormatted(DateTime.now(),
isArabic: projectViewModel!.isArabic),
fontWeight: FontWeight.w600,
fontSize: 14,
),
AppText(
model.patientProgressNoteList[index].createdOn != null
? AppDateUtils.getHour(AppDateUtils.getDateTimeFromServerFormat(
model.patientProgressNoteList[index].createdOn ?? ""))
: AppDateUtils.getHour(DateTime.now()),
fontWeight: FontWeight.w600,
fontSize: 14,
),
],
crossAxisAlignment: CrossAxisAlignment.end,
)
],
),
SizedBox(
height: 8,
),
Row(mainAxisAlignment: MainAxisAlignment.start, children: [
Expanded(
child: AppText(
model.patientProgressNoteList[index].notes,
fontSize: 10,
),
),
])
],
),
SizedBox(
height: 20,
),
],
), ),
), );
); }),
}), ),
), ),
),
], ],
), ),
), ),

@ -84,7 +84,7 @@ postPrescription(
postProcedureReqModel.prescriptionRequestModel = prescriptionList; postProcedureReqModel.prescriptionRequestModel = prescriptionList;
await model!.postPrescription(postProcedureReqModel, patient.patientMRN!); await model!.postPrescription(postProcedureReqModel, patient.patientMRN!);
if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.Error) {
Helpers.showErrorToast(model.error); Helpers.showErrorToast(model.error);
} else if (model.state == ViewState.Idle) { } else if (model.state == ViewState.Idle) {
model.getPrescriptions(patient); model.getPrescriptions(patient);
@ -112,6 +112,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
String? strengthError; String? strengthError;
late int selectedType; late int selectedType;
bool isSubmitted = false;
TextEditingController strengthController = TextEditingController(); TextEditingController strengthController = TextEditingController();
TextEditingController indicationController = TextEditingController(); TextEditingController indicationController = TextEditingController();
@ -211,7 +212,6 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
ProjectViewModel projectViewModel = Provider.of(context);
return BaseView<MedicineViewModel>( return BaseView<MedicineViewModel>(
onModelReady: (model) async { onModelReady: (model) async {
x = model.patientAssessmentList.map((element) { x = model.patientAssessmentList.map((element) {
@ -432,8 +432,11 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
width: 5.0, width: 5.0,
), ),
PrescriptionTextFiled( PrescriptionTextFiled(
isSubmitted: isSubmitted,
width: MediaQuery.of(context).size.width * 0.560, width: MediaQuery.of(context).size.width * 0.560,
element: units, element: model.itemMedicineListUnit.length == 1
? units = model.itemMedicineListUnit[0]
: units,
elementError: unitError ?? "", elementError: unitError ?? "",
keyName: 'description', keyName: 'description',
keyId: 'parameterCode', keyId: 'parameterCode',
@ -451,8 +454,11 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
isSubmitted: isSubmitted,
elementList: model.itemMedicineListRoute, elementList: model.itemMedicineListRoute,
element: route, element: model.itemMedicineListRoute.length == 1
? route = model.itemMedicineListRoute[0]
: route,
elementError: routeError ?? "", elementError: routeError ?? "",
keyId: 'parameterCode', keyId: 'parameterCode',
keyName: 'description', keyName: 'description',
@ -466,9 +472,12 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
isSubmitted: isSubmitted,
hintText: TranslationBase.of(context).frequency ?? "", hintText: TranslationBase.of(context).frequency ?? "",
elementError: frequencyError ?? "", elementError: frequencyError ?? "",
element: frequency, element: model.itemMedicineList.length == 1
? frequency = model.itemMedicineList[0]
: frequency,
elementList: model.itemMedicineList, elementList: model.itemMedicineList,
keyId: 'parameterCode', keyId: 'parameterCode',
keyName: 'description', keyName: 'description',
@ -492,6 +501,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
}), }),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
isSubmitted: isSubmitted,
hintText: TranslationBase.of(context).doseTime ?? "", hintText: TranslationBase.of(context).doseTime ?? "",
elementError: doseTimeError ?? "", elementError: doseTimeError ?? "",
element: doseTime, element: doseTime,
@ -561,6 +571,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
), ),
SizedBox(height: spaceBetweenTextFileds), SizedBox(height: spaceBetweenTextFileds),
PrescriptionTextFiled( PrescriptionTextFiled(
isSubmitted: isSubmitted,
element: duration, element: duration,
elementError: durationError ?? "", elementError: durationError ?? "",
hintText: TranslationBase.of(context).duration ?? "", hintText: TranslationBase.of(context).duration ?? "",
@ -664,7 +675,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
if (_selectedMedication!.isNarcotic == true) { if (_selectedMedication!.isNarcotic == true) {
DrAppToastMsg.showErrorToast(TranslationBase.of(context) DrAppToastMsg.showErrorToast(TranslationBase.of(context)
.narcoticMedicineCanOnlyBePrescribedFromVida); .narcoticMedicineCanOnlyBePrescribedFromVida);
Navigator.pop(context); // Navigator.pop(context);
return; return;
} }
@ -766,35 +777,36 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
} }
} else { } else {
setState(() { setState(() {
isSubmitted = true;
if (duration == null) { if (duration == null) {
durationError = TranslationBase.of(context).fieldRequired; durationError = TranslationBase.of(context).fieldRequired;
} else { } else {
durationError = null; durationError = "";
} }
if (doseTime == null) { if (doseTime == null) {
doseTimeError = TranslationBase.of(context).fieldRequired; doseTimeError = TranslationBase.of(context).fieldRequired;
} else { } else {
doseTimeError = null; doseTimeError = "";
} }
if (route == null) { if (route == null) {
routeError = TranslationBase.of(context).fieldRequired; routeError = TranslationBase.of(context).fieldRequired;
} else { } else {
routeError = null; routeError = "";
} }
if (frequency == null) { if (frequency == null) {
frequencyError = TranslationBase.of(context).fieldRequired; frequencyError = TranslationBase.of(context).fieldRequired;
} else { } else {
frequencyError = null; frequencyError = "";
} }
if (units == null) { if (units == null) {
unitError = TranslationBase.of(context).fieldRequired; unitError = TranslationBase.of(context).fieldRequired;
} else { } else {
unitError = null; unitError = "";
} }
if (strengthController.text == "") { if (strengthController.text == "") {
strengthError = TranslationBase.of(context).fieldRequired; strengthError = TranslationBase.of(context).fieldRequired;
} else { } else {
strengthError = null; strengthError = "";
} }
}); });
} }

@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
class PrescriptionTextFiled extends StatefulWidget { class PrescriptionTextFiled extends StatefulWidget {
dynamic element; dynamic element;
final String elementError; final String elementError;
final bool? isSubmitted;
final List<dynamic> elementList; final List<dynamic> elementList;
final String keyName; final String keyName;
final String keyId; final String keyId;
@ -25,7 +26,8 @@ class PrescriptionTextFiled extends StatefulWidget {
required this.keyName, required this.keyName,
required this.keyId, required this.keyId,
required this.hintText, required this.hintText,
required this.okFunction}) required this.okFunction,
this.isSubmitted})
: super(key: key); : super(key: key);
@override @override
@ -65,7 +67,9 @@ class _PrescriptionTextFiledState extends State<PrescriptionTextFiled> {
? widget.element['${widget.keyName}'] ? widget.element['${widget.keyName}']
: null, : null,
isTextFieldHasSuffix: true, isTextFieldHasSuffix: true,
validationError: widget.elementList.length != 1 ? widget.elementError : null, validationError: widget.element == null && widget.isSubmitted == true && widget.elementList.length != 1
? widget.elementError
: null,
enabled: false, enabled: false,
), ),
), ),

Loading…
Cancel
Save