Produced by Araxis Merge on 4/27/2018 2:59:10 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 | v2.0_Sprint_15_Build_5.zip\v2.0_Sprint_15_Build_5\Unredacted\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\service\impl | CodeAndModifierServiceImpl.java | Tue Apr 24 14:50:45 2018 UTC |
| 2 | v2.0_Sprint_15_Build_5..zip\v2.0_Sprint_15_Build_5\Unredacted\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\service\impl | CodeAndModifierServiceImpl.java | Thu Apr 26 16:08:16 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 642 |
| 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.util.Arr ayList; | |
| 7 | import jav a.util.Dat e; | |
| 8 | import jav a.util.Lin kedList; | |
| 9 | import jav a.util.Lis t; | |
| 10 | ||
| 11 | import org .apache.lo gging.log4 j.LogManag er; | |
| 12 | import org .apache.lo gging.log4 j.Logger; | |
| 13 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 14 | import org .springfra mework.htt p.HttpStat us; | |
| 15 | import org .springfra mework.ste reotype.Se rvice; | |
| 16 | import org .springfra mework.uti l.StringUt ils; | |
| 17 | ||
| 18 | import gov .va.med.ar s.constant s.ErrorMes sages; | |
| 19 | import gov .va.med.ar s.dao.ars. HccsCdRepo sitory; | |
| 20 | import gov .va.med.ar s.dao.ars. LoincCdRep ository; | |
| 21 | import gov .va.med.ar s.dao.ars. LoincModCd Repository ; | |
| 22 | import gov .va.med.ar s.exceptio ns.Generic Exception; | |
| 23 | import gov .va.med.ar s.model.re quest.Code AndModifie rRequest; | |
| 24 | import gov .va.med.ar s.model.re quest.Gene ricRequest ; | |
| 25 | import gov .va.med.ar s.model.re sponse.Cod eAndModifi erResponse ; | |
| 26 | import gov .va.med.ar s.service. ICodeAndMo difierServ ice; | |
| 27 | import gov .va.med.do main.ars.H ccsCd; | |
| 28 | import gov .va.med.do main.ars.L oincCd; | |
| 29 | import gov .va.med.do main.ars.L oincModCd; | |
| 30 | ||
| 31 | /** | |
| 32 | * @author PI I
|
|
| 33 | * | |
| 34 | */ | |
| 35 | @Service | |
| 36 | public cla ss CodeAnd ModifierSe rviceImpl implements ICodeAndM odifierSer vice { | |
| 37 | ||
| 38 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Code AndModifie rServiceIm pl.class); | |
| 39 | ||
| 40 | @A utowired | |
| 41 | Lo incCdRepos itory loin cCdReposit ory; | |
| 42 | ||
| 43 | @A utowired | |
| 44 | Lo incModCdRe pository l oincModCdR epository; | |
| 45 | ||
| 46 | @A utowired | |
| 47 | Hc csCdReposi tory hccsC dRepositor y; | |
| 48 | ||
| 49 | /* | |
| 50 | * (non-Java doc) | |
| 51 | * | |
| 52 | * @see | |
| 53 | * gov.va.me d.ars.serv ice.ICodeA ndModifier Service#ge tCodeAndMo difier(jav a. | |
| 54 | * lang.Stri ng) | |
| 55 | * / | |
| 56 | @O verride | |
| 57 | pu blic List< ?> getCode AndModifie r(String U rl, List<S tring> cod esToProces s) throws GenericExc eption { | |
| 58 | List <CodeAndMo difierResp onse> resp onseList = null; | |
| 59 | List <Character > enabledV aluesToPro cess = new ArrayList <>(); | |
| 60 | for( String str : codesTo Process) { | |
| 61 | enable dValuesToP rocess.add (str.charA t(0)); | |
| 62 | } | |
| 63 | if ( Url.toLowe rCase().co ntains("lo incmod")) { | |
| 64 | List<L oincModCd> loincMdLi st = loinc ModCdRepos itory.find Byisactive In(enabled ValuesToPr ocess); | |
| 65 | respon seList = m apCodesAnd Modifiers( loincMdLis t, LoincMo dCd.class) ; | |
| 66 | } el se if (Url .toLowerCa se().conta ins("loinc ")) { | |
| 67 | List<L oincCd> lo inCdList = loincCdRe pository.f indByisact iveIn(enab ledValuesT oProcess); | |
| 68 | respon seList = m apCodesAnd Modifiers( loinCdList , LoincCd. class); | |
| 69 | } el se if (Url .toLowerCa se().conta ins("hccs" )) { | |
| 70 | List<H ccsCd> hcc sCdList = hccsCdRepo sitory.fin dByisactiv eIn(enable dValuesToP rocess); | |
| 71 | respon seList = m apCodesAnd Modifiers( hccsCdList , HccsCd.c lass); | |
| 72 | } el se { | |
| 73 | throw new Generi cException (ErrorMess ages.NOT_F OUND, "URL not found ", HttpSta tus.NOT_FO UND); | |
| 74 | } | |
| 75 | ||
| 76 | retu rn respons eList; | |
| 77 | } | |
| 78 | ||
| 79 | pr ivate List <CodeAndMo difierResp onse> mapC odesAndMod ifiers(Lis t<?> listT oMap, Clas s<?> class 1) | |
| 80 | throws GenericEx ception { | |
| 81 | List <CodeAndMo difierResp onse> code AndModifie rResponses List = new ArrayList <>(); | |
| 82 | if ( class1.get SimpleName ().equalsI gnoreCase( "loinccd") ) { | |
| 83 | for (O bject obje ct : listT oMap) { | |
| 84 | LoincCd loincd = ( LoincCd) o bject; | |
| 85 | CodeAndM odifierRes ponse resp onse = new CodeAndMo difierResp onse(loinc d.getLoinc Id(), | |
| 86 | lo incd.getSt cloincCd() , loincd.g etStcloinc CdDesc(), | |
| 87 | (l oincd.getI sactive() == 'Y' ? t rue : fals e)); | |
| 88 | codeAndM odifierRes ponsesList .add(respo nse); | |
| 89 | } | |
| 90 | ||
| 91 | } el se if (cla ss1.getSim pleName(). equalsIgno reCase("lo incmodcd") ) { | |
| 92 | for (O bject obje ct : listT oMap) { | |
| 93 | LoincMod Cd loinCdM d = (Loinc ModCd) obj ect; | |
| 94 | CodeAndM odifierRes ponse resp onse = new CodeAndMo difierResp onse(loinC dMd.getLoi ncModId(), | |
| 95 | lo inCdMd.get StcloincCd Mod(), loi nCdMd.getS tcloincCdM odDesc(), | |
| 96 | (l oinCdMd.ge tIsactive( ) == 'Y' ? true : fa lse)); | |
| 97 | codeAndM odifierRes ponsesList .add(respo nse); | |
| 98 | } | |
| 99 | ||
| 100 | } el se if (cla ss1.getSim pleName(). equalsIgno reCase("hc cscd")) { | |
| 101 | for (O bject obje ct : listT oMap) { | |
| 102 | HccsCd h ccdCd = (H ccsCd) obj ect; | |
| 103 | CodeAndM odifierRes ponse resp onse = new CodeAndMo difierResp onse(hccdC d.getHccsI d(), | |
| 104 | hc cdCd.getSt chccstatus catCd(), h ccdCd.getS tchccstatu scatCdDesc (), | |
| 105 | (h ccdCd.getI sactive() == 'Y' ? t rue : fals e)); | |
| 106 | codeAndM odifierRes ponsesList .add(respo nse); | |
| 107 | } | |
| 108 | ||
| 109 | } el se { | |
| 110 | throw new Generi cException (ErrorMess ages.DATA_ ACCESS_ERR OR, "Inter nal Error occured", | |
| 111 | HttpStatus .INTERNAL_ SERVER_ERR OR); | |
| 112 | } | |
| 113 | retu rn codeAnd ModifierRe sponsesLis t; | |
| 114 | } | |
| 115 | ||
| 116 | @O verride | |
| 117 | pu blic boole an addOrMo difyCodeAn dModifier( GenericReq uest codeA ndModifier ) throws G enericExce ption { | |
| 118 | bool ean respon se = false ; | |
| 119 | if ( codeAndMod ifier.getL oincModLis t() != nul l && codeA ndModifier .getLoincM odList().s ize() > 0) { | |
| 120 | respon se = saveC odesAndMod ifiers(cod eAndModifi er.getLoin cModList() , LoincMod Cd.class); | |
| 121 | } | |
| 122 | if ( codeAndMod ifier.getL oincList() != null & & codeAndM odifier.ge tLoincList ().size() > 0) { | |
| 123 | respon se = saveC odesAndMod ifiers(cod eAndModifi er.getLoin cList(), L oincCd.cla ss); | |
| 124 | } | |
| 125 | if ( codeAndMod ifier.getH ccList() ! = null && codeAndMod ifier.getH ccList().s ize() > 0) { | |
| 126 | respon se = saveC odesAndMod ifiers(cod eAndModifi er.getHccL ist(), Hcc sCd.class) ; | |
| 127 | } | |
| 128 | retu rn respons e; | |
| 129 | } | |
| 130 | ||
| 131 | pr ivate bool ean saveCo desAndModi fiers(List <?> listTo Map, Class <?> class1 ) { | |
| 132 | Loin cCd loincC dResponse = null; | |
| 133 | Loin cModCd loi ncModCdRes ponse = nu ll; | |
| 134 | Hccs Cd hccsCdR esponse = null; | |
| 135 | if ( class1.get SimpleName ().equalsI gnoreCase( "loinccd") ) { | |
| 136 | for (O bject obje ct : listT oMap) { | |
| 137 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
| 138 | LoincCd loincCodeD b = null; | |
| 139 | LoincCd loincCd = new LoincC d(); | |
| 140 | loincCd. setStcloin cCd(codeAn dModifier. getStcCd() ); | |
| 141 | loincCd. setStcloin cCdDesc(co deAndModif ier.getStc CdDesc()); | |
| 142 | loincCd. setDatemod ified(new Date()); | |
| 143 | if (code AndModifie r.isFlag() ) { | |
| 144 | loincCd.se tIsactive( 'Y'); | |
| 145 | } else { | |
| 146 | loincCd.se tIsactive( 'N'); | |
| 147 | } | |
| 148 | if (code AndModifie r.getCd() != null || !StringUt ils.isEmpt y(codeAndM odifier.ge tCd())) { | |
| 149 | loincCodeD b = loincC dRepositor y.findOne( codeAndMod ifier.getC d()); | |
| 150 | } | |
| 151 | if (loin cCodeDb == null) { | |
| 152 | loincCd.se tDatecreat ed(new Dat e()); | |
| 153 | loincCdRes ponse = lo incCdRepos itory.save (loincCd); | |
| 154 | } else { | |
| 155 | loincCd.se tLoincId(l oincCodeDb .getLoincI d()); | |
| 156 | loincCd.se tDatecreat ed(loincCo deDb.getDa tecreated( )); | |
| 157 | loincCdRes ponse = lo incCdRepos itory.save (loincCd); | |
| 158 | } | |
| 159 | } | |
| 160 | } | |
| 161 | ||
| 162 | if ( class1.get SimpleName ().equalsI gnoreCase( "loincmodc d")) { | |
| 163 | for (O bject obje ct : listT oMap) { | |
| 164 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
| 165 | LoincMod Cd loincCo deModDb = null; | |
| 166 | LoincMod Cd loincMo dCd = new LoincModCd (); | |
| 167 | loincMod Cd.setStcl oincCdMod( codeAndMod ifier.getS tcCd()); | |
| 168 | loincMod Cd.setStcl oincCdModD esc(codeAn dModifier. getStcCdDe sc()); | |
| 169 | loincMod Cd.setDate modified(n ew Date()) ; | |
| 170 | if (code AndModifie r.isFlag() ) { | |
| 171 | loincModCd .setIsacti ve('Y'); | |
| 172 | } else { | |
| 173 | loincModCd .setIsacti ve('N'); | |
| 174 | } | |
| 175 | if (code AndModifie r.getCd() != null || !StringUt ils.isEmpt y(codeAndM odifier.ge tCd())) { | |
| 176 | loincCodeM odDb = loi ncModCdRep ository.fi ndOne(code AndModifie r.getCd()) ; | |
| 177 | } | |
| 178 | if (loin cCodeModDb == null) { | |
| 179 | loincModCd .setDatecr eated(new Date()); | |
| 180 | loincModCd Response = loincModC dRepositor y.saveAndF lush(loinc ModCd); | |
| 181 | } else { | |
| 182 | loincModCd .setLoincM odId(loinc CodeModDb. getLoincMo dId()); | |
| 183 | loincModCd .setDatecr eated(loin cCodeModDb .getDatecr eated()); | |
| 184 | loincModCd Response = loincModC dRepositor y.save(loi ncModCd); | |
| 185 | } | |
| 186 | } | |
| 187 | } | |
| 188 | ||
| 189 | if ( class1.get SimpleName ().equalsI gnoreCase( "hccscd")) { | |
| 190 | for (O bject obje ct : listT oMap) { | |
| 191 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
| 192 | HccsCd h ccsCodeDb = null; | |
| 193 | HccsCd h ccsCd = ne w HccsCd() ; | |
| 194 | hccsCd.s etStchccst atuscatCd( codeAndMod ifier.getS tcCd()); | |
| 195 | hccsCd.s etStchccst atuscatCdD esc(codeAn dModifier. getStcCdDe sc()); | |
| 196 | hccsCd.s etDatemodi fied(new D ate()); | |
| 197 | if (code AndModifie r.isFlag() ) { | |
| 198 | hccsCd.set Isactive(' Y'); | |
| 199 | } else { | |
| 200 | hccsCd.set Isactive(' N'); | |
| 201 | } | |
| 202 | if (code AndModifie r.getCd() != null || !StringUt ils.isEmpt y(codeAndM odifier.ge tCd())) { | |
| 203 | hccsCodeDb = hccsCdR epository. findOne(co deAndModif ier.getCd( )); | |
| 204 | } | |
| 205 | if (hccs CodeDb == null) { | |
| 206 | hccsCd.set Datecreate d(new Date ()); | |
| 207 | hccsCdResp onse = hcc sCdReposit ory.saveAn dFlush(hcc sCd); | |
| 208 | } else { | |
| 209 | hccsCd.set HccsId(hcc sCodeDb.ge tHccsId()) ; | |
| 210 | hccsCd.set Datecreate d(hccsCode Db.getDate created()) ; | |
| 211 | hccsCdResp onse = hcc sCdReposit ory.save(h ccsCd); | |
| 212 | } | |
| 213 | } | |
| 214 | } | |
| 215 | if ( loincCdRes ponse != n ull || loi ncModCdRes ponse != n ull || hcc sCdRespons e != null) { | |
| 216 | return true; | |
| 217 | } | |
| 218 | retu rn false; | |
| 219 | } | |
| 220 | ||
| 221 | @O verride | |
| 222 | pu blic List< String> ch eckSubmitt edModifica tionsForDu pes(Generi cRequest c odeAndModi fierReques t) { | |
| 223 | ||
| 224 | List <String> r eturnList = new Link edList<>() ; | |
| 225 | ||
| 226 | if ( codeAndMod ifierReque st.getLoin cModList() != null & & !codeAnd ModifierRe quest.getL oincModLis t().isEmpt y()) { | |
| 227 | return List.addAl l(checkCod esAndModif iers(codeA ndModifier Request.ge tLoincModL ist(), Loi ncModCd.cl ass)); | |
| 228 | } | |
| 229 | if ( codeAndMod ifierReque st.getLoin cList() != null && ! codeAndMod ifierReque st.getLoin cList().is Empty()) { | |
| 230 | return List.addAl l(checkCod esAndModif iers(codeA ndModifier Request.ge tLoincList (), LoincC d.class)); | |
| 231 | } | |
| 232 | if ( codeAndMod ifierReque st.getHccL ist() != n ull && !co deAndModif ierRequest .getHccLis t().isEmpt y()) { | |
| 233 | return List.addAl l(checkCod esAndModif iers(codeA ndModifier Request.ge tHccList() , HccsCd.c lass)); | |
| 234 | } | |
| 235 | retu rn returnL ist; | |
| 236 | ||
| 237 | } | |
| 238 | ||
| 239 | pr ivate List <String> c heckCodesA ndModifier s(List<?> listToChec k, Class<? > class1) { | |
| 240 | ||
| 241 | List <String> e rrorList = new Linke dList<>(); | |
| 242 | ||
| 243 | if ( class1.get SimpleName ().equalsI gnoreCase( "hccscd")) { | |
| 244 | ||
| 245 | for (O bject obje ct : listT oCheck) { | |
| 246 | ||
| 247 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
| 248 | ||
| 249 | if (code AndModifie r != null | |
| 250 | && (codeAndM odifier.ge tCd() == n ull || Str ingUtils.i sEmpty(cod eAndModifi er.getCd() ))) { | |
| 251 | ||
| 252 | HccsCd loo kedUpHccsC d = hccsCd Repository .findOneBy Stchccstat uscatCd(co deAndModif ier.getStc Cd()); | |
| 253 | ||
| 254 | if (looked UpHccsCd ! = null) { | |
| 255 | ||
| 256 | lo gger.warn( String.for mat("Found an alread y existing item for request: % s", | |
| 257 | codeAn dModifier. toString() )); | |
| 258 | ||
| 259 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
| 260 | ||
| 261 | } | |
| 262 | } | |
| 263 | } | |
| 264 | } | |
| 265 | if ( class1.get SimpleName ().equalsI gnoreCase( "loinccd") ) { | |
| 266 | ||
| 267 | for (O bject obje ct : listT oCheck) { | |
| 268 | ||
| 269 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
| 270 | ||
| 271 | if (code AndModifie r != null | |
| 272 | && (codeAndM odifier.ge tCd() == n ull || Str ingUtils.i sEmpty(cod eAndModifi er.getCd() ))) { | |
| 273 | ||
| 274 | LoincCd lo okedUpHccs Cd = loinc CdReposito ry.findOne ByStcloinc Cd(codeAnd Modifier.g etStcCd()) ; | |
| 275 | ||
| 276 | if (looked UpHccsCd ! = null) { | |
| 277 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
| 278 | } | |
| 279 | } | |
| 280 | ||
| 281 | } | |
| 282 | } | |
| 283 | if ( class1.get SimpleName ().equalsI gnoreCase( "loincmodc d")) { | |
| 284 | ||
| 285 | for (O bject obje ct : listT oCheck) { | |
| 286 | ||
| 287 | CodeAndM odifierReq uest codeA ndModifier = (CodeAn dModifierR equest) ob ject; | |
| 288 | ||
| 289 | if (code AndModifie r != null | |
| 290 | && (codeAndM odifier.ge tCd() == n ull || Str ingUtils.i sEmpty(cod eAndModifi er.getCd() ))) { | |
| 291 | ||
| 292 | LoincModCd lookedUpH ccsCd = lo incModCdRe pository.f indOneBySt cloincCdMo d(codeAndM odifier.ge tStcCd()); | |
| 293 | ||
| 294 | if (looked UpHccsCd ! = null) { | |
| 295 | er rorList.ad d(addDupli cateCodeEr ror(codeAn dModifier, class1)); | |
| 296 | } | |
| 297 | } | |
| 298 | } | |
| 299 | } | |
| 300 | retu rn errorLi st; | |
| 301 | } | |
| 302 | ||
| 303 | pr ivate Stri ng addDupl icateCodeE rror(CodeA ndModifier Request co deAndModif ier, Class <?> class1 ) { | |
| 304 | ||
| 305 | Stri ng formalC odeName = null; | |
| 306 | ||
| 307 | swit ch (class1 .getSimple Name().toL owerCase() ) { | |
| 308 | case "hccscd": | |
| 309 | formal CodeName = "HCCS Cod e"; | |
| 310 | break; | |
| 311 | case "loinccd" : | |
| 312 | formal CodeName = "LOINC Co de"; | |
| 313 | break; | |
| 314 | case "loincmod cd": | |
| 315 | formal CodeName = "LOINC Mo difier Cod e"; | |
| 316 | break; | |
| 317 | } | |
| 318 | ||
| 319 | retu rn String. format("Du plicate Fo und: %s of type %s " , codeAndM odifier.ge tStcCd(), formalCode Name); | |
| 320 | } | |
| 321 | ||
| 322 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.