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

3.1 Files compared

# Location File Last Modified
1 REFDOC_2.3_06072018.zip\REFDOC 2.3_06072018\NVCC\Database\PanelMgmt\Stored Procedures usp_PMUpdateMasterLabIndexFromLOINC.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_PMUpdateMasterLabIndexFromLOINC.sql Thu Jun 21 18:54:43 2018 UTC

3.2 Comparison summary

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

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

3.4 Active regular expressions

No regular expressions were active.

3.5 Comparison detail

  1  
  2  
  3   CREATE PRO CEDURE [Pa nelMgmt].[ usp_PMUpda teMasterLa bIndexFrom LOINC] 
  4   AS
  5   --======== ========== ========== ========== ========== ========== ========== ========== ===
  6   --Requesto r                                : Jianji Y ang
  7   --Author                  : Jerr y Kohler ( Original s cript by S teve Schre iner)
  8   --Object/S P Name                  : [Panel Mgmt].[usp _PMUpdateM asterLabIn dexfromLOI NC]
  9   --SERVER                                    
D NS . U R        
  10   --Data Bas e                                : NWIC_Pan elMgmt
  11   --Schema                                    : PanelMgm t
  12   --Report                                    : None Yet
  13   --Folder                                    :
  14   --Report L oc             : 
  15   --Job                     : None
  16   --Job Loc                 : None
  17   --Note                    : 
  18   --Date Cre ated           : 12-2 8-2015
  19   --Last Cha nged           :   
  20   --Last Cha nged By                 : 
  21   --Reason F or Change               :                                 
  22   --Purpose                 : Upda te Panel M anagement  Master Lab  Index tab le 
  23   --                          with  lab test  that have  valid LOIN C codes.   This is do ne
  24   --                          thro ugh the BI SL's incre mental upd ate method  in the fi rst
  25   --                          sect ion.  This  is done t o decrease  the proce ssing time
  26   --                          and  conserve s erver reso urces.
  27   --======== ========== ========== ========== ========== ========== ========== ========== ===
  28   SET NOCOUN T on
  29  
  30   BEGIN
  31       /* 
  32       Locate  and load  the outsta nding Chem .LabChem b atches sin ce the
  33       last e xecution r ather than  processin g the enti re Chem.La bChem view .
  34       */
  35  
  36           -- declare ba tch variab les and cu rsor
  37           DE CLARE @ETL BatchID    AS INT, @E xtractBatc hID AS INT ;
  38           DE CLARE @DWV iewSchema  AS VARCHAR (50) = 'Ch em';
  39           DE CLARE @DWV iewName    AS VARCHAR (50) = 'La bChem';
  40  
  41  
  42       DECLAR E BatchCur sor CURSOR  STATIC FO R
  43           -- get batch  ids
  44               SELECT EX .ETLBatchI D, EX.Extr actBatchID
  45               FROM SPV. EB.Extract Batch AS E X
  46               INNER JOI N Dflt.Ext ractBatchL og AS EL
  47                   ON EX .DWViewSch ema = EL.D WViewSchem a AND EX.D WViewName  = EL.DWVie wName
  48               WHERE EX. DWViewSche ma = @DWVi ewSchema
  49            A ND EX.DWVi ewName   =  @DWViewNa me
  50            A ND EX.Extr actBatchID  > EL.Last ExtractBat chID
  51               ORDER BY  EX.Extract BatchID;
  52  
  53           OP EN BatchCu rsor;
  54           FE TCH NEXT F ROM BatchC ursor INTO  @ETLBatch ID, @Extra ctBatchID;
  55  
  56           WH ILE @@FETC H_STATUS =  0
  57           BE GIN
  58  
  59           IF  (SELECT O BJECT_ID(' tempdb..#L abChemPrep ')) IS NOT  NULL
  60           DR OP TABLE # LabChemPre p
  61  
  62                    -- t he lab res ults load  table has  duplicate  records, w hich the
  63           --  MERGE sta tement wil l not tole rate.  Try  and get t he latest
  64           --  record fo r each Lab ChemTestSI D in the b atch by so rting on
  65           --  specimen  date time  descending  within th at LabChem TestSID
  66                    SELE CT [Sta3n]
  67                  ,[LabC hemTestSID ]
  68                  ,[LOIN CSID]
  69                  ,[LabC hemSpecime nDateTime]
  70                  ,[LabC hemComplet eDateTime]
  71                  ,[ETLB atchID]
  72                  ,[OpCo de]
  73                  ,[Vist aCreateDat e]
  74                  ,[Vist aEditDate]
  75                  ,row_n umber() ov er (Partit ion by Lab ChemTestSI D
  76                                            or der by Lab ChemTestSI D, LabChem SpecimenDa teTime DES C) AS RN
  77           IN TO #LabChe mPrep
  78                    FROM  SPV.Chem. LabChem
  79                    WHER E ETLBatch ID = @ETLB atchID             
  80  
  81                    -- m erge data  into produ ction(dest ination) t able
  82                    MERG
  83                             ETL.Pr odLabChem  AS D
  84                    USIN G
  85                             (
  86                                      SELECT [ Sta3n]
  87                           ,[LabChe mTestSID]
  88                           ,[LOINCS ID]
  89                           ,[LabChe mSpecimenD ateTime]
  90                           ,[LabChe mCompleteD ateTime]
  91                           ,[ETLBat chID]
  92                           ,[OpCode ]
  93                           ,[VistaC reateDate]
  94                           ,[VistaE ditDate]
  95                           ,RN
  96                                      FROM #La bChemPrep
  97                                      WHERE ET LBatchID =  @ETLBatch ID
  98                      AN D RN = 1 - - the late st record  for a give n LabChemT estSID
  99                             ) AS M
  100                    ON
  101                             D.LabC hemTestSID  = M.LabCh emTestSID
  102                    WHEN  NOT MATCH ED THEN
  103                             INSERT
  104                                      (
  105                                                  [Sta3n]
  106                           ,[LabChe mTestSID]
  107                           ,[LOINCS ID]
  108                           ,[LabChe mSpecimenD ateTime]
  109                           ,[LabChe mCompleteD ateTime]
  110                           ,[ETLBat chID]
  111                           ,[OpCode ]
  112                           ,[VistaC reateDate]
  113                           ,[VistaE ditDate]
  114                                      )
  115                             VALUES
  116                                      (
  117                          M.[Sta3n]
  118                         ,M.[LabChe mTestSID]
  119                         ,M.[LOINCS ID]
  120                         ,M.[LabChe mSpecimenD ateTime]
  121                         ,M.[LabChe mCompleteD ateTime]
  122                         ,M.[ETLBat chID]
  123                         ,M.[OpCode ]
  124                         ,M.[VistaC reateDate]
  125                         ,M.[VistaE ditDate]
  126  
  127                                      )
  128                    WHEN  MATCHED T HEN
  129                             UPDATE  SET
  130                            [Sta3n]                     =  M.[Sta3n]
  131                                                 ,[LabChe mTestSID]           =  M.[LabChe mTestSID]
  132                           ,[LOINCS ID]                 =  M.[LOINCS ID]
  133                           ,[LabChe mSpecimenD ateTime] =  M.[LabChe mSpecimenD ateTime]
  134                           ,[LabChe mCompleteD ateTime] =  M.[LabChe mCompleteD ateTime]
  135                           ,[ETLBat chID]               =  M.[ETLBat chID]
  136                           ,[OpCode ]                   =  M.[OpCode ]
  137                           ,[VistaC reateDate]          =  M.[VistaC reateDate]
  138                           ,[VistaE ditDate]            =  M.[VistaE ditDate]
  139                    ;
  140  
  141                    -- a fter mergi ng batch t hen update  the Extra ctBatchLog  table
  142                    UPDA TE Dflt.Ex tractBatch Log
  143                       S ET LastExt ractBatchI D = @Extra ctBatchID,  LastExtra ctDateTime  = GETDATE ()
  144            W HERE DWVie wSchema =  @DWViewSch ema
  145               AND DWVie wName   =  @DWViewNam e;
  146  
  147                    -- g rab the ne xt batch f or process ing
  148                    FETC H NEXT FRO M BatchCur sor INTO @ ETLBatchID , @Extract BatchID;
  149           EN D
  150  
  151           --  close and  deallocat e the curs or once al l batches  for a give n table ha ve been pr ocessed
  152           CL OSE BatchC ursor;
  153           DE ALLOCATE B atchCursor ;
  154  
  155   --
  156   --
  157   --
  158   --  Using  the increm entally up dated ETL. ProdLabChe m rather t han the fu ll
  159   --  CDWWor k.Dim.Labc hem view,  insert new  lab tests  into [Pan elMgmt].[P MMasterLab Index] 
  160   --
  161   --
  162   --
  163      -- all  LOINC SIDS  for all s tations de fined in P MMasterCoh ortSite
  164      IF (SEL ECT OBJECT _ID('tempd b..#TempLO INCSID'))  IS NOT NUL L
  165      DROP TA BLE #TempL OINCSID
  166  
  167      select  li.LOINCSI D
  168              ,li.Sta3n
  169              ,lc.LOINC
  170              ,lc.TestGr oup
  171              ,lc.Result ForTestNum eric
  172              ,dateadd(y y,lc.YearS earchCrite ria,getdat e()) as Ye arSearchDa te
  173      into #T empLOINCSI D
  174      from [P anelMgmt]. [PMMasterC ohortLabTe stGroupsLO INCCodes]  as lc
  175      inner j oin [CDWWo rk].[Dim]. [LOINC] as  li on lc. LOINC = li .LOINC
  176      inner j oin [Panel Mgmt].[PMM asterCohor tSite] as  cs on li.S ta3n = cs. Sta3n;
  177  
  178  
  179      -- base d on LOINC  codes, ar e there an y new lab  tests we d o NOT
  180      -- alre ady have i n PMMaster LabIndex?
  181      IF (SEL ECT OBJECT _ID('tempd b..#Insert TheseRecor ds')) IS N OT NULL
  182      DROP TA BLE #Inser tTheseReco rds
  183  
  184      select  distinct l i.LabChemT estSID
  185                                        ,li.St a3n
  186                                        ,li.La bChemTestN ame
  187                                        ,tl.Re sultForTes tNumeric
  188                                        ,getda te() as Da teExtracte d
  189                                        ,tl.Te stGroup
  190                                        ,tl.LO INC
  191                                        ,NULL  as WorkLoa dCode
  192      into          #Ins ertTheseRe cords
  193      from                   [ETL]. ProdLabChe m lc
  194      inner j oin   [CDW Work].[Dim ].[LabChem Test] as l i on lc.La bChemTestS ID = li.La bChemTestS ID
  195      inner j oin   #Tem pLOINCSID  tl on lc.S ta3n = li. Sta3n AND  lc.LabChem CompleteDa teTime > t l.YearSear chDate
  196      where         lc.L OINCSID =  tl.LOINCSI D
  197        and         not  exists (se lect ni.La bChemTestS ID
  198                                                     from  [PanelMgm t].[PMMast erLabIndex ] as ni
  199                                                             where l i.LabChemT estSID = n i.LabChemT estSID
  200                                                                   a nd li.Sta3 n = ni.Sta 3n);
  201  
  202      Insert  into [Pane lMgmt].[PM MasterLabI ndex]
  203      (
  204         LabC hemTestSID ,
  205         Sta3 n,
  206         LabC hemTestNam e,
  207         Resu ltForTestN umeric,
  208         Date Extracted,
  209         Test Group,
  210         LOIN C,
  211         Work LoadCode
  212      )
  213      Select  LabChemTes tSID,
  214              Sta3n,
  215              LabChemTes tName,
  216              ResultForT estNumeric ,
  217              DateExtrac ted,
  218              TestGroup,
  219              LOINC,
  220              WorkLoadCo de
  221       From # InsertThes eRecords
  222      
  223      Drop ta ble #Inser tTheseReco rds
  224   --select t op 1000 *  from #Inse rtTheseRec ords
  225   --select *  from #Ins ertTheseRe cords wher e LabChemT estSID in  (select La bChemTestS ID from [P anelMgmt]. [PMMasterL abIndex])
  226   --select d istinct da teextracte d from #In sertTheseR ecords
  227   --select c ount(*) fr om #Insert TheseRecor ds
  228   --select a .*, b.* fr om #Insert TheseRecor ds a join  cdwwork.di m.labchemt est b on b .LabChemTe stSID = a. LabChemTes tSID
  229   --select a .* from #I nsertThese Records a  join cdwwo rk.dim.lab chemtest b  on b.LabC hemTestSID  = a.LabCh emTestSID  where b.St a3n != a.S ta3n
  230  
  231      UPDATE  [PanelMgmt ].[PMMaste rCohortLab TestGroups LOINCCodes ]
  232         set  LastUpdate  = cast(ge tdate() as  date);
  233  
  234   END
  235  
  236  
  237