Produced by Araxis Merge on 8/29/2017 11:27:24 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | REFDOC-devel-20170714.zip\NVCC\Database\PanelMgmt\Stored Procedures | usp_RebuildAllCDWPatients.sql | Fri Jul 14 21:26:48 2017 UTC |
| 2 | REFDOC-devel-20170714.zip\NVCC\Database\PanelMgmt\Stored Procedures | usp_RebuildAllCDWPatients.sql | Mon Aug 28 11:57:51 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 328 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| 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 |
No regular expressions were active.
| 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_ AllCDWPati ents | |
| 9 | --Server : DNS URL | |
| 10 | --Data Bas e : NWIC _PanelMgmt | |
| 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 : 07-1 4-2017 | |
| 32 | --Last Cha nged By : Brian Diggs - NW IC | |
| 33 | --Reason F or Change : Implem ented sugg estions fr om Andrew Kelly | |
| 34 | -- | |
| 35 | --Last Cha nged : 06-0 9-2017 | |
| 36 | --Last Cha nged By : Brian Diggs - NW IC | |
| 37 | --Reason F or Change : Conver ted to inc remental u pdate foll owing reco mmended CD W | |
| 38 | -- para digm | |
| 39 | -- | |
| 40 | --Last Cha nged : 04-1 9-2017 | |
| 41 | --Last Cha nged By : Brian Diggs - NW IC | |
| 42 | --Reason F or Change : Stripp ed this do wn to just the parts needed fo r REFDOC | |
| 43 | -- as p art of the migration to the Fi eld Report ing Enclav e. | |
| 44 | -- The only colum ns needed are Sta3n, PatientSS N, Patient ICN, | |
| 45 | -- Pati entSID, an d PatientI EN. | |
| 46 | -- | |
| 47 | --Last Cha nged : 06-0 6-2016 | |
| 48 | --Last Cha nged By : Jerry Kohler - N WIC | |
| 49 | --Reason F or Change : Added Next of Ki n, and per Microsoft recommend ation | |
| 50 | -- chan ged drop/c reate tabl e to drop indexes an d TRUNCATE . | |
| 51 | -- Also added WIT H (TABLOCK ) in the i nsert. | |
| 52 | -- All of this sh ould boost the perfo rmance, an d not | |
| 53 | -- elim inate stor ed executi on plans o n the tabl e. | |
| 54 | -- | |
| 55 | --Last Cha nged : 06-0 3-2016 | |
| 56 | --Last Cha nged By : Jerry Kohler - N WIC | |
| 57 | --Reason F or Change : Take a ll patient s from SPa tient, tes t or decea sed. | |
| 58 | -- Join to PanelM gmt.PMMast erCohortDe ceasedInde xNEW | |
| 59 | -- to e nsure bett er accurac y. Add de ceased fla g and | |
| 60 | -- date of death. | |
| 61 | ||
| 62 | --Last Cha nged : 04-0 5-2016 | |
| 63 | --Last Cha nged By : Jianji Yang - NW IC | |
| 64 | --Reason F or Change : Add te st patient data, dec eased pati ents, and patient's | |
| 65 | -- : home station ( based on P CP's Sta3n ). | |
| 66 | -- | |
| 67 | --Last Cha nged : 03-1 7-2017 | |
| 68 | --Last Cha nged By : Jerry Kohler - N WIC | |
| 69 | --Reason F or Change : Add Pa tientIEN s o that fun ction App. udf_AllPat ientsSIDs | |
| 70 | -- : can now hit Al lCDWPatien ts instead of SPatie nt. This | |
| 71 | -- : tabl e is much smaller, a nd will be much fast er. | |
| 72 | -- | |
| 73 | --Last Cha nged : 03-2 0-2017 | |
| 74 | --Last Cha nged By : Jerry Kohler - N WIC | |
| 75 | --Reason F or Change : Change procedure to place data in a temporary table THEN | |
| 76 | -- : trun cate and i nsert into the produ ction tabl e. This | |
| 77 | -- : mini mize the a mount of t ime querie s would re turn no da ta. | |
| 78 | --======== ========== ========== ========== ========== ========== ========== ========== ==== | |
| 79 | ||
| 80 | BEGIN | |
| 81 | ||
| 82 | SE T NOCOUNT ON; | |
| 83 | ||
| 84 | -- declare ba tch variab les and cu rsor | |
| 85 | DE CLARE @ETL BatchID AS INT, @Ext ractBatchI D AS INT; | |
| 86 | DE CLARE @DWV iewName AS VARCHAR(1 00) = 'SPa tient'; | |
| 87 | ||
| 88 | -- add a TRY/ CATCH to e xit upon f ailure | |
| 89 | BE GIN TRY | |
| 90 | ||
| 91 | SET @ExtractBa tchID = (S ELECT EL.L astExtract BatchID FR OM Dflt.Ex tractBatch Log AS EL WHERE EL.D WViewName = @DWViewN ame) ; | |
| 92 | ||
| 93 | DECL ARE BatchC ursor CURS OR STATIC | |
| 94 | FOR | |
| 95 | --ge t batch id s | |
| 96 | SELE CT EX.ETLB atchID, EX .ExtractBa tchID | |
| 97 | FROM SPV.EB.Ex tractBatch AS EX | |
| 98 | WHER E EX.DWVie wName = @D WViewName | |
| 99 | AND EX .ExtractBa tchID > @E xtractBatc hID | |
| 100 | ORDE R BY EX.Ex tractBatch ID; | |
| 101 | ||
| 102 | OPEN BatchCurs or; | |
| 103 | FETC H NEXT FRO M BatchCur sor INTO @ ETLBatchID , @Extract BatchID; | |
| 104 | ||
| 105 | WHIL E @@FETCH_ STATUS = 0 | |
| 106 | BEGI N | |
| 107 | ||
| 108 | --merg e data fro m view int o producti on(destina tion) tabl e | |
| 109 | MERGE | |
| 110 | App.AllC DWPatients AS D | |
| 111 | USING | |
| 112 | ( | |
| 113 | SELECT Sta 3n, Patien tIEN, Pati entSSN, Pa tientSID, PatientICN | |
| 114 | FROM SPV.S Patient.SP atient | |
| 115 | WHERE ETLB atchID = @ ETLBatchID | |
| 116 | ) AS M | |
| 117 | ON | |
| 118 | D.Patien tSID = M.P atientSID | |
| 119 | WHEN N OT MATCHED THEN | |
| 120 | INSERT | |
| 121 | ( | |
| 122 | St a3n, Patie ntIEN, Pat ientSSN, P atientSID, PatientIC N | |
| 123 | ) | |
| 124 | VALUES | |
| 125 | ( | |
| 126 | M. Sta3n, M.P atientIEN, M.Patient SSN, M.Pat ientSID, M .PatientIC N | |
| 127 | ) | |
| 128 | WHEN M ATCHED THE N | |
| 129 | UPDATE S ET | |
| 130 | Sta3n = m. Sta3n | |
| 131 | ,PatientIE N = m. PatientIEN | |
| 132 | ,PatientSS N = m. PatientSSN | |
| 133 | ,PatientIC N = m. PatientICN | |
| 134 | ; | |
| 135 | ||
| 136 | --afte r merging batch then update th e ExtractB atchLog ta ble | |
| 137 | UPDATE Dflt.Extr actBatchLo g | |
| 138 | SET Last ExtractBat chID = @Ex tractBatch ID, LastEx tractDateT ime = GETD ATE() | |
| 139 | WHERE DWViewName = @DWView Name; | |
| 140 | ||
| 141 | --grab the next batch for processing | |
| 142 | FETCH NEXT FROM BatchCurso r INTO @ET LBatchID, @ExtractBa tchID; | |
| 143 | END | |
| 144 | ||
| 145 | --cl ose and de allocate t he cursor once all b atches for a given t able have been proce ssed | |
| 146 | CLOS E BatchCur sor; | |
| 147 | DEAL LOCATE Bat chCursor; | |
| 148 | EN D TRY | |
| 149 | ||
| 150 | -- CATCH will report ba ck specifi c details about fail ure; the l oop will s top | |
| 151 | BE GIN CATCH | |
| 152 | ||
| 153 | SELE CT | |
| 154 | ERRO R_NUMBER() AS ErrorN umber, | |
| 155 | ERRO R_SEVERITY () AS Erro rSeverity, | |
| 156 | ERRO R_STATE() AS ErrorSt ate, | |
| 157 | ERRO R_PROCEDUR E() AS Err orProcedur e, | |
| 158 | ERRO R_LINE() A S ErrorLin e, | |
| 159 | ERRO R_MESSAGE( ) AS Error Message; | |
| 160 | ||
| 161 | EN D CATCH | |
| 162 | ||
| 163 | END | |
| 164 | ||
| 165 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.