Produced by Araxis Merge on 3/24/2017 5:17:19 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 | MHV_2017.2.0.0 Code In Flight.zip\National Portal\mhv_user\mhv-usermgmt-portal-main\src\main\bkup\gov\va\med\mhv\usermgmt\integration\service\impl | PatientIdentityServiceImpl.java | Thu Feb 11 17:12:08 2016 UTC |
| 2 | MHV_2017.2.0.0 Code In Flight.zip\National Portal\mhv_user\mhv-usermgmt-portal-main\src\main\bkup\gov\va\med\mhv\usermgmt\integration\service\impl | PatientIdentityServiceImpl.java | Fri Mar 24 20:42:08 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1770 |
| 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.m hv.usermgm t.integrat ion.servic e.impl; | |
| 5 | ||
| 6 | import gov .va.med.mh v.core.mes sages.Mess agesString Builder; | |
| 7 | import gov .va.med.mh v.core.uti l.PatientC orrelation StatusUtil s; | |
| 8 | import gov .va.med.mh v.core.uti l.Precondi tion; | |
| 9 | import gov .va.med.mh v.core.uti l.ServiceR esponseUti ls; | |
| 10 | import gov .va.med.mh v.integrat ion.phr.se rvice.Serv iceRespons e; | |
| 11 | import gov .va.med.mh v.integrat ion.regist ry.transfe r.Facility ; | |
| 12 | import gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient; | |
| 13 | import gov .va.med.mh v.integrat ion.regist ry.transfe r.Personal Info; | |
| 14 | import gov .va.med.mh v.integrat ion.regist ry.transfe r.Status; | |
| 15 | import gov .va.med.mh v.integrat ion.regist ry.transfe r.StatusTy pe; | |
| 16 | import gov .va.med.mh v.usermgmt .bizobj.Fa cilityInfo BO; | |
| 17 | import gov .va.med.mh v.usermgmt .bizobj.Us erProfileB O; | |
| 18 | import gov .va.med.mh v.usermgmt .common.Me ssagesSet; | |
| 19 | import gov .va.med.mh v.usermgmt .common.Se rviceFacto ry; | |
| 20 | import gov .va.med.mh v.usermgmt .enumerati on.Activit yActorType Enumeratio n; | |
| 21 | import gov .va.med.mh v.usermgmt .enumerati on.Authent icationSta tus; | |
| 22 | import gov .va.med.mh v.usermgmt .enumerati on.Patient Correlatio nStatus; | |
| 23 | import gov .va.med.mh v.usermgmt .integrati on.service .PatientId entityServ ice; | |
| 24 | import gov .va.med.mh v.usermgmt .service.P atientServ iceRespons e; | |
| 25 | import gov .va.med.mh v.usermgmt .service.U serProfile Service; | |
| 26 | import gov .va.med.mh v.usermgmt .transfer. InPersonAu thenticati on; | |
| 27 | import gov .va.med.mh v.usermgmt .transfer. UserProfil e; | |
| 28 | import gov .va.med.mh v.usermgmt .transfer. UserProfil eDeactivat ionReason; | |
| 29 | ||
| 30 | import jav a.util.Arr ayList; | |
| 31 | import jav a.util.Cal endar; | |
| 32 | import jav a.util.Dat e; | |
| 33 | import jav a.util.Lis t; | |
| 34 | ||
| 35 | import org .apache.co mmons.lang .StringUti ls; | |
| 36 | import org .apache.co mmons.logg ing.Log; | |
| 37 | import org .apache.co mmons.logg ing.LogFac tory; | |
| 38 | ||
| 39 | ||
| 40 | /** | |
| 41 | * Adapts the integr ation Pati entIdentit yService ( EJB) inter face to th e | |
| 42 | * interna l business service i nterface ( POJO). | |
| 43 | * The Pat ientIdenti tyService uses an in terface wi th service | |
| 44 | * respons es, just l ike the ge nerated At las servic es, | |
| 45 | * whereas the Patie ntIdentity Bean defin es its own . | |
| 46 | * This ad apter conv erts betwe en the two different interface s. | |
| 47 | * The ada pter trans lates the messages f rom the At las like s ervice to | |
| 48 | * the int erfaces of the EJB. | |
| 49 | * @author
|
|
| 50 | * | |
| 51 | */ | |
| 52 | public cla ss Patient IdentitySe rviceImpl implements PatientId entityServ ice { | |
| 53 | ||
| 54 | ||
| 55 | privat e static f inal Log L OG = LogFa ctory.getL og( | |
| 56 | Pa tientIdent ityService Impl.class ); | |
| 57 | ||
| 58 | /* (no n-Javadoc) | |
| 59 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 60 | * Pat ientIdenti tyServiceR emote#getP atientForI CN(java.la ng.String) | |
| 61 | */ | |
| 62 | public Patient g etPatientF orICN(Stri ng icn) { | |
| 63 | Pr econdition .assertNot Blank("icn ", icn); | |
| 64 | Pa tientServi ceResponse response = getPatie ntByIcn(ic n); | |
| 65 | re turn (resp onse.getPa tient() != null) | |
| 66 | ? Regist ryInterfac eUtils.toP atient(res ponse.getP atient()) | |
| 67 | : null; | |
| 68 | } | |
| 69 | ||
| 70 | /* (no n-Javadoc) | |
| 71 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 72 | * Pat ientIdenti tyServiceR emote#fina lizeCorrel ation( | |
| 73 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, | |
| 74 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Status) | |
| 75 | */ | |
| 76 | public Status fi nalizeCorr elation(Pa tient pati ent, Statu s status) { | |
| 77 | Pr econdition .assertNot Null("pati ent", pati ent); | |
| 78 | fi nal String operation = "Finali ze correla tion"; | |
| 79 | if (LOG.isDe bugEnabled ()) { | |
| 80 | LOG.debu g(operatio n + " of " + describ e(patient) + | |
| 81 | " wh ere MPI st atus is " + describe (status)); | |
| 82 | } | |
| 83 | Pa tientServi ceResponse response = getPatie nt(patient ); | |
| 84 | if (response .getPatien t() == nul l) { | |
| 85 | status = createPat ientDoesNo tExistStat us(); | |
| 86 | } else if (! PatientCor relationSt atusUtils. isPendingC orrelation ( | |
| 87 | respon se.getPati ent())) | |
| 88 | { | |
| 89 | status = createPat ientNotPen dingCorrel ationRespo nse(); | |
| 90 | } else { | |
| 91 | String e rror = get Error(stat us); | |
| 92 | // store if patien t was pend ing synchr onization, because | |
| 93 | // final izeCorrela tion will remove thi s record | |
| 94 | boolean wasPending Synchroniz ation = is PendingSyn chronizati on( | |
| 95 | resp onse.getPa tient()); | |
| 96 | handleMe ssages(get PatientSer vice().fin alizeCorre lation(res ponse. | |
| 97 | getP atient(), error)); | |
| 98 | status = finalizeA uthenticat ion(respon se.getPati ent(), err or, | |
| 99 | wasP endingSync hronizatio n); | |
| 100 | } | |
| 101 | lo gStatus(op eration, p atient, st atus); | |
| 102 | re turn statu s; | |
| 103 | } | |
| 104 | ||
| 105 | privat e Status f inalizeAut henticatio n( | |
| 106 | go v.va.med.m hv.usermgm t.transfer .Patient p atient, St ring error , | |
| 107 | bo olean wasP endingSync hronizatio n) | |
| 108 | { | |
| 109 | In PersonAuth entication ipa = get IPA(patien t); | |
| 110 | if (ipa == n ull) { | |
| 111 | return c reatePatie ntIsNotPen dingAuthen ticationSt atus(); | |
| 112 | } | |
| 113 | if (InPerson Authentica tionStatus Utils.isAu thenticate d(ipa)) { | |
| 114 | // NOTE: This scen ario shoul d eventual ly go away , | |
| 115 | // when all patien t authenti cated befo re introdu ction | |
| 116 | // of th e MPI sync hronizatio n feature are correl ated | |
| 117 | if (!was PendingSyn chronizati on) { | |
| 118 | retu rn createP atientIsNo tPendingSy nchronizat ionStatus( ); | |
| 119 | } // els e: Nothing else to d o; already authentic ated | |
| 120 | } else if (! InPersonAu thenticati onStatusUt ils. | |
| 121 | isPe ndingAuthe ntication( ipa)) | |
| 122 | { | |
| 123 | return c reatePatie ntIsNotPen dingAuthen ticationSt atus(); | |
| 124 | } else { | |
| 125 | handleMe ssages(get IPAService ().finaliz eAuthentic ation(ipa, error)); | |
| 126 | } | |
| 127 | re turn Regis tryInterfa ceUtils.cr eateOkStat us(); | |
| 128 | } | |
| 129 | ||
| 130 | privat e InPerson Authentica tion getIP A( | |
| 131 | go v.va.med.m hv.usermgm t.transfer .Patient p atient) | |
| 132 | { | |
| 133 | In PersonAuth entication Service ip aService = getIPASer vice(); | |
| 134 | In PersonAuth entication ServiceRes ponse ipaS erviceResp onse = | |
| 135 | ipaServi ce.getAuth entication ForPatient (patient.g etId()); | |
| 136 | ha ndleMessag es(ipaServ iceRespons e); | |
| 137 | re turn ipaSe rviceRespo nse.getInP ersonAuthe ntication( ); | |
| 138 | } | |
| 139 | ||
| 140 | privat e boolean isPendingS ynchroniza tion( | |
| 141 | go v.va.med.m hv.usermgm t.transfer .Patient p atient) | |
| 142 | { | |
| 143 | re turn (pati ent != nul l) | |
| 144 | && (pati ent.getPat ientSynchr onizations () != null ) | |
| 145 | && !pati ent.getPat ientSynchr onizations ().isEmpty (); | |
| 146 | } | |
| 147 | ||
| 148 | /* (no n-Javadoc) | |
| 149 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 150 | * Pat ientIdenti tyServiceR emote#fina lizeUncorr elation( | |
| 151 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, | |
| 152 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Status) | |
| 153 | */ | |
| 154 | public Status fi nalizeUnco rrelation( Patient pa tient, Sta tus status ) { | |
| 155 | Pr econdition .assertNot Null("pati ent", pati ent); | |
| 156 | Pr econdition .assertNot Empty("pat ient.getIc n()", pati ent.getIcn ()); | |
| 157 | fi nal String operation = "Finali ze uncorre lation"; | |
| 158 | if (LOG.isDe bugEnabled ()) { | |
| 159 | LOG.debu g(operatio n + " of " + describ e(patient) | |
| 160 | + " where MPI status is " + descr ibe(status )); | |
| 161 | } | |
| 162 | Pa tientServi ceResponse response = getPatie ntByIcn(pa tient.getI cn()); | |
| 163 | if (response .getPatien t() == nul l) { | |
| 164 | status = createPat ientDoesNo tExistStat us(); | |
| 165 | } else if (! PatientCor relationSt atusUtils. isPendingU ncorrelati on( | |
| 166 | response .getPatien t())) | |
| 167 | { | |
| 168 | status = createPat ientNotPen dingUncorr elationRes ponse(); | |
| 169 | } else { | |
| 170 | InPerson Authentica tion ipa = getIPA(re sponse.get Patient()) ; | |
| 171 | if (ipa == null) { | |
| 172 | stat us = creat ePatientIs NotPending Authentica tionStatus (); | |
| 173 | } else { | |
| 174 | Stri ng error = getError( status); | |
| 175 | hand leMessages (getPatien tService() .finalizeU ncorrelati on( | |
| 176 | response.g etPatient( ), error)) ; | |
| 177 | hand leMessages (getIPASer vice().fin alizeUnaut henticatio n(ipa, | |
| 178 | error)); | |
| 179 | stat us = Regis tryInterfa ceUtils.cr eateOkStat us(); | |
| 180 | } | |
| 181 | } | |
| 182 | ||
| 183 | lo gStatus(op eration, p atient, st atus); | |
| 184 | re turn statu s; | |
| 185 | } | |
| 186 | ||
| 187 | /* (no n-Javadoc) | |
| 188 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 189 | * Pat ientIdenti tyServiceR emote#upda teFaciliti es( | |
| 190 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, | |
| 191 | * jav a.util.Arr ayList) | |
| 192 | */ | |
| 193 | public Status up dateFacili ties(Patie nt patient , | |
| 194 | Ar rayList<Fa cility> fa cilities) | |
| 195 | { | |
| 196 | Pr econdition .assertNot Null("pati ent", pati ent); | |
| 197 | Pr econdition .assertNot Empty("pat ient.getIc n()", pati ent.getIcn ()); | |
| 198 | Pr econdition .assertNot Null("faci lities", f acilities) ; | |
| 199 | fi nal String operation = "Update facilitie s"; | |
| 200 | if (LOG.isDe bugEnabled ()) { | |
| 201 | LOG.debu g(operatio n + " of " + describe (patient) + " to " | |
| 202 | + de scribe(fac ilities)); | |
| 203 | } | |
| 204 | St atus statu s = null; | |
| 205 | Pa tientServi ceResponse response = getPatie ntByIcn(pa tient.getI cn()); | |
| 206 | if (response .getPatien t() != nul l) { | |
| 207 | Registry InterfaceU tils.setFa cilities(r esponse.ge tPatient() , | |
| 208 | faci lities); | |
| 209 | //Jazz E nhancement # 29539: Instead of unknown e xception, more descr iptions ar e added fo r the prod uction sup port. | |
| 210 | status = updatePat ient("MFN_ M05 Patien t location master fi le Process :Updating Patient wi th ICN:" + | |
| 211 | resp onse.getPa tient().ge tIcn()+" w ith updati ng: " + de scribe(fac ilities) + ". ", res ponse.getP atient()); | |
| 212 | } else { | |
| 213 | status = createPat ientDoesNo tExistStat us(); | |
| 214 | } | |
| 215 | ||
| 216 | lo gStatus(op eration, p atient, st atus); | |
| 217 | ||
| 218 | re turn statu s; | |
| 219 | } | |
| 220 | ||
| 221 | ||
| 222 | /* (no n-Javadoc) | |
| 223 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 224 | * Pat ientIdenti tyServiceR emote#upda tePersonal Info( | |
| 225 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, | |
| 226 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Personal Info) | |
| 227 | */ | |
| 228 | public Status up datePerson alInfo(Pat ient patie nt, Person alInfo per sonalInfo) | |
| 229 | { | |
| 230 | Pr econdition .assertNot Null("pati ent", pati ent); | |
| 231 | Pr econdition .assertNot Empty("pat ient.getIc n()", pati ent.getIcn ()); | |
| 232 | Pr econdition .assertNot Null("pers onalInfo", personalI nfo); | |
| 233 | fi nal String operation = "Update personal info"; | |
| 234 | if (LOG.isDe bugEnabled ()) { | |
| 235 | LOG.debu g(operatio n + " of " + describ e(patient) + " to " | |
| 236 | + de scribe(per sonalInfo) ); | |
| 237 | } | |
| 238 | ||
| 239 | Pa tientServi ceResponse response = getPatie ntByIcn(pa tient.getI cn()); | |
| 240 | ||
| 241 | // JAZZ Defec t# 20309: If there f our or mor e traits u pdate, DO NOT Update the user and return reject to MVI | |
| 242 | if (isFourOrM oreTraitsU pdate(resp onse.getPa tient(), p ersonalInf o)) { | |
| 243 | User Profile us erProfile = response .getPatien t().getUse rProfile() ; | |
| 244 | if (LOG. isDebugEna bled()) { | |
| 245 | LOG. debug("Pat ientIdenti tyService. updatePers onalInfo() for four or more tr aits updat e from MVI for user: " + userPr ofile.getI d() + ":Se nding Reje ct back to MVI"); | |
| 246 | } | |
| 247 | ||
| 248 | UserProf ileDeactiv ationReaso n reason = | |
| 249 | getD eactReason (UserProfi leDeactiva tionUtils. A31_POSSIB LE_ICN_MIS MATCH_DO_N OT_REACTIV ATE_NAME); | |
| 250 | response = deactiv atePatient ForMultiTr aitUpdateE rror( | |
| 251 | resp onse.getPa tient(), " ", reason, | |
| 252 | "A31 possible ICN Mismat ch (do not reactivat e)"); | |
| 253 | retu rn Registr yInterface Utils.crea teErrorSta tus("Four or more tr aits updat e from MVI "); | |
| 254 | } | |
| 255 | ||
| 256 | St atus statu s = null; | |
| 257 | if (response .getPatien t() != nul l) { | |
| 258 | Registry InterfaceU tils.setPe rsonalInfo (response. getPatient (), | |
| 259 | pers onalInfo); | |
| 260 | //Jazz E nhancement # 29539: Instead of unknown e xception, more descr iptions ar e added fo r the prod uction sup port. This is for fa cility upd ate. | |
| 261 | status = updatePat ient("ADT_ A31 Update person in formation Process fo r patient icn:" + re sponse.get Patient(). getIcn(), response.g etPatient( )); | |
| 262 | } else { | |
| 263 | status = createPat ientDoesNo tExistStat us(); | |
| 264 | } | |
| 265 | lo gStatus(op eration, p atient, st atus); | |
| 266 | re turn statu s; | |
| 267 | } | |
| 268 | ||
| 269 | public UserProfi leDeactiva tionReason getDeactR eason(Stri ng name) { | |
| 270 | re turn getUs erProfileS ervice().f indDeactiv ationReaso n(name).ge tUserProfi leDeactiva tionReason (); | |
| 271 | } | |
| 272 | ||
| 273 | //JAZZ # 128617: MVI A43 M ove messag e processi ng. | |
| 274 | public Status de activatePa tient(Pati ent pat, S tring refe renceId, S tring reas on, String deactivat ionNote) { | |
| 275 | Pa tientServi ceResponse response = getPatie ntByIcn(pa t.getIcn() ); | |
| 276 | go v.va.med.m hv.usermgm t.transfer .Patient p atient = r esponse.ge tPatient() ; | |
| 277 | Us erProfileD eactivatio nReason de actReason = getDeact Reason(rea son); | |
| 278 | deac tivatePati entForMult iTraitUpda teError(pa tient, ref erenceId, deactReaso n, deactiv ationNote) ; | |
| 279 | retu rn Registr yInterface Utils.crea teOkStatus (); | |
| 280 | } | |
| 281 | ||
| 282 | //JAZZ # 128617: MVI A43 M ove messag e processi ng. | |
| 283 | public Status de activatePa tientOld(P atient pat , String r eferenceId , String r eason, Str ing deacti vationNote ) { | |
| 284 | Pr econdition .assertNot Null("pati ent", pat) ; | |
| 285 | Pr econdition .assertNot Empty("pat ient.getIc n()", pat. getIcn()); | |
| 286 | fi nal String operation = "Deacti vate Patie nt"; | |
| 287 | if (LOG.isDe bugEnabled ()) { | |
| 288 | LOG.debu g(operatio n + " of " + describ e(pat)); | |
| 289 | } | |
| 290 | ||
| 291 | System.out .println(" ********** ******** K en So **** ********** **** Patie ntIdentity ServiceImp l.deactiva tePatient( )"); | |
| 292 | ||
| 293 | Pa tientServi ceResponse response = getPatie ntByIcn(pa t.getIcn() ); | |
| 294 | ||
| 295 | go v.va.med.m hv.usermgm t.transfer .Patient p atient = r esponse.ge tPatient() ; | |
| 296 | ||
| 297 | if (patient = = null) { | |
| 298 | retu rn Registr yInterface Utils.crea teErrorSta tus("Patie nt Not Fou nd"); | |
| 299 | } | |
| 300 | ||
| 301 | In PersonAuth entication ipa = | |
| 302 | getI PAService( ).getAuthe nticationF orPatient( patient.ge tId()).get InPersonAu thenticati on(); | |
| 303 | if (LOG.isDe bugEnabled ()) { | |
| 304 | LOG.debu g("Patient IdentitySe rvice.deac tivatePati ent()unaut henticate for user:" + patient .getUserPr ofile().ge tId()); | |
| 305 | } | |
| 306 | ||
| 307 | if(i pa.getStat us() == Au thenticati onStatus.g etEnum(Aut henticatio nStatus.AU THENTICATE D)) { | |
| 308 | InPerson Authentica tionServic eResponse ipaService Response = getIPASer vice().una uthenticat e(ipa); | |
| 309 | ||
| 310 | if(ipaSe rviceRespo nse.getInP ersonAuthe ntication( ).getStatu s() != Aut henticatio nStatus.ge tEnum(Auth entication Status.UNA UTHENTICAT ED)) { | |
| 311 | Audi tor.auditM viUnauthen ticateEven t(patient. getUserPro file().get Id(), Acti vityActorT ypeEnumera tion.SYSTE M, false); | |
| 312 | } else { | |
| 313 | System.out .println(" ********** ******** K en So **** ********** **** Patie ntIdentity Service.de activatePa tient()una uthenticat e for user :" + patie nt.getUser Profile(). getId() + ":SUCCESS" ); | |
| 314 | Audi tor.auditM viUnauthen ticateEven t(patient. getUserPro file().get Id(), Acti vityActorT ypeEnumera tion.SYSTE M, true); | |
| 315 | } | |
| 316 | } | |
| 317 | ||
| 318 | if (patient.g etCorrelat ionStatus( ) == Patie ntCorrelat ionStatus. getEnum(Pa tientCorre lationStat us.CORRELA TED)) { | |
| 319 | if (LOG. isDebugEna bled()) { | |
| 320 | LOG. debug("Pat ientIdenti tyService. deactivate Patient()u ncorrelate for user: " + patien t.getUserP rofile().g etId()); | |
| 321 | } | |
| 322 | Pati entService Response m viSyncServ iceRespons e = | |
| 323 | Servic eFactory.c reateMviIn tegrationS ervice().d eletePerso nFromCorre lationForH elpDesk( | |
| 324 | patient, p atient.get UserProfil e(), "SYST EM"); | |
| 325 | if(mviSy ncServiceR esponse.ge tPatient() .getCorrel ationStatu s() != Pa tientCorre lationStat us.getEnum (PatientCo rrelationS tatus.UNCO RRELATED)) { | |
| 326 | Audi tor.auditM viCorrelat eEvent(pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, fa lse); | |
| 327 | } else { | |
| 328 | Audi tor.auditM viCorrelat eEvent(pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, tr ue); | |
| 329 | System.out .println(" ********** ******** K en So **** ********** **** Patie ntIdentity Service.de activatePa tient()unc orrelate f or user:" + patient. getUserPro file().get Id() + ":S UCCESS"); | |
| 330 | } | |
| 331 | } | |
| 332 | ||
| 333 | if (LOG.isDe bugEnabled ()) { | |
| 334 | LOG.debu g("Patient IdentitySe rvice.deac tivatePati ent()deact ivate for user:" + p atient.get UserProfil e().getId( )); | |
| 335 | } | |
| 336 | ||
| 337 | Us erProfileD eactivatio nReason de actReason = getDeact Reason(rea son); | |
| 338 | System.out .println(" ********** ******** K en So **** ********** **** Patie ntIdentity Service.de activatePa tient()Use rProfileDe activation Utils.find Reason use r:" + pati ent.getUse rProfile() .getId() + ":deactRe ason:" +de actReason. getName()) ; | |
| 339 | ||
| 340 | Pa tientServi ceResponse pPesponse = | |
| 341 | getP atientServ ice().deac tivatePati entForMult iTraitUpda teError( | |
| 342 | patien t, referen ceId, Acti vityActorT ypeEnumera tion.SYSTE M, deactRe ason, deac tivationNo te); | |
| 343 | pa tient = pP esponse.ge tPatient() ; | |
| 344 | if (pPesponse .getMessag es().hasEr rorMessage s()) { | |
| 345 | Auditor.a uditAccoun tDeactivat eEvent( | |
| 346 | pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, fa lse); | |
| 347 | return Re gistryInte rfaceUtils .createErr orStatus(" Error in P atient Dea ctivation" ); | |
| 348 | } else { | |
| 349 | System.out .println(" ********** ******** K en So **** ********** **** Patie ntService( ).deactiva tePatientF orMultiTra itUpdateEr ror user:" + patient .getUserPr ofile().ge tId() + ": SUCCESS"); | |
| 350 | System.out .println(" ********** ******** K en So **** ********** **** Patie ntService( ).deactiva tePatientF orMultiTra itUpdateEr ror lastNa me:" + pat ient.getUs erProfile( ).getLastN ame()); | |
| 351 | Auditor.a uditAccoun tDeactivat eEvent( | |
| 352 | pati ent.getUse rProfile() .getId(), ActivityAc torTypeEnu meration.S YSTEM, tru e); | |
| 353 | } | |
| 354 | ||
| 355 | re turn Regis tryInterfa ceUtils.cr eateOkStat us(); | |
| 356 | } | |
| 357 | ||
| 358 | ||
| 359 | //JAZZ Defect# 2 0309: If t here four or more tr aits updat e, DO NOT Update the user and deactivate the user. | |
| 360 | public PatientSe rviceRespo nse deacti vatePatien tForMultiT raitUpdate Error(gov. va.med.mhv .usermgmt. transfer.P atient pat ient, | |
| 361 | St ring refer enceId, Us erProfileD eactivatio nReason re ason, Stri ng deactiv ationNote) { | |
| 362 | In PersonAuth entication ipa = | |
| 363 | getI PAService( ).getAuthe nticationF orPatient( patient.ge tId()).get InPersonAu thenticati on(); | |
| 364 | if (LOG.isDe bugEnabled ()) { | |
| 365 | LOG.debu g("Patient IdentitySe rvice.deac tivatePati entForMult iTraitUpda teError()u nauthentic ate for us er:" + pat ient.getUs erProfile( ).getId()) ; | |
| 366 | } | |
| 367 | ||
| 368 | if(i pa.getStat us() == Au thenticati onStatus.g etEnum(Aut henticatio nStatus.AU THENTICATE D)) { | |
| 369 | InPerson Authentica tionServic eResponse ipaService Response = getIPASer vice().una uthenticat e(ipa); | |
| 370 | ||
| 371 | if(ipaSe rviceRespo nse.getInP ersonAuthe ntication( ).getStatu s() != Aut henticatio nStatus.ge tEnum(Auth entication Status.UNA UTHENTICAT ED)) { | |
| 372 | Audi tor.auditM viUnauthen ticateRequ estEvent(p atient.get UserProfil e().getId( ), Activit yActorType Enumeratio n.SYSTEM, false); | |
| 373 | } else { | |
| 374 | Audi tor.auditM viUnauthen ticateRequ estEvent(p atient.get UserProfil e().getId( ), Activit yActorType Enumeratio n.SYSTEM, true); | |
| 375 | } | |
| 376 | } | |
| 377 | ||
| 378 | if (patient.g etCorrelat ionStatus( ) == Patie ntCorrelat ionStatus. getEnum(Pa tientCorre lationStat us.CORRELA TED)) { | |
| 379 | if (LOG. isDebugEna bled()) { | |
| 380 | LOG. debug("Pat ientIdenti tyService. deactivate PatientFor MultiTrait UpdateErro r()uncorre late for u ser:" + pa tient.getU serProfile ().getId() ); | |
| 381 | } | |
| 382 | Pati entService Response m viSyncServ iceRespons e = | |
| 383 | Servic eFactory.c reateMviIn tegrationS ervice().d eletePerso nFromCorre lationForH elpDesk( | |
| 384 | patient, p atient.get UserProfil e(), ""); | |
| 385 | if(mviSy ncServiceR esponse.ge tPatient() .getCorrel ationStatu s() != Pa tientCorre lationStat us.getEnum (PatientCo rrelationS tatus.UNCO RRELATED)) { | |
| 386 | Audi tor.auditM viCorrelat eEvent(pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, fa lse); | |
| 387 | } else { | |
| 388 | Audi tor.auditM viCorrelat eEvent(pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, tr ue); | |
| 389 | } | |
| 390 | } | |
| 391 | ||
| 392 | if (LOG.isDe bugEnabled ()) { | |
| 393 | LOG.debu g("Patient IdentitySe rvice.deac tivatePati entForMult iTraitUpda teError()d eactivate for user:" + patient .getUserPr ofile().ge tId()); | |
| 394 | } | |
| 395 | ||
| 396 | Pa tientServi ceResponse response = | |
| 397 | getP atientServ ice().deac tivatePati entForMult iTraitUpda teError( | |
| 398 | patien t, referen ceId, Acti vityActorT ypeEnumera tion.SYSTE M, reason, deactivat ionNote); | |
| 399 | if (response. getMessage s().hasErr orMessages ()) { | |
| 400 | Auditor.a uditAccoun tDeactivat eEvent( | |
| 401 | pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, fa lse); | |
| 402 | } else { | |
| 403 | Auditor.a uditAccoun tDeactivat eEvent( | |
| 404 | pati ent.getUse rProfile() .getId(), ActivityAc torTypeEnu meration.S YSTEM, tru e); | |
| 405 | } | |
| 406 | ||
| 407 | re turn respo nse; | |
| 408 | } | |
| 409 | ||
| 410 | public PatientSe rviceRespo nse deacti vatePatien tForAutmat edDeathNot ification( gov.va.med .mhv.userm gmt.transf er.Patient patient, | |
| 411 | St ring refer enceId, Us erProfileD eactivatio nReason re ason, Stri ng deactiv ationNote, Date date OfDeath) { | |
| 412 | In PersonAuth entication ipa = | |
| 413 | getI PAService( ).getAuthe nticationF orPatient( patient.ge tId()).get InPersonAu thenticati on(); | |
| 414 | if (LOG.isDe bugEnabled ()) { | |
| 415 | LOG.debu g("Patient IdentitySe rvice.deac tivatePati entForAutm atedDeathN otificatio n()unauthe nticate fo r user:" + patient.g etUserProf ile().getI d()); | |
| 416 | } | |
| 417 | ||
| 418 | if(i pa.getStat us() == Au thenticati onStatus.g etEnum(Aut henticatio nStatus.AU THENTICATE D)) { | |
| 419 | InPerson Authentica tionServic eResponse ipaService Response = getIPASer vice().una uthenticat e(ipa); | |
| 420 | ||
| 421 | if(ipaSe rviceRespo nse.getInP ersonAuthe ntication( ).getStatu s() != Aut henticatio nStatus.ge tEnum(Auth entication Status.UNA UTHENTICAT ED)) { | |
| 422 | Audi tor.auditM viUnauthen ticateRequ estEvent(p atient.get UserProfil e().getId( ), Activit yActorType Enumeratio n.SYSTEM, false); | |
| 423 | } else { | |
| 424 | Audi tor.auditM viUnauthen ticateRequ estEvent(p atient.get UserProfil e().getId( ), Activit yActorType Enumeratio n.SYSTEM, true); | |
| 425 | } | |
| 426 | } | |
| 427 | ||
| 428 | if (patient.g etCorrelat ionStatus( ) == Patie ntCorrelat ionStatus. getEnum(Pa tientCorre lationStat us.CORRELA TED)) { | |
| 429 | if (LOG. isDebugEna bled()) { | |
| 430 | LOG. debug("Pat ientIdenti tyService. deactivate PatientFor AutmatedDe athNotific ation()unc orrelate f or user:" + patient. getUserPro file().get Id()); | |
| 431 | } | |
| 432 | Pati entService Response m viSyncServ iceRespons e = | |
| 433 | Servic eFactory.c reateMviIn tegrationS ervice().d eletePerso nFromCorre lationForH elpDesk( | |
| 434 | patient, p atient.get UserProfil e(), ""); | |
| 435 | if(mviSy ncServiceR esponse.ge tPatient() .getCorrel ationStatu s() != Pa tientCorre lationStat us.getEnum (PatientCo rrelationS tatus.UNCO RRELATED)) { | |
| 436 | Audi tor.auditM viCorrelat eEvent(pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, fa lse); | |
| 437 | } else { | |
| 438 | Audi tor.auditM viCorrelat eEvent(pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, tr ue); | |
| 439 | } | |
| 440 | } | |
| 441 | ||
| 442 | if (LOG.isDe bugEnabled ()) { | |
| 443 | LOG.debu g("Patient IdentitySe rvice.deac tivatePati entForAutm atedDeathN otificatio n()deactiv ate for us er:" + pat ient.getUs erProfile( ).getId()) ; | |
| 444 | } | |
| 445 | ||
| 446 | Pa tientServi ceResponse response = | |
| 447 | getP atientServ ice().deac tivatePati entInHelpD esk( | |
| 448 | patien t, referen ceId, Acti vityActorT ypeEnumera tion.SYSTE M, reason, deactivat ionNote, d ateOfDeath ); | |
| 449 | ||
| 450 | if (response. getMessage s().hasErr orMessages ()) { | |
| 451 | Auditor.a uditAccoun tDeactivat eEvent( | |
| 452 | pat ient.getUs erProfile( ).getId(), ActivityA ctorTypeEn umeration. SYSTEM, fa lse); | |
| 453 | } else { | |
| 454 | Auditor.a uditAccoun tDeactivat eEvent( | |
| 455 | pati ent.getUse rProfile() .getId(), ActivityAc torTypeEnu meration.S YSTEM, tru e); | |
| 456 | } | |
| 457 | ||
| 458 | re turn respo nse; | |
| 459 | } | |
| 460 | ||
| 461 | privat e boolean isFourOrMo reTraitsUp date(gov.v a.med.mhv. usermgmt.t ransfer.Pa tient pati ent, Perso nalInfo pe rsonalInfo ) { | |
| 462 | in t traitUpd ateCount = 0; | |
| 463 | ||
| 464 | Us erProfile userProfil e = patien t.getUserP rofile(); | |
| 465 | ||
| 466 | if (LOG.isDe bugEnabled ()) { | |
| 467 | LOG.debu g("Patient IdentitySe rvice.isFo urOrMoreTr aitsUpdate () for use r profile id:" + use rProfile.g etId()); | |
| 468 | } | |
| 469 | ||
| 470 | // If a trait is not th e same, we increment the count . This app lies to fi rst name, middle nam e, last na me, ssn, g ender and DOB. | |
| 471 | if (!userProf ile.getFir stName().e qualsIgnor eCase(pers onalInfo.g etName().g etFirstNam e())) { | |
| 472 | if (LOG. isDebugEna bled()) { | |
| 473 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() fir st name is different for user profile id :" + userP rofile.get Id()); | |
| 474 | } | |
| 475 | trai tUpdateCou nt++; | |
| 476 | } | |
| 477 | ||
| 478 | // Middle nam e can be n ull on bot h sides so we need t o cover al l permutat ions. | |
| 479 | if (userProfi le.getMidd leName()== null && pe rsonalInfo .getName() .getMiddle Name()!=nu ll) { | |
| 480 | if (LOG. isDebugEna bled()) { | |
| 481 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() mid dle name i s differen t for user profile i d:" + user Profile.ge tId()); | |
| 482 | } | |
| 483 | trai tUpdateCou nt++; | |
| 484 | } else if(us erProfile. getMiddleN ame()!=nul l && perso nalInfo.ge tName().ge tMiddleNam e()==null) { | |
| 485 | if (LOG. isDebugEna bled()) { | |
| 486 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() mid dle name i s differen t for user profile i d:" + user Profile.ge tId()); | |
| 487 | } | |
| 488 | trai tUpdateCou nt++; | |
| 489 | } else if(us erProfile. getMiddleN ame()==nul l && perso nalInfo.ge tName().ge tMiddleNam e()==null) { | |
| 490 | if (LOG. isDebugEna bled()) { | |
| 491 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() no middle nam e for user profile i d:" + user Profile.ge tId()); | |
| 492 | } | |
| 493 | } else if(!u serProfile .getMiddle Name().equ alsIgnoreC ase(person alInfo.get Name().get MiddleName ())) { | |
| 494 | if (LOG. isDebugEna bled()) { | |
| 495 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() mid dle name i s differen t for user profile i d:" + user Profile.ge tId()); | |
| 496 | } | |
| 497 | trai tUpdateCou nt++; | |
| 498 | } | |
| 499 | ||
| 500 | if (!userProf ile.getLas tName().eq ualsIgnore Case(perso nalInfo.ge tName().ge tLastName( ))) { | |
| 501 | if (LOG. isDebugEna bled()) { | |
| 502 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() las t name is different for user p rofile id: " + userPr ofile.getI d()); | |
| 503 | } | |
| 504 | trai tUpdateCou nt++; | |
| 505 | } | |
| 506 | ||
| 507 | if (!userProf ile.getBir thDate().e quals(pers onalInfo.g etDateOfBi rth())) { | |
| 508 | if (LOG. isDebugEna bled()) { | |
| 509 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() bir th date is different for user profile id :" + userP rofile.get Id()); | |
| 510 | } | |
| 511 | trai tUpdateCou nt++; | |
| 512 | } | |
| 513 | ||
| 514 | if (!userProf ile.getGen der().getN ame().equa lsIgnoreCa se(persona lInfo.getG ender().ge tName())) { | |
| 515 | if (LOG. isDebugEna bled()) { | |
| 516 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() gen der is dif ferent for user prof ile id:" + userProfi le.getId() ); | |
| 517 | } | |
| 518 | trai tUpdateCou nt++; | |
| 519 | } | |
| 520 | ||
| 521 | St ring ssn = userProfi le.getSsn( ).replaceA ll("-", "" ); | |
| 522 | if (!ssn.equa ls(persona lInfo.getS sn())) { | |
| 523 | if (LOG. isDebugEna bled()) { | |
| 524 | LOG. debug("Pat ientIdenti tyService. isFourOrMo reTraitsUp date() ssn is differ ent for us er profile id:" + us erProfile. getId()); | |
| 525 | } | |
| 526 | trai tUpdateCou nt++; | |
| 527 | } | |
| 528 | ||
| 529 | if (traitUpda teCount>3) { | |
| 530 | retu rn true; | |
| 531 | } | |
| 532 | ||
| 533 | re turn false ; | |
| 534 | } | |
| 535 | ||
| 536 | /* (no n-Javadoc) | |
| 537 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 538 | * Pat ientIdenti tyServiceR emote#chan geIcn( | |
| 539 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, java.lang .String) | |
| 540 | */ | |
| 541 | public Status ch angeIcn(Pa tient pati ent, Strin g icn) { | |
| 542 | Pr econdition .assertNot Null("pati ent", pati ent); | |
| 543 | Pr econdition .assertNot Empty("pat ient.getIc n()", pati ent.getIcn ()); | |
| 544 | Pr econdition .assertNot Empty("icn ", icn); | |
| 545 | fi nal String operation = "Update icn"; | |
| 546 | if (LOG.isDe bugEnabled ()) { | |
| 547 | LOG.debu g(operatio n + " of " + describ e(patient) + " to'" + icn | |
| 548 | + "' "); | |
| 549 | } | |
| 550 | St atus statu s = null; | |
| 551 | Pa tientServi ceResponse response = getPatie ntByIcn(pa tient.getI cn()); | |
| 552 | if (response .getPatien t() != nul l) { | |
| 553 | response .getPatien t().setIcn (icn); | |
| 554 | status = updatePat ient(respo nse.getPat ient()); | |
| 555 | } else { | |
| 556 | status = createPat ientDoesNo tExistStat us(); | |
| 557 | } | |
| 558 | lo gStatus(op eration, p atient, st atus); | |
| 559 | re turn statu s; | |
| 560 | } | |
| 561 | ||
| 562 | ||
| 563 | ||
| 564 | ||
| 565 | /* (no n-Javadoc) | |
| 566 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 567 | * Pat ientIdenti tyServiceR emote#remo veCorrelat ion( | |
| 568 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient) | |
| 569 | */ | |
| 570 | public Status re moveCorrel ation(Pati ent patien t) { | |
| 571 | Pr econdition .assertNot Null("pati ent", pati ent); | |
| 572 | Pr econdition .assertNot Empty("pat ient.getIc n()", pati ent.getIcn ()); | |
| 573 | fi nal String operation = "Remove correlati on"; | |
| 574 | if (LOG.isDe bugEnabled ()) { | |
| 575 | LOG.debu g(operatio n + " of " + describ e(patient) ); | |
| 576 | } | |
| 577 | St atus statu s = null; | |
| 578 | Pa tientServi ceResponse response = getPatie ntByIcn(pa tient.getI cn()); | |
| 579 | if (response .getPatien t() == nul l) { | |
| 580 | status = createPat ientDoesNo tExistStat us(); | |
| 581 | } else if (P atientCorr elationSta tusUtils.i sPendingCo rrelation( response. | |
| 582 | getPatie nt())) | |
| 583 | { | |
| 584 | status = finalizeC orrelation (patient, new Status (StatusTyp e. | |
| 585 | Erro r, Message Keys.PATIE NT_MPI_COR RELATION_F AILED)); | |
| 586 | } else if (P atientCorr elationSta tusUtils.i sPendingUn correlatio n( | |
| 587 | response .getPatien t())) | |
| 588 | { | |
| 589 | status = finalizeU ncorrelati on(patient , new Stat us(StatusT ype. | |
| 590 | Erro r, Message Keys.PATIE NT_MPI_UNC ORRELATION _FAILED)); | |
| 591 | } else { | |
| 592 | handleMe ssages(get PatientSer vice().rem oveCorrela tion(respo nse. | |
| 593 | getP atient())) ; | |
| 594 | InPerson Authentica tion ipa = getIPA(re sponse.get Patient()) ; | |
| 595 | if (ipa != null) { | |
| 596 | hand leMessages (getIPASer vice().ter minateAuth entication (ipa)); | |
| 597 | } | |
| 598 | status = RegistryI nterfaceUt ils.create OkStatus() ; | |
| 599 | } | |
| 600 | lo gStatus(op eration, p atient, st atus); | |
| 601 | re turn statu s; | |
| 602 | } | |
| 603 | ||
| 604 | privat e void han dleMessage s(String d escription , EntitySe rviceRespo nse respon se) { | |
| 605 | if (response == null) { | |
| 606 | return; | |
| 607 | } | |
| 608 | ha ndleMessag es(descrip tion, (Ser viceRespon se) respon se); | |
| 609 | if (response .getEntity () != null ) { | |
| 610 | Messages Set messag es = respo nse.getEnt ity().getA llMessages (); | |
| 611 | if (isEm pty(messag es)) { | |
| 612 | retu rn; | |
| 613 | } | |
| 614 | ||
| 615 | logMessa ges(messag es); | |
| 616 | if (mess ages.hasEr rorMessage s()) { | |
| 617 | Stri ngBuffer b uffer = ne w StringBu ffer(); | |
| 618 | buff er.append( new Messag esStringBu ilder().ap pend(messa ges, getCl ass()).get ErrorStrin g()); | |
| 619 | //Ja zz Enhance ment # 295 39: Instea d of unkno wn excepti on, more d escription s are adde d for the production support. | |
| 620 | thro w new Runt imeExcepti on(descrip tion + ": " + buffer .toString( )); | |
| 621 | //Th is is an o ld code th at didn't have any d escription . Left it commented for resear ch purpse | |
| 622 | //th row new Ru ntimeExcep tion(Messa geKeys.UNK NOWN_EXCEP TION_OCCUR RED); | |
| 623 | } | |
| 624 | } | |
| 625 | } | |
| 626 | ||
| 627 | ||
| 628 | /* (no n-Javadoc) | |
| 629 | * @se e gov.va.m ed.mhv.int egration.r egistry.se rvices.ejb . | |
| 630 | * Pat ientIdenti tyServiceR emote#merg ePatients( | |
| 631 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, | |
| 632 | * gov .va.med.mh v.integrat ion.regist ry.transfe r.Patient, java.lang .String) | |
| 633 | */ | |
| 634 | public Status me rgePatient s(Patient fromPatien t, Patient toPatient , | |
| 635 | St ring refer enceId) | |
| 636 | { | |
| 637 | Pr econdition .assertNot Null("from Patient", fromPatien t); | |
| 638 | Pr econdition .assertNot Null("toPa tient", to Patient); | |
| 639 | Pr econdition .assertNot Blank("ref erenceId", reference Id); | |
| 640 | ||
| 641 | fi nal String operation = "Merge "; | |
| 642 | if (LOG.isDe bugEnabled ()) { | |
| 643 | LOG.debu g(operatio n + descri be(fromPat ient) + " and " + | |
| 644 | desc ribe(toPat ient) + " with refer ence id '" + referen ceId | |
| 645 | + "' "); | |
| 646 | } | |
| 647 | St atus statu s = null; | |
| 648 | Pa tientServi ceResponse response = getPatie ntByIcn(fr omPatient. getIcn()); | |
| 649 | // Jazz Enhan cement # 2 9539: Inst ead of unk nown excep tion, more descripti ons are ad ded for th e producti on support . | |
| 650 | ha ndleMessag es("ADT-A2 4 Link Pat ient Infor mation Pro cess:Getti ng From Pa tient with ICN:" + f romPatient .getIcn(), response) ; | |
| 651 | ||
| 652 | Pa tientServi ceResponse toRespons e = getPat ientByIcn( toPatient. getIcn()); | |
| 653 | // Jazz Enhan cement # 2 9539: Inst ead of unk nown excep tion, more descripti ons are ad ded for th e producti on support . | |
| 654 | ha ndleMessag es("ADT-A2 4 Link Pat ient Infor mation Pro cess:Getti ng To Pati ent with I CN:" + toP atient.get Icn(), toR esponse); | |
| 655 | if ((respons e.getPatie nt() == nu ll) | |
| 656 | || (toRe sponse.get Patient() == null)) | |
| 657 | { | |
| 658 | status = createPat ientDoesNo tExistStat us(); | |
| 659 | } else { | |
| 660 | User ProfileDea ctivationR eason reas on = | |
| 661 | UserPr ofileDeact ivationUti ls.findRea son(UserPr ofileDeact ivationUti ls.MPI_PAT IENT_MERGE _NAME); | |
| 662 | ||
| 663 | response = getPati entService ().invalid atePatient (response. getPatient (), refere nceId, rea son); | |
| 664 | //Jazz E nhancement # 29539: Instead of unknown e xception, more descr iptions ar e added fo r the prod uction sup port. | |
| 665 | handleMe ssages("AD T-A24 Link Patient I nformation Process:i nvalidatin g Patient with ICN:" + | |
| 666 | resp onse.getPa tient().ge tIcn(), to Response); | |
| 667 | sendMerg eAlert(res ponse.getP atient(), toResponse .getPatien t()); | |
| 668 | status = RegistryI nterfaceUt ils.create OkStatus() ; | |
| 669 | } | |
| 670 | lo gStatus(op eration, f romPatient , toPatien t, status) ; | |
| 671 | re turn statu s; | |
| 672 | } | |
| 673 | ||
| 674 | privat e void sen dMergeAler t( | |
| 675 | go v.va.med.m hv.usermgm t.transfer .Patient f romPatient , | |
| 676 | go v.va.med.m hv.usermgm t.transfer .Patient t oPatient) | |
| 677 | { | |
| 678 | He lpDeskAler t alert = HelpDeskAl ertPropert ies.getIns tance(). | |
| 679 | createMe rgePatient sAlert(); | |
| 680 | al ert.format Subject(fr omPatient. getInvalid ationRefer enceId()); | |
| 681 | al ert.format Message(fr omPatient. getInvalid atedIcn(), toPatient .getIcn(), | |
| 682 | Calendar .getInstan ce(), from Patient.ge tUserProfi le().getMh vId(), | |
| 683 | toPatien t.getUserP rofile().g etMhvId(), fromPatie nt. | |
| 684 | getInval idationRef erenceId() ); | |
| 685 | Vo idServiceR esponse re sponse = a lert.send( ); | |
| 686 | if (ServiceR esponseUti ls.hasErro rMessages( response)) { | |
| 687 | // TODO: Do we nee to have a try-catch block as well? | |
| 688 | // Just log the me ssages | |
| 689 | // We sh ould not f ail the me rge reques t because we cannot send | |
| 690 | // the e mail | |
| 691 | ServiceR esponseUti ls.logMess ages(respo nse, getCl ass(), LOG ); | |
| 692 | } | |
| 693 | } | |
| 694 | ||
| 695 | privat e PatientS erviceResp onse getPa tient(Pati ent patien t) { | |
| 696 | as sert patie nt != null ; | |
| 697 | Pa tientServi ceResponse response = null; | |
| 698 | if (!StringU tils.isBla nk(patient .getIcn()) ) { | |
| 699 | response = getPati entByIcn(p atient.get Icn()); | |
| 700 | } else { | |
| 701 | List use rProfileBO s = UserPr ofileBO. | |
| 702 | getP rofileByNa meBirthDat eSsn( | |
| 703 | patient.ge tPersonalI nfo().getN ame().getF irstName() , | |
| 704 | patient.ge tPersonalI nfo().getN ame().getL astName(), | |
| 705 | patient.ge tPersonalI nfo().getD ateOfBirth (), | |
| 706 | patient.ge tPersonalI nfo().getS sn()); | |
| 707 | if ((use rProfileBO s != null) && (userP rofileBOs. size() > 0 )) { | |
| 708 | resp onse = get PatientSer vice().get PatientFor User( | |
| 709 | ((UserProf ileBO) use rProfileBO s.iterator ().next()) . | |
| 710 | getUserPro fileValues ()); | |
| 711 | } else { | |
| 712 | resp onse = new PatientSe rviceRespo nse(); | |
| 713 | } | |
| 714 | } | |
| 715 | re turn respo nse; | |
| 716 | ||
| 717 | } | |
| 718 | ||
| 719 | privat e PatientS erviceResp onse getPa tientByIcn (String ic n) { | |
| 720 | if (LOG.isDe bugEnabled ()) { | |
| 721 | LOG.debu g("getPati entByIcn(" + icn + " )"); | |
| 722 | } | |
| 723 | Pa tientServi ceResponse response = getPatie ntService( ). | |
| 724 | getPatie ntByIcn(ic n); | |
| 725 | ha ndleMessag es(respons e); | |
| 726 | re turn respo nse; | |
| 727 | } | |
| 728 | ||
| 729 | privat e UserProf ileService getUserPr ofileServi ce() { | |
| 730 | re turn Servi ceFactory. createUser ProfileSer vice(); | |
| 731 | } | |
| 732 | ||
| 733 | privat e PatientS ervice get PatientSer vice() { | |
| 734 | re turn Servi ceFactory. createPati entService (); | |
| 735 | } | |
| 736 | ||
| 737 | privat e InPerson Authentica tionServic e getIPASe rvice() { | |
| 738 | re turn Servi ceFactory. createInPe rsonAuthen ticationSe rvice(); | |
| 739 | } | |
| 740 | ||
| 741 | //Jazz Enhanceme nt # 29539 : Instead of unknown exception , more des criptions are added for the pr oduction s upport. | |
| 742 | privat e Status u pdatePatie nt(String descriptio n, | |
| 743 | go v.va.med.m hv.usermgm t.transfer .Patient p atient) { | |
| 744 | Pa tientServi ceResponse response = getPatie ntService( ). | |
| 745 | updatePa tientRegis tryInforma tion(patie nt); | |
| 746 | ||
| 747 | Me ssagesSet messages = response. getEntity( ).getAllMe ssages(); | |
| 748 | if (messages .hasErrorM essages()) { | |
| 749 | //Jazz E nhancement # 29539: Find out w hich facil ities do n ot exist i n MHV but in MVI. | |
| 750 | boolea n facility NotFound = false; | |
| 751 | for (Object o: patient.g etFacility s()) { | |
| 752 | gov.va .med.mhv.u sermgmt.tr ansfer.Fac ility faci lity = (go v.va.med.m hv.usermgm t.transfer .Facility) o; | |
| 753 | List e xistingFac ilities = FacilityIn foBO.query ByStationN umber(faci lity.getNa me()); | |
| 754 | if(exist ingFacilit ies == nul l || exist ingFacilit ies.size() == 0){ | |
| 755 | if(!facili tyNotFound ) { | |
| 756 | de scription = descript ion + "The following facilitie s are not found in M HV {"; | |
| 757 | fa cilityNotF ound = tru e; | |
| 758 | } else { | |
| 759 | de scription = descript ion + " "; | |
| 760 | } | |
| 761 | descriptio n = descri ption + fa cility.get Name(); | |
| 762 | } | |
| 763 | descript ion = desc ription + "}"; | |
| 764 | } | |
| 765 | } | |
| 766 | ||
| 767 | ha ndleMessag es(descrip tion, resp onse); | |
| 768 | re turn Regis tryInterfa ceUtils.cr eateOkStat us(); | |
| 769 | } | |
| 770 | ||
| 771 | privat e Status u pdatePatie nt( | |
| 772 | gov.va.m ed.mhv.use rmgmt.tran sfer.Patie nt patient ) | |
| 773 | { | |
| 774 | re turn updat ePatient(n ull, patie nt); | |
| 775 | } | |
| 776 | ||
| 777 | privat e void han dleMessage s(ServiceR esponse re sponse) { | |
| 778 | ha ndleMessag es(null, r esponse); | |
| 779 | } | |
| 780 | ||
| 781 | privat e void han dleMessage s(String d escription , ServiceR esponse re sponse) { | |
| 782 | if (response == null) { | |
| 783 | return; | |
| 784 | } | |
| 785 | if (isEmpty( response.g etMessages ())) { | |
| 786 | return; | |
| 787 | } | |
| 788 | lo gMessages( response.g etMessages ()); | |
| 789 | if (response .getMessag es().hasEr rorMessage s()) { | |
| 790 | Stri ngBuffer b uffer = ne w StringBu ffer(); | |
| 791 | buff er.append( new Messag esStringBu ilder().ap pend(respo nse.getMes sages(), g etClass()) .getErrorS tring()); | |
| 792 | //Jazz E nhancement # 29539: Instead of unknown e xception, more descr iptions ar e added fo r the prod uction sup port. | |
| 793 | thro w new Runt imeExcepti on(descrip tion + ": " + buffer .toString( )); | |
| 794 | //Th is is an o ld code th at didn't have any d escription . Left it commented for resear ch purpse | |
| 795 | //th row new Ru ntimeExcep tion(Messa geKeys.UNK NOWN_EXCEP TION_OCCUR RED); | |
| 796 | } | |
| 797 | } | |
| 798 | ||
| 799 | privat e void log Messages(M essagesSet messages) { | |
| 800 | Pr econdition .assertNot Null("mess ages", mes sages); | |
| 801 | if (isEmpty( messages)) { | |
| 802 | return; | |
| 803 | } | |
| 804 | Me ssagesStri ngBuilder builder = new Messag esStringBu ilder(); | |
| 805 | bu ilder.appe nd(message s, getClas s()); | |
| 806 | if (messages .hasInform ationalMes sages()) { | |
| 807 | if (LOG. isInfoEnab led()) { | |
| 808 | LOG. info(build er.getInfo String()); | |
| 809 | } | |
| 810 | } | |
| 811 | if (messages .hasErrorM essages()) { | |
| 812 | LOG.erro r(builder. getErrorSt ring()); | |
| 813 | } | |
| 814 | } | |
| 815 | ||
| 816 | privat e boolean isEmpty(Me ssagesSet messages) { | |
| 817 | re turn (mess ages == nu ll) | |
| 818 | || (mess ages.getEr rorMessage Count() + | |
| 819 | mess ages.getIn formationa lMessageCo unt() == 0 ); | |
| 820 | } | |
| 821 | ||
| 822 | privat e void log Status(Str ing descri ption, Pat ient patie nt, Status status) { | |
| 823 | lo gStatus(de scription, patient, null, stat us); | |
| 824 | } | |
| 825 | ||
| 826 | privat e void log Status(Str ing descri ption, Pat ient fromP atient, | |
| 827 | Pa tient toPa tient, Sta tus status ) | |
| 828 | { | |
| 829 | Pr econdition .assertNot Null("stat us", statu s); | |
| 830 | if (StatusTy pe.Error.e quals(stat us.getStat us())) { | |
| 831 | LOG.erro r(descript ion + " of " + descr ibe(fromPa tient) + | |
| 832 | ((to Patient != null) ? " and " + d escribe(to Patient) : "") + | |
| 833 | " fa iled, beca use " + st atus.getSt atusDescri ption()); | |
| 834 | } else if (L OG.isInfoE nabled()) { | |
| 835 | LOG.info (descripti on + " of " + descri be(fromPat ient) + | |
| 836 | ((to Patient != null) ? " and " + d escribe(to Patient) : "") + | |
| 837 | " su cceeded"); | |
| 838 | } | |
| 839 | } | |
| 840 | ||
| 841 | privat e String d escribe(Pa tient pati ent) { | |
| 842 | re turn Regis tryInterfa ceUtils.de scribe(pat ient); | |
| 843 | } | |
| 844 | ||
| 845 | privat e String d escribe(Pe rsonalInfo personalI nfo) { | |
| 846 | re turn Regis tryInterfa ceUtils.de scribe(per sonalInfo) ; | |
| 847 | } | |
| 848 | ||
| 849 | privat e String d escribe(Li st<Facilit y> facilit ies) { | |
| 850 | re turn Regis tryInterfa ceUtils.de scribe(fac ilities); | |
| 851 | } | |
| 852 | ||
| 853 | privat e String d escribe(St atus statu s) { | |
| 854 | re turn Regis tryInterfa ceUtils.de scribe(sta tus); | |
| 855 | } | |
| 856 | ||
| 857 | privat e static S tatus crea tePatientD oesNotExis tStatus() { | |
| 858 | re turn Regis tryInterfa ceUtils.cr eateErrorS tatus(Mess ageKeys. | |
| 859 | PATIENT_ NOT_FOUND) ; | |
| 860 | } | |
| 861 | ||
| 862 | privat e static S tatus crea tePatientN otPendingC orrelation Response() { | |
| 863 | re turn Regis tryInterfa ceUtils.cr eateErrorS tatus(Mess ageKeys. | |
| 864 | PATIENT_ IS_NOT_PEN DING_CORRE LATION); | |
| 865 | } | |
| 866 | ||
| 867 | privat e static S tatus crea tePatientN otPendingU ncorrelati onResponse () { | |
| 868 | re turn Regis tryInterfa ceUtils.cr eateErrorS tatus(Mess ageKeys. | |
| 869 | PATIENT_ IS_NOT_PEN DING_UNCOR RELATION); | |
| 870 | } | |
| 871 | ||
| 872 | privat e static S tatus crea tePatientI sNotPendin gAuthentic ationStatu s() { | |
| 873 | re turn Regis tryInterfa ceUtils.cr eateErrorS tatus(Mess ageKeys. | |
| 874 | PATIENT_ IS_NOT_PEN DING_AUTHE NTICATION) ; | |
| 875 | } | |
| 876 | ||
| 877 | privat e static S tatus crea tePatientI sNotPendin gSynchroni zationStat us() { | |
| 878 | re turn Regis tryInterfa ceUtils.cr eateErrorS tatus(Mess ageKeys. | |
| 879 | PATIENT_ IS_NOT_PEN DING_SYNCH RONIZATION ); | |
| 880 | } | |
| 881 | ||
| 882 | privat e String g etError(St atus statu s) { | |
| 883 | re turn ((sta tus != nul l) && Stat usType.Err or.equals( status.get Status())) | |
| 884 | ? status .getStatus Descriptio n() : null ; | |
| 885 | } | |
| 886 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.