|
|
|
|
@ -1,13 +1,10 @@
|
|
|
|
|
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/PatientMedicalReportViewModel.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/patient/MedicalReport/MeidcalReportModel.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/base/base_view.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/patients/profile/medical_report/MedicalReportPage.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
|
|
|
|
|
@ -15,9 +12,27 @@ import 'package:doctor_app_flutter/widgets/shared/text_fields/html_rich_editor.d
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:html_editor_enhanced/html_editor.dart';
|
|
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class AddVerifyMedicalReport extends StatefulWidget {
|
|
|
|
|
final PatiantInformtion patient;
|
|
|
|
|
final String patientType;
|
|
|
|
|
final String arrivalType;
|
|
|
|
|
final MedicalReportModel medicalReport;
|
|
|
|
|
final PatientMedicalReportViewModel model;
|
|
|
|
|
final MedicalReportStatus status;
|
|
|
|
|
final String medicalNote;
|
|
|
|
|
|
|
|
|
|
const AddVerifyMedicalReport(
|
|
|
|
|
{Key key,
|
|
|
|
|
this.patient,
|
|
|
|
|
this.patientType,
|
|
|
|
|
this.arrivalType,
|
|
|
|
|
this.medicalReport,
|
|
|
|
|
this.model,
|
|
|
|
|
this.status,
|
|
|
|
|
this.medicalNote})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_AddVerifyMedicalReportState createState() => _AddVerifyMedicalReportState();
|
|
|
|
|
}
|
|
|
|
|
@ -25,121 +40,121 @@ class AddVerifyMedicalReport extends StatefulWidget {
|
|
|
|
|
class _AddVerifyMedicalReportState extends State<AddVerifyMedicalReport> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
ProjectViewModel projectViewModel = Provider.of<ProjectViewModel>(context);
|
|
|
|
|
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
|
|
|
|
|
PatientMedicalReportViewModel patientMedicalReportViewModel = routeArgs['model'];
|
|
|
|
|
PatiantInformtion patient = routeArgs['patient'];
|
|
|
|
|
MedicalReportStatus status = routeArgs['status'] as MedicalReportStatus;
|
|
|
|
|
MedicalReportModel medicalReport = routeArgs.containsKey("medicalReport") ? routeArgs['medicalReport'] : null;
|
|
|
|
|
String txtOfMedicalReport;
|
|
|
|
|
|
|
|
|
|
return BaseView<PatientMedicalReportViewModel>(
|
|
|
|
|
onModelReady: (_) => patientMedicalReportViewModel.getMedicalReportTemplate(),
|
|
|
|
|
onModelReady: (model) async {},
|
|
|
|
|
builder: (_, model, w) => AppScaffold(
|
|
|
|
|
baseViewModel: model,
|
|
|
|
|
isShowAppBar: true,
|
|
|
|
|
appBarTitle: status == MedicalReportStatus.ADD
|
|
|
|
|
appBarTitle: widget.status == MedicalReportStatus.ADD
|
|
|
|
|
? TranslationBase.of(context).medicalReportAdd
|
|
|
|
|
: TranslationBase.of(context).medicalReportVerify,
|
|
|
|
|
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
body: model.state == ViewState.BusyLocal
|
|
|
|
|
? AppLoaderWidget()
|
|
|
|
|
: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// if (model.medicalReportTemplate.length > 0)
|
|
|
|
|
HtmlRichEditor(
|
|
|
|
|
initialText: (medicalReport != null
|
|
|
|
|
? medicalReport.reportDataHtml
|
|
|
|
|
: model.medicalReportTemplate[0].templateText.length > 0
|
|
|
|
|
? model.medicalReportTemplate[0].templateText
|
|
|
|
|
: ""),
|
|
|
|
|
hint: "Write the medical report ",
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.75,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
body: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
margin: EdgeInsets.all(16),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (model.medicalReportTemplate.length > 0)
|
|
|
|
|
HtmlRichEditor(
|
|
|
|
|
initialText: (widget.medicalReport != null
|
|
|
|
|
? widget.medicalNote
|
|
|
|
|
: widget.model.medicalReportTemplate[0].templateText.length > 0
|
|
|
|
|
? widget.model.medicalReportTemplate[0].templateText
|
|
|
|
|
: ""),
|
|
|
|
|
hint: "Write the medical report ",
|
|
|
|
|
height: MediaQuery.of(context).size.height * 0.75,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.all(16.0),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: AppButton(
|
|
|
|
|
title: status == MedicalReportStatus.ADD
|
|
|
|
|
? TranslationBase.of(context).save
|
|
|
|
|
: TranslationBase.of(context).save,
|
|
|
|
|
color: Color(0xffEAEAEA),
|
|
|
|
|
fontColor: Colors.black,
|
|
|
|
|
// disabled: progressNoteController.text.isEmpty,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
String txtOfMedicalReport = await HtmlEditor.getText();
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.all(16.0),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: AppButton(
|
|
|
|
|
title: widget.status == MedicalReportStatus.ADD
|
|
|
|
|
? TranslationBase.of(context).save
|
|
|
|
|
: TranslationBase.of(context).save,
|
|
|
|
|
color: Color(0xffEAEAEA),
|
|
|
|
|
fontColor: Colors.black,
|
|
|
|
|
// disabled: progressNoteController.text.isEmpty,
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
txtOfMedicalReport = await HtmlEditor.getText();
|
|
|
|
|
|
|
|
|
|
if (txtOfMedicalReport.isNotEmpty) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
medicalReport != null
|
|
|
|
|
? model.updateMedicalReport(
|
|
|
|
|
patient,
|
|
|
|
|
txtOfMedicalReport,
|
|
|
|
|
medicalReport != null ? medicalReport.lineItemNo : null,
|
|
|
|
|
medicalReport != null ? medicalReport.invoiceNo : null)
|
|
|
|
|
: model.addMedicalReport(patient, txtOfMedicalReport);
|
|
|
|
|
//model.getMedicalReportList(patient);
|
|
|
|
|
if (txtOfMedicalReport.isNotEmpty) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
widget.medicalReport != null
|
|
|
|
|
? widget.model.updateMedicalReport(
|
|
|
|
|
widget.patient,
|
|
|
|
|
txtOfMedicalReport,
|
|
|
|
|
widget.medicalReport != null ? widget.medicalReport.lineItemNo : null,
|
|
|
|
|
widget.medicalReport != null ? widget.medicalReport.invoiceNo : null)
|
|
|
|
|
: widget.model.addMedicalReport(widget.patient, txtOfMedicalReport);
|
|
|
|
|
//model.getMedicalReportList(patient);
|
|
|
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 8,
|
|
|
|
|
),
|
|
|
|
|
if (medicalReport != null)
|
|
|
|
|
Expanded(
|
|
|
|
|
child: AppButton(
|
|
|
|
|
title: status == MedicalReportStatus.ADD
|
|
|
|
|
? TranslationBase.of(context).add
|
|
|
|
|
: TranslationBase.of(context).verify,
|
|
|
|
|
color: Color(0xff359846),
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await model.verifyMedicalReport(patient, medicalReport);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(model.error);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
if (widget.model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(widget.model.error);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
DrAppToastMsg.showErrorToast("Please enter medical note");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: 8,
|
|
|
|
|
),
|
|
|
|
|
if (widget.medicalReport != null)
|
|
|
|
|
Expanded(
|
|
|
|
|
child: AppButton(
|
|
|
|
|
title: widget.status == MedicalReportStatus.ADD
|
|
|
|
|
? TranslationBase.of(context).add
|
|
|
|
|
: TranslationBase.of(context).verify,
|
|
|
|
|
color: Color(0xff359846),
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
txtOfMedicalReport = await HtmlEditor.getText();
|
|
|
|
|
if (txtOfMedicalReport.isNotEmpty) {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
await widget.model.verifyMedicalReport(widget.patient, widget.medicalReport);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
if (widget.model.state == ViewState.ErrorLocal) {
|
|
|
|
|
DrAppToastMsg.showErrorToast(widget.model.error);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
DrAppToastMsg.showErrorToast("Please enter medical note");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|