function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Need to find duplicate records using firstname, last name and date of birth

I am inserting records in a custom object name as RAW patient order through data loader and i have written a trigger which picks some values from this object and insert into patient and patient order objects.


We have to do one more additional check here for the patients. Customer mentioned that they will get the orders from the same patient over and over. In that scenario we should not be creating duplicate patients. We have to check for the following patient and see if it exists. If so, skip the creation process and just create patient orders alone by associating with the existing patients.

Unique Identifier for Patient: first name, last name and birth date


Now I am facing the problem that how would i check this condition from the database. if i go for soql query one by one for every inserting record than surly i will face soql execution limits.


Please suggest, if any one have any idea to achieve this functionality


Thanks in advance!!

Best Answer chosen by Admin (Salesforce Developers) 

1. Load the data without checks and later merge the contacts based on firstname, lastname and dob. Check the app exchange for the available tools that may help you.


2. If you don't have thousands of patients, load them all in a collection and then do the comparison. You'll just need to maintain your collection.


3. Sort the data before loading and group it by firstname, lastname and dob and then load it. It can be easily done in Excel or any database of your choice.


4. If you don't want to use database, use java or any other programming language of your choice.