Produced by Araxis Merge on 8/1/2019 1:26:28 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 | JLV_2_8_0_0_0_July_2019.zip\JLV_2_8_0_0_0_July_2019\BHIERelayService\src\test\java\gov\va\med\bhie\patient | NoteDaoTest.java | Mon Jul 8 18:57:46 2019 UTC |
2 | JLV_2_8_0_0_0_July_2019.zip\JLV_2_8_0_0_0_July_2019\BHIERelayService\src\test\java\gov\va\med\bhie\patient | NoteDaoTest.java | Tue Jul 30 17:39:04 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 3 | 522 |
Changed | 2 | 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 | /** | |
2 | * Janus 4 .0 (c) | |
3 | * Copyrig ht (c) 201 1 Hawaii R esource Gr oup LLC. A ll Rights Reserved. | |
4 | * Develop ed for the Pacific T elehealth & Technolo gy Hui and the Pacif ic Joint I nformation Technolog y Center | |
5 | * Contrib utors: | |
6 | * Hon orable Sen ator Danie l K. Inouy e | |
7 | * VA Pacific Is lands Heal th Care Sy stem | |
8 | * Tri pler Army Medical Ce nter | |
9 | */ | |
10 | ||
11 | ||
12 | package go v.va.med.b hie.patien t; | |
13 | ||
14 | import com .sun.jerse y.core.uti l.Base64; | |
15 | import gov .va.med.bh ie.BaseTes t; | |
16 | import gov .va.med.bh ie.beans.N oteImage; | |
17 | import gov .va.med.bh ie.beans.v 4.Medicati onFillInfo V4; | |
18 | import gov .va.med.bh ie.common. AppConfig; | |
19 | import gov .va.med.bh ie.common. ClinicalDo mainLoincC ode; | |
20 | import gov .va.med.bh ie.dao.Dao Exception; | |
21 | import gov .va.med.bh ie.dao.pat ient.NoteD ao; | |
22 | import gov .va.med.bh ie.dao.pat ient.V4Dao ; | |
23 | import gov .va.med.bh ie.resultc ollection. V4ResultCo llection; | |
24 | import gov .va.med.bh ie.webserv ice.NoteFi xer; | |
25 | import org .apache.co mmons.lang 3.StringEs capeUtils; | |
26 | import org .apache.co mmons.lang 3.StringUt ils; | |
27 | import org .junit.Tes t; | |
28 | import org .w3c.dom.D ocument; | |
29 | import org .xml.sax.I nputSource ; | |
30 | import org .xml.sax.S AXExceptio n; | |
31 | ||
32 | import jav ax.xml.par sers.Docum entBuilder ; | |
33 | import jav ax.xml.par sers.Docum entBuilder Factory; | |
34 | import jav ax.xml.par sers.Parse rConfigura tionExcept ion; | |
35 | import jav a.io.IOExc eption; | |
36 | import jav a.io.Strin gReader; | |
37 | import jav a.util.Lis t; | |
38 | ||
39 | import sta tic org.ju nit.Assert .assertTru e; | |
40 | ||
41 | public cla ss NoteDao Test exten ds BaseTes t | |
42 | { | |
43 | ||
44 | privat e static f inal Strin g C62_NODE _ID = "tem plateId ro ot=\"1.3.6 .1.4.1.193 76.1.5.3.1 .1.1\""; | |
45 | ||
46 | @Test | |
47 | public void test GetPatient Notes() th rows DaoEx ception { | |
48 | ||
49 | // NoteDao no teDao = ne w NoteDao( ); | |
50 | // NoteResult Collection V3 noteRes ults = not eDao.getPa tientNotes V3(queryBe an); | |
51 | // | |
52 | // //long sti me = logRe quest(quer yBean); | |
53 | // String tok en = ""; | |
54 | // try { | |
55 | // NoteRe sultCollec tionV3 rtc ; | |
56 | // int co unt = 0; | |
57 | // //rtc = BHIELimi t.getInsta nce().getP atientNote sCache(que ryBean); | |
58 | // //if ( rtc == nul l) { | |
59 | // // token = BH IELimit.ge tInstance( ).getToken (); | |
60 | // rt c = noteDa o.getPatie ntNotesV3( queryBean) ; | |
61 | // // if (rtc != null && r tc.getData RecordList () != null ) { | |
62 | // // count = rtc.getD ataRecordL ist().size (); | |
63 | // // } | |
64 | // // logRespons e(queryBea n, "", rtc , count, s time, "fal se"); | |
65 | // // BHIELimit. getInstanc e().putPat ientNotesC ache(query Bean, rtc) ; | |
66 | // //} el se { | |
67 | // // logRespons e(queryBea n, "", rtc , rtc.getD ataRecordL ist().size (), stime, "true"); | |
68 | // //} | |
69 | // // retu rn rtc; | |
70 | // } catch (E xception e ) { | |
71 | // //logR esponse(qu eryBean, e .getLocali zedMessage (), null, 0, stime, "false"); | |
72 | // throw new Runtim eException (e); | |
73 | // } finally { | |
74 | // BHIELi mit.getIns tance().re leaseToken (token); | |
75 | // } | |
76 | // | |
77 | // assertTrue (noteResul ts.getData RecordList ().size() > 0); | |
78 | } | |
79 | ||
80 | @Test | |
81 | public void test GetPatient NotesV4() throws Dao Exception { | |
82 | V4 Dao v4Dao = new V4Da o(); | |
83 | V4 ResultColl ection v4R esults = v 4Dao.getV4 Data(Clini calDomainL oincCode.N OTES, quer yBean); | |
84 | as sertTrue(v 4Results.g etDataReco rdList().g etAllergy( ).size() > 0); | |
85 | } | |
86 | ||
87 | @Test | |
88 | public void test GetEncount erNotes() throws Dao Exception { | |
89 | ||
90 | No teDao note Dao = new NoteDao(); | |
91 | // NoteResult Collection V3 noteRes ults = not eDao.getEn counterNot esV3(query Bean); | |
92 | // assertTrue (noteResul ts.getData RecordList ().size() > 0); | |
93 | } | |
94 | ||
95 | @Test | |
96 | public void test GetNoteIma ge() throw s DaoExcep tion { | |
97 | ||
98 | No teDao note Dao = new NoteDao(); | |
99 | No teImage re sponse = n oteDao.get NoteImage( "215286578 7"); | |
100 | as sertTrue(r esponse.ge tNoteBytes ().length > 0); | |
101 | } | |
102 | ||
103 | @Test | |
104 | public void test GetNoteIma geFromUrl( ) throws D aoExceptio n { | |
105 | ||
106 | No teDao note Dao = new NoteDao(); | |
107 | Il legalArgum entExcepti on iae = n ull; | |
108 | tr y | |
109 | { | |
110 | NoteImage ni = noteD ao.getNote ImageFromU rl("http:/ / IP /MockDoDAd aptor/asyn c/complex/ note/99999 01"); | |
111 | ni.getCo ntentType( ); | |
112 | } | |
113 | ca tch (Illeg alArgument Exception e) | |
114 | { | |
115 | iae = e; | |
116 | } | |
117 | ||
118 | as sertTrue(i ae != null ); | |
119 | ||
120 | ia e = null; | |
121 | ||
122 | tr y | |
123 | { | |
124 | noteDao. getNoteIma geFromUrl( "http://BH IEdomain/a sync/comet ?loinc=123 4&userid=1 2345"); | |
125 | } | |
126 | ca tch (Illeg alArgument Exception e) | |
127 | { | |
128 | iae = e; | |
129 | } | |
130 | ||
131 | as sertTrue(i ae != null ); | |
132 | ||
133 | ia e = null; | |
134 | ||
135 | No teImage re sponse = n oteDao.get NoteImageF romUrl("ht tp://BHIEd omain:8080 /async/com plex/note/ 2157580439 "); | |
136 | as sertTrue(r esponse.ge tNoteBytes ().length > 0); | |
137 | } | |
138 | ||
139 | ||
140 | @Test | |
141 | public void test GetNoteAtt achmentFro mUrl() thr ows DaoExc eption { | |
142 | St ring error Text = ""; | |
143 | ||
144 | No teDao note Dao = new NoteDao(); | |
145 | No teImage rt c; | |
146 | ||
147 | tr y { | |
148 | ||
149 | rtc = note Dao.getNot eImageFrom Url("http: // IP /MockDoDAd aptor/asyn c/complex/ note/doc9. json"); | |
150 | ||
151 | if (rtc != null && rtc.getNo teBytes() != null) { | |
152 | try { | |
153 | ||
154 | String dat aXML = new String(rt c.getNoteB ytes(), "U TF-8"); | |
155 | ||
156 | //unwrap C 62 documen ts coming over as js on strings | |
157 | if(StringU tils.isNot Empty(rtc. getContent Type()) && rtc.getCo ntentType( ).endsWith ("json") & & dataXML. startsWith ("\"")){ | |
158 | dataXM L = dataXM L.replaceA ll("^\"|\" $", ""); | |
159 | dataXM L = String EscapeUtil s.unescape Java(dataX ML); | |
160 | } | |
161 | ||
162 | DocumentBu ilderFacto ry dbFacto ry = Docum entBuilder Factory.ne wInstance( ); | |
163 | ||
164 | dbFactory. setFeature ("http://x ml.org/sax /features/ external-g eneral-ent ities", fa lse); | |
165 | dbFactory. setFeature ("http://x ml.org/sax /features/ external-p arameter-e ntities", false); | |
166 | dbFactory. setFeature ("http://j avax.xml.X MLConstant s/feature/ secure-pro cessing", true); | |
167 | ||
168 | DocumentBu ilder dBui lder = dbF actory.new DocumentBu ilder(); | |
169 | InputSourc e is = new InputSour ce(new Str ingReader( dataXML)); | |
170 | Document d oc = dBuil der.parse( is); | |
171 | ||
172 | // StringBu ffer attac hmentOutpu t = new St ringBuffer (""); | |
173 | String enc odedText = ""; | |
174 | String med iaType = " text/html" ; | |
175 | ||
176 | if (doc != null && d oc.getElem entsByTagN ame("text" ) != null | |
177 | && doc.getEl ementsByTa gName("tex t").item(0 ) != null | |
178 | && !doc.getE lementsByT agName("te xt").item( 0).getText Content(). isEmpty()) { | |
179 | encode dText = do c.getEleme ntsByTagNa me("text") .item(0).g etTextCont ent().trim (); | |
180 | ||
181 | if (do c.getEleme ntsByTagNa me("text") .item(0).g etAttribut es().getNa medItem("m ediaType") != null) { | |
182 | me diaType = doc.getEle mentsByTag Name("text ").item(0) .getAttrib utes().get NamedItem( "mediaType ").getNode Value(); | |
183 | } | |
184 | } | |
185 | ||
186 | rtc.setCon tentType(m ediaType); | |
187 | ||
188 | if(isC62Do c(dataXML) ){ | |
189 | rtc.se tNoteBytes (Base64.de code(encod edText)); | |
190 | } else if (mediaType .contains( "plain") | | mediaTyp e.contains ("html") | | mediaTyp e.contains ("image")) { | |
191 | // do nothing, l et web-fro nt end ren der the at tachment i n-line | |
192 | } else if (mediaType .contains( "applicati on") || me diaType.co ntains("rt f")) { | |
193 | rtc.se tNoteBytes (Base64.de code(encod edText)); | |
194 | } | |
195 | ||
196 | } ca tch (Parse rConfigura tionExcept ion e) { | |
197 | // logError (e); | |
198 | errorText = "1"; | |
199 | } ca tch (SAXEx ception e) { | |
200 | // logError (e); | |
201 | errorText = "1"; | |
202 | } ca tch (IOExc eption e) { | |
203 | // logError (e); | |
204 | errorText = "1"; | |
205 | } | |
206 | } | |
207 | ||
208 | // if (!" false".equ alsIgnoreC ase((Strin g) AppConf ig.getInst ance().get Properties ().get("fi xrtf"))) { | |
209 | // rt c = NoteFi xer.fixNot eImage(rtc , "pdf".eq ualsIgnore Case(AppCo nfig.getIn stance().g etNoteConv ertFormat( ))); | |
210 | // } | |
211 | ||
212 | if (rtc != null) { | |
213 | Stri ng content Type = rtc .getConten tType(); | |
214 | /* f latten pdf note type s to remov e fillable pdf */ | |
215 | if ( "applicati on/octet-s tream".equ alsIgnoreC ase(conten tType) | |
216 | || "ap plication/ pdf".equal sIgnoreCas e(contentT ype)) { | |
217 | rtc = Note Fixer.flat tenNoteFor m(rtc); | |
218 | } | |
219 | } | |
220 | ||
221 | } catch (Dao Exception e) { | |
222 | ||
223 | throw ne w RuntimeE xception(e ); | |
224 | } | |
225 | as sertTrue(r tc != null ); | |
226 | } | |
227 | ||
228 | public static bo olean isC6 2Doc(Strin g xmlDoc) { | |
229 | if (xmlDoc.i ndexOf(C62 _NODE_ID) > 0) { | |
230 | return t rue; | |
231 | } | |
232 | re turn false ; | |
233 | } | |
234 | ||
235 | @Test | |
236 | public void test GetMedicat ionFillInf o() throws DaoExcept ion { | |
237 | ||
238 | No teDao note Dao = new NoteDao(); | |
239 | Li st<Medicat ionFillInf oV4> fillI nfoList = null; | |
240 | ||
241 | tr y | |
242 | { | |
243 | fillInfo List = not eDao.getMe dicationFi llInfo("ht tp://local host/MockD oDAdaptor/ async/comp lex/note/f ill.json") ; | |
244 | ||
245 | } | |
246 | ca tch (Excep tion e) | |
247 | { | |
248 | //do som ething; | |
249 | System.o ut.println ("test fai l e: " + e .getMessag e()); | |
250 | } | |
251 | ||
252 | ||
253 | as sertTrue(f illInfoLis t.size() > 0); | |
254 | } | |
255 | ||
256 | // @Tes t | |
257 | // publ ic void te stGetPatie ntConsults () throws DaoExcepti on { | |
258 | // | |
259 | // NoteDao no teDao = ne w NoteDao( ); | |
260 | // NoteResult Collection V3 noteRes ults = not eDao.getPa tientConsu ltsV3(quer yBean); | |
261 | // assertTrue (noteResul ts.getData RecordList ().size() > 0); | |
262 | // } | |
263 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.