From a701b6e9894b2308d49500a759e3673981fda8a0 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 15 Apr 2021 13:46:21 +0300 Subject: [PATCH] make referral changes --- lib/config/config.dart | 4 + .../patient-doctor-referral-service.dart | 19 +- lib/core/service/patient_service.dart | 2 +- .../viewModel/patient-referral-viewmodel.dart | 17 +- lib/core/viewModel/patient_view_model.dart | 2 +- .../get_doctor_by_clinic_id_request.dart | 118 +++++------- .../patient/my_referral/clinic-doctor.dart | 169 ++++++++++++++++++ .../profile/refer_patient_screen.dart | 3 +- .../referral/refer-patient-screen.dart | 7 +- 9 files changed, 255 insertions(+), 86 deletions(-) create mode 100644 lib/models/patient/my_referral/clinic-doctor.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 654f704a..04844667 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -18,6 +18,10 @@ const PATIENT_REFER_TO_DOCTOR_URL = "Services/DoctorApplication.svc/REST/ReferToDoctor"; const PATIENT_GET_DOCTOR_BY_CLINIC_URL = "Services/DoctorApplication.svc/REST/GetDoctorsByClinicID"; + +const PATIENT_GET_DOCTOR_BY_CLINIC_Hospital = + "Services/Doctors.svc/REST/SearchDoctorsByTime"; + const GET_CLINICS_FOR_DOCTOR = 'Services/DoctorApplication.svc/REST/GetClinicsForDoctor'; const PATIENT_GET_LIST_REFERAL_URL = diff --git a/lib/core/service/patient-doctor-referral-service.dart b/lib/core/service/patient-doctor-referral-service.dart index 052f78b6..62ebcb06 100644 --- a/lib/core/service/patient-doctor-referral-service.dart +++ b/lib/core/service/patient-doctor-referral-service.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart'; import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart'; import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/PendingReferral.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/clinic-doctor.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/my_referred_patient_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/request_my_referral_patient_model.dart'; @@ -15,7 +16,7 @@ import 'base/lookup-service.dart'; class PatientReferralService extends LookupService { List projectsList = []; List clinicsList = []; - List doctorsList = []; + List doctorsList = List(); List listMyReferredPatientModel = []; List pendingReferralList = []; List patientReferralList = []; @@ -101,25 +102,31 @@ class PatientReferralService extends LookupService { ); } - Future getDoctorsList(String clinicId, int branchId) async { + Future getDoctorsList(PatiantInformtion patient ,int clinicId, int branchId) async { hasError = false; DoctorsByClinicIdRequest _doctorsByClinicIdRequest = DoctorsByClinicIdRequest(); _doctorsByClinicIdRequest.projectID = branchId; _doctorsByClinicIdRequest.clinicID = clinicId; + _doctorsByClinicIdRequest.patientID = patient.patientId; + _doctorsByClinicIdRequest.gender = patient.gender; - await baseAppClient.post( - PATIENT_GET_DOCTOR_BY_CLINIC_URL, + + await baseAppClient.postPatient( + PATIENT_GET_DOCTOR_BY_CLINIC_Hospital, onSuccess: (dynamic response, int statusCode) { - doctorsList = []; - doctorsList = response['List_Doctors_All']; + doctorsList.clear(); + response['DoctorList'].forEach((v) { + doctorsList.add(ClinicDoctor.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: _doctorsByClinicIdRequest.toJson(), + patient: patient ); } diff --git a/lib/core/service/patient_service.dart b/lib/core/service/patient_service.dart index 413bb6ae..aea26e8a 100644 --- a/lib/core/service/patient_service.dart +++ b/lib/core/service/patient_service.dart @@ -357,7 +357,7 @@ class PatientService extends BaseService { ); } - Future getDoctorsList(String clinicId) async { + Future getDoctorsList(int clinicId) async { hasError = false; _doctorsByClinicIdRequest.clinicID = clinicId; await baseAppClient.post( diff --git a/lib/core/viewModel/patient-referral-viewmodel.dart b/lib/core/viewModel/patient-referral-viewmodel.dart index f46fe463..2a7f921a 100644 --- a/lib/core/viewModel/patient-referral-viewmodel.dart +++ b/lib/core/viewModel/patient-referral-viewmodel.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/PendingReferral.dart'; +import 'package:doctor_app_flutter/models/patient/my_referral/clinic-doctor.dart'; import 'package:doctor_app_flutter/models/patient/my_referral/my_referred_patient_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; @@ -21,7 +22,9 @@ class PatientReferralViewModel extends BaseViewModel { List get clinicsList => _referralPatientService.clinicsList; - List get doctorsList => _referralPatientService.doctorsList; + List doctorsList = []; + + List get clinicDoctorsList => _referralPatientService.doctorsList; List get listMyReferredPatientModel => _referralPatientService.listMyReferredPatientModel; @@ -82,14 +85,20 @@ class PatientReferralViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future getClinicDoctors(String clinicId, int branchId) async { + Future getClinicDoctors(PatiantInformtion patient ,int clinicId, int branchId) async { setState(ViewState.BusyLocal); - await _referralPatientService.getDoctorsList(clinicId, branchId); + await _referralPatientService.getDoctorsList(patient, clinicId, branchId); if (_referralPatientService.hasError) { error = _referralPatientService.error; setState(ViewState.ErrorLocal); - } else + } else{ + doctorsList.clear(); + clinicDoctorsList.forEach((element) { + doctorsList.add(element.toJson()); + }); setState(ViewState.Idle); + } + } Future getDoctorBranch() async { diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart index 5f4b6c9a..9e938630 100644 --- a/lib/core/viewModel/patient_view_model.dart +++ b/lib/core/viewModel/patient_view_model.dart @@ -170,7 +170,7 @@ class PatientViewModel extends BaseViewModel { } } - Future getDoctorsList(String clinicId) async { + Future getDoctorsList(int clinicId) async { setState(ViewState.BusyLocal); await _patientService.getDoctorsList(clinicId); if (_patientService.hasError) { diff --git a/lib/models/patient/get_doctor_by_clinic_id_request.dart b/lib/models/patient/get_doctor_by_clinic_id_request.dart index a2b33e29..9504fc35 100644 --- a/lib/models/patient/get_doctor_by_clinic_id_request.dart +++ b/lib/models/patient/get_doctor_by_clinic_id_request.dart @@ -1,86 +1,66 @@ class DoctorsByClinicIdRequest { -/* - *@author: Ibrahim Albitar - *@Date:03/06/2020 - *@param: - *@return: - *@desc: DoctorsByClinicIdRequest - */ - + int clinicID; int projectID; - String clinicID; - int languageID; - String stamp; - String iPAdress; - double versionID; - int channel; - String tokenID; - String sessionID; - bool isLoginForDoctorApp; - bool patientOutSA; - int patientTypeID; + bool continueDentalPlan; + bool isSearchAppointmnetByClinicID; + int patientID; + int gender; + bool isGetNearAppointment; + bool isVoiceCommand; + int latitude; + int longitude; + bool license; + bool isDentalAllowedBackend; - /* - { - "ProjectID": 21, - "ClinicID": "0", - "LanguageID": 2, - "stamp": "2020-06-03T11:22:04.702Z", - "IPAdress": "11.11.11.11", - "VersionID": 1.2, - "Channel": 9, - "TokenID": "gyIQFH4WWEm2Tq7xjYMjsg==", - "SessionID": "JBXRsDl37L", - "IsLoginForDoctorApp": true, - "PatientOutSA": false, - "PatientTypeID": 1 -} - */ DoctorsByClinicIdRequest( - {this.projectID, - this.clinicID, - this.languageID = 2, - this.stamp = "2020-06-03T11:22:04.702Z", - this.iPAdress = "11.11.11.11", - this.versionID = 1.2, - this.channel = 9, - this.tokenID, - this.sessionID = "JBXRsDl37L", - this.isLoginForDoctorApp = true, - this.patientOutSA = false, - this.patientTypeID = 1}); + { + this.clinicID, + this.projectID, + this.continueDentalPlan = false, + this.isSearchAppointmnetByClinicID = true, + this.patientID, + this.gender, + this.isGetNearAppointment = false, + this.isVoiceCommand = true, + this.latitude = 0, + this.longitude = 0, + this.license = true, + this.isDentalAllowedBackend = false, + }); + DoctorsByClinicIdRequest.fromJson(Map json) { - projectID = json['ProjectID']; clinicID = json['ClinicID']; - languageID = json['LanguageID']; - stamp = json['stamp']; - iPAdress = json['IPAdress']; - versionID = json['VersionID']; - channel = json['Channel']; - tokenID = json['TokenID']; - sessionID = json['SessionID']; - isLoginForDoctorApp = json['IsLoginForDoctorApp']; - patientOutSA = json['PatientOutSA']; - patientTypeID = json['PatientTypeID']; + projectID = json['ProjectID']; + continueDentalPlan = json['ContinueDentalPlan']; + isSearchAppointmnetByClinicID = json['IsSearchAppointmnetByClinicID']; + patientID = json['PatientID']; + gender = json['gender']; + isGetNearAppointment = json['IsGetNearAppointment']; + isVoiceCommand = json['IsVoiceCommand']; + latitude = json['Latitude']; + longitude = json['Longitude']; + license = json['License']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; } Map toJson() { final Map data = new Map(); - data['ProjectID'] = this.projectID; data['ClinicID'] = this.clinicID; - data['LanguageID'] = this.languageID; - data['stamp'] = this.stamp; - data['IPAdress'] = this.iPAdress; - data['VersionID'] = this.versionID; - data['Channel'] = this.channel; - data['TokenID'] = this.tokenID; - data['SessionID'] = this.sessionID; - data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; - data['PatientOutSA'] = this.patientOutSA; - data['PatientTypeID'] = this.patientTypeID; + data['ProjectID'] = this.projectID; + data['ContinueDentalPlan'] = this.continueDentalPlan; + data['IsSearchAppointmnetByClinicID'] = this.isSearchAppointmnetByClinicID; + data['PatientID'] = this.patientID; + data['gender'] = this.gender; + data['IsGetNearAppointment'] = this.isGetNearAppointment; + data['IsVoiceCommand'] = this.isVoiceCommand; + data['Latitude'] = this.latitude; + data['Longitude'] = this.longitude; + data['License'] = this.license; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; return data; + } } diff --git a/lib/models/patient/my_referral/clinic-doctor.dart b/lib/models/patient/my_referral/clinic-doctor.dart new file mode 100644 index 00000000..843f636c --- /dev/null +++ b/lib/models/patient/my_referral/clinic-doctor.dart @@ -0,0 +1,169 @@ +class ClinicDoctor { + int clinicID; + String clinicName; + String doctorTitle; + int iD; + String name; + int projectID; + String projectName; + int actualDoctorRate; + int clinicRoomNo; + String date; + String dayName; + int doctorID; + String doctorImageURL; + String doctorProfile; + String doctorProfileInfo; + int doctorRate; + int gender; + String genderDescription; + bool isAppointmentAllowed; + bool isDoctorAllowVedioCall; + bool isDoctorDummy; + bool isLiveCare; + String latitude; + String longitude; + String nationalityFlagURL; + String nationalityID; + String nationalityName; + String nearestFreeSlot; + int noOfPatientsRate; + String originalClinicID; + int personRate; + int projectDistanceInKiloMeters; + String qR; + String qRString; + int rateNumber; + String serviceID; + String setupID; + List speciality; + String workingHours; + + ClinicDoctor( + {this.clinicID, + this.clinicName, + this.doctorTitle, + this.iD, + this.name, + this.projectID, + this.projectName, + this.actualDoctorRate, + this.clinicRoomNo, + this.date, + this.dayName, + this.doctorID, + this.doctorImageURL, + this.doctorProfile, + this.doctorProfileInfo, + this.doctorRate, + this.gender, + this.genderDescription, + this.isAppointmentAllowed, + this.isDoctorAllowVedioCall, + this.isDoctorDummy, + this.isLiveCare, + this.latitude, + this.longitude, + this.nationalityFlagURL, + this.nationalityID, + this.nationalityName, + this.nearestFreeSlot, + this.noOfPatientsRate, + this.originalClinicID, + this.personRate, + this.projectDistanceInKiloMeters, + this.qR, + this.qRString, + this.rateNumber, + this.serviceID, + this.setupID, + this.speciality, + this.workingHours}); + + ClinicDoctor.fromJson(Map json) { + clinicID = json['ClinicID']; + clinicName = json['ClinicName']; + doctorTitle = json['DoctorTitle']; + iD = json['ID']; + name = json['Name']; + projectID = json['ProjectID']; + projectName = json['ProjectName']; + actualDoctorRate = json['ActualDoctorRate']; + clinicRoomNo = json['ClinicRoomNo']; + date = json['Date']; + dayName = json['DayName']; + doctorID = json['DoctorID']; + doctorImageURL = json['DoctorImageURL']; + doctorProfile = json['DoctorProfile']; + doctorProfileInfo = json['DoctorProfileInfo']; + doctorRate = json['DoctorRate']; + gender = json['Gender']; + genderDescription = json['GenderDescription']; + isAppointmentAllowed = json['IsAppointmentAllowed']; + isDoctorAllowVedioCall = json['IsDoctorAllowVedioCall']; + isDoctorDummy = json['IsDoctorDummy']; + isLiveCare = json['IsLiveCare']; + latitude = json['Latitude']; + longitude = json['Longitude']; + nationalityFlagURL = json['NationalityFlagURL']; + nationalityID = json['NationalityID']; + nationalityName = json['NationalityName']; + nearestFreeSlot = json['NearestFreeSlot']; + noOfPatientsRate = json['NoOfPatientsRate']; + originalClinicID = json['OriginalClinicID']; + personRate = json['PersonRate']; + projectDistanceInKiloMeters = json['ProjectDistanceInKiloMeters']; + qR = json['QR']; + qRString = json['QRString']; + rateNumber = json['RateNumber']; + serviceID = json['ServiceID']; + setupID = json['SetupID']; + speciality = json['Speciality'].cast(); + workingHours = json['WorkingHours']; + } + + Map toJson() { + final Map data = new Map(); + data['ClinicID'] = this.clinicID; + data['ClinicName'] = this.clinicName; + data['DoctorTitle'] = this.doctorTitle; + data['ID'] = this.iD; + data['Name'] = this.name; + data['ProjectID'] = this.projectID; + data['ProjectName'] = this.projectName; + data['ActualDoctorRate'] = this.actualDoctorRate; + data['ClinicRoomNo'] = this.clinicRoomNo; + data['Date'] = this.date; + data['DayName'] = this.dayName; + data['DoctorID'] = this.doctorID; + data['DoctorImageURL'] = this.doctorImageURL; + data['DoctorProfile'] = this.doctorProfile; + data['DoctorProfileInfo'] = this.doctorProfileInfo; + data['DoctorRate'] = this.doctorRate; + data['Gender'] = this.gender; + data['GenderDescription'] = this.genderDescription; + data['IsAppointmentAllowed'] = this.isAppointmentAllowed; + data['IsDoctorAllowVedioCall'] = this.isDoctorAllowVedioCall; + data['IsDoctorDummy'] = this.isDoctorDummy; + data['IsLiveCare'] = this.isLiveCare; + data['Latitude'] = this.latitude; + data['Longitude'] = this.longitude; + data['NationalityFlagURL'] = this.nationalityFlagURL; + data['NationalityID'] = this.nationalityID; + data['NationalityName'] = this.nationalityName; + data['NearestFreeSlot'] = this.nearestFreeSlot; + data['NoOfPatientsRate'] = this.noOfPatientsRate; + data['OriginalClinicID'] = this.originalClinicID; + data['PersonRate'] = this.personRate; + data['ProjectDistanceInKiloMeters'] = this.projectDistanceInKiloMeters; + data['QR'] = this.qR; + data['QRString'] = this.qRString; + data['RateNumber'] = this.rateNumber; + data['ServiceID'] = this.serviceID; + data['SetupID'] = this.setupID; + data['Speciality'] = this.speciality; + data['WorkingHours'] = this.workingHours; + return data; + } + +} \ No newline at end of file diff --git a/lib/screens/patients/profile/refer_patient_screen.dart b/lib/screens/patients/profile/refer_patient_screen.dart index 9b56003b..ffa1608a 100644 --- a/lib/screens/patients/profile/refer_patient_screen.dart +++ b/lib/screens/patients/profile/refer_patient_screen.dart @@ -78,8 +78,7 @@ class _ReferPatientState extends State { _selectedDoctor = null; _selectedClinic = selectedValue; model.getDoctorsList( - _selectedClinic['ClinicID'] - .toString()); + _selectedClinic['ClinicID']); }); }, ); diff --git a/lib/screens/patients/profile/referral/refer-patient-screen.dart b/lib/screens/patients/profile/referral/refer-patient-screen.dart index 52170c9b..c27a5c46 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen.dart @@ -363,7 +363,8 @@ class _PatientMakeReferralScreenState extends State { GifLoaderDialogUtils.showMyDialog(context); await model .getClinicDoctors( - _selectedClinic['ClinicID'].toString(), + patient, + _selectedClinic['ClinicID'], _selectedBranch['facilityId']) .then((_) => GifLoaderDialogUtils.hideDialog(context)); @@ -390,7 +391,7 @@ class _PatientMakeReferralScreenState extends State { height: screenSize.height * 0.075, hintText: TranslationBase.of(context).doctor, dropDownText: - _selectedDoctor != null ? _selectedDoctor['DoctorName'] : null, + _selectedDoctor != null ? _selectedDoctor['Name'] : null, enabled: false, isDropDown: true, validationError: doctorError, @@ -400,7 +401,7 @@ class _PatientMakeReferralScreenState extends State { ? () { ListSelectDialog dialog = ListSelectDialog( list: model.doctorsList, - attributeName: 'DoctorName', + attributeName: 'Name', attributeValueId: 'DoctorID', usingSearch: true, hintSearchText: TranslationBase.of(context).doctorSearch,