diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index ce00c085..9b77c0e4 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -18,19 +18,21 @@ import '../util/helpers.dart'; const GET_PATIENT_VITAL_SIGN = BASE_URL + 'Doctors.svc/REST/Doctor_GetPatientVitalSign'; -const GET_PATIENT_LAB_OREDERS =BASE_URL + 'DoctorApplication.svc/REST/GetPatientLabOreders'; -const GET_PRESCRIPTION =BASE_URL+'Patients.svc/REST/GetPrescriptionApptList'; -const GET_RADIOLOGY = BASE_URL+'DoctorApplication.svc/REST/GetPatientRadResult'; +const GET_PATIENT_LAB_OREDERS = + BASE_URL + 'DoctorApplication.svc/REST/GetPatientLabOreders'; +const GET_PRESCRIPTION = BASE_URL + 'Patients.svc/REST/GetPrescriptionApptList'; +const GET_RADIOLOGY = + BASE_URL + 'DoctorApplication.svc/REST/GetPatientRadResult'; + class PatientsProvider with ChangeNotifier { - bool isLoading = true; + bool isLoading = false; bool isError = false; String error = ''; List patientVitalSignList = []; - List patientLabResultOrdersList = []; - List patientPrescriptionsList = []; - List patientRadiologyList = []; + List patientLabResultOrdersList = []; + List patientPrescriptionsList = []; + List patientRadiologyList = []; - Client client = HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); @@ -87,6 +89,9 @@ class PatientsProvider with ChangeNotifier { *@desc: getPatientVitalSign */ getPatientVitalSign(patient) async { + isLoading = true; + notifyListeners(); + try { if (await Helpers.checkConnection()) { final response = await client.post(GET_PATIENT_VITAL_SIGN, @@ -138,6 +143,9 @@ class PatientsProvider with ChangeNotifier { *@desc: getLabResult Orders */ getLabResultOrders(patient) async { + isLoading = true; + notifyListeners(); + try { if (await Helpers.checkConnection()) { final response = await client.post(GET_PATIENT_LAB_OREDERS, @@ -179,11 +187,14 @@ class PatientsProvider with ChangeNotifier { *@return: *@desc: getPatientPrescriptions */ -getPatientPrescriptions(patient) async { + getPatientPrescriptions(patient) async { + isLoading = true; + notifyListeners(); + try { if (await Helpers.checkConnection()) { - final response = await client.post(GET_PRESCRIPTION, - body: json.encode(patient)); + final response = + await client.post(GET_PRESCRIPTION, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -197,7 +208,8 @@ getPatientPrescriptions(patient) async { patientPrescriptionsList = []; print("res['PatientPrescriptionList']"); res['PatientPrescriptionList'].forEach((v) { - patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v)); + patientPrescriptionsList + .add(new PrescriptionResModel.fromJson(v)); }); } else { isError = true; @@ -221,11 +233,13 @@ getPatientPrescriptions(patient) async { *@return: *@desc: getPatientRadiology */ -getPatientRadiology(patient) async { + getPatientRadiology(patient) async { + isLoading = true; + notifyListeners(); try { if (await Helpers.checkConnection()) { - final response = await client.post(GET_RADIOLOGY, - body: json.encode(patient)); + final response = + await client.post(GET_RADIOLOGY, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; @@ -239,7 +253,7 @@ getPatientRadiology(patient) async { patientRadiologyList = []; print("res['List_GetRadOreders']"); res['List_GetRadOreders'].forEach((v) { - patientRadiologyList.add(new RadiologyResModel .fromJson(v)); + patientRadiologyList.add(new RadiologyResModel.fromJson(v)); }); } else { isError = true; @@ -256,6 +270,4 @@ getPatientRadiology(patient) async { throw error; } } - - }