Produced by Araxis Merge on 6/9/2017 3:51:18 PM 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 | Fri Jun 9 19:51:18 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-svc-consent-mgmt\src\main\java\gov\va\nvap\svc\consentmgmt\stub\data | ConsentDirective.java | Fri Apr 21 20:03:30 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 444 |
| 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 | * To chan ge this te mplate, ch oose Tools | Templat es | |||||
| 3 | * and ope n the temp late in th e editor. | |||||
| 4 | */ | |||||
| 5 | ||||||
| 6 | package go v.va.nvap. svc.consen tmgmt.stub .data; | |||||
| 7 | ||||||
| 8 | import jav a.io.Seria lizable; | |||||
| 9 | import jav a.util.Col lection; | |||||
| 10 | import jav a.util.Dat e; | |||||
| 11 | ||||||
| 12 | import jav ax.persist ence.Basic ; | |||||
| 13 | import jav ax.persist ence.Colum n; | |||||
| 14 | import jav ax.persist ence.Entit y; | |||||
| 15 | import jav ax.persist ence.Fetch Type; | |||||
| 16 | import jav ax.persist ence.Gener atedValue; | |||||
| 17 | import jav ax.persist ence.Gener ationType; | |||||
| 18 | import jav ax.persist ence.Id; | |||||
| 19 | import jav ax.persist ence.JoinC olumn; | |||||
| 20 | import jav ax.persist ence.JoinT able; | |||||
| 21 | import jav ax.persist ence.ManyT oMany; | |||||
| 22 | import jav ax.persist ence.ManyT oOne; | |||||
| 23 | import jav ax.persist ence.Named NativeQuer ies; | |||||
| 24 | import jav ax.persist ence.Named NativeQuer y; | |||||
| 25 | import jav ax.persist ence.Named Queries; | |||||
| 26 | import jav ax.persist ence.Named Query; | |||||
| 27 | import jav ax.persist ence.Table ; | |||||
| 28 | import jav ax.persist ence.Tempo ral; | |||||
| 29 | import jav ax.persist ence.Tempo ralType; | |||||
| 30 | import jav ax.persist ence.Trans ient; | |||||
| 31 | ||||||
| 32 | import org .hibernate .annotatio ns.Formula ; | |||||
| 33 | ||||||
| 34 | /** | |||||
| 35 | * | |||||
| 36 | * @author vhaislegb erb | |||||
| 37 | */ | |||||
| 38 | @Entity | |||||
| 39 | @Table(nam e = "PATIE NT_CONSENT _DIR") | |||||
| 40 | @NamedQuer ies({ | |||||
| 41 | @Nam edQuery(na me = "Cons entDirecti ve.findAll ", query = "SELECT c FROM Cons entDirecti ve c order by c.opti nTS desc") , | |||||
| 42 | //@N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.Reanno unce", que ry = "SELE CT DISTINC T c FROM C onsentDire ctive c wh ere c.opti nConsentTy pe = :cons entTypeAut horize and c.expirat ionDate > CURRENT_TI MESTAMP an d c.optout TS is null and c.pat ientIen no t in (SELE CT DISTINC T d.patien tIen FROM ConsentDir ective d i nner join d.excluded Organizati ons eo whe re d.optin ConsentTyp e = :conse ntTypeRest rict and e o = :targe tedOrganiz ation and d.optoutTS is null) ORDER BY c .consentDi rId"), | |||||
| 43 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.Reanno unce", que ry = "SELE CT DISTINC T c FROM C onsentDire ctive c wh ere c.opti nConsentTy pe = :cons entTypeAut horize and c.expirat ionDate > CURRENT_TI MESTAMP an d c.optout TS is null ORDER BY c.consentD irId"), | |||||
| 44 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded", qu ery = "SEL ECT DISTIN CT c FROM ConsentDir ective c l eft outer join fetch c.exclude dOrganizat ions eo wh ere (eo is null or e o <> :targ etedOrgani zation) an d c.optout TS is null and c.exp irationDat e > CURREN T_TIMESTAM P"), | |||||
| 45 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.create dBeforeDat e.Reannoun ce", query = "SELECT DISTINCT c FROM Con sentDirect ive c wher e c.optinC onsentType = :consen tTypeAutho rize and c .expiratio nDate > CU RRENT_TIME STAMP and c.optoutTS is null a nd c.optin TS < :befo reDate ORD ER BY c.co nsentDirId "), | |||||
| 46 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded.crea tedBeforeD ate", quer y = "SELEC T DISTINCT c FROM Co nsentDirec tive c lef t outer jo in fetch c .excludedO rganizatio ns eo wher e (eo is n ull or eo <> :target edOrganiza tion) and c.optoutTS is null a nd c.expir ationDate > CURRENT_ TIMESTAMP and c.opti nTS < :bef oreDate"), | |||||
| 47 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.create dAfterDate .Reannounc e", query = "SELECT DISTINCT c FROM Cons entDirecti ve c where c.optinCo nsentType = :consent TypeAuthor ize and c. expiration Date > CUR RENT_TIMES TAMP and c .optoutTS is null an d c.optinT S > :after Date ORDER BY c.cons entDirId") , | |||||
| 48 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded.crea tedAfterDa te", query = "SELECT DISTINCT c FROM Con sentDirect ive c left outer joi n fetch c. excludedOr ganization s eo where (eo is nu ll or eo < > :targete dOrganizat ion) and c .optoutTS is null an d c.expira tionDate > CURRENT_T IMESTAMP a nd c.optin TS > :afte rDate"), | |||||
| 49 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.create dBetweenDa tes.Reanno unce", que ry = "SELE CT DISTINC T c FROM C onsentDire ctive c wh ere c.opti nConsentTy pe = :cons entTypeAut horize and c.expirat ionDate > CURRENT_TI MESTAMP an d c.optout TS is null and c.opt inTS betwe en :afterD ate and :b eforeDate ORDER BY c .consentDi rId"), | |||||
| 50 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded.crea tedBetween Dates", qu ery = "SEL ECT DISTIN CT c FROM ConsentDir ective c l eft outer join fetch c.exclude dOrganizat ions eo wh ere (eo is null or e o <> :targ etedOrgani zation) an d c.optout TS is null and c.exp irationDat e > CURREN T_TIMESTAM P and c.op tinTS betw een :after Date and : beforeDate "), | |||||
| 51 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded", qu ery = "SEL ECT DISTIN CT c FROM ConsentDir ective c w here c.opt inConsentT ype = :con sentTypeAu thorize an d c.expira tionDate > CURRENT_T IMESTAMP a nd c.optou tTS is nul l and c.pa tientIen n ot in (SEL ECT DISTIN CT d.patie ntIen FROM ConsentDi rective d inner join d.exclude dOrganizat ions eo wh ere d.opti nConsentTy pe = :cons entTypeRes trict and eo = :targ etedOrgani zation and d.optoutT S is null) ORDER BY c.consentD irId"), | |||||
| 52 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded", quer y = "SELEC T DISTINCT c FROM Co nsentDirec tive c whe re c.optin ConsentTyp e = :conse ntTypeAuth orize and c.expirati onDate > C URRENT_TIM ESTAMP and c.optoutT S is null and c not in (SELECT a.consent Directive FROM Annou ncement a where a.ta rgetOrgani zation = : targetedOr ganization ) ORDER BY c.consent DirId"), | |||||
| 53 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded", qu ery = "SEL ECT DISTIN CT c FROM ConsentDir ective c l eft outer join fetch c.exclude dOrganizat ions eo wh ere (eo is null or e o <> :targ etedOrgani zation) an d c.optout TS is null and c.exp irationDat e > CURREN T_TIMESTAM P"), | |||||
| 54 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.create dBeforeDat e", query = "SELECT DISTINCT c FROM Cons entDirecti ve c where c.optinCo nsentType = :consent TypeAuthor ize and c. expiration Date > CUR RENT_TIMES TAMP and c .optoutTS is null an d c.optinT S < :befor eDate and c not in ( SELECT a.c onsentDire ctive FROM Announcem ent a wher e a.target Organizati on = :targ etedOrgani zation) OR DER BY c.c onsentDirI d"), | |||||
| 55 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded.crea tedBeforeD ate", quer y = "SELEC T DISTINCT c FROM Co nsentDirec tive c lef t outer jo in fetch c .excludedO rganizatio ns eo wher e (eo is n ull or eo <> :target edOrganiza tion) and c.optoutTS is null a nd c.expir ationDate > CURRENT_ TIMESTAMP and c.opti nTS < :bef oreDate"), | |||||
| 56 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.create dAfterDate ", query = "SELECT D ISTINCT c FROM Conse ntDirectiv e c where c.optinCon sentType = :consentT ypeAuthori ze and c.e xpirationD ate > CURR ENT_TIMEST AMP and c. optoutTS i s null and c.optinTS > :afterD ate and c not in (SE LECT a.con sentDirect ive FROM A nnouncemen t a where a.targetOr ganization = :target edOrganiza tion) ORDE R BY c.con sentDirId" ), | |||||
| 57 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded.crea tedAfterDa te", query = "SELECT DISTINCT c FROM Con sentDirect ive c left outer joi n fetch c. excludedOr ganization s eo where (eo is nu ll or eo < > :targete dOrganizat ion) and c .optoutTS is null an d c.expira tionDate > CURRENT_T IMESTAMP a nd c.optin TS > :afte rDate"), | |||||
| 58 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.create dBetweenDa tes", quer y = "SELEC T DISTINCT c FROM Co nsentDirec tive c whe re c.optin ConsentTyp e = :conse ntTypeAuth orize and c.expirati onDate > C URRENT_TIM ESTAMP and c.optoutT S is null and c.opti nTS betwee n :afterDa te and :be foreDate a nd c not i n (SELECT a.consentD irective F ROM Announ cement a w here a.tar getOrganiz ation = :t argetedOrg anization) ORDER BY c.consentD irId"), | |||||
| 59 | // @NamedQuer y(name = " ConsentDir ective.act ive.notExc luded.crea tedBetween Dates", qu ery = "SEL ECT DISTIN CT c FROM ConsentDir ective c l eft outer join fetch c.exclude dOrganizat ions eo wh ere (eo is null or e o <> :targ etedOrgani zation) an d c.optout TS is null and c.exp irationDat e > CURREN T_TIMESTAM P and c.op tinTS betw een :after Date and : beforeDate "), | |||||
| 60 | ||||||
| 61 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.multOr gs", query = "SELECT DISTINCT c FROM Con sentDirect ive c wher e c.optinC onsentType = :consen tTypeAutho rize and c .expiratio nDate > CU RRENT_TIME STAMP and c.optoutTS is null a nd c not i n (SELECT a.consentD irective F ROM Announ cement a w here a.tar getOrganiz ation in (:targeted Organizati ons)) and c not in ( SELECT a.c onsentDire ctive FROM Announcem entOrg o J OIN o.anno uncement a where o.t argetOrgan ization in (:targete dOrganizat ions)) ORD ER BY c.co nsentDirId "), | |||||
| 62 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.multOr gs.created BeforeDate ", query = "SELECT D ISTINCT c FROM Conse ntDirectiv e c where c.optinCon sentType = :consentT ypeAuthori ze and c.e xpirationD ate > CURR ENT_TIMEST AMP and c. optoutTS i s null and c.optinTS < :before Date and c not in (S ELECT a.co nsentDirec tive FROM Announceme nt a where a.targetO rganizatio n in (:ta rgetedOrga nizations) ) and c no t in (SELE CT a.conse ntDirectiv e FROM Ann ouncementO rg o JOIN o.announce ment a whe re o.targe tOrganizat ion in (:t argetedOrg anizations )) ORDER B Y c.consen tDirId"), | |||||
| 63 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.multOr gs.created AfterDate" , query = "SELECT DI STINCT c F ROM Consen tDirective c where c .optinCons entType = :consentTy peAuthoriz e and c.ex pirationDa te > CURRE NT_TIMESTA MP and c.o ptoutTS is null and c.optinTS > :afterDa te and c n ot in (SEL ECT a.cons entDirecti ve FROM An nouncement a where a .targetOrg anization in (:targ etedOrgani zations)) and c not in (SELECT a.consent Directive FROM Annou ncementOrg o JOIN o. announceme nt a where o.targetO rganizatio n in (:tar getedOrgan izations)) ORDER BY c.consentD irId"), | |||||
| 64 | @N amedQuery( name = "Co nsentDirec tive.activ e.notExclu ded.multOr gs.created BetweenDat es", query = "SELECT DISTINCT c FROM Con sentDirect ive c wher e c.optinC onsentType = :consen tTypeAutho rize and c .expiratio nDate > CU RRENT_TIME STAMP and c.optoutTS is null a nd c.optin TS between :afterDat e and :bef oreDate an d c not in (SELECT a .consentDi rective FR OM Announc ement a wh ere a.targ etOrganiza tion in (: targetedOr ganization s)) and c not in (SE LECT a.con sentDirect ive FROM A nnouncemen tOrg o JOI N o.announ cement a w here o.tar getOrganiz ation in ( :targetedO rganizatio ns)) ORDER BY c.cons entDirId") , | |||||
| 65 | ||||||
| 66 | @N amedQuery( name = "Co nsentDirec tive.findA llByPatien t", query = "SELECT c FROM Con sentDirect ive c wher e c.patien tIen IN (: patientIen s) order b y c.optinT S desc"), | |||||
| 67 | @Nam edQuery(na me = "Cons entDirecti ve.findByC onsentDirI d", query = "SELECT c FROM Con sentDirect ive c WHER E c.consen tDirId = : consentDir Id"), | |||||
| 68 | @Nam edQuery(na me = "Cons entDirecti ve.findByP atientIen" , query = "SELECT c FROM Conse ntDirectiv e c WHERE c.patientI en IN (:pa tientIen)" ), | |||||
| 69 | @Nam edQuery(na me = "Cons entDirecti ve.findByO ptinDate", query = " SELECT c F ROM Consen tDirective c WHERE c .optinDate = :optinD ate"), | |||||
| 70 | @Nam edQuery(na me = "Cons entDirecti ve.findByO ptoutDate" , query = "SELECT c FROM Conse ntDirectiv e c WHERE c.optoutDa te = :opto utDate"), | |||||
| 71 | @Nam edQuery(na me = "Cons entDirecti ve.findByO ptoutTS", query = "S ELECT c FR OM Consent Directive c WHERE c. optoutTS = :optoutTS "), | |||||
| 72 | @Nam edQuery(na me = "Cons entDirecti ve.findByE xpirationD ate", quer y = "SELEC T c FROM C onsentDire ctive c WH ERE c.expi rationDate = :expira tionDate") , | |||||
| 73 | @Nam edQuery(na me = "Cons entDirecti ve.findByO ptinTS", q uery = "SE LECT c FRO M ConsentD irective c WHERE c.o ptinTS = : optinTS"), | |||||
| 74 | @Nam edQuery(na me = "Cons entDirecti ve.findAct ive", quer y = "SELEC T c FROM C onsentDire ctive c WH ERE c.pati entIen IN (:patientI ens) and c .optoutTS is null"), | |||||
| 75 | @Nam edQuery(na me = "Cons entDirecti ve.findAct iveByConse ntType", q uery = "SE LECT c FRO M ConsentD irective c WHERE c.p atientIen IN (:patie ntIens) an d c.optinC onsentType = :consen tType and c.optoutCo nsentType is null") }) | |||||
| 76 | ||||||
| 77 | ||||||
| 78 | ||||||
| 79 | ||||||
| 80 | ||||||
| 81 | ||||||
| 82 | ||||||
| 83 | ||||||
| 84 | ||||||
| 85 | ||||||
| 86 | ||||||
| 87 | ||||||
| 88 | ||||||
| 89 | ||||||
| 90 | ||||||
| 91 | ||||||
| 92 | ||||||
| 93 | @Nam edNativeQu eries({ | |||||
| 94 | @Named NativeQuer y( | |||||
| 95 | name="Cons entDirecti ve.findAll ExpiringCo nsentDirec tives", | |||||
| 96 | query=Cons entDirecti ve.findAll ExpiringCo nsentDirec tivesNativ eSQL, | |||||
| 97 | resultClas s=ConsentD irective.c lass | |||||
| 98 | ), | |||||
| 99 | @NamedNa tiveQuery( | |||||
| 100 | name="Cons entDirecti ve.findAll ExpiringCo nsentDirec tivesWithD ates", | |||||
| 101 | query=Cons entDirecti ve.findAll ExpiringCo nsentDirec tivesWithD atesNative SQL, | |||||
| 102 | resultClas s=ConsentD irective.c lass | |||||
| 103 | ), | |||||
| 104 | @Named NativeQuer y( | |||||
| 105 | name="Cons entDirecti ve.findAll FutureExpi ringConsen tDirective s", | |||||
| 106 | query=Cons entDirecti ve.findAll FutureExpi ringConsen tDirective sNativeSQL , | |||||
| 107 | resultClas s=ConsentD irective.c lass | |||||
| 108 | ), | |||||
| 109 | @Named NativeQuer y( | |||||
| 110 | name="Cons entDirecti ve.findAll FutureExpi ringConsen tDirective sPage", | |||||
| 111 | query=Cons entDirecti ve.findAll FutureExpi ringConsen tDirective sPageNativ eSQL, | |||||
| 112 | resultClas s=ConsentD irective.c lass | |||||
| 113 | ), | |||||
| 114 | @Named NativeQuer y( | |||||
| 115 | name="Cons entDirecti ve.findExp iringConse ntDirectiv es", | |||||
| 116 | query=Cons entDirecti ve.findExp iringConse ntDirectiv esNativeSQ L, | |||||
| 117 | resultClas s=ConsentD irective.c lass | |||||
| 118 | ), | |||||
| 119 | @Named NativeQuer y( | |||||
| 120 | name="Cons entDirecti ve.findOpt inConsentD irectives" , | |||||
| 121 | query=Cons entDirecti ve.findOpt inConsentD irectivesN ativeSQL, | |||||
| 122 | resultClas s=ConsentD irective.c lass | |||||
| 123 | ), | |||||
| 124 | @Named NativeQuer y( | |||||
| 125 | name="Cons entDirecti ve.findOpt outConsent Directives ", | |||||
| 126 | query=Cons entDirecti ve.findOpt outConsent Directives NativeSQL, | |||||
| 127 | resultClas s=ConsentD irective.c lass | |||||
| 128 | ), | |||||
| 129 | @NamedNa tiveQuery( | |||||
| 130 | name="Cons entDirecti ve.findRec entlyExpir edConsent" , | |||||
| 131 | query=Cons entDirecti ve.findRec entlyExpir edConsentS QL, | |||||
| 132 | resultClas s=ConsentD irective.c lass | |||||
| 133 | ) | |||||
| 134 | ||||||
| 135 | }) | |||||
| 136 | ||||||
| 137 | public cla ss Consent Directive implements Serializa ble { | |||||
| 138 | pr ivate stat ic final l ong serial VersionUID = 1L; | |||||
| 139 | ||||||
| 140 | /* * | |||||
| 141 | * String co nstant nat ive SQL fo r retrievi ng patient consent d irectives that are s et to | |||||
| 142 | * expire in a given n umber of d ays whose patients h ave NOT re ceived a n otificatio n | |||||
| 143 | * / | |||||
| 144 | pr otected st atic final String fi ndAllExpir ingConsent Directives NativeSQL= | |||||
| 145 | "sel ect * from (select a. *, row_num ber() over (ORDER BY a.consent _dir_id AS C) line_nu mber, coun t(1) over () totalRo ws from pa tient_cons ent_dir a where a.O PTIN_CONSE NT_TYPE_ID IS NOT NU LL and a. optout_dat e is null and a.opto ut_ts is n ull and a. expiration _date < sy stimestamp + :days_u ntil_expir ation and a.expirati on_date > systimesta mp ) WHERE (line_num ber BETWEE N :from_pa ge AND :to _page) OR (:to_page < 0) ORDER BY line_n umber"; | |||||
| 146 | ||||||
| 147 | protec ted static final Str ing findAl lExpiringC onsentDire ctivesWith DatesNativ eSQL= | |||||
| 148 | "sel ect * from ("+ | |||||
| 149 | "sel ect a.*, r ow_number( ) over (OR DER BY a.c onsent_dir _id ASC) l ine_number , count(1) over () t otalRows " + | |||||
| 150 | ||||||
| 151 | "fro m patient_ consent_di r a " + | |||||
| 152 | "whe re a.OPTI N_CONSENT_ TYPE_ID IS NOT NULL " + | |||||
| 153 | "and a.optout _date is n ull and a. optout_ts is null " + | |||||
| 154 | "and a.expi ration_dat e <= to_da te(:end_da te, 'YYYY- MM-DD')" + | |||||
| 155 | "a nd a.ex piration_d ate > to_d ate(:start _date, 'YY YY-MM-DD') " + | |||||
| 156 | ||||||
| 157 | ") W HERE (line _number BE TWEEN :fro m_page AND :to_page) OR (:to_p age < 0) O RDER BY li ne_number" ; | |||||
| 158 | ||||||
| 159 | /* * | |||||
| 160 | * String co nstant nat ive SQL fo r retrievi ng patient consent d irectives that are s et to | |||||
| 161 | * expire at any futur e time who se patient s have NOT received a notifica tion | |||||
| 162 | * | |||||
| 163 | * NOTE: Doe s not chec k if patie nts have a lready bee n notified | |||||
| 164 | * / | |||||
| 165 | pr otected st atic final String fi ndAllFutur eExpiringC onsentDire ctivesPage NativeSQL= | |||||
| 166 | "sel ect * from ("+ | |||||
| 167 | "sel ect a.*, r ow_number( ) over (OR DER BY a.c onsent_dir _id ASC) l ine_number , count(1) over () t otalRows " + | |||||
| 168 | "fro m patient_ consent_di r a " + | |||||
| 169 | "whe re a.OPTI N_CONSENT_ TYPE_ID IS NOT NULL " + | |||||
| 170 | "and a.optout _date is n ull and a. optout_ts is null " + | |||||
| 171 | "a nd a.ex piration_d ate > syst imestamp" + | |||||
| 172 | ") WHERE (li ne_number BETWEEN :f rom_page A ND :to_pag e) OR (:to _page < 0) ORDER BY line_numbe r"; | |||||
| 173 | ||||||
| 174 | /* * | |||||
| 175 | * String co nstant nat ive SQL fo r retrievi ng patient consent d irectives that are s et to | |||||
| 176 | * expire at any futur e time who se patient s have NOT received a notifica tion | |||||
| 177 | * | |||||
| 178 | * NOTE: Doe s not chec k if patie nts have a lready bee n notified | |||||
| 179 | * / | |||||
| 180 | pr otected st atic final String fi ndAllFutur eExpiringC onsentDire ctivesNati veSQL= | |||||
| 181 | "Sel ect a.*, c ount(1) ov er () tota lRows " + | |||||
| 182 | "fro m patient_ consent_di r a " + | |||||
| 183 | "whe re a.OPTI N_CONSENT_ TYPE_ID IS NOT NULL " + | |||||
| 184 | "and a.optout _date is n ull and a. optout_ts is null " + | |||||
| 185 | ||||||
| 186 | "a nd a.ex piration_d ate > syst imestamp"; | |||||
| 187 | ||||||
| 188 | ||||||
| 189 | /* * | |||||
| 190 | * String co nstant nat ive SQL fo r retrievi ng patient consent d irectives that are s et to | |||||
| 191 | * expire in a given n umber of d ays for th e patient passed who have NOT received a notificat ion | |||||
| 192 | * / | |||||
| 193 | pr otected st atic final String fi ndExpiring ConsentDir ectivesNat iveSQL= | |||||
| 194 | ||||||
| 195 | ||||||
| 196 | "sel ect * from ("+ | |||||
| 197 | "sel ect a.*, r ow_number( ) over (OR DER BY a.c onsent_dir _id ASC) l ine_number , count(1 ) over () totalRows " + | |||||
| 198 | "fro m patient_ consent_di r a " + | |||||
| 199 | "whe re a.opto ut_date is null and a.optout_ ts is null " + | |||||
| 200 | "and a.expi ration_dat e < systim estamp + : days_until _expiratio n " + | |||||
| 201 | "a nd a.ex piration_d ate > syst imestamp " + | |||||
| 202 | "a nd a.pa tient_ien in (:patie nt_iens) " + | |||||
| 203 | ") W HERE (line _number BE TWEEN :fro m_page AND :to_page) OR (:to_p age < 0) O RDER BY li ne_number" ; | |||||
| 204 | ||||||
| 205 | /* * | |||||
| 206 | * String co nstant nat ive SQL fo r retrievi ng patient consent d irectives that have expired | |||||
| 207 | * for patie nts who ha ve NOT rec eived a no tification | |||||
| 208 | * / | |||||
| 209 | pr otected st atic final String fi ndExpiredC onsentDire ctivesNati veSQL= | |||||
| 210 | "sel ect * from ("+ | |||||
| 211 | "sel ect a.*, r ow_number( ) over (OR DER BY a.c onsent_dir _id ASC) l ine_number , count(1 ) over () totalRows " + | |||||
| 212 | "fro m patient_ consent_di r a " + | |||||
| 213 | "whe re a.opto ut_date is null and a.optout_ ts is null " + | |||||
| 214 | "and a.expi ration_dat e < systim estamp " + | |||||
| 215 | ") W HERE (line _number BE TWEEN :fro m_page AND :to_page) OR (:to_p age < 0) O RDER BY li ne_number" ; | |||||
| 216 | ||||||
| 217 | /* * | |||||
| 218 | * String co nstant nat ive SQL fo r retrievi ng patient opt-in co nsent dire ctives tha t | |||||
| 219 | * have been entered i n a given number of days whose patients have NOT r eceived a notificati on | |||||
| 220 | * / | |||||
| 221 | pr otected st atic final String fi ndOptinCon sentDirect ivesNative SQL= | |||||
| 222 | "sel ect * from patient_c onsent_dir a " + | |||||
| 223 | "whe re a.cons ent_type_i d = :conse nt_type " + | |||||
| 224 | "and a.opto ut_date is null " + | |||||
| 225 | "and a.opti n_date > s ystimestam p - :optin _range_day s "; | |||||
| 226 | ||||||
| 227 | /* * | |||||
| 228 | * String co nstant nat ive SQL fo r retrievi ng patient opt-out c onsent dir ectives th at | |||||
| 229 | * have been entered i n a given number of days whose patients have NOT r eceived a notificati on | |||||
| 230 | * / | |||||
| 231 | pr otected st atic final String fi ndOptoutCo nsentDirec tivesNativ eSQL= | |||||
| 232 | "sel ect * from patient_c onsent_dir a " + | |||||
| 233 | "whe re a.cons ent_type_i d = :conse nt_type " + | |||||
| 234 | "and a.opto ut_date is not null " + | |||||
| 235 | "and a.opto ut_date > systimesta mp - :opto ut_range_d ays"; | |||||
| 236 | ||||||
| 237 | /** | |||||
| 238 | * Retr ieve recen tly expire d patients that do n ot have a new opt-in entry for that cons ent type | |||||
| 239 | */ | |||||
| 240 | protec ted static final Str ing findRe centlyExpi redConsent SQL | |||||
| 241 | = "select * from pati ent_consen t_dir a wh ere " | |||||
| 242 | + "a.EXPIRAT ION_DATE < trunc( sy sdate) " | |||||
| 243 | // + "and a .EXPIRATIO N_DATE >= trunc( sys date -1 ) " //for on ly yesterd ay | |||||
| 244 | + "and OPTOU T_TS is nu ll " | |||||
| 245 | + "and OPTOU T_DATE is null " | |||||
| 246 | + "and not e xists " | |||||
| 247 | + "(select 1 from pati ent_consen t_dir b wh ere " | |||||
| 248 | + "a.PATIENT _IEN = b.P ATIENT_IEN " | |||||
| 249 | + "and a.OPT IN_DATE < b.OPTIN_DA TE " | |||||
| 250 | + "and a.OPT IN_CONSENT _TYPE_ID = b.OPTIN_C ONSENT_TYP E_ID" | |||||
| 251 | + ")"; | |||||
| 252 | ||||||
| 253 | @I d | |||||
| 254 | @G eneratedVa lue(strate gy = Gener ationType. AUTO) | |||||
| 255 | @B asic(optio nal = fals e) | |||||
| 256 | @C olumn(name = "CONSEN T_DIR_ID") | |||||
| 257 | pr ivate Long consentDi rId; | |||||
| 258 | @M anyToOne(f etch = Fet chType.EAG ER) | |||||
| 259 | @J oinColumn( name = "OP TIN_CONSEN T_TYPE_ID" ) | |||||
| 260 | pr ivate Cons entType op tinConsent Type; | |||||
| 261 | @M anyToOne(f etch = Fet chType.EAG ER) | |||||
| 262 | @J oinColumn( name = "OP TOUT_CONSE NT_TYPE_ID ") | |||||
| 263 | pr ivate Cons entType op toutConsen tType; | |||||
| 264 | @M anyToOne(f etch = Fet chType.EAG ER) | |||||
| 265 | @J oinColumn( name = "PO U_ID") | |||||
| 266 | pr ivate Purp oseOfUse p urposeOfUs e; | |||||
| 267 | @B asic(optio nal = fals e) | |||||
| 268 | @C olumn(name = "OPTIN_ TS") | |||||
| 269 | @T emporal(Te mporalType .TIMESTAMP ) | |||||
| 270 | pr ivate Date optinTS; | |||||
| 271 | @M anyToMany( fetch = Fe tchType.EA GER) | |||||
| 272 | @J oinTable(n ame = "PAT IENT_EXCLU DED_ORG", joinColumn s = { @Joi nColumn(na me = "CONS ENT_DIR_ID ") }, inve rseJoinCol umns = { @ JoinColumn (name = "O RG_ID") }) | |||||
| 273 | pr ivate Coll ection<Org anization> excludedO rganizatio ns; | |||||
| 274 | @C olumn(name = "EXPIRA TION_DATE" ) | |||||
| 275 | @T emporal(Te mporalType .TIMESTAMP ) | |||||
| 276 | pr ivate Date expiratio nDate; | |||||
| 277 | @B asic(optio nal = fals e) | |||||
| 278 | @C olumn(name = "OPTIN_ DATE") | |||||
| 279 | @T emporal(Te mporalType .TIMESTAMP ) | |||||
| 280 | pr ivate Date optinDate ; | |||||
| 281 | @C olumn(name = "OPTOUT _TS") | |||||
| 282 | @T emporal(Te mporalType .TIMESTAMP ) | |||||
| 283 | pr ivate Date optoutTS; | |||||
| 284 | @M anyToOne(f etch = Fet chType.EAG ER) | |||||
| 285 | @J oinColumn( name = "OP TOUT_REASO N_ID") | |||||
| 286 | pr ivate Opto utReason o ptoutReaso n; | |||||
| 287 | @B asic(optio nal = fals e) | |||||
| 288 | @C olumn(name = "PATIEN T_IEN") | |||||
| 289 | pr ivate Stri ng patient Ien; | |||||
| 290 | @C olumn(name = "OPTOUT _DATE") | |||||
| 291 | @T emporal(Te mporalType .TIMESTAMP ) | |||||
| 292 | pr ivate Date optoutDat e; | |||||
| 293 | @T ransient | |||||
| 294 | pr ivate Long totalRows ; | |||||
| 295 | ||||||
| 296 | pu blic Conse ntDirectiv e() { | |||||
| 297 | } | |||||
| 298 | ||||||
| 299 | pu blic Conse ntDirectiv e(final Lo ng consent DirId) { | |||||
| 300 | this .consentDi rId = cons entDirId; | |||||
| 301 | } | |||||
| 302 | ||||||
| 303 | pu blic Conse ntDirectiv e(final Lo ng consent DirId, fin al String patientIen , | |||||
| 304 | final Date optin Date, fina l Date exp irationDat e, | |||||
| 305 | final Date optin TS, final ConsentTyp e consentT ype) { | |||||
| 306 | this .consentDi rId = cons entDirId; | |||||
| 307 | this .patientIe n = patien tIen; | |||||
| 308 | this .optinDate = optinDa te; | |||||
| 309 | this .expiratio nDate = ex pirationDa te; | |||||
| 310 | this .optinTS = optinTS; | |||||
| 311 | this .optinCons entType = consentTyp e; | |||||
| 312 | } | |||||
| 313 | ||||||
| 314 | @O verride | |||||
| 315 | pu blic boole an equals( final Obje ct object) { | |||||
| 316 | // T ODO: Warni ng - this method won 't work in the case the id fie lds are | |||||
| 317 | // n ot set | |||||
| 318 | if ( !(object i nstanceof ConsentDir ective)) { | |||||
| 319 | return false; | |||||
| 320 | } | |||||
| 321 | fina l ConsentD irective o ther = (Co nsentDirec tive) obje ct; | |||||
| 322 | if ( ((this.con sentDirId == null) & & (other.c onsentDirI d != null) ) | |||||
| 323 | || ((thi s.consentD irId != nu ll) && !th is.consent DirId | |||||
| 324 | .e quals(othe r.consentD irId))) { | |||||
| 325 | return false; | |||||
| 326 | } | |||||
| 327 | retu rn true; | |||||
| 328 | } | |||||
| 329 | ||||||
| 330 | pu blic Long getConsent DirId() { | |||||
| 331 | retu rn this.co nsentDirId ; | |||||
| 332 | } | |||||
| 333 | ||||||
| 334 | pu blic Date getOptinTS () { | |||||
| 335 | retu rn this.op tinTS; | |||||
| 336 | } | |||||
| 337 | ||||||
| 338 | pu blic Colle ction<Orga nization> getExclude dOrganizat ions() { | |||||
| 339 | retu rn this.ex cludedOrga nizations; | |||||
| 340 | } | |||||
| 341 | ||||||
| 342 | pu blic Date getExpirat ionDate() { | |||||
| 343 | retu rn this.ex pirationDa te; | |||||
| 344 | } | |||||
| 345 | ||||||
| 346 | pu blic Date getOptinDa te() { | |||||
| 347 | retu rn this.op tinDate; | |||||
| 348 | } | |||||
| 349 | pu blic Date getOptoutD ate() { | |||||
| 350 | retu rn this.op toutDate; | |||||
| 351 | } | |||||
| 352 | pu blic Date getOptoutT S() { | |||||
| 353 | retu rn this.op toutTS; | |||||
| 354 | } | |||||
| 355 | ||||||
| 356 | pu blic Optou tReason ge tOptoutRea son() { | |||||
| 357 | retu rn this.op toutReason ; | |||||
| 358 | } | |||||
| 359 | ||||||
| 360 | pu blic Strin g getPatie ntIen() { | |||||
| 361 | retu rn this.pa tientIen; | |||||
| 362 | } | |||||
| 363 | ||||||
| 364 | @O verride | |||||
| 365 | pu blic int h ashCode() { | |||||
| 366 | int hash = 0; | |||||
| 367 | hash += (this. consentDir Id != null ? this.co nsentDirId .hashCode( ) : 0); | |||||
| 368 | retu rn hash; | |||||
| 369 | } | |||||
| 370 | ||||||
| 371 | pu blic void setConsent DirId(fina l Long con sentDirId) { | |||||
| 372 | this .consentDi rId = cons entDirId; | |||||
| 373 | } | |||||
| 374 | ||||||
| 375 | pu blic void setOptinTS (final Dat e optinTS) { | |||||
| 376 | this .optinTS = optinTS; | |||||
| 377 | } | |||||
| 378 | ||||||
| 379 | pu blic void setExclude dOrganizat ions( | |||||
| 380 | final Collection <Organizat ion> organ izationsCo llection) { | |||||
| 381 | this .excludedO rganizatio ns = organ izationsCo llection; | |||||
| 382 | } | |||||
| 383 | ||||||
| 384 | pu blic void setExpirat ionDate(fi nal Date e xpirationD ate) { | |||||
| 385 | this .expiratio nDate = ex pirationDa te; | |||||
| 386 | } | |||||
| 387 | ||||||
| 388 | pu blic void setOptinDa te(final D ate optinD ate) { | |||||
| 389 | this .optinDate = optinDa te; | |||||
| 390 | } | |||||
| 391 | pu blic void setOptoutD ate(final Date optou tDate) { | |||||
| 392 | this .optoutDat e = optout Date; | |||||
| 393 | } | |||||
| 394 | pu blic void setOptoutT S(final Da te optoutT S) { | |||||
| 395 | this .optoutTS = optoutTS ; | |||||
| 396 | } | |||||
| 397 | ||||||
| 398 | pu blic void setOptoutR eason(fina l OptoutRe ason optou tReason) { | |||||
| 399 | this .optoutRea son = opto utReason; | |||||
| 400 | } | |||||
| 401 | ||||||
| 402 | pu blic void setPatient Ien(final String pat ientIen) { | |||||
| 403 | this .patientIe n = patien tIen; | |||||
| 404 | } | |||||
| 405 | ||||||
| 406 | @O verride | |||||
| 407 | pu blic Strin g toString () { | |||||
| 408 | retu rn "gov.va .med.vler. nhin.vap.p ip.entitie s.ConsentD irective[c onsentDirI d=" | |||||
| 409 | + this.c onsentDirI d + "]"; | |||||
| 410 | } | |||||
| 411 | ||||||
| 412 | pu blic void setOptoutC onsentType (ConsentTy pe optoutC onsentType ) { | |||||
| 413 | this .optoutCon sentType = optoutCon sentType; | |||||
| 414 | } | |||||
| 415 | ||||||
| 416 | pu blic Conse ntType get OptoutCons entType() { | |||||
| 417 | retu rn optoutC onsentType ; | |||||
| 418 | } | |||||
| 419 | ||||||
| 420 | pu blic void setOptinCo nsentType( ConsentTyp e optinCon sentType) { | |||||
| 421 | this .optinCons entType = optinConse ntType; | |||||
| 422 | } | |||||
| 423 | ||||||
| 424 | pu blic void setPurpose OfUse(Purp oseOfUse p urposeOfUs e) { | |||||
| 425 | this .purposeOf Use = purp oseOfUse; | |||||
| 426 | } | |||||
| 427 | ||||||
| 428 | pu blic Conse ntType get OptinConse ntType() { | |||||
| 429 | retu rn optinCo nsentType; | |||||
| 430 | } | |||||
| 431 | ||||||
| 432 | pu blic Purpo seOfUse ge tPurposeOf Use() { | |||||
| 433 | retu rn purpose OfUse; | |||||
| 434 | } | |||||
| 435 | ||||||
| 436 | pu blic Long getTotalRo ws() { | |||||
| 437 | retu rn totalRo ws; | |||||
| 438 | } | |||||
| 439 | ||||||
| 440 | pu blic void setTotalRo ws(Long to talRows) { | |||||
| 441 | this .totalRows = totalRo ws; | |||||
| 442 | } | |||||
| 443 | ||||||
| 444 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.