RecalculateAdjustments(claimId, coverageId, RecalculateAdjustmentsInput)
Recalculate adjustments for existing payment details.
API Version
66.0
Requires Chatter
No
Signature
public static ConnectApi.CalculateAdjustmentsRepresentation RecalculateAdjustments(String claimId, String coverageId, ConnectApi.RecalculateAdjustmentsInputRep RecalculateAdjustmentsInput)
Parameters
- claimId
- Type: String
- ID of the claim for which the adjustments must be recalculated.
- coverageId
- Type: String
- ID of the claim coverage.
- RecalculateAdjustmentsInput
- Type: ConnectApi.RecalculateAdjustmentsInputRep
- Details to recalculate the adjustments.
Return Value
Example
- Class Definition
- This is a sample Apex code to define the RecalculateAdjustments class before you can call it from Apex to recalculate payment adjustments.
-
1 2public with sharing class RecalculateAdjustmentsCallable implements System.Callable { 3 4 public Object call(String action, Map<String, Object> args) { 5 // Retrieve the input and output maps from the arguments 6 Map<String, Object> inputMap = (Map<String, Object>) args.get('input'); 7 Map<String, Object> outputMap = (Map<String, Object>) args.get('output'); 8 9 // Check the action type 10 if (action == 'recalculateAdjustments') { 11 // Retrieve the required parameters from the input map 12 String claimId = (String) inputMap.get('claimId'); 13 String claimCoverageId = (String) inputMap.get('claimCoverageId'); 14 15 ConnectApi.RecalculateAdjustmentsInputRep recalculateAdjustmentInputRep = 16 (ConnectApi.RecalculateAdjustmentsInputRep) inputMap.get('RecalculateAdjustmentsInput'); 17 18 System.debug('Start of connect API call to recalculate adjustments'); 19 System.debug('Claim ID: ' + claimId); 20 System.debug('Claim Coverage ID: ' + claimCoverageId); 21 22 // Initialize the output representation 23 ConnectApi.CalculateAdjustmentsRepresentation reCalcAdjResponse; 24 25 // Call the Connect API to recalculate adjustments 26 try { 27 // Call the Connect API resource directly 28 // The endpoint is: /connect/insurance/claims/${claimId}/coverages/${coverageId}/recalculate-adjustments 29 reCalcAdjResponse = ConnectApi.InsuranceClaimFamily.RecalculateAdjustments( 30 recalculateAdjustmentInputRep, 31 claimId, 32 claimCoverageId 33 ); 34 35 System.debug('Recalculate adjustments completed successfully: ' + reCalcAdjResponse); 36 37 // Put the reCalcAdjResponse in the output map 38 outputMap.put('reCalcAdjResponse', reCalcAdjResponse); 39 outputMap.put('isSuccess', reCalcAdjResponse.isSuccess); 40 41 // Check if there are any errors 42 if (reCalcAdjResponse.errors != null && !reCalcAdjResponse.errors.isEmpty()) { 43 outputMap.put('errors', reCalcAdjResponse.errors); 44 System.debug('Errors found: ' + reCalcAdjResponse.errors); 45 } 46 } 47 catch (Exception e) { 48 System.debug('Error while recalculating adjustments: ' + e.getMessage()); 49 outputMap.put('error', e.getMessage()); 50 outputMap.put('isSuccess', false); 51 } 52 53 return reCalcAdjResponse; 54 } 55 56 // If the action is not recognized, return null 57 return null; 58 } 59} - Usage Example
- This example shows how to call the RecalculateAdjustmentsCallable class from Apex and include the required input data.
-
1RecalculateAdjustmentsCallable callable = new RecalculateAdjustmentsCallable(); 2 3// Prepare the input arguments 4Map<String, Object> input = new Map<String, Object>(); 5 6// Set the required parameters 7input.put('claimId', '0ZkSB0000001AVH0A2'); // Claim ID 8input.put('claimCoverageId', '0kPSB000000GHdu2AG'); 9 10// Create the input representation object 11// First create a Map with the properties 12Map<String, Object> recalculateAdjustmentInputMap = new Map<String, Object>(); 13recalculateAdjustmentInputMap.put('paymentDetailId', '0l2SB000000CLsMYAW'); 14recalculateAdjustmentInputMap.put('claimedAmount', 4252.35); 15 16// Convert the Map to ConnectApi.RecalculateAdjustmentsInputRep using JSON.deserialize 17String jsonString = JSON.serialize(recalculateAdjustmentInputMap); 18ConnectApi.RecalculateAdjustmentsInputRep recalculateAdjustmentInputRep = 19 (ConnectApi.RecalculateAdjustmentsInputRep) JSON.deserialize(jsonString, ConnectApi.RecalculateAdjustmentsInputRep.class); 20 21input.put('RecalculateAdjustmentsInput', recalculateAdjustmentInputRep); 22 23// Prepare the output map 24Map<String, Object> output = new Map<String, Object>(); 25 26// Prepare the args map 27Map<String, Object> args = new Map<String, Object>(); 28args.put('input', input); 29args.put('output', output); 30 31// Call the 'recalculateAdjustments' action 32Object result = callable.call('recalculateAdjustments', args); 33 34// Check the result 35if (result != null) { 36 System.debug('recalculateAdjustments processed successfully: ' + result); 37 38 // Access the processed adjustment data 39 ConnectApi.CalculateAdjustmentsRepresentation reCalcAdjResponse = 40 (ConnectApi.CalculateAdjustmentsRepresentation) result; 41 42 // Process the result as needed 43 System.debug('recalc Adjustment response: ' + reCalcAdjResponse); 44 45 // Check if the response was successful 46 if (reCalcAdjResponse.isSuccess) { 47 System.debug('recalculateAdjustment was successful'); 48 } else { 49 System.debug('recalculateAdjustment failed'); 50 if (reCalcAdjResponse.errors != null) { 51 System.debug('Error details: ' + reCalcAdjResponse.errors); 52 } 53 } 54} else { 55 System.debug('Error occurred: ' + output.get('error')); 56}