|
|
|
|
@ -3,7 +3,9 @@ import 'dart:io';
|
|
|
|
|
import 'package:dartz/dartz.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/api/api_client.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/api_consts.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/enums.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_models/get_livecare_clinic_schedule_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_models/get_livecare_immediate_clinics_response_model.dart';
|
|
|
|
|
@ -11,6 +13,8 @@ import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_mode
|
|
|
|
|
import 'package:hmg_patient_app_new/features/immediate_livecare/models/resp_models/get_patient_livecare_history_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/logger_service.dart';
|
|
|
|
|
|
|
|
|
|
import '../../core/dependencies.dart';
|
|
|
|
|
|
|
|
|
|
abstract class ImmediateLiveCareRepo {
|
|
|
|
|
Future<Either<Failure, GenericApiModel<List<GetLiveCareClinicListResponseModel>>>> getLiveCareImmediateClinicsList(int age, int genderID, {Function(dynamic)? onSuccess, Function(String)? onError});
|
|
|
|
|
|
|
|
|
|
@ -28,6 +32,9 @@ abstract class ImmediateLiveCareRepo {
|
|
|
|
|
|
|
|
|
|
Future<Either<Failure, GenericApiModel<dynamic>>> addInsuranceUpdateRequestForLiveCare(String name, String mobileNumber, String fileNumber,
|
|
|
|
|
{Function(dynamic)? onSuccess, Function(String)? onError});
|
|
|
|
|
|
|
|
|
|
Future<Either<Failure, GenericApiModel<dynamic>>> rescheduleLiveCareCallRequest(int callID, int serviceID, String consultationTime, bool isRescheduledForOneHourLater,
|
|
|
|
|
{Function(dynamic)? onSuccess, Function(String)? onError});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ImmediateLiveCareRepoImp implements ImmediateLiveCareRepo {
|
|
|
|
|
@ -292,4 +299,51 @@ class ImmediateLiveCareRepoImp implements ImmediateLiveCareRepo {
|
|
|
|
|
return Left(UnknownFailure(e.toString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<Either<Failure, GenericApiModel>> rescheduleLiveCareCallRequest(int callID, int serviceID, String consultationTime, bool isRescheduledForOneHourLater,
|
|
|
|
|
{Function(dynamic p1)? onSuccess, Function(String p1)? onError}) async {
|
|
|
|
|
Map<String, dynamic> mapDevice = {
|
|
|
|
|
"VCID": callID,
|
|
|
|
|
"UserID": getIt.get<AppState>().getAuthenticatedUser()!.patientId,
|
|
|
|
|
"ServiceID": serviceID,
|
|
|
|
|
"consultationTime": consultationTime,
|
|
|
|
|
"Notes": isRescheduledForOneHourLater ? "Rescheduled by user for 1 hour later" : "Rescheduled by user for 30 mins later",
|
|
|
|
|
"ProjectID": getIt.get<AppState>().getAuthenticatedUser()!.outSa! == 0
|
|
|
|
|
? ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat
|
|
|
|
|
? 15
|
|
|
|
|
: 12
|
|
|
|
|
: 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
GenericApiModel<dynamic>? apiResponse;
|
|
|
|
|
Failure? failure;
|
|
|
|
|
await apiClient.post(
|
|
|
|
|
RESCHEDULE_LIVECARE_CALL,
|
|
|
|
|
body: mapDevice,
|
|
|
|
|
onFailure: (error, statusCode, {messageStatus, failureType}) {
|
|
|
|
|
failure = failureType;
|
|
|
|
|
// onError!(error);
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
|
|
|
|
|
try {
|
|
|
|
|
apiResponse = GenericApiModel<dynamic>(
|
|
|
|
|
messageStatus: messageStatus,
|
|
|
|
|
statusCode: statusCode,
|
|
|
|
|
errorMessage: null,
|
|
|
|
|
data: response,
|
|
|
|
|
);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
failure = DataParsingFailure(e.toString());
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
if (failure != null) return Left(failure!);
|
|
|
|
|
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
|
|
|
|
|
return Right(apiResponse!);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
return Left(UnknownFailure(e.toString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|