zKnit()
# medhx_20090405 (this one has results for the 3 listed participants below, just under different histIds).
# medhx20100113 (this one does not have results for the participants listed below).

chkFor = c(8113068701,8151924202,8155040901,8161465702,8161742501,8163597901,8171299501,8172084901,8172271601,8172431601,8173159101,8173159102,8173360601)

getMain = function(db.tbl) {

    main = HNDdbGet(db.tbl)

    main$HNDid = HNDconcatID(zVsel(main, handlsIdPrefix:handlsIdSuffix))

    main
    }


hx15.main = getMain('medhx.hist_main')                  # current wave 1 medhx database
hx10.main = getMain('medhx20100113.hist_main')              # restored mechx from 2010-01-13
hx09.main = getMain('medhx_20090405.hist_main')             # restored medhx from 2009-04-05

#
# ***Find histIDs for HNDids in hist_main...
#

(h15ID = hx09.main[hx15.main$HNDid %in% chkFor,zQ(histId,HNDid)])
     histId      HNDid
2219   2381 8194573901
2221   2383 8181029301
2225   2387 8191780501
2304   2466 8173002702
2310   2472 8173480101
2318   2480 8171530501
2435   2597 8161149701
2498   2660 8173226301
2593   2755 8163637501
2622   2784 8173206101
2624   2786 8171553401
2691   2853 8151061901
2692   2854 8155208701
(h10ID = hx09.main[hx10.main$HNDid %in% chkFor,zQ(histId,HNDid)])
     histId      HNDid
2219   2381 8194573901
2221   2383 8181029301
2225   2387 8191780501
2304   2466 8173002702
2310   2472 8173480101
2318   2480 8171530501
2435   2597 8161149701
2498   2660 8173226301
2593   2755 8163637501
2622   2784 8173206101
2624   2786 8171553401
2691   2853 8151061901
2692   2854 8155208701
(h09ID = hx09.main[hx09.main$HNDid %in% chkFor,zQ(histId,HNDid)])
     histId      HNDid
2235   2397 8172084901
2265   2427 8161465702
2269   2431 8173159102
2270   2432 8173159101
2350   2512 8161742501
2357   2519 8173360601
2362   2524 8163597901
2535   2697 8171299501
2639   2801 8151924202
2666   2828 8172431601
2672   2834 8172271601
2736   2898 8155040901
2737   2899 8113068701
#
# ***Are histIDs in hist_surg???
#

hist15_surg = HNDdbGet('medhx.hist_surg')
hist10_surg = HNDdbGet('medhx20100113.hist_surg')
hist09_surg = HNDdbGet('medhx_20090405.hist_surg')

(h15surg = hist15_surg[hist15_surg$histId %in% h15ID$histID,])
[1] id          histId      surgeryId   isSurgery   surgeryType WhnStamp    WhnXfer     server     
<0 rows> (or 0-length row.names)
(h10surg = hist15_surg[hist10_surg$histId %in% h10ID$histID,])
[1] id          histId      surgeryId   isSurgery   surgeryType WhnStamp    WhnXfer     server     
<0 rows> (or 0-length row.names)
(h09surg = hist15_surg[hist09_surg$histId %in% h09ID$histID,])
[1] id          histId      surgeryId   isSurgery   surgeryType WhnStamp    WhnXfer     server     
<0 rows> (or 0-length row.names)
#
# ***Check for changes in histID-HNDid matches...
#

hist.10.15 = merge(h10ID, h15ID, 'histId', all=T)
hist.09.15 = merge(h09ID, h15ID, 'histId', all=T)
hndI.09.15 = merge(h09ID, h15ID, 'HNDid',  all=T)

(hist.10.15$diffHNDid = with(hist.10.15, HNDid.x-HNDid.y))      # No changes between 2010 & 2015
 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0
(hist.09.15$diffHNDid = with(hist.09.15, HNDid.x-HNDid.y))      # No correspondence between 2009 & 2015
 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
zQuick(hist.10.15)
[1] 13  4
     histId            HNDid.x              HNDid.y             diffHNDid
 Min.   :2381.000   Min.   :8151061901   Min.   :8151061901   Min.   :0  
 1st Qu.:2466.000   1st Qu.:8163637501   1st Qu.:8163637501   1st Qu.:0  
 Median :2597.000   Median :8173002702   Median :8173002702   Median :0  
 Mean   :2604.462   Mean   :8171880047   Mean   :8171880047   Mean   :0  
 3rd Qu.:2784.000   3rd Qu.:8173480101   3rd Qu.:8173480101   3rd Qu.:0  
 Max.   :2854.000   Max.   :8194573901   Max.   :8194573901   Max.   :0  
zQuick(hist.09.15)
[1] 26  4
     histId            HNDid.x              HNDid.y             diffHNDid  
 Min.   :2381.000   Min.   :8113068701   Min.   :8151061901   Min.   : NA  
 1st Qu.:2440.500   1st Qu.:8161465702   1st Qu.:8163637501   1st Qu.: NA  
 Median :2560.500   Median :8171299501   Median :8173002702   Median : NA  
 Mean   :2617.577   Mean   :8162662024   Mean   :8171880047   Mean   :NaN  
 3rd Qu.:2797.250   3rd Qu.:8172431601   3rd Qu.:8173480101   3rd Qu.: NA  
 Max.   :2899.000   Max.   :8173360601   Max.   :8194573901   Max.   : NA  
                    NA's   :13           NA's   :13           NA's   :26   
(hndI.09.15$diffHisID = with(hndI.09.15, histId.x-histId.y))
 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
zQuick(hndI.09.15)
[1] 26  4
     HNDid               histId.x           histId.y          diffHisID  
 Min.   :8113068701   Min.   :2397.000   Min.   :2381.000   Min.   : NA  
 1st Qu.:8161534902   1st Qu.:2432.000   1st Qu.:2466.000   1st Qu.: NA  
 Median :8171819151   Median :2524.000   Median :2597.000   Median : NA  
 Mean   :8167271036   Mean   :2630.692   Mean   :2604.462   Mean   :NaN  
 3rd Qu.:8173194351   3rd Qu.:2828.000   3rd Qu.:2784.000   3rd Qu.: NA  
 Max.   :8194573901   Max.   :2899.000   Max.   :2854.000   Max.   : NA  
                      NA's   :13         NA's   :13         NA's   :26   

It looks like something happened in between 2009 & 2010. It doesn't help us find the IDs we're looking for, but this suggests that something wonky may have happening syncing the database between home base and the MRVs.

What's odd is that the HNDids aren't in 2010 but they were in 2009. I suspect that the surgery table in 2009 didn't sync to home base between 2009 & 2010.