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

Return Value 

Type: ConnectApi.CalculateAdjustmentsRepresentation

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.

1public with sharing class RecalculateAdjustmentsCallable implements System.Callable {
2
3    public Object call(String action, Map<String, Object> args) {
4        // Retrieve the input and output maps from the arguments
5        Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
6        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
7
8        // Check the action type
9        if (action == 'recalculateAdjustments') {
10            // Retrieve the required parameters from the input map
11            String claimId = (String) inputMap.get('claimId');
12            String claimCoverageId = (String) inputMap.get('claimCoverageId');
13
14            ConnectApi.RecalculateAdjustmentsInputRep recalculateAdjustmentInputRep =
15                (ConnectApi.RecalculateAdjustmentsInputRep) inputMap.get('RecalculateAdjustmentsInput');
16
17            System.debug('Start of connect API call to recalculate adjustments');
18            System.debug('Claim ID: ' + claimId);
19            System.debug('Claim Coverage ID: ' + claimCoverageId);
20
21            // Initialize the output representation
22            ConnectApi.CalculateAdjustmentsRepresentation reCalcAdjResponse;
23
24            // Call the Connect API to recalculate adjustments
25            try {
26                // Call the Connect API resource directly
27                // The endpoint is: /connect/insurance/claims/${claimId}/coverages/${coverageId}/recalculate-adjustments
28                reCalcAdjResponse = ConnectApi.InsuranceClaimFamily.RecalculateAdjustments(
29                    recalculateAdjustmentInputRep,
30                    claimId,
31                    claimCoverageId
32                );
33
34                System.debug('Recalculate adjustments completed successfully: ' + reCalcAdjResponse);
35
36                // Put the reCalcAdjResponse in the output map
37                outputMap.put('reCalcAdjResponse', reCalcAdjResponse);
38                outputMap.put('isSuccess', reCalcAdjResponse.isSuccess);
39
40                // Check if there are any errors
41                if (reCalcAdjResponse.errors != null && !reCalcAdjResponse.errors.isEmpty()) {
42                    outputMap.put('errors', reCalcAdjResponse.errors);
43                    System.debug('Errors found: ' + reCalcAdjResponse.errors);
44                }
45            }
46            catch (Exception e) {
47                System.debug('Error while recalculating adjustments: ' + e.getMessage());
48                outputMap.put('error', e.getMessage());
49                outputMap.put('isSuccess', false);
50            }
51
52            return reCalcAdjResponse;
53        }
54
55        // If the action is not recognized, return null
56        return null;
57    }
58}

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}