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/PatientRegistrationViewMode...

81 lines
3.2 KiB
Dart

import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckActivationCodeModel.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckPatientForRegistrationModel.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/GetPatientInfoRequestModel.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/GetPatientInfoResponseModel.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/PatientRegistrationModel.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/SendActivationCodebyOTPNotificationTypeForRegistrationModel.dart';
import 'package:doctor_app_flutter/core/service/PatientRegistrationService.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import '../../locator.dart';
class PatientRegistrationViewModel extends BaseViewModel {
PatientRegistrationService _patientRegistrationService =
locator<PatientRegistrationService>();
GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel;
CheckPatientForRegistrationModel checkPatientForRegistrationModel ;
Future checkPatientForRegistration(
CheckPatientForRegistrationModel registrationModel) async {
checkPatientForRegistrationModel =registrationModel;
setState(ViewState.BusyLocal);
await _patientRegistrationService
.checkPatientForRegistration(registrationModel);
if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future getPatientInfo(
GetPatientInfoRequestModel getPatientInfoRequestModel) async {
setState(ViewState.BusyLocal);
await _patientRegistrationService.
getPatientInfo(getPatientInfoRequestModel);
if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future sendActivationCodeByOTPNotificationType(
SendActivationCodeByOTPNotificationTypeForRegistrationModel
registrationModel) async {
setState(ViewState.Busy);
await _patientRegistrationService
.sendActivationCodeByOTPNotificationType(registrationModel);
if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future checkActivationCode(CheckActivationCodeModel registrationModel) async {
setState(ViewState.Busy);
await _patientRegistrationService.checkActivationCode(registrationModel);
if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future registrationPatient(PatientRegistrationModel registrationModel) async {
setState(ViewState.Busy);
await _patientRegistrationService.registrationPatient(registrationModel);
if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
}