Produced by Araxis Merge on 9/27/2017 9:44:48 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.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | adk\adk\product\production\documentation\adk | using-adk.md | Mon Aug 28 20:39:30 2017 UTC |
| 2 | adk\adk\product\production\documentation\adk | using-adk.md | Tue Sep 26 13:01:59 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 3778 |
| Changed | 1 | 4 |
| 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 | ::: page-d escription | |
| 2 | # API, Uti lities & S ervices # | |
| 3 | List of al l availabl e API call s, utiliti es, and se rvices tha t the ADK exposes | |
| 4 | ::: | |
| 5 | ||
| 6 | ## Collect ions ## | |
| 7 | ||
| 8 | **`ADK.Col lections`* * are Back bone colle ction defi nitions wi th extende d fetch me chanisms, as well as additiona l function ality depe nding on w hich colle ction is b eing used. **`ADK.Co llections` ** should be the mec hanism use d to fetch and maint ain domain data from the resou rce server , instead of the now deprecate d ADK.Reso urceServic e and ADK. PatientRec ordService . | |
| 9 | ||
| 10 | **Note:** anything t he BaseCol lection su pports, th e other co llections will also support as they exte nd the Bas eCollectio n. | |
| 11 | ||
| 12 | To see ful l options, see the s ections be low. An ex ample usag e (using B aseCollect ion): | |
| 13 | ||
| 14 | ```JavaScr ipt | |
| 15 | var fetchO ptions = { | |
| 16 | resource Title: 'my -resource- title-from -directory ' | |
| 17 | }; | |
| 18 | var myColl = new ADK .Collectio ns.BaseCol lection(); | |
| 19 | myColl.fet ch(fetchOp tions); | |
| 20 | ``` | |
| 21 | ||
| 22 | ### BaseCo llection # ## | |
| 23 | ||
| 24 | The base c ollection definition that the other coll ections in **`ADK.Co llections` ** extend from. The fetch func tion has b een extend ed to gene rate the u rl from th e Resource Directory, as well a s apply pa tient info rmation re levant to the fetch url if `pa tientData: true`. | |
| 25 | ||
| 26 | #### Fetch ing #### | |
| 27 | ||
| 28 | After inst antiation (`var myCo ll = new A DK.Collect ions.BaseC ollection( )`), you h ave two op tions to r etrieve th e data: | |
| 29 | ||
| 30 | **GET** : simply cal l `myColl. fetch(fetc hOptions)` | |
| 31 | ||
| 32 | **POST** : simply ca ll `myColl .post(fetc hOptions)` (alternat ively, set `type: 'P OST'` with `.fetch`) | |
| 33 | ||
| 34 | There is n o differen ce on how the fetchO ptions nee ds to be f ormatted b etween `.f etch` and `.post` -- the `Base Collection ` handles that for y ou. | |
| 35 | ||
| 36 | ##### Fetc hOptions # #### | |
| 37 | ||
| 38 | ```JavaScr ipt | |
| 39 | // Availab le options , in addit ion to mos t xhr/Back bone.Model fetch opt ions. | |
| 40 | // Default s shown wh ere applic able. | |
| 41 | var fetchO ptions = { | |
| 42 | type: 'G ET', // `t ype: 'POST '` is alte rnative to calling ` myColl.pos t` | |
| 43 | cache: t rue, // wh ether the fetch url and respon se will be cached | |
| 44 | patientD ata: false , // sends pid of cu rrent pati ent | |
| 45 | resource Title: 'my -resource- title-from -directory ', // maps to Resour ceDirector y | |
| 46 | allowAbo rt: true, // if anot her fetch goes out, abort will be called | |
| 47 | criteria : { // sen d as part of the que ry string parameters | |
| 48 | templa te: 'notex t' // an e xample, wi ll be reso urce-speci fic | |
| 49 | } // thi s above wo uld parse to '?templ ate=notext ' in the u rl | |
| 50 | }; | |
| 51 | ``` | |
| 52 | ||
| 53 | #### Use C ase #### | |
| 54 | ||
| 55 | This colle ction type should be used for simple dat a fetches in which s erver pagi ng, sortin g, and/or filtering is not req uired. | |
| 56 | ||
| 57 | #### Parse Error Cat ching #### | |
| 58 | ||
| 59 | Each parse call is w rapped in a try/catc h and upon an uncaug ht error, the collec tion will throw an ' error' eve nt, which can be tre ated the s ame as a f etch error . | |
| 60 | ||
| 61 | ### Server Collection ### | |
| 62 | ||
| 63 | Extends [B aseCollect ion](#Coll ections-Ba seCollecti on), and a dds server -side func tionality, such as g etting and managing pages of d ata, sorti ng while m anaging pa ge state, and filter ing approp riately. S upports [Q ueryBuilde r](#Collec tions-Quer yBuilder) on `this.C riteria`. | |
| 64 | ||
| 65 | #### Fetch Options ## ## | |
| 66 | ```JavaScr ipt | |
| 67 | // in addi tion to th e options supported in BaseCol lection | |
| 68 | var fetchO ptions = { | |
| 69 | sortKey: "dateTime desc, ref erenceDate Time desc" | |
| 70 | }; | |
| 71 | ``` | |
| 72 | ||
| 73 | #### Funct ions #### | |
| 74 | - **server Sort(sortK ey, fetchO ptions)**: sets new sort key t hen trigge rs fetch. Calls `res et` with s tate optio n set to ' sorting' | |
| 75 | - **server Filter(fil terObject, fetchOpti ons)**: fi lterObject should ha ve `values ` and `fie lds`. Call s `reset` with state option se t to 'filt ering' | |
| 76 | - **hasNex tPage**: r eturns tru e if there are more total item s than the current s tart index | |
| 77 | - **getNex tPage(fetc hOptions)* *: fetches next page if `hasNe xtPage` re turns true | |
| 78 | ||
| 79 | #### Use C ase #### | |
| 80 | ||
| 81 | This colle ction shou ld be used when serv er-side pa ging, sort ing, and f iltering i s required , but the data is ex pected to be a flat list of mo dels. | |
| 82 | ||
| 83 | ### Groupi ngCollecti on ### | |
| 84 | ||
| 85 | Extends th e [ServerC ollection] (#Collects -ServerCol lection), and thus i s designed to conduc t server-s ide paging , sorting, and filte ring, but there are expected t o be "grou ps" of mod els, i.e. grouped mo dels by fa cility. | |
| 86 | ||
| 87 | #### Fetch Options ## ## | |
| 88 | ```JavaScr ipt | |
| 89 | // in addi tion to th e options supported in ServerC ollection | |
| 90 | var fetchO ptions = { | |
| 91 | groupKey : FullScre enColumns[ 0].groupKe y, // data attribute to group with | |
| 92 | groupNam e: FullScr eenColumns [0].name | |
| 93 | }; | |
| 94 | ``` | |
| 95 | ||
| 96 | #### Funct ions #### | |
| 97 | - **getTot alItems**: returns l ength of a ll items i n all grou ps of mode ls | |
| 98 | - **isEmpt y**: retur ns true if either `c ollection. length` is 0 or `get TotalItems ` is 0 | |
| 99 | - **setGro uping(grou ping)**: u pdates att ribute to group on. Does not u pdate grou pings | |
| 100 | - **server Sort(sortK ey, option s)**: in a ddition to the [`Ser verCollect ion.server Sort`](#Co llections- ServerColl ection), p ass in `gr oupKey` to update at tribute to group on, else will go to def ault/initi al groupin g -- calls `setGroup ing` with appropriat e groupKey | |
| 101 | ||
| 102 | #### Use C ase #### | |
| 103 | ||
| 104 | This colle ction shou ld be used when serv er-side pa ging, sort ing, and f iltering i s required , and the data is ex pected to be in the form of a list of gr oups of mo dels. | |
| 105 | ||
| 106 | ### QueryB uilder ### | |
| 107 | ||
| 108 | The QueryB uilder man ages the g eneration of certain criteria sent with fetch requ ests. For example, t he [Server Collection ](#Collect ions-Serve rCollectio n) makes u se of the QueryBuild er to main tain the l ogic for t he date ra nge, text filter, pa gination, and sort o rder. The typical us e case is just to ac cess the c riteria th rough the collection . | |
| 109 | ||
| 110 | Example us age (as do ne in [Ser verCollect ion](#Coll ections-Se rverCollec tion)): | |
| 111 | ```JavaScr ipt | |
| 112 | initialize : function () { | |
| 113 | // this is a chain ed constru ctor that instantiat es all sup ported cri teria | |
| 114 | this.Cri teria = ne w QueryBu ilder.Crit eria(); | |
| 115 | // examp le use, wo rks in sim ilar manne r with all supported criteria types | |
| 116 | this.Cri teria.Page .setPageSi ze(100); | |
| 117 | this.Cri teria.Page .setMax(30 0); | |
| 118 | }, | |
| 119 | fetch: fun ction(fetc hOptions) { | |
| 120 | // calls `getCrite ria` for e ach criter ion | |
| 121 | fetchOpt ions.crite ria = this .Criteria. getCriteri a(); | |
| 122 | // ... | |
| 123 | } | |
| 124 | ``` | |
| 125 | ||
| 126 | #### Crite ria #### | |
| 127 | ||
| 128 | When insta ntiated, i nstantiate s all supp orted crit eria. This is the re commended and most c onvenient way to man age criter ia, as opp osed to in stantiatin g the crit eria indiv idually. | |
| 129 | ||
| 130 | ##### Attr ibutes ### ## | |
| 131 | On instant iation, se ts the fol lowing att ributes to the insta ntiated su pported cr iteria. (a ccessible through `C riteria.<c riterion>` ) | |
| 132 | ||
| 133 | - [**Query **](#Colle ctions-Que ryBuilder- Query): ge neric gene rator tail ored for J DS formatt ed queries . Useful f or queries not suppo rted by ot her criter ia below. | |
| 134 | - [**Range **](#Colle ctions-Que ryBuilder- Range): us ed to set date range if 'range ' is a sup ported fie ld in the resource | |
| 135 | - [**TextF ilter**](# Collection s-QueryBui lder-TextF ilter): us ed to filt er with mu ltiple tex t filters against mu ltiple fie lds | |
| 136 | - [**Page* *](#Collec tions-Quer yBuilder-P age): used to mainta in page st ate for pa geable col lections | |
| 137 | - [**NoTex t**](#Coll ections-Qu eryBuilder -NoText): reduces da ta payload | |
| 138 | - [**SortK ey**](#Col lections-Q ueryBuilde r-SortKey) : used to maintain s ort order | |
| 139 | ||
| 140 | ##### Func tions #### # | |
| 141 | ||
| 142 | - **Criter ia.reset** : calls `r eset` on a ll support ed criteri a | |
| 143 | - **Criter ia.getCrit eria**: ca lls `getCr iteria` on all suppo rted crite ria | |
| 144 | ||
| 145 | #### Query #### | |
| 146 | Already in stantiated by `Query Builder.Cr iteria()` | |
| 147 | ||
| 148 | Alternativ e isolated instantia tion: `Que ryBuilder. QueryBuild er()` | |
| 149 | ||
| 150 | Query is a generic J DS query g enerator. There are functions such as `Q uery.betwe en` that r eturn a ne w query. D oing this does not a dd that qu ery to the Query obj ect. To do this, you should cr eate the n ew query t hen pass i t to `Quer y.add`. | |
| 151 | ||
| 152 | ##### Attr ibutes ### ## | |
| 153 | ||
| 154 | None that should be accessed. `_fields` is used in ternally t o keep tra ck of adde d queries (i.e. with `Query.ad d`), but s hould not be relied on. | |
| 155 | ||
| 156 | ##### Func tions #### # | |
| 157 | ||
| 158 | - **Query. hasQueries **: return s true if queries we re added u sing the ` Query.add` function | |
| 159 | - **Query. between(fi eld, start , end)**: returns ne w 'between ' query | |
| 160 | - **Query. gte(field, value)**: returns n ew 'gte' ( greater th an or equa l) query | |
| 161 | - **Query. lte(field, value)**: returns n ew 'lte' ( less than or equal) query | |
| 162 | - **Query. or(firstQu ery, secon dQuery)**: returns n ew 'or' qu ery, which is a comb ination of the first and secon d queries passed in separated by an 'or' | |
| 163 | - **Query. and(firstQ uery, seco ndQuery)** : returns new 'and' query, whi ch is a co mbination of the fir st and sec ond querie s passed i n separate d by an 'a nd' | |
| 164 | - **Query. in(field, array)**: returns ne w 'in' que ry, i.e. ' in(field,[ array[0],a rray[1],.. ,array[X]] )' | |
| 165 | - **Query. not(query) **: return s new 'not ' query, i .e. 'ne(fi eld,query) ' | |
| 166 | - **Query. ne(field, query)**: returns ne w 'ne' que ry, i.e. ' in(field,[ array[0],a rray[1],.. ,array[X]] )' | |
| 167 | - **Query. createClau se(clause) **: create s new func tion at `Q uery[claus e]` that r eceives 'f ield' and 'values' a s paramete r; functio n is a pas s through to `Query. custom`. R eturns fal se if the clause (st ring) spec ified alre ady exists , i.e. 'be tween' or 'lte' | |
| 168 | - **Query. custom(cla use, field , values)* *: returns new query using 'cl ause' as m ap to cust om clause created us ing `Query .createCla use`. No n eed to use this func tion, as c alling `Qu ery[clause ](field, v alue)` is equivalent | |
| 169 | - **Query. add(query) **: adds q uery to `_ values` (i .e. will b e returned by `Query .getCriter ia`) | |
| 170 | - **Query. clearFilte rs**: clea rs all que ries added with `Que ry.add` | |
| 171 | - **Query. dateFilter (field, st art, end)* *: returns date filt er query. Returns a `Query.bet ween` when 'start' a nd 'end' a re strings , `Query.g te` when o nly 'start ' is given , and `Que ry.lte` wh en only 'e nd' | |
| 172 | - **Query. globalDate Filter(fie ld)**: ret urns date filter que ry with 's tart' and 'end' from the globa l date fil ter in Ses sion (call s `Query.d ateFilter` with thes e values) | |
| 173 | - **Query. toString** : converts all queri es added w ith `Query .add` into a string that can b e used in the url. R eturns str ing | |
| 174 | - **Query. reset**: c lears all queries ad ded with ` Query.add` | |
| 175 | - **Query. getCriteri a**: used when conve rting to c riteria be fore fetch . Returns object wit h single s tring on ' filter' at tribute. S ingle stri ng is all queries ad ded with ` Query.add` stringifi ed and con catenated together ( using `Que ry.toStrin g`) | |
| 176 | ||
| 177 | #### Range #### | |
| 178 | Already in stantiated by `Query Builder.Cr iteria()` | |
| 179 | ||
| 180 | Alternativ e isolated instantia tion: `Que ryBuilder. RangeBuild er()` | |
| 181 | ||
| 182 | Range sets a date ra nge criter ia field, i.e. 'rang e={fromDat e}..{toDat e}' | |
| 183 | ||
| 184 | ##### Attr ibutes ### ## | |
| 185 | ||
| 186 | None that should be accessed. `isSet`, ` _fromDate` , and `_to Date` are set intern ally to ke ep track o f those re spective v alues. | |
| 187 | ||
| 188 | ##### Func tions #### # | |
| 189 | ||
| 190 | - **Range. setRange(f romDate, t oDate)**: sets `_fro mDate` and `_toDate` with give n strings, and sets `isSet` to true | |
| 191 | - **Range. createFrom GlobalDate **: calls `Range.set Range` usi ng 'fromDa te and 'to Date' from global da te filter | |
| 192 | - **Range. toString** : returns `_fromDate ` and `_to Date` as c oncatenate d string s eparated b y two peri ods, i.e. '{fromDate }..{toDate }' | |
| 193 | - **Range. reset**: u nsets `_fr omDate`, ` _toDate`, and `isSet ` | |
| 194 | - **Range. getCriteri a**: retur ns range a s an objec t with url -friendly string (us es `Range. toString`) set to 'r ange' attr ibute. | |
| 195 | ||
| 196 | #### TextF ilter #### | |
| 197 | Already in stantiated by `Query Builder.Cr iteria()` | |
| 198 | ||
| 199 | Alternativ e isolated instantia tion: `Que ryBuilder. TextFilter Builder()` | |
| 200 | ||
| 201 | TextFilter allows fo r the crea tion and m aintenance of multip le text fi lters agai nst multip le fields, i.e. `fil terFields= [{field1}, {field2}, ..,{fieldX }]` and `f ilterList= [{filter1} ,{filter2} ,..,{filte rY}]` | |
| 202 | ||
| 203 | ##### Attr ibutes ### ## | |
| 204 | ||
| 205 | - `default Values` (a rray): set with `Tex tFilter.se tDefaultVa lues` | |
| 206 | - `default Fields` (a rray): set with `Tex tFilter.se tDefaultFi elds` | |
| 207 | ||
| 208 | `_values` and `_fiel ds` are us ed to keep track of the values and field s internal ly, and sh ould not b e accessed . | |
| 209 | ||
| 210 | ##### Func tions #### # | |
| 211 | ||
| 212 | - **TextFi lter.setDe faultValue s(defaultV alues)**: sets `defa ultValues` taking in an array of strings | |
| 213 | - **TextFi lter.setDe faultField s(defaultF ields)**: sets `defa ultFields` taking in an array of strings | |
| 214 | - **TextFi lter.addTe xtValue(va lueString) **: adds v alueString to `_valu es` | |
| 215 | - **TextFi lter.addTe xtValues(v alueArray) **: add ea ch value i n array to `_values` , calls `T extFilter. addTextVal ue` on eac h item in array | |
| 216 | - **TextFi lter.remov eTextValue (valueStri ng)**: rem oves value String fro m `_values ` | |
| 217 | - **TextFi lter.remov eTextValue s(valueArr ay)**: rem oves each value in a rray from `_values`, calls `Te xtFilter.r emoveTextV alue` on e ach item i n array | |
| 218 | - **TextFi lter.addFi eld(fieldN ame)**: ad ds fieldNa me (string ) to `_fie lds` | |
| 219 | - **TextFi lter.addFi elds(field Array)**: adds array of field names to ` _fields`, calls `Tex tFilter.ad dField` on each item in array | |
| 220 | - **TextFi lter.remov eField(fie ldName)**: removes f ieldName ( string) fr om `_field s` | |
| 221 | - **TextFi lter.remov eFields(fi eldArray)* *: removes array of field name s from `_f ields`, ca lls `TextF ilter.remo veField` o n each ite m in array | |
| 222 | - **TextFi lter.clear TextValues **: clears `_values` | |
| 223 | - **TextFi lter.clear Fields**: clears `_f ields` | |
| 224 | - **TextFi lter.clear **: clears `_values` (calls `T extFilter. clearTextV alues`) an d `_fields ` (`TextFi lter.clear Fields`) | |
| 225 | - **TextFi lter.reset Values**: resets val ues to tho se set wit h `TextFil ter.setDef aultValues ` (or empt y array) | |
| 226 | - **TextFi lter.reset Fields**: resets fie lds to tho se set wit h `TextFil ter.setDef aultFields ` (or empt y array) | |
| 227 | - **TextFi lter.reset **: resets `_values` and `_fie lds` to de faults (ca lls `TextF ilter.setD efaultValu es` and `T extFilter. setDefault Fields`) | |
| 228 | - **TextFi lter.getFi lterTextVa lues**: re turns arra y of value strings | |
| 229 | - **TextFi lter.getFi lterFields **: return s array of field str ings | |
| 230 | - **TextFi lter.getCr iteria**: used when converting to fetch- friendly f ormat. Ret urns objec t with `fi lterList` (calls `Te xtFilter.g etFilterTe xtValues`) and `filt erFields` (calls `Te xtFilter.g etFilterFi elds`) as attributes | |
| 231 | ||
| 232 | #### Page #### | |
| 233 | Already in stantiated by `Query Builder.Cr iteria()` | |
| 234 | ||
| 235 | Alternativ e isolated instantia tion: `Que ryBuilder. PageBuilde r()` | |
| 236 | ||
| 237 | Page maint ains the p age state for pageab le collect ions (i.e. [ServerCo llection]( #Collectio ns-ServerC ollection) -- server paging). | |
| 238 | ||
| 239 | ##### Attr ibutes ### ## | |
| 240 | ||
| 241 | - `start` (integer): start ind ex in coll ection, up date with `Page.next ` | |
| 242 | - `limit` (integer): page size , update w ith `Page. setPageSiz e` | |
| 243 | - `max` (i nteger): m aximum num ber of ite ms in coll ection. Us ed for `Pa ge.hasNext `. Updated with `Pag e.setMax` | |
| 244 | ||
| 245 | ##### Func tions #### # | |
| 246 | ||
| 247 | - **Page.s etPageSize **: sets t he `limit` to the pr ovided val ue | |
| 248 | - **Page.n ext**: cal led when c ollection should get next page . Updates `start` to provided next start index, or the previ ous `start ` + `limit ` | |
| 249 | - **Page.s etMax**: c alled when total num ber of ite ms in coll ection is known (i.e . after in itial fetc h). Sets ` max` with the provid ed value | |
| 250 | - **Page.h asNext**: returns tr ue if ther e is a nex t page. Ch ecks if `s tart` is l ess than ` max` | |
| 251 | - **Page.r eset**: se ts `start` to 0, uns ets `max`, and retur ns `limit` to defaul t page siz e | |
| 252 | - **Page.g etCriteria **: used w hen conver ting to fe tch-friend ly format. Returns o bject with `start` a nd `limit` as attrib utes | |
| 253 | ||
| 254 | #### NoTex t #### | |
| 255 | Already in stantiated by `Query Builder.Cr iteria()` | |
| 256 | ||
| 257 | Alternativ e isolated instantia tion: `Que ryBuilder. NoTextBuil der()` | |
| 258 | ||
| 259 | If NoText is enabled , reduces data paylo ad (resour ce must su pport it) | |
| 260 | ||
| 261 | ##### Attr ibutes ### ## | |
| 262 | ||
| 263 | - `notext` (boolean) : turns fl ag on/off, updated w ith `NoTex t.enable` and `NoTex t.disable` | |
| 264 | ||
| 265 | ##### Func tions #### # | |
| 266 | ||
| 267 | - **NoText .enable**: sets `not ext` to tr ue | |
| 268 | - **NoText .enable**: sets `not ext` to fa lse | |
| 269 | - **NoText .getCriter ia**: used when conv erting to fetch-frie ndly forma t. Returns object wi th `notext ` as attri bute | |
| 270 | ||
| 271 | #### SortK ey #### | |
| 272 | Already in stantiated by `Query Builder.Cr iteria()` | |
| 273 | ||
| 274 | Alternativ e isolated instantia tion: `Que ryBuilder. SortKeyBui lder()` | |
| 275 | ||
| 276 | Builds and maintains key that collection is sorted on | |
| 277 | ||
| 278 | ##### Attr ibutes ### ## | |
| 279 | ||
| 280 | - `default ` (string) : key to f all back t o after re set, updat ed with `S ortKey.set DefaultKey ` | |
| 281 | - `order` (string): current so rt key, up dated with `SortKey. setSortKey ` | |
| 282 | ||
| 283 | ##### Func tions #### # | |
| 284 | ||
| 285 | - **SortKe y.setDefau ltKey(defa ultKey)**: sets `def ault` to d efaultKey | |
| 286 | - **SortKe y.setSortK ey(sortKey )**: sets `order` to sortKey | |
| 287 | - **SortKe y.reset**: sets `ord er` to `de fault` | |
| 288 | - **SortKe y.getCrite ria**: use d when con verting to fetch-fri endly form at. Return s object w ith `order ` as attri bute | |
| 289 | ||
| 290 | ## Models ## | |
| 291 | **`ADK.Mod els`** are Backbone model defi nitions wi th extende d fetch me chanisms, as well as additiona l function ality depe nding on w hich colle ction is b eing used. **`ADK.Mo dels`** sh ould be th e mechanis m used to fetch and maintain d omain data from the resource s erver, ins tead of th e now depr ecated ADK .ResourceS ervice's a nd ADK.Pat ientRecord Service's `fetchMode l` functio ns. | |
| 292 | ||
| 293 | **Note:** anything t he BaseMod el support s, the oth er models will also support as they will extend th e BaseMode l. | |
| 294 | ||
| 295 | To see ful l options, see the s ections be low. An ex ample usag e (using B aseModel): | |
| 296 | ||
| 297 | ```JavaScr ipt | |
| 298 | var fetchO ptions = { | |
| 299 | resource Title: 'my -resource- title-from -directory ' | |
| 300 | }; | |
| 301 | var myMode l = new AD K.Models.B aseModel() ; | |
| 302 | myModel.fe tch(fetchO ptions); | |
| 303 | ``` | |
| 304 | ### BaseMo del ### | |
| 305 | The base m odel defin ition that the other models in **`ADK.Mo dels`** wi ll extend from. The 'save' and 'fetch' f unctions h ave been e xtended to generate the url fr om the Res ourceDirec tory, as w ell as app ly patient informati on relevan t to the f etch url i f `patient Data: true `. | |
| 306 | ||
| 307 | #### Fetch #### | |
| 308 | ||
| 309 | After inst antiation (`var myMo del = new ADK.Models .BaseModel ()`), simp ly call 'f etch' with any attri butes and fetch opti ons to fet ch a model from the server. [F etch optio ns are bel ow](#Model s-BaseMode l-FetchOpt ions) | |
| 310 | ||
| 311 | #### Save #### | |
| 312 | ||
| 313 | After inst antiation (`var myMo del = new ADK.Models .BaseModel ()`), simp ly call 's ave' with any attrib utes and [ fetch opti ons](#Mode ls-BaseMod el-FetchOp tions) to send a POS T (first) or PATCH/P UT (subseq uent) to t he server: | |
| 314 | ||
| 315 | #### Fetch Options ## ## | |
| 316 | ||
| 317 | ```JavaScr ipt | |
| 318 | // Availab le options , in addit ion to mos t xhr/Back bone.Model fetch opt ions. | |
| 319 | // Default s shown wh ere applic able. | |
| 320 | var fetchO ptions = { | |
| 321 | cache: t rue, // wh ether the fetch url and respon se will be cached | |
| 322 | patientD ata: false , // sends pid of cu rrent pati ent | |
| 323 | resource Title: 'my -resource- title-from -directory ', // maps to Resour ceDirector y | |
| 324 | allowAbo rt: true / / if anoth er fetch g oes out, a bort will be called | |
| 325 | }; | |
| 326 | ``` | |
| 327 | ||
| 328 | #### Use C ase #### | |
| 329 | ||
| 330 | This model type shou ld be used for data fetches fe tches or s aves. | |
| 331 | ||
| 332 | #### Parse Error Cat ching #### | |
| 333 | ||
| 334 | Each parse call is w rapped in a try/catc h and upon an uncaug ht error, the model will throw an 'error ' event, w hich can b e treated the same a s a fetch error. | |
| 335 | ||
| 336 | ## Resourc eService # # | |
| 337 | RESOURCE S ERVICE FET CHING NOW DEPRECATED , please t ransition to use [** `ADK.Colle ctions`**] (#Collecti ons) and [ **`ADK.Mod els`**](#M odels) | |
| 338 | ||
| 339 | > **ADK.Re sourceServ ice** is a n applicat ion servic e that ret urns an ob ject of fu nctions th at allows a develope r to inter act with t he Softwar e Developm ent Kit's [Vista Exc hange API] [VXAPI]. | |
| 340 | ||
| 341 | Using ADK. ResourceSe rvice allo ws you to perform fe tches agai nst any do main liste d in the [ VX-API's R esource Di rectory][V XAPI]. Ne w domains can be add ed to the Vista Exch ange API t hrough the SDK's [Re source Dev elopment K it][RDK]. | |
| 342 | ||
| 343 | ### Method s ### | |
| 344 | **ADK.Reso urceServic e.**[metho d below] | |
| 345 | ||
| 346 | #### .fetc hCollectio n(options) {.method .copy-link } #### | |
| 347 | returns a Backbone M odel of th e requeste d resource | |
| 348 | [(list of options)][ ADK.Record Service.Co mmonOption s] | |
| 349 | ``` JavaSc ript | |
| 350 | var data = ADK.Resou rceService .fetchColl ection({.. .}); | |
| 351 | ``` | |
| 352 | #### .fetc hModel(opt ions) {.me thod .copy -link} ### # | |
| 353 | returns a Backbone M odel of th e requeste d resource | |
| 354 | [(list of options)][ ADK.Record Service.Co mmonOption s] | |
| 355 | ``` JavaSc ript | |
| 356 | var data = ADK.Resou rceService .fetchMode l({...}); | |
| 357 | ``` | |
| 358 | #### .fetc hResponseS tatus(opti ons) {.met hod .copy- link} #### | |
| 359 | returns a Backbone M odel of th e requeste d resource | |
| 360 | [(list of options)][ ADK.Record Service.Co mmonOption s] | |
| 361 | ``` JavaSc ript | |
| 362 | var Respon seStatus = ADK.Resou rceService .fetchResp onseStatus ({...}); | |
| 363 | ``` | |
| 364 | #### .rese tCollectio n(original Collection , options) {.method .copy-link } #### | |
| 365 | returns or ginialColl ection aft er a new f etch is ca lled to up date the c ollection' s models | |
| 366 | [(list of options)][ ADK.Record Service.Co mmonOption s] | |
| 367 | ``` JavaSc ript | |
| 368 | var data = ADK.Resou rceService .fetchColl ection({.. .}); | |
| 369 | data = ADK.Resou rceService .resetColl ection(dat a, {...}); | |
| 370 | ``` | |
| 371 | #### .filt erCollecti on(origina lCollectio n, filterF unction) { .method .c opy-link} #### | |
| 372 | returns th e originia lCollectio n after it is filter ed by the filter fun ction | |
| 373 | ``` JavaSc ript | |
| 374 | var data = ADK.Resou rceService .fetchColl ection({.. .}); | |
| 375 | var filter edData = A DK.Resourc eService.f ilterColle ction(data , function (model) { | |
| 376 | if (ty peof model .get('id') !== 'unde fined') { | |
| 377 | re turn true; | |
| 378 | } else { | |
| 379 | re turn false ; | |
| 380 | } | |
| 381 | }); | |
| 382 | ``` | |
| 383 | #### .buil dUrl(resou rceTitle, criteria) {.method . copy-link} #### | |
| 384 | returns a resource's URL from VX-API's r esource di rectory | |
| 385 | ``` JavaSc ript | |
| 386 | var url = ADK.Resour ceService. buildUrl(' user-servi ce-userinf o', {param eter1:'exa mple'}); | |
| 387 | ``` | |
| 388 | #### .buil dJdsDateFi lter(dateF ilterOptio ns) {.meth od .copy-l ink} #### | |
| 389 | returns a date filte r string t hat is gen erated by dateFilter Options | |
| 390 | ``` JavaSc ript | |
| 391 | var dateFi lter = ADK .ResourceS ervice.bui ldJdsDateF ilter({par ameter1:'e xample'}); | |
| 392 | ``` | |
| 393 | #### .clea rAllCache( domainStri ng) {.meth od .copy-l ink} #### | |
| 394 | deletes al l cached f etches fro m Backbone .fetchCach e in the d omain spec ified (if no domainS tring is s pecified, all cached data will be delete d) | |
| 395 | ``` JavaSc ript | |
| 396 | ADK.Resour ceService. clearAllCa che('user- service-us erinfo'); | |
| 397 | ADK.Resour ceService. clearAllCa che(); | |
| 398 | ``` | |
| 399 | #### Commo n Options #### | |
| 400 | The follow ing are at tributes t hat may be included in the **o ptions** o bject para meter used in the fo llowing me thods: **f etchCollec tion**, ** fetchModel **, **rese tCollectio n** (secon d paramete r), and ** fetchRespo nseStatus* *. | |
| 401 | ||
| 402 | | Attribut e | T ype | D escription | | |
| 403 | |--------- ---------- -------|-- -------|-- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -----| | |
| 404 | | **resour ceTitle** | s tring | r esource ti tle from V X-API's re source dir ectory use d to gener ate a url | | |
| 405 | | **pageab le** | b oolean | f etchCollec tion or re setCollect ion will r eturn a Ba ckbone.Pag eableColle ction when _true_ | | |
| 406 | | **collec tionConfig ** | o bject | c ollection config pas sed to con structor ( see below for more d etails) | | |
| 407 | | **viewMo del** | o bject | v iew model object tha t contains a parse f unction th at overrid es the def ault model parse [(b ackbone do cumentatio n)][ModelP arse] | | |
| 408 | | **criter ia** | o bject | k ey value p airs conve rted to qu ery string parameter s on fetch URL (see below for more detai ls) | | |
| 409 | | **cache* * | b oolean | f etch from cache when _true_, b ypass/expi re cache w hen _false _. (defaul t true) | | |
| 410 | | **cacheE xpiration* * | i nteger | c ache expir ation in s econds or _false_ fo r never ex pires. (d efault 10 minutes) | | |
| 411 | ||
| 412 | ::: side-n ote | |
| 413 | **Provided below is more detai ls about c ommon opti ons for AD K.RecordSe rvice meth ods.** | |
| 414 | ##### coll ectionConf ig {.optio n} ##### | |
| 415 | Available attributes for the c ollectionC onfig obje ct: | |
| 416 | ||
| 417 | ###### .co llectionPa rse {.opti on} ###### | |
| 418 | function t hat receiv es a colle ction and returns an Object Ar ray to ove rride defa ult collec tion parse . | |
| 419 | ```JavaScr ipt | |
| 420 | fetchOptio ns.collect ionConfig = { | |
| 421 | co llectionPa rse: funct ion(collec tion) { | |
| 422 | return c ollection. where({ | |
| 423 | summ ary: 'CHOC OLATE' | |
| 424 | }); | |
| 425 | } | |
| 426 | }; | |
| 427 | ``` | |
| 428 | ##### crit eria {.opt ion} ##### | |
| 429 | Examples o f possible criteria key - valu e pairs: | |
| 430 | ||
| 431 | ###### .fi lter {.opt ion} ##### # | |
| 432 | criteria o ption for passing JD S filter [ (see JDS d ocumentati on for fil ter syntax )][RDK] | |
| 433 | ```JavaScr ipt | |
| 434 | ||
| 435 | criteria = { | |
| 436 | filter: 'lte(overa llStart,"2 013"),gte( overallSto p,"2015")' | |
| 437 | } | |
| 438 | ||
| 439 | ``` | |
| 440 | ###### .so rt {.optio n} ###### | |
| 441 | criteria o ption for passing JD S sort ord er | |
| 442 | ```JavaScr ipt | |
| 443 | criteria = { | |
| 444 | order: ' overallSto p DESC' | |
| 445 | } | |
| 446 | ``` | |
| 447 | ###### .pa ging {.opt ion} ##### # | |
| 448 | (see resou rce direct ory for ap plicable r esources) | |
| 449 | ```JavaScr ipt | |
| 450 | criteria = { | |
| 451 | paging: { | |
| 452 | 'start ': '0', // start show ing result s from thi s 0-based index | |
| 453 | 'limit ': '10' // show this many resul ts | |
| 454 | } | |
| 455 | } | |
| 456 | ``` | |
| 457 | ::: | |
| 458 | #### More Examples # ### | |
| 459 | The follow ing is an example of fetching both a mod el and col lection us ing ADK's ResourceSe rvice: | |
| 460 | ```JavaScr ipt | |
| 461 | define([ | |
| 462 | "ADK", | |
| 463 | ... | |
| 464 | ], functio n (ADK, .. .) { | |
| 465 | ... | |
| 466 | var fe tchOptions = { | |
| 467 | cach e: true, | |
| 468 | reso urceTitle: 'some-res ource-titl e', //reso urce title from reso urce direc tory | |
| 469 | view Model: vie wModel, // optional o verride of default v iewModel | |
| 470 | page able: true ; //option al to retu rn a Backb one.Pageab leCollecti on | |
| 471 | coll ectionConf ig: { //op tional | |
| 472 | co llectionPa rse: funct ion(collec tion) { | |
| 473 | return c ollection; | |
| 474 | } | |
| 475 | } | |
| 476 | crit eria: crit eria //opt ional crit eria objec t gets con verted to query stri ng paramet ers on res ource call | |
| 477 | }; | |
| 478 | resour ceCollecti on = ADK.R esourceSer vice.fetch Collection (fetchOpti ons); | |
| 479 | resour ceModel = ADK.Resour ceService. fetchModel (fetchOpti ons); | |
| 480 | }); | |
| 481 | ``` | |
| 482 | ||
| 483 | ## Patient RecordServ ice ## | |
| 484 | PATIENT RE CORD SERVI CE FETCHIN G NOW DEPR ECATED, pl ease trans ition to u se [**`ADK .Collectio ns`**](#Co llections) and [**`A DK.Models` **](#Model s) with `p atientData : true` | |
| 485 | ||
| 486 | > **ADK.Pa tientRecor dService** acts simi lar to ADK .ResourceS ervice exc ept it all ows you to fetch res ources fro m the Reso urceDirect ory in reg ards to a particular patient b y passing in a patie nt attribu te as part of the op tions para meter. | |
| 487 | ||
| 488 | ### Method s ### | |
| 489 | **ADK.Pati entRecordS ervice.**[ method bel ow] | |
| 490 | #### .fetc hModel(opt ions) {.me thod .copy -link} ### # | |
| 491 | returns a Backbone M odel of th e requeste d resource | |
| 492 | ``` JavaSc ript | |
| 493 | var Patien tData = AD K.PatientR ecordServi ce.fetchMo del(); | |
| 494 | ``` | |
| 495 | ##### Opti ons ##### | |
| 496 | In additio n to the a ttributes available in the [op tions](#AD K-Services -ResourceS ervice) ob ject of AD K's Resour ceService, the follo wing attri butes may be include d in the * *options** object pa rameter us ed in this method. | |
| 497 | ||
| 498 | | Attribut e | Typ e | Descri ption | | |
| 499 | |--------- -----|---- ---------- --|------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | | |
| 500 | | **patien t** | Bac kbone Mode l | Model containing a patient 's identif ying attri butes. Whe n left und efined the applicati on's curre ntly selec ted patien t model wi ll be used | | |
| 501 | ##### More Example(s ) ##### | |
| 502 | ###### Pro viding Opt ions ##### # | |
| 503 | The follow ing grabs the applic ation's cu rrent pati ent's demo graphic re cord data. | |
| 504 | ::: showco de Show ex ample | |
| 505 | ``` | |
| 506 | var fetchO ptions = { | |
| 507 | 'resourc eTitle' : 'patient-r ecord-pati ent', //r esource ti tle from r esource di rectory | |
| 508 | 'onSucce ss': funct ion(){ | |
| 509 | // Ale rt others that the d ata is bac k ? | |
| 510 | } | |
| 511 | }; | |
| 512 | ||
| 513 | var patien tModel = A DK.Patient RecordServ ice.fetchM odel(fetch Options); | |
| 514 | ``` | |
| 515 | ::: | |
| 516 | ###### Fet ch Data fo r a Specif ic Patient ###### | |
| 517 | The follow ing grabs the demogr aphic reco rd data fo r a specif ic patient . | |
| 518 | ::: showco de Show ex ample | |
| 519 | ``` | |
| 520 | var fetchO ptions = { | |
| 521 | 'resourc eTitle' : 'patient-r ecord-pati ent', //r esource ti tle from r esource di rectory | |
| 522 | // Provide model of the patien t you woul d like to receive th e resource data on | |
| 523 | 'patient ' : Backbo ne.Model.e xtend({pid : "...."}) | |
| 524 | // | |
| 525 | }; | |
| 526 | ||
| 527 | var patien tModel = A DK.Patient RecordServ ice.fetchM odel(fetch Options); | |
| 528 | ``` | |
| 529 | ::: | |
| 530 | #### .fetc hCollectio n(options) {.method .copy-link } #### | |
| 531 | returns a Backbone C ollection of the req uested res ource | |
| 532 | ``` JavaSc ript | |
| 533 | var Patien tData = AD K.PatientR ecordServi ce.fetchCo llection() ; | |
| 534 | ``` | |
| 535 | ##### Opti ons ##### | |
| 536 | In additio n to the a ttributes available in the [op tions](#AD K-Services -ResourceS ervice) ob ject of AD K's Resour ceService, the follo wing attri butes may be include d in the * *options** object pa rameter us ed in this method. | |
| 537 | ||
| 538 | | Attribut e | Typ e | Descri ption | | |
| 539 | |--------- -----|---- ---------- --|------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | | |
| 540 | | **patien t** | Bac kbone Mode l | Model containing a patient 's identif ying attri butes. Whe n left und efined the applicati on's curre ntly selec ted patien t model wi ll be used | | |
| 541 | ##### More Example(s ) ##### | |
| 542 | ###### Pro viding Opt ions ##### # | |
| 543 | The follow ing grabs the applic ation's cu rrent pati ent's medi cation rec ord data. | |
| 544 | ::: showco de Show ex ample | |
| 545 | ``` | |
| 546 | var fetchO ptions = { | |
| 547 | 'resourc eTitle' : 'patient-r ecord-med' , //resou rce title from resou rce direct ory | |
| 548 | 'onSucce ss': funct ion(){ | |
| 549 | // Ale rt others that the d ata is bac k ? | |
| 550 | } | |
| 551 | }; | |
| 552 | ||
| 553 | var medica tionCollec tion = ADK .PatientRe cordServic e.fetchCol lection(fe tchOptions ); | |
| 554 | ``` | |
| 555 | ::: | |
| 556 | ###### Fet ch Data fo r a Specif ic Patient ###### | |
| 557 | The follow ing grabs the medica tion recor d data for a specifi c patient. | |
| 558 | ::: showco de Show ex ample | |
| 559 | ``` | |
| 560 | var fetchO ptions = { | |
| 561 | 'resourc eTitle' : 'patient-r ecord-med' , //resou rce title from resou rce direct ory | |
| 562 | // Provide model of the patien t you woul d like to receive th e resource data on | |
| 563 | 'patient ' : Backbo ne.Model.e xtend({pid : "...."}) | |
| 564 | // | |
| 565 | }; | |
| 566 | ||
| 567 | var medica tionCollec tion = ADK .PatientRe cordServic e.fetchCol lection(fe tchOptions ); | |
| 568 | ``` | |
| 569 | ::: | |
| 570 | #### .getC urrentPati ent() {.me thod .copy -link} ### # | |
| 571 | returns a Backbone M odel of th e currentl y selected patient | |
| 572 | ``` JavaSc ript | |
| 573 | var curren tPatientMo del = ADK. PatientRec ordService .getCurren tPatient() ; | |
| 574 | ``` | |
| 575 | #### .setC urrentPati ent(patien t, options ) {.method .copy-lin k} #### | |
| 576 | Triggers [ Messaging] (#Messagin g) event ` 'context:p atient:cha nge'` and passes thr ough **pat ient** and **options **. The ** patient** parameter should be either a p id string or model w ith patien t data alr eady defin ed on it. The **opti ons** para meter shou ld be in o bject form at. For mo re documen tation on applicable options, please ref er to appl et documen tation for any apple t listenin g to the ` 'context:p atient:cha nge'` Mess aging even t. | |
| 577 | ``` JavaSc ript | |
| 578 | ADK.Patien tRecordSer vice.setCu rrentPatie nt('9E7A;1 49'); | |
| 579 | ``` | |
| 580 | ``` JavaSc ript | |
| 581 | ADK.Patien tRecordSer vice.setCu rrentPatie nt(PATIENT _MODEL); | |
| 582 | ``` | |
| 583 | ||
| 584 | #### .refr eshCurrent Patient() {.method . copy-link} #### | |
| 585 | updates th e current patient mo del in ses sion with the latest data asso ciated wit h the curr ent site t he user is logged in to. | |
| 586 | ||
| 587 | #### .getR ecentPatie nts(collec tion) {.me thod .copy -link} ### # | |
| 588 | returns a Backbone C ollection of recentl y selected patient m odels. The _optional _ `collect ion` argum ent allows the patie nt models to be set on an exis ting colle ction rath er than a new Backbo ne Collect ion. The c ollection argument i s generall y used to refresh an existing collection of recent patients. | |
| 589 | ``` JavaSc ript | |
| 590 | var curren tPatientMo del = ADK. PatientRec ordService .getRecent Patients() ; | |
| 591 | ||
| 592 | var recent PatientsCo llection = ADK.Patie ntRecordSe rvice.getR ecentPatie nts(); | |
| 593 | // The col lection ca n be updat ed by pass ing in the collectio n as an ar gument. | |
| 594 | ADK.Patien tRecordSer vice.getRe centPatien ts(recentP atientsCol lection); | |
| 595 | ``` | |
| 596 | ||
| 597 | #### .fetc hResponseS tatus(opti ons) {.met hod .copy- link} #### | |
| 598 | returns HT TP respons e status f rom the fe tch call ( does not r eturn a mo del or col lection) | |
| 599 | ``` JavaSc ript | |
| 600 | var Respon seStatus = ADK.Patie ntRecordSe rvice.fetc hResponseS tatus(); | |
| 601 | ``` | |
| 602 | ##### Opti ons ##### | |
| 603 | In additio n to the a ttributes available in the [op tions](#AD K-Services -ResourceS ervice) ob ject of AD K's Resour ceService, the follo wing attri butes may be include d in the * *options** object pa rameter us ed in this method. | |
| 604 | ||
| 605 | | Attribut e | Typ e | Descri ption | | |
| 606 | |--------- -----|---- ---------- --|------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- | | |
| 607 | | **patien t** | Bac kbone Mode l | Model containing a patient 's identif ying attri butes. Whe n left und efined the applicati on's curre ntly selec ted patien t model wi ll be used | | |
| 608 | ||
| 609 | ### Events ### | |
| 610 | ADK's Pati entRecordS ervice exp oses a few events fo r hooking into it's functional ity. | |
| 611 | All Patien tRecordSer vice event s are fire d on [ADK' s global m essaging c hannel][AD K.Messagin g]. | |
| 612 | | Event Ty pe | Descriptio n | | |
| 613 | |--------- ---------- --------|- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----| | |
| 614 | | **refres h.ehmp.pat ient** | This event is fired immediatel y when the `refreshC urrentPati ent` metho d has been called. | | |
| 615 | | **refres hed.ehmp.p atient**| This event is fired when the u pdated dat a has fini shed being set on th e patient model in s ession. | | |
| 616 | ||
| 617 | ## CCOWSer vice ## | |
| 618 | > **ADK.CC OWService* * is an ap plication service th at handles CCOW (Cli nical Cont ext Object Workgroup ) context for the ap plication. In short, it allows the appli cation to navigate t o a specif ic patient when othe r connecte d applicat ions do th e same. Th e service provides f unctionali ty to conn ect to the CCOW vaul t, listen for update s to the c ontext and push cont ext update s. | |
| 619 | ||
| 620 | ### Method s ### | |
| 621 | **ADK.CCOW Service.** [method be low] | |
| 622 | ||
| 623 | #### .star t(callback ) {.method .copy-lin k} #### | |
| 624 | Initialize s and atta ches the C COW Active X control to the ser vice. Set s pertinen t CCOW ses sion infor mation as well. The callback i s executed with one parameter, an error string. If the error string is undefined , CCOW was initializ ed success fully. | |
| 625 | ||
| 626 | ##### Para meters ### ## | |
| 627 | | Attribut e | Typ e | Desc ription | | |
| 628 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 629 | | **callba ck** | fun ction | Ca llback tha t is execu ted upon c ompletion with an er ror code p arameter | | |
| 630 | ||
| 631 | #### .getT okenFromCo ntextItems () {.metho d .copy-li nk} #### | |
| 632 | Returns th e VistA co ntext toke n from the current c ontext | |
| 633 | ||
| 634 | #### .getD fnFromCont extItems() {.method .copy-link } #### | |
| 635 | Returns th e DFN valu e from the current c ontext | |
| 636 | ||
| 637 | #### .getD ivisionFro mContextIt ems() {.me thod .copy -link} ### # | |
| 638 | Returns th e division value fro m the curr ent contex t | |
| 639 | ||
| 640 | #### .pers istCcowSes sion(ccowM odel) {.me thod .copy -link} ### # | |
| 641 | Persists t he given C COW Backbo ne Model i nto sessio n storage. | |
| 642 | ||
| 643 | ##### Para meters ### ## | |
| 644 | | Attribut e | Typ e | Desc ription | | |
| 645 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 646 | | **ccowMo del** | Ba ckbone mod el | Backb one model with CCOW session pr operties s et (Notabl y 'reiniti alize' and 'status') | | |
| 647 | ||
| 648 | #### .getS iteInfo(ca llback) {. method .co py-link} # ### | |
| 649 | Calls the authentica tion resou rce to obt ain curren t site inf ormation. On success , it match es the sit e returned to the cu rrent cont ext's site . A callba ck is exec uted with the site i f they mat ch. | |
| 650 | ||
| 651 | ##### Para meters ### ## | |
| 652 | | Attribut e | Typ e | Desc ription | | |
| 653 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 654 | | **callba ck** | fun ction | Ca llback tha t is execu ted with a n error ob ject (prop erty 'erro r' that co ntains the error mes sage) or t he matched site | | |
| 655 | ||
| 656 | #### .getP id(patient ) {.method .copy-lin k} #### | |
| 657 | Returns th e dfn part of the pi d property from the passed in patient | |
| 658 | ||
| 659 | #### .hand leContextC hange(pati ent, callb ack) {.met hod .copy- link} #### | |
| 660 | Pushes a c ontext cha nge from t his applic ation to t he CCOW va ult. It up dates the context wi th all app licable in formation from the p atient par ameter. If the conte xt push is successfu l, the CCO W session object wil l show 'Co nnected' i n the stat us propert y. If it f ails, the status wil l be 'Disc onnected'. | |
| 661 | ||
| 662 | ##### Para meters ### ## | |
| 663 | | Attribut e | Typ e | Desc ription | | |
| 664 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 665 | | **patien t** | Back bone model | Patient model tha t will be pushed to the contex t | | |
| 666 | | **callba ck** | Bac kbone mode l | Callba ck that is executed regardless of succes s or failu re. Check the status property of the ses sion objec t for succ ess/failur e informat ion | | |
| 667 | ||
| 668 | #### .upda tePatientI nfo() {.me thod .copy -link} ### # | |
| 669 | Checks the currently selected patient in the appli cation and compares it to the current pa tient in t he context . If they are differ ent, it ca lls [ADK.P atientReco rdService. setCurrent Patient] t o prompt t he user to confirm t he new con text patie nt. | |
| 670 | ||
| 671 | #### .form atPatientN ameForCont ext(name) {.method . copy-link} #### | |
| 672 | returns a patient na me that is properly formatted so it can be inserte d into the context | |
| 673 | ||
| 674 | ##### Para meters ### ## | |
| 675 | | Attribut e | Typ e | Desc ription | | |
| 676 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 677 | | **name** | str ing | Pat ient name | | |
| 678 | ||
| 679 | ||
| 680 | #### .susp endContext (hideNotif ication) { .method .c opy-link} #### | |
| 681 | Suspends t he applica tion from the vault context. T his means that it wi ll no long er react t o changes in the con text until reconnect ed. The se ssion stat us propert y will be set to 'Su spended'. | |
| 682 | ||
| 683 | ##### Para meters ### ## | |
| 684 | | Attribut e | Typ e | Desc ription | | |
| 685 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 686 | | **hideNo tification ** | b oolean | If set to true, the default gr owl notifi cation wil l not appe ar when th e context is suspend ed | | |
| 687 | ||
| 688 | #### .resu meContext( ) {.method .copy-lin k} #### | |
| 689 | Reconnects the appli cation to the curren t context. If connec ted succes sfully, th e .updateP atientInfo () functio n is invok ed. | |
| 690 | ||
| 691 | #### .upda teCcowStat us(status, callback) {.method .copy-link } #### | |
| 692 | Updates th e CCOW ses sion statu s with the given par ameter str ing. | |
| 693 | ||
| 694 | ##### Para meters ### ## | |
| 695 | | Attribut e | Typ e | Desc ription | | |
| 696 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 697 | | **status ** | s tring | S tatus prop erty value to update in the se ssion | | |
| 698 | | **callba ck** | string | Callback executed u pon comple tion of th e function | | |
| 699 | ||
| 700 | #### .getC cowStatus( ) {.method .copy-lin k} #### | |
| 701 | Returns th e current status fro m the CCOW session o bject. If the browse r is not I E or the s ession is undefined, false is returned. | |
| 702 | ||
| 703 | #### .ccow IconSwitch (event, cc owAction) {.method . copy-link} #### | |
| 704 | Opens an a lert dialo g allows t he user to suspend o r resume t heir parti cipation i n the cont ext based on the giv en ccowAct ion parame ter. If cc owAction i s 'Disconn ected', th e user is prompted t o break th e link oth erwise the y are prom pted to re sume parti cipation. | |
| 705 | ||
| 706 | ##### Para meters ### ## | |
| 707 | | Attribut e | Typ e | Desc ription | | |
| 708 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 709 | | **event* * | st ring | Br owser even t that is passed alo ng when cl icking the button | | |
| 710 | | **ccowAc tion** | string | Action to take (Usua lly 'Disco nnected' o r 'Connect ed') | | |
| 711 | ||
| 712 | #### .quit () {.metho d .copy-li nk} #### | |
| 713 | Suspends t he current applicati on session from the context. T his should be called when a us er session is ending . | |
| 714 | ||
| 715 | ## UserSer vice ## | |
| 716 | > **ADK.Us erService* * is an ap plication service th at returns an object of functi ons that a llows a de veloper to retrieve and update informati on about t he current user. | |
| 717 | ||
| 718 | ### Method s ### | |
| 719 | **ADK.User Service.** [method be low] | |
| 720 | ||
| 721 | #### .getU serSession () {.metho d .copy-li nk} #### | |
| 722 | returns a Backbone M odel from [SessionSt orage](#Se ssionStora ge) with d ata attrib utes of cu rrent user . | |
| 723 | [(list of options)][ ADK.Record Service.Co mmonOption s] | |
| 724 | ``` JavaSc ript | |
| 725 | var userSe ssion = AD K.UserServ ice.getUse rSession() ; | |
| 726 | ``` | |
| 727 | ##### Resp onse ##### | |
| 728 | The Follow ing is an example ou tput of wh at gets re turned by _getUserSe ssion()_: | |
| 729 | ```JavaScr ipt | |
| 730 | // ADK.Use rService.g etUserSess ion().attr ibutes ret urns the f ollowing o bject: | |
| 731 | { | |
| 732 | "site" : "9E7A", | |
| 733 | "expir es": "2015 -02-26T19: 53:36.301Z ", | |
| 734 | "statu s": "logge din", | |
| 735 | "disab led": fals e, | |
| 736 | "divis ionSelect" : false, | |
| 737 | "duz": { | |
| 738 | "9 E7A": "100 00000227" | |
| 739 | }, | |
| 740 | "facil ity": "PAN ORAMA", | |
| 741 | "first name": "PA NORAMA", | |
| 742 | "lastn ame": "USE R", | |
| 743 | "permi ssions": [ ], | |
| 744 | "requi resReset": false, | |
| 745 | "secti on": "Medi cine", | |
| 746 | "title ": "Clinic ian", | |
| 747 | "provi der": true , | |
| 748 | "infoB uttonPanor ama": "1.3 .6.1.4.1.3 768", | |
| 749 | "infoB uttonKodak ": "1.3.6. 1.4.1.2000 ", | |
| 750 | "infoB uttonSite" : "www.som esite.com" | |
| 751 | } | |
| 752 | ``` | |
| 753 | #### .auth enticate(u serName, p assword, f acility) { .method .c opy-link} #### | |
| 754 | authentica tes agains t VX-API's Authentic ation reso urce with the provid ed credent ials. Meth od returns a $.Defer red() prom ise. If su ccessful a t authenti cating and setting t he user se ssion, pro mise.done( ) method w ill be cal led, other wise promi se.fail() method wil l be calle d with the se [list o f options] [ADK.Recor dService.C ommonOptio ns]. | |
| 755 | ``` JavaSc ript | |
| 756 | function o nSuccessfu lLogin() { | |
| 757 | consol e.log("Suc cessfully authentica ted"); | |
| 758 | } | |
| 759 | function o nFailedLog in() { | |
| 760 | consol e.log("Fai led to aut henticate" ); | |
| 761 | } | |
| 762 | ||
| 763 | var authen ticateUser = ADK.Use rService.a uthenticat e('JohnSmi th', 'Exam plePasswor d', 'AAAA' ); | |
| 764 | authentica teUser.don e(onSucces sfulLogin) .fail(onFa iledLogin) ; | |
| 765 | ``` | |
| 766 | ##### Para meters ### ## | |
| 767 | | Attribut e | Typ e | Desc ription | | |
| 768 | |--------- -----|---- ----|----- ---------- ---------- ---------- ---------- ---------- ---------- ---------- --| | |
| 769 | | **userNa me** | str ing | The username t o authenti cate | | |
| 770 | | **passwo rd** | str ing | The password t o authenti cate | | |
| 771 | | **facili ty** | str ing | The Vista faci lity to au thenticate against | | |
| 772 | ||
| 773 | #### .clea rUserSessi on() {.met hod .copy- link} #### | |
| 774 | destroys t he session of the cu rrent user both on t he client side and r esource si de. | |
| 775 | ``` JavaSc ript | |
| 776 | ADK.UserSe rvice.clea rUserSessi on(); | |
| 777 | ``` | |
| 778 | #### .hasP ermission( permission ) {.method .copy-lin k} #### | |
| 779 | checks if the curren t user has the provi ded permis sion. Retu rns **true ** if user has permi ssion, oth erwise wil l return * *false**. [Handlebar helper av ailable fo r use in t emplate](# Handlebar- Template-H elpers-Has -Permissio n) | |
| 780 | ``` JavaSc ript | |
| 781 | var hasPer missionBoo lean = ADK .UserServi ce.hasPerm ission('ed it-patient -record'); | |
| 782 | if (hasPer missionBoo lean) { | |
| 783 | console. log("User has permis sion to: E dit Patien t Record") ; | |
| 784 | } else { | |
| 785 | console. log("User does not h ave permis sion to: E dit Patien t Record") ; | |
| 786 | } | |
| 787 | ``` | |
| 788 | #### .chec kUserSessi on() {.met hod .copy- link} #### | |
| 789 | checks the user toke n's expira tion to en sure the c urrent use r is still authentic ated. Retu rns a _boo lean_ wher e **false* * indicate s token/se ssion is e xpired. | |
| 790 | ``` JavaSc ript | |
| 791 | var isUser SessionAli ve = ADK.U serService .checkUser Session(); | |
| 792 | if (isUser SessionAli ve) { | |
| 793 | console. log("User is still a ctive, and logged in ."); | |
| 794 | } else { | |
| 795 | console. log("User' s session has ended! "); | |
| 796 | } | |
| 797 | ``` | |
| 798 | ## Workspa ceContextR epository ## | |
| 799 | > **ADK.Wo rkspaceCon textReposi tory** is an applica tion servi ce that ma nages a re pository o f workspac e contexts for patie nt, staff, and admin . | |
| 800 | ||
| 801 | #### ADK.W orkspaceCo ntextRepos itory.**cu rrentConte xt** #### | |
| 802 | - Returns a Backbone Model wit h data att ributes of current * workspace* context. | |
| 803 | | Attr ibute | Type | Descrip tion | | |
| 804 | |----- ---------- ---------- -|-------- -|-------- ---------- ---------- ---------- ---------- ---------- ---------- --------| | |
| 805 | | **id ** | strin g | works pace conte xt id. e.g . 'patient ', 'admin' , or 'staf f' | | |
| 806 | ||
| 807 | #### ADK.W orkspaceCo ntextRepos itory.**cu rrentWorks pace** ### # | |
| 808 | - Returns a Backbone Model wit h data att ributes of current w orkspace. | |
| 809 | | Attr ibute | Type | Descrip tion | | |
| 810 | |----- ---------- ---------- -|-------- -|-------- ---------- ---------- ---------- ---------- ---------- ---------- --------| | |
| 811 | | **id ** | strin g | works pace id. e .g. 'overv iew' | | |
| 812 | ||
| 813 | ## Navigat ion ## | |
| 814 | > **ADK.Na vigation** controls the screen change an d route/UR L update t hroughout the applic ation. | |
| 815 | ||
| 816 | ### Naviga tion Metho ds ### | |
| 817 | #### ADK.N avigation. **navigate (workspace Id)** #### | |
| 818 | - Changes the Applic ation's cu rrent scre en to the provided s creen/work space and updates th e browser' s URL/rout e | |
| 819 | ||
| 820 | Example of navigat ing to the _"allergy -list"_ wo rkspace: | |
| 821 | ```JavaS cript | |
| 822 | ADK.Navi gation.nav igate("all ergy-list" ); | |
| 823 | ``` | |
| 824 | | Requir ed | Attribute | Type | Descrip tion | | |
| 825 | |:------ ---------- ---------- --------:| ---------- ---------- |--------- -|-------- -----| | |
| 826 | | <i cla ss="fa fa- check-circ le"></i> | **workspa ceId** | string | unique identifier | | |
| 827 | | | **o ptions** | object | optional parameter | | |
| 828 | ::: show code optio ns example : | |
| 829 | ``` | |
| 830 | { | |
| 831 | ro ute: { | |
| 832 | trigger: true | |
| 833 | }, | |
| 834 | ex traScreenD isplay: { | |
| 835 | dontLoad Applets: t rue // Ski p applet l oading dur ing screen module lo ading | |
| 836 | }, | |
| 837 | ca llback: fu nction() { // Run t his callba ck before workspace is display ed on the browser | |
| 838 | console. log('Hi AD K!'); | |
| 839 | } | |
| 840 | } | |
| 841 | ``` | |
| 842 | ||
| 843 | #### ADK.N avigation. **displayS creen(work spaceId)** #### | |
| 844 | - Changes the Applic ation's cu rrent scre en to the provided s creen/work space but does **not ** update the browse r's URL/ro ute (may w ant to use in a case where you don't wan t the prov ided scree n/workspac e change t o be saved in the br owser's hi story) | |
| 845 | ||
| 846 | Example of display ing the _" allergy-su mmary"_ wo rkspace: w orkspace: | |
| 847 | ```JavaS cript | |
| 848 | ADK.Navi gation.dis playScreen ("allergy- summary"); | |
| 849 | ``` | |
| 850 | ||
| 851 | ### Naviga tion Check s ### | |
| 852 | **DEPRECAT ED! PLEASE USE** [** ADK.Checks **](#Check s) **INSTE AD** | |
| 853 | ||
| 854 | There are situations where the user shou ld be warn ed or take an action before th e workspac e/screen i s changed using eith er _ADK.Na vigation_ or a brows er refresh /change in url. **N avigation Checks** a llow a dev eloper to register a nd unregis ter checks to a glob al collect ion at any time base d on the b usiness ne eds/requir ements. T he collect ion of glo bal checks is proces sed and ex ecuted onc e any navi gation is triggered. | |
| 855 | ||
| 856 | When a ref resh is tr iggered on the brows er or ther e is a cha nge in the url that points to outside th e applicat ion, the u ser will b e presente d a confir mation ale rt that in cludes all the regis tered navi gation che cks' _fail ureMessage _ as part of a discl aimer to t he user. | |
| 857 | ||
| 858 | ::: side-n ote | |
| 859 | **Example: ** User st arts a wor kflow that will writ e back to the server . Before the user c ompletes a nd saves t he workflo w on the c lient, an event is t riggered t o navigate to a scre en where t he in-prog ress workf low does n ot exist, which woul d cause th e in-progr ess work t o be lost. If a nav igation ch eck is reg istered on start of the workfl ow, the na vigation m ethod will not compl ete until the regist ered check passes it s conditio n to allow for navig ation to c ontinue, t hus allowi ng the use r the opti on to save or discar d the chan ges. Upon completion of the wo rkflow, th is check c an be unre gistered a nd no inte rruption t o the navi gation met hod will o ccur (unle ss other c hecks have been regi stered). | |
| 860 | ::: | |
| 861 | ||
| 862 | A **Naviga tion Check ** is defi ned as a B ackbone.Mo del with t he followi ng attribu tes: | |
| 863 | | Required | A ttribute | Type | Descripti on | | |
| 864 | |:-------- ---------- ---------- ------:|-- ---------- --------|- ---------| ---------- ---| | |
| 865 | | <i class ="fa fa-ch eck-circle "></i> | * *id** | string | unique id entifier | | |
| 866 | | <i class ="fa fa-ch eck-circle "></i> | * *failureMe ssage** | string | message t o display to the use r when the check fai ls <br/> _ (ie. shoul dNavigate returns fa lse)_ | | |
| 867 | | <i class ="fa fa-ch eck-circle "></i> | * *shouldNav igate** | function | executes appropriat e actions based on t he workspa ce being n avigated t o <br/> ** Important: ** Must re turn `true ` or `fals e` to indi cate wheth er navigat ion should continue. <br/> _No te:_ the m ethod is p assed the following parameters : the name of the sc reen being navigated to and th e config o bject used to regist er the nav igation ch eck | | |
| 868 | ||
| 869 | ::: showco de Naming standards for "id" a ttribute: | |
| 870 | ||
| 871 | ::: side-n ote | |
| 872 | The "id" s hould be a ll lowerca se separat ed by "-". | |
| 873 | It should always beg in with th e applet's id follow ed by the action and brief des cription. | |
| 874 | ||
| 875 | (`appletId `-`action` -`descript ion`) | |
| 876 | ||
| 877 | Example: " allergies- writeback- in-progres s" | |
| 878 | ::: | |
| 879 | ::: showco de Example of regist ering a na vigation c heck: | |
| 880 | ``` JavaSc ript | |
| 881 | ADK.Naviga tion.regis terCheck(n ew ADK.Nav igation.Pa tientConte xtCheck({ | |
| 882 | id: 'a ppletid-ac tion-descr iption-uni que', | |
| 883 | failur eMessage: 'This is a important message! Any unsave d changes will be lo st if you continue.' , | |
| 884 | should Navigate: function(s creenName, config){ | |
| 885 | //ch eck to avo id navigat ion to the "demo-scr een" | |
| 886 | if ( screenName === "demo -screen"){ | |
| 887 | re turn false ; | |
| 888 | } el se { | |
| 889 | re turn true; | |
| 890 | } | |
| 891 | } | |
| 892 | })); | |
| 893 | ``` | |
| 894 | ::: | |
| 895 | ||
| 896 | #### ADK.N avigation. **register Check(mode l)** #### | |
| 897 | - This met hod takes in a _navi gation che ck_ model to registe r to the g lobal coll ection and returns t he instanc e of the m odel that was regist ered. | |
| 898 | ||
| 899 | #### ADK.N avigation. **unregist erCheck(un ique)** ## ## | |
| 900 | - Takes in the "**id **" string or the wh ole model to determi ne which c heck to un register f rom the gl obal colle ction. On ce unregis tered, nav igation wi ll no long er run the check. | |
| 901 | ||
| 902 | ::: defini tion | |
| 903 | **Availabl e Checks** | |
| 904 | ||
| 905 | The follow ing are co mmon check s abstract ed to the ADK for us e througho ut the app lication. | |
| 906 | ||
| 907 | #### ADK.N avigation. PatientCon textCheck #### | |
| 908 | - Determin es if the user is be ing taken away from the "patie nt" contex t. If the user is n avigating away from a patient context wo rkspace to a differe nt context , the navi gation pro cess will be ended a nd the use r will be presented with a con firmation alert that includes the naviga tion check 's _failur eMessage_ as part of the discl aimer to t he user. | |
| 909 | - Below is an exampl e of the a lert that is present ed to the user when trying to navigate a way from a patient c ontext wor kspace: | |
| 910 |  | |
| 911 | ||
| 912 | The table below disp lays the a ttributes to define when exten ding the _ PatientCon textCheck_ . | |
| 913 | | Required | A ttribute | Type | Descripti on | | |
| 914 | |:-------- ---------- ---------- ------:|-- ---------- --------|- ---------| ---------- ---| | |
| 915 | | <i class ="fa fa-ch eck-circle "></i> | * *id** | string | unique id entifier | | |
| 916 | | <i class ="fa fa-ch eck-circle "></i> | * *failureMe ssage** | string | message t o display to the use r when the check fai ls <br/> _ (ie. shoul dNavigate returns fa lse)_ | | |
| 917 | | | * *onCancel* * | function | method ge ts called on click o f the "Can cel" butto n inside t he alert c onfirmatio n | | |
| 918 | | | * *onFailure ** | function | method ge ts called once the c heck fails (before t he alert p ops up) | | |
| 919 | ||
| 920 | **Importan t:** Do no t overwrit e the **sh ouldValida te** metho d on the _ PatientCon textCheck_ . | |
| 921 | ||
| 922 | **Note:** Follow sam e naming s tandards f or **id** attribute as defined above. | |
| 923 | ||
| 924 | ::: | |
| 925 | ||
| 926 | ## Checks ## | |
| 927 | ||
| 928 | > **ADK.Ch ecks** ena bles custo m logical interrupti ons in the user's wo rkflow. An example o f this wou ld be stop ping the u ser from n avigating away from a screen w hen a form is in pro gress. Thi s is achie ved by reg istering l ogic traps and callb acks as mo dels in th e collecti on of chec ks which c an be trig gered at a ny time (p lease use responsibl y) | |
| 929 | ||
| 930 | Below is a n example of how to register a nd run a s imple chec k. Feel fr ee to try it out in the browse r's consol e. Obvious ly, it has no inhere nt value t o the appl ication. A list of p redefined check mode l definiti ons are pr ovided in the **Avai lable Pred efined Che cks** sect ion below. | |
| 931 | ||
| 932 | ```JavaScr ipt | |
| 933 | // should define a r eusable cl ass of che cks with a common gr oup and pu rpose | |
| 934 | // i.e. a check to b e run on n avigation (group: 'n avigation' ) | |
| 935 | var MyChec k = ADK.Ch ecks.Check Model.exte nd({ | |
| 936 | validate : function (attribute s, validat ionOptions ) { | |
| 937 | // val idate is c alled by i sValid, wh ich is cal led | |
| 938 | // by ADK.Checks .run. Both `validate ` and `isV alid` are | |
| 939 | // pre defined pa tterns in Backbone | |
| 940 | valida tionOption s = valida tionOption s || {}; | |
| 941 | var my CustomOpti ons = vali dationOpti ons.option s || {}; | |
| 942 | if (my CustomOpti ons.should Fail){ | |
| 943 | retu rn "My che ck failed! "; | |
| 944 | } | |
| 945 | }, | |
| 946 | defaults : { | |
| 947 | group: 'my-group ', | |
| 948 | onInva lid: funct ion(invali dOptions) { | |
| 949 | // r an after i sValid ret urns false | |
| 950 | inva lidOptions = invalid Options || {}; | |
| 951 | var checkConfi g = invali dOptions.c heckConfig ; | |
| 952 | var onPassCall back = inv alidOption s.onPass | | function () {}; | |
| 953 | var runCheckOp tions = in validOptio ns.options ; | |
| 954 | if ( confirm(ch eckConfig. failureMes sage)) { | |
| 955 | // Hey, it's just an e xample! wi ndow.confi rm returns true or | |
| 956 | // false dep ending on which butt on was pre ssed. | |
| 957 | // ADK.UI.Al ert should be used f or any pop up interac tion displ ayed | |
| 958 | // to the us er | |
| 959 | AD K.Checks.u nregister( checkConfi g.id); | |
| 960 | AD K.Checks.r un(checkCo nfig.group , onPassCa llback, ru nCheckOpti ons); | |
| 961 | } el se { | |
| 962 | co nsole.log( 'User canc elled the action!'); | |
| 963 | } | |
| 964 | } | |
| 965 | } | |
| 966 | }); | |
| 967 | ADK.Checks .register( new MyChec k({ | |
| 968 | id: 'exa mple-id', | |
| 969 | label: ' Example', | |
| 970 | failureM essage: 'M y example check has failed! Wo uld you li ke to cont inue?' | |
| 971 | })); | |
| 972 | var myChec kOptions = { | |
| 973 | shouldFa il: true | |
| 974 | } | |
| 975 | ADK.Checks .run('my-g roup', fun ction(){ | |
| 976 | // metho d to run a fter all c hecks pass | |
| 977 | console. log('My ch ecks all p assed! Now do someth ing :)'); | |
| 978 | }, myCheck Options); | |
| 979 | ``` | |
| 980 | ||
| 981 | ### Check Model Defi nition ### | |
| 982 | In the cas e that a n ew check m odel class need be d efined, it it highly recommend ed to exte nd **ADK.C hecks.Chec kModel**, which is u sed as a b ase for al l predefin ed checks. It is imp ortant to specify a **group** in order t o have new instances of your c heck model definitio n run all together. Similarly, **validat e** and ** onInvalid* * should a lso be spe cified sin ce without **validat e**, `isVa lid()` wil l return t rue, and i f `isValid ()` return s false, w ithout **o nInvalid** nothing w ill happen . | |
| 983 | ||
| 984 | :::side-no te | |
| 985 | **validate ** should be defined on the to p-level of the model , while ** group** an d **onInva lid** shou ld be defi ned under the model' s `default s` attribu te. | |
| 986 | ::: | |
| 987 | ||
| 988 | #### Group #### | |
| 989 | The **grou p** attrib ute should be define d as a str ing under the models `defaults ` attribut e. This st ring is us ed to name space and logically group mult iple check s, and sho uld be bot h concise and descri ptive of t he purpose of the gr oup of che cks. | |
| 990 | ||
| 991 | Example gr oup: | |
| 992 | ||
| 993 | ```JavaScr ipt | |
| 994 | var MyChec kModel = A DK.Checks. CheckModel .extend({ | |
| 995 | // ... r est of def inition | |
| 996 | defaults : { | |
| 997 | group: 'my-group ' | |
| 998 | // ... rest of d efinition | |
| 999 | }); | |
| 1000 | ``` | |
| 1001 | ||
| 1002 | #### Valid ate #### | |
| 1003 | The **vali date** att ribute sho uld be def ined as a function o n the mode l and is r un when th e model's isValid fu nction is called (Se e [Backbon e isValid documentat ion](http: //backbone js.org/#Mo del-isVali d)), which is called by ADK.Ch ecks.run. If the che ck should fail, a st ring descr ibing the failure sh ould be re turned. It receives two argume nts: _attr ibutes_ (a ttributes on the che ck model, passed in by isValid ) and _val idationOpt ions_ (obj ect with a dditional options pa ssed by AD K.Checks.r un). The _ validation Options_ a rgument wi ll receive **checkCo nfig** (at tributes o n the chec k model -- provided for consis tency and convenienc e), **onPa ss** (meth od passed into ADK.C hecks.run, in order to continu e to the n ext check) , and **op tions** (c ustom opti ons passed into ADK. Checks.run , useful f or the val idation co ndition). | |
| 1004 | ||
| 1005 | Example va lidate fun ction: | |
| 1006 | ||
| 1007 | ```JavaScr ipt | |
| 1008 | var MyChec kModel = A DK.Checks. CheckModel .extend({ | |
| 1009 | validate : function (attribute s, validat ionOptions ) { | |
| 1010 | if (/* someCondit ion*/) { | |
| 1011 | retu rn "Some c ondition f ailed"; | |
| 1012 | } | |
| 1013 | }, | |
| 1014 | // ... r est of def inition | |
| 1015 | }); | |
| 1016 | ``` | |
| 1017 | ||
| 1018 | #### OnInv alid #### | |
| 1019 | The **onIn valid** at tribute sh ould by de fined as a function on the mod el's `defa ults` attr ibute, and is called when isVa lid (calle d by ADK.C hecks.run) returns f alse. Any user inter ruption sh ould be in voked in t his callba ck. This f unction re ceives _in validOptio ns_ (an ob ject) as i ts only ar gument, wh ich will r eceive **c heckConfig ** (attrib utes on th e check mo del -- pro vided for consistenc y and conv enience), **onPass** (method p assed into ADK.Check s.run, in order to c ontinue to the next check), an d **option s** (custo m options passed int o ADK.Chec ks.run, us ed primari ly as an a rgument to chain). | |
| 1020 | ||
| 1021 | :::side-no te | |
| 1022 | Additional callbacks or option s can be e xpected an d passed i nto the in stantiatio n of the c heck model upon regi stration. An example of this w ould be ** onCancel** , which ca n then be used by th e **onInva lid** func tion. This allows fo r extensib ility of t he onInval id callbac k (i.e. av oid requir ing new de finitions of onInval id for eac h instance ). See exa mple below . | |
| 1023 | ::: | |
| 1024 | ||
| 1025 | Example on Invalid: | |
| 1026 | ||
| 1027 | ```JavaScr ipt | |
| 1028 | var MyChec kModel = A DK.Checks. CheckModel .extend({ | |
| 1029 | // ... r est of def inition | |
| 1030 | defaults : { | |
| 1031 | onInva lid: funct ion(invali dOptions) { | |
| 1032 | inva lidOptions = invalid Options || {}; | |
| 1033 | var checkConfi g = invali dOptions.c heckConfig ; | |
| 1034 | var onPassCall back = inv alidOption s.onPass | | function () {}; | |
| 1035 | var runCheckOp tions = in validOptio ns.options ; | |
| 1036 | if ( confirm(ch eckConfig. failureMes sage)) { | |
| 1037 | // it is imp ortant to unregister checks wh en done wi th them | |
| 1038 | AD K.Checks.u nregister( checkConfi g.id); | |
| 1039 | // since ADK .Checks.ru n stops an d executes only the first fail ing check | |
| 1040 | // the check callback should run the check s again in order to chain them . | |
| 1041 | AD K.Checks.r un(checkCo nfig.group , onPassCa llback, ru nCheckOpti ons); | |
| 1042 | } el se { | |
| 1043 | // otherwise , perform some other action, s uch as | |
| 1044 | // hiding th e ADK.UI.A lert view which shou ld be used | |
| 1045 | // instead o f this win dow.confir m | |
| 1046 | co nsole.log( 'User canc elled the action!'); | |
| 1047 | // example o f addition al custom callback e xpected by this func tion | |
| 1048 | if (_.isFunc tion(check Config.onC ancel)) { | |
| 1049 | checkConfi g.onCancel (); | |
| 1050 | } | |
| 1051 | } | |
| 1052 | }, | |
| 1053 | // ... rest of d efinition | |
| 1054 | }); | |
| 1055 | ``` | |
| 1056 | ||
| 1057 | ### Regist ration of Checks ### | |
| 1058 | #### ADK.C hecks.**re gister(mod els)** ### # | |
| 1059 | Adds the p rovided mo del(s) to the Backbo ne collect ion of che cks. The * *models** argument c an be eith er a singl e Backbone model or array of m odels. The model(s) passed in should be instantiat ed with an y options required b y the chec k model de finition u sed. | |
| 1060 | ||
| 1061 | Upon insta ntiation, all check models req uire an ** id** attri bute (stri ng, should be indica tive of th e originat or), **lab el** (stri ng, should be "prett y" title f or origina tor), and **failureM essage** ( string, us ed for mes sage to us er in the check mode l's chosen user inte rruption). See examp le below. | |
| 1062 | ||
| 1063 | :::callout | |
| 1064 | **Note:** on initial ize of any model ext ended from ADK.Check s.CheckMod el, the _g roup_ attr ibute is a ppended to the _id_ attribute, separated by a '-' (hyphen). For exampl e, given ` id: 'my-or iginator'` and `grou p: 'my-gro up'`, the post-initi alization id would b e "my-orig inator-my- group" | |
| 1065 | ::: | |
| 1066 | ||
| 1067 | Example re gistration : | |
| 1068 | ||
| 1069 | ```JavaScr ipt | |
| 1070 | // where M yCheck ext ends ADK.C hecks.Chec kModel | |
| 1071 | ADK.Checks .register( new MyChec k({ | |
| 1072 | id: 'exa mple-id', // used to distingui sh between checks | |
| 1073 | label: ' Example', // used by ADK.Check s.getAllLa bels -- wh ich can be used by o nInvalid | |
| 1074 | failureM essage: 'M y example check has failed! Wo uld you li ke to cont inue?' | |
| 1075 | // ^ use d by onInv alid and A DK.Checks. getAllMess ages | |
| 1076 | })); | |
| 1077 | ``` | |
| 1078 | ||
| 1079 | :::side-no te | |
| 1080 | **Register ing Multip le Checks: ** simply pass ADK.C hecks.regi ster an ar ray of mod els. There is no nee d to speci fy differe nt id's fo r each mod el passed since each id has th e individu al check's group app ended to i t. | |
| 1081 | ::: | |
| 1082 | ||
| 1083 | ||
| 1084 | #### ADK.C hecks.**un register(i d)** #### | |
| 1085 | Removes mo del(s) mat ched by ** id** argum ent, which can be in one of th e followin g formats: string (s ingle id), array of strings (m ultiple id s), object with id a nd/or grou p (single or multipl e ids), or the model (s) to be removed th emselves ( array for multiple). See the b elow examp le for exa mples of v alid unreg ister form ats. | |
| 1086 | ||
| 1087 | Example un register: | |
| 1088 | ||
| 1089 | ```JavaScr ipt | |
| 1090 | var common CheckOptio ns = { | |
| 1091 | id: 'exa mple-id', | |
| 1092 | label: ' Example', | |
| 1093 | failureM essage: 'M y example check has failed! Wo uld you li ke to cont inue?' | |
| 1094 | } | |
| 1095 | // where M yCheck ext ends ADK.C hecks.Chec kModel wit h group of 'my-group ' | |
| 1096 | var MyOthe rCheck = M yCheck.ext end({ | |
| 1097 | defaults : _.defaul ts({ | |
| 1098 | group: 'my-other -group' | |
| 1099 | }, MyChe ck.prototy pe.default s) | |
| 1100 | }); | |
| 1101 | var myChec kInstance = new MyCh eck(common CheckOptio ns); | |
| 1102 | var myOthe rCheckInst ance = new MyOtherCh eck(common CheckOptio ns); | |
| 1103 | ADK.Checks .register( [myCheckIn stance, my OtherCheck Instance]) ; | |
| 1104 | ||
| 1105 | // Given t he above ( two separa te checks of differe nt groups) | |
| 1106 | // the fol lowing met hods of un registrati on are val id | |
| 1107 | ---------- ---------- ---------- ---------- --------- | |
| 1108 | // removes both chec ks due to _.includes (id used for namesp ace) | |
| 1109 | ADK.Checks .unregiste r('example -id'); | |
| 1110 | // removes only myOt herCheckIn stance | |
| 1111 | ADK.Checks .unregiste r('example -id-my-oth er-group') ; | |
| 1112 | // removes both chec ks | |
| 1113 | ADK.Checks .unregiste r(['exampl e-id-my-gr oup','exam ple-id-my- other-grou p']); | |
| 1114 | ADK.Checks .unregiste r({ // rem oves both checks | |
| 1115 | id: 'exa mple-id' | |
| 1116 | }); | |
| 1117 | ADK.Checks .unregiste r({ // rem oves only myOtherChe ckInstance | |
| 1118 | id: 'exa mple-id-my -other-gro up' | |
| 1119 | }); | |
| 1120 | ADK.Checks .unregiste r({ // rem oves only myOtherChe ckInstance | |
| 1121 | id: 'exa mple-id', | |
| 1122 | group: ' my-other-g roup' | |
| 1123 | }); | |
| 1124 | ADK.Checks .unregiste r({ // rem oves both checks | |
| 1125 | id: 'exa mple-id', | |
| 1126 | group: [ 'my-group' ,'my-other -group'] | |
| 1127 | }); | |
| 1128 | // removes only myOt herCheckIn stance | |
| 1129 | ADK.Checks .unregiste r(myOtherC heckInstan ce); | |
| 1130 | // removes both chec ks | |
| 1131 | ADK.Checks .unregiste r([myCheck Instance, myOtherChe ckInstance ]); | |
| 1132 | ``` | |
| 1133 | ||
| 1134 | ### Execut ion of Che cks ### | |
| 1135 | ||
| 1136 | #### ADK.C hecks.**ru n(group, o nPass, opt ions)** ## ## | |
| 1137 | Requires * *group** ( string, co rresponds to relevan t group) a nd **onPas s** (funct ion, post- check targ et action) parameter s to be de fined. The **options ** paramet er will be passed in to the _va lidate_ an d _onInval id_ functi ons. | |
| 1138 | ||
| 1139 | ||
| 1140 | ### Retrie val of Dat a From Che cks ### | |
| 1141 | #### ADK.C hecks.**ge tAllMessag es(group)* * #### | |
| 1142 | Returns al l failure messages f rom the ch ecks colle ction filt ered on pr ovided **g roup** arg ument (wil l return a ll failure messages if not spe cified). | |
| 1143 | ||
| 1144 | Example: | |
| 1145 | ||
| 1146 | ```JavaScr ipt | |
| 1147 | // with tw o checks r egistered in 'my-gro up' | |
| 1148 | var myGrou pMessages = ADK.Chec ks.getAllM essages('m y-group'); | |
| 1149 | ``` | |
| 1150 | ||
| 1151 | #### ADK.C hecks.**ge tAllLabels (group, op tions)** # ### | |
| 1152 | Designed t o be used in onInval id. Thus, only inval id checks' labels wi ll be retr ieved (det ermined by calling i sValid). R etrieves l abels from all check s filtered on **grou p** (strin g, should correlate to a group in use). Returns an array of strings. T he **optio ns** argum ent will b e passed i nto the is Valid call , and shou ld be in o bject form at. Specif ying **exc lude** (st ring, shou ld match a check's i d) as an a ttribute o n the opti ons object will caus e that che ck's label to be exc luded from the retur ned array. | |
| 1153 | ||
| 1154 | Example: | |
| 1155 | ||
| 1156 | ```JavaScr ipt | |
| 1157 | // Let's s ay this is inside an onInvalid and check Config has been defi ned | |
| 1158 | // ... | |
| 1159 | // this wi ll return all active checks th at are of group "my- group" and do not | |
| 1160 | // have th e id of th is check | |
| 1161 | var myGrou pLabels = ADK.Checks .getAllLab els('my-gr oup', {exc lude:check Config.id} ); | |
| 1162 | ``` | |
| 1163 | ||
| 1164 | #### ADK.C hecks.**ge tFailingCh ecks(group , options) ** #### | |
| 1165 | Designed t o be used in onInval id. Thus, only inval id checks will be re trieved (d etermined by calling isValid). Retrieves all check s filtered on **grou p** (strin g, should correlate to a group in use). Returns an array of models. Th e **option s** argume nt will be passed in to the isV alid call, and shoul d be in ob ject forma t. Specify ing **excl ude** (str ing, shoul d match a check's id ) as an at tribute on the optio ns object will cause that chec k's label to be excl uded from the return ed array, while spec ifying **g etAttribut e** (strin g, should correlate to an attr ibute on t he check m odels, i.e . "label") will retu rn an arra y of value s correspo nding to t he values at the spe cified att ribute on each match ing check' s model. N OTE: when **getAttri bute** is specified, an object will be r eturned wi th **check s** (array of models ) and **ta rgetAttrib ute** (arr ay of valu es from ma tching che cks), inst ead of jus t an array of models . | |
| 1166 | ||
| 1167 | Example: | |
| 1168 | ||
| 1169 | ```JavaScr ipt | |
| 1170 | // Let's s ay this is inside an onInvalid and check Config has been defi ned | |
| 1171 | // ... | |
| 1172 | // this wi ll return all active checks th at are of group "my- group" and do not | |
| 1173 | // have th e id of th is check | |
| 1174 | var myGrou pLabels = ADK.Checks .getFailin gChecks('m y-group', {exclude:c heckConfig .id, getAt tribute: ' label'}); | |
| 1175 | ||
| 1176 | ``` | |
| 1177 | ||
| 1178 | ### Availa ble Predef ined Check s ### | |
| 1179 | The below are predef ined check s provided for diffe rent workf low points . | |
| 1180 | - Navigati on | |
| 1181 | - Visit Co ntext | |
| 1182 | ||
| 1183 | #### Navig ation #### | |
| 1184 | Available at **ADK.N avigation. PatientCon textCheck* * and trig gered by * *ADK.Navig ation.navi gate**. Up on failure , displays an alert which cont ains all o ther faili ng navigat ion checks . Upon con firming th e alert, w ill unregi ster and r un the **o nContinue* * for each failing c heck. | |
| 1185 | ||
| 1186 | :::definit ion | |
| 1187 | Provided c onfigurati on: | |
| 1188 | - **group: ** `'navig ation'` | |
| 1189 | - **valida te:** fail s if targe t screen i s outside of patient context | |
| 1190 | - **onInva lid:** pre sents user with aler t displayi ng _failur eMessage_ which upon "Continue " unregist ers check and contin ues naviga tion. Also allows th e followin g callback s to be de fined when initializ ing the ch eck model: | |
| 1191 | - **onCa ncel:** fu nction fir ed in aler t's "Cance l" click e vent. | |
| 1192 | - **onCo ntinue:** function f ired in al ert's "Con tinue" cli ck event. | |
| 1193 | - **onFa ilure:** f unction fi red when a lert is di splayed. | |
| 1194 | ||
| 1195 | Example re gistration : | |
| 1196 | ||
| 1197 | ```JavaScr ipt | |
| 1198 | var checkO ptions = { | |
| 1199 | id: 'e xample-wri teback-in- progress', | |
| 1200 | label: 'Example' , | |
| 1201 | failur eMessage: 'Example W riteback W orkflow In Progress! Any unsav ed changes will be l ost if you continue. ', | |
| 1202 | onCont inue: _.bi nd(functio n(model) { | |
| 1203 | fo rm.workflo w.close(); | |
| 1204 | }, for m) | |
| 1205 | }; | |
| 1206 | ADK.Checks .register( new ADK.Na vigation.P atientCont extCheck(c heckOption s)); | |
| 1207 | // Note: t he id ends up being the provid ed id, plu s the grou p | |
| 1208 | // so for the above check, the id is 'ex ample-writ eback-in-p rogress-na vigation' | |
| 1209 | // To unre gister: | |
| 1210 | ADK.Checks .register( 'example-w riteback-i n-progress '); | |
| 1211 | ``` | |
| 1212 | ::: | |
| 1213 | ||
| 1214 | #### Visit Context # ### | |
| 1215 | Available at **ADK.C hecks.pred efined.Vis itContextC heck** and triggered by a chan ge in pati ent visit context. U pon failur e, display s an alert which con tains all other fail ing visit context ch ecks. Upon confirmin g the aler t, will un register a nd run the **onConti nue** for each faili ng check. | |
| 1216 | ||
| 1217 | :::definit ion | |
| 1218 | Provided c onfigurati on: | |
| 1219 | - **group: ** `'visit -context'` | |
| 1220 | - **valida te:** alwa ys fails. In other w ords, if y ou're regi stered, th e onInvali d will fir e. | |
| 1221 | - **onInva lid:** pre sents user with aler t displayi ng _failur eMessage_ which upon "Continue " unregist ers check and contin ues to the next chec k. Also al lows the f ollowing c allbacks t o be defin ed when in itializing the check model: | |
| 1222 | - **onCa ncel:** fu nction fir ed in aler t's "Cance l" click e vent. | |
| 1223 | - **onCo ntinue:** function f ired in al ert's "Con tinue" cli ck event. | |
| 1224 | - **onFa ilure:** f unction fi red when a lert is di splayed. | |
| 1225 | ::: | |
| 1226 | ||
| 1227 | Example re gistration : | |
| 1228 | ||
| 1229 | ```JavaScr ipt | |
| 1230 | var checkO ptions = { | |
| 1231 | id: 'e xample-wri teback-in- progress', | |
| 1232 | label: 'Example' , | |
| 1233 | failur eMessage: 'Example W riteback W orkflow In Progress! Any unsav ed changes will be l ost if you continue. ', | |
| 1234 | onCont inue: _.bi nd(functio n(model) { | |
| 1235 | fo rm.workflo w.close(); | |
| 1236 | }, for m) | |
| 1237 | }; | |
| 1238 | ADK.Checks .register( new ADK.Ch ecks.prede fined.Visi tContextCh eck(checkO ptions)); | |
| 1239 | // Note: t he id ends up being the provid ed id, plu s the grou p | |
| 1240 | // so for the above check, the id is 'ex ample-writ eback-in-p rogress-vi sit-contex t' | |
| 1241 | // To unre gister: | |
| 1242 | ADK.Checks .register( 'example-w riteback-i n-progress '); | |
| 1243 | ``` | |
| 1244 | ||
| 1245 | ## Messagi ng ## | |
| 1246 | ||
| 1247 | > **ADK.Me ssaging** allows for global-sc ope eventi ng to faci litate a v ariety of functional ity, such as applet to applet communicat ion and gl obal date range even ting. | |
| 1248 | ||
| 1249 | #### ADK.* *Messaging ** #### | |
| 1250 | - The glob al Backbon e.Radio ch annel [Bac kbone.Radi o docs][Ba ckboneRadi o] | |
| 1251 | ||
| 1252 | ```JavaScr ipt | |
| 1253 | ADK.Messag ing.on("<s omeGlobalE vent>", fu nction(... ) {...}); | |
| 1254 | // OR ('th is' being a view) | |
| 1255 | this.liste nTo(ADK.Me ssaging, " <someGloba lEvent>", function(. ..) {...}) ; | |
| 1256 | ``` | |
| 1257 | ||
| 1258 | #### ADK.M essaging.* *getChanne l(channelN ame)** ### # | |
| 1259 | - returns a private channel sp ecific to communicat ions direc ted toward s the _cha nnelName_ | |
| 1260 | - example case would be to hav e a channe l for a sp ecific app let (see c ode exampl e below) | |
| 1261 | ||
| 1262 | ```JavaScr ipt | |
| 1263 | var someAp pletChanne l = ADK.Me ssaging.ge tChannel(' <AppletID> '); | |
| 1264 | // These a re two exa mples of u sing Backb one.Radio' s handlers and trigg er methods | |
| 1265 | someApplet Channel.re quest("<so meAppletRe quest>", o ptionalPar ameter); | |
| 1266 | someApplet Channel.co mply("<som eCommandNa me>", func tion(...) {...}); | |
| 1267 | ``` | |
| 1268 | ::: side-n ote | |
| 1269 | Be sure to read the docs ([**B ackbone.Ra dio**][Bac kboneRadio ]) to unde rstand all of the di fferences between ev ents, requ ests, and commands. For instan ce, you ca n have man y listener s for a gi ven _event _ on a giv en channel , but only _one_ lis tener for a given _c ommand_ on a given c hannel (re gistering a new list ener for c ommand B o n channel A will ove rwrite any previous listener f or command B on chan nel A). | |
| 1270 | ::: | |
| 1271 | ||
| 1272 | The follow ing is an example of setting u p listener to a date change. | |
| 1273 | ```JavaScr ipt | |
| 1274 | /* | |
| 1275 | * First t he date ch ange event should be registere d through ADK.Messag ing, this time in da te picker: | |
| 1276 | */ | |
| 1277 | ||
| 1278 | // "this" = the even t-triggeri ng/date-pi cker view | |
| 1279 | this.model .set({ | |
| 1280 | fromDa te: fromDa te, | |
| 1281 | toDate : toDate | |
| 1282 | }); | |
| 1283 | // Note th e model be ing served up to who mever subs cribes to the event. | |
| 1284 | // Also no te that no channel i s being re quested, s o scope is global. | |
| 1285 | ADK.Messag ing.trigge r('date:se lected', t his.model) ; | |
| 1286 | ``` | |
| 1287 | ```JavaScr ipt | |
| 1288 | /* | |
| 1289 | * Then th e listener is set up , this tim e in an ap plet view: | |
| 1290 | */ | |
| 1291 | ||
| 1292 | // "this" = the appl et view | |
| 1293 | var self = this; | |
| 1294 | // note: l istenTo is being use d so that when the v iew is des troyed the eventList ener is de stroyed as well, ".o n" should be used if the the l istener ne eds to per sist | |
| 1295 | this.liste nTo(ADK.Me ssaging, ' date:selec ted', func tion(dateM odel) { | |
| 1296 | ... // Do someth ing | |
| 1297 | ||
| 1298 | // ie. Below wou ld execute the apple t view's d ateRangeRe fresh func tion | |
| 1299 | self.d ateRangeRe fresh('dat e'); | |
| 1300 | }); | |
| 1301 | ``` | |
| 1302 | ||
| 1303 | The follow ing is an example of setting u p listener to receiv e a config : | |
| 1304 | ```JavaScr ipt | |
| 1305 | /* | |
| 1306 | * First t he reply n eeds to be set up. | |
| 1307 | */ | |
| 1308 | ||
| 1309 | var applet Config = { | |
| 1310 | 'configA ttribute1' : 'test At tribute Va lue', | |
| 1311 | 'configA ttribute2' : 'generic Attribute Value' | |
| 1312 | }; | |
| 1313 | // getting channel s o as not t o be globa l scope | |
| 1314 | var config Channel = ADK.Messag ing.getCha nnel('getA ppletConfi g'); | |
| 1315 | // when th is request is made, send this reply to t he first r equester o n this cha nnel | |
| 1316 | configChan nel.reply( 'config:re quest', ap pletConfig ); | |
| 1317 | ``` | |
| 1318 | ```JavaScr ipt | |
| 1319 | /* | |
| 1320 | * Then th e request is made: | |
| 1321 | */ | |
| 1322 | ||
| 1323 | var config Channel = ADK.Messa ging.getCh annel('get AppletConf ig'); | |
| 1324 | // request made on s ame channe l as the a ppropriate reply. | |
| 1325 | var receiv edAppletCo nfig = con figChannel .request(' config:req uest', fun ction(conf ig){ | |
| 1326 | return c onfig; | |
| 1327 | }); | |
| 1328 | receivedAp pletConfig .get('conf igAttribut e1'); | |
| 1329 | ``` | |
| 1330 | **Note:** the reques t/reply pa ttern is u sed when o nly **one* * requeste r should g et a reply | |
| 1331 | ||
| 1332 | ### Reques ts ### | |
| 1333 | **ADK.Mess aging.requ est('**[ke y below]** ')** | |
| 1334 | ||
| 1335 | Requests a re used wh en asking for a very specific thing to o ccur or fo r receivin g a flat v alue like an object or boolean . For more informati on on `.re quest()` r ead the [* *Backbone. Radio**][B ackboneRad io] docume ntation. | |
| 1336 | ||
| 1337 | The ADK ha s set up a reply han dler for e ach of the following request k eys below. | |
| 1338 | ||
| 1339 | #### ehmpC onfig {.me thod .copy -link} ### # | |
| 1340 | returns a Backbone M odel that holds cent rally mana ged applic ation conf igurations served fr om the ehm p config r esource. The ehmp c onfigurati on support s environm ent specif ic configu rations th at may be configured in a data store or infrastruc ture repos itory. | |
| 1341 | ||
| 1342 | The follow ing is an example of calling t he request . | |
| 1343 | ```JavaS cript | |
| 1344 | ADK.Mess aging.requ est('ehmpC onfig'); | |
| 1345 | ``` | |
| 1346 | The attr ibutes obj ect of the Backbone Model that is return ed to the requester looks simi lar to the following : | |
| 1347 | ```JavaS cript | |
| 1348 | { | |
| 1349 | "featu reFlags": { | |
| 1350 | "tra ckSolrStor age": fals e | |
| 1351 | } | |
| 1352 | } | |
| 1353 | ``` | |
| 1354 | You can access con figuration s like "fe atureFlags " or neste d ones lik e "trackSo lrStorage" in the fo llowing ma nner: | |
| 1355 | ```JavaS cript | |
| 1356 | var ehmp Config = A DK.Messagi ng.request ('ehmpConf ig'); | |
| 1357 | var feat ureFlags = ehmpConfi g.get('fea tureFlags' ); | |
| 1358 | var trac kSolrStora geBoolean = _.get(fe atureFlags , 'trackSo lrStorage' ); | |
| 1359 | ``` | |
| 1360 | **Note:* * The requ ester is p rovided wi th a Backb one Model but its at tributes a re frozen, so callin g `.set()` on the mo del will n ot affect the model' s attribut es or valu es. | |
| 1361 | ||
| 1362 | ## Errors ## | |
| 1363 | `ADK.Error s` mainly consists o f a [centr al collect ion of err ors](#Erro rs-Collect ion). When catching an error, an error c an be adde d to this collection by callin g [`ADK.Er rors.colle ction.add` ](http://b ackbonejs. org/#Colle ction-add) in a mann er similar to below: | |
| 1364 | ||
| 1365 | ```JavaScr ipt | |
| 1366 | if (!obj.s omeRequire dAttribute ) { | |
| 1367 | ADK.Erro rs.collect ion.add({ | |
| 1368 | messag e: 'Specif ic applet/ view: some RequiredAt tribute no t found.', // 'messa ge' is req uired | |
| 1369 | detail s: ADK.Err ors.omitNo nJSONDeep( obj, 'myOb j', {}) | |
| 1370 | // 'de tails' is optional, omitNonJSO NDeep scru bs values to be more friendly when value is saved to server, | |
| 1371 | // use ful to avo id JSON pa rsing erro rs. | |
| 1372 | }); | |
| 1373 | } | |
| 1374 | ``` | |
| 1375 | ### Collec tion ### | |
| 1376 | Backbone.C ollection that gathe rs and set s informat ion when a model is added, don e with the `parse` f unction. | |
| 1377 | ||
| 1378 | #### Addin g a New Er ror #### | |
| 1379 | On add of a new erro r (AKA a n ew Backbon e.Model), the model parse sets certain a dditional informatio n, such as some rout e informat ion and ti mestamp. T he collect ion parse also ensur es that ea ch model h as a `mess age` attri bute, and if not, re moves it f rom the co llection a nd throws an error i n the cons ole. | |
| 1380 | ||
| 1381 | **`message `** is the only requ ired attri bute, and is used as the `idAt tribute` f or each mo del. In ot her words, a message of "An er ror has oc curred." w ill only b e represen ted by one unique er ror in the collectio n, while " My Applet/ View 1: An error has occurred. " will be that much more uniqu e. Please note that the value of `messag e` is also visible t o the user , so it is important to avoid any techni cal detail s. Utilizi ng `ADK.Er rorMessagi ng.getMess age(errorC ode)` for the main c ontent of the messag e is advis ed, as thi s returns a standard ized messa ge. | |
| 1382 | ||
| 1383 | **`details `** is an optional a ttribute t hat is mea nt to be u sed as a v ehicle for any addit ional info rmation th at might b e useful f or context of the er ror, gener ally some arguments of the fun ction that the error is found in. Other helpful co ntent may be some re source res ponse opti ons, apple t configur ation, or view optio ns. Scrubb ing the co ntents of `details` with [`omi tNonJSONDe ep`](#Erro rs-Util-Fu nctions-om itNonJSOND eep-source Object--ke yString--t argetObjec t-) is adv ised, as t he model c an eventua lly be sen t to the s erver. | |
| 1384 | ||
| 1385 | ### Util F unctions # ## | |
| 1386 | #### omitN onJSONDeep (sourceObj ect, keySt ring, targ etObject) {.method . copy-link} #### | |
| 1387 | `omitNonJS ONDeep` re cursively scrubs an object or array of n on-JSON-fr iendly val ues, such as functio ns. Return s `targetO bject` wit h scrubbed copy of ` sourceObje ct` set to attribute of `keySt ring`. Uti lizes [`AD K.Errors.i sJSONFrien dly`](#Err ors-Util-F unctions-i sJSONFrien dly-item-) for type checking. Example: | |
| 1388 | ||
| 1389 | ```JavaScr ipt | |
| 1390 | // try in the consol e | |
| 1391 | var option s = { | |
| 1392 | view: ne w Backbone .Marionett e.ItemView ({ model: new Backbo ne.Model({ a: true } ) }), | |
| 1393 | values: [{ | |
| 1394 | id: 'v al1', | |
| 1395 | value: 1, | |
| 1396 | getVal ue: functi on() { | |
| 1397 | re turn 1; | |
| 1398 | }, | |
| 1399 | props: { cool: t rue } | |
| 1400 | }, { | |
| 1401 | id: 'v al2', | |
| 1402 | value: 2, | |
| 1403 | getVal ue: functi on() { | |
| 1404 | re turn 2; | |
| 1405 | }, | |
| 1406 | props: { cool: f alse } | |
| 1407 | }] | |
| 1408 | }; | |
| 1409 | JSON.strin gify(optio ns); | |
| 1410 | // Uncaugh t TypeErro r: Convert ing circul ar structu re to JSON | |
| 1411 | JSON.strin gify(ADK.E rrors.omit NonJSONDee p(options, 'options' , {})); | |
| 1412 | // "{"opti ons":{"val ues":[{"id ":"val1"," value":1," props":{"c ool":true} },{"id":"v al2","valu e":2,"prop s":{"cool" :false}}]} }" | |
| 1413 | // Note th at view an d getValue are omitt ed from ta rgetObject | |
| 1414 | ``` | |
| 1415 | ||
| 1416 | **Note:** `omitNonJS ONDeep` mu tates `tar getObject` , which me ans that m ultiple ch ild object s can be s et on `tar getObject` . | |
| 1417 | Example: | |
| 1418 | ||
| 1419 | ```JavaScr ipt | |
| 1420 | // try in console | |
| 1421 | var obj1 = {a: [{b:t rue}]}; | |
| 1422 | var obj2 = {a: [{b:f alse}]}; | |
| 1423 | var detail s = {}; | |
| 1424 | ADK.Errors .omitNonJS ONDeep(obj 1, 'obj1', details); | |
| 1425 | ADK.Errors .omitNonJS ONDeep(obj 2, 'obj2', details); | |
| 1426 | JSON.strin gify(detai ls); | |
| 1427 | // "{"obj1 ":{"a":[{" b":true}]} ,"obj2":{" a":[{"b":f alse}]}}" | |
| 1428 | ``` | |
| 1429 | ||
| 1430 | #### isJSO NFriendly( item) {.me thod .copy -link} ### # | |
| 1431 | `isJSONFri endly` che cks if `it em` is of a JSON fri endly type , and retu rns boolea n. Note th at it does not check the types of its ch ild attrib utes in ca se of an o bject/arra y. Thus th is functio n is best used recur sively, as [`omitNon JSONDeep` does](#Err ors-Util-F unctions-o mitNonJSON Deep-sourc eObject--k eyString-- targetObje ct-). Exam ples: | |
| 1432 | ||
| 1433 | ```JavaScr ipt | |
| 1434 | // try in the consol e | |
| 1435 | ADK.Errors .isJSONFri endly(fals e) // true | |
| 1436 | ADK.Errors .isJSONFri endly({ a: false }) // true | |
| 1437 | ADK.Errors .isJSONFri endly(new Error('My error')) / / false | |
| 1438 | ADK.Errors .isJSONFri endly({ er ror: new E rror('My e rror') }) // true | |
| 1439 | ADK.Errors .isJSONFri endly([1, 2, 3]) // true | |
| 1440 | ADK.Errors .isJSONFri endly([new Error('My first err or'), new Error('My second err or')]) // true | |
| 1441 | ADK.Errors .isJSONFri endly(func tion() {re turn;}) // false | |
| 1442 | ADK.Errors .isJSONFri endly({ fu nc: functi on() {retu rn;} }) // true | |
| 1443 | ``` | |
| 1444 | ||
| 1445 | ### Try/Ca tch Approa ch ### | |
| 1446 | #### Funct ion.protot ype.try(th isBind, ar gs) {.meth od .copy-l ink} | |
| 1447 | Wraps `fun ction.appl y(context, args)` in a try/cat ch. `args` can be ei ther in .a pply or .c all format (array/ar guments vs simple li st of args ). `functi on.onError ` can be d efined whi ch will be called in the catch . The 'onE rror' will receive t he `error` and `args ` passed t o the appl y. This ap proach can be used t o add erro rs to [ADK .Errors.co llection]( #Errors-Co llection) (already u sed to wra p most Bac kbone/Mari onette lif e-cycle ev ents and c allbacks). | |
| 1448 | ||
| 1449 | Example: | |
| 1450 | ```JavaScr ipt | |
| 1451 | // try in console | |
| 1452 | var testFu nc = funct ion() { | |
| 1453 | var myFu nctionToTr y = functi on(stringA rg) { | |
| 1454 | // try this with and witho ut `notHer eVariable` , | |
| 1455 | // to see it wor k with err or and wit hout error | |
| 1456 | consol e.log('in myFunc', s tringArg, notHereVar iable); | |
| 1457 | }; | |
| 1458 | myFuncti onToTry.on Error = fu nction(err or, args) { | |
| 1459 | consol e.warn('Er ror callin g myFunc', error, ar gs); | |
| 1460 | }; | |
| 1461 | // can t reat like .call | |
| 1462 | myFuncti onToTry.tr y(this, "T ry this on for size" ); | |
| 1463 | // can a lso treat like .appl y | |
| 1464 | myFuncti onToTry.tr y(this, ar guments); | |
| 1465 | }; | |
| 1466 | testFunc(' test strin g'); | |
| 1467 | ``` | |
| 1468 | ||
| 1469 | ## Session Storage ## | |
| 1470 | ### ADK's Session Ob ject ### | |
| 1471 | This refer s to the i n-memory o bject that gets used to persis t the chan ges to the following models: | |
| 1472 | **user**, **patient* *, and **g lobalDate* * | |
| 1473 | ||
| 1474 | ::: defini tion | |
| 1475 | For **savi ng** data, ADK.Sessi onStorage _always_ d efaults to saving th e key/valu e pairs to both the in-memory object as well as th e browser' s session storage, u nless expl icitly sta ting a pre ference. | |
| 1476 | ||
| 1477 | For **retr ieving** d ata, ADK.S essionStor age _alway s_ default s to using the in-me mory sessi on data, u nless expl icitly sta ting a pre ference an d the key exists as part of AD K's Sessio n models. | |
| 1478 | ||
| 1479 | ### **Note **: ADK's Session Ob ject shoul d only be transforme d through the ADK.Se ssionStora ge methods ### | |
| 1480 | ::: | |
| 1481 | ||
| 1482 | ### ADK.Se ssionStora ge.**set** ### | |
| 1483 | #### **ses sionModel( key, value , preferen ce)** #### | |
| 1484 | - Adds a k ey/value p air into t he browser 's Session Storage a nd sets th e ADK's Se ssion Obje ct _(if ap plicable)_ . | |
| 1485 | - method p arameters: | |
| 1486 | + **key* * : unique identifie r in sessi on | |
| 1487 | + **valu e** : back bone model to save i n session | |
| 1488 | + **pref erence** : (string) options: " sessionSto rage" | "s ession" | null (de fault: nul l) | |
| 1489 | * when preferenc e equals " sessionSto rage" the ADK's Sess ion Object will **no t** be set | |
| 1490 | * othe rwise the key/value pair will get set in to the ADK 's Session Object if the key e xists as o ne of [ADK 's Session models](# SessionSto rage-ADK-s -Session-O bject). | |
| 1491 | ||
| 1492 | The follow ing is an example of calling t he method and its ex pected res ponse. | |
| 1493 | ```JavaS cript | |
| 1494 | var user Model = ne w Backbone .Model({.. .}); | |
| 1495 | ADK.Sess ionStorage .set.sessi onModel('u ser', user Model, 'se ssion'); | |
| 1496 | ``` | |
| 1497 | The attr ibutes of the userMo del get st ored in th e browser' s Session Storage as a JSON ob ject. Exam ple user o bject belo w: | |
| 1498 | ```JavaS cript | |
| 1499 | user: { | |
| 1500 | "facil ity": "PAN ORAMA", | |
| 1501 | "first name": "PA NORAMA", | |
| 1502 | "lastn ame": "USE R", | |
| 1503 | "permi ssions": [ ], | |
| 1504 | ... | |
| 1505 | } | |
| 1506 | ``` | |
| 1507 | **Note:* * The user model wil l also get set in AD K's Sessio n object a s a Backbo ne model s ince prefe rence was set to _'s ession'_ | |
| 1508 | ||
| 1509 | #### **app letStorage Model(...) ** #### | |
| 1510 | - Gets the browser's Session S torage obj ect titled 'context | |
| 1511 | -appletSto rage' (e.g . patient- appletStor age) and r etrieves i ts object associated with the given _app letId_ (if _appletId _ is not a n attribut e of the a ppletStora ge object, it will c reate a ne w blank ob ject with _workspace Id | |
| 1512 | $appletId | |
| 1513 | _ as its k ey e.g. pr ovider-cen tric-view$ todo_list) . Then the _key_ / _ value_ pai r will be used to ad d / update the _appl etId_ obje ct. | |
| 1514 | ||
| 1515 | The follow ing is an example of adding la b results specific d ata to Ses sion Stora ge. | |
| 1516 | ```JavaScr ipt | |
| 1517 | ADK.Sessio nStorage.s et.appletS torageMode l('overvie w', 'lab_r esults', ' key1', 'va lue1', /* optional * / contextN ame); | |
| 1518 | ``` | |
| 1519 | The Browse r's Sessio n Storage will store the model value as a JSON obj ect: | |
| 1520 | ```JavaScr ipt | |
| 1521 | patient-ap pletStorag e: { // cu rrent cont ext is 'pa tient' in this case. | |
| 1522 | 'overvie w$lab_resu lts': { | |
| 1523 | 'key1' : 'value1' | |
| 1524 | } | |
| 1525 | } | |
| 1526 | ``` | |
| 1527 | ||
| 1528 | ### ADK.Se ssionStora ge.**get** ### | |
| 1529 | #### **ses sionModel( key, prefe rence)** # ### | |
| 1530 | - Gets the object as sociated w ith the _k ey_ from b rowser's S ession Sto rage **unl ess** _pre ference_ i s set to ' session' a nd the key exists as one of [A DK's Sessi on models] (#SessionS torage-ADK -s-Session -Object). | |
| 1531 | ||
| 1532 | The follow ing is an example of retrievin g the user model fro m ADK's Se ssion obje ct. | |
| 1533 | ```JavaScr ipt | |
| 1534 | ADK.Sessio nStorage.g et.session Model('use r', 'sessi on'); | |
| 1535 | ``` | |
| 1536 | ||
| 1537 | The follow ing is an example of retrievin g the user model fro m the brow ser's Sess ion Storag e. | |
| 1538 | ```JavaScr ipt | |
| 1539 | ADK.Sessio nStorage.g et.session Model('use r', 'sessi onStorage' ); | |
| 1540 | ``` | |
| 1541 | **Note:** if the mod el is retu rned from ADK's Sess ion object , it will respond to model eve nts when A DK's Sessi on model u pdates. Ot herwise, a new Backb one Model with ident ical attri butes will be return ed. | |
| 1542 | ||
| 1543 | #### **app letStorage Model(appl etId)** ## ## | |
| 1544 | - Gets the browser's Session S torage obj ect titled 'appletSt orage', an d retrieve s and retu rns its ob ject assoc iated with the given _appletId _. | |
| 1545 | ||
| 1546 | The follow ing is an example of getting l ab results specific data from Session St orage. | |
| 1547 | ```JavaScr ipt | |
| 1548 | ADK.Sessio nStorage.g et.appletS torageMode l('overvie w', 'lab_r esults', / * optional */ contex tName); | |
| 1549 | ``` | |
| 1550 | ||
| 1551 | **Note:** the model returned w ill be a n ew Backbon e model th at has att ributes id entical to those sto red in the browser's Session S torage obj ect. | |
| 1552 | ||
| 1553 | ### ADK.Se ssionStora ge.**delet e** ### | |
| 1554 | #### **ses sionModel( key, setDe fault)** # ### | |
| 1555 | - Removes object ass ociated wi th the giv en _key_ f rom ADK's Session ob ject and t he browser 's Session Storage o bject. Spe cifying _s etDefault_ to **true ** will re set the AD K's Sessio n model as sociated w ith the gi ven _key_ to it's sp ecified de fault valu es. | |
| 1556 | ||
| 1557 | ```JavaScr ipt | |
| 1558 | // this on e will res et the use r model to its defau lts | |
| 1559 | ADK.Sessio nStorage.d elete.sess ionModel(' user', tru e); | |
| 1560 | ||
| 1561 | // this on e will com pletely de lete all o f patient' s attribut es from Se ssion | |
| 1562 | ADK.Sessio nStorage.d elete.sess ionModel(' patient'); | |
| 1563 | ``` | |
| 1564 | ||
| 1565 | #### **app letStorage Model(appl etId)** ## ## | |
| 1566 | - Removes the object associate d with the given _ap pletId_ fr om the app letStorage object in the brows er's Sessi on Storage object. | |
| 1567 | ||
| 1568 | ```JavaScr ipt | |
| 1569 | ADK.Sessio nStorage.d elete.appl etStorageM odel('lab_ results'); | |
| 1570 | ``` | |
| 1571 | ||
| 1572 | #### **all ()** #### | |
| 1573 | - Clears a ll attribu tes from b rowser's S ession Sto rage objec t and remo ves user, patient, a nd global date model s from ADK 's Session models. | |
| 1574 | ||
| 1575 | ::: callou t | |
| 1576 | This perma nently cle ars out se ssion unti l items ar e set agai n. In othe r words, t his should not be us ed unless the user's workflow has ended, such as o n logout. | |
| 1577 | ::: | |
| 1578 | ||
| 1579 | ```JavaScr ipt | |
| 1580 | ADK.Sessio nStorage.d elete.all( ); | |
| 1581 | ``` | |
| 1582 | ||
| 1583 | ## ADK Uti lities ## | |
| 1584 | ||
| 1585 | The follow ing are th e availabl e utilitie s that hav e been cre ated thus far in the ADK. | |
| 1586 | ||
| 1587 | ### Collec tion Manip ulation ## # | |
| 1588 | **ADK.util s.**[metho d below] | |
| 1589 | ||
| 1590 | #### .sort Collection (collectio n, key, so rtType, as cending) { .method .c opy-link} #### | |
| 1591 | - _collect ion_ - The collectio n to be so rted | |
| 1592 | - _key_ - The key to sort by | |
| 1593 | - _sortTyp e_ - Alpha betical, A lphanumeri cal, Numer ical | |
| 1594 | - _ascendi ng_ - Bool ean: True for sortin g. False f or reverse sorting | |
| 1595 | ||
| 1596 | ```JavaScr ipt | |
| 1597 | sortCollec tion: func tion(colle ction, key , sortType , ascendin g) { | |
| 1598 | ADK.ut ils.sortCo llection(c ollection, key, sort Type, asce nding); | |
| 1599 | } | |
| 1600 | ``` | |
| 1601 | --- | |
| 1602 | The follow ing collec tion filte rs are ava ilable for convenien ce. Howev er, backbo ne collect ions have a built in filter me thod based on Unders core, [Und erscore][u nderscoreF ilterWebPa ge]. | |
| 1603 | ||
| 1604 | #### .filt erCollecti onByDays(c ollection, numberOfD ays, dateK ey) {.meth od .copy-l ink} #### | |
| 1605 | - _collect ion_ - The collectio n to be fi ltered | |
| 1606 | - _numberO fDays_ - T he key to sort by | |
| 1607 | - _dateKey _ - the mo del key of the date field to f ilter on | |
| 1608 | ||
| 1609 | #### .filt erCollecti onByDateRa nge(collec tion, star tDate, end Date, date Key) {.met hod .copy- link} #### | |
| 1610 | - _collect ion_ - The collectio n to be fi ltered | |
| 1611 | - _startDa te_ - Java Script Dat e object o f Start ra nge | |
| 1612 | - _endDate _ - JavaSc ript Date object of End range | |
| 1613 | - _dateKey _ - the mo del key of the date field to f ilter on | |
| 1614 | ||
| 1615 | #### .filt erCollecti onBeginsWi th(collect ion, key, filterValu e) {.metho d .copy-li nk} #### | |
| 1616 | - _collect ion_ - The collectio n to be fi ltered | |
| 1617 | - _key_ - the model key of the field to filter on | |
| 1618 | - _filterV alue_ - th e string v alue to fi lter by | |
| 1619 | ||
| 1620 | #### .filt erCollecti onByValue( collection , key, fil terValue) {.method . copy-link} #### | |
| 1621 | - _collect ion_ - The collectio n to be fi ltered | |
| 1622 | - _dateKey _ - the mo del key of the field to filter on | |
| 1623 | - _filterV alue_ - th e string v alue to fi lter by | |
| 1624 | ||
| 1625 | #### .rese tCollectio n(collecti on) {.meth od .copy-l ink} #### | |
| 1626 | - _collect ion_ - The collectio n to be re set | |
| 1627 | ||
| 1628 | ### Date U tilities # ## | |
| 1629 | **ADK.util s.**[metho d below] | |
| 1630 | ||
| 1631 | #### .form atDate(dat e, display Format, so urceFormat ) {.method .copy-lin k} #### | |
| 1632 | Returns a string tha t has been tranforme d the give n _date_ u sing the g iven _disp layFormat_ and _sour ceFormat_. | |
| 1633 | ||
| 1634 | The follow ing exampl e would re turn '1225 2014' | |
| 1635 | ```JavaScr ipt | |
| 1636 | var date = '20141225 '; | |
| 1637 | date = ADK .utils.for matDate(da te, 'MMDDY YYY', 'YYY YMMDD'); | |
| 1638 | ``` | |
| 1639 | ||
| 1640 | ||
| 1641 | #### .getT imeSince(d ateString, showMinut es) {.meth od .copy-l ink} #### | |
| 1642 | Returns an object co ntaining t he attribu tes specif ied below. The timeS ince attri bute is ca lculated w ith the gi ven _dateS tring_. If time elap sed is les s than 1 h our timeSi nce will h ave the va lue '< 1h' unless _s howMinutes _ paramete r is set t o **true** , in which case time Since will be the ac tual numbe r of minut es. | |
| 1643 | ||
| 1644 | - timeSinc e : time e lapsed sin ce the giv en moment in time | |
| 1645 | - timeUnit s : unit o f time in which resu lt is retu rned ('y': year, 'm' : month, ' d': days, 'h': hours , '\'': mi nutes) | |
| 1646 | - count : the number of timeUn its since the given date | |
| 1647 | - timeSinc eDescripti on : resul t in forma tted strin g | |
| 1648 | - isRecent : is **tr ue** if ti meSince is less than 6 months | |
| 1649 | ||
| 1650 | Example re turned val ues: | |
| 1651 | ```JavaScr ipt | |
| 1652 | // this wo uld be ret urned if t he given d ateString was 1 year ago | |
| 1653 | { | |
| 1654 | timeSinc e: '1y', | |
| 1655 | timeUnit s: 'y', | |
| 1656 | count: ' 1', | |
| 1657 | timeSinc eDescripti on: '1 Yea r', | |
| 1658 | isRecent : false | |
| 1659 | } | |
| 1660 | ``` | |
| 1661 | ||
| 1662 | #### .date Utils.date picker(sel ector, opt ions) {.me thod .copy -link} ## ## | |
| 1663 | Provides a standardi zed way to invoke th e datepick er with ma sking util izing the global con vention fo r date for matting. T he utility takes two arguments , the firs t of which is the re ference to the input DOM eleme nt for whi ch the dat epicker an d input ma sking is t o be appli ed, and th e second i s an optio ns object. | |
| 1664 | ||
| 1665 | For exampl e: | |
| 1666 | ```JavaScr ipt | |
| 1667 | var curren tDateTime = new Mome nt().forma t(ADK.util s.dateUtil s.defaultO ptions().p laceholder ); | |
| 1668 | ADK.utils. dateUtils. datepicker (this.$('# myDateInpu t'), { | |
| 1669 | 'endDate ': current DateTime | |
| 1670 | }); | |
| 1671 | //Should o ne need to retrieve options se t against an element ... | |
| 1672 | var startD ate = this .$('#myDat eInput').d ata('dateU tilOptions ').startDa te; | |
| 1673 | ``` | |
| 1674 | ||
| 1675 | Note in th e above ex ample that all confi guration o ptions can be retrie ved with t he options function call. Also note that the place holder doe s not need to be exp licitly se t on the D OM element , but sinc e this met hod expect s and inpu t element type, manu al configu ration is required f or an icon to trigge r the date picker. | |
| 1676 | ||
| 1677 | ```JavaScr ipt | |
| 1678 | $('#myDate Input').pa rent().fin d('.glyphi con-calend ar').on('c lick', fun ction() { | |
| 1679 | $('#myD ateInput') .datepicke r('show'); | |
| 1680 | }); | |
| 1681 | ``` | |
| 1682 | ||
| 1683 | The follow ing are th e default options co nfigured f or both th e datepick er and inp ut mask. S tart date defaults t o the olde st date vi sta can ac cept. All datepicker or input mask optio ns can be configured (please r efer to ea ch librari es documen tation for more info rmation). | |
| 1684 | ||
| 1685 | ```JavaScr ipt | |
| 1686 | { | |
| 1687 | format : 'mm/dd/y yyy', | |
| 1688 | placeh older: 'MM /DD/YYYY', | |
| 1689 | regex: /^(0[1-9] |1[012])\/ (0[1-9]|[1 2][0-9]|3[ 01])\/(19| 20)\d\d$/g , | |
| 1690 | clearI ncomplete: true, | |
| 1691 | todayH ighlight: true, | |
| 1692 | endDat e: new Mom ent().form at('mm/dd/ yyyy'), | |
| 1693 | startD ate: new M oment('01/ 01/1800'). format('mm /dd/yyyy') , | |
| 1694 | keyboa rdNavigati on: false, | |
| 1695 | oninco mplete: fu nction(e) { //Requir ed to ensu re model i s sync'd t o field | |
| 1696 | $( this).val( '').trigge r('change' ); | |
| 1697 | }, | |
| 1698 | inputm ask: 'm/d/ y' | |
| 1699 | } | |
| 1700 | ``` | |
| 1701 | ||
| 1702 | ||
| 1703 | ### Miscel laneous Ut ilities ## # | |
| 1704 | **ADK.util s.**[metho d below] | |
| 1705 | ||
| 1706 | #### .extr act(obj, e xpr, args) {.method .copy-link } #### | |
| 1707 | The defaul t response from the PatientRec ordService is the VP R JSON for mat. In m any cases you may wa nt to flat ten or sim plify the model for use in a v iew templa te. The m odel is ov erridden b y passing in an opti onal viewM odel param eter inclu ding a new parse met hod to the PatientRe cordServic e. | |
| 1708 | ||
| 1709 | - _obj_ - object rep resenting the respon se | |
| 1710 | - _expr_ - path expr ession | |
| 1711 | - _args_ - key value pairs in which the 'key' is u sed to ass ign a new param to r esponse, a nd the 'va lue' is th e name of the value being assi gned to th e new para m. | |
| 1712 | ||
| 1713 | ```JavaScr ipt | |
| 1714 | var viewMo del = { | |
| 1715 | parse: function( response) { | |
| 1716 | if (response .reactions ) { | |
| 1717 | response = ADK.uti ls.extract (response, response. reactions[ 0], {react ion:"name" }); | |
| 1718 | } | |
| 1719 | re turn respo nse; | |
| 1720 | } | |
| 1721 | }; | |
| 1722 | ``` | |
| 1723 | #### .char tDataBinni ng(graphDa ta, config ) {.method .copy-lin k} #### | |
| 1724 | The functi on is used to create binning d ata series for highc hart. | |
| 1725 | ::: side-n ote | |
| 1726 | **graphDat a** - The data for h ighchart | |
| 1727 | ```JavaS cript | |
| 1728 | var gra phData = { | |
| 1729 | series : [ {dateTime, val}, ... ] // high chart seri ea | |
| 1730 | oldestDate : dateTime // oldest ev ent | |
| 1731 | newestDate : dateTime // newest ev ent | |
| 1732 | } | |
| 1733 | ``` | |
| 1734 | **config** - the con figuration for binni ng | |
| 1735 | ```JavaS cript | |
| 1736 | var c onfig = { | |
| 1737 | chartWid th: 100, // chart w idth in pi xels | |
| 1738 | barWidth : 5, // width o f chart ba r / 5 by default | |
| 1739 | barPaddi ng: 2, // padding between b ars / 2 by default | |
| 1740 | normal_f unction : function(v al) {retur n Math.log ((val*val) /0.1);}, | |
| 1741 | // data no rmalizatio n function (optional ) | |
| 1742 | debug: t rue // false b y default | |
| 1743 | } | |
| 1744 | ``` | |
| 1745 | **returns* * - new bi nned data series ([{ datetime, value},... .]) | |
| 1746 | ```JavaS cript | |
| 1747 | var config = t his.option s.binningO ptions; | |
| 1748 | var chartConfi g = new Ev entGistGra ph(this.mo del.get('g raphData') ); | |
| 1749 | this .chartPoin ter = $('# graph_' + this.model .get('id') ); | |
| 1750 | if (config ) { | |
| 1751 | config .chartWidt h = (this. chartPoint er).width( ); | |
| 1752 | chartC onfig.seri es[0].data = Utils.c hartDataBi nning(this .model.get ('graphDat a'), confi g); | |
| 1753 | } | |
| 1754 | this .chartPoin ter.highch arts(chart Config); | |
| 1755 | ``` | |
| 1756 | ::: | |
| 1757 | ||
| 1758 | <br /> | |
| 1759 | ||
| 1760 | ### CRS Hi ghlight ## # | |
| 1761 | Visual not ification to the use r of relat ionships i n data whe n a is con cept is se lected and applied. | |
| 1762 | ||
| 1763 | The origin ator for n ow is only the Condi tion/Probl em domain. | |
| 1764 | ||
| 1765 | In the app letsManife st file th e applet t hat will d isplay the highlight needs to have a pro perty call ed 'crsDom ain' that has one of the follo wing value s [Vital, Medication , Laborato ry, Proble m] | |
| 1766 | ||
| 1767 | ```JavaScr ipt | |
| 1768 | { | |
| 1769 | id: 'v itals', | |
| 1770 | title: 'Vitals', | |
| 1771 | contex t: ['patie nt'], | |
| 1772 | maximi zeScreen: 'vitals-fu ll', | |
| 1773 | showIn UDWSelecti on: true, //true to show up in User Defi ned Worksp ace Carous el | |
| 1774 | permis sions: ['r ead-vital' ], | |
| 1775 | crsDom ain: ADK.u tils.crsUt il.domain. VITAL | |
| 1776 | } | |
| 1777 | ``` | |
| 1778 | ||
| 1779 | If your ap plet is us ing any of the follo wing domai ns [medica tion, labo ratory, vi tal, probl em] and it inherits from datag rid or bas eDisplayAp plet then the model only needs to have t he followi ng propert ies: | |
| 1780 | ||
| 1781 | ```JavaScr ipt | |
| 1782 | crsDomai n: ADK.uti ls.crsUtil .domain.ME DICATION, | |
| 1783 | codes: [ { | |
| 1784 | "code": "197518", | |
| 1785 | "display ": "Clinda mycin 150 MG Oral Ca psule", | |
| 1786 | "system" : "urn:oid :2.16.840. 1.113883.6 .88" | |
| 1787 | }] | |
| 1788 | ``` | |
| 1789 | ||
| 1790 | <b>The ins tructions below is o nly needed if the ap plet doesn 't inherit from data grid or ba seDisplayA pplet.</b> | |
| 1791 | ||
| 1792 | When you c all applyC onceptCode Id() it wi ll add dat aCode on t he model t hat was pa ssed to it . You only need to m ake sure t hat the mo del you pa ss has the 'crsDomai n' propert y defined: | |
| 1793 | ||
| 1794 | ```JavaScr ipt | |
| 1795 | ||
| 1796 | crsDomain : ADK.util s.crsUtil. domain.MED ICATION, ( the domain the resou rce is com ing from) | |
| 1797 | ||
| 1798 | ``` | |
| 1799 | You can us e an ADK u tility to get the fo llowing va lues: | |
| 1800 | ||
| 1801 | ```JavaScr ipt | |
| 1802 | ADK.utils. crsUtil.do main.LABOR ATORY retu rns 'Labor atory' | |
| 1803 | ADK.utils. crsUtil.do main.MEDIC ATION retu rns 'Medic ation' | |
| 1804 | ADK.utils. crsUtil.do main.PROBL EM returns 'Problem' | |
| 1805 | ADK.utils. crsUtil.do main.VITAL returns ' Vital' | |
| 1806 | ||
| 1807 | ADK.utils. crsUtil.ap plyConcept CodeId(mod el) accept s one para meter and returns an object | |
| 1808 | { | |
| 1809 | dataCode : | |
| 1810 | } | |
| 1811 | ``` | |
| 1812 | ||
| 1813 | <b>dataCod e</b> come s from the codes arr ay in the model base d on the d omain bein g used for that appl et <br /> | |
| 1814 | ||
| 1815 | In the htm l there sh ould be at tributes c alled data -code on e ach row to be highli ghted | |
| 1816 | ```JavaScr ipt | |
| 1817 | <div data- code="{{da taCode}}"> </div> | |
| 1818 | ``` | |
| 1819 | ||
| 1820 | <b>Removin g CRS High lighting</ b> | |
| 1821 | ||
| 1822 | To remove the curren t active C RS highlig hting you need to pa ss the cur rent view to the rem oveStyle() method. T his functi on will re move the S TYLE eleme nt from th e page and also hide the CRS i cons from the applet title bar s. | |
| 1823 | ||
| 1824 | ```JavaScr ipt | |
| 1825 | ||
| 1826 | ADK.utils .crsUtil.r emoveStyle (this); | |
| 1827 | ||
| 1828 | // NOTE: You can al so access the STYLE element ID and CRS i con class names by d oing the f ollowing: | |
| 1829 | ADK.utils .crsUtil.g etCssTagNa me(); | |
| 1830 | ADK.utils .crsUtil.g etCrsIconC lassName() ; | |
| 1831 | ||
| 1832 | ``` | |
| 1833 | ||
| 1834 | ## Accessi bility ## | |
| 1835 | ### Skip L inks ### | |
| 1836 | #### .Skip Links {.me thod .copy -link} ### # | |
| 1837 | SkipLinks are the co llection o f skip lin ks for any given scr een. When any are pr esent, the [SkipLink Dropdown v iew](#Acce ssibility- Skip-Links --SkipLink Dropdown) will be sh own. The p attern of adding a s kip link t o the coll ection whe n shown an d removed from the c ollection when destr oyed shoul d be follo wed. This pattern al lows for e ach screen to define the links while als o avoiding any manif est-type l ists to ma intain. Th is pattern has been abstracted to the [S kipLinks b ehavior](u i-library/ behaviors. md#SkipLin ks). Using the behav ior is the preferred manner to add and m aintain sk ip links. | |
| 1838 | ||
| 1839 | ```JavaScr ipt | |
| 1840 | // example usage | |
| 1841 | var MyView = Marione tte.Layout View.exten d({ | |
| 1842 | template : Handleba rs.compile ('<div cla ss="exampl e-target-l ink-region ">'), | |
| 1843 | onRender : function () { | |
| 1844 | ADK.Ac cessibilit y.SkipLink s.add({ | |
| 1845 | disp layText: ' Example Sk ip Link Me nu Item', // text di splayed in dropdown, also used as model id | |
| 1846 | focu sEl: this. $('.exampl e-target-l ink-region '), // ele ment on wh ich to set focus on click of m enu item | |
| 1847 | rank : 0, // no n-negative ints, low er == high er place i n collecti on (i.e. 0 would be first item ), | |
| 1848 | focu sFirstTabb able: true // if tru e, finds f irst focus able child element o f `focusEl ` | |
| 1849 | // ` focusFirst Tabbable: true` is u seful for when `focu sEl` is no t focusabl e | |
| 1850 | // i f `focusFi rstTabbabl e: false`, ensure th e element is focusab le | |
| 1851 | }); | |
| 1852 | }, | |
| 1853 | onDestro y: functio n() { | |
| 1854 | ADK.Ac cessibilit y.SkipLink s.remove(' Example Sk ip Link Me nu Item'); | |
| 1855 | } | |
| 1856 | }); | |
| 1857 | ``` | |
| 1858 | ||
| 1859 | #### .Skip LinkDropdo wn {.metho d .copy-li nk} #### | |
| 1860 | Dropdown v iew that s hows list of [skip l inks](#Acc essibility -Skip-Link s--SkipLin ks). On fo cus of ski p link, th e associat ed `focusE l` will be visually highlighte d to help make it cl ear where the elemen t resides on the scr een. On cl ick of ski p link, fo cus is set to the as sociated e lement. | |
| 1861 | ||
| 1862 | ```JavaScr ipt | |
| 1863 | // example usage | |
| 1864 | myView.sho wChildView ('exampleR egion', ne w Accessib ility.Skip LinkDropdo wn({ | |
| 1865 | collecti on: ADK.Ac cessibilit y.SkipLink s | |
| 1866 | })); | |
| 1867 | ``` | |
| 1868 | ||
| 1869 | [adkSource Code]: htt ps://code. vistacore. us/scm/app /adk.git | |
| 1870 | [ehmpuiSou rceCode]: https://co de.vistaco re.us/scm/ app/ehmp-u i.git | |
| 1871 | [standardi zedIdeWiki Page]: htt ps://wiki. vistacore. us/display / DNS RE/Team+St andardized +IDE+for+J avaScript+ Developmen t | |
| 1872 | [workspace SetupWikiP age]: http s://wiki.v istacore.u s/display/ DNS RE/Creatin g+DevOps+w orkspace+e nvironment | |
| 1873 | [sublimeWe bsite]: ht tp://www.s ublimetext .com/3 | |
| 1874 | [sublimeSe ttingsWiki Page]: htt ps://wiki. vistacore. us/x/RZsZ | |
| 1875 | [adkBuildJ enkins]: h ttps://bui ld.vistaco re.us/view /adk/view/ Next%20Bra nch/ | |
| 1876 | [bsCSS]: h ttp://getb ootstrap.c om/css/ | |
| 1877 | [bsCompone nts]: http ://getboot strap.com/ components / | |
| 1878 | [bsJQ]: ht tp://getbo otstrap.co m/javascri pt/ | |
| 1879 | [backboneW ebPage]: h ttp://back bonejs.org / | |
| 1880 | [marionett eWebPage]: https://g ithub.com/ marionette js/backbon e.marionet te/tree/ma ster/docs | |
| 1881 | [requireJs WebPage]: http://req uirejs.org / | |
| 1882 | [amdWebPag e]: http:/ /requirejs .org/docs/ whyamd.htm l | |
| 1883 | [handlebar sWebPage]: http://ha ndlebarsjs .com/ | |
| 1884 | [underscor eFilterWeb Page]: htt p://unders corejs.org /#filter | |
| 1885 | [BackboneR adio]: htt ps://githu b.com/mari onettejs/b ackbone.ra dio | |
| 1886 | [sass]: ht tp://sass- lang.com/ | |
| 1887 | [VXAPI]: v x-api/ | |
| 1888 | [RDK]: /rd k/index.md | |
| 1889 | [ModelPars e]: http:/ /backbonej s.org/#Mod el-parse | |
| 1890 | [ADK.Messa ging]: usi ng-adk.md# ADK-Messag ing | |
| 1891 | [ADK.Recor dService.C ommonOptio ns]: using -adk.md#Re sourceServ ice-Method s-Common-O ptions |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.