276. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/22/2018 9:28:22 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.

276.1 Files compared

# Location File Last Modified
1 REFDOC_2.3_06072018.zip\REFDOC 2.3_06072018\NVCC\SQL usp_RebuildAllCDWPatients.sql Thu Jun 7 16:53:38 2018 UTC
2 REFDOC_2.3_06072018.zip\REFDOC 2.3_06072018\NVCC\SQL usp_RebuildAllCDWPatients.sql Fri Jun 22 12:54:04 2018 UTC

276.2 Comparison summary

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

276.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

276.4 Active regular expressions

No regular expressions were active.

276.5 Comparison detail

  1   USE [NWIC_ PanelMgmt]
  2   GO
  3  
  4   /****** Ob ject:  Sto redProcedu re [PanelM gmt].[usp_ RebuildAll CDWPatient s]    Scri pt Date: 3 /23/2017 9 :06:41 AM  ******/
  5   SET ANSI_N ULLS ON
  6   GO
  7  
  8   SET QUOTED _IDENTIFIE R ON
  9   GO
  10  
  11  
  12   CREATE PRO CEDURE [Pa nelMgmt].[ usp_Rebuil dAllCDWPat ients]
  13   AS
  14   --======== ========== ========== ========== ========== ========== ========== ========== ====
  15   --Requesto r              : Non  Va Coordin ated Care  Project, b ut produce s a great
  16   --                          gene ral use al l patient  table for  any applic ation.
  17   --Author                  : Jerr y Kohler,  Jianji Yan g - Northw est Innova tion Cente r
  18   --Object/S P Name         : usp_ AllCDWPati ents
  19   --Server                  :  DNS.URL         
  20   --Data Bas e              : NWIC _PanelMgmt
  21   --Schema                  : Pane lMgmt
  22   --Report                  : N/A
  23   --Folder                  : N/A
  24   --Report L oc             : N/A
  25   --Job                     : None
  26   --Job Loc                 : None
  27   --Note                    : This  table con tains ALL  patients,  including
  28   --                          dece ased and t est.
  29   --Date Cre ated           : 03-1 0-2016
  30   --
  31   --Last Cha nged           : 06-0 6-2016
  32   --Last Cha nged By                 : Jerry  Kohler - N WIC
  33   --Reason F or Change               : Added  Next of Ki n, and per  Microsoft  recommend ation
  34   --                          chan ged drop/c reate tabl e to drop  indexes an d TRUNCATE .
  35   --                          Also  added WIT H (TABLOCK ) in the i nsert.
  36   --                          All  of this sh ould boost  the perfo rmance, an d not
  37   --                          elim inate stor ed executi on plans o n the tabl e.
  38   --
  39   --Last Cha nged           : 06-0 3-2016
  40   --Last Cha nged By                 : Jerry  Kohler - N WIC
  41   --Reason F or Change               : Take a ll patient s from SPa tient, tes t or decea sed.
  42   --                          Join  to PanelM gmt.PMMast erCohortDe ceasedInde xNEW
  43   --                          to e nsure accu racy.  Add  deceased  flag and
  44   --                          date  of death.
  45   --
  46   --
  47   --Last Cha nged           : 6-1- 2016
  48   --Last Cha nged By                 : Jianji  Yang - NW IC
  49   --Reason F or Change               : to add  PCP, Clin ic, HomeSt a, and DOB
  50   --Purpose                 : To c reate a ta ble to tra nslate bet ween sever al types o f
  51   --                          pati ent identi fication:
  52   --                             -  SSN
  53   --                             -  SID
  54   --                             -  ICN
  55   --                             -  Name (las t,first)
  56   --                             -  CPRSKey ( first char acter of l ast name,  comma, las t4)
  57   --Last Cha nged           : 04-0 5-2016
  58   --Last Cha nged By                 : Jerry  Kohler - N WIC
  59   --Reason F or Change               : Add te st patient  data.
  60   --
  61   --Purpose                 : Beca use SPatie nt does no t have an  index on P atientSSN,
  62   --                          we c reate a ta ble to tra nslate bet ween sever al types o f
  63   --                          pati ent identi fication:
  64   --                             -  SSN
  65   --                             -  SID
  66   --                             -  ICN
  67   --                             -  Name (las t,first)
  68   --                             -  CPRSKey ( first char acter of l ast name,  last4)
  69   --
  70   --Last Cha nged           : 04-0 5-2016
  71   --Last Cha nged By                 : Jianji  Yang - NW IC
  72   --Reason F or Change               : Add te st patient  data, dec eased pati ents, and  patient's
  73   --                        : home  station ( based on P CP's Sta3n ).
  74   --
  75   --Last Cha nged           : 03-1 7-2017
  76   --Last Cha nged By                 : Jerry  Kohler - N WIC
  77   --Reason F or Change               : Add Pa tientIEN s o that fun ction App. udf_AllPat ientsSIDs
  78   --                        : can  now hit Al lCDWPatien ts instead  of SPatie nt.  This
  79   --                        : tabl e is much  smaller, a nd will be  much fast er.
  80   --
  81   --Last Cha nged           : 03-2 0-2017
  82   --Last Cha nged By                 : Jerry  Kohler - N WIC
  83   --Reason F or Change               : Change  procedure  to place  data in a  temporary  table THEN
  84   --                        : trun cate and i nsert into  the produ ction tabl e.  This
  85   --                        : mini mize the a mount of t ime querie s would re turn no da ta.
  86   --======== ========== ========== ========== ========== ========== ========== ========== ====
  87  
  88   BEGIN
  89  
  90       -- Cre ate tempor ary tables
  91  
  92       -- Ran k PCP Rela tionship S tart Date  latest to  oldest.
  93       -- We  want the m ost recent ly assigne d Primary  Care Provi der.
  94       -- The  Provider' s station  will becom e the pati ent's
  95       -- hom e station  (patient p arent site )
  96       select  ROW_NUMBE R() over(P artition b y PatientS ID ORDER B Y Relation shipStartD ate Desc)  As RowNum
  97              ,PatientSI D
  98              ,[PrimaryP roviderSID ]
  99              ,PrimaryPr ovider as  [PrimaryPr oviderName ]
  100              ,[TeamSID]
  101              ,Team as [ PCPTeam]
  102              ,Instituti onCode as  [Sta6a]
  103              ,DivisionN ame as [Cl inic]
  104       into # PCP
  105       from [ App].[PCMM CurrentPat ientProvid erRelation ship];
  106  
  107       create  unique cl ustered in dex #PCPid x on #PCP( PatientSID , RowNum)  with (SORT _IN_TEMPDB  = ON);
  108  
  109  
  110       -- Nex t of Kin f or REFDOC
  111       IF (SE LECT OBJEC T_ID('#NOK ')) IS NOT  NULL
  112       DROP T ABLE #NOK
  113  
  114       Select  a.Patient SID, a.SPa tientAddre ssSid
  115       Into # NOK
  116       From C DWWork.SPa tient.SPat ientAddres s a
  117       Where  PatientSID  > 0
  118         and  a.OrdinalN umber = (s elect min( x.OrdinalN umber)
  119                                  f rom cdwwor k.SPatient .SPatientA ddress x
  120                                  w here x.Pat ientSID =  a.PatientS ID)
  121         and  a.AddressT ype like ' %Next Of K in%';
  122  
  123       Create  unique cl ustered in dex #spa O N #NOK (Pa tientSID,  SPatientAd dressSID)  with (SORT _IN_TEMPDB  = ON);
  124  
  125  
  126  
  127       -- Get  patient d ata and pu t in a tem porary tab le
  128       IF (SE LECT OBJEC T_ID('#PTS ')) IS NOT  NULL
  129       DROP T ABLE #PTS
  130  
  131       select  a.[Sta3n]
  132              ,a.[Patien tIEN]
  133              ,a.[Patien tSSN]
  134              ,a.[Patien tSID]
  135              ,a.[Patien tICN]
  136              ,a.[Patien tName]
  137              ,a.DateOfB irth
  138              ,RIGHT(a.[ PatientSSN ], 4) as L astFour
  139              ,LEFT(a.[P atientLast Name], 1)  + RIGHT(a. [PatientSS N], 4) AS  [CPRSKey]
  140              ,ISNULL(c. [PrimaryPr oviderSID]  , 0) AS P rimaryProv iderSID
  141              ,ISNULL(c. [PrimaryPr oviderName ], 'PCP No t Assigned ') AS Prim aryProvide rName
  142              ,c.TeamSID  AS [PCPTe amSID]
  143              ,c.[PCPTea m]
  144              ,c.[Sta6a]
  145              ,c.[Clinic ]
  146              ,NULL as H omeSta3n
  147              ,[Deceased ] = CASE
  148                                 Wh en b.DateO fDeath is  NOT NULL t hen 1
  149                                 El se 0
  150                             END
  151                      ,b .[DateOfDe ath]
  152              ,[TestPati entFlag] =  CASE
  153                                         When  a.[TestPat ientFlag]  IS NULL Th en 0
  154                                         Else  1
  155                                     END
  156              ,d.Spatien tAddressSI D AS [NOKA ddressSID]     -- Nex t of Kin i s in CDWWo rk.SPatien t.SPatient Address
  157       into # PTS
  158       from C DWWork.SPa tient.SPat ient a
  159           LE FT JOIN Pa nelMgmt.PM MasterCoho rtDeceased IndexNEW b  on b.Pati entSID = a .PatientSI D
  160           LE FT JOIN #P CP c on a. PatientSID  = c.Patie ntSID AND  c.RowNum =  1
  161       LEFT J OIN #NOK d  on a.Pati entSID = d .PatientSI D
  162       where  a.[Patient SSN] Not I n ('*Missi ng*', '*Un known at t his time*' )
  163  
  164       Create  noncluste red index  #PTS1 on # PTS (Patie ntICN)
  165       with ( SORT_IN_TE MPDB = ON)
  166       
  167       Create  noncluste red index  #PTS2 on # PTS (Patie ntSID)
  168       with ( SORT_IN_TE MPDB = ON)
  169       
  170       Create  noncluste red index  #PTS3 on # PTS (Prima ryProvider SID)
  171       with ( SORT_IN_TE MPDB = ON)
  172  
  173  
  174       -- Upd ate PCP an d Home Sta tion colum ns
  175  
  176       Update  #PTS
  177           se t [Primary ProviderSI D] = 0,
  178           [P rimaryProv iderName]  ='PCP Not  Assigned'
  179           wh ere [Prima ryProvider SID] < 0
  180  
  181  
  182           se lect disti nct sta3n,  patientic
  183       into # homestatio n
  184           fr om #PTS
  185           wh ere [Prima ryProvider SID] > 0
  186       
  187       Create  clustered  index #Ho meStationI CN on #hom estation ( PatientICN )
  188           
  189       update   #PTS
  190           se t HomeSta3 n =b.Sta3n
  191           fr om #PTS a
  192           jo in #homeSt ation b
  193           on  a.patient icn = b.pa tienticn
  194  
  195  
  196       -- Dro p all inde xes except  the prima ry cluster ed index ( create sta tement
  197       -- bel ow in case  it gets d ropped to  avoid the  overhead o f maintain ing
  198       -- the m during t he truncat e and inse rt of the  table.  Th is method  was
  199       -- ena cted based  on CDW op erational  recommenda tions by M icrosoft.
  200  
  201       IF (SE LECT OBJEC T_ID('App. AllCDWPati ents')) IS  NOT NULL
  202           BE GIN
  203                DROP ind ex AllCDWP atients_Pa tientICN          on  App.AllCDW Patients;
  204                DROP ind ex AllCDWP atients_Pa tientSID          on  App.AllCDW Patients;
  205                DROP ind ex AllCDWP atients_Pa tientName         on  App.AllCDW Patients;
  206                DROP ind ex AllCDWP atients_CP RSKey             on  App.AllCDW Patients;
  207                DROP ind ex AllCDWP atients_Pr imaryProvi derSID on  App.AllCDW Patients;
  208  
  209                TRUNCATE  TABLE App .AllCDWPat ients;
  210           EN D
  211  
  212       
  213       -- Ins ert patien t records  into the t able
  214  
  215       Insert  into App. AllCDWPati ents WITH  (TABLOCK)
  216           (
  217           [S ta3n],
  218           [P atientIEN] ,
  219           [P atientSSN] ,
  220           [P atientSID] ,
  221           [P atientICN] ,
  222           [P atientName ],
  223                    [Dat eOfBirth],
  224                    [Las tFour],
  225           [C PRSKey],
  226                    [Pri maryProvid erSID],
  227                    [Pri maryProvid erName],
  228                    [PCP TeamSID],
  229                    [PCP Team],
  230                    [Sta 6a],
  231                    [Cli nic],
  232                    [Hom eSta3n],
  233                    [Dec eased],
  234                    [Dat eOfDeath],
  235           [T estPatient Flag],
  236           [N OKAddressS ID]
  237           )
  238       (
  239       select  [Sta3n],
  240               [PatientI EN],
  241               [PatientS SN],
  242               [PatientS ID],
  243               [PatientI CN],
  244               [PatientN ame],
  245                       [ DateOfBirt h],
  246                       [ LastFour],
  247               [CPRSKey] ,
  248                       [ PrimaryPro viderSID],
  249                       [ PrimaryPro viderName] ,
  250                       [ PCPTeamSID ],
  251                       [ PCPTeam],
  252                       [ Sta6a],
  253                       [ Clinic],
  254                       [ HomeSta3n] ,
  255                       [ Deceased],
  256                       [ DateOfDeat h],
  257               [TestPati entFlag],
  258               [NOKAddre ssSID]
  259         from  #PTS
  260       )
  261  
  262  
  263       -- Rec reate inde xes
  264  
  265       -- In  case this  one gets d ropped som ehow.  Thi s one is
  266       -- cri tical to R EFDOC (aka  CITCoM, a ka NVCC)
  267  
  268       --Crea te Cluster ed Index A llCDWPatie nts_Sta3n_ PatientSSN
  269       --On A pp.AllCDWP atients (S ta3n, Pati entSSN)
  270       --With  (SORT_IN_ TEMPDB = O N, DATA_CO MPRESSION  = PAGE)
  271  
  272  
  273       Create  noncluste red index  AllCDWPati ents_Patie ntICN on A pp.AllCDWP atients (P atientICN)
  274       includ e (Patient SID, Patie ntSSN, Sta 3n, Deceas ed, DateOf Death)
  275       with ( SORT_IN_TE MPDB = ON,  DATA_COMP RESSION =  PAGE)
  276       
  277       Create  noncluste red index  AllCDWPati ents_Patie ntSID on A pp.AllCDWP atients (P atientSID)
  278       includ e (Patient ICN, Decea sed, DateO fDeath)
  279       with ( SORT_IN_TE MPDB = ON,  DATA_COMP RESSION =  PAGE)
  280       
  281       Create  noncluste red index  AllCDWPati ents_Patie ntName on  App.AllCDW Patients ( PatientNam e)
  282       includ e (Patient ICN, Patie ntSID, Pat ientSSN, S ta3n, Dece ased, Date OfDeath)
  283       with ( SORT_IN_TE MPDB = ON,  DATA_COMP RESSION =  PAGE)
  284       
  285       Create  noncluste red index  AllCDWPati ents_CPRSK ey on App. AllCDWPati ents (CPRS Key)
  286       includ e (Patient ICN, Patie ntSID, Pat ientSSN, S ta3n, Dece ased, Date OfDeath)
  287       with ( SORT_IN_TE MPDB = ON,  DATA_COMP RESSION =  PAGE)
  288       
  289       Create  noncluste red index  AllCDWPati ents_Prima ryProvider SID on App .AllCDWPat ients (Pri maryProvid erSID)
  290       includ e (Primary ProviderNa me, Patien tICN, Pati entSID)
  291       with ( SORT_IN_TE MPDB = ON,  DATA_COMP RESSION =  PAGE)
  292       
  293  
  294       -- Cle an up
  295  
  296       IF (SE LECT OBJEC T_ID('#PCP ')) IS NOT  NULL
  297                    DROP  TABLE #PC P;
  298  
  299       IF (SE LECT OBJEC T_ID('#NOK ')) IS NOT  NULL
  300           DR OP TABLE # NOK
  301  
  302       IF (SE LECT OBJEC T_ID('#hom estation') ) IS NOT N ULL
  303           DR OP TABLE # homestatio n
  304  
  305       IF (SE LECT OBJEC T_ID('#PTS ')) IS NOT  NULL
  306       DROP T ABLE #PTS
  307  
  308   END
  309  
  310   GO