4. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/22/2018 9:27:11 AM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

4.1 Files compared

# Location File Last Modified
1 REFDOC_2.3_06072018.zip\REFDOC 2.3_06072018\NVCC\Database\PanelMgmt\Stored Procedures usp_RebuildAllCDWPatients.sql Thu Jun 7 16:53:12 2018 UTC
2 REFDOC_2.3_06072018.zip\REFDOC 2.3_06072018\NVCC\Database\PanelMgmt\Stored Procedures usp_RebuildAllCDWPatients.sql Thu Jun 21 18:55:14 2018 UTC

4.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 418
Changed 1 2
Inserted 0 0
Removed 0 0

4.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

4.4 Active regular expressions

No regular expressions were active.

4.5 Comparison detail

  1  
  2   CREATE PRO CEDURE [Pa nelMgmt].[ usp_Rebuil dAllCDWPat ients] 
  3   AS
  4   --======== ========== ========== ========== ========== ========== ========== ========== ====
  5   --Requesto r              : Non  Va Coordin ated Care  Project, b ut produce s a great
  6   --                          gene ral use al l patient  table for  any applic ation.
  7   --Author                  : Jerr y Kohler,  Jianji Yan g - Northw est Innova tion Cente r
  8   --Object/S P Name         : usp_ RebuildAll CDWPatient s
  9   --Server                  :  DNS.URL         
  10   --Data Bas e              : CC_R EFDOC
  11   --Schema                  : Pane lMgmt
  12   --Report                  : N/A
  13   --Folder                  : N/A
  14   --Report L oc             : N/A
  15   --Job                     : None
  16   --Job Loc                 : None
  17   --Note                    : This  table con tains ALL  patients,  including
  18   --                          dece ased and t est.
  19   --Date Cre ated           : 03-1 0-2016
  20   --
  21   --
  22   --Purpose                 : Beca use SPatie nt does no t have an  index on P atientSSN,
  23   --                          we c reate a ta ble to tra nslate bet ween sever al types o f
  24   --                          pati ent identi fication f or REFDOC:
  25   --                             -  SSN
  26   --                             -  SID
  27   --                             -  ICN
  28   --                             -  Name (las t,first)
  29   --                             -  CPRSKey ( first char acter of l ast name,  last4)
  30   --
  31   --Last Cha nged           : 08-1 0-2017
  32   --Last Cha nged By                 : Brian  Diggs - NW IC
  33   --Reason F or Change               : Proces s was stil l blocking  for way t oo long, p reventing
  34   --                          look ups of pat ients. Ref actored ba sed on dis cussions
  35   --                          with  Andrew Ke lly. Extra ct the bat ches outsi de the
  36   --                          (blo cking) MER GE, then f ilter them  while
  37   --                          flag ging if th e record i s an updat e or inser t.
  38   --                          Do t he updates  and then  inserts an d update t he ETLBatc hID
  39   --
  40   --Last Cha nged           : 07-1 4-2017
  41   --Last Cha nged By                 : Brian  Diggs - NW IC
  42   --Reason F or Change               : Implem ented sugg estions fr om Andrew  Kelly
  43   --
  44   --Last Cha nged           : 06-0 9-2017
  45   --Last Cha nged By                 : Brian  Diggs - NW IC
  46   --Reason F or Change               : Conver ted to inc remental u pdate foll owing reco mmended CD
  47   --                          para digm
  48   --
  49   --Last Cha nged           : 04-1 9-2017
  50   --Last Cha nged By                 : Brian  Diggs - NW IC
  51   --Reason F or Change               : Stripp ed this do wn to just  the parts  needed fo r REFDOC
  52   --                          as p art of the  migration  to the Fi eld Report ing Enclav e.
  53   --                          The  only colum ns needed  are Sta3n,  PatientSS N, Patient ICN,
  54   --                          Pati entSID, an d PatientI EN.
  55   --
  56   --Last Cha nged           : 06-0 6-2016
  57   --Last Cha nged By                 : Jerry  Kohler - N WIC
  58   --Reason F or Change               : Added  Next of Ki n, and per  Microsoft  recommend ation
  59   --                          chan ged drop/c reate tabl e to drop  indexes an d TRUNCATE .
  60   --                          Also  added WIT H (TABLOCK ) in the i nsert.
  61   --                          All  of this sh ould boost  the perfo rmance, an d not
  62   --                          elim inate stor ed executi on plans o n the tabl e.
  63   --
  64   --Last Cha nged           : 06-0 3-2016
  65   --Last Cha nged By                 : Jerry  Kohler - N WIC
  66   --Reason F or Change               : Take a ll patient s from SPa tient, tes t or decea sed.
  67   --                          Join  to PanelM gmt.PMMast erCohortDe ceasedInde xNEW
  68   --                          to e nsure bett er accurac y.  Add de ceased fla g and
  69   --                          date  of death.
  70  
  71   --Last Cha nged           : 04-0 5-2016
  72   --Last Cha nged By                 : Jianji  Yang - NW IC
  73   --Reason F or Change               : Add te st patient  data, dec eased pati ents, and  patient's
  74   --                        : home  station ( based on P CP's Sta3n ).
  75   --
  76   --Last Cha nged           : 03-1 7-2017
  77   --Last Cha nged By                 : Jerry  Kohler - N WIC
  78   --Reason F or Change               : Add Pa tientIEN s o that fun ction App. udf_AllPat ientsSIDs
  79   --                        : can  now hit Al lCDWPatien ts instead  of SPatie nt.  This
  80   --                        : tabl e is much  smaller, a nd will be  much fast er.
  81   --
  82   --Last Cha nged           : 03-2 0-2017
  83   --Last Cha nged By                 : Jerry  Kohler - N WIC
  84   --Reason F or Change               : Change  procedure  to place  data in a  temporary  table THEN
  85   --                        : trun cate and i nsert into  the produ ction tabl e.  This
  86   --                        : mini mize the a mount of t ime querie s would re turn no da ta.
  87   --======== ========== ========== ========== ========== ========== ========== ========== ====
  88  
  89   BEGIN
  90  
  91           SE T NOCOUNT  ON;
  92  
  93           -- declare ba tch variab les and cu rsor
  94           DE CLARE @ETL BatchID AS  INT, @Ext ractBatchI D AS INT;
  95           DE CLARE @DWV iewName AS  VARCHAR(1 00) = 'SPa tient';
  96  
  97           -- add a TRY/ CATCH to e xit upon f ailure
  98           BE GIN TRY
  99  
  100                    SET  @ExtractBa tchID = (S ELECT EL.L astExtract BatchID FR OM Dflt.Ex tractBatch Log AS EL  WHERE EL.D WViewName  = @DWViewN ame) ;
  101  
  102                    DECL ARE BatchC ursor CURS OR STATIC 
  103                    FOR
  104                    --ge t batch id s
  105                    SELE CT EX.ETLB atchID, EX .ExtractBa tchID
  106                    FROM  SPV.EB.Ex tractBatch  AS EX
  107                    WHER E EX.DWVie wName = @D WViewName
  108                             AND EX .ExtractBa tchID > @E xtractBatc hID
  109                    ORDE R BY EX.Ex tractBatch ID;
  110  
  111                    CREA TE TABLE # spat1 (
  112                             Sta3n  smallint,
  113                             Patien tIEN varch ar(50),
  114                             Patien tSSN varch ar(50),
  115                             Patien tSID int,
  116                             Patien tICN varch ar(50)
  117                    )
  118                    DECL ARE @LastE xtractBatc hID AS INT ;
  119  
  120                    OPEN  BatchCurs or;
  121                    FETC H NEXT FRO M BatchCur sor INTO @ ETLBatchID , @Extract BatchID;
  122  
  123                    WHIL E @@FETCH_ STATUS = 0
  124                    BEGI N
  125                             INSERT  INTO #spa t1
  126                             SELECT  Sta3n, Pa tientIEN,  PatientSSN , PatientS ID, Patien tICN
  127                             FROM S PV.SPatien t.SPatient
  128                             WHERE  ETLBatchID  = @ETLBat chID
  129  
  130                             -- Sto re to upda te trackin g table la ter
  131                             SET @L astExtract BatchID =  @ExtractBa tchID
  132  
  133                             --merg e data fro m view int o producti on(destina tion) tabl e
  134                             --grab  the next  batch for  processing
  135                             FETCH  NEXT FROM  BatchCurso r INTO @ET LBatchID,  @ExtractBa tchID;
  136                    END
  137  
  138                    --cl ose and de allocate t he cursor  once all b atches for  a given t able have  been proce ssed
  139                    CLOS E BatchCur sor;
  140                    DEAL LOCATE Bat chCursor;
  141  
  142                    SELE CT
  143                             S.Sta3 n,
  144                             S.Pati entIEN,
  145                             S.Pati entSSN,
  146                             S.Pati entSID,
  147                             S.Pati entICN,
  148                             CASE
  149                                      WHEN A.P atientSID  IS NULL TH EN 'I'
  150                                      ELSE 'U'
  151                             END AS  InsertUpd ate
  152                    INTO  #spat2
  153                    FROM
  154                             #spat1  AS S
  155                             LEFT J OIN App.Al lCDWPatien ts AS A WI TH (NOLOCK )
  156                                      ON S.Pat ientSID =  A.PatientS ID
  157                             WHERE
  158                                      A.Patien tSID IS NU LL 
  159                                      OR (S.St a3n != A.S ta3n
  160                                               OR S.Patie ntICN != A .PatientIC N
  161                                               OR S.Patie ntSSN != A .PatientSS N
  162                                               OR S.Patie ntIEN != A .PatientIE N)
  163  
  164                    CREA TE CLUSTER ED INDEX [ #tmpidx] O N #spat2 ( PatientSID  ASC) WITH  (DATA_COM PRESSION =  PAGE);
  165  
  166                    BEGI N TRANSACT ION
  167                             UPDATE  A
  168                             SET
  169                                      A.Sta3n  = U.Sta3n,
  170                                      A.Patien tIEN = U.P atientIEN,
  171                                      A.Patien tSSN = U.P atientSSN,
  172                                      A.Patien tICN = U.P atientICN
  173                             FROM
  174                                      App.AllC DWPatients  AS A
  175                                      INNER JO IN #spat2  AS U
  176                                               ON A.Patie ntSID = U. PatientSID
  177                             WHERE
  178                                      U.Insert Update = ' U'
  179  
  180                             INSERT  INTO App. AllCDWPati ents (Sta3 n, Patient IEN, Patie ntSSN, Pat ientSID, P atientICN)
  181                             SELECT  Sta3n, Pa tientIEN,  PatientSSN , PatientS ID, Patien tICN
  182                             FROM # spat2
  183                             WHERE  InsertUpda te = 'I'
  184  
  185                             --afte r merging  batch then  update th e ExtractB atchLog ta ble
  186                             UPDATE  Dflt.Extr actBatchLo g
  187                                      SET Last ExtractBat chID = @La stExtractB atchID, La stExtractD ateTime =  GETDATE()
  188                             WHERE  DWViewName  = @DWView Name;
  189  
  190                    COMM IT TRANSAC TION
  191  
  192           EN D TRY
  193  
  194           -- CATCH will  report ba ck specifi c details  about fail ure; the l oop will s top
  195           BE GIN CATCH
  196  
  197                    IF @ @TRANCOUNT  > 0
  198                             ROLLBA CK TRANSAC TION;
  199  
  200                    SELE CT
  201                    ERRO R_NUMBER()  AS ErrorN umber,
  202                    ERRO R_SEVERITY () AS Erro rSeverity,
  203                    ERRO R_STATE()  AS ErrorSt ate,
  204                    ERRO R_PROCEDUR E() AS Err orProcedur e,
  205                    ERRO R_LINE() A S ErrorLin e,
  206                    ERRO R_MESSAGE( ) AS Error Message;
  207            
  208           EN D CATCH 
  209  
  210   END