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\observation | observation-resource.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\fhir\observation | observation-resource.js | Tue Oct 3 18:03:26 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 18 | 816 |
| 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 | //Code was commented out, not removed, f or possibl e reuse at a later d ate if hea lth factor s, aka soc ial-histor y, are syn cd. | |
| 3 | var rdk = require('. ./../core/ rdk'); | |
| 4 | var _ = re quire('lod ash'); | |
| 5 | var async = require( 'async'); | |
| 6 | var nullch ecker = rd k.utils.nu llchecker; | |
| 7 | var fhirUt ils = requ ire('../co mmon/utils /fhir-conv erter'); | |
| 8 | var vitals = require ('./vitals /vitals-re source'); | |
| 9 | ////No-Hea lth-Factor s ++ | |
| 10 | //var heal thFactors = require( './health- factors/he alth-facto rs'); | |
| 11 | ////No-Hea lth-Factor s -- | |
| 12 | var fhirTo JDSSearch = require( '../common /utils/fhi r-to-jds-s earch'); | |
| 13 | var fhirRe source = r equire('.. /common/en tities/fhi r-resource '); | |
| 14 | var observ ationUtils = require ('./observ ation-util s'); | |
| 15 | var confUt ils = requ ire('../co nformance/ conformanc e-utils'); | |
| 16 | var confor mance = re quire('../ conformanc e/conforma nce-resour ce'); | |
| 17 | ||
| 18 | var fhirTo JDSAttrMap = [{ | |
| 19 | fhirNa me: 'date' , | |
| 20 | vprNam e: '', // this does not map co nventional ly - it's 'observed' in vitals , and 'ent ered' in h ealth fact ors | |
| 21 | dataTy pe: 'dateT ime', | |
| 22 | defini tion: 'htt p://www.hl 7.org/FHIR /2015May/d atatypes.h tml#dateTi me', | |
| 23 | descri ption: 'Ob tained dat e/time. Th e prefixes >, >=, <= , < and != may be us ed on the parameter value (e.g . date=>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. da te=2015-01 -26T08:30: 00) or an implicit r ange (e.g. date=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 (> , >=). ', | |
| 24 | search able: true | |
| 25 | },{ | |
| 26 | fhirNa me: 'code' , | |
| 27 | vprNam e: 'name', | |
| 28 | dataTy pe: 'strin g', | |
| 29 | defini tion: 'htt p://www.hl 7.org/FHIR /2015May/d atatypes.h tml#string ', | |
| 30 | descri ption: 'Wh at action is being o rdered - a tokenized value con taining a single fie ld, or 2 p ipe separa ted fields called \' system\' a nd \'code\ '. The sy stem field (left sid e of pipe) and pipe is optiona l and may be omitted . If the s ystem fiel d is empty and the p ipe is inc luded, it is implied that the field shou ld not exi st in the results. Multiple c odes can b e specifie d, by join ing with a comma, wh ich signif ies an OR clause. ( Valid exam ples: [cod e=8310-5] [code=http ://loinc.o rg|8310-5] [code=927 9-1,8310-5 ] [code=ht tp://loinc .org|9279- 1,8310-5] [code=http ://loinc.o rg|9279-1, http://loi nc.org|831 0-5] [code =|8310-5] [code=8310 -5,|9279-1 ])', | |
| 31 | search able: true | |
| 32 | },{ | |
| 33 | //this is effect ively a se archable a ttribute, and is add ed here fo r conforma nce. | |
| 34 | fhirNa me: '_tag' , | |
| 35 | vprNam e: '', | |
| 36 | dataTy pe: 'strin g', | |
| 37 | defini tion: 'htt p://www.hl 7.org/FHIR /2015May/d atatypes.h tml#string ', | |
| 38 | descri ption: 'To specify a specific subset, us e either v ital-signs or social -history. (social-hi story is c urrently n ot impleme nted.)' , | |
| 39 | search able: true | |
| 40 | },{ | |
| 41 | fhirNa me: '_sort ', | |
| 42 | vprNam e: '', | |
| 43 | dataTy pe: 'strin g', | |
| 44 | defini tion: 'htt p://hl7.or g/FHIR/201 5May/datat ypes.html# string', | |
| 45 | 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: date, identifie r, patient , performe r, subject , value-qu antity.', | |
| 46 | search able: true | |
| 47 | }]; | |
| 48 | confUtils. addCountAt tribute(fh irToJDSAtt rMap); //a dding the _count att ribute tha t is commo n to (almo st) all en dpoints. | |
| 49 | ||
| 50 | // Issue c all to Con formance r egistratio n | |
| 51 | conformanc e.register (confUtils .domains.O BSERVATION , createOb servationC onformance Data()); | |
| 52 | ||
| 53 | function c reateObser vationConf ormanceDat a() { | |
| 54 | var res ourceType = confUtil s.domains. OBSERVATIO N; | |
| 55 | var pro fileRefere nce = 'htt p://www.hl 7.org/FHIR /2015May/o bservation .html'; | |
| 56 | var int eractions = [ 'read' , 'search- type' ]; | |
| 57 | ||
| 58 | return confUtils. createConf ormanceDat a(resource Type, prof ileReferen ce, | |
| 59 | interacti ons, fhirT oJDSAttrMa p); | |
| 60 | } | |
| 61 | ||
| 62 | var TAGS = { | |
| 63 | VITALS : 'vital-s igns', | |
| 64 | HEALTH _FACTORS: 'social-hi story' | |
| 65 | }; | |
| 66 | ||
| 67 | function g etResource Config() { | |
| 68 | return [{ | |
| 69 | na me: 'fhir- vitals-obs ervation', | |
| 70 | pa th: '', | |
| 71 | ge t: getObse rvation, | |
| 72 | su bsystems: ['patientr ecord', 'j ds', 'solr ', 'jdsSyn c', 'autho rization'] , | |
| 73 | in terceptors : { fhirPi d: true }, | |
| 74 | re quiredPerm issions: [ 'read-fhir '], | |
| 75 | is PatientCen tric: true , | |
| 76 | pe rmitRespon seFormat: true | |
| 77 | },{ | |
| 78 | na me: 'fhir- vitals-obs ervation-s earch', | |
| 79 | pa th: '_sear ch', | |
| 80 | po st: getObs ervation, | |
| 81 | su bsystems: ['patientr ecord', 'j ds', 'solr ', 'jdsSyn c', 'autho rization'] , | |
| 82 | in terceptors : { fhirPi d: true }, | |
| 83 | re quiredPerm issions: [ 'read-fhir '], | |
| 84 | is PatientCen tric: true , | |
| 85 | pe rmitRespon seFormat: true | |
| 86 | }]; | |
| 87 | } | |
| 88 | ||
| 89 | function l imitFHIRRe sultByCoun t(fhirBund le, countS tr) { | |
| 90 | if (nu llchecker. isNotNulli sh(countSt r)) { | |
| 91 | va r count = parseInt(c ountStr); | |
| 92 | fh irBundle.e ntry = _.t ake(fhirBu ndle.entry , count); | |
| 93 | } | |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * @api {g et} /fhir/ patient/{i d}/observa tion Get O bservation | |
| 98 | * @apiNam e getObser vation | |
| 99 | * @apiGro up Observa tion | |
| 100 | * @apiPar am {String } id The p atient id | |
| 101 | * @apiPar am {Number } [_count] The numbe r of resul ts to show . | |
| 102 | * @apiPar am {String } [code] a tokenized value con taining a single fie ld, or 2 p ipe separa ted fields called 's ystem' and 'code'. The system field (le ft side of pipe) and pipe is o ptional an d may be o mitted. If the syste m field is empty and the pipe is include d, it is i mplied tha t the fiel d should n ot exist i n the resu lts. Mult iple codes can be sp ecified, b y joining with a com ma, which signifies an OR clau se. (Vali d examples : [code=83 10-5] [cod e=http://l oinc.org|8 310-5] [co de=9279-1, 8310-5] [c ode=http:/ /loinc.org |9279-1,83 10-5] [cod e=http://l oinc.org|9 279-1,http ://loinc.o rg|8310-5] [code=|83 10-5] [cod e=8310-5,| 9279-1] @s ee http:// www.hl7.or g/FHIR/201 5May/searc h.html#tok en | |
| 103 | * @apiPar am {String } [date] O btained da te/time. T he prefixe s >, >=, < =, < and ! = may be u sed on the parameter value (e. g. date=>2 015-01-15) . The foll owing date formats a re permitt ed: yyyy-m m-ddThh:mm :ss (exact date sear ch), yyyy- mm-dd (wit hin given day), yyyy -mm (withi n given mo nth), yyyy (within g iven year) . A single date para meter can be used fo r an exact date sear ch (e.g. d ate=2015-0 1-26T08:30 :00) or an implicit range (e.g . date=201 5-01, sear ches all d ates in Ja nuary 2015 ). Two dat e paramete rs can be used to sp ecify an e xplicitly bounded ra nge. When using a pa ir of date parameter s, the par ameters sh ould bind both ends of the ran ge. One sh ould have a less-tha n operator (<, <=) w hile the o ther a gre ater-than operator ( >, >=). Co nsult the <a href="h ttp://www. hl7.org/FH IR/2015May /search.ht ml#date">F HIR DSTU2 API</a> do cumentatio n for more informati on. | |
| 104 | * @apiPar am {String } [_tag] T o specify a specific subset, e ither vita l-signs | |
| 105 | * @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: dat e, identif ier, patie nt, perfor mer, subje ct, value- quantity. | |
| 106 | * @apiPar am {String } [_sort:d esc] Desce nding sort criteria. Order is specified with the f ollowing v ariants: _sort:asc (ascending ), _sort:d esc (desce nding). Su pported so rt propert ies: date, identifie r, patient , performe r, subject , value-qu antity. | |
| 107 | * @apiPar am {String } [_sort:a sc] Ascend ing sort c riteria. O rder is sp ecified wi th the fol lowing var iants: _s ort:asc (a scending), _sort:des c (descend ing). Supp orted sort propertie s: date, i dentifier, patient, performer, subject, value-quan tity. | |
| 108 | * | |
| 109 | * @apiDes cription C onverts a vpr \'vita ls\' resou rce into a FHIR \'ob servation\ ' resource . | |
| 110 | * | |
| 111 | * @apiExa mple {js} Request Ex amples: | |
| 112 | * // Limiting results co unt | |
| 113 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_co unt=1 | |
| 114 | * | |
| 115 | * // Exact dat e search | |
| 116 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=2015-01- 26T13:45:0 0 | |
| 117 | * | |
| 118 | * // Observati ons on a d ay | |
| 119 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=2015-01- 26 | |
| 120 | * | |
| 121 | * // Observati ons on a m onth | |
| 122 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=2015-01 | |
| 123 | * | |
| 124 | * // Observati ons on a y ear | |
| 125 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=2015 | |
| 126 | * | |
| 127 | * // Observati ons outsid e a date r ange (e.g. observati ons not oc curing on January 20 15) | |
| 128 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=!=2015-0 1 | |
| 129 | * | |
| 130 | * // Explicit date range | |
| 131 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=>=2014-0 6&date=<=2 014-09-20 | |
| 132 | * | |
| 133 | * // Observati ons of a p articular code | |
| 134 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?cod e=9279-1 | |
| 135 | * | |
| 136 | * // Observati ons of a p articular code and s ystem | |
| 137 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?cod e=http://l oinc.org|9 279-1 | |
| 138 | * | |
| 139 | * // Observati ons sorted by date ( sorts by O bservation .appliesDa teTime) | |
| 140 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_so rt=date | |
| 141 | * | |
| 142 | * // Observati ons sorted by identi fier (sort s by Obser vation.ide ntifier.va lue) | |
| 143 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_so rt=identif ier | |
| 144 | * | |
| 145 | * // Observati ons sorted by perfor mer (sorts by Observ ation.perf ormer.disp lay) | |
| 146 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_so rt=perform er | |
| 147 | * | |
| 148 | * // Observati ons sorted by subjec t (sorts b y Observat ion.subjec t.referenc e) | |
| 149 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_so rt=subject | |
| 150 | * | |
| 151 | * // Observati ons sorted by value- quantity ( sorts by O bservation .valueQuan tity.value ) | |
| 152 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_so rt=value-q uantity | |
| 153 | * | |
| 154 | * // Observati ons sorted by value- quantity i n descendi ng order | |
| 155 | * http:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?_so rt:desc=va lue-quanti ty | |
| 156 | * | |
| 157 | * @apiSuc cess {json } data Jso n object c onforming to the <a href="http ://www.hl7 .org/FHIR/ 2015May/ob servation. html">Obse rvation FH IR DTSU2 s pecificati on</a>. | |
| 158 | * @apiSuc cessExampl e Success- Response: | |
| 159 | * HTTP/1. 1 200 OK | |
| 160 | * { | |
| 161 | * "re sourceType ": "Bundle ", | |
| 162 | * "ty pe": "coll ection", | |
| 163 | * "id ": "urn:uu id:1e89fe8 a-339c-48e 3-ba5a-58e e064fb14b" , | |
| 164 | * "li nk": [ | |
| 165 | * { | |
| 166 | * "rel" : "self", | |
| 167 | * "href": "h ttp:// IP /resource/ fhir/patie nt/ R E D A CTED ;253/obser vation?dat e=%3E2015- 01-26T01:2 0:00Z&code =http://lo inc.org|83 10-5&_coun t=1" | |
| 168 | * } | |
| 169 | * ], | |
| 170 | * "me ta": { | |
| 171 | * "lastUpda ted": "201 5-06-18T14 :38:50.000 +08:00" | |
| 172 | * }, | |
| 173 | * "en try": [ | |
| 174 | * { | |
| 175 | * "reso urce": { | |
| 176 | * " resourceTy pe": "Obse rvation", | |
| 177 | * " text": { | |
| 178 | * "status ": "genera ted", | |
| 179 | * "div": "<div>TEMP ERATURE 98 .2 F</div> " | |
| 180 | * } , | |
| 181 | * " contained" : [ | |
| 182 | * { | |
| 183 | * "re sourceType ": "Organi zation", | |
| 184 | * "_i d": "481de 831-8896-4 331-ab52-c 9f7cdc7834 8", | |
| 185 | * "id entifier": [ | |
| 186 | * { | |
| 187 | * "syst em": "urn: oid:2.16.8 40.1.11388 3.6.233", | |
| 188 | * "valu e": "998" | |
| 189 | * } | |
| 190 | * ], | |
| 191 | * "na me": "ABIL ENE (CAA)" | |
| 192 | * } | |
| 193 | * ] , | |
| 194 | * " code": { | |
| 195 | * "coding ": [ | |
| 196 | * { | |
| 197 | * "system": "urn:oid: 2.16.840.1 .113883.6. 233", | |
| 198 | * "code": " urn:va:vui d:4500638" , | |
| 199 | * "display" : "TEMPERA TURE" | |
| 200 | * }, | |
| 201 | * { | |
| 202 | * "system": "http://l oinc.org", | |
| 203 | * "code": " 8310-5", | |
| 204 | * "display" : "BODY TE MPERATURE" | |
| 205 | * } | |
| 206 | * ] | |
| 207 | * } , | |
| 208 | * " valueQuant ity": { | |
| 209 | * "value" : 98.2, | |
| 210 | * "units" : "F" | |
| 211 | * } , | |
| 212 | * " appliesDat eTime": "2 015-02-24T 22:40:00+0 8:00", | |
| 213 | * " issued": " 2015-02-25 T15:23:27- 08:00", | |
| 214 | * " status": " final", | |
| 215 | * " reliabilit y": "unkno wn", | |
| 216 | * " identifier ": { | |
| 217 | * "use": "official" , | |
| 218 | * "system ": "http:/ /vistacore .us/fhir/i d/uid", | |
| 219 | * "value": " urn:va:vit al: R E D A CTED :253:28425 " | |
| 220 | * } , | |
| 221 | * " subject": { | |
| 222 | * "refere nce": "Pat ient/253" | |
| 223 | * } , | |
| 224 | * " performer" : [ | |
| 225 | * { | |
| 226 | * "re ference": "481de831- 8896-4331- ab52-c9f7c dc78348", | |
| 227 | * "di splay": "A BILENE (CA A)" | |
| 228 | * } | |
| 229 | * ] , | |
| 230 | * " referenceR ange": [ | |
| 231 | * { | |
| 232 | * "lo w": { | |
| 233 | * "value": 95, | |
| 234 | * "units": "F" | |
| 235 | * }, | |
| 236 | * "hi gh": { | |
| 237 | * "value": 102, | |
| 238 | * "units": "F" | |
| 239 | * }, | |
| 240 | * "me aning": { | |
| 241 | * "coding": [ | |
| 242 | * { | |
| 243 | * " system": " http://sno med.info/i d", | |
| 244 | * " code": "87 273009", | |
| 245 | * " display": "Normal Te mperature" | |
| 246 | * } | |
| 247 | * ] | |
| 248 | * } | |
| 249 | * } | |
| 250 | * ] | |
| 251 | * } | |
| 252 | * } | |
| 253 | * ], | |
| 254 | * "to tal": 2 | |
| 255 | * } | |
| 256 | * | |
| 257 | * @apiErr or (Error 400) Inval id paramet er values. | |
| 258 | * @apiErr orExample Error-Resp onse: | |
| 259 | * HTTP/1. 1 400 Bad Request | |
| 260 | * { | |
| 261 | * In valid para meter valu es. | |
| 262 | * } | |
| 263 | */ | |
| 264 | function g etObservat ion(req, r es) { | |
| 265 | var pi d = req.qu ery.pid; | |
| 266 | var pa rams = req .query; | |
| 267 | ||
| 268 | if (nu llchecker. isNullish( pid)) { | |
| 269 | re turn res.s tatus(rdk. httpstatus .bad_forma t).send('M issing req uired para meter: pid '); | |
| 270 | } | |
| 271 | ||
| 272 | valida teParams(p arams, /*o nSuccess*/ function( ) { | |
| 273 | fe tchObserva tions(req, res); | |
| 274 | }, /*o nError*/ f unction(er rors) { | |
| 275 | re turn res.s tatus(rdk. httpstatus .bad_reque st).send(' Invalid pa rameters:' + fhirToJ DSSearch.v alidationE rrorsToStr ing(errors )); | |
| 276 | }); | |
| 277 | } | |
| 278 | ||
| 279 | function p rocessJDSE rror(logge r, pid, er ror, body, errorTag) { | |
| 280 | var er rorMessage ; | |
| 281 | if (er ror) { | |
| 282 | er rorMessage = errorTa g + 'Error fetching pid=' + pi d + ' - ' + (error.m essage || error); | |
| 283 | lo gger.error (errorMess age); | |
| 284 | re turn error Message; | |
| 285 | } | |
| 286 | if ('d ata' in bo dy) { | |
| 287 | re turn null; // no err ors to pro cess | |
| 288 | } | |
| 289 | if ('e rror' in b ody) { | |
| 290 | er rorMessage = errorTa g + body.e rror.code + ' - ' + getJDSErro rMessage(b ody.error) ; | |
| 291 | lo gger.error (errorMess age); | |
| 292 | re turn error Message; | |
| 293 | } | |
| 294 | errorM essage = e rrorTag + 'Empty res ponse from JDS'; | |
| 295 | logger .error(err orMessage) ; | |
| 296 | return errorMess age; | |
| 297 | } | |
| 298 | ||
| 299 | function f etchObserv ations(req , res) { | |
| 300 | var pi d = req.qu ery.pid; | |
| 301 | var pa rams = req .query; | |
| 302 | var co nfig = req .app.confi g; | |
| 303 | var lo gger = req .logger; | |
| 304 | ||
| 305 | // bui ld list of requests | |
| 306 | var as yncTasks = []; | |
| 307 | if (!p arams._tag || params ._tag === TAGS.VITAL S) { | |
| 308 | as yncTasks.p ush(functi on(callbac k) { | |
| 309 | vitals.g etVitalsDa ta(config, logger, p id, params , function (error, bo dy) { | |
| 310 | var errorLog = processJD SError(log ger, pid, error, bod y, 'Observ ation::get VitalsData : '); | |
| 311 | if ( errorLog) { | |
| 312 | return cal lback(erro rLog); | |
| 313 | } | |
| 314 | retu rn callbac k(null, { | |
| 315 | fhirItems: vitals.co nvertToFHI RObservati ons(body.d ata.items, req), | |
| 316 | total: bod y.data.tot alItems | |
| 317 | }); | |
| 318 | }); | |
| 319 | }) ; | |
| 320 | } | |
| 321 | //// No-He alth-Facto rs ++ | |
| 322 | // NO Heal th-Factors | |
| 323 | // if ( !params._t ag || para ms._tag == = TAGS.HEA LTH_FACTOR S) { | |
| 324 | // asyncTasks .push(func tion(callb ack) { | |
| 325 | // health Factors.ge tHealthFac tors(confi g, logger, pid, para ms, functi on(error, body) { | |
| 326 | // va r errorLog = process JDSError(l ogger, pid , error, b ody, 'Obse rvation::g etHealthFa ctors: '); | |
| 327 | // if (errorLog ) { | |
| 328 | // return c allback(er rorLog); | |
| 329 | // } | |
| 330 | // re turn callb ack(null, { | |
| 331 | // fhirItem s: healthF actors.con vertToFHIR Observatio ns(body.da ta.items, req), | |
| 332 | // total: b ody.data.t otalItems | |
| 333 | // }) ; | |
| 334 | // }); | |
| 335 | // }); | |
| 336 | // } | |
| 337 | //// No-He alth-Facto rs -- | |
| 338 | ||
| 339 | // mak e parallel requests and handle results | |
| 340 | async. parallel(a syncTasks, function( err, fhirR esults) { | |
| 341 | if (nullchec ker.isNotN ullish(err )) { | |
| 342 | return r es.status( rdk.httpst atus.inter nal_server _error).se nd('There was an err or process ing your r equest. Th e error ha s been log ged.'); | |
| 343 | } | |
| 344 | // merge res ults | |
| 345 | va r mergedRe sults = _. reduce(fhi rResults, function(a ccumulator , item) { | |
| 346 | return { | |
| 347 | fhir Items: acc umulator.f hirItems.c oncat(item .fhirItems ), | |
| 348 | tota l: accumul ator.total + item.to tal | |
| 349 | }; | |
| 350 | }, { | |
| 351 | fhirItem s: [], | |
| 352 | total: 0 | |
| 353 | }) ; | |
| 354 | ||
| 355 | // sort | |
| 356 | me rgedResult s.fhirItem s = observ ationUtils .sortBy(me rgedResult s.fhirItem s, params) ; | |
| 357 | ||
| 358 | // wrap in F HIR bundle | |
| 359 | va r fhirBund le = wrapI nFhirBundl e(mergedRe sults.fhir Items, mer gedResults .total, re q); | |
| 360 | ||
| 361 | // limit by _count | |
| 362 | li mitFHIRRes ultByCount (fhirBundl e, params. _count); | |
| 363 | ||
| 364 | re turn res.s tatus(rdk. httpstatus .ok).send( fhirBundle ); | |
| 365 | }); | |
| 366 | } | |
| 367 | ||
| 368 | function w rapInFhirB undle(fhir Results, t otal, req) { | |
| 369 | var li nk = 'http ://' + req ._remoteAd dress + re q.url; | |
| 370 | ||
| 371 | var fh irResult = new fhirR esource.Bu ndle([new fhirResour ce.Link(li nk, 'self' )]); | |
| 372 | ||
| 373 | var no w = new Da te(); | |
| 374 | ||
| 375 | //Note : Will let current t ime defaul t to runni ng server TZ. | |
| 376 | fhirRe sult.meta = { | |
| 377 | 'l astUpdated ': fhirUti ls.convert ToFhirDate Time(now) | |
| 378 | }; | |
| 379 | fhirRe sult.entry = fhirRes ults; | |
| 380 | fhirRe sult.total = total; | |
| 381 | ||
| 382 | return fhirResul t; | |
| 383 | } | |
| 384 | ||
| 385 | function v alidatePar ams(params , onSucces s, onError ) { | |
| 386 | ////No-Hea lth-Factor s ++ | |
| 387 | // if ( nullchecke r.isNotNul lish(param s._tag) && !_.includ es([TAGS.H EALTH_FACT ORS, TAGS. VITALS], p arams._tag )) { | |
| 388 | // re turn onErr or(['Unsup ported _ta g criteria . Supporte d attribut es are: ' + TAGS.VIT ALS + ' an d ' + TAGS .HEALTH_FA CTORS + '. ']); | |
| 389 | //} | |
| 390 | ////No-Hea lth-Factor s -- | |
| 391 | if (nu llchecker. isNotNulli sh(params. _tag) && ! _.includes ([TAGS.VIT ALS], para ms._tag)) { | |
| 392 | re turn onErr or(['Unsup ported _ta g criteria . Supporte d attribut es are: ' + TAGS.VIT ALS + '.'] ); | |
| 393 | } | |
| 394 | ||
| 395 | // che ck common parameters | |
| 396 | return fhirToJDS Search.val idateCommo nParams(pa rams, func tion() { | |
| 397 | // validate date | |
| 398 | fh irToJDSSea rch.valida teDatePara ms(params, ['date'], function( ) { | |
| 399 | if (vita ls.isSortC riteriaVal id(params) ) { | |
| 400 | onSu ccess(); | |
| 401 | } else { | |
| 402 | onEr ror(['Unsu pported _s ort criter ia. Suppor ted attrib utes are: date, iden tifier, pa tient, per former, su bject and value-quan tity']); | |
| 403 | } | |
| 404 | }, onError); | |
| 405 | // Future TO DO: add va lidation f or code pa ram | |
| 406 | }, onE rror); | |
| 407 | } | |
| 408 | ||
| 409 | function g etJDSError Message(er ror) { | |
| 410 | var ms g = ''; | |
| 411 | ||
| 412 | if (nu llchecker. isNotNulli sh(error.e rrors)) { | |
| 413 | ms g = _.redu ce(error.e rrors, fun ction(memo , e) { | |
| 414 | if (memo && memo.l ength > 0) { | |
| 415 | memo += ', '; | |
| 416 | } | |
| 417 | memo += e.domain + ' :: ' + e.message; | |
| 418 | return m emo; | |
| 419 | }, ''); | |
| 420 | } | |
| 421 | return msg; | |
| 422 | } | |
| 423 | ||
| 424 | module.exp orts.getRe sourceConf ig = getRe sourceConf ig; | |
| 425 | module.exp orts.getOb servation = getObser vation; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.