Document Selection Plugin
The Document Selection Plugin allows you to determine whether a document will be generated and attached to a quote or policy.
This plugin will be automatically executed as part of the policy document workflow. Document workflows can be customized through DocumentConfigRef configuration objects.
This plugin is executed asynchronously.
Supported Entity Types
The Document Selection Plugin supports the following entity types:
Quotes
Policy Transactions
Actions
Actions determine how the Document Selection Plugin handles a given document. For each document, one of the following actions can be specified:
generate- Generate and attach a new document instance, and replace any currently attached instances of the same document within the same documentscopenoAction- No new document instances will be generated and attached, and any existing instances of the same document within the same documentscopewill remain attachedgenerateIfAbsent- Generate and attach a new document instance if no instances of the same document within the same documentscopeare currently attachedremove- Remove any currently attached instances of the same document within the same documentscope
Note
The remove action does not affect documents if their scope value is set to transaction, since documents with this scope are associated with a transaction rather than a quote or policy.
When executing actions, the plugin considers two document instances to be instances of the same document if both document instances have the same staticName and scope. For multiple versions of the same document, all versions are considered to be instances of the same document.
Implementation
Create a new Java class in the src/main/java/com/socotra/deployment/customer folder. All plugin code must be contained within this folder. We named our class DocumentSelectionPluginImpl.java in the example below, but you can name your class whatever you’d like.
Implement the DocumentSelectionPlugin interface, and override the method corresponding to your target entity type.
For example, the following class contains a method that selects documents for commercial auto quotes:
public class DocumentSelectionPluginImpl implements DocumentSelectionPlugin {
private static final Logger log = LoggerFactory.getLogger(DocumentSelectionPluginImpl.class);
// Select documents for commercial auto quotes
@Override
public Map<String, DocumentSelectionAction> selectDocuments(CommercialAutoQuoteRequest commercialAutoQuoteRequest) {
return Map.of("TermsAndConditions", DocumentSelectionAction.generate);
}
}
The method argument contains the entity. In this case, the entity is a commercial auto quote.
The method returns a map of document names to actions.
Examples
All examples are based on the Prism configuration. Contact your Socotra representative for more information.
Quote
// Generate and attach documents listed in the document configuration for the commercial auto product if they’re not currently attached to commercial auto quotes
@Override
public Map<String, DocumentSelectionAction> selectDocuments(CommercialAutoQuoteRequest commercialAutoQuoteRequest) {
Map<String, DocumentSelectionAction> response = new HashMap<>();
commercialAutoQuoteRequest.documentConfigs()
.forEach(config ->
response.put(config.name(), DocumentSelectionAction.generateIfAbsent)
);
return response;
}
Policy Transaction
// Generate and attach a document upon renewal of commercial auto policies
@Override
public Map<String, DocumentSelectionAction> selectDocuments(CommercialAutoRequest commercialAutoRequest) {
Map<String, DocumentSelectionAction> response = new HashMap<>();
if (commercialAutoRequest.transaction().transactionCategory().equals(TransactionCategory.renewal)) {
response.put("TermsAndConditions", DocumentSelectionAction.generate);
}
return response;
}