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(); GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel; CheckPatientForRegistrationModel checkPatientForRegistrationModel ; Future checkPatientForRegistration( CheckPatientForRegistrationModel registrationModel) async { checkPatientForRegistrationModel =CheckPatientForRegistrationModel.fromJson(registrationModel.toJson()); 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); /// TODO Elham* return call service when it working _patientRegistrationService.getPatientInfoResponseModel = GetPatientInfoResponseModel.fromJson({ "Date": null, "LanguageID": 0, "ServiceName": 0, "Time": null, "AndroidLink": null, "AuthenticationTokenID": null, "Data": null, "Dataw": false, "DietType": 0, "ErrorCode": null, "ErrorEndUserMessage": null, "ErrorEndUserMessageN": null, "ErrorMessage": null, "ErrorType": 0, "FoodCategory": 0, "IOSLink": null, "IsAuthenticated": false, "MealOrderStatus": 0, "MealType": 0, "MessageStatus": 1, "NumberOfResultRecords": 0, "PatientBlodType": null, "SuccessMsg": null, "SuccessMsgN": null, "VidaUpdatedResponse": null, "AccessTokenObject": null, "Age": 33, "ClientIdentifierId": null, "CreatedBy": 0, "DateOfBirth": "07/31/1988", "FirstNameAr": "سفيان", "FirstNameEn": "SUFIAN", "Gender": "M", "GenderAr": null, "GenderEn": null, "HealthId": "30000018540264", "IdNumber": "1062938285", "IdType": "NationalId", "IsHijri": false, "IsInstertedOrUpdated": 0, "IsNull": 0, "IsPatientExistNHIC": 0, "IsRecordLockedByCurrentUser": false, "LastNameAr": "عثمان", "LastNameEn": "OTHMAN", "List_ActiveAccessToken": null, "MaritalStatus": "غير معروف", "MaritalStatusCode": "U", "NationalDateOfBirth": "18/12/1408", "Nationality": "السعودية", "NationalityCode": "SAU", "Occupation": "طالب", "PCDTransactionDataResultList": null, "PCD_GetVidaPatientForManualVerificationList": null, "PCD_NHIC_HMG_PatientDetailsMatchCalulationList": null, "PCD_ReturnValue": 0, "PatientStatus": "-", "PlaceofBirth": "فينا", "PractitionerStatusCode": null, "PractitionerStatusDescAr": null, "PractitionerStatusDescEn": null, "RowCount": 0, "SecondNameAr": "عبدالهادي", "SecondNameEn": "ABDULHADI", "ThirdNameAr": "احمد", "ThirdNameEn": "A", "YakeenVidaPatientDataStatisticsByPatientIdList": null, "YakeenVidaPatientDataStatisticsList": null, "YakeenVidaPatientDataStatisticsPrefferedList": null, "accessToken": null, "categoryCode": 0, "categoryNameAr": null, "categoryNameEn": null, "constraintCode": 0, "constraintNameAr": null, "constraintNameEn": null, "content": null, "errorList": null, "licenseExpiryDate": null, "licenseIssuedDate": null, "licenseStatusCode": null, "licenseStatusDescAr": null, "licenseStatusDescEn": null, "organizations": null, "registrationNumber": null, "specialtyCode": 0, "specialtyNameAr": null, "specialtyNameEn": null }); // 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); } }