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 | CodeAndModifierServiceImpl.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 | CodeAndModifierServiceImpl.java | Fri Mar 29 17:29:16 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 1436 |
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.text.Dat eFormat; | |
7 | import jav a.text.Par seExceptio n; | |
8 | import jav a.text.Sim pleDateFor mat; | |
9 | import jav a.util.Arr ayList; | |
10 | import jav a.util.Dat e; | |
11 | import jav a.util.Lin kedList; | |
12 | import jav a.util.Lis t; | |
13 | ||
14 | import org .apache.lo gging.log4 j.LogManag er; | |
15 | import org .apache.lo gging.log4 j.Logger; | |
16 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
17 | import org .springfra mework.htt p.HttpStat us; | |
18 | import org .springfra mework.ste reotype.Se rvice; | |
19 | import org .springfra mework.uti l.StringUt ils; | |
20 | ||
21 | import gov .va.med.ar s.constant s.ErrorMes sages; | |
22 | import gov .va.med.ar s.dao.ars. HccsCdRepo sitory; | |
23 | import gov .va.med.ar s.dao.ars. ILoincType LookupResp ository; | |
24 | import gov .va.med.ar s.dao.ars. IPayerInfo Repository ; | |
25 | import gov .va.med.ar s.dao.ars. LoincCdRep ository; | |
26 | import gov .va.med.ar s.dao.ars. LoincModCd Repository ; | |
27 | import gov .va.med.ar s.exceptio ns.Generic Exception; | |
28 | import gov .va.med.ar s.model.re quest.Code AndModifie rRequest; | |
29 | import gov .va.med.ar s.model.re quest.Gene ricRequest ; | |
30 | import gov .va.med.ar s.model.re sponse.Cod eAndModifi erResponse ; | |
31 | import gov .va.med.ar s.model.re sponse.Loi ncCodeList Response; | |
32 | import gov .va.med.ar s.service. ICodeAndMo difierServ ice; | |
33 | import gov .va.med.do main.ars.H ccsCd; | |
34 | import gov .va.med.do main.ars.L oincCd; | |
35 | import gov .va.med.do main.ars.L oincModCd; | |
36 | import gov .va.med.do main.ars.L oincTypeLo okup; | |
37 | import gov .va.med.do main.fee.P ayerInfo; | |
38 | ||
39 | /** | |
40 | * @author
|
|
41 | * | |
42 | */ | |
43 | @Service | |
44 | public cla ss CodeAnd ModifierSe rviceImpl implements ICodeAndM odifierSer vice { | |
45 | ||
46 | pr ivate stat ic final S tring DATE _FORMAT_IS _NOT_AS_EX PECTED_MM_ DD_YYYY = "Date form at is not as expecte d MM/dd/yy yy"; | |
47 | pr ivate stat ic final S tring TODA Y_IS_BETWE EN_START_D ATE_AND_EN D_DATE = " Today is b etween sta rt Date an d end Date "; | |
48 | ||
49 | pr ivate stat ic final S tring LOIN C_CD = "lo inccd"; | |
50 | pr ivate stat ic final S tring LOIN C_MOD_CD = "loincmod cd"; | |
51 | pr ivate stat ic final S tring HCCS _CD = "hcc scd"; | |
52 | ||
53 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Code AndModifie rServiceIm pl.class); | |
54 | Da teFormat d ateFormat = new Simp leDateForm at("MM/dd/ yyyy"); | |
55 | @A utowired | |
56 | Lo incCdRepos itory loin cCdReposit ory; | |
57 | ||
58 | @A utowired | |
59 | Lo incModCdRe pository l oincModCdR epository; | |
60 | ||
61 | @A utowired | |
62 | Hc csCdReposi tory hccsC dRepositor y; | |
63 | ||
64 | @A utowired | |
65 | IL oincTypeLo okupRespos itory loin cTypeLooku pRepositor y; | |
66 | ||
67 | ||
68 | /* | |
69 | * (non-Java doc) | |
70 | * | |
71 | * @see | |
72 | * gov.va.me d.ars.serv ice.ICodeA ndModifier Service#ge tCodeAndMo difier(jav a. | |
73 | * lang.Stri ng) | |
74 | * / | |
75 | ||
76 | @O verride | |
77 | pu blic List< ?> getCode AndModifie r(String u rl, List<S tring> cod esToProces s) throws GenericExc eption { | |
78 | List <?> respon seList = n ull; | |
79 | List <Character > enabledV aluesToPro cess = new ArrayList <>(); | |
80 | for (String st r : codesT oProcess) { | |
81 | enable dValuesToP rocess.add (str.charA t(0)); | |
82 | } | |
83 | if ( url.toLowe rCase().co ntains("lo incmod")) { | |
84 | loincM odCdReposi tory.updat eIsActiveO nEndDate() ; | |
85 | List<L oincModCd> loincMdLi st = loinc ModCdRepos itory.find Byisactive InAndIsarc hive(enabl edValuesTo Process, | |
86 | 'N'); | |
87 | respon seList = m apCodesAnd Modifiers( loincMdLis t, LoincMo dCd.class) ; | |
88 | } el se if (url .toLowerCa se().conta ins("loinc ")) { | |
89 | loincC dRepositor y.updateIs ActiveOnEn dDate(); | |
90 | List<L oincCd> lo inCdList = loincCdRe pository.f indByisact iveInAndIs archive(en abledValue sToProcess , 'N'); | |
91 | respon seList = m apCodesAnd Modifiers( loinCdList , LoincCd. class); | |
92 | respon seList = s eperateLis t(response List); | |
93 | } el se if (url .toLowerCa se().conta ins("hccs" )) { | |
94 | hccsCd Repository .updateIsA ctiveOnEnd Date(); | |
95 | List<H ccsCd> hcc sCdList = hccsCdRepo sitory.fin dByisactiv eInAndIsar chive(enab ledValuesT oProcess, 'N'); | |
96 | respon seList = m apCodesAnd Modifiers( hccsCdList , HccsCd.c lass); | |
97 | } el se { | |
98 | throw new Generi cException (ErrorMess ages.NOT_F OUND, "URL not found ", HttpSta tus.NOT_FO UND); | |
99 | } | |
100 | ||
101 | retu rn respons eList; | |
102 | } | |
103 | ||
104 | pr ivate List <?> sepera teList(Lis t<?> respo nseList) { | |
105 | List <LoincCode ListRespon se> loincR esponseLis t = new Ar rayList<>( ); | |
106 | Loin cCodeListR esponse re sponse = n ew LoincCo deListResp onse(); | |
107 | List <CodeAndMo difierResp onse> clai mList = ne w ArrayLis t<>(); | |
108 | List <CodeAndMo difierResp onse> line List = new ArrayList <>(); | |
109 | for (Object ob ject : res ponseList) { | |
110 | CodeAn dModifierR esponse lo incd = (Co deAndModif ierRespons e) object; | |
111 | if (lo incd.getLe vel().equa lsIgnoreCa se("Claim" )) { | |
112 | claimLis t.add(loin cd); | |
113 | } else if (loinc d.getLevel ().equalsI gnoreCase( "Line")) { | |
114 | lineList .add(loinc d); | |
115 | } else { | |
116 | claimLis t.add(loin cd); | |
117 | lineList .add(loinc d); | |
118 | } | |
119 | } | |
120 | resp onse.setCl aimList(cl aimList); | |
121 | resp onse.setLi neList(lin eList); | |
122 | loin cResponseL ist.add(re sponse); | |
123 | retu rn loincRe sponseList ; | |
124 | } | |
125 | ||
126 | pr ivate void setDatesA ndFlag(Dat e startDat e, Date en dDate, Cod eAndModifi erResponse response) { | |
127 | Date Format for matter = n ew SimpleD ateFormat( "MM/dd/yyy y"); | |
128 | Date todayDate = null; | |
129 | try { | |
130 | todayD ate = date Format.par se(dateFor mat.format (new Date( ))); | |
131 | } ca tch (Parse Exception e1) { | |
132 | logger .info("New Date cann ot be pars ed", e1); | |
133 | } | |
134 | if ( startDate != null && endDate ! = null) { | |
135 | // Set the activ e flag acc ordingly | |
136 | try { | |
137 | response .setStartD ate(format ter.format (startDate )); | |
138 | response .setEndDat e(formatte r.format(e ndDate)); | |
139 | if (toda yDate != n ull && tod ayDate.com pareTo(dat eFormat.pa rse(dateFo rmat.forma t(startDat e))) >= 0 | |
140 | && todayDate .compareTo (dateForma t.parse(da teFormat.f ormat(endD ate))) <= 0 | |
141 | && response. isFlag()) { | |
142 | logger.inf o(TODAY_IS _BETWEEN_S TART_DATE_ AND_END_DA TE); | |
143 | response.s etFlag(tru e); | |
144 | } else { | |
145 | response.s etFlag(fal se); | |
146 | } | |
147 | } catc h (ParseEx ception e) { | |
148 | logger.i nfo(DATE_F ORMAT_IS_N OT_AS_EXPE CTED_MM_DD _YYYY, e); | |
149 | } | |
150 | } el se if (sta rtDate != null) { | |
151 | try { | |
152 | response .setStartD ate(format ter.format (startDate )); | |
153 | if (toda yDate != n ull && tod ayDate.com pareTo(dat eFormat.pa rse(dateFo rmat.forma t(startDat e))) >= 0 | |
154 | && response. isFlag()) { | |
155 | response.s etFlag(tru e); | |
156 | } else { | |
157 | response.s etFlag(fal se); | |
158 | } | |
159 | } catc h (ParseEx ception e) { | |
160 | logger.i nfo(DATE_F ORMAT_IS_N OT_AS_EXPE CTED_MM_DD _YYYY, e); | |
161 | } | |
162 | } el se if (end Date != nu ll) { | |
163 | try { | |
164 | response .setEndDat e(formatte r.format(e ndDate)); | |
165 | if (toda yDate != n ull && tod ayDate.com pareTo(dat eFormat.pa rse(dateFo rmat.forma t(endDate) )) <= 0 | |
166 | && response. isFlag()) { | |
167 | response.s etFlag(tru e); | |
168 | } else { | |
169 | response.s etFlag(fal se); | |
170 | } | |
171 | } catc h (ParseEx ception e) { | |
172 | logger.i nfo(DATE_F ORMAT_IS_N OT_AS_EXPE CTED_MM_DD _YYYY, e); | |
173 | } | |
174 | } | |
175 | } | |
176 | ||
177 | pr ivate List <?> mapCod esAndModif iers(List< ?> listToM ap, Class< ?> class1) throws Ge nericExcep tion { | |
178 | List <CodeAndMo difierResp onse> code AndModifie rResponses List = new ArrayList <>(); | |
179 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_CD)) { | |
180 | for (O bject obje ct : listT oMap) { | |
181 | LoincCd loincd = ( LoincCd) o bject; | |
182 | CodeAndM odifierRes ponse resp onse = new CodeAndMo difierResp onse(); | |
183 | response .setCd(loi ncd.getLoi ncId()); | |
184 | response .setStcCd( loincd.get StcloincCd ()); | |
185 | response .setStcCdD esc(loincd .getStcloi ncCdDesc() ); | |
186 | response .setFlag(( loincd.get Isactive() == 'Y' ? true : fal se)); | |
187 | response .setLevel( loincd.get ClaimLineB ridge().ge tIdCd()); | |
188 | Date sta rtDate = l oincd.getS tartdate() ; | |
189 | Date end Date = loi ncd.getEnd date(); | |
190 | setDates AndFlag(st artDate, e ndDate, re sponse); | |
191 | codeAndM odifierRes ponsesList .add(respo nse); | |
192 | } | |
193 | ||
194 | } el se if (cla ss1.getSim pleName(). equalsIgno reCase(LOI NC_MOD_CD) ) { | |
195 | for (O bject obje ct : listT oMap) { | |
196 | LoincMod Cd loinCdM d = (Loinc ModCd) obj ect; | |
197 | CodeAndM odifierRes ponse resp onse = new CodeAndMo difierResp onse(); | |
198 | response .setCd(loi nCdMd.getL oincModId( )); | |
199 | response .setStcCd( loinCdMd.g etStcloinc CdMod()); | |
200 | response .setStcCdD esc(loinCd Md.getStcl oincCdModD esc()); | |
201 | response .setFlag(( loinCdMd.g etIsactive () == 'Y' ? true : f alse)); | |
202 | Date sta rtDate = l oinCdMd.ge tStartdate (); | |
203 | Date end Date = loi nCdMd.getE nddate(); | |
204 | setDates AndFlag(st artDate, e ndDate, re sponse); | |
205 | codeAndM odifierRes ponsesList .add(respo nse); | |
206 | } | |
207 | ||
208 | } el se if (cla ss1.getSim pleName(). equalsIgno reCase(HCC S_CD)) { | |
209 | for (O bject obje ct : listT oMap) { | |
210 | HccsCd h ccdCd = (H ccsCd) obj ect; | |
211 | CodeAndM odifierRes ponse resp onse = new CodeAndMo difierResp onse(); | |
212 | response .setCd(hcc dCd.getHcc sId()); | |
213 | response .setStcCd( hccdCd.get Stchccstat uscatCd()) ; | |
214 | response .setStcCdD esc(hccdCd .getStchcc statuscatC dDesc()); | |
215 | response .setFlag(( hccdCd.get Isactive() == 'Y' ? true : fal se)); | |
216 | Date sta rtDate = h ccdCd.getS tartdate() ; | |
217 | Date end Date = hcc dCd.getEnd date(); | |
218 | setDates AndFlag(st artDate, e ndDate, re sponse); | |
219 | codeAndM odifierRes ponsesList .add(respo nse); | |
220 | } | |
221 | ||
222 | } el se { | |
223 | throw new Generi cException (ErrorMess ages.DATA_ ACCESS_ERR OR, "Inter nal Error occured", | |
224 | HttpStatus .INTERNAL_ SERVER_ERR OR); | |
225 | } | |
226 | retu rn codeAnd ModifierRe sponsesLis t; | |
227 | } | |
228 | ||
229 | @O verride | |
230 | pu blic boole an addOrMo difyCodeAn dModifier( GenericReq uest codeA ndModifier ) throws G enericExce ption { | |
231 | bool ean respon se = false ; | |
232 | if ( codeAndMod ifier.getL oincModLis t() != nul l && !code AndModifie r.getLoinc ModList(). isEmpty()) { | |
233 | respon se = saveC odesAndMod ifiers(cod eAndModifi er.getLoin cModList() , LoincMod Cd.class); | |
234 | } | |
235 | if ( codeAndMod ifier.getL oincList() != null & & !codeAnd Modifier.g etLoincLis t().isEmpt y()) { | |
236 | respon se = saveC odesAndMod ifiers(cod eAndModifi er.getLoin cList(), L oincCd.cla ss); | |
237 | } | |
238 | if ( codeAndMod ifier.getH ccList() ! = null && !codeAndMo difier.get HccList(). isEmpty()) { | |
239 | respon se = saveC odesAndMod ifiers(cod eAndModifi er.getHccL ist(), Hcc sCd.class) ; | |
240 | } | |
241 | retu rn respons e; | |
242 | } | |
243 | ||
244 | pr ivate bool ean saveCo desAndModi fiers(List <?> listTo Map, Class <?> class1 ) { | |
245 | Loin cCd loincC dResponse = null; | |
246 | Loin cModCd loi ncModCdRes ponse = nu ll; | |
247 | Date todayDate = null; | |
248 | try { | |
249 | todayD ate = date Format.par se(dateFor mat.format (new Date( ))); | |
250 | } ca tch (Parse Exception e1) { | |
251 | logger .info("New Date cann ot be pars ed", e1); | |
252 | } | |
253 | Hccs Cd hccsCdR esponse = null; | |
254 | List <LoincType Lookup> lo incTypeRep oResults = loincType LookupRepo sitory.fin dAll(); | |
255 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_CD)) { | |
256 | for (O bject obje ct : listT oMap) { | |
257 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
258 | LoincCd loincCodeD b = null; | |
259 | LoincCd loincCd = new LoincC d(); | |
260 | loincCd. setStcloin cCd(codeAn dModifier. getStcCd() ); | |
261 | loincCd. setStcloin cCdDesc(co deAndModif ier.getStc CdDesc()); | |
262 | loincCd. setDatemod ified(new Date()); | |
263 | if (code AndModifie r.isFlag() ) { | |
264 | loincCd.se tIsactive( 'Y'); | |
265 | } else { | |
266 | loincCd.se tIsactive( 'N'); | |
267 | } | |
268 | for (Loi ncTypeLook up loincty pe : loinc TypeRepoRe sults) { | |
269 | if (loinct ype.getIdC d().equals IgnoreCase (codeAndMo difier.get Level())) { | |
270 | lo incCd.setC laimLineBr idge(loinc type); | |
271 | br eak; | |
272 | } | |
273 | } | |
274 | if (!cod eAndModifi er.isArchi ve()) { | |
275 | loincCd.se tIsarchive ('N'); | |
276 | if (codeAn dModifier. getStartDa te() != nu ll && !(co deAndModif ier.getSta rtDate().i sEmpty()) | |
277 | && c odeAndModi fier.getEn dDate() != null && ! (codeAndMo difier.get EndDate(). isEmpty()) ) { | |
278 | // Set the a ctive flag according ly | |
279 | tr y { | |
280 | loin cCd.setSta rtdate(dat eFormat.pa rse(codeAn dModifier. getStartDa te())); | |
281 | loin cCd.setEnd date(dateF ormat.pars e(codeAndM odifier.ge tEndDate() )); | |
282 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getStar tDate())) >= 0 | |
283 | && today Date.compa reTo(dateF ormat.pars e(codeAndM odifier.ge tEndDate() )) <= 0 | |
284 | && codeA ndModifier .isFlag()) { | |
285 | logger .info(TODA Y_IS_BETWE EN_START_D ATE_AND_EN D_DATE); | |
286 | loincC d.setIsact ive('Y'); | |
287 | } el se { | |
288 | loincC d.setIsact ive('N'); | |
289 | } | |
290 | } catch (Par seExceptio n e) { | |
291 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
292 | } | |
293 | } else if (codeAndMo difier.get StartDate( ) != null && !(codeA ndModifier .getStartD ate().isEm pty())) { | |
294 | tr y { | |
295 | loin cCd.setSta rtdate(dat eFormat.pa rse(codeAn dModifier. getStartDa te())); | |
296 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getStar tDate())) >= 0 | |
297 | && codeA ndModifier .isFlag()) { | |
298 | loincC d.setIsact ive('Y'); | |
299 | } el se { | |
300 | loincC d.setIsact ive('N'); | |
301 | } | |
302 | } catch (Par seExceptio n e) { | |
303 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
304 | } | |
305 | } else if (codeAndMo difier.get EndDate() != null && !(codeAnd Modifier.g etEndDate( ).isEmpty( ))) { | |
306 | tr y { | |
307 | loin cCd.setEnd date(dateF ormat.pars e(codeAndM odifier.ge tEndDate() )); | |
308 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getEndD ate())) <= 0 | |
309 | && codeA ndModifier .isFlag()) { | |
310 | loincC d.setIsact ive('Y'); | |
311 | } el se { | |
312 | loincC d.setIsact ive('N'); | |
313 | } | |
314 | } catch (Par seExceptio n e) { | |
315 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
316 | } | |
317 | } | |
318 | } else { | |
319 | try { | |
320 | if (codeAndM odifier.ge tStartDate () != null && !(code AndModifie r.getStart Date().isE mpty()) | |
321 | && tod ayDate.com pareTo(dat eFormat.pa rse(codeAn dModifier. getStartDa te())) >= 0) { | |
322 | loin cCd.setDat ecreated(d ateFormat. parse(code AndModifie r.getStart Date())); | |
323 | } else { | |
324 | loin cCd.setDat ecreated(n ew Date()) ; | |
325 | } | |
326 | } catch (P arseExcept ion e) { | |
327 | lo gger.info( DATE_FORMA T_IS_NOT_A S_EXPECTED _MM_DD_YYY Y, e); | |
328 | } | |
329 | loincCd.se tEnddate(n ew Date()) ; | |
330 | loincCd.se tIsactive( 'N'); | |
331 | loincCd.se tIsarchive ('Y'); | |
332 | } | |
333 | if (code AndModifie r.getCd() != null || !StringUt ils.isEmpt y(codeAndM odifier.ge tCd())) { | |
334 | loincCodeD b = loincC dRepositor y.findBylo incId(code AndModifie r.getCd()) ; | |
335 | } | |
336 | if (loin cCodeDb == null) { | |
337 | loincCd.se tDatecreat ed(new Dat e()); | |
338 | loincCdRes ponse = lo incCdRepos itory.save (loincCd); | |
339 | } else { | |
340 | loincCd.se tLoincId(l oincCodeDb .getLoincI d()); | |
341 | loincCdRes ponse = lo incCdRepos itory.save (loincCd); | |
342 | } | |
343 | ||
344 | } | |
345 | } | |
346 | ||
347 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_MOD_ CD)) { | |
348 | for (O bject obje ct : listT oMap) { | |
349 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
350 | LoincMod Cd loincCo deModDb = null; | |
351 | LoincMod Cd loincMo dCd = new LoincModCd (); | |
352 | loincMod Cd.setStcl oincCdMod( codeAndMod ifier.getS tcCd()); | |
353 | loincMod Cd.setStcl oincCdModD esc(codeAn dModifier. getStcCdDe sc()); | |
354 | loincMod Cd.setDate modified(n ew Date()) ; | |
355 | if (code AndModifie r.isFlag() ) { | |
356 | loincModCd .setIsacti ve('Y'); | |
357 | } else { | |
358 | loincModCd .setIsacti ve('N'); | |
359 | } | |
360 | if (!cod eAndModifi er.isArchi ve()) { | |
361 | loincModCd .setIsarch ive('N'); | |
362 | if (codeAn dModifier. getStartDa te() != nu ll && !(co deAndModif ier.getSta rtDate().i sEmpty()) | |
363 | && c odeAndModi fier.getEn dDate() != null && ! (codeAndMo difier.get EndDate(). isEmpty()) ) { | |
364 | // Set the a ctive flag according ly | |
365 | tr y { | |
366 | loin cModCd.set Startdate( dateFormat .parse(cod eAndModifi er.getStar tDate())); | |
367 | loin cModCd.set Enddate(da teFormat.p arse(codeA ndModifier .getEndDat e())); | |
368 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getStar tDate())) >= 0 | |
369 | && today Date.compa reTo(dateF ormat.pars e(codeAndM odifier.ge tEndDate() )) <= 0 | |
370 | && codeA ndModifier .isFlag()) { | |
371 | logger .info(TODA Y_IS_BETWE EN_START_D ATE_AND_EN D_DATE); | |
372 | loincM odCd.setIs active('Y' ); | |
373 | } el se { | |
374 | loincM odCd.setIs active('N' ); | |
375 | } | |
376 | } catch (Par seExceptio n e) { | |
377 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
378 | } | |
379 | } else if (codeAndMo difier.get StartDate( ) != null && !(codeA ndModifier .getStartD ate().isEm pty())) { | |
380 | tr y { | |
381 | loin cModCd.set Startdate( dateFormat .parse(cod eAndModifi er.getStar tDate())); | |
382 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getStar tDate())) >= 0 | |
383 | && codeA ndModifier .isFlag()) { | |
384 | loincM odCd.setIs active('Y' ); | |
385 | } el se { | |
386 | loincM odCd.setIs active('N' ); | |
387 | } | |
388 | } catch (Par seExceptio n e) { | |
389 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
390 | } | |
391 | } else if (codeAndMo difier.get EndDate() != null && !(codeAnd Modifier.g etEndDate( ).isEmpty( ))) { | |
392 | tr y { | |
393 | loin cModCd.set Enddate(da teFormat.p arse(codeA ndModifier .getEndDat e())); | |
394 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getEndD ate())) <= 0 | |
395 | && codeA ndModifier .isFlag()) { | |
396 | loincM odCd.setIs active('Y' ); | |
397 | } el se { | |
398 | loincM odCd.setIs active('N' ); | |
399 | } | |
400 | } catch (Par seExceptio n e) { | |
401 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
402 | } | |
403 | } | |
404 | } else { | |
405 | try { | |
406 | if (codeAndM odifier.ge tStartDate () != null && !(code AndModifie r.getStart Date().isE mpty()) | |
407 | && tod ayDate.com pareTo(dat eFormat.pa rse(codeAn dModifier. getStartDa te())) >= 0) { | |
408 | loin cModCd.set Datecreate d(dateForm at.parse(c odeAndModi fier.getSt artDate()) ); | |
409 | } else { | |
410 | loin cModCd.set Datecreate d(new Date ()); | |
411 | } | |
412 | } catch (P arseExcept ion e) { | |
413 | lo gger.info( DATE_FORMA T_IS_NOT_A S_EXPECTED _MM_DD_YYY Y, e); | |
414 | } | |
415 | loincModCd .setEnddat e(new Date ()); | |
416 | loincModCd .setIsacti ve('N'); | |
417 | loincModCd .setIsarch ive('Y'); | |
418 | } | |
419 | ||
420 | if (code AndModifie r.getCd() != null || !StringUt ils.isEmpt y(codeAndM odifier.ge tCd())) { | |
421 | loincCodeM odDb = loi ncModCdRep ository.fi ndByloincM odId(codeA ndModifier .getCd()); | |
422 | } | |
423 | if (loin cCodeModDb == null) { | |
424 | loincModCd .setDatecr eated(new Date()); | |
425 | loincModCd Response = loincModC dRepositor y.saveAndF lush(loinc ModCd); | |
426 | } else { | |
427 | loincModCd .setLoincM odId(loinc CodeModDb. getLoincMo dId()); | |
428 | loincModCd Response = loincModC dRepositor y.save(loi ncModCd); | |
429 | } | |
430 | } | |
431 | } | |
432 | ||
433 | if ( class1.get SimpleName ().equalsI gnoreCase( HCCS_CD)) { | |
434 | for (O bject obje ct : listT oMap) { | |
435 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
436 | HccsCd h ccsCodeDb = null; | |
437 | HccsCd h ccsCd = ne w HccsCd() ; | |
438 | hccsCd.s etStchccst atuscatCd( codeAndMod ifier.getS tcCd()); | |
439 | hccsCd.s etStchccst atuscatCdD esc(codeAn dModifier. getStcCdDe sc()); | |
440 | hccsCd.s etDatemodi fied(new D ate()); | |
441 | if (code AndModifie r.isFlag() ) { | |
442 | hccsCd.set Isactive(' Y'); | |
443 | } else { | |
444 | hccsCd.set Isactive(' N'); | |
445 | } | |
446 | if (!cod eAndModifi er.isArchi ve()) { | |
447 | hccsCd.set Isarchive( 'N'); | |
448 | if (codeAn dModifier. getStartDa te() != nu ll && !(co deAndModif ier.getSta rtDate().i sEmpty()) | |
449 | && c odeAndModi fier.getEn dDate() != null && ! (codeAndMo difier.get EndDate(). isEmpty()) ) { | |
450 | // Set the a ctive flag according ly | |
451 | tr y { | |
452 | hccs Cd.setStar tdate(date Format.par se(codeAnd Modifier.g etStartDat e())); | |
453 | hccs Cd.setEndd ate(dateFo rmat.parse (codeAndMo difier.get EndDate()) ); | |
454 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getStar tDate())) >= 0 | |
455 | && today Date.compa reTo(dateF ormat.pars e(codeAndM odifier.ge tEndDate() )) <= 0 | |
456 | && codeA ndModifier .isFlag()) { | |
457 | logger .info(TODA Y_IS_BETWE EN_START_D ATE_AND_EN D_DATE); | |
458 | hccsCd .setIsacti ve('Y'); | |
459 | } el se { | |
460 | hccsCd .setIsacti ve('N'); | |
461 | } | |
462 | } catch (Par seExceptio n e) { | |
463 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
464 | } | |
465 | } else if (codeAndMo difier.get StartDate( ) != null && !(codeA ndModifier .getStartD ate().isEm pty())) { | |
466 | tr y { | |
467 | hccs Cd.setStar tdate(date Format.par se(codeAnd Modifier.g etStartDat e())); | |
468 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getStar tDate())) >= 0 | |
469 | && codeA ndModifier .isFlag()) { | |
470 | hccsCd .setIsacti ve('Y'); | |
471 | } el se { | |
472 | hccsCd .setIsacti ve('N'); | |
473 | } | |
474 | } catch (Par seExceptio n e) { | |
475 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
476 | } | |
477 | } else if (codeAndMo difier.get EndDate() != null && !(codeAnd Modifier.g etEndDate( ).isEmpty( ))) { | |
478 | tr y { | |
479 | hccs Cd.setEndd ate(dateFo rmat.parse (codeAndMo difier.get EndDate()) ); | |
480 | if ( todayDate. compareTo( dateFormat .parse(cod eAndModifi er.getEndD ate())) <= 0 | |
481 | && codeA ndModifier .isFlag()) { | |
482 | hccsCd .setIsacti ve('Y'); | |
483 | } el se { | |
484 | hccsCd .setIsacti ve('N'); | |
485 | } | |
486 | } catch (Par seExceptio n e) { | |
487 | logg er.info(DA TE_FORMAT_ IS_NOT_AS_ EXPECTED_M M_DD_YYYY, e); | |
488 | } | |
489 | } | |
490 | } else { | |
491 | try { | |
492 | if (codeAndM odifier.ge tStartDate () != null && !(code AndModifie r.getStart Date().isE mpty()) | |
493 | && tod ayDate.com pareTo(dat eFormat.pa rse(codeAn dModifier. getStartDa te())) >= 0) { | |
494 | hccs Cd.setDate created(da teFormat.p arse(codeA ndModifier .getStartD ate())); | |
495 | } else { | |
496 | hccs Cd.setDate created(ne w Date()); | |
497 | } | |
498 | } catch (P arseExcept ion e) { | |
499 | lo gger.info( DATE_FORMA T_IS_NOT_A S_EXPECTED _MM_DD_YYY Y, e); | |
500 | } | |
501 | hccsCd.set Enddate(ne w Date()); | |
502 | hccsCd.set Isactive(' N'); | |
503 | hccsCd.set Isarchive( 'Y'); | |
504 | } | |
505 | if (code AndModifie r.getCd() != null || !StringUt ils.isEmpt y(codeAndM odifier.ge tCd())) { | |
506 | hccsCodeDb = hccsCdR epository. findByhccs Id(codeAnd Modifier.g etCd()); | |
507 | } | |
508 | if (hccs CodeDb == null) { | |
509 | hccsCd.set Datecreate d(new Date ()); | |
510 | logger.inf o("before saving"); | |
511 | hccsCdResp onse = hcc sCdReposit ory.saveAn dFlush(hcc sCd); | |
512 | } else { | |
513 | hccsCd.set HccsId(hcc sCodeDb.ge tHccsId()) ; | |
514 | hccsCdResp onse = hcc sCdReposit ory.save(h ccsCd); | |
515 | } | |
516 | } | |
517 | } | |
518 | retu rn loincCd Response ! = null || loincModCd Response ! = null || hccsCdResp onse != nu ll; | |
519 | } | |
520 | ||
521 | @O verride | |
522 | pu blic List< String> ch eckSubmitt edModifica tionsForDu pes(Generi cRequest c odeAndModi fierReques t) { | |
523 | ||
524 | List <String> r eturnList = new Link edList<>() ; | |
525 | ||
526 | if ( codeAndMod ifierReque st.getLoin cModList() != null & & !codeAnd ModifierRe quest.getL oincModLis t().isEmpt y()) { | |
527 | return List.addAl l(checkCod esAndModif iers(codeA ndModifier Request.ge tLoincModL ist(), Loi ncModCd.cl ass)); | |
528 | } | |
529 | if ( codeAndMod ifierReque st.getLoin cList() != null && ! codeAndMod ifierReque st.getLoin cList().is Empty()) { | |
530 | return List.addAl l(checkCod esAndModif iers(codeA ndModifier Request.ge tLoincList (), LoincC d.class)); | |
531 | } | |
532 | if ( codeAndMod ifierReque st.getHccL ist() != n ull && !co deAndModif ierRequest .getHccLis t().isEmpt y()) { | |
533 | return List.addAl l(checkCod esAndModif iers(codeA ndModifier Request.ge tHccList() , HccsCd.c lass)); | |
534 | } | |
535 | retu rn returnL ist; | |
536 | ||
537 | } | |
538 | ||
539 | pr ivate List <String> c heckCodesA ndModifier s(List<?> listToChec k, Class<? > class1) { | |
540 | ||
541 | List <String> e rrorList = new Linke dList<>(); | |
542 | ||
543 | if ( class1.get SimpleName ().equalsI gnoreCase( HCCS_CD)) { | |
544 | ||
545 | for (O bject obje ct : listT oCheck) { | |
546 | ||
547 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
548 | ||
549 | if (code AndModifie r != null | |
550 | && (codeAndM odifier.ge tCd() == n ull || Str ingUtils.i sEmpty(cod eAndModifi er.getCd() ))) { | |
551 | ||
552 | HccsCd loo kedUpHccsC d = hccsCd Repository .findOneBy Stchccstat uscatCd(co deAndModif ier.getStc Cd()); | |
553 | ||
554 | if (looked UpHccsCd ! = null) { | |
555 | ||
556 | lo gger.warn( String.for mat("Found an alread y existing item for request: % s", | |
557 | codeAn dModifier. toString() )); | |
558 | ||
559 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
560 | ||
561 | } | |
562 | } | |
563 | } | |
564 | } | |
565 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_CD)) { | |
566 | ||
567 | for (O bject obje ct : listT oCheck) { | |
568 | ||
569 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
570 | ||
571 | if (code AndModifie r != null | |
572 | && (codeAndM odifier.ge tCd() == n ull || Str ingUtils.i sEmpty(cod eAndModifi er.getCd() ))) { | |
573 | ||
574 | LoincCd lo okedUpHccs Cd = loinc CdReposito ry.findOne ByStcloinc Cd(codeAnd Modifier.g etStcCd()) ; | |
575 | ||
576 | if (looked UpHccsCd ! = null) { | |
577 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
578 | } | |
579 | } | |
580 | ||
581 | } | |
582 | } | |
583 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_MOD_ CD)) { | |
584 | ||
585 | for (O bject obje ct : listT oCheck) { | |
586 | ||
587 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
588 | ||
589 | if (code AndModifie r != null | |
590 | && (codeAndM odifier.ge tCd() == n ull || Str ingUtils.i sEmpty(cod eAndModifi er.getCd() ))) { | |
591 | ||
592 | LoincModCd lookedUpH ccsCd = lo incModCdRe pository.f indOneBySt cloincCdMo d(codeAndM odifier.ge tStcCd()); | |
593 | ||
594 | if (looked UpHccsCd ! = null) { | |
595 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
596 | } | |
597 | } | |
598 | } | |
599 | } | |
600 | retu rn errorLi st; | |
601 | } | |
602 | ||
603 | pr ivate Stri ng addDupl icateCodeE rror(CodeA ndModifier Request co deAndModif ier, Class <?> class1 ) { | |
604 | ||
605 | Stri ng formalC odeName = null; | |
606 | ||
607 | swit ch (class1 .getSimple Name().toL owerCase() ) { | |
608 | case HCCS_CD: | |
609 | ||
610 | formal CodeName = "HCCS Cod e"; | |
611 | break; | |
612 | case LOINC_CD: | |
613 | ||
614 | formal CodeName = "LOINC Co de"; | |
615 | break; | |
616 | case LOINC_MOD _CD: | |
617 | ||
618 | formal CodeName = "LOINC Mo difier Cod e"; | |
619 | break; | |
620 | defa ult: | |
621 | break; | |
622 | } | |
623 | ||
624 | retu rn String. format("Du plicate Fo und: %s of type %s " , codeAndM odifier.ge tStcCd(), formalCode Name); | |
625 | } | |
626 | ||
627 | @O verride | |
628 | pu blic List< String> ge tArchivedC odes(Gener icRequest codeAndMod ifierReque st) { | |
629 | List <String> r eturnList = new Link edList<>() ; | |
630 | ||
631 | if ( codeAndMod ifierReque st.getLoin cModList() != null & & !codeAnd ModifierRe quest.getL oincModLis t().isEmpt y()) { | |
632 | return List.addAl l( | |
633 | checkCodes AndModifie rsToRemove Archive(co deAndModif ierRequest .getLoincM odList(), LoincModCd .class)); | |
634 | } | |
635 | if ( codeAndMod ifierReque st.getLoin cList() != null && ! codeAndMod ifierReque st.getLoin cList().is Empty()) { | |
636 | return List.addAl l( | |
637 | checkCodes AndModifie rsToRemove Archive(co deAndModif ierRequest .getLoincL ist(), Loi ncCd.class )); | |
638 | } | |
639 | if ( codeAndMod ifierReque st.getHccL ist() != n ull && !co deAndModif ierRequest .getHccLis t().isEmpt y()) { | |
640 | return List.addAl l(checkCod esAndModif iersToRemo veArchive( codeAndMod ifierReque st.getHccL ist(), Hcc sCd.class) ); | |
641 | } | |
642 | retu rn returnL ist; | |
643 | } | |
644 | ||
645 | pr ivate List <String> c heckCodesA ndModifier sToRemoveA rchive(Lis t<?> listT oCheck, Cl ass<?> cla ss1) { | |
646 | ||
647 | List <String> e rrorList = new Linke dList<>(); | |
648 | ||
649 | if ( class1.get SimpleName ().equalsI gnoreCase( HCCS_CD)) { | |
650 | ||
651 | for (O bject obje ct : listT oCheck) { | |
652 | ||
653 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
654 | ||
655 | if (code AndModifie r != null | |
656 | && !(codeAnd Modifier.g etCd() == null || St ringUtils. isEmpty(co deAndModif ier.getCd( )))) { | |
657 | ||
658 | HccsCd loo kedUpHccsC d = hccsCd Repository .findOneBy Stchccstat uscatCd(co deAndModif ier.getStc Cd()); | |
659 | ||
660 | if (looked UpHccsCd ! = null && lookedUpHc csCd.getIs archive() != null | |
661 | && l ookedUpHcc sCd.getIsa rchive().e quals('Y') ) { | |
662 | ||
663 | lo gger.warn( String.for mat("Found an alread y existing item for request: % s", | |
664 | codeAn dModifier. toString() )); | |
665 | ||
666 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
667 | ||
668 | } | |
669 | } | |
670 | } | |
671 | } | |
672 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_CD)) { | |
673 | ||
674 | for (O bject obje ct : listT oCheck) { | |
675 | ||
676 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
677 | ||
678 | if (code AndModifie r != null | |
679 | && !(codeAnd Modifier.g etCd() == null || St ringUtils. isEmpty(co deAndModif ier.getCd( )))) { | |
680 | ||
681 | LoincCd lo okedUpHccs Cd = loinc CdReposito ry.findOne ByStcloinc Cd(codeAnd Modifier.g etStcCd()) ; | |
682 | ||
683 | if (looked UpHccsCd ! = null && lookedUpHc csCd.getIs archive() != null | |
684 | && l ookedUpHcc sCd.getIsa rchive().e quals('Y') ) { | |
685 | ||
686 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
687 | } | |
688 | } | |
689 | ||
690 | } | |
691 | } | |
692 | if ( class1.get SimpleName ().equalsI gnoreCase( LOINC_MOD_ CD)) { | |
693 | ||
694 | for (O bject obje ct : listT oCheck) { | |
695 | ||
696 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
697 | ||
698 | if (code AndModifie r != null | |
699 | && !(codeAnd Modifier.g etCd() == null || St ringUtils. isEmpty(co deAndModif ier.getCd( )))) { | |
700 | ||
701 | LoincModCd lookedUpH ccsCd = lo incModCdRe pository.f indOneBySt cloincCdMo d(codeAndM odifier.ge tStcCd()); | |
702 | ||
703 | if (looked UpHccsCd ! = null && lookedUpHc csCd.getIs archive() != null | |
704 | && l ookedUpHcc sCd.getIsa rchive().e quals('Y') ) { | |
705 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
706 | } | |
707 | } | |
708 | } | |
709 | } | |
710 | retu rn errorLi st; | |
711 | } | |
712 | ||
713 | /* | |
714 | * private S tring getC laimLineBr idgeName(L oincTypeLo okup claim LineBridge ) { | |
715 | * if (claim LineBridge .getId() = = 1) { ret urn "Claim "; } else if | |
716 | * (claimLin eBridge.ge tId() == 2 ) { return "Line"; } else if | |
717 | * (claimLin eBridge.ge tId() == 3 ) { return "Both"; } return nu ll; } | |
718 | * / | |
719 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.