Null Safety Update

update_flutter_3.16.0_voipcall
Aamir Muhammad 2 years ago
parent 76f8b37d1e
commit ea7744254b

@ -20,7 +20,7 @@ import '../../widgets/shared/errors/error_message.dart';
class NewPrescriptionsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
final routeArgs = ModalRoute.of(context)!.settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
bool isInpatient = routeArgs['isInpatient'];
bool isFromLiveCare = routeArgs['isFromLiveCare'];
@ -32,7 +32,7 @@ class NewPrescriptionsPage extends StatelessWidget {
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: true,
backgroundColor: Colors.grey[100],
backgroundColor: Colors.grey[100]!,
appBar: PatientProfileAppBar(
patient,
isInpatient: isInpatient,

@ -21,7 +21,7 @@ import '../../widgets/shared/errors/error_message.dart';
class OldPrescriptionsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
final routeArgs = ModalRoute.of(context)!.settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
String patientType = routeArgs['patientType'];
String arrivalType = routeArgs['arrivalType'];
@ -37,7 +37,7 @@ class OldPrescriptionsPage extends StatelessWidget {
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
isShowAppBar: true,
backgroundColor: Colors.grey[100],
backgroundColor: Colors.grey[100]!,
appBar: PatientProfileAppBar(
patient,
isInpatient: isInpatient,
@ -89,19 +89,19 @@ class OldPrescriptionsPage extends StatelessWidget {
doctorName:
Utils.convertToTitleCase(model
.prescriptionsList[index]
.doctorName),
.doctorName!),
profileUrl: model
.prescriptionsList[index]
.doctorImageURL,
.doctorImageURL!,
branch: model
.prescriptionsList[index].name,
.prescriptionsList[index].name!,
clinic: model.prescriptionsList[index]
.clinicDescription,
.clinicDescription!,
isPrescriptions: true,
appointmentDate: AppDateUtils
.getDateTimeFromServerFormat(
model.prescriptionsList[index]
.appointmentDate,
.appointmentDate!,
),
),
],
@ -155,7 +155,7 @@ class OldPrescriptionsPage extends StatelessWidget {
label: "",
value: Utils.convertToTitleCase(model
.medicationForInPatient[index]
.pHRItemDescription),
.pHRItemDescription!),
valueSize: SizeConfig
.getTextMultiplierBasedOnWidth() *
3.5,
@ -207,12 +207,12 @@ class OldPrescriptionsPage extends StatelessWidget {
startOn: AppDateUtils
.getDateTimeFromServerFormat(
model.medicationForInPatient[index]
.startDatetime,
.startDatetime!,
),
stopOn: AppDateUtils
.getDateTimeFromServerFormat(
model.medicationForInPatient[index]
.stopDatetime,
.stopDatetime!,
),
),
),

@ -32,66 +32,57 @@ import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_to_text.dart' as stt;
class PrescriptionCheckOutScreen extends StatefulWidget {
final PrescriptionViewModel model;
final PatiantInformtion patient;
final List<PrescriptionModel> prescriptionList;
final ProcedureTempleteDetailsModel groupProcedures;
final PrescriptionViewModel? model;
final PatiantInformtion? patient;
final List<PrescriptionModel>? prescriptionList;
final ProcedureTempleteDetailsModel? groupProcedures;
const PrescriptionCheckOutScreen(
{Key key,
this.model,
this.patient,
this.prescriptionList,
this.groupProcedures})
: super(key: key);
const PrescriptionCheckOutScreen({Key? key, this.model, this.patient, this.prescriptionList, this.groupProcedures}) : super(key: key);
@override
_PrescriptionCheckOutScreenState createState() =>
_PrescriptionCheckOutScreenState();
_PrescriptionCheckOutScreenState createState() => _PrescriptionCheckOutScreenState();
}
class _PrescriptionCheckOutScreenState
extends State<PrescriptionCheckOutScreen> {
class _PrescriptionCheckOutScreenState extends State<PrescriptionCheckOutScreen> {
postPrescription(
{String duration,
String doseTimeIn,
String dose,
String drugId,
String strength,
String route,
String frequency,
String indication,
String instruction,
PrescriptionViewModel model,
DateTime doseTime,
String doseUnit,
String icdCode,
PatiantInformtion patient,
String patientType}) async {
PostPrescriptionReqModel postProcedureReqModel =
new PostPrescriptionReqModel();
{String? duration,
String? doseTimeIn,
String? dose,
String? drugId,
String? strength,
String? route,
String? frequency,
String? indication,
String? instruction,
PrescriptionViewModel? model,
DateTime? doseTime,
String? doseUnit,
String? icdCode,
PatiantInformtion? patient,
String? patientType}) async {
PostPrescriptionReqModel postProcedureReqModel = new PostPrescriptionReqModel();
List<PrescriptionRequestModel> prescriptionList = [];
postProcedureReqModel.appointmentNo = patient.appointmentNo;
postProcedureReqModel.appointmentNo = patient!.appointmentNo;
postProcedureReqModel.clinicID = patient.clinicId;
postProcedureReqModel.episodeID = patient.episodeNo;
postProcedureReqModel.patientMRN = patient.patientMRN;
prescriptionList.add(PrescriptionRequestModel(
covered: true,
dose: double.parse(dose),
itemId: drugId.isEmpty ? 1 : int.parse(drugId),
doseUnitId: int.parse(doseUnit),
route: route.isEmpty ? 1 : int.parse(route),
frequency: frequency.isEmpty ? 1 : int.parse(frequency),
dose: double.parse(dose!),
itemId: drugId!.isEmpty ? 1 : int.parse(drugId),
doseUnitId: int.parse(doseUnit!),
route: route!.isEmpty ? 1 : int.parse(route),
frequency: frequency!.isEmpty ? 1 : int.parse(frequency),
remarks: instruction,
approvalRequired: true,
icdcode10Id: icdCode.toString(),
doseTime: doseTimeIn.isEmpty ? 1 : int.parse(doseTimeIn),
duration: duration.isEmpty ? 1 : int.parse(duration),
doseStartDate: doseTime.toIso8601String()));
doseTime: doseTimeIn!.isEmpty ? 1 : int.parse(doseTimeIn),
duration: duration!.isEmpty ? 1 : int.parse(duration),
doseStartDate: doseTime!.toIso8601String()));
postProcedureReqModel.prescriptionRequestModel = prescriptionList;
await model.postPrescription(postProcedureReqModel, patient.patientMRN);
await model!.postPrescription(postProcedureReqModel, patient.patientMRN!);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
@ -101,14 +92,14 @@ class _PrescriptionCheckOutScreenState
}
}
String routeError;
String frequencyError;
String doseTimeError;
String durationError;
String unitError;
String strengthError;
String? routeError;
String? frequencyError;
String? doseTimeError;
String? durationError;
String? unitError;
String? strengthError;
int selectedType;
int? selectedType;
TextEditingController strengthController = TextEditingController();
TextEditingController indicationController = TextEditingController();
@ -118,11 +109,10 @@ class _PrescriptionCheckOutScreenState
bool visibilitySearch = true;
final myController = TextEditingController();
DateTime selectedDate;
int strengthChar;
GetMedicationResponseModel _selectedMedication;
GlobalKey key =
new GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
DateTime? selectedDate;
int? strengthChar;
GetMedicationResponseModel _selectedMedication = GetMedicationResponseModel();
GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>> key = GlobalKey<AutoCompleteTextFieldState<GetMedicationResponseModel>>();
TextEditingController drugIdController = TextEditingController();
TextEditingController doseController = TextEditingController();
@ -160,8 +150,7 @@ class _PrescriptionCheckOutScreenState
onVoiceText() async {
new SpeechToText(context: context).showAlertDialog(context);
var lang = TranslationBase.of(AppGlobal.CONTEX).locale.languageCode;
bool available = await speech.initialize(
onStatus: statusListener, onError: errorListener);
bool available = await speech.initialize(onStatus: statusListener, onError: errorListener);
if (available) {
speech.listen(
onResult: resultListener,
@ -204,8 +193,7 @@ class _PrescriptionCheckOutScreenState
}
Future<void> initSpeechState() async {
bool hasSpeech = await speech.initialize(
onError: errorListener, onStatus: statusListener);
bool hasSpeech = await speech.initialize(onError: errorListener, onStatus: statusListener);
print(hasSpeech);
if (!mounted) return;
}
@ -222,19 +210,13 @@ class _PrescriptionCheckOutScreenState
return BaseView<MedicineViewModel>(
onModelReady: (model) async {
// TODO Elham* move this logic to the model
model.getItem(
itemID: int.parse(
widget.groupProcedures.aliasN.replaceAll("item code ;", "")));
model.getItem(itemID: int.parse(widget.groupProcedures!.aliasN!.replaceAll("item code ;", "")));
x = model.patientAssessmentList.map((element) {
return element.icdCode10ID;
});
GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel(
patientMRN: widget.patient.patientMRN,
episodeID: widget.patient.episodeNo.toString(),
editedBy: '',
doctorID: '',
appointmentNo: widget.patient.appointmentNo);
GetAssessmentReqModel getAssessmentReqModel =
GetAssessmentReqModel(patientMRN: widget.patient!.patientMRN, episodeID: widget.patient!.episodeNo.toString(), editedBy: '', doctorID: '', appointmentNo: widget.patient!.appointmentNo);
if (model.medicationStrengthList.length == 0) {
await model.getMedicationStrength();
}
@ -249,7 +231,7 @@ class _PrescriptionCheckOutScreenState
builder: (
BuildContext context,
MedicineViewModel model,
Widget child,
Widget? child,
) =>
AppScaffold(
backgroundColor: Color(0xffF8F8F8).withOpacity(0.9),
@ -265,8 +247,7 @@ class _PrescriptionCheckOutScreenState
height: MediaQuery.of(context).size.height * 1.35,
color: Color(0xffF8F8F8),
child: Padding(
padding:
EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0),
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 10.0),
child: Column(
children: [
Column(
@ -290,8 +271,7 @@ class _PrescriptionCheckOutScreenState
width: 7.0,
),
AppText(
TranslationBase.of(context)
.newPrescriptionOrder,
TranslationBase.of(context).newPrescriptionOrder,
fontWeight: FontWeight.w700,
fontSize: 20,
),
@ -325,16 +305,14 @@ class _PrescriptionCheckOutScreenState
child: Column(
children: [
AppText(
widget.groupProcedures.procedureName ??
"",
widget.groupProcedures!.procedureName ?? "",
bold: true,
),
Container(
child: Row(
children: [
AppText(
TranslationBase.of(context)
.orderType,
TranslationBase.of(context).orderType,
fontWeight: FontWeight.w600,
),
Radio(
@ -342,11 +320,10 @@ class _PrescriptionCheckOutScreenState
value: 1,
groupValue: selectedType,
onChanged: (value) {
setSelectedType(value);
setSelectedType(value!);
},
),
Text(TranslationBase.of(context)
.regular),
Text(TranslationBase.of(context).regular),
],
),
),
@ -356,13 +333,10 @@ class _PrescriptionCheckOutScreenState
child: Row(
children: [
Container(
width: MediaQuery.of(context)
.size
.width *
0.35,
width: MediaQuery.of(context).size.width * 0.35,
child: AppTextFieldCustom(
height: 40,
validationError: strengthError,
validationError: strengthError!,
hintText: TranslationBase.of(context).strength,
isTextFieldHasSuffix: false,
enabled: true,
@ -371,17 +345,13 @@ class _PrescriptionCheckOutScreenState
setState(() {
strengthChar = value.length;
});
if (strengthChar >= 5) {
DrAppToastMsg
.showErrorToast(
TranslationBase.of(
context)
.only5DigitsAllowedForStrength,
if (strengthChar! >= 5) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context).only5DigitsAllowedForStrength,
);
}
},
inputType: TextInputType
.numberWithOptions(
inputType: TextInputType.numberWithOptions(
decimal: true,
),
),
@ -390,17 +360,13 @@ class _PrescriptionCheckOutScreenState
width: 5.0,
),
PrescriptionTextFiled(
width: MediaQuery.of(context)
.size
.width *
0.560,
width: MediaQuery.of(context).size.width * 0.560,
element: units,
elementError: unitError,
elementError: unitError!,
keyName: 'description',
keyId: 'parameterCode',
hintText: 'Select',
elementList:
model.itemMedicineListUnit,
elementList: model.itemMedicineListUnit,
okFunction: (selectedValue) {
setState(() {
units = selectedValue;
@ -413,10 +379,9 @@ class _PrescriptionCheckOutScreenState
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
elementList:
model.itemMedicineListRoute,
elementList: model.itemMedicineListRoute,
element: route,
elementError: routeError,
elementError: routeError!,
keyId: 'parameterCode',
keyName: 'description',
okFunction: (selectedValue) {
@ -425,14 +390,12 @@ class _PrescriptionCheckOutScreenState
route['isDefault'] = true;
});
},
hintText:
TranslationBase.of(context).route,
hintText: TranslationBase.of(context).route,
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
hintText: TranslationBase.of(context)
.frequency,
elementError: frequencyError,
hintText: TranslationBase.of(context).frequency,
elementError: frequencyError!,
element: frequency,
elementList: model.itemMedicineList,
keyId: 'parameterCode',
@ -441,21 +404,9 @@ class _PrescriptionCheckOutScreenState
setState(() {
frequency = selectedValue;
frequency['isDefault'] = true;
if (_selectedMedication != null &&
duration != null &&
frequency != null &&
strengthController.text !=
null) {
if (_selectedMedication != null && duration != null && frequency != null && strengthController.text != null) {
model.getBoxQuantity(
freq: frequency[
'parameterCode'],
duration: duration['id'],
itemCode:
_selectedMedication
.itemId,
strength: double.parse(
strengthController
.text));
freq: frequency['parameterCode'], duration: duration['id'], itemCode: _selectedMedication.itemId, strength: double.parse(strengthController.text));
return;
}
@ -463,12 +414,10 @@ class _PrescriptionCheckOutScreenState
}),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
hintText: TranslationBase.of(context)
.doseTime,
elementError: doseTimeError,
hintText: TranslationBase.of(context).doseTime,
elementError: doseTimeError!,
element: doseTime,
elementList:
model.medicationDoseTimeList,
elementList: model.medicationDoseTimeList,
keyId: 'id',
keyName: 'nameEn',
okFunction: (selectedValue) {
@ -477,8 +426,7 @@ class _PrescriptionCheckOutScreenState
});
}),
SizedBox(height: spaceBetweenTextFields),
if (model
.patientAssessmentList.isNotEmpty)
if (model.patientAssessmentList.isNotEmpty)
Container(
height: screenSize.height * 0.070,
width: double.infinity,
@ -486,47 +434,19 @@ class _PrescriptionCheckOutScreenState
child: Row(
children: [
Container(
width: MediaQuery.of(context)
.size
.width *
0.29,
width: MediaQuery.of(context).size.width * 0.29,
child: TextField(
decoration:
textFieldSelectorDecoration(
model
.patientAssessmentList[
0]
.icdCode10ID
.toString(),
indication != null
? indication[
'name']
: null,
false),
decoration: textFieldSelectorDecoration(model.patientAssessmentList[0].icdCode10ID.toString(), indication != null ? indication['name'] : null, false),
enabled: true,
readOnly: true,
),
),
Container(
width: MediaQuery.of(context)
.size
.width *
0.65,
width: MediaQuery.of(context).size.width * 0.65,
color: Colors.white,
child: TextField(
maxLines: 5,
decoration:
textFieldSelectorDecoration(
model
.patientAssessmentList[
0]
.asciiDesc
.toString(),
indication != null
? indication[
'name']
: null,
false),
decoration: textFieldSelectorDecoration(model.patientAssessmentList[0].asciiDesc.toString(), indication != null ? indication['name'] : null, false),
enabled: true,
readOnly: true,
),
@ -539,16 +459,10 @@ class _PrescriptionCheckOutScreenState
height: screenSize.height * 0.070,
color: Colors.white,
child: InkWell(
onTap: () =>
selectDate(context, widget.model),
onTap: () => selectDate(context, widget.model!),
child: TextField(
decoration: textFieldSelectorDecoration(
TranslationBase.of(context)
.date,
selectedDate != null
? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
: null,
true,
TranslationBase.of(context).date, selectedDate != null ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}" : "", true,
suffixIcon: Icon(
Icons.calendar_today,
color: Colors.black,
@ -560,29 +474,20 @@ class _PrescriptionCheckOutScreenState
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
element: duration,
elementError: durationError,
hintText: TranslationBase.of(context)
.duration,
elementList:
model.medicationDurationList,
elementError: durationError!,
hintText: TranslationBase.of(context).duration,
elementList: model.medicationDurationList,
keyName: 'nameEn',
keyId: 'id',
okFunction: (selectedValue) {
setState(() {
duration = selectedValue;
if (_selectedMedication != null &&
duration != null &&
frequency != null &&
strengthController.text !=
null) {
if (_selectedMedication != null && duration != null && frequency != null && strengthController.text != null) {
model.getBoxQuantity(
freq:
frequency['parameterCode'],
freq: frequency['parameterCode'],
duration: duration['id'],
itemCode:
_selectedMedication.itemId,
strength: double.parse(
strengthController.text),
itemCode: _selectedMedication.itemId,
strength: double.parse(strengthController.text),
);
box = model.boxQuintity;
@ -595,20 +500,13 @@ class _PrescriptionCheckOutScreenState
SizedBox(height: spaceBetweenTextFields),
SizedBox(height: spaceBetweenTextFields),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(6.0)),
border: Border.all(
width: 1.0,
color: HexColor("#CCCCCC"))),
decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(6.0)), border: Border.all(width: 1.0, color: HexColor("#CCCCCC"))),
child: Stack(
children: [
TextFields(
maxLines: 6,
minLines: 4,
hintText:
TranslationBase.of(context)
.instruction,
hintText: TranslationBase.of(context).instruction,
controller: instructionController,
//keyboardType: TextInputType.number,
),
@ -622,9 +520,7 @@ class _PrescriptionCheckOutScreenState
size: 35,
),
onPressed: () {
initSpeechState().then(
(value) =>
{onVoiceText()});
initSpeechState().then((value) => {onVoiceText()});
},
),
),
@ -633,15 +529,13 @@ class _PrescriptionCheckOutScreenState
),
SizedBox(height: spaceBetweenTextFields),
Container(
margin: EdgeInsets.all(
SizeConfig.widthMultiplier! * 5),
margin: EdgeInsets.all(SizeConfig.widthMultiplier! * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
color: AppGlobal.appGreenColor,
title: TranslationBase.of(context)
.addMedication,
title: TranslationBase.of(context).addMedication,
fontWeight: FontWeight.w600,
onPressed: () async {
if (route != null &&
@ -650,101 +544,41 @@ class _PrescriptionCheckOutScreenState
frequency != null &&
units != null &&
selectedDate != null &&
strengthController.text !=
"") {
if (double.parse(
strengthController
.text) >
1000.0) {
strengthController.text != "") {
if (double.parse(strengthController.text) > 1000.0) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context).thousandIsTheMAXForTheStrength,);
TranslationBase.of(context).thousandIsTheMAXForTheStrength,
);
return;
}
if (double.parse(
strengthController
.text) <
0.0) {
if (double.parse(strengthController.text) < 0.0) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context).strengthCanNotBeZero,);
TranslationBase.of(context).strengthCanNotBeZero,
);
return;
}
if (formKey.currentState
.validate()) {
if (formKey.currentState!.validate()) {
Navigator.pop(context);
{
postPrescription(
icdCode: model
.patientAssessmentList
.isNotEmpty
? model
.patientAssessmentList[
0]
.icdCode10ID
.isEmpty
icdCode: model.patientAssessmentList.isNotEmpty
? model.patientAssessmentList[0].icdCode10ID!.isEmpty
? "test"
: model
.patientAssessmentList[
0]
.icdCode10ID
.toString()
: model.patientAssessmentList[0].icdCode10ID.toString()
: "test",
dose: strengthController
.text,
doseUnit: model
.itemMedicineListUnit
.length ==
1
? model
.itemMedicineListUnit[
0][
'parameterCode']
.toString()
: units['parameterCode']
.toString(),
dose: strengthController.text,
doseUnit:
model.itemMedicineListUnit.length == 1 ? model.itemMedicineListUnit[0]['parameterCode'].toString() : units['parameterCode'].toString(),
patient: widget.patient,
doseTimeIn:
doseTime['id']
.toString(),
doseTimeIn: doseTime['id'].toString(),
model: widget.model,
duration: duration['id']
.toString(),
frequency: model
.itemMedicineList
.length ==
1
? model
.itemMedicineList[
0][
'parameterCode']
.toString()
: frequency[
'parameterCode']
.toString(),
route: model.itemMedicineListRoute
.length ==
1
? model
.itemMedicineListRoute[
0][
'parameterCode']
.toString()
: route['parameterCode']
.toString(),
drugId: (widget
.groupProcedures
.aliasN
.replaceAll(
"item code ;",
"")),
strength:
strengthController
.text,
indication:
indicationController
.text,
instruction:
instructionController
.text,
duration: duration['id'].toString(),
frequency: model.itemMedicineList.length == 1 ? model.itemMedicineList[0]['parameterCode'].toString() : frequency['parameterCode'].toString(),
route: model.itemMedicineListRoute.length == 1 ? model.itemMedicineListRoute[0]['parameterCode'].toString() : route['parameterCode'].toString(),
drugId: (widget.groupProcedures!.aliasN!.replaceAll("item code ;", "")),
strength: strengthController.text,
indication: indicationController.text,
instruction: instructionController.text,
doseTime: selectedDate,
);
}
@ -752,59 +586,39 @@ class _PrescriptionCheckOutScreenState
} else {
setState(() {
if (duration == null) {
durationError =
TranslationBase.of(
context)
.fieldRequired;
durationError = TranslationBase.of(context).fieldRequired;
} else {
durationError = null;
}
if (doseTime == null) {
doseTimeError =
TranslationBase.of(
context)
.fieldRequired;
doseTimeError = TranslationBase.of(context).fieldRequired;
} else {
doseTimeError = null;
}
if (route == null) {
routeError =
TranslationBase.of(
context)
.fieldRequired;
routeError = TranslationBase.of(context).fieldRequired;
} else {
routeError = null;
}
if (frequency == null) {
frequencyError =
TranslationBase.of(
context)
.fieldRequired;
frequencyError = TranslationBase.of(context).fieldRequired;
} else {
frequencyError = null;
}
if (units == null) {
unitError =
TranslationBase.of(
context)
.fieldRequired;
unitError = TranslationBase.of(context).fieldRequired;
} else {
unitError = null;
}
if (strengthController
.text ==
"") {
strengthError =
TranslationBase.of(
context)
.fieldRequired;
if (strengthController.text == "") {
strengthError = TranslationBase.of(context).fieldRequired;
} else {
strengthError = null;
}
});
}
formKey.currentState.save();
formKey.currentState!.save();
},
),
],
@ -833,7 +647,7 @@ class _PrescriptionCheckOutScreenState
Utils.hideKeyboard(context);
DateTime selectedDate;
selectedDate = DateTime.now();
final DateTime picked = await showDatePicker(
final DateTime? picked = await showDatePicker(
context: context,
initialDate: selectedDate,
firstDate: DateTime.now(),
@ -849,9 +663,7 @@ class _PrescriptionCheckOutScreenState
/// TODO Elham* Use it from the textfeild utils
InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) {
InputDecoration textFieldSelectorDecoration(String hintText, String selectedText, bool isDropDown, {Icon? suffixIcon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),

@ -7,25 +7,15 @@ import 'package:flutter/material.dart';
class PrescriptionTextFiled extends StatefulWidget {
dynamic element;
final String elementError;
final List<dynamic> elementList;
final String keyName;
final String keyId;
final String hintText;
final double width;
final Function(dynamic) okFunction;
final String? elementError;
final List<dynamic>? elementList;
final String? keyName;
final String? keyId;
final String? hintText;
final double? width;
final Function(dynamic)? okFunction;
PrescriptionTextFiled(
{Key key,
@required this.element,
@required this.elementError,
this.width,
this.elementList,
this.keyName,
this.keyId,
this.hintText,
this.okFunction})
: super(key: key);
PrescriptionTextFiled({Key? key, required this.element, required this.elementError, this.width, this.elementList, this.keyName, this.keyId, this.hintText, this.okFunction}) : super(key: key);
@override
_PrescriptionTextFiledState createState() => _PrescriptionTextFiledState();
@ -41,14 +31,11 @@ class _PrescriptionTextFiledState extends State<PrescriptionTextFiled> {
? () {
Utils.hideKeyboard(context);
ListSelectDialog dialog = ListSelectDialog(
list: widget.elementList,
list: widget.elementList!,
attributeName: '${widget.keyName}',
attributeValueId: widget.elementList.length == 1
? widget.elementList[0]['${widget.keyId}'].toString()
: '${widget.keyId}',
attributeValueId: widget.elementList!.length == 1 ? widget.elementList![0]['${widget.keyId}'].toString() : '${widget.keyId}',
okText: TranslationBase.of(context).ok,
okFunction: (selectedValue) =>
widget.okFunction(selectedValue),
okFunction: (selectedValue) => widget.okFunction!(selectedValue),
);
showDialog(
barrierDismissible: false,
@ -60,15 +47,14 @@ class _PrescriptionTextFiledState extends State<PrescriptionTextFiled> {
}
: null,
child: AppTextFieldCustom(
hintText: widget.hintText,
dropDownText: widget.elementList.length == 1
? widget.elementList[0]['${widget.keyName}']
hintText: widget.hintText!,
dropDownText: widget.elementList!.length == 1
? widget.elementList![0]['${widget.keyName}']
: widget.element != null
? widget.element['${widget.keyName}']
: null,
isTextFieldHasSuffix: true,
validationError:
widget.elementList.length != 1 ? widget.elementError : null,
validationError: widget.elementList!.length != 1 ? widget.elementError! : "",
enabled: false,
),
),

@ -14,16 +14,16 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
class PrescriptionItemsInPatientPage extends StatelessWidget {
final GetMedicationForInPatientModel prescriptions;
final PatiantInformtion patient;
final String patientType;
final String arrivalType;
final DateTime startOn;
final DateTime stopOn;
final int prescriptionIndex;
final GetMedicationForInPatientModel? prescriptions;
final PatiantInformtion? patient;
final String?patientType;
final String? arrivalType;
final DateTime? startOn;
final DateTime? stopOn;
final int? prescriptionIndex;
PrescriptionItemsInPatientPage(
{Key key,
{Key? key,
this.prescriptions,
this.patient,
this.patientType,
@ -38,14 +38,14 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
return BaseView<PrescriptionViewModel>(
onModelReady: (model) async {
if (model.medicationForInPatient.length == 0) {
await model.getMedicationForInPatient(patient);
await model.getMedicationForInPatient(patient!);
}
},
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
backgroundColor: Colors.grey[100],
backgroundColor: Colors.grey[100]!,
baseViewModel: model,
appBar: PatientProfileAppBar(patient),
appBar: PatientProfileAppBar(patient!),
body: SingleChildScrollView(
child: Container(
child: Column(
@ -64,7 +64,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
Container(
margin: EdgeInsets.only(left: 18, right: 18),
child: AppText(
prescriptions.pHRItemDescription,
prescriptions!.pHRItemDescription ?? "",
bold: true,
),
),
@ -87,7 +87,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
children: [
CustomRow(
label: TranslationBase.of(context).direction + ' :',
value: " " + prescriptions.directionDescription.toString() ?? '',
value: " " + prescriptions!.directionDescription! ?? "",
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -95,7 +95,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).route + ' :',
value: " " + prescriptions.routeDescription ?? '',
value: " " + prescriptions!.routeDescription! ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -103,7 +103,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).refill + ' :',
value: " " + prescriptions.refillDescription ?? '',
value: " " + prescriptions!.refillDescription! ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -111,7 +111,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).startDate + ' :',
value: " " + AppDateUtils.getDayMonthYearDateFormatted(startOn, isArabic: projectViewModel.isArabic) ?? '',
value: " " + AppDateUtils.getDayMonthYearDateFormatted(startOn!, isArabic: projectViewModel.isArabic) ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -119,7 +119,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).stopDate + ' :',
value: " " + AppDateUtils.getDayMonthYearDateFormatted(stopOn, isArabic: projectViewModel.isArabic) ?? '',
value: " " + AppDateUtils.getDayMonthYearDateFormatted(stopOn!, isArabic: projectViewModel.isArabic) ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -127,7 +127,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: 'UOM' + ' :',
value: " " + prescriptions.uomDescription.toString() ?? '',
value: " " + prescriptions!.uomDescription.toString() ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -135,7 +135,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).dailyDoses,
value: " " + prescriptions.dose.toString() ?? '',
value: " " + prescriptions!.dose.toString() ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -143,7 +143,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).status,
value: " " + prescriptions.statusDescription.toString() ?? '',
value: " " + prescriptions!.statusDescription.toString() ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -151,7 +151,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: TranslationBase.of(context).processed,
value: " " + prescriptions.doctorName.toString() ?? '',
value: " " + prescriptions!.doctorName.toString() ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,
@ -162,7 +162,7 @@ class PrescriptionItemsInPatientPage extends StatelessWidget {
),
CustomRow(
label: '',
value: prescriptions.comments ?? '',
value: prescriptions!.comments ?? '',
isCopyable: false,
isExpanded: false,
valueSize: 13,

@ -14,12 +14,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class PrescriptionItemsPage extends StatelessWidget {
final Prescriptions prescriptions;
final PatiantInformtion patient;
final String arrivalType;
final Prescriptions? prescriptions;
final PatiantInformtion? patient;
final String? arrivalType;
PrescriptionItemsPage(
{Key key,
{Key? key,
this.prescriptions,
this.patient,
this.arrivalType});
@ -28,20 +28,20 @@ class PrescriptionItemsPage extends StatelessWidget {
Widget build(BuildContext context) {
return BaseView<PrescriptionViewModel>(
onModelReady: (model) => model.getPrescriptionReport(
prescriptions: prescriptions, patient: patient),
prescriptions: prescriptions, patient: patient!),
builder: (_, model, widget) => AppScaffold(
isShowAppBar: true,
backgroundColor: Colors.grey[100],
backgroundColor: Colors.grey[100]!,
baseViewModel: model,
appBar: PatientProfileAppBar(
patient,
clinic: prescriptions.clinicDescription,
branch: prescriptions.name,
patient!,
clinic: prescriptions!.clinicDescription!,
branch: prescriptions!.name!,
isPrescriptions: true,
appointmentDate: AppDateUtils.getDateTimeFromServerFormat(
prescriptions.appointmentDate),
doctorName: prescriptions.doctorName,
profileUrl: prescriptions.doctorImageURL,
prescriptions!.appointmentDate!),
doctorName: prescriptions!.doctorName!,
profileUrl: prescriptions!.doctorImageURL!,
isAppointmentHeader: true,
),
body: SingleChildScrollView(

@ -16,17 +16,17 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class AddFavouriteProcedure extends StatefulWidget {
final ProcedureViewModel previousProcedureViewModel;
final PrescriptionViewModel prescriptionModel;
final PatiantInformtion patient;
final ProcedureType procedureType;
final ProcedureViewModel? previousProcedureViewModel;
final PrescriptionViewModel? prescriptionModel;
final PatiantInformtion? patient;
final ProcedureType? procedureType;
AddFavouriteProcedure({
Key key,
Key? key,
this.previousProcedureViewModel,
this.prescriptionModel,
this.patient,
@required this.procedureType,
required this.procedureType,
});
@override
@ -36,54 +36,51 @@ class AddFavouriteProcedure extends StatefulWidget {
class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
_AddFavouriteProcedureState({this.patient, this.model});
ProcedureViewModel model;
PatiantInformtion patient;
ProcedureViewModel? model;
PatiantInformtion? patient;
List<ProcedureTempleteDetailsModel> entityList = [];
ProcedureTempleteDetailsModel groupProcedures;
ProcedureTempleteDetailsModel groupProcedures = ProcedureTempleteDetailsModel();
@override
Widget build(BuildContext context) {
return BaseView<ProcedureViewModel>(
builder: (BuildContext context, ProcedureViewModel procedureViewModel,
Widget child) =>
AppScaffold(
isShowAppBar: false,
body: Column(children: [
(widget.previousProcedureViewModel.templateList.length != 0)
? Expanded(
child: EntityListCheckboxSearchFavProceduresWidget(
isProcedure: !(widget.procedureType ==
ProcedureType.PRESCRIPTION),
model: widget.previousProcedureViewModel,
removeFavProcedure: (item) {
setState(() {
entityList.remove(item);
});
},
addFavProcedure: (history) {
setState(() {
entityList.add(history);
});
},
isEntityFavListSelected: (master) =>
procedureViewModel.isProcedureEntityListSelected(
master, entityList),
groupProcedures: groupProcedures,
selectProcedures: (selectedProcedure) {
setState(() {
groupProcedures = selectedProcedure;
});
},
),
)
: ErrorMessage(
error: TranslationBase.of(context)
.youDoNotHaveFavoriteTemplate,
),
]),
bottomSheet: widget.previousProcedureViewModel.templateList.length == 0?Container(height: 0,):CustomBottomSheetContainer(
label: widget.procedureType.getAddButtonTitle(context) ??
TranslationBase.of(context).addSelectedProcedures,
builder: (BuildContext context, ProcedureViewModel procedureViewModel, Widget? child) => AppScaffold(
isShowAppBar: false,
body: Column(children: [
(widget.previousProcedureViewModel.templateList.length != 0)
? Expanded(
child: EntityListCheckboxSearchFavProceduresWidget(
isProcedure: !(widget.procedureType == ProcedureType.PRESCRIPTION),
model: widget.previousProcedureViewModel,
removeFavProcedure: (item) {
setState(() {
entityList.remove(item);
});
},
addFavProcedure: (history) {
setState(() {
entityList.add(history);
});
},
isEntityFavListSelected: (master) => procedureViewModel.isProcedureEntityListSelected(master, entityList),
groupProcedures: groupProcedures,
selectProcedures: (selectedProcedure) {
setState(() {
groupProcedures = selectedProcedure;
});
},
),
)
: ErrorMessage(
error: TranslationBase.of(context).youDoNotHaveFavoriteTemplate,
),
]),
bottomSheet: widget.previousProcedureViewModel.templateList.length == 0
? Container(
height: 0,
)
: CustomBottomSheetContainer(
label: widget.procedureType.getAddButtonTitle(context) ?? TranslationBase.of(context).addSelectedProcedures,
onTap: () async {
if (widget.procedureType == ProcedureType.PRESCRIPTION) {
if (groupProcedures == null) {
@ -101,14 +98,12 @@ class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
model: widget.prescriptionModel,
groupProcedures: groupProcedures,
),
settings: RouteSettings(
name: 'PrescriptionCheckOutScreen')),
settings: RouteSettings(name: 'PrescriptionCheckOutScreen')),
);
} else {
if (entityList.isEmpty == true) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.fillTheMandatoryProcedureDetails,
TranslationBase.of(context).fillTheMandatoryProcedureDetails,
);
return;
}
@ -117,16 +112,12 @@ class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
MaterialPageRoute(
builder: (context) => ProcedureCheckOutScreen(
items: entityList,
previousProcedureViewModel:
widget.previousProcedureViewModel,
previousProcedureViewModel: widget.previousProcedureViewModel,
patient: widget.patient,
addButtonTitle: widget.procedureType
.getAddButtonTitle(context),
toolbarTitle: widget.procedureType
.getToolbarLabel(context),
addButtonTitle: widget.procedureType.getAddButtonTitle(context),
toolbarTitle: widget.procedureType.getToolbarLabel(context),
),
settings:
RouteSettings(name: 'ProcedureCheckOutScreen')),
settings: RouteSettings(name: 'ProcedureCheckOutScreen')),
);
}
})),

Loading…
Cancel
Save