Fix add medication button

merge-requests/967/head
RoaaGhali98 4 years ago
parent 5b8211eec4
commit d5e3a79f85

@ -8,7 +8,6 @@ import '../../../core/model/patient/patiant_info_model.dart';
import '../../../core/model/search_drug/get_medication_response_model.dart';
import '../../../core/viewModel/prescription_view_model.dart';
import '../../../widgets/shared/buttons/app_buttons_widget.dart';
import 'add_prescription_form.dart';
import 'drugtodrug.dart';
class AddDrugWidget extends StatefulWidget {
@ -16,37 +15,30 @@ class AddDrugWidget extends StatefulWidget {
final List<PrescriptionModel> prescriptionList;
final MedicineViewModel medicineModel;
final PrescriptionViewModel modelPrescription;
final dynamic units;
final dynamic route;
final dynamic frequency;
final dynamic duration;
final dynamic doseTime;
final dynamic uom;
final dynamic x;
final GetMedicationResponseModel selectedMedication;
final String strength;
final String indication;
final String instruction;
final DateTime selectedDate;
const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel, this.modelPrescription}) : super(key: key);
const AddDrugWidget({Key key, this.patient, this.prescriptionList, this.medicineModel,
this.modelPrescription, this.units, this.route, this.frequency, this.duration, this.doseTime,
this.uom, this.x, this.selectedMedication, this.strength, this.indication, this.instruction, this.selectedDate}) : super(key: key);
@override
_AddDrugWidgetState createState() => _AddDrugWidgetState();
}
class _AddDrugWidgetState extends State<AddDrugWidget> {
TextEditingController strengthController = TextEditingController();
dynamic route;
dynamic frequency;
dynamic duration;
dynamic doseTime;
dynamic indication;
dynamic units;
dynamic uom;
dynamic box;
dynamic x;
@override
Widget build(BuildContext context) {
GetMedicationResponseModel _selectedMedication;
TextEditingController indicationController = TextEditingController();
TextEditingController instructionController = TextEditingController();
DateTime selectedDate;
return Container(
height: SizeConfig.realScreenHeight * .8,
width: SizeConfig.realScreenWidth,
@ -66,7 +58,6 @@ class _AddDrugWidgetState extends State<AddDrugWidget> {
title: TranslationBase.of(context).addMedication,
onPressed: () {
Navigator.pop(context);
widget.medicineModel.postPrescription(
icdCode: widget.medicineModel.patientAssessmentList.isNotEmpty
? widget.medicineModel.patientAssessmentList[0].icdCode10ID
@ -75,28 +66,28 @@ class _AddDrugWidgetState extends State<AddDrugWidget> {
: widget.medicineModel.patientAssessmentList[0].icdCode10ID
.toString()
: "test",
dose: strengthController.text,
dose: widget.strength,
doseUnit: widget.medicineModel.itemMedicineListUnit.length == 1
? widget.medicineModel.itemMedicineListUnit[0]['parameterCode']
.toString()
: units['parameterCode'].toString(),
: widget.units['parameterCode'].toString(),
patient: widget.patient,
doseTimeIn: doseTime['id'].toString(),
doseTimeIn: widget.doseTime['id'].toString(),
model: widget.modelPrescription,
duration: duration['id'].toString(),
duration: widget.duration['id'].toString(),
frequency: widget.medicineModel.itemMedicineList.length == 1
? widget.medicineModel.itemMedicineList[0]['parameterCode']
.toString()
: frequency['parameterCode'].toString(),
: widget.frequency['parameterCode'].toString(),
route: widget.medicineModel.itemMedicineListRoute.length == 1
? widget.medicineModel.itemMedicineListRoute[0]['parameterCode']
.toString()
: route['parameterCode'].toString(),
drugId: _selectedMedication.itemId.toString(),
strength: strengthController.text,
indication: indicationController.text,
instruction: instructionController.text,
doseTime: selectedDate,
: widget.route['parameterCode'].toString(),
drugId: widget.selectedMedication.itemId.toString(),
strength: widget.strength,
indication: widget.indication,
instruction: widget.instruction,
doseTime: widget.selectedDate,
);
},
))

@ -113,52 +113,49 @@ class _AddPrescriptionFormState extends State<AddPrescriptionForm> {
height: spaceBetweenTextFields,
),
Container(
child: Form(
key: formKey,
child: Column(
children: [
Visibility(
visible: visibilitySearch,
child: SearchPrescriptionWidget(
spaceBetweenTextFields:
spaceBetweenTextFields,
medicineViewModel: model,
prescriptionViewModel:
widget.prescriptionViewModel,
onItemSelected:
(GetMedicationResponseModel
medication) async {
setState(() {
visibilitySearch = !visibilitySearch;
_selectedMedication = medication;
});
GifLoaderDialogUtils.showMyDialog(context);
await model.getAssessmentList(patientInfo: widget.patient, isLocalBusy: true);
GifLoaderDialogUtils.hideDialog(context);
},
child: Column(
children: [
Visibility(
visible: visibilitySearch,
child: SearchPrescriptionWidget(
spaceBetweenTextFields:
spaceBetweenTextFields,
medicineViewModel: model,
prescriptionViewModel:
widget.prescriptionViewModel,
onItemSelected:
(GetMedicationResponseModel
medication) async {
setState(() {
visibilitySearch = !visibilitySearch;
_selectedMedication = medication;
});
GifLoaderDialogUtils.showMyDialog(context);
await model.getAssessmentList(patientInfo: widget.patient, isLocalBusy: true);
GifLoaderDialogUtils.hideDialog(context);
},
),
),
Visibility(
visible: !visibilitySearch,
child: Container(
child: Column(
children: [
PrescriptionFormWidget(
patient: widget.patient,
prescriptionViewModel:
widget.prescriptionViewModel,
medicineViewModel: model,
prescriptionList:
widget.prescriptionList,
selectedMedication: _selectedMedication,
),
],
),
),
Visibility(
visible: !visibilitySearch,
child: Container(
child: Column(
children: [
PrescriptionFormWidget(
patient: widget.patient,
prescriptionViewModel:
widget.prescriptionViewModel,
medicineViewModel: model,
prescriptionList:
widget.prescriptionList,
selectedMedication: _selectedMedication,
),
],
),
),
],
),
),
],
),
),
],

@ -86,7 +86,6 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
dynamic frequency;
dynamic duration;
dynamic doseTime;
dynamic indication;
dynamic units;
dynamic uom;
dynamic box;
@ -155,366 +154,368 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
@override
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
return Column(
children: [
AppText(
widget.selectedMedication?.description ?? "",
fontWeight: FontWeight.w600,
),
SizedBox(
height: 15.0,
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 6,
),
AppText(
TranslationBase.of(context).orderType,
fontWeight: FontWeight.w500,
),
SizedBox(
width: 18,
),
Radio(
activeColor: AppGlobal.appRedColor,
value: 1,
groupValue: selectedType,
onChanged: (value) {
setSelectedType(value);
},
),
Text(TranslationBase.of(context).regular),
],
return Form(
key: formKey,
child: Column(
children: [
AppText(
widget.selectedMedication?.description ?? "",
fontWeight: FontWeight.w600,
),
SizedBox(
height: 15.0,
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 6,
),
AppText(
TranslationBase.of(context).orderType,
fontWeight: FontWeight.w500,
),
SizedBox(
width: 18,
),
Radio(
activeColor: AppGlobal.appRedColor,
value: 1,
groupValue: selectedType,
onChanged: (value) {
setSelectedType(value);
},
),
Text(TranslationBase.of(context).regular),
],
),
),
),
Container(
width: double.infinity,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.35,
child: AppTextFieldCustom(
height: 38,
validationError: strengthError,
hintText: 'Strength',
isTextFieldHasSuffix: false,
enabled: true,
controller: strengthController,
onChanged: (String value) {
Container(
width: double.infinity,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.35,
child: AppTextFieldCustom(
height: 38,
validationError: strengthError,
hintText: 'Strength',
isTextFieldHasSuffix: false,
enabled: true,
controller: strengthController,
onChanged: (String value) {
setState(() {
strengthChar = value.length;
});
if (strengthChar >= 5) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.only5DigitsAllowedForStrength,
);
}
},
inputType: TextInputType.numberWithOptions(
decimal: true,
),
),
),
SizedBox(
width: 5.0,
),
// Container(
// width: MediaQuery.of(context)
// .size
// .width *
// 0.35,
// child: AppTextFieldCustom(
// height: 38,
// validationError:
// unitError,
// hintText: 'Unit',
// isTextFieldHasSuffix: false,
// enabled: true,
// controller:
// unitController,
// onChanged: (selectedValue) {
// setState(() {
// units = selectedValue;
// units['isDefault'] = true;
// });
// if (strengthChar >= 5) {
// DrAppToastMsg
// .showErrorToast(
// TranslationBase.of(
// context)
// .only5DigitsAllowedForStrength,
// );
// }
// },
// inputType: TextInputType
// .numberWithOptions(
// decimal: true,
// ),
// ),
// ),
PrescriptionTextFiled(
width: MediaQuery.of(context).size.width * 0.510,
element:
widget.medicineViewModel.itemMedicineListUnit.length == 1
? widget.medicineViewModel.itemMedicineListUnit[0]
: units,
elementError: unitError,
keyName: 'description',
keyId: 'parameterCode',
hintText: 'Unit',
elementList: widget.medicineViewModel.itemMedicineListUnit,
okFunction: (selectedValue) {
setState(() {
strengthChar = value.length;
units = selectedValue;
units['isDefault'] = true;
});
if (strengthChar >= 5) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.only5DigitsAllowedForStrength,
);
}
},
inputType: TextInputType.numberWithOptions(
decimal: true,
),
),
],
),
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
elementList: widget.medicineViewModel.itemMedicineListRoute,
element: widget.medicineViewModel.itemMedicineListRoute.length == 1
? route = widget.medicineViewModel.itemMedicineListRoute[0]
: route,
elementError: routeError,
keyId: 'parameterCode',
keyName: 'description',
okFunction: (selectedValue) {
setState(() {
route = selectedValue;
route['isDefault'] = true;
});
},
hintText: TranslationBase.of(context).route,
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
hintText: TranslationBase.of(context).frequency,
elementError: frequencyError,
// element: frequency,
element: widget.medicineViewModel.itemMedicineListRoute.length == 1
? frequency = widget.medicineViewModel.itemMedicineListRoute[0]
: frequency,
elementList: widget.medicineViewModel.itemMedicineList,
keyId: 'parameterCode',
keyName: 'description',
okFunction: (selectedValue) {
setState(() {
frequency = selectedValue;
frequency['isDefault'] = true;
if (widget.selectedMedication != null &&
duration != null &&
frequency != null &&
strengthController.text != null) {
widget.medicineViewModel.getBoxQuantity(
freq: frequency['parameterCode'],
duration: duration['id'],
itemCode: widget.selectedMedication.itemId,
strength: double.parse(strengthController.text));
return;
}
});
}),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
hintText: TranslationBase.of(context).doseTime,
elementError: doseTimeError,
element: doseTime,
elementList: widget.medicineViewModel.medicationDoseTimeList,
keyId: 'id',
keyName: 'nameEn',
okFunction: (selectedValue) {
setState(() {
doseTime = selectedValue;
});
}),
SizedBox(height: spaceBetweenTextFields),
if (widget.medicineViewModel.patientAssessmentList.isNotEmpty)
Container(
height: screenSize.height * 0.070,
width: double.infinity,
color: Colors.white,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.29,
child: AppTextFieldCustom(
hintText: widget
.medicineViewModel.patientAssessmentList[0].icdCode10ID
.toString(),
// indication != null
// ? indication[
// 'name']
// : null,
enabled: true,
),
),
Container(
width: MediaQuery.of(context).size.width * 0.57,
color: Colors.white,
child: AppTextFieldCustom(
maxLines: 5,
hintText: widget
.medicineViewModel.patientAssessmentList[0].asciiDesc
.toString(),
// indication != null
// ? indication[
// 'name']
// : null,
enabled: true,
),
),
],
),
SizedBox(
width: 5.0,
),
SizedBox(height: spaceBetweenTextFields),
Container(
color: Colors.transparent,
child: InkWell(
onTap: () => selectDate(context, widget.prescriptionViewModel),
child: AppTextFieldCustom(
validationError: strengthError,
hintText: 'Date',
isTextFieldHasSuffix: true,
suffixIcon: IconButton(
icon: Icon(
Icons.calendar_today,
color: Colors.black,
),
),
dropDownText: selectedDate != null
? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
: null,
enabled: false,
controller: strengthController,
),
// Container(
// width: MediaQuery.of(context)
// .size
// .width *
// 0.35,
// child: AppTextFieldCustom(
// height: 38,
// validationError:
// unitError,
// hintText: 'Unit',
// isTextFieldHasSuffix: false,
// enabled: true,
// controller:
// unitController,
// onChanged: (selectedValue) {
// setState(() {
// units = selectedValue;
// units['isDefault'] = true;
// });
// if (strengthChar >= 5) {
// DrAppToastMsg
// .showErrorToast(
// TextField(
// decoration:
// textFieldSelectorDecoration(
// TranslationBase.of(
// context)
// .only5DigitsAllowedForStrength,
// );
// }
// },
// inputType: TextInputType
// .numberWithOptions(
// decimal: true,
// ),
// ),
// context)
// .date,
// selectedDate != null
// ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
// : null,
// true,
// suffixIcon: Icon(
// Icons.calendar_today,
// color: Colors.black,
// )),
// enabled: false,
// ),
PrescriptionTextFiled(
width: MediaQuery.of(context).size.width * 0.510,
element:
widget.medicineViewModel.itemMedicineListUnit.length == 1
? widget.medicineViewModel.itemMedicineListUnit[0]
: units,
elementError: unitError,
keyName: 'description',
keyId: 'parameterCode',
hintText: 'Unit',
elementList: widget.medicineViewModel.itemMedicineListUnit,
okFunction: (selectedValue) {
setState(() {
units = selectedValue;
units['isDefault'] = true;
});
},
),
],
),
),
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
elementList: widget.medicineViewModel.itemMedicineListRoute,
element: widget.medicineViewModel.itemMedicineListRoute.length == 1
? route = widget.medicineViewModel.itemMedicineListRoute[0]
: route,
elementError: routeError,
keyId: 'parameterCode',
keyName: 'description',
okFunction: (selectedValue) {
setState(() {
route = selectedValue;
route['isDefault'] = true;
});
},
hintText: TranslationBase.of(context).route,
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
hintText: TranslationBase.of(context).frequency,
elementError: frequencyError,
// element: frequency,
element: widget.medicineViewModel.itemMedicineListRoute.length == 1
? frequency = widget.medicineViewModel.itemMedicineListRoute[0]
: frequency,
elementList: widget.medicineViewModel.itemMedicineList,
keyId: 'parameterCode',
keyName: 'description',
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
element: duration,
elementError: durationError,
hintText: TranslationBase.of(context).duration,
elementList: widget.medicineViewModel.medicationDurationList,
keyName: 'nameEn',
keyId: 'id',
okFunction: (selectedValue) {
setState(() {
frequency = selectedValue;
frequency['isDefault'] = true;
duration = selectedValue;
if (widget.selectedMedication != null &&
duration != null &&
frequency != null &&
strengthController.text != null) {
widget.medicineViewModel.getBoxQuantity(
freq: frequency['parameterCode'],
duration: duration['id'],
itemCode: widget.selectedMedication.itemId,
strength: double.parse(strengthController.text));
// widget.medicineViewModel.getBoxQuantity(
// freq: frequency['parameterCode'],
// duration: duration['id'],
// itemCode: widget.selectedMedication.itemId,
// strength: double.parse(strengthController.text),
// );
box = widget.medicineViewModel.boxQuintity;
return;
}
});
}),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
hintText: TranslationBase.of(context).doseTime,
elementError: doseTimeError,
element: doseTime,
elementList: widget.medicineViewModel.medicationDoseTimeList,
keyId: 'id',
keyName: 'nameEn',
okFunction: (selectedValue) {
setState(() {
doseTime = selectedValue;
});
}),
SizedBox(height: spaceBetweenTextFields),
if (widget.medicineViewModel.patientAssessmentList.isNotEmpty)
},
),
SizedBox(height: spaceBetweenTextFields),
Container(
height: screenSize.height * 0.070,
width: double.infinity,
color: Colors.white,
child: Row(
children: [
Container(
width: MediaQuery.of(context).size.width * 0.29,
child: AppTextFieldCustom(
hintText: widget
.medicineViewModel.patientAssessmentList[0].icdCode10ID
.toString(),
// indication != null
// ? indication[
// 'name']
// : null,
enabled: true,
),
),
Container(
width: MediaQuery.of(context).size.width * 0.57,
color: Colors.white,
child: AppTextFieldCustom(
maxLines: 5,
hintText: widget
.medicineViewModel.patientAssessmentList[0].asciiDesc
.toString(),
// indication != null
// ? indication[
// 'name']
// : null,
enabled: true,
),
),
],
child: AppTextFieldCustom(
hintText: "UOM",
isTextFieldHasSuffix: false,
dropDownText: uom != null ? uom : null,
enabled: false,
),
),
SizedBox(height: spaceBetweenTextFields),
Container(
color: Colors.transparent,
child: InkWell(
onTap: () => selectDate(context, widget.prescriptionViewModel),
SizedBox(height: spaceBetweenTextFields),
Container(
color: Colors.white,
child: AppTextFieldCustom(
validationError: strengthError,
hintText: 'Date',
isTextFieldHasSuffix: true,
suffixIcon: IconButton(
icon: Icon(
Icons.calendar_today,
color: Colors.black,
),
),
dropDownText: selectedDate != null
? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
hintText: TranslationBase.of(context).boxQuantity,
isTextFieldHasSuffix: false,
dropDownText: box != null
? widget.medicineViewModel.boxQuintity.toString()
: null,
enabled: false,
controller: strengthController,
),
// TextField(
// decoration:
// textFieldSelectorDecoration(
// TranslationBase.of(
// context)
// .date,
// selectedDate != null
// ? "${AppDateUtils.convertStringToDateFormat(selectedDate.toString(), "yyyy-MM-dd")}"
// : null,
// true,
// suffixIcon: Icon(
// Icons.calendar_today,
// color: Colors.black,
// )),
// enabled: false,
// ),
),
),
SizedBox(height: spaceBetweenTextFields),
PrescriptionTextFiled(
element: duration,
elementError: durationError,
hintText: TranslationBase.of(context).duration,
elementList: widget.medicineViewModel.medicationDurationList,
keyName: 'nameEn',
keyId: 'id',
okFunction: (selectedValue) {
setState(() {
duration = selectedValue;
if (widget.selectedMedication != null &&
duration != null &&
frequency != null &&
strengthController.text != null) {
widget.medicineViewModel.getBoxQuantity(
freq: frequency['parameterCode'],
duration: duration['id'],
itemCode: widget.selectedMedication.itemId,
strength: double.parse(strengthController.text),
);
box = widget.medicineViewModel.boxQuintity;
return;
}
});
},
),
SizedBox(height: spaceBetweenTextFields),
Container(
color: Colors.white,
child: AppTextFieldCustom(
hintText: "UOM",
isTextFieldHasSuffix: false,
dropDownText: uom != null ? uom : null,
enabled: false,
),
),
SizedBox(height: spaceBetweenTextFields),
Container(
color: Colors.white,
child: AppTextFieldCustom(
hintText: TranslationBase.of(context).boxQuantity,
isTextFieldHasSuffix: false,
dropDownText: box != null
? widget.medicineViewModel.boxQuintity.toString()
: null,
enabled: false,
),
),
SizedBox(height: spaceBetweenTextFields),
Container(
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,
controller: instructionController,
//keyboardType: TextInputType.number,
),
Positioned(
top: 0,
right: 15,
child: IconButton(
icon: Icon(
DoctorApp.speechtotext,
color: Colors.black,
size: 35,
SizedBox(height: spaceBetweenTextFields),
Container(
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,
controller: instructionController,
//keyboardType: TextInputType.number,
),
Positioned(
top: 0,
right: 15,
child: IconButton(
icon: Icon(
DoctorApp.speechtotext,
color: Colors.black,
size: 35,
),
onPressed: () {
initSpeechState().then((value) => {onVoiceText()});
},
),
onPressed: () {
initSpeechState().then((value) => {onVoiceText()});
},
),
),
],
],
),
),
),
SizedBox(height: spaceBetweenTextFields),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
color: Color(0xff359846),
title: TranslationBase.of(context).addMedication,
fontWeight: FontWeight.w600,
onPressed: () async {
addMedicationButton(widget.medicineViewModel);
},
),
],
SizedBox(height: spaceBetweenTextFields),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
color: Color(0xff359846),
title: TranslationBase.of(context).addMedication,
fontWeight: FontWeight.w600,
onPressed: () async {
addMedicationButton(widget.medicineViewModel);
},
),
],
),
),
),
],
],
),
);
}
@ -537,15 +538,27 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
}
openDrugToDrug(
MedicineViewModel model, PrescriptionViewModel modelPrescription) {
MedicineViewModel medicineViewModel, PrescriptionViewModel modelPrescription) {
showModalBottomSheet(
context: context,
builder: (context) {
return AddDrugWidget(
patient: widget.patient,
medicineModel: model,
modelPrescription: modelPrescription,
medicineModel: widget.medicineViewModel,
modelPrescription: widget.prescriptionViewModel,
prescriptionList: widget.prescriptionList,
route: route,
doseTime: doseTime,
duration: duration,
frequency: frequency,
units: units,
uom: uom,
x: x,
selectedMedication: widget.selectedMedication,
strength: strengthController.text,
indication: indicationController.text,
instruction: instructionController.text,
selectedDate: selectedDate,
);
});
}
@ -578,7 +591,7 @@ class _PrescriptionFormWidgetState extends State<PrescriptionFormWidget> {
if (formKey.currentState.validate()) {
Navigator.pop(context);
openDrugToDrug(model, widget.prescriptionViewModel);
openDrugToDrug(model, prescriptionViewModel);
}
} else {
setState(() {

Loading…
Cancel
Save