Produced by Araxis Merge on 10/4/2017 8:04:34 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 | rdk.zip\rdk\product\production\rdk\src\resources\crs | crs-data-transformer.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\resources\crs | crs-data-transformer.js | Tue Oct 3 17:16:40 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 514 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 'use stric t'; | |
| 2 | ||
| 3 | var _ = re quire('lod ash'); | |
| 4 | ||
| 5 | var CONCEP T_DOMAINS = { | |
| 6 | MEDICA TION: 'Med ication', | |
| 7 | VITAL: 'Vital', | |
| 8 | LABORA TORY: 'Lab oratory' | |
| 9 | }; | |
| 10 | ||
| 11 | var Concep tDomainMap = { | |
| 12 | 'RXNOR M': { | |
| 13 | do main: CONC EPT_DOMAIN S.MEDICATI ON, | |
| 14 | sy stem: 'RxN ORM' | |
| 15 | }, | |
| 16 | 'LNC': { | |
| 17 | do main: CONC EPT_DOMAIN S.LABORATO RY, | |
| 18 | sy stem: 'LOI NC' | |
| 19 | } | |
| 20 | }; | |
| 21 | ||
| 22 | function g etSystemBy GraphName( graphName) { | |
| 23 | return _.get(Con ceptDomain Map[graphN ame], 'sys tem'); | |
| 24 | } | |
| 25 | ||
| 26 | function g etDomainBy GraphName( graphName) { | |
| 27 | return _.get(Con ceptDomain Map[graphN ame], 'dom ain'); | |
| 28 | } | |
| 29 | ||
| 30 | function g etGraphNam e(uri) { | |
| 31 | // htt p://<URI_P ATH>/<grap h_name>/<c ode> | |
| 32 | // e.g . http://p url.bioont ology.org/ ontology/R XNORM/9997 | |
| 33 | // gra ph name: R XNORM | |
| 34 | var ur iRegex = / ([^\/]+)\/ [^\/]+$/; | |
| 35 | var ma tches = ur i.match(ur iRegex); | |
| 36 | if (ma tches.leng th > 1) { | |
| 37 | re turn match es[1]; | |
| 38 | } | |
| 39 | return null; | |
| 40 | } | |
| 41 | ||
| 42 | function g etCode(uri ) { | |
| 43 | // htt p://<URI_P ATH>/<grap h_name>/<c ode> | |
| 44 | // e.g . http://p url.bioont ology.org/ ontology/R XNORM/9997 | |
| 45 | // cod e: 9997 | |
| 46 | var ur iRegex = / [^\/]+\/([ ^\/]+)$/; | |
| 47 | var ma tches = ur i.match(ur iRegex); | |
| 48 | if (ma tches.leng th > 1) { | |
| 49 | re turn match es[1]; | |
| 50 | } | |
| 51 | return null; | |
| 52 | } | |
| 53 | ||
| 54 | function g etConceptD omain(item ) { | |
| 55 | // If item is ta gged as Vi tal then i t is vital , there's nothing mo re to chec k. | |
| 56 | if (_. get(item, 'isvital.v alue') === 'true') { | |
| 57 | re turn CONCE PT_DOMAINS .VITAL; | |
| 58 | } | |
| 59 | ||
| 60 | var gr aphName = getGraphNa me(item.ta rgetConcep tId.value) ; | |
| 61 | if (gr aphName) { | |
| 62 | re turn getDo mainByGrap hName(grap hName.toUp perCase()) ; | |
| 63 | } | |
| 64 | return ''; | |
| 65 | } | |
| 66 | ||
| 67 | function l istToLower Case(list) { | |
| 68 | return _.map(lis t, functio n(item) { | |
| 69 | re turn item. toLowerCas e(); | |
| 70 | }); | |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * Formats concept c odes objec ts into a system cod e group fo rmat | |
| 75 | * | |
| 76 | * Concept code obje cts as ret urned by t he CRS ser vice: | |
| 77 | * { | |
| 78 | * "targ etConceptI d": { | |
| 79 | * "ty pe": "uri" , | |
| 80 | * "va lue": "htt p://purl.b ioontology .org/ontol ogy/RXNORM /9997" | |
| 81 | * }, | |
| 82 | * "targ etConceptL abel": { | |
| 83 | * "ty pe": "lite ral", | |
| 84 | * "xm l:lang": " eng", | |
| 85 | * "va lue": "Spi ronolacton e" | |
| 86 | * } | |
| 87 | * } | |
| 88 | * | |
| 89 | * System code group format: | |
| 90 | * { | |
| 91 | * "syst em": "RxNO RM", | |
| 92 | * "code s": [ | |
| 93 | * { | |
| 94 | * " code": "99 97", | |
| 95 | * " display": "Spironola ctone" | |
| 96 | * }, | |
| 97 | * ... | |
| 98 | * ] | |
| 99 | * } | |
| 100 | */ | |
| 101 | function f ormatSyste mGroups(it ems) { | |
| 102 | var sy stemCodes = {}; | |
| 103 | _.forE ach(items, function( item) { | |
| 104 | va r uri = it em.targetC onceptId.v alue; | |
| 105 | va r system = getSystem ByGraphNam e(getGraph Name(uri)) ; | |
| 106 | va r code = g etCode(uri ); | |
| 107 | va r formatte dCode = { | |
| 108 | code: co de, | |
| 109 | display: _.get(ite m, 'target ConceptLab el.value') | |
| 110 | }; | |
| 111 | if (_.isArra y(systemCo des[system ])) { | |
| 112 | systemCo des[system ].push(for mattedCode ); | |
| 113 | } else { | |
| 114 | systemCo des[system ] = [forma ttedCode]; | |
| 115 | } | |
| 116 | }); | |
| 117 | var fo rmattedSys tems = []; | |
| 118 | _.forO wn(systemC odes, func tion(value , key) { | |
| 119 | fo rmattedSys tems.push( { | |
| 120 | system: key, | |
| 121 | codes: v alue | |
| 122 | }) ; | |
| 123 | }); | |
| 124 | return formatted Systems; | |
| 125 | } | |
| 126 | ||
| 127 | var DataTr ansformer = function (data) { | |
| 128 | this.d ata = data ; | |
| 129 | }; | |
| 130 | ||
| 131 | DataTransf ormer.prot otype.grou pByDomain = function () { | |
| 132 | this.d ata = _.gr oupBy(this .data, fun ction(item ) { | |
| 133 | re turn getCo nceptDomai n(item); | |
| 134 | }); | |
| 135 | return this; | |
| 136 | }; | |
| 137 | ||
| 138 | DataTransf ormer.prot otype.remo veUnwanted Domains = function(t argetDomai ns) { | |
| 139 | target Domains = listToLowe rCase(targ etDomains) ; // for c ase-insens itive filt ering | |
| 140 | var da taDomains = _.keys(t his.data); | |
| 141 | var fi ltered = [ ]; | |
| 142 | _.forE ach(dataDo mains, _.b ind(functi on(domain) { | |
| 143 | if (_.contai ns(targetD omains, do main.toLow erCase())) { | |
| 144 | filtered .push({ | |
| 145 | doma in: domain , | |
| 146 | item s: this.da ta[domain] | |
| 147 | }); | |
| 148 | } | |
| 149 | }, thi s)); | |
| 150 | this.d ata = filt ered; | |
| 151 | return this; | |
| 152 | }; | |
| 153 | ||
| 154 | DataTransf ormer.prot otype.form atResponse = functio n() { | |
| 155 | this.d ata = _.ma p(this.dat a, functio n(group) { | |
| 156 | re turn { | |
| 157 | 'concept .domain': group.doma in, | |
| 158 | 'code.sy stems': fo rmatSystem Groups(gro up.items) | |
| 159 | }; | |
| 160 | }); | |
| 161 | return this; | |
| 162 | }; | |
| 163 | ||
| 164 | DataTransf ormer.prot otype.valu e = functi on() { | |
| 165 | return this.data ; | |
| 166 | }; | |
| 167 | ||
| 168 | /** | |
| 169 | * Transfo rms data r eturned by the Conce pt Relatio nship Serv ice (CRS) into a for mat | |
| 170 | * that th e UI can c onsume. | |
| 171 | * | |
| 172 | * CRS raw response: | |
| 173 | * { | |
| 174 | * "head ": { | |
| 175 | * "va rs": [ | |
| 176 | * " targetConc eptId", | |
| 177 | * " targetConc eptLabel", | |
| 178 | * " isvital" | |
| 179 | * ] | |
| 180 | * }, | |
| 181 | * "resu lts": { | |
| 182 | * "bi ndings": [ | |
| 183 | * { | |
| 184 | * "targetCo nceptId": { | |
| 185 | * "type": "uri", | |
| 186 | * "value" : "http:// purl.bioon tology.org /ontology/ RXNORM/999 7" | |
| 187 | * }, | |
| 188 | * "targetCo nceptLabel ": { | |
| 189 | * "type": "literal" , | |
| 190 | * "xml:la ng": "eng" , | |
| 191 | * "value" : "Spirono lactone" | |
| 192 | * } | |
| 193 | * } , | |
| 194 | * { | |
| 195 | * "targetCo nceptId": { | |
| 196 | * "type": "uri", | |
| 197 | * "value" : "http:// purl.bioon tology.org /ontology/ LNC/84860" | |
| 198 | * }, | |
| 199 | * "targetCo nceptLabel ": { | |
| 200 | * "type": "literal" , | |
| 201 | * "xml:la ng": "eng" , | |
| 202 | * "value" : "Intrava scular dia stolic:Pre s:Pt:Arter ial system :Qn" | |
| 203 | * }, | |
| 204 | * "isvital" : { | |
| 205 | * "dataty pe": "http ://www.w3. org/2001/X MLSchema#b oolean", | |
| 206 | * "type": "typed-li teral", | |
| 207 | * "value" : "true" | |
| 208 | * } | |
| 209 | * } | |
| 210 | * ] | |
| 211 | * } | |
| 212 | * } | |
| 213 | * | |
| 214 | * Transfo rmed forma t: | |
| 215 | * [ | |
| 216 | * { | |
| 217 | * "co ncept.doma in": "medi cation", | |
| 218 | * "co de.systems ": [ | |
| 219 | * { | |
| 220 | * "system": "RxNORM", | |
| 221 | * "codes": [ | |
| 222 | * { | |
| 223 | * "code ": "9997", | |
| 224 | * "disp lay": "Spi ronolacton e" | |
| 225 | * } | |
| 226 | * ] | |
| 227 | * } | |
| 228 | * ] | |
| 229 | * }, | |
| 230 | * { | |
| 231 | * "co ncept.doma in": "vita l", | |
| 232 | * "co de.systems ": [ | |
| 233 | * { | |
| 234 | * "system": "LOINC", | |
| 235 | * "codes": [ | |
| 236 | * { | |
| 237 | * "code ": "8462", | |
| 238 | * "disp lay": "Int ravascular diastolic :Pres:Pt:A rterial sy stem:Qn" | |
| 239 | * } | |
| 240 | * ] | |
| 241 | * } | |
| 242 | * ] | |
| 243 | * } | |
| 244 | * ] | |
| 245 | * | |
| 246 | * Referen ce: https: //wiki.vis tacore.us/ display/ DNS RE/US11449 +-+Spike:+ Define+CRS +Interface +for+query ing+relati onships+-+ Concept+Hi ghlighting | |
| 247 | * | |
| 248 | * @param {array} includeDom ains An ar ray of dom ains to in clude in t he data, a ll others | |
| 249 | * will be fi ltered out | |
| 250 | * @param {object} rawData Ra w response object fr om the CRS service | |
| 251 | */ | |
| 252 | module.exp orts.trans form = fun ction(incl udeDomains , rawData) { | |
| 253 | return new DataT ransformer (rawData) | |
| 254 | .g roupByDoma in() | |
| 255 | .r emoveUnwan tedDomains (includeDo mains) | |
| 256 | .f ormatRespo nse() | |
| 257 | .v alue(); | |
| 258 | }; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.