From 87d2489186755a447f290ee533990ec85c08fb3b Mon Sep 17 00:00:00 2001 From: yaso Date: Fri, 8 Nov 2024 14:46:24 +0200 Subject: [PATCH] add fetch personal appointments api --- .../lib/mih_apis/mih_api_calls.dart | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Frontend/patient_manager/lib/mih_apis/mih_api_calls.dart b/Frontend/patient_manager/lib/mih_apis/mih_api_calls.dart index 31eccd95..c098d0f0 100644 --- a/Frontend/patient_manager/lib/mih_apis/mih_api_calls.dart +++ b/Frontend/patient_manager/lib/mih_apis/mih_api_calls.dart @@ -550,13 +550,45 @@ class MIHApiCalls { /// Patameters: String date & business_id . /// /// Returns List. - static Future> fetchPatientQueue( + static Future> fetchBusinessAppointmentsAPICall( String date, String business_id, ) async { //print("Patien manager page: $endpoint"); final response = await http.get(Uri.parse( - "${AppEnviroment.baseApiUrl}/queue/appointments/business/$business_id")); + "${AppEnviroment.baseApiUrl}/queue/appointments/business/$business_id?date=$date")); + // print("Here"); + // print("Body: ${response.body}"); + // print("Code: ${response.statusCode}"); + // errorCode = response.statusCode.toString(); + // errorBody = response.body; + + if (response.statusCode == 200) { + //print("Here1"); + Iterable l = jsonDecode(response.body); + //print("Here2"); + List patientQueue = List.from( + l.map((model) => PatientQueue.fromJson(model))); + //print("Here3"); + //print(patientQueue); + return patientQueue; + } else { + throw Exception('failed to fatch patient queue'); + } + } + + /// This function is used to fetch a list of appointments for a doctors office for a date. + /// + /// Patameters: String date & business_id . + /// + /// Returns List. + static Future> fetchPersonalAppointmentsAPICall( + String date, + String app_id, + ) async { + //print("Patien manager page: $endpoint"); + final response = await http.get(Uri.parse( + "${AppEnviroment.baseApiUrl}/queue/appointments/personal/$app_id?date=$date")); // print("Here"); // print("Body: ${response.body}"); // print("Code: ${response.statusCode}");