Produced by Araxis Merge on 10/2/2017 1:40:04 PM 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | chef-repo.zip\chef-repo\project_cookbooks\ehmp_oracle\files\default\oracledb\communication | communication_packages.sql | Wed Jul 5 22:28:39 2017 UTC |
| 2 | chef-repo.zip\chef-repo\project_cookbooks\ehmp_oracle\files\default\oracledb\communication | communication_packages.sql | Mon Oct 2 12:39:07 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 5 | 622 |
| Changed | 4 | 8 |
| 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 | -- DDL fo r Package MESSAGE_AP I | |
| 3 | ---------- ---------- ---------- ---------- ---------- ------ | |
| 4 | ||
| 5 | CREATE OR REPLACE PA CKAGE "COM MUNICATION "."MESSAGE _API" | |
| 6 | AS | |
| 7 | TYPE VAR CHAR2_ARRA Y IS TABLE OF VARCHA R2(1000) I NDEX BY BI NARY_INTEG ER; | |
| 8 | PROCEDUR E fetch_me ssages( | |
| 9 | i_us er_id V ARCHAR2, | |
| 10 | i_ve rsion V ARCHAR2, | |
| 11 | i_ca tegory V ARCHAR2_AR RAY, | |
| 12 | i_st atus V ARCHAR2 DE FAULT 'htt p://hl7.or g/fhir/Val ueSet/comm unication- status/com pleted', | |
| 13 | i_ov erride_pre ferences V ARCHAR2 DE FAULT 'N', | |
| 14 | o_me ssages OUT CLOB); | |
| 15 | PROCEDUR E fetch_me ssage_atta chment( | |
| 16 | i_at tachment_i dentifier VARCHAR2, | |
| 17 | o_at tachment_c ontenttype OUT VARCH AR2, | |
| 18 | o_at tachment O UT BLOB); | |
| 19 | PROCEDUR E create_m essage( | |
| 20 | io_i dentifier IN OUT V ARCHAR2, | |
| 21 | i_category _system IN VARCHAR 2 DEFAULT 'http://eh mp. DNS /messageCa tegories', | |
| 22 | i_ca tegory_cod e IN VARCHA R2, | |
| 23 | i_se nder IN VARCHA R2, | |
| 24 | i_re cipient IN VARCHA R2, | |
| 25 | i_pa yload_cont ent IN CLOB, | |
| 26 | i_pa yload_data IN CLOB, | |
| 27 | i_pa yload_titl e IN VARCHA R2, | |
| 28 | i_at tachment_d ata IN BLOB, | |
| 29 | i_at tachment_c ontenttype IN VARCHA R2, | |
| 30 | i_se nt IN TIMEST AMP DEFAUL T SYSTIMES TAMP, | |
| 31 | i_st atus_syste m IN VARCHA R2 DEFAULT 'http://h l7.org/fhi r/ValueSet /communica tion-statu s', | |
| 32 | i_st atus_code IN VARCHA R2 DEFAULT 'complete d', | |
| 33 | o_ro wcount OUT number); | |
| 34 | PROCEDUR E delete_m essage( | |
| 35 | i_id entifier V ARCHAR2, | |
| 36 | o_ro wcount OUT NUMBER); | |
| 37 | PROCEDUR E activate _message( | |
| 38 | i_id entifier V ARCHAR2, | |
| 39 | o_ro wcount OUT NUMBER); | |
| 40 | PROCEDUR E update_u ser_prefer ences( | |
| 41 | i_us er_id VARCHA R2, | |
| 42 | i_ca tegory_sys tem VARCHA R2, | |
| 43 | i_ca tegory_cod e VARCHA R2, | |
| 44 | i_en abled VARCHA R2, | |
| 45 | o_ro wcount OUT NUMBER); | |
| 46 | PROCEDUR E update_u ser_prefer ences( | |
| 47 | i_ca tegory_sys tem VARCHA R2, | |
| 48 | i_ca tegory_cod e VARCHA R2, | |
| 49 | i_en abled VARCHA R2, | |
| 50 | o_ro wcount OUT NUMBER); | |
| 51 | FUNCTION array_to_ table(i_ar ray VARCHA R2_ARRAY) RETURN VAR CHAR2_LIST ; | |
| 52 | END MESSAG E_API; | |
| 53 | / | |
| 54 | ---------- ---------- ---------- ---------- ---------- ------ | |
| 55 | -- DDL fo r Package Body MESSA GE_API | |
| 56 | ---------- ---------- ---------- ---------- ---------- ------ | |
| 57 | ||
| 58 | CREATE OR REPLACE PA CKAGE BODY "COMMUNIC ATION"."ME SSAGE_API" AS | |
| 59 | PROCEDUR E fetch_me ssages(i_u ser_id VARCHAR2, | |
| 60 | i_v ersion VARCHAR2, | |
| 61 | i_c ategory VARCHAR2_A RRAY, | |
| 62 | i_s tatus VARCHAR2 D EFAULT 'ht tp://hl7.o rg/fhir/Va lueSet/com munication -status/co mpleted', | |
| 63 | i_o verride_pr eferences VARCHAR2 D EFAULT 'N' , | |
| 64 | o_m essages OU T CLOB) AS | |
| 65 | TYPE m essage_rec IS RECORD (identifi er message .identifie r%type, | |
| 66 | category _system me ssage.cate gory_syste m%type, | |
| 67 | category _code mess age.catego ry_code%ty pe, | |
| 68 | status_s ystem mess age.status _system%ty pe, | |
| 69 | status_c ode messag e.status_c ode%type, | |
| 70 | sender m essage.sen der%type, | |
| 71 | recipien t message. recipient% type, | |
| 72 | payload_ title mess age.payloa d_title%ty pe, | |
| 73 | payload_ content me ssage.payl oad_conten t%type, | |
| 74 | payload_ data messa ge.payload _data%type , | |
| 75 | payload_ attachment _contentty pe message .payload_a ttachment_ contenttyp e%type, | |
| 76 | sent mes sage.sent% type); | |
| 77 | item m essage_rec ; | |
| 78 | messag e_cursor S YS_REFCURS OR; | |
| 79 | v_sql varchar2(3 2767); | |
| 80 | j_cont entdata ap ex_json.t_ values; | |
| 81 | BEGIN | |
| 82 | v_sql := ' | |
| 83 | SELECT identifie r, categor y_system, category_c ode, statu s_system, status_cod e, sender, recipient , payload_ title, pay load_conte nt, payloa d_data, pa yload_atta chment_con tenttype, sent | |
| 84 | FROM c ommunicati on.message m | |
| 85 | WHERE m.category IN (SELEC T column_v alue FROM TABLE(:i_c ategory)) AND '; | |
| 86 | ||
| 87 | IF i_u ser_id IS NOT NULL A ND i_overr ide_prefer ences <> ' Y' THEN | |
| 88 | v_sq l := CONCA T(v_sql, | |
| 89 | 'NOT EXI STS (SELEC T u.enable d | |
| 90 | FROM c ommunicati on.user_pr eferences u | |
| 91 | WHERE u.user_id = :i_user_ id and | |
| 92 | m.category _system = u.category _system an d | |
| 93 | m.category _code = u. category_c ode and | |
| 94 | enabled = ''N'') AND '); | |
| 95 | ELSE | |
| 96 | v_sq l := CONCA T(v_sql, ' (1 = 1 OR :i_user_id IS NULL) AND '); | |
| 97 | END IF ; | |
| 98 | ||
| 99 | v_sql := CONCAT( v_sql, '(m .recipient = :i_vers ion OR m.r ecipient I S NULL) AN D '); | |
| 100 | v_sql := CONCAT( v_sql, 'm. status = : i_status ' ); | |
| 101 | v_sql := CONCAT( v_sql, 'OR DER BY DEC ODE(m.cate gory_code, ''announc ements-ter ms'', 1, ' 'announcem ents-syste m'', 2, '' announceme nts-promot ions'', 3) , m.sent D ESC'); | |
| 102 | ||
| 103 | OPEN m essage_cur sor | |
| 104 | FOR v_ sql | |
| 105 | USING array_to_t able(i_cat egory), i_ user_id, i _version, i_status; | |
| 106 | ||
| 107 | APEX_J SON.initia lize_clob_ output; | |
| 108 | APEX_J SON.open_o bject; -- { | |
| 109 | APEX_J SON.open_a rray('comm unication' ); -- com munication [ | |
| 110 | ||
| 111 | LOOP | |
| 112 | fetc h message_ cursor int o item; | |
| 113 | exit when mess age_cursor %notfound; | |
| 114 | ||
| 115 | APEX _JSON.open _object; -- { | |
| 116 | ||
| 117 | APEX _JSON.open _array('id entifier') ; -- ide ntifier [ | |
| 118 | APEX _JSON.open _object; -- { | |
| 119 | APEX_JSON. write('sys tem', 'htt p://ehmp. DNS /messageId entifier') ; | |
| 120 | APEX _JSON.writ e('value', item.iden tifier); | |
| 121 | APEX _JSON.clos e_object; -- } | |
| 122 | APEX _JSON.clos e_array; -- ] i dentifier | |
| 123 | ||
| 124 | APEX _JSON.open _array('ca tegory'); -- cat egory [ | |
| 125 | APEX _JSON.open _object; | |
| 126 | APEX _JSON.writ e('system' , item.cat egory_syst em); | |
| 127 | APEX _JSON.writ e('code', item.categ ory_code); | |
| 128 | APEX _JSON.clos e_object; | |
| 129 | APEX _JSON.clos e_array; -- ] c ategory | |
| 130 | ||
| 131 | APEX _JSON.open _object('s ender'); -- sen der { | |
| 132 | APEX _JSON.writ e('name', item.sende r); | |
| 133 | APEX _JSON.clos e_object; -- } s ender | |
| 134 | ||
| 135 | APEX _JSON.open _array('re cipient'); -- rec ipient [ | |
| 136 | APEX _JSON.open _object; | |
| 137 | IF i tem.recipi ent IS NUL L THEN | |
| 138 | AP EX_JSON.wr ite('all', 'true'); | |
| 139 | ELSE | |
| 140 | AP EX_JSON.wr ite('ehmpA ppVersion' , item.rec ipient); | |
| 141 | END IF; | |
| 142 | APEX _JSON.clos e_object; | |
| 143 | APEX _JSON.clos e_array; -- ] recipient | |
| 144 | ||
| 145 | APEX _JSON.open _array('pa yload'); -- pa yload [ | |
| 146 | APEX _JSON.open _object; -- { | |
| 147 | APEX _JSON.open _array('co ntent'); -- co ntent [ | |
| 148 | APEX _JSON.open _object; -- { | |
| 149 | APEX _JSON.writ e('title', item.payl oad_title) ; | |
| 150 | APEX _JSON.writ e('content String', i tem.payloa d_content) ; | |
| 151 | ||
| 152 | IF ( item.paylo ad_data IS NOT NULL) THEN | |
| 153 | BE GIN | |
| 154 | APEX_JSON. parse(j_co ntentdata, item.payl oad_data); | |
| 155 | APEX_JSON. write('con tentData', j_content data); | |
| 156 | EXCEPTION WHEN OTHER S THEN | |
| 157 | NULL; | |
| 158 | EN D; | |
| 159 | END IF; | |
| 160 | ||
| 161 | IF ( item.paylo ad_attachm ent_conten ttype IS N OT NULL) T HEN | |
| 162 | AP EX_JSON.op en_object( 'contentAt tachment') ; -- { con tentAttach ment | |
| 163 | AP EX_JSON.wr ite('conte ntAttachme ntIdentifi er', item. identifier ); | |
| 164 | AP EX_JSON.wr ite('link' , '/'||ite m.identifi er||'/atta chment/'|| item.ident ifier); | |
| 165 | AP EX_JSON.wr ite('conte ntType', i tem.payloa d_attachme nt_content type); | |
| 166 | AP EX_JSON.cl ose_object ; -- } contentA ttachment | |
| 167 | END IF; | |
| 168 | ||
| 169 | APEX _JSON.clos e_object; -- } | |
| 170 | APEX _JSON.clos e_array; -- ] content | |
| 171 | APEX _JSON.clos e_object; -- } | |
| 172 | APEX _JSON.clos e_array; -- ] payload | |
| 173 | ||
| 174 | APEX _JSON.open _array('me dium'); -- me dium [ | |
| 175 | APEX _JSON.open _object; | |
| 176 | APEX _JSON.writ e('system' , 'http:// hl7.org/fh ir/v3/Part icipationM ode'); | |
| 177 | APEX _JSON.writ e('code', '2.16.840. 1.113883.5 .1064'); | |
| 178 | APEX _JSON.clos e_object; | |
| 179 | APEX _JSON.clos e_array; -- ] medium | |
| 180 | ||
| 181 | APEX _JSON.open _object('s tatus'); -- st atus { | |
| 182 | APEX _JSON.writ e('system' , item.sta tus_system ); | |
| 183 | APEX _JSON.writ e('code', item.statu s_code); | |
| 184 | APEX _JSON.clos e_object; -- } status | |
| 185 | ||
| 186 | APEX _JSON.writ e('sent', TO_CHAR(it em.sent, ' YYYY-MM-DD "T"HH:MI:S STZH:TZM') ); | |
| 187 | ||
| 188 | APEX _JSON.clos e_object; | |
| 189 | ||
| 190 | END LO OP; | |
| 191 | CLOSE message_cu rsor; | |
| 192 | ||
| 193 | APEX_J SON.close_ array; -- ] communi cation | |
| 194 | APEX_J SON.close_ object; -- } | |
| 195 | o_mess ages := AP EX_JSON.ge t_clob_out put; | |
| 196 | DBMS_O UTPUT.PUT_ LINE(o_mes sages); | |
| 197 | APEX_J SON.free_o utput; | |
| 198 | ||
| 199 | END fetc h_messages ; | |
| 200 | ||
| 201 | PROCEDUR E fetch_me ssage_atta chment( | |
| 202 | i_at tachment_i dentifier VARCHAR2, | |
| 203 | o_at tachment_c ontenttype OUT VARCH AR2, | |
| 204 | o_at tachment O UT BLOB) | |
| 205 | AS | |
| 206 | BEGIN | |
| 207 | SELECT payload_a ttachment_ contenttyp e, payload _attachmen t_data INT O o_attach ment_conte nttype, o_ attachment | |
| 208 | FROM c ommunicati on.message | |
| 209 | WHERE identifier = i_attac hment_iden tifier; | |
| 210 | END fetc h_message_ attachment ; | |
| 211 | ||
| 212 | PROCEDUR E create_m essage(io_ identifier IN OUT VA RCHAR2, | |
| 213 | i_category _system IN VARCHAR2 DEFAULT 'h ttp://ehmp . DNS /messageCa tegories', | |
| 214 | i_c ategory_co de IN VARC HAR2, | |
| 215 | i_s ender IN V ARCHAR2, | |
| 216 | i_r ecipient I N VARCHAR2 , | |
| 217 | i_p ayload_con tent IN CL OB, | |
| 218 | i_p ayload_dat a IN CLOB, | |
| 219 | i_p ayload_tit le IN VARC HAR2, | |
| 220 | i_a ttachment_ data IN BL OB, | |
| 221 | i_a ttachment_ contenttyp e IN VARCH AR2, | |
| 222 | i_s ent IN TIM ESTAMP DEF AULT SYSTI MESTAMP, | |
| 223 | i_s tatus_syst em IN VARC HAR2 DEFAU LT 'http:/ /hl7.org/f hir/ValueS et/communi cation-sta tus', | |
| 224 | i_s tatus_code IN VARCHA R2 DEFAULT 'complete d', | |
| 225 | o_r owcount OU T number) | |
| 226 | AS | |
| 227 | BEGIN | |
| 228 | SELECT NVL(io_id entifier, SYS_GUID() ) INTO io_ identifier FROM dual ; | |
| 229 | MERGE INTO commu nication.m essage m | |
| 230 | USIN G dual | |
| 231 | ON (m.identi fier = io_ identifier ) | |
| 232 | WHEN MATCHED T HEN | |
| 233 | UP DATE SET | |
| 234 | category_s ystem = i_ category_s ystem, | |
| 235 | category_c ode = i_ca tegory_cod e, | |
| 236 | sender = i _sender, | |
| 237 | recipient = i_recipi ent, | |
| 238 | payload_ti tle = i_pa yload_titl e, | |
| 239 | sent = i_s ent, | |
| 240 | status_sys tem = i_st atus_syste m, | |
| 241 | status_cod e = i_stat us_code, | |
| 242 | payload_at tachment_c ontenttype = i_attac hment_cont enttype, | |
| 243 | payload_co ntent = i_ payload_co ntent, | |
| 244 | payload_da ta = i_pay load_data, | |
| 245 | payload_at tachment_d ata = i_at tachment_d ata | |
| 246 | WH EN NOT MAT CHED THEN | |
| 247 | INSERT (id entifier, category_s ystem, cat egory_code , sender, recipient, payload_t itle, sent , status_s ystem, sta tus_code, payload_at tachment_c ontenttype , payload_ content, p ayload_dat a, payload _attachmen t_data) | |
| 248 | VALUES (io _identifie r, i_categ ory_system , i_catego ry_code, i _sender, i _recipient , i_payloa d_title, i _sent, i_s tatus_syst em, i_stat us_code, i _attachmen t_contentt ype, i_pay load_conte nt, i_payl oad_data, i_attachme nt_data); | |
| 249 | o_rowc ount := sq l%rowcount ; | |
| 250 | END crea te_message ; | |
| 251 | ||
| 252 | PROCEDUR E delete_m essage(i_i dentifier varchar2, o_rowcount OUT numbe r) | |
| 253 | AS | |
| 254 | BEGIN | |
| 255 | UPDATE communica tion.messa ge | |
| 256 | SET status _code = 'd eleted', s tatus_syst em = 'http ://ehmp. DNS /messageSt atus' | |
| 257 | WHERE identifier = i_ident ifier; | |
| 258 | o_rowc ount := sq l%rowcount ; | |
| 259 | END dele te_message ; | |
| 260 | ||
| 261 | PROCEDUR E activate _message(i _identifie r varchar2 , o_rowcou nt OUT num ber) | |
| 262 | AS | |
| 263 | BEGIN | |
| 264 | UPDATE communica tion.messa ge | |
| 265 | SET st atus_code = 'complet ed', statu s_system = 'http://h l7.org/fhi r/ValueSet /communica tion-statu s' | |
| 266 | WHERE identifier = i_ident ifier; | |
| 267 | o_rowc ount := sq l%rowcount ; | |
| 268 | END acti vate_messa ge; | |
| 269 | ||
| 270 | PROCEDUR E update_u ser_prefer ences(i_us er_id varc har2, i_ca tegory_sys tem varcha r2, i_cate gory_code varchar2, i_enabled varchar2, o_rowcount OUT numbe r) | |
| 271 | AS | |
| 272 | BEGIN | |
| 273 | IF i_u ser_id IS NULL THEN | |
| 274 | upda te_user_pr eferences( i_category _system, i _category_ code, i_en abled, o_r owcount); | |
| 275 | ELSE | |
| 276 | MERG E INTO com munication .user_pref erences | |
| 277 | USIN G dual ON (user_id = i_user_id and categ ory_system = i_categ ory_system and categ ory_code = i_categor y_code) | |
| 278 | WHEN MATCHED T HEN UPDATE SET enabl ed = i_ena bled | |
| 279 | WHEN NOT MATCH ED THEN IN SERT (user _id, categ ory_system , category _code, ena bled) | |
| 280 | VALU ES (i_user _id, i_cat egory_syst em, i_cate gory_code, i_enabled ); | |
| 281 | o_ro wcount := sql%rowcou nt; | |
| 282 | END IF ; | |
| 283 | END upda te_user_pr eferences; | |
| 284 | ||
| 285 | PROCEDUR E update_u ser_prefer ences(i_ca tegory_sys tem varcha r2, i_cate gory_code varchar2, i_enabled varchar2, o_rowcount OUT numbe r) | |
| 286 | AS | |
| 287 | BEGIN | |
| 288 | UPDATE user_pref erences SE T enabled = i_enable d WHERE ca tegory_sys tem = i_ca tegory_sys tem and ca tegory_cod e = i_cate gory_code; | |
| 289 | o_rowc ount := sq l%rowcount ; | |
| 290 | END upda te_user_pr eferences; | |
| 291 | ||
| 292 | FUNCTION array_to_ table(i_ar ray VARCHA R2_ARRAY) RETURN VAR CHAR2_LIST as | |
| 293 | l_inde x pls_inte ger := i_a rray.first ; | |
| 294 | l_tab VARCHAR2_L IST := VAR CHAR2_LIST (); | |
| 295 | BEGIN | |
| 296 | WHILE l_index IS NOT NULL LOOP | |
| 297 | l_tab.ex tend; | |
| 298 | l_tab(l_ tab.last) := i_array (l_index); | |
| 299 | l_index := i_array .next(l_in dex); | |
| 300 | END LO OP; | |
| 301 | RETURN l_tab; | |
| 302 | END; | |
| 303 | ||
| 304 | END MESSAG E_API; | |
| 305 | ||
| 306 | / | |
| 307 | ||
| 308 | ---------- ---------- ---------- ---------- ---------- ------ | |
| 309 | -- DDL fo r Package Grants | |
| 310 | ---------- ---------- ---------- ---------- ---------- ------ | |
| 311 | ||
| 312 | GRANT EXEC UTE ON COM MUNICATION .MESSAGE_A PI TO ehmp _rw_role; | |
| 313 | / | |
| 314 | ||
| 315 |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.