You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RSGDoctorApp/lib/core/viewModel/PatientMedicalReportViewMod...

89 lines
3.5 KiB
Dart

4 years ago
import 'package:doctor_app_flutter/core/enum/view_state.dart';
import 'package:doctor_app_flutter/core/service/patient_medical_file/medical_report/PatientMedicalReportService.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/core/model/patient/MedicalReport/MedicalReportTemplate.dart';
import 'package:doctor_app_flutter/core/model/patient/MedicalReport/MeidcalReportModel.dart';
import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart';
import '../../locator.dart';
class PatientMedicalReportViewModel extends BaseViewModel {
PatientMedicalReportService _service = locator<PatientMedicalReportService>();
List<MedicalReportModel> get medicalReportList => _service.medicalReportList;
5 years ago
List<MedicalReportTemplate> get medicalReportTemplate =>
_service.medicalReportTemplate;
7 months ago
Future getMedicalReportList(PatiantInformtion patient,{bool isVidaPlusProject = false}) async {
setState(ViewState.Busy);
7 months ago
await _service.getMedicalReportList(patient, isVidaPlusProject);
if (_service.hasError) {
error = _service.error;
setState(ViewState.ErrorLocal); // ViewState.Error
} else
setState(ViewState.Idle);
}
Future getMedicalReportTemplate() async {
setState(ViewState.Busy);
await _service.getMedicalReportTemplate();
if (_service.hasError) {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future insertMedicalReport(PatiantInformtion patient, String htmlText) async {
setState(ViewState.Busy);
await _service.insertMedicalReport(patient, htmlText);
if (_service.hasError) {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
5 years ago
Future verifyMedicalReport(
7 months ago
PatiantInformtion patient, MedicalReportModel medicalReport, bool? isVidaPlusProject) async {
setState(ViewState.Busy);
6 months ago
print("the isVidaPlusProject flag in VM is $isVidaPlusProject");
7 months ago
await _service.verifyMedicalReport(patient, medicalReport, isVidaPlusProject);
if (_service.hasError) {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
7 months ago
await getMedicalReportList(patient, isVidaPlusProject: isVidaPlusProject == true);
setState(ViewState.Idle);
}
7 months ago
Future addMedicalReport(PatiantInformtion patient, String htmlText, bool? isVidaPlusProject) async {
setState(ViewState.Busy);
7 months ago
await _service.addMedicalReport(patient, htmlText, isVidaPlusProject);
if (_service.hasError) {
error = _service.error;
7 months ago
await getMedicalReportList(patient, isVidaPlusProject: isVidaPlusProject == true);
setState(ViewState.ErrorLocal);
5 years ago
} else {
7 months ago
await getMedicalReportList(patient,isVidaPlusProject: isVidaPlusProject == true);
5 years ago
setState(ViewState.Idle);
}
}
5 years ago
Future updateMedicalReport(PatiantInformtion patient, String htmlText,
int limitNumber, String invoiceNumber, bool? isVidaPlusProject, int? summaryId, MedicalReportModel medicalReportModel) async {
setState(ViewState.Busy);
5 years ago
await _service.updateMedicalReport(
patient, htmlText, limitNumber, invoiceNumber, summaryId, medicalReportModel);
if (_service.hasError) {
error = _service.error;
7 months ago
await getMedicalReportList(patient, isVidaPlusProject: isVidaPlusProject == true);
setState(ViewState.ErrorLocal);
5 years ago
} else {
7 months ago
await getMedicalReportList(patient,isVidaPlusProject: isVidaPlusProject == true);
5 years ago
setState(ViewState.Idle);
}
}
}