diff --git a/lib/core/service/patient/patient_service.dart b/lib/core/service/patient/patient_service.dart index 579af1fe..26a6e40d 100644 --- a/lib/core/service/patient/patient_service.dart +++ b/lib/core/service/patient/patient_service.dart @@ -621,6 +621,28 @@ class PatientService extends BaseService { ); } + Future getPatientCondition() async { + Map request = {}; + var success = false; + + await baseAppClient.post(GET_PATIENT_CLINIC, + onSuccess: (dynamic response, int statusCode) { + stpMasterList = []; + + response['ListPatientConditionProgress']['resultData'].forEach((v) => + v['PATIENT_CONDITION'].forEach((item) { + stpMasterList.add(item); + })); + success = false; + }, onFailure: (String error, int statusCode) { + success = false; + hasError = true; + super.error = error; + }, body: request); + + return success; + } + Future createProgressNote( CreateNoteModel data, PatiantInformtion patient, diff --git a/lib/core/viewModel/patient-referral-viewmodel.dart b/lib/core/viewModel/patient-referral-viewmodel.dart index 13f71ba7..505ec8c2 100644 --- a/lib/core/viewModel/patient-referral-viewmodel.dart +++ b/lib/core/viewModel/patient-referral-viewmodel.dart @@ -3,12 +3,14 @@ import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/diagnosis/GetDiagnosisForInPatientRequestModel.dart'; import 'package:doctor_app_flutter/core/model/diagnosis/GetDiagnosisForInPatientResponseModel.dart'; import 'package:doctor_app_flutter/core/model/doctor/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart'; import 'package:doctor_app_flutter/core/model/patient/my_referral/PendingReferral.dart'; import 'package:doctor_app_flutter/core/model/patient/my_referral/clinic-doctor.dart'; import 'package:doctor_app_flutter/core/model/patient/my_referral/my_referred_patient_model.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/core/model/referral/DischargeReferralPatient.dart'; import 'package:doctor_app_flutter/core/model/referral/MyReferralPatientModel.dart'; +import 'package:doctor_app_flutter/core/service/hospitals/hospitals_service.dart'; import 'package:doctor_app_flutter/core/service/patient/DischargedPatientService.dart'; import 'package:doctor_app_flutter/core/service/patient/MyReferralPatientService.dart'; import 'package:doctor_app_flutter/core/service/patient/ReferralService.dart'; @@ -25,13 +27,15 @@ class PatientReferralViewModel extends BaseViewModel { ReferralService _referralService = locator(); + HospitalsService _hospitalService = locator(); + MyReferralInPatientService _myReferralService = locator(); DischargedPatientService _dischargedPatientService = locator(); List get myDischargeReferralPatient => _dischargedPatientService.myDischargeReferralPatients; - List? get branchesList => _referralPatientService.projectsList; + List? branchesList = []; List? get clinicsList => _referralPatientService.clinicsList; @@ -83,6 +87,7 @@ class PatientReferralViewModel extends BaseViewModel { error = _referralPatientService.error; setState(ViewState.Error); } else { + await getBranches(); if (patientReferral.length == 0) { await getMasterLookup(MasterKeysService.physiotherapyGoals); } else { @@ -97,25 +102,41 @@ class PatientReferralViewModel extends BaseViewModel { if (_referralPatientService.hasError) { error = _referralPatientService.error; setState(ViewState.Error); - } else - await getBranches(); + } + // await getBranches(); } Future getBranches() async { setState(ViewState.BusyLocal); - await _referralPatientService.getReferralFacilities(); + if( _hospitalService.hospitals.isNotEmpty){ + mapHospitalToBranchList(); + return; + } + + DoctorProfileModel doctorProfile = await getDoctorProfile(); + await _hospitalService.getHospitals(GetHospitalsRequestModel( + memberID: doctorProfile.doctorID?.toString()??"" ,doctorID: doctorProfile.doctorID?.toString()??"" + )); if (_referralPatientService.hasError) { error = _referralPatientService.error; setState(ViewState.Error); } else { + mapHospitalToBranchList(); setState(ViewState.Idle); } } + mapHospitalToBranchList(){ + branchesList!.clear(); + _hospitalService.hospitals.forEach((element) { + branchesList!.add({"facilityId": element.facilityId, "facilityName": element.facilityName}); + }); + } + Future getClinics(int projectId) async { setState(ViewState.BusyLocal); await _referralPatientService.getClinicsList(projectId); - await _referralPatientService.getProjectInfo(projectId); + // await _referralPatientService.getProjectInfo(projectId); if (_referralPatientService.hasError) { error = _referralPatientService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 2e97f957..62378baa 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -96,7 +96,7 @@ class _HomeScreenState extends State { } } }); - startZoom(); + // startZoom(); }); }, builder: (_, model, w) => AppScaffold( diff --git a/lib/screens/patients/profile/referral/refer_details/refer-patient-screen-in-patient.dart b/lib/screens/patients/profile/referral/refer_details/refer-patient-screen-in-patient.dart index 20a26ad5..8900aa77 100644 --- a/lib/screens/patients/profile/referral/refer_details/refer-patient-screen-in-patient.dart +++ b/lib/screens/patients/profile/referral/refer_details/refer-patient-screen-in-patient.dart @@ -230,24 +230,24 @@ class _PatientMakeInPatientReferralScreenState extends State GifLoaderDialogUtils.hideDialog(context)); if (model.state == ViewState.ErrorLocal) { DrAppToastMsg.showErrorToast(model.error); } - } else { - _selectedBranch = null; } - }); + );} else { + model.getBranches(); + } }); }, ); diff --git a/lib/screens/patients/profile/referral/refer_details/refer-patient-screen.dart b/lib/screens/patients/profile/referral/refer_details/refer-patient-screen.dart index d92a54f1..9105a076 100644 --- a/lib/screens/patients/profile/referral/refer_details/refer-patient-screen.dart +++ b/lib/screens/patients/profile/referral/refer_details/refer-patient-screen.dart @@ -187,6 +187,12 @@ class _PatientMakeReferralScreenState extends State { _selectedBranch = null; _selectedClinic = null; _selectedDoctor = null; + //handle the other branch data + if(_referTo['id'] == 2){ + + return; + } + model.getDoctorBranch().then((value) async { _selectedBranch = value; if (_referTo['id'] == 1) {