|
|
|
|
@ -1,3 +1,6 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:doctor_app_flutter/client/app_client.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor_profile_model.dart';
|
|
|
|
|
@ -15,8 +18,12 @@ 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';
|
|
|
|
|
@ -60,47 +67,53 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
STPReferralFrequencyRequest();
|
|
|
|
|
ClinicByProjectIdRequest _clinicByProjectIdRequest =
|
|
|
|
|
ClinicByProjectIdRequest();
|
|
|
|
|
ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest();
|
|
|
|
|
ReferToDoctorRequest _referToDoctorRequest ;
|
|
|
|
|
Client client =
|
|
|
|
|
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
|
|
|
|
|
|
|
|
|
|
PatiantInformtion _selectedPatient;
|
|
|
|
|
|
|
|
|
|
Future<dynamic> getPatientList(PatientModel patient, patientType) async {
|
|
|
|
|
Future<Map> getPatientList(PatientModel patient, patientType) async {
|
|
|
|
|
/* const url =
|
|
|
|
|
BASE_URL+'DoctorApplication.svc/REST/GetMyInPatient';*/
|
|
|
|
|
|
|
|
|
|
int val = int.parse(patientType);
|
|
|
|
|
//**********Modify url by amjad amireh for patiant type*********
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
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,
|
|
|
|
|
"FirstName": patient.FirstName,
|
|
|
|
|
"MiddleName": patient.MiddleName,
|
|
|
|
|
"LastName": patient.LastName,
|
|
|
|
|
"PatientMobileNumber": patient.PatientMobileNumber,
|
|
|
|
|
"PatientIdentificationID": patient.PatientIdentificationID,
|
|
|
|
|
"PatientID": patient.PatientID,
|
|
|
|
|
"From": patient.From,
|
|
|
|
|
"To": patient.To,
|
|
|
|
|
"LanguageID": patient.LanguageID,
|
|
|
|
|
"stamp": patient.stamp,
|
|
|
|
|
"IPAdress": patient.IPAdress,
|
|
|
|
|
"VersionID": patient.VersionID,
|
|
|
|
|
"Channel": patient.Channel,
|
|
|
|
|
"TokenID": patient.TokenID,
|
|
|
|
|
"SessionID": patient.SessionID,
|
|
|
|
|
"IsLoginForDoctorApp": patient.IsLoginForDoctorApp,
|
|
|
|
|
"PatientOutSA": patient.PatientOutSA
|
|
|
|
|
});
|
|
|
|
|
final url =
|
|
|
|
|
BASE_URL + "DoctorApplication.svc/REST/" + SERVICES_PATIANT[val];
|
|
|
|
|
// print("a===========$url=======a");
|
|
|
|
|
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
print(error);
|
|
|
|
|
throw error;
|
|
|
|
|
try {
|
|
|
|
|
final response = await client.post(url,
|
|
|
|
|
body: json.encode({
|
|
|
|
|
"ProjectID": patient.ProjectID,
|
|
|
|
|
"ClinicID": patient.ClinicID,
|
|
|
|
|
"DoctorID": patient.DoctorID,
|
|
|
|
|
"FirstName": patient.FirstName,
|
|
|
|
|
"MiddleName": patient.MiddleName,
|
|
|
|
|
"LastName": patient.LastName,
|
|
|
|
|
"PatientMobileNumber": patient.PatientMobileNumber,
|
|
|
|
|
"PatientIdentificationID": patient.PatientIdentificationID,
|
|
|
|
|
"PatientID": patient.PatientID,
|
|
|
|
|
"From": patient.From,
|
|
|
|
|
"To": patient.To,
|
|
|
|
|
"LanguageID": patient.LanguageID,
|
|
|
|
|
"stamp": patient.stamp,
|
|
|
|
|
"IPAdress": patient.IPAdress,
|
|
|
|
|
"VersionID": patient.VersionID,
|
|
|
|
|
"Channel": patient.Channel,
|
|
|
|
|
"TokenID": patient.TokenID,
|
|
|
|
|
"SessionID": patient.SessionID,
|
|
|
|
|
"IsLoginForDoctorApp": patient.IsLoginForDoctorApp,
|
|
|
|
|
"PatientOutSA": patient.PatientOutSA
|
|
|
|
|
}));
|
|
|
|
|
//**********************
|
|
|
|
|
//***********************
|
|
|
|
|
|
|
|
|
|
return Future.value(json.decode(response.body));
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -122,38 +135,48 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
setBasicData();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(GET_PATIENT_VITAL_SIGN,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientVitalSignList = [];
|
|
|
|
|
response['List_DoctorPatientVitalSign'].forEach((v) {
|
|
|
|
|
patientVitalSignList.add(new VitalSignResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
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 (patientVitalSignList.length > 0) {
|
|
|
|
|
List<VitalSignResModel> patientVitalSignOrderdSubListTemp = [];
|
|
|
|
|
patientVitalSignOrderdSubListTemp = patientVitalSignList;
|
|
|
|
|
patientVitalSignOrderdSubListTemp
|
|
|
|
|
.sort((VitalSignResModel a, VitalSignResModel b) {
|
|
|
|
|
return b.vitalSignDate.microsecondsSinceEpoch -
|
|
|
|
|
a.vitalSignDate.microsecondsSinceEpoch;
|
|
|
|
|
});
|
|
|
|
|
patientVitalSignOrderdSubList.clear();
|
|
|
|
|
int length = patientVitalSignOrderdSubListTemp.length >= 20
|
|
|
|
|
? 20
|
|
|
|
|
: patientVitalSignOrderdSubListTemp.length;
|
|
|
|
|
for (int x = 0; x < length; x++) {
|
|
|
|
|
patientVitalSignOrderdSubList
|
|
|
|
|
.add(patientVitalSignOrderdSubListTemp[x]);
|
|
|
|
|
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) {
|
|
|
|
|
patientVitalSignList = [];
|
|
|
|
|
res['List_DoctorPatientVitalSign'].forEach((v) {
|
|
|
|
|
patientVitalSignList.add(new VitalSignResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (patientVitalSignList.length > 0) {
|
|
|
|
|
List<VitalSignResModel> patientVitalSignOrderdSubListTemp = [];
|
|
|
|
|
patientVitalSignOrderdSubListTemp = patientVitalSignList;
|
|
|
|
|
patientVitalSignOrderdSubListTemp
|
|
|
|
|
.sort((VitalSignResModel a, VitalSignResModel b) {
|
|
|
|
|
return b.vitalSignDate.microsecondsSinceEpoch -
|
|
|
|
|
a.vitalSignDate.microsecondsSinceEpoch;
|
|
|
|
|
});
|
|
|
|
|
patientVitalSignOrderdSubList.clear();
|
|
|
|
|
for (int x = 0; x < 20; x++) {
|
|
|
|
|
patientVitalSignOrderdSubList
|
|
|
|
|
.add(patientVitalSignOrderdSubListTemp[x]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -172,20 +195,33 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
setBasicData();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(GET_PATIENT_LAB_OREDERS,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientLabResultOrdersList = [];
|
|
|
|
|
response['List_GetLabOreders'].forEach((v) {
|
|
|
|
|
patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(GET_PATIENT_LAB_OREDERS,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
patientLabResultOrdersList = [];
|
|
|
|
|
res['List_GetLabOreders'].forEach((v) {
|
|
|
|
|
patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -200,21 +236,36 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*/
|
|
|
|
|
getOutPatientPrescriptions(patient) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(GET_PRESCRIPTION,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientPrescriptionsList = [];
|
|
|
|
|
response['PatientPrescriptionList'].forEach((v) {
|
|
|
|
|
patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response =
|
|
|
|
|
await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
patientPrescriptionsList = [];
|
|
|
|
|
res['PatientPrescriptionList'].forEach((v) {
|
|
|
|
|
patientPrescriptionsList
|
|
|
|
|
.add(new PrescriptionResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -298,20 +349,33 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(GET_RADIOLOGY,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientRadiologyList = [];
|
|
|
|
|
response['List_GetRadOreders'].forEach((v) {
|
|
|
|
|
patientRadiologyList.add(new RadiologyResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response =
|
|
|
|
|
await AppClient.post(GET_RADIOLOGY, body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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 = [];
|
|
|
|
|
res['List_GetRadOreders'].forEach((v) {
|
|
|
|
|
patientRadiologyList.add(new RadiologyResModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -345,17 +409,31 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
getPatientInsuranceApprovals(patient) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(PATIENT_INSURANCE_APPROVALS_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(PATIENT_INSURANCE_APPROVALS_URL,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -369,17 +447,30 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
getPatientProgressNote(patient) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(PATIENT_PROGRESS_NOTE_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
final response = await AppClient.post(PATIENT_PROGRESS_NOTE_URL,
|
|
|
|
|
body: json.encode(patient));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: patient);
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -391,23 +482,45 @@ 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 {
|
|
|
|
|
_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) {
|
|
|
|
|
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 {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _doctorsByClinicIdRequest.toJson());
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
isLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -422,19 +535,37 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*@desc: getClinicsList
|
|
|
|
|
*/
|
|
|
|
|
getClinicsList() async {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(PATIENT_GET_CLINIC_BY_PROJECT_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
clinicsList = response['List_Clinic_All'];
|
|
|
|
|
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;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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 {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _clinicByProjectIdRequest.toJson());
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -453,19 +584,33 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*@desc: getReferralFrequancyList
|
|
|
|
|
*/
|
|
|
|
|
getReferralFrequancyList() async {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
await BaseAppClient.post(PATIENT_GET_LIST_REFERAL_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
referalFrequancyList = response['list_STPReferralFrequency'];
|
|
|
|
|
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;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
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 {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _referralFrequencyRequest.toJson());
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
@ -483,48 +628,69 @@ class PatientsProvider with ChangeNotifier {
|
|
|
|
|
*@Date:3/6/2020
|
|
|
|
|
*@desc: referToDoctor
|
|
|
|
|
*/
|
|
|
|
|
referToDoctor(
|
|
|
|
|
int selectedDoctorID,
|
|
|
|
|
int selectedClinicID,
|
|
|
|
|
String selectedReferralFrequancyID,
|
|
|
|
|
referToDoctor(context,
|
|
|
|
|
{String selectedDoctorID,
|
|
|
|
|
String selectedClinicID,
|
|
|
|
|
int admissionNo,
|
|
|
|
|
String extension,
|
|
|
|
|
String doctorRemark) async {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
int projectID = await sharedPref.getInt(PROJECT_ID);
|
|
|
|
|
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile);
|
|
|
|
|
int doctorID = doctorProfile.doctorID;
|
|
|
|
|
int clinicId = doctorProfile.clinicID;
|
|
|
|
|
String priority,
|
|
|
|
|
String frequency,
|
|
|
|
|
String referringDoctorRemarks,
|
|
|
|
|
int patientID,
|
|
|
|
|
int patientTypeID,
|
|
|
|
|
String roomID,
|
|
|
|
|
int projectID}) async {
|
|
|
|
|
setBasicData();
|
|
|
|
|
try {
|
|
|
|
|
// _referToDoctorRequest.tokenID = token;
|
|
|
|
|
// _referToDoctorRequest.admissionNo = admissionNo;
|
|
|
|
|
// _referToDoctorRequest.projectID = projectID;
|
|
|
|
|
// _referToDoctorRequest.tokenID = token;
|
|
|
|
|
// _referToDoctorRequest.extension = extension;
|
|
|
|
|
// _referToDoctorRequest.frequency = selectedReferralFrequancyID;
|
|
|
|
|
// _referToDoctorRequest.patientID =
|
|
|
|
|
// _referToDoctorRequest.priority =
|
|
|
|
|
// _referToDoctorRequest.referralClinic =
|
|
|
|
|
// _referToDoctorRequest.referralDoctor =
|
|
|
|
|
// _referToDoctorRequest.referringDoctorRemarks =
|
|
|
|
|
// _referToDoctorRequest.roomID =
|
|
|
|
|
// _referToDoctorRequest.referringClinic =
|
|
|
|
|
// _referToDoctorRequest.referringDoctor =
|
|
|
|
|
|
|
|
|
|
await BaseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
|
|
|
|
|
if (await Helpers.checkConnection()) {
|
|
|
|
|
String token = await sharedPref.getString(TOKEN);
|
|
|
|
|
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
|
|
|
|
|
DoctorProfileModel doctorProfile =
|
|
|
|
|
new DoctorProfileModel.fromJson(profile);
|
|
|
|
|
int doctorID = doctorProfile.doctorID;
|
|
|
|
|
int clinicId = doctorProfile.clinicID;
|
|
|
|
|
_referToDoctorRequest = ReferToDoctorRequest(
|
|
|
|
|
projectID: projectID,
|
|
|
|
|
admissionNo: admissionNo,
|
|
|
|
|
roomID: roomID,
|
|
|
|
|
referralClinic: selectedClinicID.toString(),
|
|
|
|
|
referralDoctor: selectedDoctorID.toString(),
|
|
|
|
|
createdBy: doctorID,
|
|
|
|
|
editedBy: doctorID,
|
|
|
|
|
patientID: patientID,
|
|
|
|
|
patientTypeID: patientTypeID,
|
|
|
|
|
referringClinic: clinicId,
|
|
|
|
|
referringDoctor: doctorID,
|
|
|
|
|
referringDoctorRemarks: referringDoctorRemarks,
|
|
|
|
|
priority: priority,
|
|
|
|
|
frequency: frequency,
|
|
|
|
|
extension: extension,
|
|
|
|
|
tokenID: token);
|
|
|
|
|
|
|
|
|
|
final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
|
|
|
|
|
body: json.encode(_referToDoctorRequest));
|
|
|
|
|
final int statusCode = response.statusCode;
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = false;
|
|
|
|
|
this.error = '';
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
print('Done : \n $res');
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
} else {
|
|
|
|
|
isError = true;
|
|
|
|
|
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isLoading = false;
|
|
|
|
|
isError = true;
|
|
|
|
|
this.error = error;
|
|
|
|
|
}, body: _referralFrequencyRequest.toJson());
|
|
|
|
|
|
|
|
|
|
error = 'Please Check The Internet Connection';
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handelCatchErrorCase(err);
|
|
|
|
|
|