Skip to main content

Apex classes

This reference page provides information about the globally exposed Apex classes in Komodo Care Connect that you can reference and use.

The Account Search Interface (PJN_AccountSearchIntf) Apex class defines the necessary methods to implement a search handler for Account Search and is implemented by the class called in the Account Search Result (PJN_AccountSearchResult) constructor.

 global interface PJN_AccountSearchIntf

Methods

getAccountExternalIdField()

Description

Returns

This method returns the field on the Account record that contains the external ID that identifies the account in the external database system.

SObjectField

SObjectField getAccountExternalIdField()

insertAccountDetails(searchResult)

Description

Returns

This method inserts an account from an external database system into Komodo Care Connect by creating a new Account record and any related Contact Information (mvn__PJN_Contact_Information__c) records and then returns the ID of the local account.

Id

Id insertAccountDetails(PJN_AccountSearchResult searchResult)

Parameters

Type

Description

searchResult

PJN_AccountSearchResult

The search result from an external database system that is used to create a new Account record.

search(searchRequest)

Description

Returns

This method takes a search request to return a list of search results. The search request is an instance of the Account Search Request (PJN_AccountSearchRequest) class while the search results are instances of the Account Search Result (PJN_AccountSearchResult) class.

List<mvn.PJN_AccountSearchResult>

List<PJN_AccountSearchResult> search(PJN_AccountSearchRequest searchRequest)

Parameters

Type

Description

searchRequest

PJN_AccountSearchRequest

The Account Search Request (PJN_AccountSearchRequest) object representing the search that was performed.

The Account Search Request (PJN_AccountSearchRequest) Apex class represents a search performed in Account Search.

global with sharing class PJN_AccountSearchRequest

Methods

getAccountRecordTypeNames()

Description

Returns

This method returns a list of the API names of the Account record types that was requested as filters in Account Search.

Note

This method is exposed to simplify unit testing.

List<String>

global List<String> getAccountRecordTypeNames()

Example

List<String> accountRecordTypes = request.getAccountRecordTypeNames();

getIsPersonSearch()

Description

Returns

This method indicates whether or not the search was a Person Account search.

Boolean

global Boolean getIsPersonSearch()

Example

Boolean isPersonSearch = request.getIsPersonSearch();

getRequestedAccountRecordTypeDeveloperNames()

Description

Returns

This method returns a list of all of the requested Account record types to be searched.

List<String>

global List<String> getRequestedAccountRecordTypeDeveloperNames()

Example

List<String> requestedRecordTypes = request.getRequestedAccountRecordTypeDeveloperNames();
// the sample output could be PJN_Physician,MVN_Mastered_Physician

getSearchInfoByObjectType()

Description

Returns

This method returns a map of populated fields to values by SObjectType.

Map<ObjectType, Map<String, Object>>

global Map<SObjectType, Map<String, Object>> getSearchInfoByObjectType()

Example

// retrieve the searched information
Map<SObjectType, Map<String, Object>> searchInfoByObjectType = request.getSearchInfoByObjectType();

// parse out into separate maps 
Map<String, Object> populatedAccountFields = searchInfoByObjectType.get(Account.getSObjectType()); 
Map<String, Object> populatedContactInfoFields = searchInfoByObjectType.get(mvn__PJN_Contact_Information__c.getSObjectType());

setAccount(account)

Description

Returns

This method sets the Account record on the Account Search request.

Note

This method is exposed to simplify unit testing.

PJN_AccountSearchRequest

global PJN_AccountSearchRequest setAccount(Account account)

Example

request = request.setAccount(new Account(FirstName='james'));

setAccountRecordTypeNames(accountRecordTypeNames)

Description

Returns

This method specifies the list of Account record types to be searched.

Note

This method is exposed to simplify unit testing.

PJN_AccountSearchRequest

global PJN_AccountSearchRequest setAccountRecordTypeNames(List<String> accountRecordTypeNames)

Example

request = request.setAccountRecordTypeNames(new List<String>{'PJN_Patient', 'PJN_Consumer'});

setContactInfo(contactInfo)

Description

Returns

This method sets specific field values on a Contact Information (mvn__PJN_Contact_Information__c) record.

Note

This method is exposed to simplify unit testing.

PJN_AccountSearchRequest

global PJN_AccountSearchRequest setContactInfo(PJN_Contact_Information__c contactInfo)

Example

 request = request.setContactInfo(new mvn__PJN_Contact_Information__c(mvn__PJN_Phone__c='555-666-7777'));

setIsPersonSearch(isPersonSearch)

Description

Returns

This method specifies if the search is a Person Account search.

Note

This method is exposed to simplify unit testing.

Boolean

global PJN_AccountSearchRequest setIsPersonSearch(Boolean isPersonSearch)

Example

request = request.setIsPersonSearch(true);

The Account Search Result (PJN_AccountSearchResult) Apex class represents a single result returned from a search performed in Account Search.

global with sharing class PJN_AccountSearchResult

Note

The setter classes implement the builder pattern to allow chaining calls.

Constructor

PJN_AccountSearchResult(searchClass)

Description

This constructor initializes the class that will implement the Account Search Interface (mvn.PJN_AccountSearchIntf) class.

global PJN_AccountSearchResult(String searchClass)

Parameter

Type

Description

searchClass

String

The name of the class that will implement the Account Search Interface (mvn.PJN_AccountSearchIntf) class.

Methods

addContactInfos(contactInformation)

Description

Returns

This method adds contact information to the search result to be displayed.

mvn.PJN_AccountSearchResult

global PJN_AccountSearchResult addContactInfos(List<PJN_Contact_Information__c> contactInformation)

Parameters

Type

Description

contactInformation

List<PJN_Contact_Information__c>

The list of Contact Information (mvn__PJN_Contact_Information__c) records to be added to the search result.

Warning

The Record Type (RecordTypeId) field on each Contact Information record must be populated.

getAccount()

Description

Returns

This method returns the account that was set on the search result.

Account

global Account getAccount()

getAccountExternalId()

Description

Returns

This method returns the external ID of the record of an implementation of the Account Search Interface (mvn.PJN_AccountSearchIntf) from which the Account Search result was generated.

String

global String getAccountExternalId()

Example

Id extId = result.getAccountExternalId();

getAdditionalData(key)

Description

Returns

This method retrieves additional data from a search result that was stored via the setAdditionalData(key, additionalDataString) method.

String

global String getAdditionalData(String key)

Parameters

Type

Description

key

String

The key to retrieve the additional data that was stored.

getContactInfoByRecTypeId()

Warning

This method has been deprecated as of Komodo Care Connect V2.1.0.

Description

Returns

This method returns a list of Contact Information (mvn__PJN_Contact_Information__c) records mapped to their Contact Information record type ID.

Map<Id, List<mvn__PJN_Contact_Information__c>>

global Map<Id, List<PJN_Contact_Information__c>> getContactInfoByRecTypeId()

getContactInfos()

Description

Returns

This method returns the list of Contact Information (mvn__PJN_Contact_Information__c) records that was set on the search result. The returned list of contact information may not be in the same order as the list of records that was passed in.

List<mvn__PJN_Contact_Information__c>

global List<PJN_Contact_Information__c> getContactInfos()

setAccount(accountDetail)

Description

Returns

This method sets the account on the search result.

mvn.PJN_AccountSearchResult

global PJN_AccountSearchResult setAccount(Account accountDetail)

Parameters

Type

Description

accountDetail

Account

The Account record to be returned in the search result.

Warning

The Account Record Type (RecordTypeId) field on the Account record must be populated.

setAdditionalData(key, additionalDataString)

Description

Returns

This method stores additional data in a search result so that the data can be retrieved at a later time.

mvn.PJN_AccountSearchResult

global PJN_AccountSearchResult setAdditionalData(String key, String additionalDataString)

Parameters

Type

Description

key

String

The key to identify the additional data being stored.

additionalDataString

String

The additional data to be stored.

setSelectResultActionLabel(label)

Description

Returns

This method sets the label on the menu option that a user would click on to select the search result.

mvn.PJN_AccountSearchResult

global PJN_AccountSearchResult setSelectResultActionLabel(String label)

Parameters

Type

Description

label

String

The label of the menu option that selects the (external) search result. By default, this is "Select Account" when a user is relating an account to a Case record.

setViewResultActionLabel(label)

Description

Returns

This method sets the label on the menu option that a user would click on to view the (external) search result.

mvn.PJN_AccountSearchResult

global PJN_AccountSearchResult setViewResultActionLabel(String label)

Parameters

Type

Description

label

String

The label of the menu option that opens the (external) search result. By default, this is "View Details" when a user is searching for an account.

Example

This example demonstrates how to call and use the Account Search Result class and methods with a sample Account Search Interface (PJN_AccountSearchIntf) implementation called PJN_AccountSearchDemoHdlr.

List<mvn.PJN_AccountSearchResult> results = new List<mvn.PJN_AccountSearchResult>(); 

Account resultAccount = buildAccount(); 
List<mvn.PJN_Contact_Information__c> resultAccount = buildContactInfos(); 

results.add( 
     new mvn.PJN_AccountSearchResult('PJN_AccountSearchDemoHdlr') 
         .setAccount(resultAccount) 
         .addContactInfos(resultAccount) 
         .setViewResultActionLabel('Download External Physician') 
         .setSelectResultActionLabel('Select External Physician') 
);

The Care Plan Activity Service (PJN_CarePlanActivityService) global Apex class enables users to automatically create new activities via a trigger in a flow or via a batch job. For example, it can be used in a flow such that a time-based trigger on a record on a care plan automatically creates a new activity before an upcoming deadline. This global Apex class contains both an invocable method and an inner class with invocable variables. Reference the Activity Request (ActivityRequest) inner class for more information.

global with sharing class PJN_CarePlanActivityService

Method

createActivities(activityRequests)

Description

Returns

This invocable method generates Activity (Case) records from a list of activity requests.

List<Case>

@InvocableMethod
global static List<Case> createActivities(List<ActivityRequest> activityRequests)

Parameter

Type

Description

activityRequests

List<ActivityRequest>

The list of activity requests. Reference Activity Request (ActivityRequest).

Example

This example demonstrates how to call and use the Care Plan Activity Service, including the Activity Request inner class.

mvn.PJN_CarePlanActivityService.ActivityRequest request = new mvn.PJN_CarePlanActivityService.ActivityRequest() 
    .setCarePlanId(carePlan.Id) 
    .setDescription('Activity Description') 
    .setDueDate(Date.today().addDays(30)) 
    .setOrigin('Email') 
    .setOwnerId(carePlan.ownerId) 
    .setPriority('High') 
    .setSubject('Activity Subject') 
    .setType('Outbound') 
    .setStatus('Open') 
    .createOnly(); // don't insert records 

List<mvn.PJN_CarePlanActivityService> requests = new List<mvn.PJN_CarePlanActivityService>(); 
requests.add(request); 
List<Case> activities = mvn.PJN_CarePlanActivityService.createActivities(requests); 
 
activities[0].CUST_custom_field__c = 'my custom value'; 
insert activities;

The Activity Request (ActivityRequest) inner class for the Care Plan Activity Service (PJN_CarePlanActivityService) global Apex class represents a request to create an activity.

global class ActivityRequest

Properties

Name

Type

Required?

Description

carePlanId

Id

The ID of the parent care plan.

description

String

The description to set on the activity.

dueDate

Date

The due date to set on the activity.

insertActivity

Boolean

Indicates whether the activity should be inserted (true) or just created in memory (false). The default value is true.

origin

String

The origin to set on the activity.

ownerId

Id

The owner ID to set on the activity. If not provided, the value will be the care plan owner.

parentAccountId

Id

The account ID to set on the activity. If not provided, the value will be the care plan account.

priority

String

The priority to set on the activity.

recordTypeDeveloperName

String

The API name of the Case record type of the activity to be created. If not provided, the record type will be PJN_Activity.

status

String

The status to set on the activity.

subject

String

The subject to set on the activity.

type

String

The type to set on the activity.

Methods

createOnly()

Description

Returns

This method marks the activity request as an in-memory creation request only and therefore does not insert the activity.

ActivityRequest

global ActivityRequest createOnly()

setCarePlanId(carePlanId)

Description

Returns

This method sets the parent care plan ID for the activity.

ActivityRequest

global ActivityRequest setCarePlanId(Id carePlanId)

Parameter

Type

Description

carePlanId

Id

The ID of the parent Care Plan (Case) record of the activity to be created.

setDescription(description)

Description

Returns

This method sets the description of the activity.

ActivityRequest

global ActivityRequest setDescription(String description)

Parameter

Type

Description

description

String

The description of the activity to be created.

setDueDate(dueDate)

Description

Returns

This method sets the due date of the activity.

ActivityRequest

global ActivityRequest setDueDate(Date dueDate)

Parameter

Type

Description

dueDate

Date

The due date of the activity to be created.

setOrigin(origin)

Description

Returns

This method sets the origin of the activity.

ActivityRequest

global ActivityRequest setOrigin(String origin)

Parameter

Type

Description

origin

String

The origin of the activity to be created.

setOwnerId(ownerId)

Description

Returns

This method sets the owner ID of the activity.

ActivityRequest

global ActivityRequest setOwnerId(Id ownerId)

Parameter

Type

Description

ownerId

Id

The ID of the Owner (User or Group) record of the activity to be created. If none is provided, the owner of the Care Plan (Case) record is used by default.

setParentAccountId(parentAccountId)

Description

Returns

This method sets the related account ID of the activity.

ActivityRequest

global ActivityRequest setParentAccountId(Id parentAccountId)

Parameter

Type

Description

parentAccountId

Id

The ID of the related Account record of the activity to be created.

setPriority(priority)

Description

Returns

This method sets the priority of the activity.

ActivityRequest

global ActivityRequest setPriority(String priority)

Parameter

Type

Description

priority

String

The priority level of the activity to be created.

setRecordType(recordTypeDeveloperName)

Description

Returns

This method sets the record type of the activity.

ActivityRequest

global ActivityRequest setRecordType(String recordTypeDeveloperName)

Parameter

Type

Description

recordTypeDeveloperName

String

The API name of the Case record type to be created. If none is provided, PJN_Activity is used by default.

setStatus(status)

Description

Returns

This method sets the status of the activity.

ActivityRequest

global ActivityRequest setStatus(String status)

Parameter

Type

Description

status

String

The status of the activity to be created.

setSubject(subject)

Description

Returns

This method sets the subject of the activity.

ActivityRequest

global ActivityRequest setSubject(String subject)

Parameter

Type

Description

subject

String

The subject of the activity to be created.

setType(type)

Description

Returns

This method sets the type of activity.

ActivityRequest

global ActivityRequest setType(String type)

Parameter

Type

Description

type

String

The type of activity to be created.

The Data Change Request Criteria Selector (PJN_DataChangeRequestCriteriaSelector) global Apex class is a selector for the Data Change Request Criteria (mvn__PJN_Data_Change_Request_Criteria__mdt) custom metadata type. It can be used with the Data Change Request Field Selector (PJN_DataChangeRequestFieldSelector) global Apex class to mock the configuration of the data change request (DCR) framework in unit tests.

global with sharing class PJN_DataChangeRequestCriteriaSelector

Methods

setCriteriaForSObject(sObjectName, criteria)

Description

Returns

This method sets the criteria to be returned for a given sObject.

Warning

This method can only be used during test execution.

void

global static void setCriteriaForSObject(String sObjectName, List<PJN_Data_Change_Request_Criteria__mdt> criteria)

Parameter

Type

Description

sObjectName

String

The API name of the sObject to be tracked.

criteria

List<PJN_Data_Change_Request_Criteria__mdt>

The list of mock Data Change Request Criteria (mvn__PJN_Data_Change_Request_Criteria__mdt) metadata records.

Example

This example demonstrates how to call and use the Data Change Request Criteria Selector Apex class.

mvn.PJN_DataChangeRequestCriteriaSelector.setCriteriaForSObject( 
    'Account', 
    new List<mvn__PJN_Data_Change_Request_Criteria__mdt>{ 
        new mvn__PJN_Data_Change_Request_Criteria__mdt(...) 
    } 
);

The Data Change Request Field Selector (PJN_DataChangeRequestFieldSelector) global Apex class is a selector for the Data Change Request Field (mvn__PJN_Data_Change_Request_Field__mdt) custom metadata type. It can be used with the Data Change Request Criteria Selector (PJN_DataChangeRequestCriteriaSelector) global Apex class to mock the configuration of the data change request (DCR) framework in unit tests.

global with sharing class PJN_DataChangeRequestFieldSelector

Methods

setFieldsForCriteriaId(criteriaId, fields)

Description

Returns

This method sets the fields to be returned for a given data change request criteria.

Warning

This method can only be used during test execution.

void

global static void setFieldsForCriteriaId(Id criteriaId, List<PJN_Data_Change_Request_Field__mdt> fields)

Parameter

Type

Description

criteriaId

Id

The ID of the parent Data Change Request Criteria (mvn__PJN_Data_Change_Request_Criteria__mdt) metadata record.

fields

List<PJN_Data_Change_Request_Field__mdt>

The list of mock Data Change Request Field (mvn__PJN_Data_Change_Request_Field__mdt) metadata records.

Example

This example demonstrates how to call and use the Data Change Request Field Selector Apex class.

mvn.PJN_DataChangeRequestFieldSelector.setFieldsForCriteriaId( 
    'fakeCriteriaId', 
    new List<mvn__PJN_Data_Change_Request_Field__mdt>{ 
        new mvn__PJN_Data_Change_Request_Field__mdt(mvn__PJN_Field_API_Name__c = 'fakeField') 
    } 
);

The Data Change Request Handler (PJN_DataChangeRequestHdlr) global Apex class implements the Trigger Dispatcher Handler Interface (PJN_TriggerDispatcher.HandlerInterface) to manage the data change request (DCR) framework and create Data Change Request (mvn__PJN_Data_Change_Request__c) records accordingly. For more information, reference Data change requests (DCR).

global with sharing class PJN_DataChangeRequestHdlr

Methods

setEnabled(enabled)

Description

Returns

This method controls whether or not the DCR framework is active.

void

global static void setEnabled(Boolean enabled)

Parameter

Type

Description

enabled

Boolean

When true, as it is by default, the DCR framework is enabled and active.

The ePA Request (PJN_EpaRequest) Apex class provides an API for generating a JSON string and creating a Prior Authorization (mvn__PJN_Prior_Authorization__c) record on a Member Plan (mvn__PJN_Member_Plan__c) record. This is used for the electronic prior authorization (ePA) functionality.

global with sharing class PJN_EpaRequest

Constructor

PJN_EpaRequest(memberPlanId)

Description

This constructor generates a new ePA request for a specific Member Plan (mvn__PJN_Member_Plan__c) record. It expects that a single Interface Handler (mvn__Interface_Handler__mdt) metadata record has been configured for the ePA Vendor API Interface (PJN_EpaVendorApiIntf) and whose program developer name matches that of the parent care plan.

global PJN_EpaRequest(Id memberPlanId)

Parameter

Type

Description

memberPlanId

Id

The ID of the Member Plan (mvn__PJN_Member_Plan__c) record.

Exception

mvn.PJN_EpaRequest.PJN_EpaRequestException

Methods

addValueAtKeyPath(keyPathString, value)

Description

Returns

This method formats the data to be sent to the ePA vendor into keys and values in accordance with the vendor's JSON structure.

PJN_EpaRequest

global PJN_EpaRequest addValueAtKeyPath(String keyPathString, String value)

Parameter

Type

Description

keyPathString

String

The vendor's JSON key or path at which the value should be stored.

value

String

The data or value to be stored.

Example

 new PJN_EpaRequest('03x000000000123').addValueAtKeyPath('patient.firstName', 'James');

generateEpaRequest()

Description

Returns

This method returns a Prior Authorization (mvn__PJN_Prior_Authorization__c) record for the parent Member Plan (mvn__PJN_Member_Plan__c) record with the following stamped values:

Field label

Stamped value

Member Plan

The parent Member Plan record.

Submitted Date

Today's date.

Status

Pending

Vendor Name

The vendor's name.

Request JSON

The serialized JSON string containing the formatted keys and values.

mvn__PJN_Prior_Authorization__c

global mvn__PJN_Prior_Authorization__c generateEpaRequest()

getMappings()

Description

Returns

This method returns the current map of the key-value pairs that has been built.

Map<String, Object>

global Map<String, Object> getMappings()

Example

This example demonstrates how to call and use the ePA Request class.

mvn__Prior_Authorization__c pa = new PJN_EpaRequest('03x000000000123') 
     .addValueAtKeyPath('patient.firstName', 'James') 
     .addValueAtKeyPath('patient.lastName', 'Dean') 
     .addValueAtKeyPath('memberPlan.Id', '23456') 
     .addValueAtKeyPath('memberPlan.Group', 'x34th') 
     .generateEpaRequest();

This generates the following JSON string:

{
    "patient": {
        "firstName": "James",
        "lastName": "Dean"
    },
    "memberPlan": {
        "Id": "23456",
        "Group": "x34th"
    }
}

The ePA Response (PJN_EpaResponse) Apex class is a wrapper class to update a Prior Authorization (mvn__PJN_Prior_Authorization__c) record with a vendor's response to an ePA request. This is used for the electronic prior authorization (ePA) functionality.

global with sharing class PJN_EpaResponse

Constructor

PJN_EpaResponse()

Description

This constructor generates a new ePA response.

global PJN_EpaResponse()

Methods

approved(effectiveDate, expirationDate)

Description

Returns

This method should be used for when a vendor approves an ePA request and sets the the following values on the generated Prior Authorization (mvn__PJN_Prior_Authorization__c) record:

Field label

Stamped value

Effective Date

The effectiveDate value.

Expiration Date

The expirationDate value.

Outcome

Approved

Status

Completed

PJN_EpaResponse

global PJN_EpaResponse approved(Date effectiveDate, Date expirationDate)

Parameter

Type

Description

effectiveDate

Date

The date that the prior authorization is effective from.

expirationDate

Date

The date that the prior authorization expires.

decisionDate(decisionDate)

Description

Returns

This method sets the date that the vendor either approved or denied the ePA request on the generated Prior Authorization (mvn__PJN_Prior_Authorization__c) record.

Field label

Stamped value

Decision Date

The decisionDate value.

PJN_EpaResponse

global PJN_EpaResponse decisionDate(Date decisionDate)

Parameter

Type

Description

decisionDate

Date

The date that the prior authorization outcome was made.

denied(denialReasons)

Description

Returns

This method should be used for when a vendor denies an ePA request and sets the the following values on the generated Prior Authorization (mvn__PJN_Prior_Authorization__c) record:

Field label

Stamped value

Denial Reason

The denialReasons value.

Outcome

Denied

Status

Completed

PJN_EpaResponse

global PJN_EpaResponse denied(String denialReasons)

Parameter

Type

Description

denialReasons

String

The list of reasons that the prior authorization was denied. Each reason should be separated with a semicolon (;).

getPriorAuthForUpdate()

Description

Returns

This method returns the generated Prior Authorization (mvn__PJN_Prior_Authorization__c) record to be updated in the database. No ID or external ID is set.

mvn__PJN_Prior_Authorization__c

global mvn__PJN_Prior_Authorization__c getPriorAuthForUpdate()

responseJSON(responseJSON)

Description

Returns

This method sets the response JSON on the generated Prior Authorization (mvn__PJN_Prior_Authorization__c) record.

Field label

Stamped value

Response JSON

The responseJSON string.

PJN_EpaResponse

global PJN_EpaResponse responseJSON(String responseJSON)

Parameter

Type

Description

responseJSON

String

The JSON payload value that the vendor returned.

Example

This example demonstrates how to call and use the ePA Response class.

mvn__Prior_Authorization__c pa = new PJN_EpaResponse() 
     .approved(Date.today(), Date.today().addDays(21)) 
     .decisionDate(Date.today()) 
     .responseJSON(jsonValue) 
     .getPriorAuthForUpdate();

If the current day is November 1, 2023, this stamps the following values on the designated Prior Authorization (mvn__PJN_Prior_Authorization__c) record:

Field label

Stamped value

Effective date

11/01/2023

Expiration date

11/22/2023

Decision date

11/01/2023

Outcome

Approved

Status

Completed

The ePA Vendor API Interface (PJN_EpaVendorApiIntf) Apex class handles a vendor implementation for the electronic prior authorization (ePA) functionality.

global interface PJN_EpaVendorApiIntf

Methods

getVendorName()

Description

Returns

Implement this method so that it returns the name of the vendor that the implementation is for. The vendor name is then stamped on the Prior Authorization (mvn__PJN_Prior_Authorization__c) record that is created.

String

String getVendorName()

submit(memberPlanId)

Description

Returns

Implement this method so that it accepts the ID of a Member Plan (mvn__PJN_Member_Plan__c) record and returns a Prior Authorization (mvn__PJN_Prior_Authorization__c) record for the member plan.

mvn__PJN_Prior_Authorization__c

mvn__PJN_Prior_Authorization__c submit(Id memberPlanId)

Parameter

Type

Description

memberPlanId

Id

The ID of the Member Plan (mvn__PJN_Member_Plan__c) record.

The Lead Convert Service (PJN_LeadConvertService) global Apex class enables users to convert Lead records into Person Account records via a flow or from the PJN_LeadSearchHdlr handler. This global Apex class contains both an invocable method and an inner class with invocable variables. Reference the Lead Convert Request (LeadConvertRequest) inner class for more information.

global with sharing class PJN_LeadConvertService

Methods

convertLead (leadId)

Description

Returns

This method converts a lead into an account by taking a Lead record and returning a new Person Account record.

Id

global static Id convertLead(Id leadId)

Parameter

Type

Description

leadId

Id

The single Lead record to be converted.

convertLeads(requests)

Description

Returns

This invocable method converts leads into accounts by taking a list of Lead records and returning a list of new Person Account records.

Warning

This method has a bulk convert limit of 100 records.

List<Id>

@InvocableMethod(
    label='KCC Lead Convert Service'
    description='Passing lead ids into this service will convert them to person accounts. Returns new AccountIds'
    )
global static List<Id> convertLeads(List<LeadConvertRequest> requests)

Parameter

Type

Description

requests

List<LeadConvertRequest>

The list of Lead records to be converted. Reference Lead Convert Request (LeadConvertRequest).

The Lead Convert Request (LeadConvertRequest) inner class for the Lead Convert Service (PJN_LeadConvertService) global Apex class represents a Lead record to process.

global class LeadConvertRequest

Property

Name

Type

Required?

Description

leadId

Id

The ID of the Lead record to process.

The Mapping Engine (PJN_MappingEngine) global Apex class maps and stamps values onto a record.

Note

To use the Mapping Engine in Komodo Care Connect V1, admin users must be assigned the KCC - Base Permissions Mapping Engine (PJN_Base_Permissions_Mapping_Engine) permission set.

global with sharing class PJN_MappingEngine

Methods

initiate(jobName)

Description

Returns

This method initiates the mapping engine for a configured mapping job.

void

global void initiate(String jobName)

Parameter

Type

Description

jobName

String

The API name of the mapping job to be run.

run(sourceObjectIds, targetObject)

Description

Returns

This method runs the mapping engine for a single target object.

A SObject that is the target object with the mapped values.

global SObject run(Map<String, Id> sourceObjectIds, SObject targetObject)

Parameter

Type

Description

sourceObjectIds

Map<String, Id>

The API name of the source object and the ID of the specific record.

targetObject

SObject

The API name of the target object.

run(sourceObjectIds, targetObjects)

Description

Returns

This method runs the mapping engine for multiple target objects.

The SObjects that are the target objects with the mapped values.

global Map<String, SObject> run(Map<String, List<Id>> sourceObjectIds, List<SObject> targetObjects)

Parameter

Type

Description

sourceObjectIds

Map<String, List<Id>>

The API name of the source object and the IDs of the specific records.

targetObjects

List<SObject>

The API names of the target objects.

setRecordIdentifierField(idField)

Description

Returns

This method sets the field to be used as a unique identifier for when the ID of the record is not necessarily available (e.g., Before Insert).

void

global void setRecordIdentifierField(String idField)

Parameter

Type

Description

idField

String

The API name of the field on the record to be used as the unique identifier in place of the ID.

Example

This example demonstrates how to call and use the Mapping Engine.

mvn.PJN_MappingEngine thisMappingEngine = new mvn.PJN_MappingEngine(); 
thisMappingEngine.initiate('<job-name>'); 
thisMappingEngine.run( 
    new Map<String, Id> { 
        'careplan' => '<careplan-id>', 
        'patient' => '<patient-id>', 
        'careplanlabels' => '<careplan-id>' 
    }, 
    '<target-record-id>' 
);

The Trigger Dispatcher (PJN_TriggerDispatcher) global Apex class enables the management of trigger handlers via custom metadata configurations. It also implements the Trigger Dispatcher Handler Interface (PJN_TriggerDispatcher.HandlerInterface).

global with sharing class PJN_TriggerDispatcher

To use the Trigger Dispatcher Apex class:

  1. Create a custom class for the Trigger Handler Setting (mvn__PJN_Trigger_Handler_Setting__mdt) custom metadata type and cast the desired object into a list. Reference the Trigger Dispatcher Handler Interface example.

  2. Create a Trigger Handler Setting metadata record.

  3. Create a trigger for the target object. Reference the Trigger Dispatcher example.

If a trigger handler does not execute successfully, the error or warning log is captured in the Debug Log (mvn__Debug_Log__c) object. For each Debug Log record created from a failed trigger handler execution, the Body (mvn__Body__c) field stores the trigger that was called while the Message (mvn__Message__c) field stores the error or warning message. The Message field can only capture 255 characters, so any additional characters in the error or warning message are truncated. However, from the first 255 characters, users can match the log to a trigger handler exception and identify whether the trigger stack belongs to an error or warning.

Methods

addTriggerHandlerSettingRecords()

Description

Returns

This method queries the Trigger Handler Setting metadata records for the current object and adds them to the processing queue. If the metadata records are invalid, PJN_TriggerDispatcherException throws a Trigger Handler Exception.

PJN_TriggerDispatcher

global PJN_TriggerDispatcher addTriggerHandlerSettingRecords()

dispatch()

Description

Returns

This method initiates the Trigger Dispatcher Handler Interface handle() method for each Trigger Handler Setting metadata record in order of Trigger.operationType.

void

global void dispatch()

Example

This example demonstrates how to call and use the Trigger Dispatcher on the Account object.

trigger PJN_Account on Account(before insert, after insert, before update, after update, before delete, after delete, after undelete) { 
    new mvn.PJN_TriggerDispatcher().addTriggerHandlerSettingRecords().dispatch(); 
}

The Trigger Dispatcher Handler Interface (PJN_TriggerDispatcher.HandlerInterface) Apex class handles and is implemented by the Trigger Dispatcher.

global interface HandlerInterface

Method

handle()

Description

Returns

This method enables custom implementation of how the Trigger Dispatcher should handle the Trigger Handler Setting (mvn__PJN_Trigger_Handler_Setting__mdt) metadata records.

void

void handle()

Example

This example demonstrates how to call and define the Trigger Dispatcher Handler Interface on the Account object and how to implement the handle() method to stamp today's date on a custom Account field.

global class CUST_AccountHdlr implements mvn.PJN_TriggerDispatcher.HandlerInterface { 
    global void handle() {
        for (Account thisAccount : (List<Account> Trigger.new)) { 
            thisAccount.CUST_Date__c = Date.Today(); 
        }
    } 
 }

The Trigger Handler Setting Query (PJN_TriggerHandlerSettingQuery) Apex class retrieves the Trigger Handler Setting (mvn__PJN_Trigger_Handler_Setting__mdt) metadata records to be run for a given object and allows users to overwrite the settings for testing purposes.

global class PJN_TriggerHandlerSettingQuery

Method

getSettingsForObject(SObjectType objectType)

Description

Returns

This method returns the list of Trigger Handler Setting (mvn__PJN_Trigger_Handler_Setting__mdt) metadata records to be run for a given object.

List<PJN_Trigger_Handler_Setting__mdt>

global static List<PJN_Trigger_Handler_Setting__mdt> getSettingsForObject(SObjectType objectType)

Parameter

Type

Description

objectType

SObjectType

The SObject that the trigger handlers are configured for.

setSettingsForObject(objectType, settings)

Description

Returns

This method overwrites the trigger handler settings to run for a given object.

Warning

This method can only be used during test execution.

void

global static void setSettingsForObject(SObjectType objectType, List<PJN_Trigger_Handler_Setting__mdt> settings)

Parameter

Type

Description

objectType

SObject Type

The SObject that is being tested with specific trigger handlers.

settings

List<PJN_Trigger_Handler_Setting__mdt>

The list of Trigger Handler Setting (mvn__PJN_Trigger_Handler_Setting__mdt) metadata records to run.

Example

This example demonstrates how to call and use the Trigger Handler Setting Query Apex class in a testing execution.

@isTest
private class ThisIsATest {
    
    @isTest
    private static void thisIsATestMethod() {
        mvn__PJN_Trigger_Handler_Setting__mdt someSetting = new mvn__PJN_Trigger_Handler_Setting__mdt(
            mvn__PJN_Class__c = 'MVN_ShipmentHdlr',
            mvn__PJN_Event__c = 'AFTER_INSERT',
            mvn__PJN_SObject_API_Name__c = 'Account');
        
        List<mvn__PJN_Trigger_Handler_Setting__mdt> settings = new List<mvn__PJN_Trigger_Handler_Setting__mdt>();
        settings.add(someSetting);
        
        mvn.PJN_TriggerHandlerSettingQuery.setSettingsForObject(Schema.Account.getSObjectType(), settings);
    }
}