|
|
|
@ -16,13 +16,10 @@ import 'package:doctor_app_flutter/models/patient/prescription_res_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/patient/radiology_res_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/prescription_report.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:http/http.dart';
|
|
|
|
|
import 'package:http_interceptor/http_client_with_interceptor.dart';
|
|
|
|
|
|
|
|
|
|
import '../client/app_client.dart';
|
|
|
|
|
import '../config/config.dart';
|
|
|
|
|
import '../interceptor/http_interceptor.dart';
|
|
|
|
|
import '../models/patient/lab_orders_res_model.dart';
|
|
|
|
|
import '../models/patient/patiant_info_model.dart';
|
|
|
|
|
import '../models/patient/patient_model.dart';
|
|
|
|
@ -32,6 +29,7 @@ import '../models/patient/vital_sign_res_model.dart';
|
|
|
|
|
import '../util/helpers.dart';
|
|
|
|
|
|
|
|
|
|
Helpers helpers = Helpers();
|
|
|
|
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
|
|
|
|
|
class PatientsProvider with ChangeNotifier {
|
|
|
|
|
bool isLoading = false;
|
|
|
|
@ -60,31 +58,26 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
var referalFrequancyList = [];
|
|
|
|
|
|
|
|
|
|
DoctorsByClinicIdRequest _doctorsByClinicIdRequest =
|
|
|
|
|
DoctorsByClinicIdRequest();
|
|
|
|
|
DoctorsByClinicIdRequest();
|
|
|
|
|
STPReferralFrequencyRequest _referralFrequencyRequest =
|
|
|
|
|
STPReferralFrequencyRequest();
|
|
|
|
|
STPReferralFrequencyRequest();
|
|
|
|
|
ClinicByProjectIdRequest _clinicByProjectIdRequest =
|
|
|
|
|
ClinicByProjectIdRequest();
|
|
|
|
|
ReferToDoctorRequest _referToDoctorRequest ;
|
|
|
|
|
Client client =
|
|
|
|
|
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
|
|
|
|
|
ClinicByProjectIdRequest();
|
|
|
|
|
ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest();
|
|
|
|
|
|
|
|
|
|
PatiantInformtion _selectedPatient;
|
|
|
|
|
|
|
|
|
|
Future<Map> getPatientList(PatientModel patient, patientType) async {
|
|
|
|
|
/* const url =
|
|
|
|
|
BASE_URL+'DoctorApplication.svc/REST/GetMyInPatient';*/
|
|
|
|
|
|
|
|
|
|
Future<dynamic> getPatientList(PatientModel patient, patientType) async {
|
|
|
|
|
int val = int.parse(patientType);
|
|
|
|
|
//**********Modify url by amjad amireh for patiant type*********
|
|
|
|
|
|
|
|
|
|
final url =
|
|
|
|
|
BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val];
|
|
|
|
|
// print("a===========$url=======a");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
final response = await client.post(url,
|
|
|
|
|
body: json.encode({
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await BaseAppClient.post('DoctorApplication.svc/REST/' + SERVICES_PATIANT[val],
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
}, body: {
|
|
|
|
|
"ProjectID": patient.ProjectID,
|
|
|
|
|
"ClinicID": patient.ClinicID,
|
|
|
|
|
"DoctorID": patient.DoctorID,
|
|
|
|
@ -105,13 +98,12 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
"SessionID": patient.SessionID,
|
|
|
|
|
"IsLoginForDoctorApp": patient.IsLoginForDoctorApp,
|
|
|
|
|
"PatientOutSA": patient.PatientOutSA
|
|
|
|
|
}));
|
|
|
|
|
//**********************
|
|
|
|
|
//***********************
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Future.value(json.decode(response.body));
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print(error);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -133,21 +125,10 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
setBasicData();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(GET_PATIENT_VITAL_SIGN,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
await BaseAppClient.post(GET_PATIENT_VITAL_SIGN,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientVitalSignList = [];
|
|
|
|
|
res['List_DoctorPatientVitalSign'].forEach((v) {
|
|
|
|
|
response['List_DoctorPatientVitalSign'].forEach((v) {
|
|
|
|
|
patientVitalSignList.add(new VitalSignResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -160,21 +141,22 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
a.vitalSignDate.microsecondsSinceEpoch;
|
|
|
|
|
});
|
|
|
|
|
patientVitalSignOrderdSubList.clear();
|
|
|
|
|
for (int x = 0; x < 20; x++) {
|
|
|
|
|
int length = patientVitalSignOrderdSubListTemp.length >= 20
|
|
|
|
|
? 20
|
|
|
|
|
: patientVitalSignOrderdSubListTemp.length;
|
|
|
|
|
for (int x = 0; x < length; x++) {
|
|
|
|
|
patientVitalSignOrderdSubList
|
|
|
|
|
.add(patientVitalSignOrderdSubListTemp[x]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -193,33 +175,20 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
setBasicData();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(GET_PATIENT_LAB_OREDERS,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
await BaseAppClient.post(GET_PATIENT_LAB_OREDERS,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientLabResultOrdersList = [];
|
|
|
|
|
res['List_GetLabOreders'].forEach((v) {
|
|
|
|
|
response['List_GetLabOreders'].forEach((v) {
|
|
|
|
|
patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -234,36 +203,21 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*/
|
|
|
|
|
getOutPatientPrescriptions(patient) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response =
|
|
|
|
|
await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
await BaseAppClient.post(GET_PRESCRIPTION,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientPrescriptionsList = [];
|
|
|
|
|
res['PatientPrescriptionList'].forEach((v) {
|
|
|
|
|
patientPrescriptionsList
|
|
|
|
|
.add(new PrescriptionResModel.fromJson(v));
|
|
|
|
|
response['PatientPrescriptionList'].forEach((v) {
|
|
|
|
|
patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -284,13 +238,13 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
await BaseAppClient.post(
|
|
|
|
|
'DoctorApplication.svc/REST/GetPrescriptionReportForInPatient',
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['List_PrescriptionReportForInPatient'].forEach((v) {
|
|
|
|
|
prescriptionReportForInPatientList
|
|
|
|
|
.add(PrescriptionReportForInPatient.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
isError = false;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
response['List_PrescriptionReportForInPatient'].forEach((v) {
|
|
|
|
|
prescriptionReportForInPatientList
|
|
|
|
|
.add(PrescriptionReportForInPatient.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
isError = false;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
this.error = error;
|
|
|
|
@ -309,16 +263,16 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
await BaseAppClient.post('Patients.svc/REST/GetPrescriptionReport',
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
response['ListPRM'].forEach((v) {
|
|
|
|
|
prescriptionReport.add(PrescriptionReport.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
isError = false;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: prescriptionReqModel);
|
|
|
|
|
response['ListPRM'].forEach((v) {
|
|
|
|
|
prescriptionReport.add(PrescriptionReport.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
isError = false;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: prescriptionReqModel);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -347,33 +301,20 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response =
|
|
|
|
|
await AppClient.post(GET_RADIOLOGY, body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
await BaseAppClient.post(GET_RADIOLOGY,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientRadiologyList = [];
|
|
|
|
|
res['List_GetRadOreders'].forEach((v) {
|
|
|
|
|
response['List_GetRadOreders'].forEach((v) {
|
|
|
|
|
patientRadiologyList.add(new RadiologyResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -391,47 +332,33 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
requestLabResult.patientTypeID = labOrdersResModel.patientType;
|
|
|
|
|
await BaseAppClient.post('DoctorApplication.svc/REST/GetPatientLabResults',
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
isError = false;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
response['List_GetLabNormal'].forEach((v) {
|
|
|
|
|
labResultList.add(new LabResult.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: requestLabResult.toJson());
|
|
|
|
|
isError = false;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
response['List_GetLabNormal'].forEach((v) {
|
|
|
|
|
labResultList.add(new LabResult.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isError = true;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: requestLabResult.toJson());
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getPatientInsuranceApprovals(patient) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
//patientRadiologyList = [];
|
|
|
|
|
insuranceApporvalsList = res['List_ApprovalMain_InPatient'];
|
|
|
|
|
} else {
|
|
|
|
|
await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -445,30 +372,17 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
getPatientProgressNote(patient) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
patientProgressNoteList = res['List_GetPregressNoteForInPatient'];
|
|
|
|
|
} else {
|
|
|
|
|
await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -480,51 +394,29 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*@desc: getDoctorsList
|
|
|
|
|
*/
|
|
|
|
|
getDoctorsList(String clinicId) async {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
_doctorsByClinicIdRequest.projectID = projectID;
|
|
|
|
|
_doctorsByClinicIdRequest.clinicID = clinicId;
|
|
|
|
|
_doctorsByClinicIdRequest.tokenID = token;
|
|
|
|
|
|
|
|
|
|
final response = await AppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL,
|
|
|
|
|
body: json.encode(_doctorsByClinicIdRequest));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
isLoading = false;
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
doctorsList = res['List_Doctors_All'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
} else {
|
|
|
|
|
_doctorsByClinicIdRequest.clinicID = clinicId;
|
|
|
|
|
await BaseAppClient.post(PATIENT_GET_DOCTOR_BY_CLINIC_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
doctorsList = response['List_Doctors_All'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _doctorsByClinicIdRequest.toJson());
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List getDoctorNameList() {
|
|
|
|
|
var doctorNamelist =
|
|
|
|
|
doctorsList.map((value) => value['DoctorName'].toString()).toList();
|
|
|
|
|
doctorsList.map((value) => value['DoctorName'].toString()).toList();
|
|
|
|
|
return doctorNamelist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -533,37 +425,19 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*@desc: getClinicsList
|
|
|
|
|
*/
|
|
|
|
|
getClinicsList() async {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
_clinicByProjectIdRequest.projectID = projectID;
|
|
|
|
|
_clinicByProjectIdRequest.tokenID = token;
|
|
|
|
|
|
|
|
|
|
final response = await AppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL,
|
|
|
|
|
body: json.encode(_clinicByProjectIdRequest));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
clinicsList = res['List_Clinic_All'];
|
|
|
|
|
} else {
|
|
|
|
|
await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
clinicsList = response['List_Clinic_All'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _clinicByProjectIdRequest.toJson());
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -582,33 +456,19 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*@desc: getReferralFrequancyList
|
|
|
|
|
*/
|
|
|
|
|
getReferralFrequancyList() async {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
_referralFrequencyRequest.tokenID = token;
|
|
|
|
|
final response = await AppClient.post(PATIENT_GET_LIST_REFERAL_URL,
|
|
|
|
|
body: json.encode(_referralFrequencyRequest));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400 || json == null) {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Error While Fetching data';
|
|
|
|
|
} else {
|
|
|
|
|
var res = json.decode(response.body);
|
|
|
|
|
print('$res');
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
referalFrequancyList = res['list_STPReferralFrequency'];
|
|
|
|
|
} else {
|
|
|
|
|
await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
referalFrequancyList = response['list_STPReferralFrequency'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _referralFrequencyRequest.toJson());
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
@ -628,23 +488,23 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*/
|
|
|
|
|
referToDoctor(context,
|
|
|
|
|
{String selectedDoctorID,
|
|
|
|
|
String selectedClinicID,
|
|
|
|
|
int admissionNo,
|
|
|
|
|
String extension,
|
|
|
|
|
String priority,
|
|
|
|
|
String frequency,
|
|
|
|
|
String referringDoctorRemarks,
|
|
|
|
|
int patientID,
|
|
|
|
|
int patientTypeID,
|
|
|
|
|
String roomID,
|
|
|
|
|
int projectID}) async {
|
|
|
|
|
String selectedClinicID,
|
|
|
|
|
int admissionNo,
|
|
|
|
|
String extension,
|
|
|
|
|
String priority,
|
|
|
|
|
String frequency,
|
|
|
|
|
String referringDoctorRemarks,
|
|
|
|
|
int patientID,
|
|
|
|
|
int patientTypeID,
|
|
|
|
|
String roomID,
|
|
|
|
|
int projectID}) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
DoctorProfileModel doctorProfile =
|
|
|
|
|
new DoctorProfileModel.fromJson(profile);
|
|
|
|
|
new DoctorProfileModel.fromJson(profile);
|
|
|
|
|
int doctorID = doctorProfile.doctorID;
|
|
|
|
|
int clinicId = doctorProfile.clinicID;
|
|
|
|
|
_referToDoctorRequest = ReferToDoctorRequest(
|
|
|
|
|