Produced by Araxis Merge on 4/18/2019 5:55:12 PM Eastern 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 | MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_API_Core\src\app\metabase\commands\fhir | refreshFacilities.js | Wed Apr 3 02:27:38 2019 UTC |
2 | MCCF_EDI_TAS_TASCore v2.0_Build_10.zip\MCCF_EDI_TAS_API_Core\src\app\metabase\commands\fhir | refreshFacilities.js | Tue Apr 16 13:20:38 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 360 |
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 | const debu g = requir e('debug') ('metabase ') | |
4 | ||
5 | const util = require ('util') | |
6 | ||
7 | const $tas = require ('../../.. /../tas')( ) | |
8 | ||
9 | const meta base = $ta s.provider s.load('me tabase') | |
10 | ||
11 | const TEMP LATE_facil ities_url = (extract Config) => '/' + ext ractConfig .fhirResou rceBundle + '?' + $t as.helpers .uri.pqsJo in({ | |
12 | locati on: extrac tConfig.vi staInstanc e, | |
13 | use: e xtractConf ig.use | |
14 | }) | |
15 | ||
16 | const crit eria = [{ | |
17 | pr edicate: ( error, res ponse, bod y) => ((er ror || {}) .message | | '').incl udes('ECON NRESET'), | |
18 | ac tion: (err or, respon se, body) => true | |
19 | }, | |
20 | { | |
21 | pr edicate: ( error, res ponse, bod y) => ((er ror || {}) .message | | '').incl udes('ENOT FOUND'), | |
22 | ac tion: (err or, respon se, body) => false | |
23 | }, | |
24 | { | |
25 | pr edicate: ( error, res ponse, bod y) => ((er ror || {}) .message | | '').incl udes('ETIM EDOUT'), | |
26 | ac tion: () = > true | |
27 | }, | |
28 | { | |
29 | pr edicate: ( error, res ponse, bod y) => (res ponse || { }).statusC ode === 50 2, | |
30 | ac tion: () = > true | |
31 | }, | |
32 | { | |
33 | pr edicate: ( error, res ponse, bod y) => ((bo dy || {}). entry || ' ').length === 0, | |
34 | ac tion: () = > false | |
35 | } | |
36 | ] | |
37 | const Refr eshFacilit iesCommand = class e xtends $ta s.command. Command { | |
38 | async getBundle( user_id, w ebClientOp tions) { | |
39 | le t message = "Success " | |
40 | le t statusCo de = 200 | |
41 | le t uri = we bClientOpt ions.uri | |
42 | le t bundle | |
43 | le t { | |
44 | error, | |
45 | response , | |
46 | body | |
47 | } = await $t as.webclie nt({ | |
48 | security ContextNot Used: user _id | |
49 | }, webClient Options) | |
50 | ||
51 | if (error != = null || body === n ull) { | |
52 | if (resp onse != nu ll && resp onse.reque st) { | |
53 | stat usCode = r esponse.st atusCode | | 500 | |
54 | if ( response.s tatusCode === 500) { | |
55 | message = webClientO ptions.uri + 'body: ' + body | |
56 | } el se { | |
57 | message = 'Error fro m FHIR ser ver:' + ut il.inspect (error) + ' ' + webC lientOptio ns.uri + ' ' + body | |
58 | } | |
59 | } else { | |
60 | stat usCode = 5 00 | |
61 | mess age = 'Err or: ' + we bClientOpt ions.uri + ' ' + uti l.inspect( error) | |
62 | } | |
63 | } else if (b ody !== nu ll && resp onse != nu ll && resp onse.statu sCode !== 200) { | |
64 | statusCo de = respo nse.status Code | |
65 | message = 'FHIR Se rver retur ned status code: ' + response. statusCode + ' ' + w ebClientOp tions.uri + ' ' + bo dy | |
66 | } else { | |
67 | try { | |
68 | bund le = JSON. parse(body ) | |
69 | } catch (ex) { | |
70 | stat usCode = 5 00 | |
71 | mess age = 'FHI R Server r eturned no n json (ht ml?) :' + webClientO ptions.uri + ' ' + b ody | |
72 | } | |
73 | } | |
74 | re turn { | |
75 | statusCo de, | |
76 | message, | |
77 | uri, | |
78 | bundle | |
79 | } | |
80 | } | |
81 | ||
82 | /** | |
83 | * TOD O 3/1/2019 Need inpu t - what is the vis taid suppo sed to be? | |
84 | * | |
85 | * @pa ram {*} us er_id | |
86 | * @pa ram {*} ex tractConfi g | |
87 | * @pa ram {*} vi staid | |
88 | */ | |
89 | async refresh (u ser_id, ex tractConfi g, vistaid ) { | |
90 | if (typeof ex tractConfi g === 'und efined') { | |
91 | debug('W ARNING: ex tractConfi g was unde fined. Fac ility refr esh skippe d.') | |
92 | return | |
93 | } | |
94 | le t uri = $t as.helpers .uri.join( extractCon fig.tasFHI REndpoint, TEMPLATE _facilitie s_url(extr actConfig) ) | |
95 | le t options = { | |
96 | method: 'GET', | |
97 | uri: uri , | |
98 | headers: { | |
99 | vist aid | |
100 | }, | |
101 | retry: { | |
102 | maxC ount: 40, | |
103 | slee pTime: 90, | |
104 | crit eria | |
105 | } | |
106 | } | |
107 | le t bundleOb j = await this.getBu ndle(user_ id, option s) | |
108 | ||
109 | if (bundleOb j.statusCo de !== 200 ) { | |
110 | delete b undleObj.b undle | |
111 | return b undleObj | |
112 | } | |
113 | ||
114 | ||
115 | le t query = `entry[*]. resource.{ identifie r : identi fier[0].va lue, name: name }` | |
116 | le t stations = $tas.he lpers.jmes path.searc h(bundleOb j.bundle, query) | |
117 | ||
118 | // here is h ow you wou ld access what's in metabase | |
119 | // let resul ts = await metabase. getByScope ('stations ') | |
120 | ||
121 | // would nee d to strip 'stations :' | |
122 | // const toB eUpdated = results.f ilter(p => stations. includes(p .name) === true) | |
123 | ||
124 | // N.B. This is upsert (for now) if exist, update th e name, if it doesn' t exist cr eate stati on. | |
125 | fo r (let sta tion of st ations) { | |
126 | if (!sta tion.ident ifier ) { | |
127 | // b ad data, s ent email to SM and KO | |
128 | //de bug('>>>>> ', station ) | |
129 | cont inue | |
130 | } | |
131 | let name = 'statio ns:' + sta tion.ident ifier.toLo werCase() | |
132 | let valu e = statio n.name | |
133 | ||
134 | await me tabase.upd ate(name, value) | |
135 | } | |
136 | } | |
137 | ||
138 | async run(_, val ues, adapt er) { | |
139 | de bug('refre shFaciliti es', value s) | |
140 | co nst user_i d = _.seci d | |
141 | co nst config = values. params | |
142 | tr y { | |
143 | const p = await th is.refresh (user_id, config) | |
144 | return a dapter.cre ateRespons e($tas.con stants.sta tus.SUCCES S, p) | |
145 | } catch (ex) { | |
146 | debug('E xception: refresh::' + util.in spect(ex)) | |
147 | return a dapter.cre ateRespons e($tas.con stants.sta tus.ERROR, { | |
148 | erro r: ex.mess age | |
149 | }) | |
150 | } | |
151 | } | |
152 | } | |
153 | ||
154 | const Refr eshAllFaci litiesComm and = clas s extends $tas.comma nd.Command { | |
155 | async run(_, val ues, adapt er) { | |
156 | de bug('refre shAllFacil ities') | |
157 | ||
158 | co nst config = { | |
159 | "tasFHIREn dpoint": " https:// DNS . URL /VA-FHIR-S erver/fhir ", | |
160 | "operati on": "SEAR CH", | |
161 | "fhirRes ourceBundl e": "Bundl e", | |
162 | "vistaIn stance": " dev_0001", | |
163 | "vistaId ": "519|52 0824645^PN ^519^USVHA |A", | |
164 | "use": " facilities ", | |
165 | "from": "20150730" , | |
166 | "limit": "5", | |
167 | "log": " 1", | |
168 | "descrip tion": "mo ck ntr" | |
169 | } | |
170 | re turn await $tas.comm and.run('m etabase.fh ir.refresh Facilities ', { | |
171 | user_id: 'user_id' , | |
172 | config | |
173 | }) | |
174 | } | |
175 | } | |
176 | ||
177 | module.exp orts = { | |
178 | Refres hFacilitie sCommand, | |
179 | Refres hAllFacili tiesComman d, | |
180 | TEMPLA TE_facilit ies_url | |
181 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.