4 * Note this may be included by CLI scripts, so don't do anything web-specific here!
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @copyright Copyright (c) 2021 Rod Roark <rod@sunsetsystems.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 // The SQL returned by this function is an expression that computes the duplication
14 // score between two patient_data table rows p1 and p2.
16 function getDupScoreSQL()
20 "5 * (SOUNDEX(p1.fname) = SOUNDEX(p2.fname)) + " .
22 "3 * (SOUNDEX(p1.lname) = SOUNDEX(p2.lname)) + " .
25 "(TRIM(p1.phone_home) != '' AND ( " .
26 "REPLACE(REPLACE(p1.phone_home, '-', ''), ' ', '') IN ( " .
27 "REPLACE(REPLACE(p2.phone_home, '-', ''), ' ', ''), " .
28 "REPLACE(REPLACE(p2.phone_biz , '-', ''), ' ', ''), " .
29 "REPLACE(REPLACE(p2.phone_cell, '-', ''), ' ', '')))) " .
30 "OR (TRIM(p1.phone_biz) != '' AND ( " .
31 "REPLACE(REPLACE(p1.phone_biz , '-', ''), ' ', '') IN ( " .
32 "REPLACE(REPLACE(p2.phone_biz , '-', ''), ' ', ''), " .
33 "REPLACE(REPLACE(p2.phone_cell, '-', ''), ' ', '')))) " .
34 "OR (TRIM(p1.phone_cell) != '' AND ( " .
35 "REPLACE(REPLACE(p1.phone_cell, '-', ''), ' ', '') = " .
36 "REPLACE(REPLACE(p2.phone_cell, '-', ''), ' ', ''))) " .
39 "6 * (p1.DOB IS NOT NULL AND p2.DOB IS NOT NULL AND p1.DOB = p2.DOB) + " .
41 "7 * (TRIM(p1.email) != '' AND TRIM(p1.email) = TRIM(p2.email)) + " .
43 "15 * (TRIM(p1.ss) != '' AND TRIM(p1.ss) = TRIM(p2.ss))";