|
|
|
|
@ -11,6 +11,8 @@ abstract class PrescriptionsRepo {
|
|
|
|
|
Future<Either<Failure, GenericApiModel<List<PatientPrescriptionsResponseModel>>>> getPatientPrescriptionOrders({required String patientId});
|
|
|
|
|
|
|
|
|
|
Future<Either<Failure, GenericApiModel<List<PrescriptionDetailResponseModel>>>> getPatientPrescriptionDetails({required PatientPrescriptionsResponseModel prescriptionsResponseModel});
|
|
|
|
|
|
|
|
|
|
Future<Either<Failure, GenericApiModel<dynamic>>> getPrescriptionInstructionsPDF({required PatientPrescriptionsResponseModel prescriptionsResponseModel});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PrescriptionsRepoImp implements PrescriptionsRepo {
|
|
|
|
|
@ -107,4 +109,48 @@ class PrescriptionsRepoImp implements PrescriptionsRepo {
|
|
|
|
|
return Left(UnknownFailure(e.toString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<Either<Failure, GenericApiModel>> getPrescriptionInstructionsPDF({required PatientPrescriptionsResponseModel prescriptionsResponseModel}) async {
|
|
|
|
|
Map<String, dynamic> mapDevice = {
|
|
|
|
|
"AppointmentNo": prescriptionsResponseModel.appointmentNo.toString(),
|
|
|
|
|
"SetupID": prescriptionsResponseModel.setupID,
|
|
|
|
|
"ClinicID": prescriptionsResponseModel.clinicID.toString(),
|
|
|
|
|
"ProjectID": prescriptionsResponseModel.projectID.toString(),
|
|
|
|
|
"LocationID": "0",
|
|
|
|
|
"SalesInvoiceNo": "0",
|
|
|
|
|
"IsTest": false,
|
|
|
|
|
"ChannelID": "3",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
GenericApiModel<dynamic>? apiResponse;
|
|
|
|
|
Failure? failure;
|
|
|
|
|
await apiClient.post(
|
|
|
|
|
GET_PRESCRIPTION_INSTRUCTIONS_PDF,
|
|
|
|
|
body: mapDevice,
|
|
|
|
|
onFailure: (error, statusCode, {messageStatus, failureType}) {
|
|
|
|
|
failure = failureType;
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
|
|
|
|
|
try {
|
|
|
|
|
final prescriptionPDFURL = response["InvoiceUrl"];
|
|
|
|
|
apiResponse = GenericApiModel<dynamic>(
|
|
|
|
|
messageStatus: messageStatus,
|
|
|
|
|
statusCode: statusCode,
|
|
|
|
|
errorMessage: null,
|
|
|
|
|
data: prescriptionPDFURL,
|
|
|
|
|
);
|
|
|
|
|
} 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()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|