@ -1,3 +1,4 @@
import ' package:diplomaticquarterapp/config/config.dart ' ;
import ' package:diplomaticquarterapp/core/enum/viewstate.dart ' ;
import ' package:diplomaticquarterapp/core/model/ask_doctor/AskDoctorReqTypes.dart ' ;
import ' package:diplomaticquarterapp/core/model/ask_doctor/DoctorResponse.dart ' ;
@ -6,51 +7,40 @@ import 'package:diplomaticquarterapp/core/service/medical/my_doctor_service.dart
import ' package:diplomaticquarterapp/core/viewModels/base_view_model.dart ' ;
import ' package:diplomaticquarterapp/locator.dart ' ;
import ' package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart ' ;
import ' package:diplomaticquarterapp/pages/base/base_view.dart ' ;
import ' package:diplomaticquarterapp/uitl/app_toast.dart ' ;
import ' package:diplomaticquarterapp/uitl/translations_delegate_base.dart ' ;
class AskDoctorViewModel extends BaseViewModel {
AskDoctorService _askDoctorService = locator < AskDoctorService > ( ) ;
MyDoctorService _myDoctorService = locator < MyDoctorService > ( ) ;
List < PatientDoctorAppointmentList > patientDoctorAppointmentListHospital =
List ( ) ;
List < PatientDoctorAppointmentList > patientDoctorAppointmentListHospital = List ( ) ;
List < AskDoctorReqTypes > get askDoctorReqTypes = >
_askDoctorService . askDoctorReqTypes ;
List < AskDoctorReqTypes > get askDoctorReqTypes = > _askDoctorService . askDoctorReqTypes ;
List < DoctorResponse > get doctorResponseList = >
_askDoctorService . doctorResponseList ;
List < DoctorResponse > get doctorResponseList = > _askDoctorService . doctorResponseList ;
Future getMyDoctor ( ) async {
setState ( ViewState . Busy ) ;
await _myDoctorService . getPatientDoctorAppointmentList (
top: 25 , beforeDays: 15 ) ;
await _myDoctorService . getPatientDoctorAppointmentList ( top: 25 , beforeDays: 15 ) ;
if ( _myDoctorService . hasError ) {
error = _myDoctorService . error ;
setState ( ViewState . Error ) ;
} else
var asd = " " ;
_myDoctorService . patientDoctorAppointmentList . forEach ( ( element ) {
List < PatientDoctorAppointmentList > doctorByClinic =
patientDoctorAppointmentListHospital
. where ( ( elementClinic ) = >
elementClinic . filterName = = element . projectName )
. toList ( ) ;
if ( doctorByClinic . length ! = 0 ) {
patientDoctorAppointmentListHospital [
patientDoctorAppointmentListHospital . indexOf ( doctorByClinic [ 0 ] ) ]
. patientDoctorAppointmentList
. add ( element ) ;
} else {
patientDoctorAppointmentListHospital . add ( PatientDoctorAppointmentList (
filterName: element . projectName ,
patientDoctorAppointment: element ) ) ;
}
} else if ( _myDoctorService . patientDoctorAppointmentList . length ! = 0 ) {
_myDoctorService . patientDoctorAppointmentList . forEach ( ( element ) {
List < PatientDoctorAppointmentList > doctorByClinic = patientDoctorAppointmentListHospital . where ( ( elementClinic ) = > elementClinic . filterName = = element . projectName ) . toList ( ) ;
if ( doctorByClinic . length ! = 0 ) {
patientDoctorAppointmentListHospital [ patientDoctorAppointmentListHospital . indexOf ( doctorByClinic [ 0 ] ) ] . patientDoctorAppointmentList . add ( element ) ;
} else {
patientDoctorAppointmentListHospital . add ( PatientDoctorAppointmentList ( filterName: element . projectName , patientDoctorAppointment: element ) ) ;
}
setState ( ViewState . Idle ) ;
} ) ;
} else {
setState ( ViewState . Idle ) ;
} ) ;
AppToast . showErrorToast ( message: TranslationBase . of ( AppGlobal . context ) . askDocEmpty ) ;
}
}
Future getCallRequestTypeLOVs ( ) async {
@ -66,8 +56,7 @@ class AskDoctorViewModel extends BaseViewModel {
Future getCallInfoHoursResult ( { int projectId , int doctorId } ) async {
setState ( ViewState . Busy ) ;
await _askDoctorService . getCallInfoHoursResult (
projectId: projectId , doctorId: doctorId ) ;
await _askDoctorService . getCallInfoHoursResult ( projectId: projectId , doctorId: doctorId ) ;
if ( _askDoctorService . hasError ) {
error = _askDoctorService . error ;
setState ( ViewState . ErrorLocal ) ;
@ -95,11 +84,9 @@ class AskDoctorViewModel extends BaseViewModel {
setState ( ViewState . Idle ) ;
}
Future sendRequestLOV (
{ DoctorList doctorList , String requestType , String remark } ) async {
Future sendRequestLOV ( { DoctorList doctorList , String requestType , String remark } ) async {
setState ( ViewState . BusyLocal ) ;
await _askDoctorService . sendRequestLOV (
doctorList: doctorList , requestType: requestType , remark: remark ) ;
await _askDoctorService . sendRequestLOV ( doctorList: doctorList , requestType: requestType , remark: remark ) ;
if ( _askDoctorService . hasError ) {
error = _askDoctorService . error ;
setState ( ViewState . ErrorLocal ) ;