Produced by Araxis Merge on 4/5/2017 4:21:45 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:\working_scrub\Unredacted\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterEJB\src\archive\java\gov\va\med\nhin\adapter\adaptergateway\docquery | AdapterGatewayDocQueryOrchBean.java | Fri Feb 10 15:41:44 2017 UTC |
| 2 | eHX-CIF.zip\eHX-CIF\eHX Code Base\eHX_Bld2_Source Code_CIF_2017-02-14\NHIN_adapter\AdapterEJB\src\archive\java\gov\va\med\nhin\adapter\adaptergateway\docquery | AdapterGatewayDocQueryOrchBean.java | Mon Apr 3 14:22:51 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1230 |
| 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 | package go v.va.med.n hin.adapte r.adapterg ateway.doc query; | |
| 2 | ||
| 3 | import jav a.util.Arr ayList; | |
| 4 | import jav a.util.Dat e; | |
| 5 | import jav a.util.Has hMap; | |
| 6 | import jav a.util.Lis t; | |
| 7 | import jav a.util.Map ; | |
| 8 | import jav a.util.con current.Ca llable; | |
| 9 | import jav a.util.con current.Ex ecutionExc eption; | |
| 10 | import jav a.util.con current.Ex ecutorComp letionServ ice; | |
| 11 | import jav a.util.con current.Ex ecutorServ ice; | |
| 12 | import jav a.util.reg ex.Matcher ; | |
| 13 | import jav a.util.reg ex.Pattern ; | |
| 14 | ||
| 15 | import jav ax.ejb.EJB ; | |
| 16 | import jav ax.ejb.Sta teless; | |
| 17 | ||
| 18 | import gov .va.med.nh in.adapter .utils.Log Util; | |
| 19 | import org .apache.co mmons.lang 3.StringUt ils; | |
| 20 | import org .hl7.v3.II ; | |
| 21 | import org .hl7.v3.PR PAIN201310 UV02; | |
| 22 | import org .hl7.v3.PR PAMT201304 UV02Patien t; | |
| 23 | import org .hl7.v3.Re trievePati entCorrela tionsReque stType; | |
| 24 | import org .hl7.v3.Re trievePati entCorrela tionsRespo nseType; | |
| 25 | import org .slf4j.Log ger; | |
| 26 | import org .slf4j.Log gerFactory ; | |
| 27 | ||
| 28 | import gov .hhs.fha.n hinc.adapt erpolicyen gine.Adapt erPolicyEn ginePortTy pe; | |
| 29 | import gov .hhs.fha.n hinc.commo n.eventcom mon.AdhocQ ueryReques tEventType ; | |
| 30 | import gov .hhs.fha.n hinc.commo n.eventcom mon.AdhocQ ueryReques tMessageTy pe; | |
| 31 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.Assert ionType; | |
| 32 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.HomeCo mmunityTyp e; | |
| 33 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.NhinTa rgetCommun ityType; | |
| 34 | import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .CheckPoli cyRequestT ype; | |
| 35 | import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .CheckPoli cyResponse Type; | |
| 36 | import gov .hhs.fha.n hinc.nhinc componentp atientcorr elation.Pa tientCorre lationPort Type; | |
| 37 | import gov .hhs.fha.n hinc.nhinc lib.NhincC onstants; | |
| 38 | import gov .hhs.fha.n hinc.trans form.polic y.PolicyEn gineTransf ormer; | |
| 39 | import gov .hhs.fha.n hinc.trans form.subdi sc.HL7PRPA 201309Tran sforms; | |
| 40 | import gov .va.med.nh in.adapter .audit.req uests.Requ estActions ; | |
| 41 | import gov .va.med.nh in.adapter .audit.req uests.Requ estAudit; | |
| 42 | import gov .va.med.nh in.adapter .audit.req uests.Requ estAuditEn tity; | |
| 43 | import gov .va.med.nh in.adapter .facilitym anager.Fac ility; | |
| 44 | import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag er; | |
| 45 | import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag erLocal; | |
| 46 | import gov .va.med.nh in.adapter .facilitym anager.Ope rationOnOf f; | |
| 47 | import gov .va.med.nh in.adapter .logging.C heckPolicy ; | |
| 48 | import gov .va.med.nh in.adapter .logging.E rrorMessag e; | |
| 49 | import gov .va.med.nh in.adapter .logging.M aintLog; | |
| 50 | import gov .va.med.nh in.adapter .patientco rrelation. PatientCor relationPo rtTypeLoca l; | |
| 51 | import gov .va.med.nh in.adapter .policyeng ine.Adapte rPolicyEng inePortTyp eLocal; | |
| 52 | import gov .va.med.nh in.adapter .utils.Nul lChecker; | |
| 53 | import oas is.names.t c.ebxml_re grep.xsd.q uery._3.Ad hocQueryRe quest; | |
| 54 | import oas is.names.t c.ebxml_re grep.xsd.q uery._3.Ad hocQueryRe sponse; | |
| 55 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Adho cQueryType ; | |
| 56 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Slot Type1; | |
| 57 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Valu eListType; | |
| 58 | import oas is.names.t c.ebxml_re grep.xsd.r s._3.Regis tryError; | |
| 59 | import oas is.names.t c.ebxml_re grep.xsd.r s._3.Regis tryErrorLi st; | |
| 60 | ||
| 61 | /** | |
| 62 | * | |
| 63 | * @author DN S VAZQUD | |
| 64 | */ | |
| 65 | @Stateless (name = "A dapterGate wayDocQuer yOrch") | |
| 66 | public cla ss Adapter GatewayDoc QueryOrchB ean implem ents Adapt erGatewayD ocQueryPor tTypeLocal | |
| 67 | { | |
| 68 | pr ivate clas s SendRequ estRespons e | |
| 69 | { | |
| 70 | publ ic AdhocQu eryRespons e adhocQue ryResponse ; | |
| 71 | publ ic II remo tePatientI d; | |
| 72 | publ ic String remoteHome CommunityI d; | |
| 73 | publ ic SendReq uestExcept ion sre = null; | |
| 74 | ||
| 75 | publ ic boolean hasError( ) | |
| 76 | { | |
| 77 | if(sre == null) | |
| 78 | { | |
| 79 | return f alse; | |
| 80 | } | |
| 81 | ||
| 82 | return true; | |
| 83 | } | |
| 84 | } | |
| 85 | ||
| 86 | pr ivate clas s SendRequ estExcepti on extends Exception | |
| 87 | { | |
| 88 | publ ic II remo tePatientI d; | |
| 89 | publ ic String remoteHome CommunityI d; | |
| 90 | } | |
| 91 | ||
| 92 | pr ivate clas s SendRequ estCallabl e implemen ts Callabl e<SendRequ estRespons e> | |
| 93 | { | |
| 94 | priv ate final AdhocQuery Request ad hocQueryRe quest; | |
| 95 | priv ate final AssertionT ype assert ion; | |
| 96 | priv ate II rem otePatient Id; | |
| 97 | priv ate String remoteHom eCommunity Id; | |
| 98 | priv ate String auditUUID ; | |
| 99 | ||
| 100 | publ ic SendReq uestCallab le(AdhocQu eryRequest adhocQuer yRequest, AssertionT ype assert ion, II re motePatien tId, Strin g remoteHo meCommunit yId, Strin g auditUUI D) | |
| 101 | { | |
| 102 | this.a dhocQueryR equest = a dhocQueryR equest; | |
| 103 | this.a ssertion = assertion ; | |
| 104 | this.r emotePatie ntId = rem otePatient Id; | |
| 105 | this.r emoteHomeC ommunityId = remoteH omeCommuni tyId; | |
| 106 | this.a uditUUID = auditUUID ; | |
| 107 | } | |
| 108 | ||
| 109 | publ ic SendReq uestRespon se call() throws Exc eption | |
| 110 | { | |
| 111 | return sendReque st(adhocQu eryRequest , assertio n, remoteP atientId, remoteHome CommunityI d, auditUU ID); | |
| 112 | } | |
| 113 | } | |
| 114 | ||
| 115 | pr ivate stat ic final L ogger logg er = Logge rFactory.g etLogger(A dapterGate wayDocQuer yOrchBean. class.getN ame()); | |
| 116 | ||
| 117 | st atic priva te final S tring EBXM L_DOCENTRY _PATIENT_I D = "$XDSD ocumentEnt ryPatientI d"; | |
| 118 | ||
| 119 | pr ivate Faci lityManage r facility Manager; | |
| 120 | pr ivate Pati entCorrela tionPortTy pe adapter PatientCor relation; | |
| 121 | pr ivate Adap terPolicyE nginePortT ype adapte rPolicyEng ine; | |
| 122 | pr ivate NHIN DocQueryRe questSende r nhinDocQ ueryReques tSender; | |
| 123 | pr ivate Exec utorServic e executor Service; | |
| 124 | pr ivate Requ estAudit r equestAudi t; | |
| 125 | ||
| 126 | @E JB(beanInt erface = F acilityMan agerLocal. class, bea nName = "F acilityMan ager") | |
| 127 | pu blic void setFacilit yManager(F acilityMan ager facil ityManager ) | |
| 128 | { | |
| 129 | this .facilityM anager = f acilityMan ager; | |
| 130 | } | |
| 131 | ||
| 132 | @E JB(beanInt erface = A dapterPoli cyEnginePo rtTypeLoca l.class, b eanName = "AdapterPo licyEngine ") | |
| 133 | pu blic void setAdapter PolicyEngi ne(Adapter PolicyEngi nePortType adapterPo licyEngine ) | |
| 134 | { | |
| 135 | this .adapterPo licyEngine = adapter PolicyEngi ne; | |
| 136 | } | |
| 137 | ||
| 138 | @E JB(beanInt erface = P atientCorr elationPor tTypeLocal .class, be anName = " AdapterPat ientCorrel ation") | |
| 139 | pu blic void setAdapter PatientCor relation(P atientCorr elationPor tType adap terPatient Correlatio n) | |
| 140 | { | |
| 141 | this .adapterPa tientCorre lation = a dapterPati entCorrela tion; | |
| 142 | } | |
| 143 | ||
| 144 | @E JB(beanInt erface = N HINDocQuer yRequestSe nder.class , beanName = "NhincP roxyNHINDo cQueryRequ estSender" ) | |
| 145 | pu blic void setNhinDoc QueryReque stSender(N HINDocQuer yRequestSe nder nhinD ocQueryReq uestSender ) | |
| 146 | { | |
| 147 | this .nhinDocQu eryRequest Sender = n hinDocQuer yRequestSe nder; | |
| 148 | } | |
| 149 | ||
| 150 | @E JB(beanInt erface = W orkManager ExecutorSe rviceLocal .class, be anName = " WorkManage rExecutorS ervice") | |
| 151 | pu blic void setExecuto rService(E xecutorSer vice execu torService ) | |
| 152 | { | |
| 153 | this .executorS ervice = e xecutorSer vice; | |
| 154 | } | |
| 155 | ||
| 156 | @E JB(beanInt erface = R equestAudi t.class, b eanName = "RequestAu dit") | |
| 157 | pu blic void setRequest Audit(Requ estAudit r equestAudi t) | |
| 158 | { | |
| 159 | this .requestAu dit = requ estAudit; | |
| 160 | } | |
| 161 | ||
| 162 | pu blic Respo ndingGatew ayCrossGat ewayQueryR esponseTyp e respondi ngGatewayC rossGatewa yQuery(Res pondingGat ewayCrossG atewayQuer yRequestTy pe respond ingGateway CrossGatew ayQueryReq uest) | |
| 163 | { | |
| 164 | Resp ondingGate wayCrossGa tewayQuery ResponseTy pe ret = c reateRespo ndingGatew ayCrossGat ewayQueryR esponse(); | |
| 165 | ||
| 166 | Exec utorComple tionServic e<SendRequ estRespons e> complet ionService = new Exe cutorCompl etionServi ce<SendReq uestRespon se>(execut orService) ; | |
| 167 | II p atientId = getPatien tId(respon dingGatewa yCrossGate wayQueryRe quest.getA dhocQueryR equest()); | |
| 168 | ||
| 169 | logg er.debug(" Patient Id {} :", pa tientId); | |
| 170 | ||
| 171 | if(p atientId ! = null) | |
| 172 | { | |
| 173 | // Set up incomin g request audit valu es. | |
| 174 | Reques tAuditEnti ty request AuditEntit y = new Re questAudit Entity(); | |
| 175 | reques tAuditEnti ty.setPid( patientId. getExtensi on()); | |
| 176 | reques tAuditEnti ty.generat eUUID(); | |
| 177 | reques tAuditEnti ty.setStar tTime(new Date()); | |
| 178 | reques tAuditEnti ty.setActi on(Request Actions.PA RENT_REQUE ST.getValu e()); | |
| 179 | ||
| 180 | // CCR 177986 | |
| 181 | logger .debug("Re questAudit Entity req uestAuditE ntity {} " , requestA uditEntity ); | |
| 182 | ||
| 183 | if(res pondingGat ewayCrossG atewayQuer yRequest ! = null && responding GatewayCro ssGatewayQ ueryReques t.getAsser tion() != null && re spondingGa tewayCross GatewayQue ryRequest. getAsserti on().getHo meCommunit y() != nul l && Strin gUtils.isN otBlank(re spondingGa tewayCross GatewayQue ryRequest. getAsserti on().getHo meCommunit y().getHom eCommunity Id())) | |
| 184 | { | |
| 185 | logger.d ebug("Home community Id {} fro m the requ est ", res pondingGat ewayCrossG atewayQuer yRequest.g etAssertio n().getHom eCommunity ().getHome CommunityI d()); // C CR | |
| 186 | // 177 986 | |
| 187 | ||
| 188 | requestA uditEntity .setHcid(r espondingG atewayCros sGatewayQu eryRequest .getAssert ion().getH omeCommuni ty().getHo meCommunit yId()); | |
| 189 | } | |
| 190 | else | |
| 191 | { | |
| 192 | requestA uditEntity .setHcid(" UNKNOWN"); | |
| 193 | } | |
| 194 | ||
| 195 | Retrie vePatientC orrelation sResponseT ype patien tCorrelati ons = getP atientCorr elations(p atientId, responding GatewayCro ssGatewayQ ueryReques t.getAsser tion()); | |
| 196 | if(pat ientCorrel ations != null && pa tientCorre lations.ge tPRPAIN201 310UV02() != null) | |
| 197 | { | |
| 198 | int numS ubmitted = 0; | |
| 199 | PRPAMT20 1304UV02Pa tient pati ent = extr actPatient (patientCo rrelations .getPRPAIN 201310UV02 ()); | |
| 200 | ||
| 201 | for(II c orrelatedP atientId : patient.g etId()) | |
| 202 | { | |
| 203 | List<Strin g> remoteH omeCommuni tyIds = ge tRemoteHom eCommunity Ids(correl atedPatien tId); | |
| 204 | for(String remoteHom eCommunity Id : remot eHomeCommu nityIds) | |
| 205 | { | |
| 206 | if (facilityM anager.isP artnerAllo wed(remote HomeCommun ityId, Ope rationOnOf f.ONBOARD) ) | |
| 207 | { | |
| 208 | if(f acilityMan ager.isPar tnerAllowe d(remoteHo meCommunit yId, Opera tionOnOff. OUT_DQ)) | |
| 209 | { | |
| 210 | AdhocQ ueryReques t adhocQue ryRequest = createAd hocQueryRe quest(resp ondingGate wayCrossGa tewayQuery Request.ge tAdhocQuer yRequest() , remoteHo meCommunit yId, corre latedPatie ntId); | |
| 211 | if(che ckPolicy(a dhocQueryR equest, re spondingGa tewayCross GatewayQue ryRequest. getAsserti on(), remo teHomeComm unityId)) | |
| 212 | { | |
| 213 | SendRequ estCallabl e callable = new Sen dRequestCa llable(adh ocQueryReq uest, resp ondingGate wayCrossGa tewayQuery Request.ge tAssertion (), correl atedPatien tId, remot eHomeCommu nityId, re questAudit Entity.get Uuid()); | |
| 214 | completi onService. submit(cal lable); | |
| 215 | ++numSub mitted; | |
| 216 | } | |
| 217 | } | |
| 218 | else | |
| 219 | { | |
| 220 | addErr orToRespon se(ret, re spondingGa tewayCross GatewayQue ryRequest. getAdhocQu eryRequest (), ErrorM essage.OUT _DQ_DISABL ED.getMess age(), rem oteHomeCom munityId, correlated PatientId. getExtensi on()); | |
| 221 | ||
| 222 | // CCR 177986 - parameteri zed loggin g | |
| 223 | logger .error(Err orMessage. OUT_DQ_DIS ABLED + " {} ", "Rem ote Commun ity ID"); | |
| 224 | } | |
| 225 | } | |
| 226 | el se | |
| 227 | { | |
| 228 | addE rrorToResp onse(ret, responding GatewayCro ssGatewayQ ueryReques t.getAdhoc QueryReque st(), Erro rMessage.O UT_DQ_NOT_ A_PARTNER. getMessage (), remote HomeCommun ityId, cor relatedPat ientId.get Extension( )); | |
| 229 | ||
| 230 | // C CR 177986 - paramete rized logg ing | |
| 231 | logg er.error(E rrorMessag e.OUT_DQ_N OT_A_PARTN ER + " {} ", "Remote Community ID"); | |
| 232 | } | |
| 233 | } | |
| 234 | } | |
| 235 | ||
| 236 | if(patie nt.getId() .size() < 1) | |
| 237 | { | |
| 238 | // CCR 177 986- added logger as a paramet er | |
| 239 | MaintLog.q ueryError( responding GatewayCro ssGatewayQ ueryReques t, ErrorMe ssage.OUT_ DQ_NO_CORR ELATIONS, logger); | |
| 240 | } | |
| 241 | ||
| 242 | for(int i = 0; i < numSubmit ted; ++i) | |
| 243 | { | |
| 244 | try | |
| 245 | { | |
| 246 | Se ndRequestR esponse re sponse = c ompletionS ervice.tak e().get(); | |
| 247 | if (!response .hasError( )) | |
| 248 | { | |
| 249 | addR esultToRes ponse(ret, response) ; | |
| 250 | } | |
| 251 | el se | |
| 252 | { | |
| 253 | Send RequestExc eption sre = respons e.sre; | |
| 254 | addE rrorToResp onse(ret, responding GatewayCro ssGatewayQ ueryReques t.getAdhoc QueryReque st(), Stri ngUtils.EM PTY, sre.r emoteHomeC ommunityId , sre.remo tePatientI d.getExten sion()); | |
| 255 | ||
| 256 | // C CR 177986- logging u pdates | |
| 257 | logg er.error(" Error send ing DocQue ry for com munity Id: {} with e xception: {}", new O bject[] { sre.remote HomeCommun ityId, sre .getCause( ).getMessa ge() }); | |
| 258 | } | |
| 259 | } | |
| 260 | catch(Exec utionExcep tion ee) | |
| 261 | { | |
| 262 | lo gger.error ("An Unkno wn error o ccured pro cessing an outbound doc query request", ee); | |
| 263 | Ma intLog.que ryError(re spondingGa tewayCross GatewayQue ryRequest, ErrorMess age.OUT_DQ _UNKNOWN, "An Unknow n error oc cured proc essing an outbound d oc query r equest.", logger); | |
| 264 | } | |
| 265 | catch(Inte rruptedExc eption ie) | |
| 266 | { | |
| 267 | lo gger.error ("Outbound Doc Query Threads i nterrupted . Return will not b e complete ", ie); | |
| 268 | } | |
| 269 | catch(Exce ption e) | |
| 270 | { | |
| 271 | lo gger.error ("Error in Outbound Doc Query" , e); | |
| 272 | } | |
| 273 | } | |
| 274 | } | |
| 275 | else | |
| 276 | { | |
| 277 | MaintLog .queryErro r(respondi ngGatewayC rossGatewa yQueryRequ est, Error Message.OU T_DQ_NO_CO RRELATIONS , logger); | |
| 278 | } | |
| 279 | ||
| 280 | reques tAudit.sto reAudit(re questAudit Entity); | |
| 281 | } | |
| 282 | else | |
| 283 | { | |
| 284 | MaintL og.queryEr ror(respon dingGatewa yCrossGate wayQueryRe quest, Err orMessage. OUT_DQ_NO_ PATIENT_ID , logger); | |
| 285 | } | |
| 286 | ||
| 287 | retu rn ret; | |
| 288 | } | |
| 289 | ||
| 290 | pr ivate Resp ondingGate wayCrossGa tewayQuery ResponseTy pe createR espondingG atewayCros sGatewayQu eryRespons e() | |
| 291 | { | |
| 292 | Comm unityAdhoc QueryRespo nsesType c ommunityRe sponses = new Commun ityAdhocQu eryRespons esType(); | |
| 293 | ||
| 294 | Resp ondingGate wayCrossGa tewayQuery ResponseTy pe ret = n ew Respond ingGateway CrossGatew ayQueryRes ponseType( ); | |
| 295 | ret. setCommuni tyResponse s(communit yResponses ); | |
| 296 | ||
| 297 | retu rn ret; | |
| 298 | } | |
| 299 | ||
| 300 | pr ivate II g etPatientI d(AdhocQue ryRequest adhocQuery Request) | |
| 301 | { | |
| 302 | II r et = new I I(); | |
| 303 | Map< String, Li st<String> > slotMap = getMapFr omSlots(ad hocQueryRe quest.getA dhocQuery( ).getSlot( )); | |
| 304 | Stri ng patient Id = slotM ap.get(EBX ML_DOCENTR Y_PATIENT_ ID).get(0) ; | |
| 305 | Patt ern p = Pa ttern.comp ile("\\d{1 0}V\\d{6}" ); | |
| 306 | Matc her m = p. matcher(pa tientId); | |
| 307 | if(m .find()) | |
| 308 | { | |
| 309 | ret = new II(); | |
| 310 | ret.se tExtension (m.group() ); | |
| 311 | ret.se tRoot(getH omeCommuni tyId()); | |
| 312 | } | |
| 313 | retu rn ret; | |
| 314 | } | |
| 315 | ||
| 316 | pr ivate Map< String, Li st<String> > getMapFr omSlots(Li st<SlotTyp e1> slots) | |
| 317 | { | |
| 318 | Hash Map<String , List<Str ing>> ret = new Hash Map<String , List<Str ing>>(); | |
| 319 | ||
| 320 | for( SlotType1 slot : slo ts) | |
| 321 | { | |
| 322 | if(!Nu llChecker. isNullOrEm pty(slot.g etName()) && !NullCh ecker.isNu llOrEmpty( slot.getVa lueList()) && !NullC hecker.isN ullOrEmpty (slot.getV alueList() .getValue( ))) | |
| 323 | { | |
| 324 | List<Str ing> value s = ret.ge t(slot.get Name()); | |
| 325 | if(value s == null) | |
| 326 | { | |
| 327 | values = n ew ArrayLi st<String> (); | |
| 328 | ret.put(sl ot.getName (), values ); | |
| 329 | } | |
| 330 | values.a ddAll(pars eParamForm attedStrin gs(slot.ge tValueList ().getValu e())); | |
| 331 | } | |
| 332 | } | |
| 333 | ||
| 334 | retu rn ret; | |
| 335 | } | |
| 336 | ||
| 337 | pu blic List< String> pa rseParamFo rmattedStr ings(List< String> pa ramFormatt edStrings) | |
| 338 | { | |
| 339 | List <String> r et = new A rrayList<S tring>(); | |
| 340 | ||
| 341 | for( String par amFormatte dString : paramForma ttedString s) | |
| 342 | { | |
| 343 | parseP aramFormat tedString( paramForma ttedString , ret); | |
| 344 | } | |
| 345 | ||
| 346 | retu rn ret; | |
| 347 | } | |
| 348 | ||
| 349 | pu blic void parseParam FormattedS tring(Stri ng paramFo rmattedStr ing, List< String> re sultCollec tion) | |
| 350 | { | |
| 351 | if(( paramForma ttedString != null) && (result Collection != null)) | |
| 352 | { | |
| 353 | String working = paramForm attedStrin g; | |
| 354 | if(par amFormatte dString.st artsWith(" (")) | |
| 355 | { | |
| 356 | working = paramFor mattedStri ng.substri ng(1); | |
| 357 | int endI ndex = wor king.index Of(")"); | |
| 358 | if(endIn dex != -1) | |
| 359 | { | |
| 360 | working = working.su bstring(0, endIndex) ; | |
| 361 | } | |
| 362 | } | |
| 363 | String [] multiVa lueString = working. split(",") ; | |
| 364 | if(mul tiValueStr ing != nul l) | |
| 365 | { | |
| 366 | for(int i = 0; i < multiValu eString.le ngth; i++) | |
| 367 | { | |
| 368 | String sin gleValue = multiValu eString[i] ; | |
| 369 | if(singleV alue != nu ll) | |
| 370 | { | |
| 371 | si ngleValue = singleVa lue.trim() ; | |
| 372 | } | |
| 373 | if(singleV alue.start sWith("'") ) | |
| 374 | { | |
| 375 | si ngleValue = singleVa lue.substr ing(1); | |
| 376 | in t endTickI ndex = sin gleValue.i ndexOf("'" ); | |
| 377 | if (endTickIn dex != -1) | |
| 378 | { | |
| 379 | sing leValue = singleValu e.substrin g(0, endTi ckIndex); | |
| 380 | } | |
| 381 | } | |
| 382 | resultColl ection.add (singleVal ue); | |
| 383 | } | |
| 384 | } | |
| 385 | } | |
| 386 | } | |
| 387 | ||
| 388 | pr ivate Retr ievePatien tCorrelati onsRespons eType getP atientCorr elations(I I patientI d, Asserti onType ass ertion) | |
| 389 | { | |
| 390 | Retr ievePatien tCorrelati onsRequest Type reque st = creat eRetrieveP atientCorr elationsRe quest(pati entId); | |
| 391 | requ est.setAss ertion(ass ertion); | |
| 392 | retu rn adapter PatientCor relation.r etrievePat ientCorrel ations(req uest); | |
| 393 | } | |
| 394 | ||
| 395 | pr ivate Retr ievePatien tCorrelati onsRequest Type creat eRetrieveP atientCorr elationsRe quest(II p atientId) | |
| 396 | { | |
| 397 | Retr ievePatien tCorrelati onsRequest Type ret = new Retri evePatient Correlatio nsRequestT ype(); | |
| 398 | ret. setPRPAIN2 01309UV02( HL7PRPA201 309Transfo rms.create PRPA201309 (patientId .getRoot() , patientI d.getExten sion())); | |
| 399 | retu rn ret; | |
| 400 | } | |
| 401 | ||
| 402 | pr ivate Stri ng getHome CommunityI d() | |
| 403 | { | |
| 404 | Stri ng ret = n ull; | |
| 405 | Faci lity facil ity = faci lityManage r.getFacil ityByFacil ityNumber( "VA"); | |
| 406 | if(f acility != null) | |
| 407 | { | |
| 408 | ret = facility.g etHomeComm unityId(); | |
| 409 | } | |
| 410 | retu rn ret; | |
| 411 | } | |
| 412 | ||
| 413 | pr ivate PRPA MT201304UV 02Patient extractPat ient(PRPAI N201310UV0 2 prpain20 1310UV02) | |
| 414 | { | |
| 415 | PRPA MT201304UV 02Patient ret = null ; | |
| 416 | ||
| 417 | if(p rpain20131 0UV02.getC ontrolActP rocess() ! = null && !NullCheck er.isNullO rEmpty(prp ain201310U V02.getCon trolActPro cess().get Subject()) && prpain 201310UV02 .getContro lActProces s().getSub ject().get (0).getReg istrationE vent() != null && pr pain201310 UV02.getCo ntrolActPr ocess().ge tSubject() .get(0).ge tRegistrat ionEvent() .getSubjec t1() != nu ll && prpa in201310UV 02.getCont rolActProc ess().getS ubject().g et(0).getR egistratio nEvent().g etSubject1 ().getPati ent() != n ull) | |
| 418 | { | |
| 419 | ret = prpain2013 10UV02.get ControlAct Process(). getSubject ().get(0). getRegistr ationEvent ().getSubj ect1().get Patient(); | |
| 420 | } | |
| 421 | ||
| 422 | retu rn ret; | |
| 423 | } | |
| 424 | ||
| 425 | pr ivate List <String> g etRemoteHo meCommunit yIds(II re motePatien tId) | |
| 426 | { | |
| 427 | List <String> r et = new A rrayList<S tring>(); | |
| 428 | List <Facility> remoteFac ilities = facilityMa nager.getF acilitiesC ontainingA ssigningAu thority(re motePatien tId.getRoo t()); | |
| 429 | ||
| 430 | if(N ullChecker .isNotNull OrEmpty(re moteFacili ties)) | |
| 431 | { | |
| 432 | for(Fa cility rem oteFacilit y : remote Facilities ) | |
| 433 | { | |
| 434 | ret.add( remoteFaci lity.getHo meCommunit yId()); | |
| 435 | } | |
| 436 | } | |
| 437 | ||
| 438 | retu rn ret; | |
| 439 | } | |
| 440 | ||
| 441 | pr ivate bool ean checkP olicy(Adho cQueryRequ est adhocQ ueryReques t, Asserti onType ass ertion, St ring homeC ommunityId ) | |
| 442 | { | |
| 443 | Adho cQueryRequ estMessage Type adhoc QueryReque stMessage = new Adho cQueryRequ estMessage Type(); | |
| 444 | adho cQueryRequ estMessage .setAdhocQ ueryReques t(adhocQue ryRequest) ; | |
| 445 | adho cQueryRequ estMessage .setAssert ion(assert ion); | |
| 446 | ||
| 447 | Home CommunityT ype receiv ingHomeCom munity = n ew HomeCom munityType (); | |
| 448 | rece ivingHomeC ommunity.s etHomeComm unityId(ho meCommunit yId); | |
| 449 | ||
| 450 | Home CommunityT ype sendin gHomeCommu nity = new HomeCommu nityType() ; | |
| 451 | send ingHomeCom munity.set HomeCommun ityId(getH omeCommuni tyId()); | |
| 452 | ||
| 453 | Adho cQueryRequ estEventTy pe adhocQu eryRequest Event = ne w AdhocQue ryRequestE ventType() ; | |
| 454 | adho cQueryRequ estEvent.s etMessage( adhocQuery RequestMes sage); | |
| 455 | adho cQueryRequ estEvent.s etDirectio n(NhincCon stants.POL ICYENGINE_ OUTBOUND_D IRECTION); | |
| 456 | adho cQueryRequ estEvent.s etReceivin gHomeCommu nity(recei vingHomeCo mmunity); | |
| 457 | adho cQueryRequ estEvent.s etSendingH omeCommuni ty(sending HomeCommun ity); | |
| 458 | adho cQueryRequ estEvent.s etInterfac e(NhincCon stants.AUD IT_LOG_ENT ITY_INTERF ACE); | |
| 459 | ||
| 460 | Poli cyEngineTr ansformer policyEngi neTransfor mer = new PolicyEngi neTransfor mer(); | |
| 461 | Chec kPolicyReq uestType c heckPolicy Request = policyEngi neTransfor mer.transf ormAdhocQu eryToCheck Policy(adh ocQueryReq uestEvent) ; | |
| 462 | ||
| 463 | Chec kPolicyRes ponseType checkPolic yResponse = adapterP olicyEngin e.checkPol icy(checkP olicyReque st); | |
| 464 | ||
| 465 | retu rn CheckPo licy.check Policy(che ckPolicyRe quest, che ckPolicyRe sponse); | |
| 466 | } | |
| 467 | ||
| 468 | pr ivate Send RequestRes ponse send Request(Ad hocQueryRe quest adho cQueryRequ est, Asser tionType a ssertion, II remoteP atientId, String rem oteHomeCom munityId, final Stri ng auditUU ID) throws SendReque stExceptio n | |
| 469 | { | |
| 470 | Send RequestRes ponse ret = new Send RequestRes ponse(); | |
| 471 | Requ estAuditEn tity audit Entity = n ew Request AuditEntit y(); | |
| 472 | audi tEntity.se tStartTime (new Date( )); | |
| 473 | audi tEntity.se tUuid(audi tUUID); | |
| 474 | audi tEntity.se tHcid(remo teHomeComm unityId); | |
| 475 | audi tEntity.se tPid(remot ePatientId .getExtens ion()); | |
| 476 | audi tEntity.se tAction(Re questActio ns.QUERY_R EQUEST.get Value()); | |
| 477 | ||
| 478 | try | |
| 479 | { | |
| 480 | final String ver sion = "2. 0"; | |
| 481 | ret.ad hocQueryRe sponse = n hinDocQuer yRequestSe nder.sendR equest(adh ocQueryReq uest, asse rtion, rem oteHomeCom munityId, version); | |
| 482 | auditE ntity.setS topTime(ne w Date()); | |
| 483 | auditE ntity.setS tatus(ret. adhocQuery Response.g etStatus() ); | |
| 484 | reques tAudit.sto reAudit(au ditEntity) ; | |
| 485 | ret.re moteHomeCo mmunityId = remoteHo meCommunit yId; | |
| 486 | ret.re motePatien tId = remo tePatientI d; | |
| 487 | } | |
| 488 | catc h(Throwabl e e) | |
| 489 | { | |
| 490 | SendRe questExcep tion sre = new SendR equestExce ption(); | |
| 491 | sre.re moteHomeCo mmunityId = remoteHo meCommunit yId; | |
| 492 | sre.re motePatien tId = remo tePatientI d; | |
| 493 | sre.in itCause(e) ; | |
| 494 | auditE ntity.setS topTime(ne w Date()); | |
| 495 | auditE ntity.setS tatus("Fai led:" + e. getMessage ()); | |
| 496 | reques tAudit.sto reAudit(au ditEntity) ; | |
| 497 | ret.sr e = sre; | |
| 498 | } | |
| 499 | retu rn ret; | |
| 500 | } | |
| 501 | ||
| 502 | pr ivate Adho cQueryRequ est create AdhocQuery Request(Ad hocQueryRe quest from AdhocQuery Request, S tring home CommunityI d, II remo tePatientI d) | |
| 503 | { | |
| 504 | Adho cQueryRequ est ret = new AdhocQ ueryReques t(); | |
| 505 | ret. setFederat ion(fromAd hocQueryRe quest.getF ederation( )); | |
| 506 | ret. setMaxResu lts(fromAd hocQueryRe quest.getM axResults( )); | |
| 507 | ret. setStartIn dex(fromAd hocQueryRe quest.getS tartIndex( )); | |
| 508 | ret. setId(from AdhocQuery Request.ge tId()); | |
| 509 | ret. setComment (fromAdhoc QueryReque st.getComm ent()); | |
| 510 | ret. setRequest SlotList(f romAdhocQu eryRequest .getReques tSlotList( )); | |
| 511 | ret. setAdhocQu ery(create AdhocQuery (fromAdhoc QueryReque st.getAdho cQuery(), homeCommun ityId, rem otePatient Id)); | |
| 512 | ret. setRespons eOption(fr omAdhocQue ryRequest. getRespons eOption()) ; | |
| 513 | retu rn ret; | |
| 514 | } | |
| 515 | ||
| 516 | pr ivate Adho cQueryType createAdh ocQuery(Ad hocQueryTy pe fromAdh ocQuery, S tring home CommunityI d, II remo tePatientI d) | |
| 517 | { | |
| 518 | Adho cQueryType ret = new AdhocQuer yType(); | |
| 519 | ret. setDescrip tion(fromA dhocQuery. getDescrip tion()); | |
| 520 | ret. setHome("u rn:oid:" + homeCommu nityId); | |
| 521 | ret. setId(from AdhocQuery .getId()); | |
| 522 | ret. setLid(fro mAdhocQuer y.getLid() ); | |
| 523 | ret. setName(fr omAdhocQue ry.getName ()); | |
| 524 | ret. setObjectT ype(fromAd hocQuery.g etObjectTy pe()); | |
| 525 | ret. setQueryEx pression(f romAdhocQu ery.getQue ryExpressi on()); | |
| 526 | ret. setStatus( fromAdhocQ uery.getSt atus()); | |
| 527 | ret. setVersion Info(fromA dhocQuery. getVersion Info()); | |
| 528 | ret. getExterna lIdentifie r().addAll (fromAdhoc Query.getE xternalIde ntifier()) ; | |
| 529 | ret. getSlot(). addAll(cre ateSlots(f romAdhocQu ery.getSlo t(), remot ePatientId )); | |
| 530 | ret. getClassif ication(). addAll(fro mAdhocQuer y.getClass ification( )); | |
| 531 | retu rn ret; | |
| 532 | } | |
| 533 | ||
| 534 | pr ivate List <SlotType1 > createSl ots(List<S lotType1> slots, II remotePati entId) | |
| 535 | { | |
| 536 | Arra yList<Slot Type1> ret = new Arr ayList<Slo tType1>(); | |
| 537 | ||
| 538 | for( SlotType1 slot : slo ts) | |
| 539 | { | |
| 540 | SlotTy pe1 newSlo t; | |
| 541 | if(slo t.getName( ).equals(E BXML_DOCEN TRY_PATIEN T_ID)) | |
| 542 | { | |
| 543 | newSlot = new Slot Type1(); | |
| 544 | newSlot. setName(EB XML_DOCENT RY_PATIENT _ID); | |
| 545 | newSlot. setValueLi st(createV alueList(" '" + remot ePatientId .getExtens ion() + "^ ^^&" + rem otePatient Id.getRoot () + "&ISO '")); | |
| 546 | } | |
| 547 | else | |
| 548 | { | |
| 549 | newSlot = slot; | |
| 550 | } | |
| 551 | ret.ad d(newSlot) ; | |
| 552 | } | |
| 553 | ||
| 554 | retu rn ret; | |
| 555 | } | |
| 556 | ||
| 557 | pr ivate Valu eListType createValu eList(Stri ng value) | |
| 558 | { | |
| 559 | Valu eListType ret = new ValueListT ype(); | |
| 560 | ret. getValue() .add(value ); | |
| 561 | retu rn ret; | |
| 562 | } | |
| 563 | ||
| 564 | pr ivate void addResult ToResponse (Respondin gGatewayCr ossGateway QueryRespo nseType re spondingGa tewayCross GatewayQue ryResponse , SendRequ estRespons e response ) | |
| 565 | { | |
| 566 | Home CommunityT ype homeCo mmunity = new HomeCo mmunityTyp e(); | |
| 567 | home Community. setHomeCom munityId(r esponse.re moteHomeCo mmunityId) ; | |
| 568 | Faci lity facil ity = faci lityManage r.getFacil ityByHomeC ommunityId (response. remoteHome CommunityI d); | |
| 569 | home Community. setName(fa cility.get FacilityNa me()); | |
| 570 | ||
| 571 | Nhin TargetComm unityType nhinTarget Community = new Nhin TargetComm unityType( ); | |
| 572 | nhin TargetComm unity.setH omeCommuni ty(homeCom munity); | |
| 573 | ||
| 574 | Comm unityAdhoc QueryRespo nseType co mmunityRes ponse = ne w Communit yAdhocQuer yResponseT ype(); | |
| 575 | comm unityRespo nse.setAdh ocQueryRes ponse(resp onse.adhoc QueryRespo nse); | |
| 576 | comm unityRespo nse.setNhi nTargetCom munity(nhi nTargetCom munity); | |
| 577 | ||
| 578 | resp ondingGate wayCrossGa tewayQuery Response.g etCommunit yResponses ().getComm unityRespo nse().add( communityR esponse); | |
| 579 | } | |
| 580 | ||
| 581 | pr ivate void addErrorT oResponse( Responding GatewayCro ssGatewayQ ueryRespon seType res pondingGat ewayCrossG atewayQuer yResponse, AdhocQuer yRequest a dhocQueryR equest, fi nal String errorMess age, final String hc id, final String pat ientId) | |
| 582 | { | |
| 583 | Adho cQueryResp onse adhoc QueryRespo nse = crea teAdhocQue ryResponse Error(adho cQueryRequ est); | |
| 584 | adho cQueryResp onse.setRe gistryErro rList(new RegistryEr rorList()) ; | |
| 585 | adho cQueryResp onse.getRe gistryErro rList().se tHighestSe verity("ur n:oasis:na mes:tc:ebx ml-regrep: ErrorSever ityType:Er ror"); | |
| 586 | ||
| 587 | Regi stryError registryEr ror = new RegistryEr ror(); | |
| 588 | regi stryError. setErrorCo de("XDSReg istryError "); | |
| 589 | regi stryError. setCodeCon text("Inte rnal Regis try/Reposi tory Error - HCID = " + hcid + " - " + " , patientI d = " + pa tientId + " " + erro rMessage); | |
| 590 | regi stryError. setSeverit y("urn:oas is:names:t c:ebxml-re grep:Error SeverityTy pe:Error") ; | |
| 591 | adho cQueryResp onse.getRe gistryErro rList().ge tRegistryE rror().add (registryE rror); | |
| 592 | ||
| 593 | Home CommunityT ype homeCo mmunity = new HomeCo mmunityTyp e(); | |
| 594 | home Community. setHomeCom munityId(h cid); | |
| 595 | Faci lity facil ity = faci lityManage r.getFacil ityByHomeC ommunityId (hcid); | |
| 596 | home Community. setName(fa cility.get FacilityNa me()); | |
| 597 | ||
| 598 | Nhin TargetComm unityType nhinTarget Community = new Nhin TargetComm unityType( ); | |
| 599 | nhin TargetComm unity.setH omeCommuni ty(homeCom munity); | |
| 600 | ||
| 601 | Comm unityAdhoc QueryRespo nseType co mmunityRes ponse = ne w Communit yAdhocQuer yResponseT ype(); | |
| 602 | comm unityRespo nse.setAdh ocQueryRes ponse(adho cQueryResp onse); | |
| 603 | comm unityRespo nse.setNhi nTargetCom munity(nhi nTargetCom munity); | |
| 604 | ||
| 605 | resp ondingGate wayCrossGa tewayQuery Response.g etCommunit yResponses ().getComm unityRespo nse().add( communityR esponse); | |
| 606 | } | |
| 607 | ||
| 608 | pr ivate Adho cQueryResp onse creat eAdhocQuer yResponseE rror(Adhoc QueryReque st adhocQu eryRequest ) | |
| 609 | { | |
| 610 | Adho cQueryResp onse ret = new Adhoc QueryRespo nse(); | |
| 611 | ret. setRequest Id(adhocQu eryRequest .getId()); | |
| 612 | ret. setStartIn dex(adhocQ ueryReques t.getStart Index()); | |
| 613 | ret. setStatus( "urn:oasis :names:tc: ebxml-regr ep:Respons eStatusTyp e:Failure" ); | |
| 614 | retu rn ret; | |
| 615 | } | |
| 616 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.