89. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/31/2018 9:02:24 AM Central Standard 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.

89.1 Files compared

# Location File Last Modified
1 NVCC_2.2_01162018.zip\NVCC\SQL NVCC_usp_UsageData2.sql Thu Oct 19 16:37:26 2017 UTC
2 NVCC_2.2_01162018.zip\NVCC\SQL NVCC_usp_UsageData2.sql Wed Jan 31 13:39:23 2018 UTC

89.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 8 456
Changed 8 30
Inserted 0 0
Removed 0 0

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

89.4 Active regular expressions

No regular expressions were active.

89.5 Comparison detail

  1   --DROP PRO CEDURE App .NVCC_usp_ UsageData2
  2  
  3   USE NWIC_P anelMgmt
  4   GO
  5  
  6   SET ANSI_N ULLS ON
  7   GO
  8  
  9   SET QUOTED _IDENTIFIE R ON
  10   GO
  11  
  12   CREATE PRO CEDURE App .NVCC_usp_ UsageData2
  13           --  @timegrou p is a cha racter par ameter whi ch can tak e values N ULL, 'day' , 'week',
  14           --  'month',  'quarter',  'year', o r 'ever'.  NULL is eq uivalent t o 'ever'.  Any other  value
  15           --  will resu lt in unde find behav ior.
  16           @t imegroup v archar(max ) NULL,
  17           --  @statisti c is a cha racter par ameter whi ch can tak e values ' count' or  'cumulativ e'.
  18           --  Any other  value wil l result i n undefine d behavior .
  19           --  For 'coun t', the va lue N repr esents num ber within  that time group and  any
  20           --  other gro uping cate gories
  21           --  For 'cumu lative', t he value N  represent s the cumu lative num ber, over  time,
  22           --  up to tha t timepoin t, separat ed by any  other grou ping categ ories
  23           @s tatistic v archar(max ) NULL,
  24           --  @sta3n is  a charact er paramet er which c an either  NULL, a si ngle stati on number,
  25           --  or a comm a demlimit ed list of  station n umbers. NU LL implies  that the  data for
  26           --  all stati ons should  be return ed/used an d that no  stratifica tion by st ation shou ld
  27           --  be done.  A single s tation num ber (as a  string) wi ll return  data for o nly that
  28           --  station.  A comma de limited li st of stat ion number s will res trict the  returned d ata
  29           --  to those  present in  the list  and any ag gregation  or ordinat ion will b e done
  30           --  separatel y for each  station.
  31           @s ta3n varch ar(max) NU LL,
  32           --  @userid i s a charac ter parame ter which  can either  NULL, a s ingle user  identifie r,
  33           --  or a comm a demlimit ed list of  user iden tifiers. A  user iden tifier is  a login,
  34           --  including  the domai n. NULL im plies that  the data  for all us erss stati ons should
  35           --  be return ed/used an d that no  stratifica tion by us er should  be done. A  userid
  36           --  will retu rn data fo r only tha t user. A  comma deli mited list  of users  will
  37           --  restrict  the return ed data to  those pre sent in th e list and  any aggre gation
  38           --  or ordina tion will  be done se parately f or each us er.
  39           @u serid varc har(max) N ULL
  40   AS
  41   --======== ========== ========== ========== ========== ========== ========== ========== ====
  42   --Requesto r              : Non  Va Coordin ated Care  Project
  43   --Author                  : Bria n Diggs
  44   --Object/S P Name         : App. NVCC_usp_U sageData2
  45   --Server                  :  SERVER        
  46   --Data Bas e              : NWIC _PanelMgmt
  47   --Schema                  : app
  48   --Report                  : N/A
  49   --Folder                  : N/A
  50   --Report L oc             : N/A
  51   --Job                     : None
  52   --Job Loc                 : None
  53   --Note                    : 
  54   --Date Cre ated           : 08-0 3-2016
  55   --
  56   --Last Cha nged           : 
  57   --Last Cha nged By                 : 
  58   --Reason F or Change               : 
  59   --
  60   --Purpose                 : To g et aggrega ted, subse tted produ ction coun ts.
  61   --======== ========== ========== ========== ========== ========== ========== ========== ====
  62   --Uses: NW IC_PanelMg mt.App.udf _SplitStri ng
  63   --Uses: NW IC_PanelMg mt.App.vNV CC_Product ionAccessL og
  64   --Uses: NW IC_PanelMg mt.App.NVC C_Users
  65   --Uses: CD WWork.Pati ent.Patien t
  66   --Uses: CD WWork.SSta ff.SStaff
  67  
  68   BEGIN
  69           --  First, cr eate a tem porary tab le, #LogDa ta, which  pulls reco rds from
  70           --  App.NVCC_ Production AccessLog.
  71           --
  72           --  The Acces sDateTime  and UserID  are kept  from the l og, and th e
  73           --  PatientSI D is used  to determi ne the Sta 3n for tha t patient.
  74           --
  75           --  This list  is furthe r restrict ed to thos e stations  and users  specified
  76           --  by the pa rameters.  This is ac complished  by conver ting the p arameter
  77           --  string to  a table u sing App.u df_SplitSt ring. Only  the value  is kept
  78           --  and, for  the statio n, convert ed to a sm allint to  match the  datatype
  79           --  elsewhere . An input  of NULL w ill give a  single ro w table wi th value
  80           --  NULL. The se convers ions are d one as com mon table  expression s.
  81           --  These tab le are INN ER JOIN-ed  to the da ta, with t he clause  that
  82           --  everythin g is kept  if the val ue is NULL .
  83           --
  84           --  UserID an d Sta3n ar e converte d to NULL  if their r espective  parameters
  85           --  are NULL.  This indi cates that  there is  no stratif ication do ne (or
  86           --  possible)  on those  variables.  The TimeG roup colum n contains  a date
  87           --  which is  the start  of the int erval corr esponding  to the req uested
  88           --  aggregati on level ( day, start  of week,  start of m onth, star t of
  89           --  quarter,  start of y ear).
  90           WI TH
  91                    Sta3 n AS (SELE CT CONVERT (smallint,  Value) AS  Sta3n FRO M App.udf_ SplitStrin g(@sta3n,  ',')),
  92                    User ID AS (SEL ECT Value  AS UserID  FROM App.u df_SplitSt ring(@user id, ','))
  93                    SELE CT
  94                             IIF(@u serid IS N ULL, NULL,  al.UserID ) AS UserI D,
  95                             IIF(@s ta3n IS NU LL, NULL,  p.sta3n) A S Sta3n,
  96                             CASE @ timegroup
  97                                      WHEN 'da y' THEN
  98                                               CONVERT(DA TE, al.Acc essDateTim e)
  99                                      WHEN 'we ek' THEN
  100                                               CONVERT(DA TE, DATEAD D(DAY, 7 *  (DATEDIFF (DAY, '199 0-01-07',  al.AccessD ateTime) /  7), '1990 -01-07'))
  101                                      WHEN 'mo nth' THEN
  102                                               DATEFROMPA RTS(DATEPA RT(YEAR, a l.AccessDa teTime), D ATEPART(MO NTH, al.Ac cessDateTi me), 1)
  103                                      WHEN 'qu arter' THE N
  104                                               DATEFROMPA RTS(DATEPA RT(YEAR, a l.AccessDa teTime), ( ((DATEPART (MONTH, al .AccessDat eTime) - 1 ) / 3) * 3 ) + 1, 1)
  105                                      WHEN 'ye ar' THEN
  106                                               DATEFROMPA RTS(DATEPA RT(YEAR, a l.AccessDa teTime), 1 , 1)
  107                                      WHEN 'ev er' THEN
  108                                               NULL
  109                             END AS  TimeGroup
  110                    INTO  #LogData
  111                    FROM
  112                             NWIC_P anelMgmt.A pp.vNVCC_P roductionA ccessLog a l
  113                             INNER  JOIN CDWWo rk.Patient .Patient p
  114                                      ON al.Pa tientSID =  p.Patient SID
  115                             INNER  JOIN Sta3n  st
  116                                      ON (p.St a3n = st.S ta3n OR st .Sta3n IS  NULL)
  117                             INNER  JOIN UserI D uid
  118                                      ON (al.U serID = ui d.UserID O R uid.User ID IS NULL )
  119  
  120           --  A tempora ry table,  #LogAgg, i s created  based on t he structu re of #Log Agg plus o ne
  121           --  other, NU LLable num eric colum n N. This  must be do ne in a se parate ste p
  122           --  step (rat her than i mplicitly  with a SEL ECT ... IN TO) becaus e the same  named
  123           --  temporary  table can  not be us ed as a ta rget for m ultiple SE LECT ... I NTO statem ents.
  124           --  The WHERE  clause is  designed  to select  no rows, s o no data  is initial ly seeded
  125           --  in the te mporary ta ble.
  126           SE LECT
  127                    ld.* ,
  128                    CONV ERT(intege r, NULL) A S N
  129           IN TO #LogAgg
  130           FR OM #LogDat a AS ld
  131           WH ERE 1=0;
  132  
  133           --  Choose th e code pat h based on  the value  of @stati stic.
  134           IF  (@statist ic = 'coun t')
  135                    BEGI N
  136                             INSERT  INTO #Log Agg (Sta3n , UserID,  TimeGroup,  N)
  137                             SELECT
  138                                      Sta3n,
  139                                      UserID,
  140                                      TimeGrou p,
  141                                      COUNT(*)  AS N
  142                             FROM # LogData
  143                             GROUP  BY Sta3n,  UserID, Ti meGroup
  144                    END
  145  
  146           IF  (@statist ic = 'cumu lative')
  147                    BEGI N
  148                             INSERT  INTO #Log Agg (Sta3n , UserID,  TimeGroup,  N)
  149                             SELECT
  150                                      Sta3n,
  151                                      UserID,
  152                                      TimeGrou p,
  153                                      SUM(N) O VER (PARTI TION BY St a3n, UserI D ORDER BY  TimeGroup ) AS N
  154                             FROM (
  155                                      SELECT
  156                                               Sta3n,
  157                                               UserID,
  158                                               TimeGroup,
  159                                               COUNT(*) A S N
  160                                      FROM #Lo gData
  161                                      GROUP BY  Sta3n, Us erID, Time Group
  162                             ) A
  163                    END
  164  
  165           --  This temp orary tabl e is no lo nger neede d.
  166           DR OP TABLE # LogData;
  167  
  168           --  Further a nnotate th e #LogAgg  table by c onverting  the UserID
  169           --  into the  Staff Name  and conve rting the  station nu mber into
  170           --  a more us able versi on of the  station na me based o n the
  171           --  App.udf_S tationName  function.
  172           --
  173           --  An additi onal ID co lumn is in cluded so  that Entit y Framewor k
  174           --  has somet hing to us e as a pri mary key.  Ironically , there is
  175           --  no column  in the ta ble which  is guarant eed to be  non-NULL
  176           --  for all v alues of t he paramet ers. And a pparently,  having
  177           --  ID as the  ORDER BY  inside the  OVER clau se definin g ID
  178           --  isn't inv alid. I ha ve no idea  what it m eans, thou gh.
  179           --  However,  since the  ID is not  semantical ly meaning ful (it
  180           --  just has  to be uniq ue), it do esn't matt er.
  181           --
  182           --  Return th is further  annotated  table.
  183           SE LECT
  184                    ROW_ NUMBER() O VER (ORDER  BY ID) AS  ID,
  185                    la.* ,
  186                    s.St affName,
  187                    App. udf_Statio nName(la.S ta3n) AS S tation
  188           FR OM
  189                    #Log Agg AS la
  190                    LEFT  JOIN NWIC _PanelMgmt .App.NVCC_ Users u
  191                             ON la. UserID = u .DomainPlu sNetworkUs erName
  192                    LEFT  JOIN CDWW ork.SStaff .SStaff s
  193                             ON u.U serIEN = s .StaffIEN  and u.Sta3 n = s.Sta3 n
  194           OR DER BY Sta 3n, UserID , TimeGrou p
  195   END
  196   GO
  197  
  198   exec sp_Si gnAppObjec t 'NVCC_us p_UsageDat a2';
  199  
  200   -- Example s/Tests:
  201   --EXEC App .NVCC_usp_ UsageData2  NULL, NUL L, NULL, N ULL;
  202   --EXEC App .NVCC_usp_ UsageData2  NULL, 'co unt', NULL , NULL;
  203   --EXEC App .NVCC_usp_ UsageData2  NULL, 'cu mulative',  NULL, NUL L;
  204   --EXEC App .NVCC_usp_ UsageData2  'day', 'c ount', NUL L, NULL;
  205   --EXEC App .NVCC_usp_ UsageData2  'day', 'c umulative' , NULL, NU LL;
  206   --EXEC App .NVCC_usp_ UsageData2  'day', 'c ount', '61 0,531', NU LL;
  207   --EXEC App .NVCC_usp_ UsageData2  'day', 'c umulative' , '610,531 ', NULL;
  208   --EXEC App .NVCC_usp_ UsageData2  'day', 'c ount', '64 8', ' D O M A IN \ U S ER,DOM A I N \USER ';
  209   --EXEC App .NVCC_usp_ UsageData2  'day', 'c umulative' , '648', ' D O M A IN \ U S ER,DOM A I N \USER ';
  210   --EXEC App .NVCC_usp_ UsageData2  'week', ' count', NU LL, NULL;
  211   --EXEC App .NVCC_usp_ UsageData2  'week', ' cumulative ', NULL, N ULL;
  212   --EXEC App .NVCC_usp_ UsageData2  'week', ' count', '6 10,531', N ULL;
  213   --EXEC App .NVCC_usp_ UsageData2  'week', ' cumulative ', '610,53 1', NULL;
  214   --EXEC App .NVCC_usp_ UsageData2  'week', ' count', '6 48', ' D O M A IN \ U S ER,DOM A I N \USER ';
  215   --EXEC App .NVCC_usp_ UsageData2  'week', ' cumulative ', '648',  ' D O M A IN \ U S ER,DOM A I N \USER ';
  216   --EXEC App .NVCC_usp_ UsageData2  'month',  'count', N ULL, NULL;
  217   --EXEC App .NVCC_usp_ UsageData2  'month',  'cumulativ e', NULL,  NULL;
  218   --EXEC App .NVCC_usp_ UsageData2  'month',  'count', ' 648,610,53 1', NULL;
  219   --EXEC App .NVCC_usp_ UsageData2  'month',  'cumulativ e', '648,6 10,531', N ULL;
  220   --EXEC App .NVCC_usp_ UsageData2  'month',  'count', ' 648', ' D O M A IN \ U S ER,DOM A I N \USER ';
  221   --EXEC App .NVCC_usp_ UsageData2  'month',  'cumulativ e', '648',  ' D O M A IN \ U S ER,DOM A I N \USER ';
  222   --Exec App .NVCC_usp_ UsageData2  'ever', ' count', nu ll, null;
  223   --Exec App .NVCC_usp_ UsageData2  'ever', ' count', '6 48', null;
  224   --Exec App .NVCC_usp_ UsageData2  'ever', ' count', '6 48,610', n ull;
  225   --EXEC App .NVCC_usp_ UsageData2  'ever', ' count', '6 48', ' D O M A I N \USER ';
  226   --EXEC App .NVCC_usp_ UsageData2  'ever', ' count', NU LL, ' D O M A I N \USER ';
  227   --Exec App .NVCC_usp_ UsageData2  'ever', ' cumulative ', null, n ull;
  228   --Exec App .NVCC_usp_ UsageData2  'ever', ' cumulative ', '648',  null;
  229   --Exec App .NVCC_usp_ UsageData2  'ever', ' cumulative ', '648,61 0', null;
  230   --EXEC App .NVCC_usp_ UsageData2  'ever', ' cumulative ', '648',  ' D O M A I N \USER ';
  231   --EXEC App .NVCC_usp_ UsageData2  'ever', ' cumulative ', NULL, ' D O M A I N \USER ';
  232   --EXEC App .NVCC_usp_ UsageData2  'quarter' , 'count',  NULL, NUL L;
  233   --EXEC App .NVCC_usp_ UsageData2  'quarter' , 'cumulat ive', NULL , NULL;
  234   --EXEC App .NVCC_usp_ UsageData2  'quarter' , 'count',  '648,610, 531', NULL ;
  235   --EXEC App .NVCC_usp_ UsageData2  'quarter' , 'cumulat ive', '648 ,610,531',  NULL;
  236   --EXEC App .NVCC_usp_ UsageData2  'quarter' , 'count',  '648', ' D O M A IN \ U S ER,DOM A I N \USER ';
  237   --EXEC App .NVCC_usp_ UsageData2  'quarter' , 'cumulat ive', '648 ', ' D O M A IN \ U S ER,DOM A I N \USER ';
  238   --EXEC App .NVCC_usp_ UsageData2  'year', ' count', NU LL, NULL;
  239   --EXEC App .NVCC_usp_ UsageData2  'year', ' cumulative ', NULL, N ULL;
  240   --EXEC App .NVCC_usp_ UsageData2  'year', ' count', '6 48,610,531 ', NULL;
  241   --EXEC App .NVCC_usp_ UsageData2  'year', ' cumulative ', '648,61 0,531', NU LL;
  242   --EXEC App .NVCC_usp_ UsageData2  'year', ' count', '6 48', ' D O M A IN \ U S ER,DOM A I N \USER ';
  243   --EXEC App .NVCC_usp_ UsageData2  'year', ' cumulative ', '648',  ' D O M A IN \ U S ER,DOM A I N \USER ';