|
|
|
|
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/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>();
|
|
|
|
|
|
|
|
|
|
Future checkPatientForRegistration(
|
|
|
|
|
CheckPatientForRegistrationModel registrationModel) async {
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
await _patientRegistrationService
|
|
|
|
|
.checkPatientForRegistration(registrationModel);
|
|
|
|
|
if (_patientRegistrationService.hasError) {
|
|
|
|
|
error = _patientRegistrationService.error;
|
|
|
|
|
setState(ViewState.Error);
|
|
|
|
|
} else
|
|
|
|
|
setState(ViewState.Idle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future sendActivationCodeByOTPNotificationType(
|
|
|
|
|
{SendActivationCodeByOTPNotificationTypeForRegistrationModel
|
|
|
|
|
registrationModel,
|
|
|
|
|
int otpType}) async {
|
|
|
|
|
setState(ViewState.Busy);
|
|
|
|
|
await _patientRegistrationService.sendActivationCodeByOTPNotificationType(
|
|
|
|
|
otpType: otpType);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|