|
|
|
|
@ -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<ReferralService>();
|
|
|
|
|
|
|
|
|
|
HospitalsService _hospitalService = locator<HospitalsService>();
|
|
|
|
|
|
|
|
|
|
MyReferralInPatientService _myReferralService = locator<MyReferralInPatientService>();
|
|
|
|
|
|
|
|
|
|
DischargedPatientService _dischargedPatientService = locator<DischargedPatientService>();
|
|
|
|
|
|
|
|
|
|
List<DischargeReferralPatient> get myDischargeReferralPatient => _dischargedPatientService.myDischargeReferralPatients;
|
|
|
|
|
|
|
|
|
|
List<dynamic>? get branchesList => _referralPatientService.projectsList;
|
|
|
|
|
List<dynamic>? branchesList = [];
|
|
|
|
|
|
|
|
|
|
List<dynamic>? 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);
|
|
|
|
|
|