From c25e2d962990a964c92b55cd35605855d1b1e021 Mon Sep 17 00:00:00 2001 From: yaso Date: Mon, 18 Nov 2024 09:43:38 +0200 Subject: [PATCH] new api to reapply for access --- Frontend/lib/mih_apis/mih_api_calls.dart | 77 ++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/Frontend/lib/mih_apis/mih_api_calls.dart b/Frontend/lib/mih_apis/mih_api_calls.dart index 382c6bb6..5975b5b4 100644 --- a/Frontend/lib/mih_apis/mih_api_calls.dart +++ b/Frontend/lib/mih_apis/mih_api_calls.dart @@ -283,6 +283,42 @@ class MIHApiCalls { } } + /// This function is used to reapply for access to patient. + /// + /// Patameters:- + /// String business_id, + /// String app_id, + /// BuildContext context, + /// + /// Returns void (on success 200 navigate to /access-review ). + static Future reapplyPatientAccessAPICall( + String business_id, + String app_id, + BusinessArguments args, + BuildContext context, + ) async { + var response = await http.put( + Uri.parse("${AppEnviroment.baseApiUrl}/access-requests/re-apply/"), + headers: { + "Content-Type": "application/json; charset=UTF-8" + }, + // business_id: str + // app_id: str + // status: str + // approved_by: str + body: jsonEncode({ + "business_id": business_id, + "app_id": app_id, + }), + ); + if (response.statusCode == 200) { + reapplyAccessRequestNotificationAPICall(app_id, args, context); + //notification here + } else { + internetConnectionPopUp(context); + } + } + /// This function is used to create patient access and trigger notification to patient /// /// Patameters:- @@ -420,6 +456,47 @@ class MIHApiCalls { } } + /// This function is used to create notification to patient for access reviews + /// + /// Patameters:- + /// String app_id, + /// String business_name, + /// BuildContext context, + /// + /// Returns void. (ON SUCCESS 201 , NAVIGATE TO /patient-manager) + static Future reapplyAccessRequestNotificationAPICall( + String app_id, + BusinessArguments args, + BuildContext context, + ) async { + var response = await http.post( + Uri.parse("${AppEnviroment.baseApiUrl}/notifications/insert/"), + headers: { + "Content-Type": "application/json; charset=UTF-8" + }, + body: jsonEncode({ + "app_id": app_id, + "notification_type": "Re-applying for Access", + "notification_message": + "${args.business!.Name} is re-applying for access to your Patient Profile. Please review request.", + "action_path": "/access-review", + }), + ); + if (response.statusCode == 201) { + String message = + "A request has been sent to the patient advising that you have re-applied for access to their profile. Only once access has been granted will you be able to book an appointment."; + Navigator.of(context).pop(); + Navigator.of(context).pop(); + Navigator.of(context).pushNamed( + '/patient-manager', + arguments: args, + ); + successPopUp(message, context); + } else { + internetConnectionPopUp(context); + } + } + /// This function is used to create notification to patient for access reviews /// /// Patameters:-