medical report fix

merge-requests/761/head
hussam al-habibeh 4 years ago
parent 9890d6a063
commit 1e35b70b01

@ -24,19 +24,8 @@ class PatientMedicalReportViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
bool hasOnHold() {
bool hasHold = false;
medicalReportList.forEach((element) {
if (element.status == 1) {
hasHold = true;
}
});
return hasHold;
}
Future getMedicalReportTemplate() async {
setState(ViewState.BusyLocal);
setState(ViewState.Busy);
await _service.getMedicalReportTemplate();
if (_service.hasError) {
error = _service.error;
@ -62,7 +51,7 @@ class PatientMedicalReportViewModel extends BaseViewModel {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
getMedicalReportList(patient);
await getMedicalReportList(patient);
setState(ViewState.Idle);
}
@ -73,7 +62,7 @@ class PatientMedicalReportViewModel extends BaseViewModel {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
getMedicalReportList(patient);
await getMedicalReportList(patient);
setState(ViewState.Idle);
}
@ -84,7 +73,7 @@ class PatientMedicalReportViewModel extends BaseViewModel {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
getMedicalReportList(patient);
await getMedicalReportList(patient);
setState(ViewState.Idle);
}
}

@ -19,12 +19,12 @@ class BaseViewModel extends ChangeNotifier {
void setState(ViewState viewState) {
_state = viewState;
notifyListeners();
}
Future<DoctorProfileModel> getDoctorProfile({bool isGetProfile = false}) async {
if(isGetProfile)
{
if (isGetProfile) {
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
if (profile != null) {
doctorProfile = DoctorProfileModel.fromJson(profile);
@ -46,10 +46,10 @@ class BaseViewModel extends ChangeNotifier {
return doctorProfile;
}
}
setDoctorProfile(DoctorProfileModel doctorProfile)async {
await sharedPref.setObj(DOCTOR_PROFILE, doctorProfile);
this.doctorProfile = doctorProfile;
notifyListeners();
setDoctorProfile(DoctorProfileModel doctorProfile) async {
await sharedPref.setObj(DOCTOR_PROFILE, doctorProfile);
this.doctorProfile = doctorProfile;
notifyListeners();
}
}

@ -124,6 +124,6 @@ void setupLocator() {
locator.registerFactory(() => PatientSearchViewModel());
locator.registerFactory(() => HospitalViewModel());
locator.registerFactory(() => LiveCarePatientViewModel());
locator.registerLazySingleton(() => PatientMedicalReportViewModel());
locator.registerFactory(() => PatientMedicalReportViewModel());
locator.registerFactory(() => ScanQrViewModel());
}

@ -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");
}
},
),
),
],
),
),
],
),
));
}

@ -40,6 +40,7 @@ class _MedicalReportPageState extends State<MedicalReportPage> {
return BaseView<PatientMedicalReportViewModel>(
onModelReady: (model) async {
await model.getMedicalReportList(patient);
await model.getMedicalReportTemplate();
},
builder: (_, model, w) => AppScaffold(
baseViewModel: model,
@ -79,13 +80,25 @@ class _MedicalReportPageState extends State<MedicalReportPage> {
// Helpers.showErrorToast("Please Verified the on hold report to be able to add new one");
// } else
Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_INSERT, arguments: {
'patient': patient,
'patientType': patientType,
'arrivalType': arrivalType,
'type': MedicalReportStatus.ADD,
'model': model,
});
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddVerifyMedicalReport(
patient: patient,
patientType: patientType,
arrivalType: arrivalType,
model: model,
status: MedicalReportStatus.ADD,
)),
);
// Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_INSERT, arguments: {
// 'patient': patient,
// 'patientType': patientType,
// 'arrivalType': arrivalType,
// 'type': MedicalReportStatus.ADD,
// 'model': model,
// });
},
label: TranslationBase.of(context).createNewMedicalReport,
),
@ -95,13 +108,25 @@ class _MedicalReportPageState extends State<MedicalReportPage> {
(index) => InkWell(
onTap: () {
if (model.medicalReportList[index].status == 1) {
Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_INSERT, arguments: {
'patient': patient,
'patientType': patientType,
'arrivalType': arrivalType,
'medicalReport': model.medicalReportList[index],
'model': model,
});
// Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_INSERT, arguments: {
// 'patient': patient,
// 'patientType': patientType,
// 'arrivalType': arrivalType,
// 'medicalReport': model.medicalReportList[index],
// 'model': model,
// });
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddVerifyMedicalReport(
patient: patient,
patientType: patientType,
arrivalType: arrivalType,
medicalReport: model.medicalReportList[index],
model: model,
medicalNote: model.medicalReportList[index].reportDataHtml,
)),
);
} else {
Navigator.of(context).pushNamed(PATIENT_MEDICAL_REPORT_DETAIL, arguments: {
'patient': patient,
@ -138,8 +163,8 @@ class _MedicalReportPageState extends State<MedicalReportPage> {
),
AppText(
projectViewModel.isArabic
? model.medicalReportList[index].doctorNameN
: model.medicalReportList[index].doctorName,
? model.medicalReportList[index].doctorNameN ?? ""
: model.medicalReportList[index].doctorName ?? "",
fontSize: 1.9 * SizeConfig.textMultiplier,
fontWeight: FontWeight.w700,
color: Color(0xFF2E303A),

Loading…
Cancel
Save