You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
5.4 KiB
Dart
146 lines
5.4 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
|
import 'package:doctor_app_flutter/lookups/hospital_lookup.dart';
|
|
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.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/my_referred_patient_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/request_my_referral_patient_model.dart';
|
|
|
|
class PatientReferralService extends BaseService {
|
|
List<dynamic> projectsList = [];
|
|
List<dynamic> clinicsList = [];
|
|
List<dynamic> doctorsList = [];
|
|
List<MyReferredPatientModel> listMyReferredPatientModel = [];
|
|
List<PendingReferral> pendingReferralList = [];
|
|
|
|
Future getProjectsList() async {
|
|
hasError = false;
|
|
const url = GET_PROJECTS;
|
|
var info = {
|
|
"LanguageID": 1,
|
|
"stamp": "2020-02-26T13:51:44.111Z",
|
|
"IPAdress": "11.11.11.11",
|
|
"VersionID": 1.2,
|
|
"Channel": 9,
|
|
"TokenID": "",
|
|
"SessionID": "i1UJwCTSqt",
|
|
"IsLoginForDoctorApp": true
|
|
};
|
|
dynamic localRes;
|
|
|
|
await baseAppClient.post(url, onSuccess: (response, statusCode) async {
|
|
if (response['MessageStatus'] == 1) {
|
|
projectsList = response['ListProject'];
|
|
} else {
|
|
// handel error
|
|
projectsList = ListProject;
|
|
}
|
|
}, onFailure: (String error, int statusCode) {
|
|
projectsList = ListProject;
|
|
}, body: info);
|
|
}
|
|
|
|
Future getClinicsList(int projectId) async {
|
|
hasError = false;
|
|
ClinicByProjectIdRequest _clinicByProjectIdRequest =
|
|
ClinicByProjectIdRequest();
|
|
_clinicByProjectIdRequest.projectID = projectId;
|
|
|
|
await baseAppClient.post(
|
|
PATIENT_GET_CLINIC_BY_PROJECT_URL,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
clinicsList = [];
|
|
clinicsList = response['List_Clinic_All'];
|
|
print(response['List_Clinic_All']);
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: _clinicByProjectIdRequest.toJson(),
|
|
);
|
|
}
|
|
|
|
Future getDoctorsList(String clinicId) async {
|
|
hasError = false;
|
|
DoctorsByClinicIdRequest _doctorsByClinicIdRequest =
|
|
DoctorsByClinicIdRequest();
|
|
|
|
_doctorsByClinicIdRequest.clinicID = clinicId;
|
|
await baseAppClient.post(
|
|
PATIENT_GET_DOCTOR_BY_CLINIC_URL,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
doctorsList = [];
|
|
doctorsList = response['List_Doctors_All'];
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: _doctorsByClinicIdRequest.toJson(),
|
|
);
|
|
}
|
|
|
|
Future getMyReferredPatient() async {
|
|
hasError = false;
|
|
RequestMyReferralPatientModel _requestMyReferralPatient =
|
|
RequestMyReferralPatientModel();
|
|
DoctorProfileModel doctorProfile = await getDoctorProfile();
|
|
|
|
await baseAppClient.post(
|
|
GET_MY_REFERRED_PATIENT,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
listMyReferredPatientModel.clear();
|
|
|
|
response['List_MyReferredPatient'].forEach((v) {
|
|
MyReferredPatientModel item = MyReferredPatientModel.fromJson(v);
|
|
if (doctorProfile != null) {
|
|
item.isReferralDoctorSameBranch =
|
|
doctorProfile.projectID == item.projectId;
|
|
} else {
|
|
item.isReferralDoctorSameBranch = false;
|
|
}
|
|
listMyReferredPatientModel.add(item);
|
|
});
|
|
// print(response['List_MyReferredPatient']);
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: _requestMyReferralPatient.toJson(),
|
|
);
|
|
}
|
|
|
|
Future getPendingReferralList() async {
|
|
hasError = false;
|
|
DoctorProfileModel doctorProfile = await getDoctorProfile();
|
|
Map<String, dynamic> body = Map();
|
|
body['ClinicID'] = 0;
|
|
body['DoctorID'] = doctorProfile.doctorID;
|
|
body['VidaAuthTokenID'] =
|
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiYjVjZTZkZGEtNDA0OC00N2U4LWFhMmMtYmY5NDJiNjg0MGI0IiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODU1MDQiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODU1MDE2OSwiZXhwIjoxNjA5NDE0MTY5LCJpYXQiOjE2MDg1NTAxNjl9.mBoylGXXcfoeZcf61R2m7OfjRHnt8MmzLMG74VcotQ8";
|
|
|
|
await baseAppClient.post(
|
|
GET_PENDING_REFERRAL_PATIENT,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
pendingReferralList.clear();
|
|
|
|
response['PendingReferralList'].forEach((v) {
|
|
PendingReferral item = PendingReferral.fromJson(v);
|
|
item.isReferralDoctorSameBranch =
|
|
item.targetProjectId == item.sourceProjectId;
|
|
pendingReferralList.add(item);
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: body,
|
|
);
|
|
}
|
|
}
|