Produced by Araxis Merge on 10/4/2017 8:04:33 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\fhir\condition | condition-list-resource.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\fhir\condition | condition-list-resource.js | Tue Oct 3 18:01:45 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 18 | 824 |
| Changed | 17 | 34 |
| 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 | var condit ion = requ ire('../co mmon/entit ies/condit ion-object s'); | |
| 3 | var errors = require ('../commo n/errors') ; | |
| 4 | var domain s = requir e('../comm on/domain- map'); | |
| 5 | var fhirRe source = r equire('.. /common/en tities/fhi r-resource '); | |
| 6 | var rdk = require('. ./../core/ rdk'); | |
| 7 | var fhirTo JDSSearch = require( '../common /utils/fhi r-to-jds-s earch'); | |
| 8 | var _ = re quire('lod ash'); | |
| 9 | var nullch ecker = rd k.utils.nu llchecker; | |
| 10 | var confor manceUtils = require ('../confo rmance/con formance-u tils'); | |
| 11 | var confor mance = re quire('../ conformanc e/conforma nce-resour ce'); | |
| 12 | ||
| 13 | var fhirTo JDSAttrMap = [{ | |
| 14 | fhirNa me: 'subje ct.identif ier', | |
| 15 | vprNam e: 'pid', | |
| 16 | dataTy pe: 'strin g', | |
| 17 | defini tion: 'htt p://hl7.or g/FHIR/201 5May/datat ypes.html# string', | |
| 18 | descri ption: 'Pa tient inde ntifier - note that this patie nt identif ier will o verrule an y patient identifier that is i n the URI of this en dpoint.', | |
| 19 | search able: true | |
| 20 | },{ | |
| 21 | fhirNa me: 'pid', | |
| 22 | vprNam e: 'pid', | |
| 23 | dataTy pe: 'strin g', | |
| 24 | defini tion: 'htt p://hl7.or g/FHIR/201 5May/datat ypes.html# string', | |
| 25 | descri ption: 'Pa tient inde ntifier - note that this patie nt identif ier will o verrule an y patient identifier that has been speci fied in th e URI of t his endpoi nt as well as the su bject.iden tifier on the query string.', | |
| 26 | search able: true | |
| 27 | },{ | |
| 28 | fhirNa me: 'date- asserted', | |
| 29 | vprNam e: 'entere d', | |
| 30 | dataTy pe: 'dateT ime', | |
| 31 | defini tion: 'htt p://hl7.or g/fhir/201 5MAY/datat ypes.html# dateTime', | |
| 32 | descri ption: 'da te-asserte d date/tim e. The pre fixes >, > =, <=, < a nd != may be used on the param eter value (e.g. dat e-asserted =>2015-01- 15). The f ollowing d ate format s are perm itted: yyy y-mm-ddThh :mm:ss (ex act date s earch), yy yy-mm-dd ( within giv en day), y yyy-mm (wi thin given month), y yyy (withi n given ye ar). A sin gle date p arameter c an be used for an ex act date s earch (e.g . date-ass erted=2015 -01-26T08: 30:00) or an implici t range (e .g. date-a sserted=20 15-01, sea rches all dates in J anuary 201 5). Two da te paramet ers can be used to s pecify an explicitly bounded r ange. When using a p air of dat e paramete rs, the pa rameters s hould bind both ends of the ra nge. One s hould have a less-th an operato r (<, <=) while the other a gr eater-than operator (>, >=).', | |
| 33 | search able: true | |
| 34 | },{ | |
| 35 | fhirNa me: 'onset ', | |
| 36 | vprNam e: 'onset' , | |
| 37 | dataTy pe: 'dateT ime', | |
| 38 | defini tion: 'htt p://hl7.or g/fhir/201 5MAY/datat ypes.html# dateTime', | |
| 39 | descri ption: 'on set date/t ime. The p refixes >, >=, <=, < and != ma y be used on the par ameter val ue (e.g. o nset=>2015 -01-15). T he followi ng date fo rmats are permitted: yyyy-mm-d dThh:mm:ss (exact da te search) , yyyy-mm- dd (within given day ), yyyy-mm (within g iven month ), yyyy (w ithin give n year). A single da te paramet er can be used for a n exact da te search (e.g. onse t=2015-01- 26T08:30:0 0) or an i mplicit ra nge (e.g. onset=2015 -01, searc hes all da tes in Jan uary 2015) . Two date parameter s can be u sed to spe cify an ex plicitly b ounded ran ge. When u sing a pai r of date parameters , the para meters sho uld bind b oth ends o f the rang e. One sho uld have a less-than operator (<, <=) wh ile the ot her a grea ter-than o perator (> , >=).', | |
| 40 | search able: true | |
| 41 | },{ | |
| 42 | fhirNa me: '_sort ', | |
| 43 | vprNam e: '', | |
| 44 | dataTy pe: 'strin g', | |
| 45 | defini tion: 'htt p://hl7.or g/FHIR/201 5May/datat ypes.html# string', | |
| 46 | descri ption: 'So rt criteri a. Ascendi ng order b y default, order is specified with the f ollowing v ariants: _sort:asc (ascending ), _sort:d esc (desce nding). Su pported so rt propert ies: asser ter, code, date-asse rted, onse t, patient .', | |
| 47 | search able: true | |
| 48 | }]; | |
| 49 | conformanc eUtils.add CountAttri bute(fhirT oJDSAttrMa p); //addi ng the _co unt attrib ute that i s common t o (almost) all endpo ints. | |
| 50 | ||
| 51 | // Issue c all to Con formance r egistratio n | |
| 52 | conformanc e.register (conforman ceUtils.do mains.COND ITION, cre ateConditi onConforma nceData()) ; | |
| 53 | ||
| 54 | function c reateCondi tionConfor manceData( ) { | |
| 55 | var res ourceType = conforma nceUtils.d omains.CON DITION; | |
| 56 | var pro fileRefere nce = 'htt p://hl7.or g/fhir/201 5MAY/condi tion.html' ; | |
| 57 | var int eractions = [ 'read' , 'search- type' ]; | |
| 58 | ||
| 59 | return conformanc eUtils.cre ateConform anceData(r esourceTyp e, profile Reference, | |
| 60 | interacti ons, fhirT oJDSAttrMa p); | |
| 61 | } | |
| 62 | ||
| 63 | //http:// IP /vpr/all/f ind/proble m?filter=l ike(%22pro blemText%2 2,%22%25%2 2) | |
| 64 | //get all problems i n the syst em | |
| 65 | ||
| 66 | //http:// IP /vpr/ R E D A CTED ;20/find/p roblem | |
| 67 | //get all problems f or a speci fic pid | |
| 68 | ||
| 69 | function g etResource Config() { | |
| 70 | return [{ | |
| 71 | na me: 'fhir- condition' , | |
| 72 | pa th: '', | |
| 73 | ge t: getProb lems, | |
| 74 | su bsystems: ['patientr ecord', 'j ds', 'solr ', 'author ization'], | |
| 75 | in terceptors : { fhirPi d: true }, | |
| 76 | pe rmitRespon seFormat: true, | |
| 77 | re quiredPerm issions: [ 'read-fhir '], | |
| 78 | is PatientCen tric: true | |
| 79 | },{ | |
| 80 | na me: 'fhir- condition- search', | |
| 81 | pa th: '_sear ch', | |
| 82 | po st: getPro blems, | |
| 83 | su bsystems: ['patientr ecord', 'j ds', 'solr ', 'author ization'], | |
| 84 | in terceptors : { fhirPi d: true }, | |
| 85 | pe rmitRespon seFormat: true, | |
| 86 | re quiredPerm issions: [ 'read-fhir '], | |
| 87 | is PatientCen tric: true | |
| 88 | }]; | |
| 89 | } | |
| 90 | ||
| 91 | var fhirTo JDSMap = { | |
| 92 | assert er: 'provi derDisplay Name', | |
| 93 | // (NO T MAPPED) category | |
| 94 | // (NO T MAPPED) clinicalst atus | |
| 95 | 'code' : 'icdCode ', | |
| 96 | 'date- asserted': 'entered' , | |
| 97 | // (NO T MAPPED) dueto-code | |
| 98 | // (NO T MAPPED) dueto-item | |
| 99 | // (NO T MAPPED) encounter | |
| 100 | // (NO T MAPPED) evidence | |
| 101 | // (NO T MAPPED) following- code | |
| 102 | // (NO T MAPPED) following- item | |
| 103 | // (NO T MAPPED) location | |
| 104 | onset: 'onset', | |
| 105 | // (NO T MAPPED) onset-info | |
| 106 | patien t: 'pid', | |
| 107 | // (NO T MAPPED) severity | |
| 108 | // (NO T MAPPED) stage | |
| 109 | // (NO T MAPPED) subject | |
| 110 | }; | |
| 111 | ||
| 112 | function b uildJDSPat h(pid, par ams) { | |
| 113 | var jd sPath = '/ vpr/' + pi d + '/inde x/' + doma ins.jds('p roblem'); | |
| 114 | var qu ery = []; | |
| 115 | var se archQuery = buildSea rchQuery(p arams); | |
| 116 | ||
| 117 | // sea rch querie s | |
| 118 | if (nu llchecker. isNotNulli sh(searchQ uery)) { | |
| 119 | qu ery.push(s earchQuery ); | |
| 120 | } | |
| 121 | // com mon parame ters | |
| 122 | query = query.co ncat(fhirT oJDSSearch .buildComm onQueryPar ams(params , fhirToJD SMap)); | |
| 123 | ||
| 124 | // add filter qu eries to p ath | |
| 125 | if (qu ery.length > 0) { | |
| 126 | jd sPath += ' ?' + query .join('&') ; | |
| 127 | } | |
| 128 | ||
| 129 | return jdsPath; | |
| 130 | } | |
| 131 | ||
| 132 | function b uildSearch Query(para ms) { | |
| 133 | ||
| 134 | var qu ery = []; | |
| 135 | var da teAsserted Query, | |
| 136 | on setDateTim eQuery; | |
| 137 | ||
| 138 | /* uid was searc hable at o ne time, b ut is not indicated as such in the FHIR spec */ | |
| 139 | /* for more info ration: ht tp://www.h l7.org/FHI R/2015May/ condition. html#4.3.4 */ | |
| 140 | ||
| 141 | // NOT E: uid sh ould be ma pped to an identifie r as per t he mapping docs, but is curren tly not. | |
| 142 | ||
| 143 | //if ( nullchecke r.isNotNul lish(param s.uid)) { | |
| 144 | // uidQuery = 'like("ui d","' + pa rams.uid + '")'; | |
| 145 | // if (uidQue ry) { | |
| 146 | // query. push(uidQu ery); | |
| 147 | // } | |
| 148 | //} | |
| 149 | ||
| 150 | // dat es | |
| 151 | if (nu llchecker. isNotNulli sh(params. onset)) { | |
| 152 | on setDateTim eQuery = f hirToJDSSe arch.build DateQuery( params.ons et, 'onset ', true /* ignoreTime */ ); | |
| 153 | if (onsetDat eTimeQuery ) { | |
| 154 | query.pu sh(onsetDa teTimeQuer y); | |
| 155 | } | |
| 156 | } | |
| 157 | if (nu llchecker. isNotNulli sh(params[ 'date-asse rted'])) { //the hyp hen in the name prev ents us fr om using o ur normal convention s to acces s it. | |
| 158 | da teAsserted Query = fh irToJDSSea rch.buildD ateQuery(p arams['dat e-asserted '], 'enter ed', true /*ignoreTi me*/ ); | |
| 159 | if (dateAsse rtedQuery) { | |
| 160 | query.pu sh(dateAss ertedQuery ); | |
| 161 | } | |
| 162 | } | |
| 163 | ||
| 164 | return fhirToJDS Search.bui ldSearchQu eryString( query); | |
| 165 | } | |
| 166 | ||
| 167 | /** | |
| 168 | * @api {g et} /fhir/ patient/{i d}/conditi on Get Con dition | |
| 169 | * @apiNam e getProbl ems | |
| 170 | * @apiGro up Conditi on | |
| 171 | * @apiPar am {String } id The p atient id | |
| 172 | * @apiPar am {Number } [_count] The numbe r of resul ts to show . | |
| 173 | * @apiPar am {String } [date-as serted] da te-asserte d date/tim e. The pre fixes >, > =, <=, < a nd != may be used on the param eter value (e.g. dat e-asserted =>2015-01- 15). The f ollowing d ate format s are perm itted: yyy y-mm-ddThh :mm:ss (ex act date s earch), yy yy-mm-dd ( within giv en day), y yyy-mm (wi thin given month), y yyy (withi n given ye ar). A sin gle date p arameter c an be used for an ex act date s earch (e.g . date-ass erted=2015 -01-26T08: 30:00) or an implici t range (e .g. date-a sserted=20 15-01, sea rches all dates in J anuary 201 5). Two da te paramet ers can be used to s pecify an explicitly bounded r ange. When using a p air of dat e paramete rs, the pa rameters s hould bind both ends of the ra nge. One s hould have a less-th an operato r (<, <=) while the other a gr eater-than operator (>, >=). C onsult the <a href=" http://www .hl7.org/F HIR/2015Ma y/search.h tml#date"> FHIR DSTU2 API</a> d ocumentati on for mor e informat ion. | |
| 174 | * @apiPar am {String } [onset] onset date /time. The prefixes >, >=, <=, < and != may be use d on the p arameter v alue (e.g. onset=>20 15-01-15). The follo wing date formats ar e permitte d: yyyy-mm -ddThh:mm: ss (exact date searc h), yyyy-m m-dd (with in given d ay), yyyy- mm (within given mon th), yyyy (within gi ven year). A single date param eter can b e used for an exact date searc h (e.g. on set=2015-0 1-26T08:30 :00) or an implicit range (e.g . onset=20 15-01, sea rches all dates in J anuary 201 5). Two da te paramet ers can be used to s pecify an explicitly bounded r ange. When using a p air of dat e paramete rs, the pa rameters s hould bind both ends of the ra nge. One s hould have a less-th an operato r (<, <=) while the other a gr eater-than operator (>, >=). C onsult the <a href=" http://www .hl7.org/F HIR/2015Ma y/search.h tml#date"> FHIR DSTU2 API</a> d ocumentati on for mor e informat ion. | |
| 175 | * @apiPar am {String } [_sort] Sort crite ria. Ascen ding order by defaul t, order i s specifie d with the following variants: _sort:as c (ascendi ng), _sort :desc (des cending). Supported sort prope rties: ass erter, cod e, date-as serted, on set, patie nt. | |
| 176 | * | |
| 177 | * @apiDes cription C onverts a vpr \'prob lem\' reso urce into a FHIR \'c ondition\' resource. | |
| 178 | * @apiExa mple {js} Request Ex amples: | |
| 179 | * // Limiting results co unt | |
| 180 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?_cou nt=1 | |
| 181 | * | |
| 182 | * // Condition s on a yea r | |
| 183 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?onse t=2000 | |
| 184 | * | |
| 185 | * // Condition s in a yea r and mont h | |
| 186 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?onse t=2005-04 | |
| 187 | * | |
| 188 | * // Condition s in a yea r, month, and day | |
| 189 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?onse t=2000-02- 21 | |
| 190 | * | |
| 191 | * // Condition s outside of a date range | |
| 192 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?onse t=!=2000-0 2 | |
| 193 | * | |
| 194 | * // Condition s within a n explicit date rang e | |
| 195 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?onse t=>=2010-0 6&onset=<= 2014-09-20 | |
| 196 | * | |
| 197 | * // Condition s sorted b y code | |
| 198 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?_sor t=code | |
| 199 | * | |
| 200 | * // Condition s sorted b y asserter | |
| 201 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?_sor t=asserter | |
| 202 | * | |
| 203 | * // Condition s sorted b y date-ass erted | |
| 204 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?_sor t=date-ass erted | |
| 205 | * | |
| 206 | * // Condition s sorted b y onset | |
| 207 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?_sor t=onset | |
| 208 | * | |
| 209 | * // Condition s sorted b y patient (pid) | |
| 210 | * http:// IP /resource/ fhir/patie nt/10110V0 04877/cond ition?_sor t=patient | |
| 211 | * | |
| 212 | * | |
| 213 | * @apiSuc cess {json } data Jso n object c onforming to the <a href="http ://www.hl7 .org/FHIR/ 2015May/co ndition.ht ml">Condit ion FHIR D TSU2 speci fication</ a>. | |
| 214 | * @apiSuc cessExampl e Success- Response: | |
| 215 | * HTTP/1. 1 200 OK | |
| 216 | * { | |
| 217 | * "resou rceType": "Bundle", | |
| 218 | * "type" : "collect ion", | |
| 219 | * "id": "16b7493b- 0a69-4a16- b72a-22c98 73de33d", | |
| 220 | * "link" : [ | |
| 221 | * { | |
| 222 | * "relatio n": "self" , | |
| 223 | * "url": " http://loc alhost:888 8/resource /fhir/pati ent/10110V 004877/con dition?_co unt=1" | |
| 224 | * } | |
| 225 | * ], | |
| 226 | * "total ": 32, | |
| 227 | * "entry ": [{ | |
| 228 | * "r esource": { | |
| 229 | * "resourc eType": "C ondition", | |
| 230 | * "categor y": { | |
| 231 | * "cod ing": [{ | |
| 232 | * "code": "d iagnosis", | |
| 233 | * "system": "2.16.840. 1.113883.4 .642.2.224 " | |
| 234 | * }] | |
| 235 | * }, | |
| 236 | * "stage": { | |
| 237 | * "sum mary": "Di abetes Mel litus Type II or uns pecified ( ICD-9-CM 2 50.00)" | |
| 238 | * }, | |
| 239 | * "patient ": { | |
| 240 | * "reference ": " R E D A CTED ;8" | |
| 241 | * }, | |
| 242 | * "code": { | |
| 243 | * "cod ing": [{ | |
| 244 | * "system": "urn:oid:2 .16.840.1. 113883.6.2 33", | |
| 245 | * "code": "u rn:icd:250 .00", | |
| 246 | * "display": "DIABETES MELLI W/O COMP TYP II" | |
| 247 | * }] | |
| 248 | * }, | |
| 249 | * "asserte r": { | |
| 250 | * "ref erence": " #71a470ef- 0f93-4377- 80ac-54c4f 3ec914c", | |
| 251 | * "dis play": "VE HU,TEN" | |
| 252 | * }, | |
| 253 | * "dateAss erted": "2 000-05-08" , | |
| 254 | * "onsetDa teTime": " 2000-02-21 ", | |
| 255 | * "contain ed": [{ | |
| 256 | * "res ourceType" : "Encount er", | |
| 257 | * "tex t": { | |
| 258 | * "status": "generated ", | |
| 259 | * "div": "<d iv>Encount er with pa tient R E D A CTED ;8</div>" | |
| 260 | * }, | |
| 261 | * "loc ation": [{ | |
| 262 | * "resourceT ype": "Loc ation", | |
| 263 | * "_id": "ur n:va:locat ion: R E D A CTED :32" | |
| 264 | * }] | |
| 265 | * }, | |
| 266 | * { | |
| 267 | * "res ourceType" : "Practit ioner", | |
| 268 | * "_id ": "71a470 ef-0f93-43 77-80ac-54 c4f3ec914c ", | |
| 269 | * "nam e": "VEHU, TEN", | |
| 270 | * "ide ntifier": { | |
| 271 | * "value": " urn:va:use r: R E D A CTED :20012", | |
| 272 | * "system": "urn:oid:2 .16.840.1. 113883.6.2 33" | |
| 273 | * } | |
| 274 | * }], | |
| 275 | * "clinica lStatus": "confirmed ", | |
| 276 | * "extensi on": [{ | |
| 277 | * "url ": "http:/ /vistacore .us/fhir/e xtensions/ condition# serviceCon nected", | |
| 278 | * "val ueBoolean" : false | |
| 279 | * }, | |
| 280 | * { | |
| 281 | * "url ": "http:/ /vistacore .us/fhir/e xtensions/ condition# statusCode ", | |
| 282 | * "val ueString": "urn:sct: 55561003" | |
| 283 | * }, | |
| 284 | * { | |
| 285 | * "url ": "http:/ /vistacore .us/fhir/e xtensions/ condition# statusDisp layName", | |
| 286 | * "val ueString": "Active" | |
| 287 | * }, | |
| 288 | * { | |
| 289 | * "url ": "http:/ /vistacore .us/fhir/e xtensions/ condition# statusName ", | |
| 290 | * "val ueString": "ACTIVE" | |
| 291 | * }, | |
| 292 | * { | |
| 293 | * "url ": "http:/ /vistacore .us/fhir/e xtensions/ condition# updated", | |
| 294 | * "val ueDateTime ": "2004-0 3-31" | |
| 295 | * }] | |
| 296 | * } | |
| 297 | * }] | |
| 298 | * } | |
| 299 | * @apiErr or (Error 400) Inval id paramet ers. | |
| 300 | * @apiErr orExample Error-Resp onse: | |
| 301 | * HTTP/1. 1 400 Bad Request | |
| 302 | * { | |
| 303 | * In valid para meters: | |
| 304 | * Un supported _sort crit eria. Supp orted attr ibutes are : date-ass erted, ons et, patien t and asse rter | |
| 305 | * } | |
| 306 | */ | |
| 307 | function g etProblems (req, res) { | |
| 308 | var pi d = req.qu ery.pid; | |
| 309 | var pa rams = req .query; | |
| 310 | ||
| 311 | if (nu llchecker. isNullish( pid)) { | |
| 312 | re turn res.s tatus(rdk. httpstatus .bad_forma t).send('M issing req uired para meter: pid '); | |
| 313 | } | |
| 314 | ||
| 315 | valida teParams(p arams, /*o nSuccess*/ function( ) { | |
| 316 | ge tProblemsD ata(req.ap p.config, req.logger , pid, par ams, funct ion(err, i nputJSON) { | |
| 317 | if (null checker.is NotNullish (err)) { | |
| 318 | res. status(err .code || 5 00).send(e rr.message ); | |
| 319 | } else { | |
| 320 | var fhirBundle = convert ToFhir(inp utJSON, re q); | |
| 321 | res. status(rdk .httpstatu s.ok).send (fhirBundl e); | |
| 322 | } | |
| 323 | }) ; | |
| 324 | }, /*o nError*/ f unction(er rors) { | |
| 325 | re turn res.s tatus(rdk. httpstatus .bad_reque st).send(' Invalid pa rameters:' + fhirToJ DSSearch.v alidationE rrorsToStr ing(errors )); | |
| 326 | }); | |
| 327 | } | |
| 328 | ||
| 329 | function g etProblems Data(appCo nfig, logg er, pid, p arams, cal lback) { | |
| 330 | // che ck for req uired pid param | |
| 331 | if (nu llchecker. isNullish( pid)) { | |
| 332 | re turn callb ack(new Er ror('Missi ng require d paramete r: pid')); | |
| 333 | } | |
| 334 | ||
| 335 | var jd sPath = bu ildJDSPath (pid, para ms); | |
| 336 | var op tions = _. extend({}, appConfig .jdsServer , { | |
| 337 | ur l: jdsPath , | |
| 338 | lo gger: logg er, | |
| 339 | js on: true | |
| 340 | }); | |
| 341 | ||
| 342 | rdk.ut ils.http.g et(options , function (error, re sponse, bo dy) { | |
| 343 | va r internal Error = 'T here was a n error pr ocessing y our reques t. The err or has bee n logged.' ; | |
| 344 | lo gger.debug ('callback from fetc h()'); | |
| 345 | ||
| 346 | if (error) { | |
| 347 | callback (new error s.HTTPErro r(rdk.http status.int ernal_serv er_error, 'Error fet ching pid= ' + pid + ' - ' + (e rror.messa ge || erro r))); | |
| 348 | } else { | |
| 349 | if ('dat a' in body ) { | |
| 350 | retu rn callbac k(null, bo dy); | |
| 351 | } else i f ('error' in body) { | |
| 352 | logg er.error(' condition- list-resou rce::getPr oblemsData : ' + body .error.cod e + ' - ' + getJDSEr rorMessage (body.erro r)); | |
| 353 | retu rn callbac k(new erro rs.HTTPErr or(rdk.htt pstatus.in ternal_ser ver_error, internalE rror)); | |
| 354 | } | |
| 355 | logger.e rror('cond ition-list -resource: :getProble msData: Em pty respon se from JD S.'); | |
| 356 | return c allback(ne w errors.H TTPError(r dk.httpsta tus.intern al_server_ error, int ernalError )); | |
| 357 | } | |
| 358 | }); | |
| 359 | } | |
| 360 | ||
| 361 | function v alidatePar ams(params , onSucces s, onError ) { | |
| 362 | // che ck common parameters | |
| 363 | fhirTo JDSSearch. validateCo mmonParams (params, f unction() { | |
| 364 | // validate date | |
| 365 | fh irToJDSSea rch.valida teDatePara ms(params, ['date-as serted', ' onset'], f unction() { | |
| 366 | if (isSo rtCriteria Valid(para ms)) { | |
| 367 | onSu ccess(); | |
| 368 | } else { | |
| 369 | onEr ror(['Unsu pported _s ort criter ia. Suppor ted attrib utes are: asserter, code, date -asserted, onset, an d patient' ]); | |
| 370 | } | |
| 371 | }, onError); | |
| 372 | }, onE rror); | |
| 373 | } | |
| 374 | ||
| 375 | function c onvertToFh ir(inputJS ON, req) { | |
| 376 | var re sults = [] , | |
| 377 | it ems = inpu tJSON.data .items, | |
| 378 | to tal = inpu tJSON.data .totalItem s; | |
| 379 | ||
| 380 | _.forE ach(items, function( item, inde x) { | |
| 381 | i tem.fhirMe ta = { | |
| 382 | _pid: re q._pid, | |
| 383 | _origina lUrl: req. originalUr l, | |
| 384 | _host: r eq.headers .host, | |
| 385 | _protoco l: req.pro tocol | |
| 386 | }; | |
| 387 | re sults.push (condition .condition Factory('C onditionIt em', item) ); | |
| 388 | }); | |
| 389 | return buildBund le(results , req, tot al); | |
| 390 | } | |
| 391 | ||
| 392 | function b uildBundle (results, req, total ) { | |
| 393 | var b = new fhir Resource.B undle(); | |
| 394 | if (re q) { | |
| 395 | b. link.push( new fhirRe source.Lin k(req.prot ocol + ':/ /' + req.h eaders.hos t + req.or iginalUrl, 'self')); | |
| 396 | } | |
| 397 | b.tota l = total; | |
| 398 | _.forE ach(result s, functio n(result, index) { | |
| 399 | if (nullchec ker.isNotN ullish(res ult)) { | |
| 400 | var e = new fhirRe source.Ent ry(result) ; | |
| 401 | b.entry. push(e); | |
| 402 | } | |
| 403 | }); | |
| 404 | return b; | |
| 405 | } | |
| 406 | ||
| 407 | function i sSortCrite riaValid(p arams) { | |
| 408 | return fhirToJDS Search.isS ortCriteri aValid(par ams, fhirT oJDSMap); | |
| 409 | } | |
| 410 | ||
| 411 | function g etJDSError Message(er ror) { | |
| 412 | var ms g = ''; | |
| 413 | ||
| 414 | if (nu llchecker. isNotNulli sh(error.e rrors)) { | |
| 415 | ms g = _.redu ce(error.e rrors, fun ction(memo , e) { | |
| 416 | if (memo && memo.l ength > 0) { | |
| 417 | memo += ', '; | |
| 418 | } | |
| 419 | memo += e.domain + ' :: ' + e.message; | |
| 420 | return m emo; | |
| 421 | }, ''); | |
| 422 | } | |
| 423 | return msg; | |
| 424 | } | |
| 425 | ||
| 426 | module.exp orts.conve rtToFhir = convertTo Fhir; | |
| 427 | module.exp orts.getRe sourceConf ig = getRe sourceConf ig; | |
| 428 | module.exp orts.isSor tCriteriaV alid = isS ortCriteri aValid; | |
| 429 | module.exp orts.creat eCondition Conformanc eData = cr eateCondit ionConform anceData; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.