-5

In our Sandbox Organization Apex Classes are written in year 2011. Please find below images and Apex Classes information and let me know about what is exactly they do in our organization with apex code.

Below is available Apex Classes Information.

Apex Classes

Below is Batch Apex Class “SubmitChecksBatch” Code:

global class SubmitChecksBatch implements Database.batchable<sObject>,Database.AllowsCallouts, Database.Stateful{

global Case cs;
global List<Fulfillment_History__c> toUpdateFulfillment = new List<Fulfillment_History__c>();
global List<Webservice_Call_Result__c> callLogs = new List<Webservice_Call_Result__c>();
global List<Task> failedCalls = new List<Task>();

global Boolean exceptionOccurred = false;
global String exceptionMessage;
global String exceptionTypeName;

global Database.QueryLocator start(Database.BatchableContext info){
  String query = 'Select Name, Case__c, Fulfillment_Type__c, Fulfillment_Workflow__c from Fulfillment_History__c';
  query += ' where Fulfillment_Status__c = \'Pending Request\' and Fulfillment_Type__c in (\'Check\')';
  if(UtilityClass.isBatchTestMethodExecution)
   query += ' order by createddate desc limit 1';
  return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext info, List<Fulfillment_History__c> toSubmitChecks){
  try {
   schemasDatacontractOrg200407Telerx.ClientCredentials clientCred = UtilityClass.getClientCredentials();
   tempuriOrg.BasicHttpBinding_ITlxCheckAndLetterProcessor processVar = new tempuriOrg.BasicHttpBinding_ITlxCheckAndLetterProcessor();
   schemasDatacontractOrg200407Telerx.SubmitCheckResponse submitCheckResponse = new schemasDatacontractOrg200407Telerx.SubmitCheckResponse();

   //Create the array of check requests
   schemasDatacontractOrg200407Telerx.ArrayOfCheckRequest chqReqArray = new schemasDatacontractOrg200407Telerx.ArrayOfCheckRequest();
   chqReqArray.CheckRequest = new List<schemasDatacontractOrg200407Telerx.CheckRequest>();

   Fulfillment_History__c fh = toSubmitChecks[0];

   // Get the Case information from the Fulfillment History record
   Case[] cases = [Select CaseNumber, RecordTypeId, Job__c, Product__c, Current_Fulfillment_Status__c, Fulfillment_Date__c, Claim_Status__c, Disposition__c, OwnerId, Calculated_Rebate__c, MEC_Transaction__c, Tax_ID__c,
    Account.Name, Practice_Address__c, Practice_Address_2__c, Practice_City__c, Practice_State__c, Practice_Zip__c,
    Patient_First_Name__c, Patient_Last_Name__c, Patient_Claim_Address_1__c, Patient_Claim_Address_2__c, Patient_Claim_City__c, State_of_Residence__c, Patient_Claim_Zip__c,
    Primary_Insured_First_Name__c, Primary_Insured_Last_Name__c, Primary_Insured_Address_1__c, Primary_Insured_Address_2__c, Primary_Insured_City__c, Primary_Insured_State__c, Primary_Insured_Zip__c from Case
    where Id = :fh.Case__c];

   cs = cases[0];
   String programCode;
   String caseTypeName;

   // Get the corresponding Job information for the Check and Letter Service Codes
         Jobs__c[] clsCodes = [Select Check_And_Letter_Service_Program_Code__c, Check_Type_Code__c from Jobs__c
              where Id = :cs.Job__c];

   Jobs__c clsCode = clsCodes[0];
   programCode = clsCode.Check_And_Letter_Service_Program_Code__c;

    // Create the Check Request to submit
   schemasDatacontractOrg200407Telerx.CheckRequest chqReqTemp = new schemasDatacontractOrg200407Telerx.CheckRequest();

   chqReqTemp.CheckRequestID = fh.Name;
   chqReqTemp.CheckType = clsCode.Check_Type_Code__c;
   chqReqTemp.CheckAmount = String.valueOf(cs.Calculated_Rebate__c);

   // Set the address of the correct Fulfillment Workflow type
   if(fh.Fulfillment_Workflow__c == 'Provider'){
    chqReqTemp.MailingAddressLine1 = cs.Practice_Address__c;
    chqReqTemp.MailingAddressLine2 = cs.Practice_Address_2__c;
    chqReqTemp.MailingAddressCity = cs.Practice_City__c;
    chqReqTemp.MailingAddressState = cs.Practice_State__c;
    chqReqTemp.MailingAddressPostalCode = cs.Practice_Zip__c;
    chqReqTemp.MailingName = cs.Account.Name;
    chqReqTemp.PayeeName = cs.Account.Name;

    // Create the array of custom fields
    schemasDatacontractOrg200407Telerx.ArrayOfCustomField customFieldArray = new schemasDatacontractOrg200407Telerx.ArrayOfCustomField();
    customFieldArray.CustomField = new List<schemasDatacontractOrg200407Telerx.CustomField>();

    // Pass the MEC Transaction ID. If there is no MEC Transaction ID on the Case then pass the Case Number.
    if(cs.MEC_Transaction__c != null)
     customFieldArray.CustomField.add(UtilityClass.createCustomWebServiceField('MEC_Transaction__c', cs.MEC_Transaction__c));
    else
     customFieldArray.CustomField.add(UtilityClass.createCustomWebServiceField('MEC_Transaction__c', cs.CaseNumber));

    // Pass the Tax ID if provided
    if(cs.Tax_ID__c != null)
     customFieldArray.CustomField.add(UtilityClass.createCustomWebServiceField('Tax_ID__c', cs.Tax_ID__c));

    chqReqTemp.CustomFields = customFieldArray;

   }
   else if(fh.Fulfillment_Workflow__c == 'Primary Insured'){
    chqReqTemp.MailingAddressLine1 = cs.Primary_Insured_Address_1__c;
    chqReqTemp.MailingAddressLine2 = cs.Primary_Insured_Address_2__c;
    chqReqTemp.MailingAddressCity = cs.Primary_Insured_City__c;
    chqReqTemp.MailingAddressState = cs.Primary_Insured_State__c;
    chqReqTemp.MailingAddressPostalCode = cs.Primary_Insured_Zip__c;
    chqReqTemp.MailingName = cs.Primary_Insured_First_Name__c + ' ' + cs.Primary_Insured_Last_Name__c;
    chqReqTemp.PayeeName = cs.Primary_Insured_First_Name__c + ' ' + cs.Primary_Insured_Last_Name__c;
   }
   else if(fh.Fulfillment_Workflow__c == 'Patient'){
    chqReqTemp.MailingAddressLine1 = cs.Patient_Claim_Address_1__c;
    chqReqTemp.MailingAddressLine2 = cs.Patient_Claim_Address_2__c;
    chqReqTemp.MailingAddressCity = cs.Patient_Claim_City__c;
    chqReqTemp.MailingAddressState = cs.State_of_Residence__c;
    chqReqTemp.MailingAddressPostalCode = cs.Patient_Claim_Zip__c;
    chqReqTemp.MailingName = cs.Patient_First_Name__c + ' ' + cs.Patient_Last_Name__c;
    chqReqTemp.PayeeName = cs.Patient_First_Name__c + ' ' + cs.Patient_Last_Name__c;
   }  

   // Add the check request to the array of check requests
   chqReqArray.CheckRequest.add(chqReqTemp);

   // This is used for the test classes since the test classes should not call out to the web service
   if(UtilityClass.isBatchTestMethodExecution) {
    submitCheckResponse.ResponseText = 'Successful Call';
    submitCheckResponse.ResponseCode = '000';
    submitCheckResponse.TransactionID = '123456789';
   }
   else {
    submitCheckResponse = processVar.submitChecks(clientCred, programCode, chqReqArray);
   }

   if(submitCheckResponse.ResponseCode == '000') {   
    cs.Current_Fulfillment_Status__c = 'Requested';
    cs.Fulfillment_Date__c = null;
    fh.Fulfillment_Status__c = 'Requested';
    fh.Date_Requested__c = datetime.now();
    update cs;
    toUpdateFulfillment.add(fh);
   }

   Webservice_Call_Result__c callLog = new Webservice_Call_Result__c();
   callLog.Case__c = cs.Id;
   callLog.Name = 'Submit Check';
   callLog.Response_Text__c = submitCheckResponse.ResponseText;
   callLog.Response_Code__c = submitCheckResponse.ResponseCode;
   callLog.Transaction_Id__c = submitCheckResponse.TransactionID;
   callLogs.add(callLog);

   // This is used for the test classes so we can test response codes other than '000' for creating a Task
   if(UtilityClass.isBatchTestMethodExecution) {
    submitCheckResponse.ResponseText = 'Failed Call';
    submitCheckResponse.ResponseCode = '300';
    submitCheckResponse.TransactionID = '123456789';
   }

   if(submitCheckResponse.ResponseCode != '000') {
    String taskDescription;
    if(submitCheckResponse.ResponseText != null)
        taskDescription += 'Response Text: ' + submitCheckResponse.ResponseText + '; ';
       if(submitCheckResponse.ResponseCode != null)
        taskDescription += 'Response Code: ' + submitCheckResponse.ResponseCode + '; ';
       if(submitCheckResponse.TransactionID != null)
        taskDescription += 'Transaction Id: ' + submitCheckResponse.TransactionID + '; ';

       UtilityClass.sendExceptionEmail('SubmitChecksBatch', 'Error while submitting checks for CaseNumber ' + cs.CaseNumber + '. ' + taskDescription, 'Failed Web Service Call');
    //Task tsk = UtilityClass.createTask(cs, 'Error while submitting check for the case. Please open a help desk ticket.', taskDescription, 'In Progress', 'High', 1, true);
       //failedCalls.add(tsk);
      }
  }
  catch(Exception ex) {
   exceptionOccurred = true;
   exceptionMessage = 'CaseNumber: ' + cs.CaseNumber + ' - ' + ex.getMessage();
   exceptionTypeName = ex.getTypeName();
  }
}

global void finish(Database.BatchableContext info){
  if(toUpdateFulfillment.size() > 0)
   update toUpdateFulfillment;
  if(callLogs.size() > 0)
   insert callLogs;
  if(failedCalls.size() > 0)
   insert failedCalls;
  if(exceptionOccurred)
   UtilityClass.sendExceptionEmail('Submit Check', exceptionMessage, exceptionTypeName);
}
}

Below is Schedule Apex Class “SubmitCheckSchedulableClass” Information

enter image description here

Above mentioned is Batch Class and Schedule Class in our Org. Please let me know information about above Batch and Schedule Class.

Thanks, Manu

2
  • Do you know Salesforce Apex? Most of the questions here show some level of efforts in their post before asking question. Your post seems like doing your job by us. OR do you have any specific reason why you can't understand these classes? Why would we read your 1000 line of code and tell you what they do.
    – Ashwani
    Jun 29, 2015 at 12:46
  • 1
    Just wondering what are you doing with these classes if you don't know Apex!
    – Ashwani
    Jun 29, 2015 at 13:04

1 Answer 1

0

This batch class integrate with an external system probably it is Telerx. It submit some check request and according to response Case record created in organisation also used object Jobs__c to get exact information about the code.

Once the check submitted successfully using the web-service it update the Webservice_Call_Result__c result and create task if there is any error some other action need to be done.

I hope this would make sense to you. I never logged in to your org.

2
  • Just posted the answer to save the org!
    – Ashwani
    Jun 29, 2015 at 13:11
  • Thanks Ashwani, Thanks alot for your inputs. How this batch class Integrate with other system, please let me know. I need information like What does it integrate to? What is the URL? What is the Webservice name, URL, credentials used? Jun 29, 2015 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .