99. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/12/2018 10:18:34 AM Central 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.

99.1 Files compared

# Location File Last Modified
1 MSSRe Build 4.zip\DatabaseScripts\DatabaseObjects dbo.prcDVEIRReferralProceduresReport.StoredProcedure.sql Tue Apr 10 19:44:16 2018 UTC
2 MSSRe Build 4.zip\DatabaseScripts\DatabaseObjects dbo.prcDVEIRReferralProceduresReport.StoredProcedure.sql Thu Apr 12 12:06:22 2018 UTC

99.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 7 550
Changed 6 12
Inserted 0 0
Removed 0 0

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

99.4 Active regular expressions

No regular expressions were active.

99.5 Comparison detail

  1   USE [V5_Re gistry]
  2   GO
  3   /****** Ob ject:  Sto redProcedu re [dbo].[ prcDVEIRRe ferralProc eduresRepo rt]    Scr ipt Date:  06/19/2013  10:12:24  ******/
  4   SET ANSI_N ULLS ON
  5   GO
  6   SET QUOTED _IDENTIFIE R ON
  7   GO
  8   CREATE Pro c [dbo].[p rcDVEIRRef erralProce duresRepor t]     
  9  
  10   --
  11   -- DESCRIP TION:
  12   --
  13   --               Popu lates the  principal  data set u tilised by  the corre sponding S SRS report  for the 
  14   --      DV EIR VA Reg istry.
  15   --
  16   --               Busi ness rules  stipulate  that the  COMPLETED/ PENDING DO D delivery  STATUS of  a Referra l be 
  17   --      de termined b y two flag s in one o r more ENC OUNTER(s)  related to  a Referra l that sig nal whethe
  18   --      th e Referral  in questi on is read y for disp atch to th e DOD or h as already  been sent  to the DO D.
  19   --
  20   -- AUTHOR( s):
  21   --
  22   --               jps
  23   --
  24   -- CREATIO N DATE:
  25   --
  26   --               12-J ul-2010
  27   --
  28   -- MODIFIC ATION HIST ORY:
  29   -- WHEN          WHO               WHY
  30   -- ------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
  31   -- 23-Jul- 2010  jps               Add mult i-valued p arameters
  32   --                                                                    @VisnI D, 
  33   --                                                                    @Diagn oses 
  34   --                        specia lly proces sed by (ne w) user-de fined func tion fncSp lit. These  parameter
  35   --                        replac e Filters  in the SSR S Report.
  36   -- 23-Jul- 2010  jps               Add WHER E clause i nvolving p arameter @ VisnId to  main SELEC T statemen t.
  37   -- 23-Jul- 2010  jps               Add WHER E clauses  involving  parameter  @Diagnoses  to CASE e xpressions  in 
  38   --                                                  SE LECT state ments that  separatel y process  Fiscal and  Calendar  Year data.
  39   -- 29-Nov- 2011  V.Na ik  Modifi ed to add  records us ing union  when no re cords exis ts for sel ected year s,
  40   --                                                  wi ll display  zero in r eport.                       
  41   -- ------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --
  42  
  43   (
  44           --  Input Par ameter(s)
  45           @I sFisYr bit  = 0,
  46           @I sCalYr bit  = 0,
  47           @V isnID varc har(8000)  = NULL,    -- multipl e, comma-s eparated v alues when  not NULL 
  48           @D iagnoses V ARCHAR(800 0) = NULL  -- multipl e, comma-s eparated v alues when  not NULL 
  49   )
  50  
  51   AS
  52  
  53   SET TRANSA CTION ISOL ATION LEVE L READ UNC OMMITTED
  54   SET NOCOUN T ON
  55   SET CONCAT _NULL_YIEL DS_NULL OF F
  56  
  57   BEGIN TRY
  58  
  59           --
  60            - - Use an i ntermediar y Table va riable to  store resu lt-sets se parately f or fiscal  and calend ar years
  61            - - because  of the nee d to perfo rm the con trol-break s (i.e., G ROUP BY) d ifferently  for each  of them.
  62            - -
  63   DECLARE @t blReferral Procedure  TABLE
  64           ( 
  65              VId                     varchar( 8),      
  66              FisYr                   smallint ,
  67              CalYr                   smallint ,
  68              RefId                   int,
  69              RefStat                 varchar( 64),  
  70              DiagCd                  varchar( 16),
  71              ProcCd                  varchar( 128)
  72           );
  73  
  74   INSERT INT O @tblRefe rralProced ure
  75   SELECT DIS TINCT
  76           --
  77           v. VisnID,
  78           --
  79           dc .FiscalYea r AS 'Fisc al Year',
  80           --
  81           dc .Year AS ' Calendar Y ear',
  82           --
  83           r. Referral_I D,
  84           --  Business  Rule: Deli very statu s of a Ref erral is w ith refere nce to one  or more a ssociated  ENCOUNTERs
  85           CA SE
  86                    WHEN  (  EXISTS
  87                                      (SELECT      REFERR AL_ID
  88                                      FROM          DVEIR .ER_ENCOUN TER
  89                                      WHERE      (SendTo_ DoD_DVEIR_ FLAG = 1)  AND (ER_EN COUNTER.RE FERRAL_ID  = R.REFERR AL_ID))
  90                                      )
  91                             THEN ' Sent to Do D DVEIR' - -'Referral  Completed ' --
  92                    WHEN  (  EXISTS
  93                                      (SELECT      REFERR AL_ID
  94                                      FROM          DVEIR .ER_ENCOUN TER
  95                                      WHERE      (Ready_t o_Send_to_ DVEIR_FLAG  = 1) AND  (ER_ENCOUN TER.REFERR AL_ID = R. REFERRAL_I D))
  96                                      )
  97                             THEN ' Ready to S end to DVE IR' --'Ref erral Comp leted' --
  98                    ELSE
  99                             sr.NAM E --'Refer ral Pendin g' --
  100                    
  101           EN D AS 'Refe rral/Encou nter Statu s',
  102           --
  103           --  NOTE: To   be examin ed if the  above set  of sub-que ries is ne cessary wh en the
  104           --        Cas e expressi on below y iels the s ame result s
  105           -- CASE 
  106                    --WH EN e.Ready _to_Send_t o_DVEIR_FL AG = 1 
  107                    --       THEN ' Ready to S end to DVE IR' --'Ref erral Comp leted'    
  108                    --WH EN e.SendT o_DoD_DVEI R_FLAG = 1
  109                    --     THEN 'Se nt to DoD  DVEIR' --  'Referral  Completed'   
  110                    --EL SE sr.NAME   
  111           -- END AS 'Re ferral/Enc ounter Sta tus',
  112       --
  113       ed.COD E as 'Diag nosticCode ',
  114       --
  115       ep.COD E as 'Proc eduralCode '        
  116   --
  117   FROM dbo.R EFERRAL r  (nolock) 
  118           --
  119           IN NER JOIN d veir.ER_EN COUNTER e  (NOLOCK)
  120                    ON r .REFERRAL_ ID = e.REF ERRAL_ID
  121           --
  122           IN NER JOIN D VEIR.ER_DI AG_DTL ed  (nolock) 
  123                    on e .ER_ENCOUN TER_ID = e d.ER_ENCOU NTER_ID
  124           --
  125           IN NER JOIN D VEIR.ER_PR OCEDURE_DT L ep (nolo ck) 
  126                    on e .ER_ENCOUN TER_ID = e p.ER_ENCOU NTER_ID
  127           --
  128           IN NER JOIN v iewFacilit iesByVisn  V
  129                    ON r .STD_INSTI TUTION_ID  = V.instit ution_id
  130           --
  131           IN NER JOIN S TD_REFERRA LSTS sr 
  132                    ON r .STD_REFER RALSTS_ID  = sr.ID
  133           --
  134           IN NER JOIN d bo.dimCale ndar dc (N OLOCK)
  135                    ON C AST(CONVER T(varchar( 10),r.CREA TED,101) a s datetime ) = dc.Ful l_Day  
  136   --
  137   WHERE (v.V isnID IN ( SELECT * F ROM fncSpl it(@VisnID , ','))
  138          OR  @VisnID IS  NULL);      
  139                        
  140           --  Enable fo r DEBUGGIN G
  141           -- SELECT * F ROM @tblRe ferralProc edure;
  142           
  143   DECLARE @Y ear TABLE
  144           (
  145              EYear SMAL LINT
  146              )
  147                      
  148   DECLARE @V ISN TABLE
  149                    (
  150                       VisnID  DNS    AR (20)
  151                      )
  152                      
  153   INSERT INT O @VISN
  154   SELECT
  155           DI STINCT Vis nID
  156   FROM
  157           vi ewFaciliti esByVisn
  158  
  159   DECLARE @D iagCode TA BLE
  160                    (
  161                       Code  DNS    AR (20)
  162                      )
  163                      
  164   INSERT INT O @DiagCod e
  165   SELECT
  166           DI STINCT COD E       
  167   FROM
  168           DV EIR.STD_ER _ICD9_CODE
  169   WHERE EYE_ DIAGNOSIS_ FLAG = 1
  170         AND  INACTIVE_F LAG = 0
  171   ORDER BY C ODE
  172  
  173   -- Process  report da ta for Fis cal Year(s )
  174   IF (@IsFis Yr = 1)
  175           BE GIN
  176           IN SERT INTO  @Year
  177           SE LECT 
  178                    DIST INCT Fisca lYear --AS  'ReportYe ar'
  179                    FROM  dimCalend ar
  180                    WHER E FiscalYe ar <= DATE PART(yyyy,  GETDATE() ) + 1
  181                    ORDE R BY Fisca lYear DESC
  182                    
  183                    SELE CT  DISTIN CT
  184                                      --
  185                             vId,
  186                             -- 
  187                                      fisYr AS  rptYr,
  188                                      --
  189                                      RefId AS  'Initiate dReferralI d',
  190                                      -- Tag c ompletion  status wit h Referral Id to faci litate use  of COUNT  aggregate  function
  191                                      CASE
  192                                               WHEN ((Ref Stat = 'Re ady to Sen d to DVEIR
  193                                                      OR  RefStat =  'Sent to D oD DvEIR')
  194                                                     AND  (DiagCd IN  ( SELECT  * FROM fnc Split(@Dia gnoses, ', '))
  195                                                           OR @Diagn oses IS NU LL))
  196                                                      THEN CAST( RefId AS  DNS    AR) + ' '  + 'Referra l Complete d'
  197                                               ELSE NULL
  198                                      END AS ' ReferralSt atus',
  199                                      --
  200                                      DiagCd A S 'Diagnos ticCd',
  201                                      --      
  202                                      CASE
  203                                               WHEN ((Ref Stat = 'Re ady to Sen d to DVEIR
  204                                                      OR  RefStat =  'Sent to D oD DvEIR')
  205                                                     AND  (DiagCd IN  ( SELECT  * FROM fnc Split(@Dia gnoses, ', '))
  206                                                           OR @Diagn oses IS NU LL))
  207                                                THEN 'Proc edure ' +  ProcCd + '  performed  for Diagn osis ' + D iagCd + '  on Complet ed Referra l ' + CAST (RefId AS  DNS    AR)
  208                                               ELSE NULL
  209                                      END AS ' Procedural Cd'
  210                    --
  211                    FROM  @tblRefer ralProcedu re 
  212                    --
  213                    --OR DER BY vid , fisYr DE SC
  214                    
  215                    UNIO
  216                    SELE CT V.VisnI D,Y.EYEAR, NULL,NULL, DC.CODE,NU LL
  217                    FROM  @YEAR Y,  @VISN V,@D iagCode DC
  218                    WHER E Y.EYEAR  NOT IN (SE LECT DISTI NCT fisYr  FROM @tblR eferralPro cedure)      
  219                    ORDE R BY fisYr  DESC
  220           
  221           EN D -- @IsFi sYr = 1)
  222                    
  223   -- Process  report da ta for Cal endar Year (s)
  224   IF (@IsCal Yr = 1)
  225           BE GIN
  226           
  227           IN SERT INTO  @Year
  228           SE LECT 
  229                    DIST INCT Fisca lYear --AS  'ReportYe ar'
  230                    FROM  dimCalend ar
  231                    WHER E FiscalYe ar <= DATE PART(yyyy,  GETDATE() ) + 1
  232                    ORDE R BY Fisca lYear DESC
  233                    
  234                    SELE CT  DISTIN CT 
  235                                      --
  236                             vId,
  237                             -- 
  238                                      calYr AS  rptYr,
  239                                      --
  240                                      RefId AS  'Initiate dReferralI d',
  241                                      -- Tag c ompletion  status wit h Referral Id to faci litate use  of COUNT  aggregate  function
  242                                      CASE
  243                                               WHEN (RefS tat = 'Rea dy to Send  to DVEIR'  
  244                                                     OR R efStat = ' Sent to Do D DvEIR')
  245                                                    AND ( DiagCd IN  ( SELECT *  FROM fncS plit(@Diag noses, ',' ))
  246                                                           OR @Diagn oses IS NU LL) 
  247                                           THEN CAST( RefId AS  DNS    AR) + ' '  + 'Referra l Complete d'                               
  248                                               ELSE NULL
  249                                      END AS ' ReferralSt atus',
  250                                      --
  251                                      DiagCd A S 'Diagnos ticCd',         
  252                                      --
  253                                      CASE
  254                                               WHEN ((Ref Stat = 'Re ady to Sen d to DVEIR
  255                                                      OR  RefStat =  'Sent to D oD DvEIR')
  256                                                     AND  (DiagCd IN  ( SELECT  * FROM fnc Split(@Dia gnoses, ', '))
  257                                                           OR @Diagn oses IS NU LL))
  258                                                THEN 'Proc edure ' +  ProcCd + '  performed  for Diagn osis ' + D iagCd + '  on Complet ed Referra l ' + CAST (RefId AS  DNS    AR)
  259                                               ELSE NULL
  260                                      END AS ' Procedural Cd'
  261                    --
  262                    FROM  @tblRefer ralProcedu re
  263                    --       
  264                    --OR DER BY vid , calYr DE SC
  265                    
  266                    UNIO
  267                    SELE CT V.VisnI D,Y.EYEAR, NULL,NULL, DC.CODE,NU LL
  268                    FROM  @YEAR Y,  @VISN V, @ DiagCode D C
  269                    WHER E Y.EYEAR  NOT IN (SE LECT DISTI NCT calYr  FROM @tblR eferralPro cedure)      
  270                    ORDE R BY calYr  DESC
  271           
  272           EN D -- @IsCa lYr = 1)             
  273           
  274   END TRY
  275  
  276   BEGIN CATC H
  277  
  278           RE TURN
  279  
  280   END CATCH
  281   GO