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.
doctor_app_flutter/lib/providers/patients_provider.dart

283 lines
9.7 KiB
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/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/get_list_stp_referral_frequency_request.dart';
import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.dart';
import 'package:doctor_app_flutter/models/patient/lab_result/lab_result.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/models/patient/prescription/prescription_report.dart';
import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.dart';
import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart';
import 'package:doctor_app_flutter/models/patient/radiology/radiology_res_model.dart';
import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
import 'package:flutter/cupertino.dart';
import '../config/config.dart';
import '../models/patient/lab_orders/lab_orders_res_model.dart';
import '../models/patient/patiant_info_model.dart';
import '../models/patient/patient_model.dart';
import '../models/patient/prescription/prescription_res_model.dart';
import '../models/patient/radiology/radiology_res_model.dart';
import '../models/patient/vital_sign/vital_sign_res_model.dart';
import '../util/helpers.dart';
Helpers helpers = Helpers();
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
class PatientsProvider with ChangeNotifier {
bool isLoading = false;
bool isError = false;
String error = '';
List<VitalSignResModel> patientVitalSignList = [];
List<VitalSignResModel> patientVitalSignOrderdSubList = [];
List<LabOrdersResModel> patientLabResultOrdersList = [];
List<PrescriptionResModel> patientPrescriptionsList = [];
List<RadiologyResModel> patientRadiologyList = [];
List<PrescriptionReportForInPatient> prescriptionReportForInPatientList = [];
List<PrescriptionReport> prescriptionReport = [];
BaseAppClient baseAppClient = BaseAppClient();
/*@author: ibrahe albitar
*@Date:2/6/2020
*@desc: getPatientPrescriptions
*/
List<LabResult> labResultList = [];
var patientProgressNoteList = [];
var insuranceApporvalsList = [];
var doctorsList = [];
var clinicsList = [];
var referalFrequancyList = [];
DoctorsByClinicIdRequest _doctorsByClinicIdRequest =
DoctorsByClinicIdRequest();
STPReferralFrequencyRequest _referralFrequencyRequest =
STPReferralFrequencyRequest();
ClinicByProjectIdRequest _clinicByProjectIdRequest =
ClinicByProjectIdRequest();
ReferToDoctorRequest _referToDoctorRequest;
PatiantInformtion _selectedPatient;
Future<dynamic> getPatientList(PatientModel patient, patientType) async {
int val = int.parse(patientType);
try {
dynamic localRes;
await baseAppClient.post(GET_PATIENT + 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
});
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
setBasicData() {
isLoading = true;
isError = false;
error = '';
notifyListeners();
}
/*@author: Elham Rababah
*@Date:12/5/2020
*@param: patient
*@return:
*@desc: getPatientRadiology
*/
handelCatchErrorCase(err) {
isLoading = false;
isError = true;
error = helpers.generateContactAdminMsg(err);
notifyListeners();
throw err;
}
// /*@author: ibrahem albitar
// *@Date:3/6/2020
// *@desc: getDoctorsList
// */
// getDoctorsList(String clinicId) async {
// 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) {
// isLoading = false;
// isError = true;
// this.error = error;
// }, body: _doctorsByClinicIdRequest.toJson());
// notifyListeners();
// } catch (err) {
// handelCatchErrorCase(err);
// }
// }
//
// List getDoctorNameList() {
// var doctorNamelist =
// doctorsList.map((value) => value['DoctorName'].toString()).toList();
// return doctorNamelist;
// }
//
// /*@author: ibrahem albitar
// *@Date:3/6/2020
// *@desc: getClinicsList
// */
// getClinicsList() async {
// setBasicData();
// try {
// 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;
// this.error = error;
// }, body: _clinicByProjectIdRequest.toJson());
// notifyListeners();
// } catch (err) {
// handelCatchErrorCase(err);
// }
// }
//
// List getClinicNameList() {
// var clinicsNameslist = clinicsList
// .map((value) => value['ClinicDescription'].toString())
// .toList();
// return clinicsNameslist;
// }
//
// /*@author: ibrahem albitar
// *@Date:3/6/2020
// *@desc: getReferralFrequancyList
// */
// getReferralFrequancyList() async {
// setBasicData();
// try {
// 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;
// this.error = error;
// }, body: _referralFrequencyRequest.toJson());
// notifyListeners();
// } catch (err) {
// handelCatchErrorCase(err);
// }
// }
//
// List getReferralNamesList() {
// var referralNamesList = referalFrequancyList
// .map((value) => value['Description'].toString())
// .toList();
// return referralNamesList;
// }
/*@author: ibrahem albitar
*@Date:3/6/2020
*@desc: referToDoctor
*/
// 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 {
// setBasicData();
// try {
// 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);
// await baseAppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
// onSuccess: (dynamic response, int statusCode) {
// // print('Done : \n $res');
// Navigator.pop(context);
// },
// onFailure: (String error, int statusCode) {
// isLoading = false;
// isError = true;
// this.error = error;
// },
// body: _referToDoctorRequest.toJson());
// notifyListeners();
//
// } catch (err) {
// handelCatchErrorCase(err);
// }
// }
}