NEW: Patient Manager Provider Setup pt4
This commit is contained in:
@@ -2,10 +2,13 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patient_access.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mih_access_controlls_provider.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_services/mih_notification_services.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MihAccessControlsServices {
|
||||
@@ -32,6 +35,98 @@ class MihAccessControlsServices {
|
||||
}
|
||||
}
|
||||
|
||||
/// This function is used to create patient access and trigger notification to patient
|
||||
///
|
||||
/// Patameters:-
|
||||
/// String business_id,
|
||||
/// String app_id,
|
||||
/// String type,
|
||||
/// String requested_by,
|
||||
/// BuildContext context,
|
||||
///
|
||||
/// Returns void (triggers notification of success 201).
|
||||
static Future<void> addPatientAccessAPICall(
|
||||
String business_id,
|
||||
String app_id,
|
||||
String type,
|
||||
String requested_by,
|
||||
bool personalSelected,
|
||||
BusinessArguments args,
|
||||
BuildContext context,
|
||||
) async {
|
||||
var response = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/access-requests/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
// business_id: str
|
||||
// app_id: str
|
||||
// type: str
|
||||
// requested_by: str
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"business_id": business_id,
|
||||
"app_id": app_id,
|
||||
"type": type,
|
||||
"requested_by": requested_by,
|
||||
}),
|
||||
);
|
||||
if (response.statusCode == 201) {
|
||||
await MihNotificationApis.addAccessRequestNotificationAPICall(
|
||||
app_id, requested_by, personalSelected, args, context);
|
||||
} else {
|
||||
internetConnectionPopUp(context);
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 /mih-access ).
|
||||
static Future<void> reapplyPatientAccessAPICall(
|
||||
String business_id,
|
||||
String app_id,
|
||||
bool personalSelected,
|
||||
BusinessArguments args,
|
||||
BuildContext context,
|
||||
) async {
|
||||
var response = await http.put(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/access-requests/re-apply/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
// business_id: str
|
||||
// app_id: str
|
||||
// status: str
|
||||
// approved_by: str
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"business_id": business_id,
|
||||
"app_id": app_id,
|
||||
}),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
await MihNotificationApis.reapplyAccessRequestNotificationAPICall(
|
||||
app_id, personalSelected, args, context);
|
||||
//notification here
|
||||
} else {
|
||||
internetConnectionPopUp(context);
|
||||
}
|
||||
}
|
||||
|
||||
static void internetConnectionPopUp(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const MIHErrorMessage(
|
||||
errorType: "Internet Connection",
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// This function is used to UPDATE access the business has.
|
||||
///
|
||||
/// Patameters:-
|
||||
|
||||
Reference in New Issue
Block a user