Produced by Araxis Merge on 4/2/2019 1:06:55 PM 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 | C:\AraxisMergeCompare\Pri_un\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\service\impl | RfaiSearchSubmissionServiceImpl.java | Wed Mar 27 19:22:43 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\service\impl | RfaiSearchSubmissionServiceImpl.java | Thu Mar 28 17:50:56 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 1052 |
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 | /** | |
2 | * | |
3 | */ | |
4 | package go v.va.med.a rs.service .impl; | |
5 | ||
6 | import jav a.math.Big Integer; | |
7 | import jav a.text.Dat eFormat; | |
8 | import jav a.text.Par seExceptio n; | |
9 | import jav a.text.Sim pleDateFor mat; | |
10 | import jav a.util.Arr ayList; | |
11 | import jav a.util.Cal endar; | |
12 | import jav a.util.Col lections; | |
13 | import jav a.util.Com parator; | |
14 | import jav a.util.Dat e; | |
15 | import jav a.util.Lis t; | |
16 | import jav a.util.str eam.Stream ; | |
17 | ||
18 | import jav ax.persist ence.crite ria.Criter iaBuilder; | |
19 | import jav ax.persist ence.crite ria.Criter iaQuery; | |
20 | import jav ax.persist ence.crite ria.Predic ate; | |
21 | import jav ax.persist ence.crite ria.Root; | |
22 | ||
23 | import org .apache.lo g4j.LogMan ager; | |
24 | import org .apache.lo g4j.Logger ; | |
25 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
26 | import org .springfra mework.dat a.domain.P age; | |
27 | import org .springfra mework.dat a.domain.P ageRequest ; | |
28 | import org .springfra mework.dat a.domain.S ort; | |
29 | import org .springfra mework.dat a.jpa.doma in.Specifi cation; | |
30 | import org .springfra mework.htt p.HttpStat us; | |
31 | import org .springfra mework.ste reotype.Se rvice; | |
32 | ||
33 | import gov .va.med.ar s.constant s.ClaimSub missionCon stants; | |
34 | import gov .va.med.ar s.constant s.ErrorMes sages; | |
35 | import gov .va.med.ar s.dao.ars. IRfaiLooku pRepositor y; | |
36 | import gov .va.med.ar s.dao.ars. RfaiLookup Repository ; | |
37 | import gov .va.med.ar s.exceptio ns.Generic Exception; | |
38 | import gov .va.med.ar s.model.re quest.Rfai LookupRequ est; | |
39 | import gov .va.med.ar s.model.re sponse.Gen ericRespon se; | |
40 | import gov .va.med.ar s.model.re sponse.Rfa iLookUpRes ponse; | |
41 | import gov .va.med.ar s.service. IRfaiSearc hSubmissio nService; | |
42 | import gov .va.med.do main.ars.C laimSubmis sion; | |
43 | ||
44 | /** | |
45 | * @author
|
|
46 | * | |
47 | */ | |
48 | @Service | |
49 | public cla ss RfaiSea rchSubmiss ionService Impl imple ments IRfa iSearchSub missionSer vice { | |
50 | ||
51 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Rfai SearchSubm issionServ iceImpl.cl ass); | |
52 | ||
53 | Da teFormat d ateFormat = new Simp leDateForm at("MM/dd/ yyyy"); | |
54 | pr ivate stat ic final S tring CURR ENT_DATE_F ORMAT = "M M/dd/yyyy" ; | |
55 | ||
56 | @A utowired | |
57 | Rf aiLookupRe pository r faiReposit ory; | |
58 | ||
59 | @A utowired | |
60 | IR faiLookupR epository iRfaiRepos itory; | |
61 | ||
62 | @O verride | |
63 | pu blic Gener icResponse getRfaiSi mpleSearch Results(Rf aiLookupRe quest rfai LookupRequ est) throw s GenericE xception { | |
64 | Gene ricRespons e searchRe sponse; | |
65 | List <ClaimSubm ission> pd iClaim = n ew ArrayLi st<>(); | |
66 | List <ClaimSubm ission> su bmissionId = new Arr ayList<>() ; | |
67 | List <ClaimSubm ission> pa tientId; | |
68 | List <ClaimSubm ission> pr oviderNpi; | |
69 | ||
70 | if ( isNullOrEm pty(rfaiLo okupReques t.getSortC olumn())) { | |
71 | rfaiLo okupReques t.setSortC olumn("sub missionId" ); | |
72 | } | |
73 | if ( rfaiLookup Request.ge tNumber(). matches("[ 0-9]+")) { | |
74 | pdiCla im = rfaiR epository. findBytrn0 2claimInde x(new BigI nteger(rfa iLookupReq uest.getNu mber())); | |
75 | submis sionId = r faiReposit ory.findBy submission id(new Big Integer(rf aiLookupRe quest.getN umber())); | |
76 | patien tId = rfai Repository .findByhl4 nm109ptid( rfaiLookup Request.ge tNumber()) ; | |
77 | provid erNpi = rf aiReposito ry.findByh l3nm109prv npi(rfaiLo okupReques t.getNumbe r()); | |
78 | } el se { | |
79 | patien tId = rfai Repository .findByhl4 nm109ptid( rfaiLookup Request.ge tNumber()) ; | |
80 | provid erNpi = rf aiReposito ry.findByh l3nm109prv npi(rfaiLo okupReques t.getNumbe r()); | |
81 | } | |
82 | ||
83 | List <ClaimSubm ission> cm = new Arr ayList<>() ; | |
84 | cm.a ddAll(pdiC laim); | |
85 | cm.a ddAll(subm issionId); | |
86 | cm.a ddAll(pati entId); | |
87 | cm.a ddAll(prov iderNpi); | |
88 | ||
89 | Coll ections.so rt(cm, new Comparato r<ClaimSub mission>() { | |
90 | ||
91 | @Overr ide | |
92 | public int compa re(ClaimSu bmission o 1, ClaimSu bmission o 2) { | |
93 | try { | |
94 | switch (rf aiLookupRe quest.getS ortColumn( )) { | |
95 | case Claim Submission Constants. PROVIDER_N AME: | |
96 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl3nm10 3svcbillpr vnm(), | |
97 | o2.get Hl3nm103sv cbillprvnm (), ClaimS ubmission. class | |
98 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PROVIDE R_NAME_DB_ COLUMN).ge tType()); | |
99 | case Claim Submission Constants. PROVIDER_N PI: | |
100 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl3nm10 9prvnpi(), | |
101 | o2.get Hl3nm109pr vnpi(), Cl aimSubmiss ion.class | |
102 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PROVIDE R_NPI_DB_C OLUMN).get Type()); | |
103 | case Claim Submission Constants. PROVIDER_T IN: | |
104 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl2nm10 9svcprvtin (), | |
105 | o2.get Hl2nm109sv cprvtin(), ClaimSubm ission.cla ss | |
106 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PROVIDE R_TIN_DB_C OLUMN).get Type()); | |
107 | case Claim Submission Constants. PATIENT_LA ST_NAME: | |
108 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 3ptlstnm() , | |
109 | o2.get Hl4nm103pt lstnm(), | |
110 | ClaimS ubmission. class | |
111 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _LAST_NAME _DB_COLUMN ) | |
112 | .getType() ); | |
113 | case Claim Submission Constants. PATIENT_FI RST_NAME: | |
114 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 4ptftnm(), | |
115 | o2.get Hl4nm104pt ftnm(), | |
116 | ClaimS ubmission. class | |
117 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _FIRST_NAM E_DB_COLUM N) | |
118 | .getType() ); | |
119 | case Claim Submission Constants. PATIENT_ID : | |
120 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 9ptid(), | |
121 | o2.get Hl4nm109pt id(), Clai mSubmissio n.class | |
122 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _ID_DB_COL UMN).getTy pe()); | |
123 | case Claim Submission Constants. PATIENT_CO NTROL_NUMB ER: | |
124 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getRef102p tctrlnmbr( ), | |
125 | o2.get Ref102ptct rlnmbr(), | |
126 | ClaimS ubmission. class | |
127 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _CONTROL_N UMBER_DB_C OLUMN) | |
128 | .getType() ); | |
129 | case Claim Submission Constants. LINE_ITEM_ CONTROL_NU MBER: | |
130 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getSubmiss ionid(), | |
131 | o2.get Submission id(), Clai mSubmissio n.class | |
132 | .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_ID_DB_ COLUMN).ge tType()); | |
133 | case Claim Submission Constants. MEDICAL_RE CORD_NUMBE R: | |
134 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getRef302m edrecnmbr( ), | |
135 | o2.get Ref302medr ecnmbr(), | |
136 | ClaimS ubmission. class | |
137 | .getDeclar edField(Cl aimSubmiss ionConstan ts.MEDICAL _RECORD_NU MBER_DB_CO LUMN) | |
138 | .getType() ); | |
139 | case Claim Submission Constants. DATE_SUBMI TTED: | |
140 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getDatesub mitted(), | |
141 | o2.get Datesubmit ted(), Cla imSubmissi on.class | |
142 | .getDeclar edField(Cl aimSubmiss ionConstan ts.DATE_SU BMITTED_DB _COLUMN).g etType()); | |
143 | case Claim Submission Constants. REQUIRED_R ESPONSE_DA TE: | |
144 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getDtp203r esponsedue date(), | |
145 | o2.get Dtp203resp onseduedat e(), | |
146 | ClaimS ubmission. class | |
147 | .getDeclar edField(Cl aimSubmiss ionConstan ts.RESPONS E_DUE_DATE _DB_COLUMN ) | |
148 | .getType() ); | |
149 | case Claim Submission Constants. PATIENT_NA ME: | |
150 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getHl4nm10 3ptlstnm() , | |
151 | o2.get Hl4nm103pt lstnm(), | |
152 | ClaimS ubmission. class | |
153 | .getDeclar edField(Cl aimSubmiss ionConstan ts.PATIENT _LAST_NAME _DB_COLUMN ) | |
154 | .getType() ); | |
155 | case Claim Submission Constants. PDI_CLAIM_ ID: | |
156 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getTrn02cl aimIndex() , | |
157 | o2.get Trn02claim Index(), C laimSubmis sion.class | |
158 | .getDeclar edField(Cl aimSubmiss ionConstan ts.Claim_P DI_DB_COLU MN_NAME).g etType()); | |
159 | case Claim Submission Constants. SUBMISSION _ID: | |
160 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), (o1 .getSubmis sionid()), | |
161 | (o2.ge tSubmissio nid()), Cl aimSubmiss ion.class | |
162 | .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_ID_DB_ COLUMN).ge tType()); | |
163 | case Claim Submission Constants. STATUS: | |
164 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), o1. getSubmiss ionStatus( ), | |
165 | o2.get Submission Status(), | |
166 | ClaimS ubmission. class | |
167 | .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_STATUS _DB_COLUMN ) | |
168 | .getType() ); | |
169 | default: | |
170 | re turn compa reByAscDes c(rfaiLook upRequest. getDescend ing(), (o1 .getSubmis sionid()), | |
171 | (o2.ge tSubmissio nid()), Cl aimSubmiss ion.class | |
172 | .getDeclar edField(Cl aimSubmiss ionConstan ts.SUBMISS ION_ID_DB_ COLUMN).ge tType()); | |
173 | } | |
174 | } catch (NoSuchFie ldExceptio n | Securi tyExceptio n e) { | |
175 | logger.inf o("Excepti on occured in try/ca tch statem ents : " + e); | |
176 | return 0; | |
177 | } | |
178 | } | |
179 | ||
180 | int co mpareByAsc Desc(boole an desc, O bject o1, Object o2, Class<?> classObjec t) { | |
181 | Object p re; | |
182 | Object p ost; | |
183 | if (!des c) { | |
184 | post = o2; | |
185 | pre = o1; | |
186 | } else { | |
187 | post = o1; | |
188 | pre = o2; | |
189 | } | |
190 | if (pre == null) { | |
191 | return (po st == null ) ? 0 : -1 ; | |
192 | } | |
193 | if (post == null) { | |
194 | return 1; | |
195 | } | |
196 | switch ( classObjec t.getSimpl eName()) { | |
197 | case "Lo ng": | |
198 | case "lo ng": | |
199 | return ((L ong) pre). compareTo( (Long) pos t); | |
200 | case "Bi gInteger": | |
201 | return ((B igInteger) pre).comp areTo((Big Integer) p ost); | |
202 | case "Da te": | |
203 | return ((D ate) pre). compareTo( (Date) pos t); | |
204 | default: | |
205 | return ((S tring) pre ).compareT o((String) post); | |
206 | } | |
207 | } | |
208 | }); | |
209 | ||
210 | List <RfaiLookU pResponse> responseL ist = assi gnClaimSub missionLis tData(cm); | |
211 | ||
212 | sear chResponse = new Gen ericRespon se(rfaiLoo kupRequest .getPageNu mber().int Value(), | |
213 | rfaiLook upRequest. getPageSiz e().intVal ue(), rfai LookupRequ est.getSor tColumn(), | |
214 | new Long (responseL ist.size() )); | |
215 | List <RfaiLookU pResponse> response = new Arra yList<>(); | |
216 | int upperLimit = rfaiLoo kupRequest .getPageNu mber() * r faiLookupR equest.get PageSize() ; | |
217 | int lowerLimit = upperLi mit - rfai LookupRequ est.getPag eSize(); | |
218 | for (int i = l owerLimit; i < upper Limit && i < respons eList.size (); i++) { | |
219 | if (re sponseList .size() > i) { | |
220 | response .add(respo nseList.ge t(i)); | |
221 | } | |
222 | } | |
223 | if ( !response. isEmpty()) { | |
224 | search Response.s etResponse (response) ; | |
225 | } el se { | |
226 | throw new Generi cException (ErrorMess ages.INVAL ID_REQUEST , "Claim o r Submissi on not fou nd", | |
227 | HttpStatus .NOT_FOUND ); | |
228 | } | |
229 | ||
230 | retu rn searchR esponse; | |
231 | } | |
232 | ||
233 | pr ivate bool ean isNull OrEmpty(St ring str) { | |
234 | retu rn str == null || st r.trim().i sEmpty(); | |
235 | } | |
236 | ||
237 | pr ivate List <RfaiLookU pResponse> assignCla imSubmissi onListData (List<Clai mSubmissio n> cm) { | |
238 | List <RfaiLookU pResponse> responseL ist = new ArrayList< >(); | |
239 | ||
240 | for (ClaimSubm ission cs : cm) { | |
241 | RfaiLo okUpRespon se respons e = new Rf aiLookUpRe sponse(); | |
242 | respon se.setSubm issionId(c s.getSubmi ssionid()) ; | |
243 | respon se.setPdiC laimId(cs. getTrn02cl aimIndex() ); | |
244 | respon se.setPati entName(cs .getHl4nm1 03ptlstnm( ) + ", " + cs.getHl4 nm104ptftn m()); | |
245 | respon se.setStat us(cs.getS ubmissionS tatus()); | |
246 | respon se.setProv iderName(c s.getHl3nm 103svcbill prvnm()); | |
247 | respon se.setProv iderNpi(cs .getHl3nm1 09prvnpi() ); | |
248 | respon se.setProv iderTin(cs .getHl2nm1 09svcprvti n()); | |
249 | respon se.setPati entId(cs.g etHl4nm109 ptid()); | |
250 | respon se.setPati entControl Number(cs. getRef102p tctrlnmbr( )); | |
251 | respon se.setMedi calRecordN umber(cs.g etRef302me drecnmbr() ); | |
252 | if (cs .getDatesu bmitted() != null) { | |
253 | response .setDatesu bmitted(da teFormat.f ormat(cs.g etDatesubm itted())); | |
254 | } | |
255 | if (cs .getDtp203 responsedu edate() != null) { | |
256 | response .setRequir edResponse Date(dateF ormat.form at(cs.getD tp203respo nseduedate ())); | |
257 | } | |
258 | ||
259 | respon seList.add (response) ; | |
260 | } | |
261 | retu rn respons eList; | |
262 | } | |
263 | ||
264 | pr ivate Page Request ge neratePagi nation(Rfa iLookupReq uest rfaiL ookupReque st) { | |
265 | Page Request pa geable; | |
266 | Stri ng sortCol umn = vali dateSort(r faiLookupR equest.get SortColumn ()); | |
267 | if ( rfaiLookup Request.ge tDescendin g()) { | |
268 | pageab le = new P ageRequest (rfaiLooku pRequest.g etPageNumb er().intVa lue() - 1, | |
269 | rfaiLookup Request.ge tPageSize( ).intValue (), Sort.D irection.D ESC, sortC olumn); | |
270 | } el se { | |
271 | pageab le = new P ageRequest (rfaiLooku pRequest.g etPageNumb er().intVa lue() - 1, | |
272 | rfaiLookup Request.ge tPageSize( ).intValue (), Sort.D irection.A SC, sortCo lumn); | |
273 | } | |
274 | retu rn pageabl e; | |
275 | } | |
276 | ||
277 | pr ivate Stri ng validat eSort(Stri ng sortCol umn) { | |
278 | if ( sortColumn != null & & !(sortCo lumn.isEmp ty())) { | |
279 | switch (sortColu mn) { | |
280 | case C laimSubmis sionConsta nts.PROVID ER_NAME: | |
281 | return " hl3nm103sv cbillprvnm "; | |
282 | case C laimSubmis sionConsta nts.PROVID ER_NPI: | |
283 | return " hl3nm109pr vnpi"; | |
284 | case C laimSubmis sionConsta nts.PROVID ER_TIN: | |
285 | return " hl2nm109sv cprvtin"; | |
286 | case C laimSubmis sionConsta nts.PATIEN T_LAST_NAM E: | |
287 | return " hl4nm103pt lstnm"; | |
288 | case C laimSubmis sionConsta nts.PATIEN T_FIRST_NA ME: | |
289 | return " hl4nm104pt ftnm"; | |
290 | case C laimSubmis sionConsta nts.PATIEN T_ID: | |
291 | return " hl4nm109pt id"; | |
292 | case C laimSubmis sionConsta nts.PATIEN T_CONTROL_ NUMBER: | |
293 | return " ref102ptct rlnmbr"; | |
294 | case C laimSubmis sionConsta nts.LINE_I TEM_CONTRO L_NUMBER: | |
295 | return " submission id"; | |
296 | case C laimSubmis sionConsta nts.MEDICA L_RECORD_N UMBER: | |
297 | return " ref302medr ecnmbr"; | |
298 | case C laimSubmis sionConsta nts.DATE_S UBMITTED: | |
299 | return " datesubmit ted"; | |
300 | case C laimSubmis sionConsta nts.REQUIR ED_RESPONS E_DATE: | |
301 | return " dtp203resp onseduedat e"; | |
302 | case C laimSubmis sionConsta nts.PATIEN T_NAME: | |
303 | return " hl4nm103pt lstnm"; | |
304 | case C laimSubmis sionConsta nts.PDI_CL AIM_ID: | |
305 | return " trn02claim Index"; | |
306 | case C laimSubmis sionConsta nts.SUBMIS SION_ID: | |
307 | return C laimSubmis sionConsta nts.SUBMIS SION_ID_DB _COLUMN; | |
308 | case C laimSubmis sionConsta nts.STATUS : | |
309 | return " submission Status"; | |
310 | defaul t: | |
311 | return C laimSubmis sionConsta nts.SUBMIS SION_ID_DB _COLUMN; | |
312 | } | |
313 | } el se { | |
314 | return "submissi onid"; | |
315 | } | |
316 | ||
317 | } | |
318 | ||
319 | @O verride | |
320 | pu blic Gener icResponse getRfaiAd vResults(R faiLookupR equest rfa iLookupReq uest) thro ws Generic Exception { | |
321 | Gene ricRespons e searchRe sponse = n ull; | |
322 | // f ront-end s ometimes s ends "" as requested sortColum n | |
323 | // a nd we need to eventu ally use t he same so rtColumn t o return s earchRespo nse | |
324 | // s etting it here to de fault sort value of submission Id if empt y. | |
325 | if ( isNullOrEm pty(rfaiLo okupReques t.getSortC olumn())) { | |
326 | rfaiLo okupReques t.setSortC olumn("sub missionId" ); | |
327 | } | |
328 | Page Request pa geable = g eneratePag ination(rf aiLookupRe quest); | |
329 | ||
330 | try { | |
331 | boolea n value = checkObjec tNullOrEmp ty(rfaiLoo kupRequest ); | |
332 | if (va lue) { | |
333 | Long cou ntElements = iRfaiRe pository.c ount(new S pecificati on<ClaimSu bmission>( ) { | |
334 | ||
335 | @Override | |
336 | public Pre dicate toP redicate(R oot<ClaimS ubmission> root, Cri teriaQuery <?> query, | |
337 | Crit eriaBuilde r cb) { | |
338 | Li st<Predica te> predic ates = new ArrayList <>(); | |
339 | ||
340 | ge tQueryData (rfaiLooku pRequest, root, cb, predicates ); | |
341 | ||
342 | re turn cb.an d(predicat es.toArray (new Predi cate[0])); | |
343 | } | |
344 | ||
345 | }); | |
346 | int page Number = r faiLookupR equest.get PageNumber (); | |
347 | pageNumb er = reset PageNumber sOnCountEl ements(rfa iLookupReq uest, coun tElements, pageNumbe r); | |
348 | if (coun tElements > 0) { | |
349 | searchResp onse = set GenericJso nResponse( rfaiLookup Request, p ageable, c ountElemen ts, pageNu mber); | |
350 | } else { | |
351 | GenericRes ponse empt yResponse = new Gene ricRespons e(rfaiLook upRequest. getPageNum ber(), | |
352 | rfai LookupRequ est.getPag eSize(), r faiLookupR equest.get SortColumn (), countE lements); | |
353 | return emp tyResponse ; | |
354 | } | |
355 | } else { | |
356 | throw ne w GenericE xception(E rrorMessag es.INVALID _REQUEST, | |
357 | "A t least on e field in formation needs to b e added", HttpStatus .NOT_FOUND ); | |
358 | } | |
359 | ||
360 | } ca tch (Excep tion e) { | |
361 | throw new Generi cException (ErrorMess ages.DATA_ ACCESS_ERR OR, e.getM essage(), | |
362 | HttpStatus .INTERNAL_ SERVER_ERR OR); | |
363 | } | |
364 | retu rn searchR esponse; | |
365 | } | |
366 | ||
367 | pr ivate Gene ricRespons e setGener icJsonResp onse(RfaiL ookupReque st rfaiLoo kupRequest , PageRequ est pageab le, | |
368 | Long c ountElemen ts, int pa geNumber) { | |
369 | Gene ricRespons e searchRe sponse; | |
370 | if ( pageNumber == 0) { | |
371 | List<R faiLookUpR esponse> r esponseLis t = queryS pecificati on(rfaiLoo kupRequest , pageable ); | |
372 | search Response = new Gener icResponse (rfaiLooku pRequest.g etPageNumb er(), rfai LookupRequ est.getPag eSize(), | |
373 | rfaiLookup Request.ge tSortColum n(), count Elements); | |
374 | search Response.s etResponse (responseL ist); | |
375 | ||
376 | } el se { | |
377 | List<R faiLookUpR esponse> r esponseLis t = queryS pecificati on(rfaiLoo kupRequest , pageable ); | |
378 | ||
379 | search Response = new Gener icResponse (rfaiLooku pRequest.g etPageNumb er().intVa lue(), | |
380 | rfaiLookup Request.ge tPageSize( ).intValue (), rfaiLo okupReques t.getSortC olumn(), c ountElemen ts); | |
381 | search Response.s etResponse (responseL ist); | |
382 | } | |
383 | retu rn searchR esponse; | |
384 | } | |
385 | ||
386 | pr ivate int resetPageN umbersOnCo untElement s(RfaiLook upRequest rfaiLookup Request, L ong countE lements, | |
387 | int pa geNumber) { | |
388 | if ( countEleme nts <= (rf aiLookupRe quest.getP ageSize() * rfaiLook upRequest. getPageNum ber())) { | |
389 | Intege r resultCo untIntVal = countEle ments.intV alue(); | |
390 | float pageNumber Float = (f loat) resu ltCountInt Val / (flo at) rfaiLo okupReques t.getPageS ize(); | |
391 | pageNu mber = (in t) Math.ce il(pageNum berFloat); | |
392 | } | |
393 | retu rn pageNum ber; | |
394 | } | |
395 | ||
396 | pr ivate bool ean checkO bjectNullO rEmpty(Rfa iLookupReq uest rfaiL ookupReque st) { | |
397 | retu rn Stream | |
398 | .of(rfai LookupRequ est.getNum ber(), rfa iLookupReq uest.getMe dicalRecor dNumber(), | |
399 | rf aiLookupRe quest.getP atientCont rolNumber( ), rfaiLoo kupRequest .getPatien tfirstName (), | |
400 | rf aiLookupRe quest.getP atientLast Name(), rf aiLookupRe quest.getP roviderNam e(), | |
401 | rf aiLookupRe quest.getP roviderNpi (), rfaiLo okupReques t.getProvi derTin(), | |
402 | rf aiLookupRe quest.getS erviceEndD ate(), rfa iLookupReq uest.getSe rviceStart Date(), | |
403 | rf aiLookupRe quest.getP atientIden tifier()) | |
404 | .filter( t -> t != null).filt er(t -> !( (String) t ).isEmpty( )).findAny ().isPrese nt(); | |
405 | } | |
406 | ||
407 | pr ivate List <RfaiLookU pResponse> querySpec ification( RfaiLookup Request rf aiLookupRe quest, Pag eRequest p ageable) { | |
408 | Page <ClaimSubm ission> cm = (Page<C laimSubmis sion>) iRf aiReposito ry | |
409 | .findAll (new Speci fication<C laimSubmis sion>() { | |
410 | ||
411 | @Override | |
412 | public Pre dicate toP redicate(R oot<ClaimS ubmission> root, Cri teriaQuery <?> query, | |
413 | Crit eriaBuilde r cb) { | |
414 | Li st<Predica te> predic ates = new ArrayList <>(); | |
415 | ||
416 | ge tQueryData (rfaiLooku pRequest, root, cb, predicates ); | |
417 | ||
418 | re turn cb.an d(predicat es.toArray (new Predi cate[0])); | |
419 | } | |
420 | ||
421 | }, pagea ble); | |
422 | ||
423 | retu rn assignD ata(cm); | |
424 | } | |
425 | ||
426 | pr ivate List <RfaiLookU pResponse> assignDat a(Page<Cla imSubmissi on> cm) { | |
427 | List <RfaiLookU pResponse> responseL ist = new ArrayList< >(); | |
428 | ||
429 | for (ClaimSubm ission cs : cm) { | |
430 | RfaiLo okUpRespon se respons e = new Rf aiLookUpRe sponse(); | |
431 | respon se.setSubm issionId(c s.getSubmi ssionid()) ; | |
432 | respon se.setPdiC laimId(cs. getTrn02cl aimIndex() ); | |
433 | respon se.setPati entName(cs .getHl4nm1 03ptlstnm( ) + ", " + cs.getHl4 nm104ptftn m()); | |
434 | respon se.setStat us(cs.getS ubmissionS tatus()); | |
435 | respon se.setProv iderName(c s.getHl3nm 103svcbill prvnm()); | |
436 | respon se.setProv iderNpi(cs .getHl3nm1 09prvnpi() ); | |
437 | respon se.setProv iderTin(cs .getHl2nm1 09svcprvti n()); | |
438 | respon se.setPati entId(cs.g etHl4nm109 ptid()); | |
439 | respon se.setPati entControl Number(cs. getRef102p tctrlnmbr( )); | |
440 | respon se.setMedi calRecordN umber(cs.g etRef302me drecnmbr() ); | |
441 | if (cs .getDatesu bmitted() != null) { | |
442 | response .setDatesu bmitted(da teFormat.f ormat(cs.g etDatesubm itted())); | |
443 | } | |
444 | if (cs .getDtp203 responsedu edate() != null) { | |
445 | response .setRequir edResponse Date(dateF ormat.form at(cs.getD tp203respo nseduedate ())); | |
446 | } | |
447 | ||
448 | respon seList.add (response) ; | |
449 | } | |
450 | retu rn respons eList; | |
451 | } | |
452 | ||
453 | pr ivate void getQueryD ata(RfaiLo okupReques t rfaiLook upRequest, Root<Clai mSubmissio n> root, C riteriaBui lder cb, | |
454 | List<P redicate> predicates ) { | |
455 | ||
456 | Date Format for matter = n ew SimpleD ateFormat( CURRENT_DA TE_FORMAT) ; | |
457 | ||
458 | if ( rfaiLookup Request.ge tNumber() != null && !(rfaiLoo kupRequest .getNumber ().isEmpty ())) { | |
459 | predic ates.add(c b.equal(ro ot.get("tr n02claimIn dex"), rfa iLookupReq uest.getNu mber())); | |
460 | } | |
461 | ||
462 | if ( rfaiLookup Request.ge tProviderN ame() != n ull && !(r faiLookupR equest.get ProviderNa me().isEmp ty())) { | |
463 | predic ates.add(c b.equal(cb .lower(roo t.get("hl3 nm103svcbi llprvnm")) , | |
464 | rfaiLookup Request.ge tProviderN ame().toLo werCase()) ); | |
465 | } | |
466 | ||
467 | if ( rfaiLookup Request.ge tProviderN pi() != nu ll && !(rf aiLookupRe quest.getP roviderNpi ().isEmpty ())) { | |
468 | predic ates.add(c b.equal(cb .lower(roo t.get("hl3 nm109prvnp i")), rfai LookupRequ est.getPro viderNpi() )); | |
469 | } | |
470 | ||
471 | if ( rfaiLookup Request.ge tProviderT in() != nu ll && !(rf aiLookupRe quest.getP roviderTin ().isEmpty ())) { | |
472 | predic ates.add(c b.equal(cb .lower(roo t.get("hl2 nm109svcpr vtin")), r faiLookupR equest.get ProviderTi n())); | |
473 | } | |
474 | ||
475 | if ( rfaiLookup Request.ge tPatientLa stName() ! = null && !(rfaiLook upRequest. getPatient LastName() .isEmpty() )) { | |
476 | predic ates.add(c b.equal(cb .lower(roo t.get("hl4 nm103ptlst nm")), | |
477 | rfaiLookup Request.ge tPatientLa stName().t oLowerCase ())); | |
478 | } | |
479 | ||
480 | if ( rfaiLookup Request.ge tPatientfi rstName() != null && !(rfaiLoo kupRequest .getPatien tfirstName ().isEmpty ())) { | |
481 | predic ates.add(c b.equal(cb .lower(roo t.get("hl4 nm104ptftn m")), | |
482 | rfaiLookup Request.ge tPatientfi rstName(). toLowerCas e())); | |
483 | } | |
484 | ||
485 | if ( rfaiLookup Request.ge tPatientId entifier() != null & & !(rfaiLo okupReques t.getPatie ntIdentifi er().isEmp ty())) { | |
486 | predic ates.add(c b.equal(cb .lower(roo t.get("hl4 nm109ptid" )), | |
487 | rfaiLookup Request.ge tPatientId entifier() .toLowerCa se())); | |
488 | } | |
489 | ||
490 | if ( rfaiLookup Request.ge tPatientCo ntrolNumbe r() != nul l | |
491 | && !(rfa iLookupReq uest.getPa tientContr olNumber() .isEmpty() )) { | |
492 | predic ates.add(c b.equal(cb .lower(roo t.get("ref 102ptctrln mbr")), | |
493 | rfaiLookup Request.ge tPatientCo ntrolNumbe r().toLowe rCase())); | |
494 | } | |
495 | ||
496 | if ( rfaiLookup Request.ge tMedicalRe cordNumber () != null | |
497 | && !(rfa iLookupReq uest.getMe dicalRecor dNumber(). isEmpty()) ) { | |
498 | predic ates.add(c b.equal(cb .lower(roo t.get("ref 302medrecn mbr")), | |
499 | rfaiLookup Request.ge tMedicalRe cordNumber ().toLower Case())); | |
500 | } | |
501 | ||
502 | if ( rfaiLookup Request.ge tServiceSt artDate() != null && !(rfaiLoo kupRequest .getServic eStartDate ().isEmpty ())) { | |
503 | ||
504 | Date b eginServic eDateInDat eType; | |
505 | try { | |
506 | beginSer viceDateIn DateType = formatter .parse(rfa iLookupReq uest.getSe rviceStart Date()); | |
507 | predicat es.add(cb. greaterTha nOrEqualTo (root.get( "dtp103svc frmdt"), b eginServic eDateInDat eType)); | |
508 | } catc h (ParseEx ception e) { | |
509 | e.printS tackTrace( ); | |
510 | } | |
511 | } | |
512 | ||
513 | if ( rfaiLookup Request.ge tServiceEn dDate() != null && ! (rfaiLooku pRequest.g etServiceE ndDate().i sEmpty())) { | |
514 | ||
515 | Date e ndServiceD ateInDateT ype; | |
516 | try { | |
517 | endServi ceDateInDa teType = f ormatter.p arse(rfaiL ookupReque st.getServ iceEndDate ()); | |
518 | Calendar cal = Cal endar.getI nstance(); | |
519 | cal.setT ime(endSer viceDateIn DateType); | |
520 | cal.add( Calendar.H OUR, 24); | |
521 | predicat es.add(cb. lessThanOr EqualTo(ro ot.get("dt p103svctod t"), cal.g etTime())) ; | |
522 | } catc h (ParseEx ception e) { | |
523 | e.printS tackTrace( ); | |
524 | } | |
525 | } | |
526 | } | |
527 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.