Produced by Araxis Merge on 3/1/2018 12:13:14 PM Central Standard 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 | ehealth_xchange_cif.zip\NHIN_adapter\AdapterEJB\src\main\java\gov\va\med\nhin\adapter\adapterxdr | AdapterXDR.java | Thu Feb 22 14:26:26 2018 UTC |
| 2 | ehealth_xchange_cif.zip\NHIN_adapter\AdapterEJB\src\main\java\gov\va\med\nhin\adapter\adapterxdr | AdapterXDR.java | Tue Feb 27 14:24:11 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1810 |
| Changed | 1 | 4 |
| 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.adapterx dr; | |
| 2 | ||
| 3 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.Assert ionType; | |
| 4 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.Person NameType; | |
| 5 | import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .AdapterPr ovideAndRe gisterDocu mentSetReq uestType; | |
| 6 | ||
| 7 | import jav ax.ejb.*; | |
| 8 | import jav ax.jws.Web Service; | |
| 9 | import jav ax.xml.ws. BindingTyp e; | |
| 10 | import jav ax.xml.ws. soap.SOAPB inding; | |
| 11 | ||
| 12 | import gov .hhs.fha.n hinc.nhinc componentp atientcorr elation.Pa tientCorre lationPort Type; | |
| 13 | import gov .hhs.fha.n hinc.trans form.subdi sc.HL7PRPA 201309Tran sforms; | |
| 14 | import gov .va.med.nh in.adapter .audit.Aud it; | |
| 15 | import gov .va.med.nh in.adapter .audit.Aud itManager; | |
| 16 | import gov .va.med.nh in.adapter .audit.Aud itManagerL ocal; | |
| 17 | import gov .va.med.nh in.adapter .documentr epository. Document; | |
| 18 | import gov .va.med.nh in.adapter .documentr epository. DocumentRe pository; | |
| 19 | import gov .va.med.nh in.adapter .documentr epository. DocumentRe positoryLo cal; | |
| 20 | import gov .va.med.nh in.adapter .facilitym anager.Fac ility; | |
| 21 | import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag er; | |
| 22 | import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag erLocal; | |
| 23 | import gov .va.med.nh in.adapter .logging.E ventAuditi ngFactory; | |
| 24 | import gov .va.med.nh in.adapter .logging.E ventAuditi ngFactoryI mpl; | |
| 25 | import gov .va.med.nh in.adapter .logging.L ogConstant s; | |
| 26 | import gov .va.med.nh in.adapter .logging.L ogConstant s.Auditing Event; | |
| 27 | import gov .va.med.nh in.adapter .logging.M essagingHe lper; | |
| 28 | import gov .va.med.nh in.adapter .logging.M essagingHe lper.Query Type; | |
| 29 | import gov .va.med.nh in.adapter .patientco rrelation. PatientCor relationPo rtTypeLoca l; | |
| 30 | import gov .va.med.nh in.adapter .patientco rrelation. parsers.he lpers.Conf iguration; | |
| 31 | import gov .va.med.nh in.adapter .patientdi scovery.Va pConsentMa nagementPo rtTypeLoca l; | |
| 32 | import gov .va.med.nh in.adapter .propertyl ookup.Prop ertyLookup ; | |
| 33 | import gov .va.med.nh in.adapter .propertyl ookup.Prop ertyLookup Local; | |
| 34 | import gov .va.med.nh in.adapter .utils.Aud itUtil; | |
| 35 | import gov .va.med.nh in.adapter .utils.Log Util; | |
| 36 | import gov .va.med.nh in.adapter .utils.Nul lChecker; | |
| 37 | import gov .va.med.nh in.adapter .utils.das .DasDAO; | |
| 38 | import gov .va.med.nh in.adapter .utils.das .DasDAOHtt pImpl; | |
| 39 | import gov .va.med.nh in.adapter .utils.das .DasExcept ion; | |
| 40 | import gov .va.med.nh in.adapter .utils.das .DasOperat ionSendImm unizationD ataRequest ; | |
| 41 | import gov .va.med.nh in.adapter .utils.das .DasOperat ionSendImm unizationD ataRespons e; | |
| 42 | import gov .va.nvap.p rivacy.Org anizationT rustedSour ceRequestT ype; | |
| 43 | import gov .va.nvap.p rivacy.Org anizationT rustedSour ceResponse Type; | |
| 44 | import ihe .iti.xds_b ._2007.Pro videAndReg isterDocum entSetRequ estType; | |
| 45 | import jav a.io.ByteA rrayOutput Stream; | |
| 46 | import jav a.io.IOExc eption; | |
| 47 | import jav a.util.Dat e; | |
| 48 | import jav a.util.Lis t; | |
| 49 | import jav ax.ejb.EJB ; | |
| 50 | import jav ax.jws.Han dlerChain; | |
| 51 | import jav ax.xml.bin d.JAXBElem ent; | |
| 52 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Exte rnalIdenti fierType; | |
| 53 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Extr insicObjec tType; | |
| 54 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Iden tifiableTy pe; | |
| 55 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Regi stryObject ListType; | |
| 56 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Slot ListType; | |
| 57 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Slot Type1; | |
| 58 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Valu eListType; | |
| 59 | import oas is.names.t c.ebxml_re grep.xsd.r s._3.Regis tryError; | |
| 60 | import oas is.names.t c.ebxml_re grep.xsd.r s._3.Regis tryErrorLi st; | |
| 61 | import oas is.names.t c.ebxml_re grep.xsd.r s._3.Regis tryRespons eType; | |
| 62 | import oas is.names.t c.ebxml_re grep.xsd.r im._3.Regi stryPackag eType; | |
| 63 | import org .hl7.fhir. dstu3.mode l.AuditEve nt; | |
| 64 | import org .hl7.v3.II ; | |
| 65 | import org .hl7.v3.Re trievePati entCorrela tionsReque stType; | |
| 66 | import org .hl7.v3.Re trievePati entCorrela tionsRespo nseType; | |
| 67 | import org .slf4j.Log ger; | |
| 68 | import org .slf4j.Log gerFactory ; | |
| 69 | import pri vacy.servi ce.nvap. DNS .ConsentMa nagementPo rtType; | |
| 70 | import pri vacy.servi ce.nvap. DNS .ConsentMa nagementSe rviceFault Message; | |
| 71 | ||
| 72 | /** | |
| 73 | * This We b Service implements Document Submission functiona lity provi ded by | |
| 74 | * CONNECT Gateway. | |
| 75 | * | |
| 76 | * @author KazeninP | |
| 77 | */ | |
| 78 | @WebServic e(serviceN ame = "Ada pterXDR_Se rvice", | |
| 79 | endpoint Interface = "gov.hhs .fha.nhinc .adapterxd r.AdapterX DRPortType ", | |
| 80 | targetNa mespace = "urn:gov:h hs:fha:nhi nc:adapter xdr", | |
| 81 | portName = "Adapte rXDR_Port" /*, | |
| 82 | wsdlLoca tion = "ME TA-INF/wsd l/AdapterX DR.wsdl"*/ ) | |
| 83 | @BindingTy pe(SOAPBin ding.SOAP1 2HTTP_BIND ING) | |
| 84 | @HandlerCh ain(file = "SOAPHand lerChain.x ml") | |
| 85 | @Transacti onAttribut e(value = Transactio nAttribute Type.SUPPO RTS) | |
| 86 | @Stateless (name = "A dapterXDR" ) | |
| 87 | public cla ss Adapter XDR implem ents Adapt erXDRPortT ypeLocal | |
| 88 | { | |
| 89 | public static fi nal Logger logger = LoggerFact ory.getLog ger(Adapte rXDR.class .getName() ); | |
| 90 | ||
| 91 | static private f inal Strin g XDS_RETR IEVE_RESPO NSE_STATUS _FAILURE = "urn:oasi s:names:tc :ebxml-reg rep:Respon seStatusTy pe:Failure "; | |
| 92 | static private f inal Strin g XDS_RETR IEVE_RESPO NSE_STATUS _SUCCESS = "urn:oasi s:names:tc :ebxml-reg rep:Respon seStatusTy pe:Success "; | |
| 93 | ||
| 94 | privat e Property Lookup pro pertyLooku p; | |
| 95 | privat e Facility Manager fa cilityMana ger; | |
| 96 | privat e AuditMan ager audit Manager; | |
| 97 | privat e PatientC orrelation PortType a dapterPati entCorrela tion; | |
| 98 | privat e Document Repository documentR epository; | |
| 99 | privat e ConsentM anagementP ortType va pConsentMa nagement; | |
| 100 | privat e DasDAO d asDAO; | |
| 101 | ||
| 102 | @EJB(b eanInterfa ce = Prope rtyLookupL ocal.class , beanName = "Proper tyFileLook up") | |
| 103 | public void setP ropertyLoo kup(Proper tyLookup p ropertyLoo kup) | |
| 104 | { | |
| 105 | th is.propert yLookup = propertyLo okup; | |
| 106 | } | |
| 107 | ||
| 108 | public void setD asDAO(DasD AO dao) | |
| 109 | { | |
| 110 | th is.dasDAO = dao; | |
| 111 | } | |
| 112 | ||
| 113 | @EJB(b eanInterfa ce = Facil ityManager Local.clas s, beanNam e = "Facil ityManager ") | |
| 114 | public void setF acilityMan ager(Facil ityManager facilityM anager) | |
| 115 | { | |
| 116 | th is.facilit yManager = facilityM anager; | |
| 117 | } | |
| 118 | ||
| 119 | @EJB(b eanInterfa ce = Audit ManagerLoc al.class, beanName = "AuditMan ager") | |
| 120 | public void setA uditManage r(AuditMan ager audit Manager) | |
| 121 | { | |
| 122 | th is.auditMa nager = au ditManager ; | |
| 123 | } | |
| 124 | ||
| 125 | @EJB(b eanInterfa ce = Patie ntCorrelat ionPortTyp eLocal.cla ss, beanNa me = "Adap terPatient Correlatio n") | |
| 126 | public void setA dapterPati entCorrela tion(Patie ntCorrelat ionPortTyp e adapterP atientCorr elation) | |
| 127 | { | |
| 128 | th is.adapter PatientCor relation = adapterPa tientCorre lation; | |
| 129 | } | |
| 130 | ||
| 131 | @EJB(b eanInterfa ce = Docum entReposit oryLocal.c lass, bean Name = "Do cumentRepo sitory") | |
| 132 | public void setD ocumentRep ository(Do cumentRepo sitory doc umentRepos itory) | |
| 133 | { | |
| 134 | th is.documen tRepositor y = docume ntReposito ry; | |
| 135 | } | |
| 136 | ||
| 137 | @EJB(b eanInterfa ce = VapCo nsentManag ementPortT ypeLocal.c lass, bean Name = "Va pConsentMa nagement") | |
| 138 | public void setV apConsentM anagement( ConsentMan agementPor tType vapC onsentMana gement) | |
| 139 | { | |
| 140 | th is.vapCons entManagem ent = vapC onsentMana gement; | |
| 141 | } | |
| 142 | ||
| 143 | /* | |
| 144 | * Thi s method i mplements provideAnd RegisterDo cumentSetb operation defined | |
| 145 | * in the Adapte rXDR.wsdl. | |
| 146 | * | |
| 147 | * @pa ram reques t contains ICN, Home CommunityI d and C32 clinical d ocument | |
| 148 | * | |
| 149 | * @re turn respo nse contai ns either VLER BsonD ocId in ca se of succ ess or | |
| 150 | * err or descrip tion in ca se of fail ure | |
| 151 | */ | |
| 152 | @Overr ide | |
| 153 | public RegistryR esponseTyp e provideA ndRegister DocumentSe tb(Adapter ProvideAnd RegisterDo cumentSetR equestType request) | |
| 154 | { | |
| 155 | Ev entAuditin gFactory<A uditEvent> afac | |
| 156 | = EventAu ditingFact oryImpl.ge tFactory(A uditEvent. class); | |
| 157 | af ac.info(af ac.newEven t(request. getAsserti on(), | |
| 158 | LogConst ants.Audit ingEvent.S UBMITIN_BE GIN, getCl ass())); | |
| 159 | Me ssagingHel per<AuditE vent> msg = afac.mes saging(); | |
| 160 | ||
| 161 | // CCR 17798 6- logger update | |
| 162 | lo gger.debug ("provideA ndRegister DocumentSe tb() invok ed"); | |
| 163 | ||
| 164 | Re gistryResp onseType r et; | |
| 165 | ||
| 166 | St ring error Msg; | |
| 167 | ||
| 168 | Pr ovideAndRe gisterDocu mentSetReq uestType b ody = requ est.getPro videAndReg isterDocum entSetRequ est(); | |
| 169 | ||
| 170 | lo gger.debug ("body {}" , body); | |
| 171 | ||
| 172 | As sertionTyp e assertio n = reques t.getAsser tion(); | |
| 173 | ||
| 174 | St ring reque stId = get RequestId( body); | |
| 175 | ||
| 176 | lo gger.debug ("request id {}", re questId); | |
| 177 | ||
| 178 | // AuditEvent event = a fac.messag ing().reqr es(Auditin gEvent.INF O, Adapter XDR.class, getHomeCo mmunityId( assertion) ); | |
| 179 | // retrieve C32 doc fr om the mes sage | |
| 180 | by te[] c32do cument = g etC32Docum ent(body); | |
| 181 | ||
| 182 | // CCR 17798 6 | |
| 183 | lo gger.debug ("c32docum ent {}", c 32document ); | |
| 184 | ||
| 185 | if (NullChec ker.isNull OrEmpty(c3 2document) ) { | |
| 186 | ||
| 187 | errorMsg = "C32 Cl inical Doc ument is m issing, re quest Id = " + reque stId; | |
| 188 | ret = cr eateErrorR egistryRes ponseType( "XDSMissin gDocument" , errorMsg , null); | |
| 189 | ret.setR equestId(r equestId); | |
| 190 | ||
| 191 | // CCR 1 77986 | |
| 192 | logger.e rror("Erro r while cr eating reg istry resp ose {}", e rrorMsg); | |
| 193 | AuditEve nt event = afac.newE vent(Audit ingEvent.S UBMITIN_EN D, getClas s()); | |
| 194 | event.se tOutcome(A uditEvent. AuditEvent Outcome._8 ); | |
| 195 | event.se tOutcomeDe sc(errorMs g); | |
| 196 | afac.err or(event); | |
| 197 | ||
| 198 | return r et; | |
| 199 | } | |
| 200 | ||
| 201 | // CCR 17798 6 | |
| 202 | lo gger.debug ("C32 Clin ical Docum ent conten t {} :\n", new Strin g(c32docum ent)); | |
| 203 | ||
| 204 | // retrieve ICN from t he message | |
| 205 | St ring icn = getICN(bo dy); | |
| 206 | lo gger.debug ("icn {}", icn); | |
| 207 | if (NullChec ker.isNull OrEmpty(ic n)) { | |
| 208 | errorMsg = "ICN is missing, request Id = " + req uestId; | |
| 209 | ret = cr eateErrorR egistryRes ponseType( "XDSUnknow nPatientId ", errorMs g, null); | |
| 210 | ret.setR equestId(r equestId); | |
| 211 | ||
| 212 | logger.e rror(error Msg); | |
| 213 | ||
| 214 | AuditEve nt event = afac.newE vent(Audit ingEvent.S UBMITIN_EN D, getClas s()); | |
| 215 | event.se tOutcome(A uditEvent. AuditEvent Outcome._4 ); | |
| 216 | event.se tOutcomeDe sc(errorMs g); | |
| 217 | afac.err or(event); | |
| 218 | ||
| 219 | return r et; | |
| 220 | } | |
| 221 | ||
| 222 | // CCR 17798 6 | |
| 223 | lo gger.debug ("Patient Unique Id (ICN) {} = ", icn); | |
| 224 | ||
| 225 | // retrieve Home Commu nity Id fr om the mes sage | |
| 226 | St ring homeC ommunityId = getHome CommunityI d(assertio n); | |
| 227 | if (NullChec ker.isNull OrEmpty(ho meCommunit yId)) { | |
| 228 | errorMsg = "Home C ommunity I d is missi ng, reques t Id = " + requestId + ", ICN = " + icn; | |
| 229 | ret = cr eateErrorR egistryRes ponseType( "XDSMissin gHomeCommu nityId", e rrorMsg, n ull); | |
| 230 | ret.setR equestId(r equestId); | |
| 231 | ||
| 232 | logger.e rror(error Msg); | |
| 233 | ||
| 234 | AuditEve nt event = afac.newE vent(Audit ingEvent.S UBMITIN_EN D, getClas s()); | |
| 235 | event.se tOutcome(A uditEvent. AuditEvent Outcome._4 ); | |
| 236 | event.se tOutcomeDe sc(errorMs g); | |
| 237 | afac.err or(event); | |
| 238 | ||
| 239 | return r et; | |
| 240 | } | |
| 241 | ||
| 242 | // CCR 17798 6 - parame terized lo gging | |
| 243 | lo gger.info( "Home Comm unity Id { } = ", hom eCommunity Id); | |
| 244 | ||
| 245 | // get home facility o f the requ estor | |
| 246 | Fa cility hom eFacility = getHomeF acility(ho meCommunit yId); | |
| 247 | if (NullChec ker.isNull OrEmpty(ho meFacility )) { | |
| 248 | errorMsg = "Home C ommunity I d " + home CommunityI d + " is i nvalid, re quest Id = " + reque stId + ", ICN = " + icn; | |
| 249 | ret = cr eateErrorR egistryRes ponseType( "XDSMissin gHomeCommu nityId", e rrorMsg, n ull); | |
| 250 | ret.setR equestId(r equestId); | |
| 251 | ||
| 252 | // CCR 1 77986 - pa rameterize d logging | |
| 253 | logger.e rror("ICN is not cor related to facility" ); | |
| 254 | logger.e rror(error Msg + "{}" ); | |
| 255 | ||
| 256 | AuditEve nt event = afac.newE vent(Audit ingEvent.S UBMITIN_EN D, getClas s()); | |
| 257 | event.se tOutcome(A uditEvent. AuditEvent Outcome._4 ); | |
| 258 | event.se tOutcomeDe sc(errorMs g); | |
| 259 | afac.err or(event); | |
| 260 | ||
| 261 | return r et; | |
| 262 | } | |
| 263 | ||
| 264 | Au ditEvent e ventPolicy Check = af ac.messagi ng().partn erauth(Aud itingEvent .SUBMITIN_ PARTNERAUT H, Adapter XDR.class, homeCommu nityId); | |
| 265 | // check Poli cy? | |
| 266 | Or ganization TrustedSou rceRequest Type trust Req = new Organizati onTrustedS ourceReque stType(); | |
| 267 | tr ustReq.set Organizati onId(homeC ommunityId ); | |
| 268 | tr y { | |
| 269 | msg.addQ uery(event PolicyChec k, trustRe q, Organiz ationTrust edSourceRe questType. class, | |
| 270 | Query Type.REQUE ST, null); | |
| 271 | Organiza tionTruste dSourceRes ponseType trustRes = vapConsen tManagemen t.getIsOrg anizationT rustedSour ce(trustRe q); | |
| 272 | msg.addQ uery(event PolicyChec k, trustRe s, Organiz ationTrust edSourceRe sponseType .class, | |
| 273 | Query Type.RESPO NSE, null) ; | |
| 274 | if (Null Checker.is NotNullOrE mpty(trust Res)) { | |
| 275 | if ( !trustRes. isIsTruste d()) { | |
| 276 | logger.inf o("Request from Home Community Id: " + h omeCommuni tyId + " f ailed orga nization t rusted pol icy check, request I d = " + re questId + ", ICN = " + icn); | |
| 277 | ||
| 278 | errorMsg = "Request failed a p olicy chec k."; | |
| 279 | ret = crea teErrorReg istryRespo nseType("X DSReposito ryError", errorMsg, null); | |
| 280 | ret.setReq uestId(req uestId); | |
| 281 | ||
| 282 | eventPolic yCheck.set Outcome(Au ditEvent.A uditEventO utcome._4) ; | |
| 283 | eventPolic yCheck.set OutcomeDes c(errorMsg ); | |
| 284 | afac.error (eventPoli cyCheck); | |
| 285 | afac.info( AuditingEv ent.SUBMIT IN_END, ge tClass()); | |
| 286 | return ret ; | |
| 287 | } | |
| 288 | else { | |
| 289 | //Success | |
| 290 | logger.deb ug("Policy check Pas sed."); | |
| 291 | eventPolic yCheck.set Outcome(Au ditEvent.A uditEventO utcome._0) ; | |
| 292 | afac.info( eventPolic yCheck); | |
| 293 | } | |
| 294 | } | |
| 295 | } | |
| 296 | ca tch (Conse ntManageme ntServiceF aultMessag e ex) { | |
| 297 | logger.e rror("Erro r during i s organiza tion trust ed policy check.", e x); | |
| 298 | ||
| 299 | errorMsg = "Reques t failed a policy ch eck."; | |
| 300 | ret = cr eateErrorR egistryRes ponseType( "XDSReposi toryError" , errorMsg , null); | |
| 301 | ret.setR equestId(r equestId); | |
| 302 | ||
| 303 | eventPol icyCheck.s etOutcome( AuditEvent .AuditEven tOutcome._ 8); | |
| 304 | eventPol icyCheck.s etOutcomeD esc(errorM sg); | |
| 305 | afac.err or(eventPo licyCheck) ; | |
| 306 | afac.inf o(Auditing Event.SUBM ITIN_END, getClass() ); | |
| 307 | return r et; | |
| 308 | } | |
| 309 | ||
| 310 | St ring facil ityNumber = homeFaci lity.getFa cilityNumb er(); | |
| 311 | lo gger.debug ("Facility Number {} = ", faci lityNumber ); | |
| 312 | ||
| 313 | // check if ICN is cor related to Home Faci lity Id | |
| 314 | II patientId = new II( ); | |
| 315 | pa tientId.se tRoot(Conf iguration. getMyCommu nityId()); // VA OID | |
| 316 | pa tientId.se tExtension (icn); | |
| 317 | ||
| 318 | Au ditEvent e ventPatien tCorrelati ons = afac .newEvent( AuditingEv ent.INFO, getClass() ); | |
| 319 | Re trievePati entCorrela tionsReque stType pat ientCorrel ationsRequ est = new RetrievePa tientCorre lationsReq uestType() ; | |
| 320 | pa tientCorre lationsReq uest.setPR PAIN201309 UV02(HL7PR PA201309Tr ansforms.c reatePRPA2 01309(pati entId.getR oot(), pat ientId.get Extension( ))); | |
| 321 | ||
| 322 | pa tientCorre lationsReq uest.setAs sertion(as sertion); | |
| 323 | ||
| 324 | Re trievePati entCorrela tionsRespo nseType pa tientCorre lations; | |
| 325 | ms g.addQuery (eventPati entCorrela tions, pat ientCorrel ationsRequ est, | |
| 326 | RetrieveP atientCorr elationsRe questType. class, Que ryType.REQ UEST, null ); | |
| 327 | tr y { | |
| 328 | patientC orrelation s = adapte rPatientCo rrelation. retrievePa tientCorre lations(pa tientCorre lationsReq uest); | |
| 329 | msg.addQ uery(event PatientCor relations, patientCo rrelations , | |
| 330 | Retri evePatient Correlatio nsResponse Type.class , QueryTyp e.RESPONSE , null); | |
| 331 | ||
| 332 | eventPat ientCorrel ations.set Outcome(Au ditEvent.A uditEventO utcome._0) ; | |
| 333 | afac.inf o(eventPat ientCorrel ations); | |
| 334 | ||
| 335 | } | |
| 336 | ca tch (Excep tion e) { | |
| 337 | errorMsg = "Error trying to correlate patient, H ome Commun ity Id " + homeCommu nityId + " , request Id = " + r equestId + ", ICN = " + icn + ", excepti on = " + e .getMessag e(); | |
| 338 | ret = cr eateErrorR egistryRes ponseType( "XDSRegist ryError", errorMsg, homeFacili ty); | |
| 339 | ret.setR equestId(r equestId); | |
| 340 | ||
| 341 | // CCR 1 77986 - pa rameterize d logging | |
| 342 | logger.e rror(error Msg + "{}" ); | |
| 343 | ||
| 344 | eventPat ientCorrel ations.set Outcome(Au ditEvent.A uditEventO utcome._8) ; | |
| 345 | eventPat ientCorrel ations.set OutcomeDes c(errorMsg ); | |
| 346 | afac.err or(eventPa tientCorre lations); | |
| 347 | ||
| 348 | afac.inf o(Auditing Event.SUBM ITIN_END, getClass() ); | |
| 349 | return r et; | |
| 350 | } | |
| 351 | ||
| 352 | if (patientC orrelation s == null || patient Correlatio ns.getPRPA IN201310UV 02() == nu ll) { | |
| 353 | errorMsg = "ICN is unknown t o VA, Home Community Id " + ho meCommunit yId + ", r equest Id = " + requ estId + ", ICN = " + icn; | |
| 354 | ret = cr eateErrorR egistryRes ponseType( "XDSUnknow nPatientId ", errorMs g, homeFac ility); | |
| 355 | ret.setR equestId(r equestId); | |
| 356 | ||
| 357 | // CCR 1 77986 - pa rameterize d logging | |
| 358 | logger.e rror(error Msg + "{}" ); | |
| 359 | ||
| 360 | eventPat ientCorrel ations.set Outcome(Au ditEvent.A uditEventO utcome._4) ; | |
| 361 | eventPat ientCorrel ations.set OutcomeDes c(errorMsg ); | |
| 362 | afac.err or(eventPa tientCorre lations); | |
| 363 | ||
| 364 | afac.inf o(Auditing Event.SUBM ITIN_END, getClass() ); | |
| 365 | return r et; | |
| 366 | } | |
| 367 | ||
| 368 | Li st<II> cor relatedPat ientIds = patientCor relations. getPRPAIN2 01310UV02( ).getContr olActProce ss().getSu bject().ge t(0).getRe gistration Event().ge tSubject1( ).getPatie nt().getId (); | |
| 369 | ||
| 370 | if (NullChec ker.isNull OrEmpty(co rrelatedPa tientIds)) { | |
| 371 | errorMsg = "ICN is unknown t o VA, Home Community Id " + ho meCommunit yId + ", r equest Id = " + requ estId + ", ICN = " + icn; | |
| 372 | ret = cr eateErrorR egistryRes ponseType( "XDSUnknow nPatientId ", errorMs g, homeFac ility); | |
| 373 | ret.setR equestId(r equestId); | |
| 374 | ||
| 375 | // CCR 1 77986 - pa rameterize d logging | |
| 376 | logger.e rror(error Msg + "{}" ); | |
| 377 | ||
| 378 | eventPat ientCorrel ations.set Outcome(Au ditEvent.A uditEventO utcome._4) ; | |
| 379 | eventPat ientCorrel ations.set OutcomeDes c(errorMsg ); | |
| 380 | afac.err or(eventPa tientCorre lations); | |
| 381 | ||
| 382 | afac.inf o(Auditing Event.SUBM ITIN_END, getClass() ); | |
| 383 | return r et; | |
| 384 | } | |
| 385 | ||
| 386 | bo olean corr elated = f alse; | |
| 387 | St ring short CommunityI d; | |
| 388 | ||
| 389 | if (homeComm unityId.st artsWith(" urn:oid:") ) { | |
| 390 | shortCom munityId = homeCommu nityId.sub string(8); | |
| 391 | } | |
| 392 | el se { | |
| 393 | shortCom munityId = homeCommu nityId; | |
| 394 | } | |
| 395 | ||
| 396 | fo r (II corr elatedPati entId : co rrelatedPa tientIds) { | |
| 397 | ||
| 398 | if (shor tCommunity Id.equalsI gnoreCase( correlated PatientId. getRoot()) ) { | |
| 399 | corr elated = t rue; | |
| 400 | brea k; | |
| 401 | } | |
| 402 | } | |
| 403 | ||
| 404 | if (!correla ted) { | |
| 405 | errorMsg = "ICN is not corre lated to " + facilit yNumber + ", Home Co mmunity Id " + homeC ommunityId + ", requ est Id = " + request Id + ", IC N = " + ic n; | |
| 406 | ret = cr eateErrorR egistryRes ponseType( "XDSUnknow nPatientId ", errorMs g, homeFac ility); | |
| 407 | ret.setR equestId(r equestId); | |
| 408 | ||
| 409 | // CCR 1 77986 - pa rameterize d logging | |
| 410 | logger.e rror(LogUt il.cleanLo gMessage(e rrorMsg) + "{}"); | |
| 411 | ||
| 412 | eventPat ientCorrel ations.set Outcome(Au ditEvent.A uditEventO utcome._4) ; | |
| 413 | eventPat ientCorrel ations.set OutcomeDes c(errorMsg ); | |
| 414 | afac.err or(eventPa tientCorre lations); | |
| 415 | ||
| 416 | afac.inf o(Auditing Event.SUBM ITIN_END, getClass() ); | |
| 417 | return r et; | |
| 418 | } | |
| 419 | ||
| 420 | Au ditEvent e ventStoreD oc = afac. newEvent(A uditingEve nt.SUBMITI N_STORE, g etClass()) ; | |
| 421 | // get url f rom the pr operty tab le | |
| 422 | St ring endPo int = prop ertyLookup .getProper ty("vler.d as.docsubm it.url"); | |
| 423 | if (NullChec ker.isNull OrEmpty(en dPoint)) { | |
| 424 | errorMsg = "VLER D AS URL vle r.das.docs ubmit.url is not con figured in the VA Ad apter PROP ERTIES tab le"; | |
| 425 | ret = cr eateErrorR egistryRes ponseType( "XDSRegist ryError", errorMsg, homeFacili ty); | |
| 426 | ||
| 427 | // CCR 1 77986 - pa rameterize d logging | |
| 428 | logger.e rror(error Msg + "{}" ); | |
| 429 | ||
| 430 | eventSto reDoc.setO utcome(Aud itEvent.Au ditEventOu tcome._4); | |
| 431 | eventSto reDoc.setO utcomeDesc (errorMsg) ; | |
| 432 | afac.err or(eventSt oreDoc); | |
| 433 | ||
| 434 | afac.inf o(Auditing Event.SUBM ITIN_END, getClass() ); | |
| 435 | return r et; | |
| 436 | } | |
| 437 | ||
| 438 | lo gger.debug ("VLER DAS URL templ ate {} = " + endPoin t); | |
| 439 | ||
| 440 | // instantia te Das Htt p client | |
| 441 | Da sDAO mydas DAO = (nul l == this. dasDAO | |
| 442 | ? n ew DasDAOH ttpImpl(en dPoint) | |
| 443 | : t his.dasDAO ); | |
| 444 | ||
| 445 | Da sOperation SendImmuni zationData Request re q; | |
| 446 | Da sOperation SendImmuni zationData Response r es; | |
| 447 | ||
| 448 | // call VLER DAS Immun ization pu sh | |
| 449 | tr y { | |
| 450 | req = ne w DasOpera tionSendIm munization DataReques t(); | |
| 451 | req.setM essage(c32 document); | |
| 452 | ||
| 453 | req.setF acility(fa cilityNumb er); | |
| 454 | req.setI CN(icn); | |
| 455 | ||
| 456 | res = my dasDAO.doO perationSe ndImmuniza tionData(r eq); | |
| 457 | eventSto reDoc.setO utcome(Aud itEvent.Au ditEventOu tcome._0); | |
| 458 | afac.inf o(eventSto reDoc); | |
| 459 | ||
| 460 | ret = cr eateRegist ryResponse Type(res.g etDocId()) ; | |
| 461 | ||
| 462 | auditDoc umentSubmi ssion(asse rtion, bod y, res); | |
| 463 | } | |
| 464 | ca tch (DasEx ception e) { | |
| 465 | ret = cr eateErrorR egistryRes ponseType( e.getError Code(), e. getCodeCon text(), ho meFacility ); | |
| 466 | ||
| 467 | // CCR 1 77986 | |
| 468 | eventSto reDoc.setO utcome(Aud itEvent.Au ditEventOu tcome._8); | |
| 469 | eventSto reDoc.setO utcomeDesc (e.getMess age()); | |
| 470 | afac.err or(eventSt oreDoc); | |
| 471 | ||
| 472 | logger.e rror("Seve re: DAS Ex ception {} ", e.getCo deContext( )); | |
| 473 | } | |
| 474 | ||
| 475 | // copy requ est Id fro m request | |
| 476 | re t.setReque stId(reque stId); | |
| 477 | ||
| 478 | // CCR 17798 6 - parame terized lo gging | |
| 479 | lo gger.debug ("provideA ndRegister DocumentSe tb() exite d"); | |
| 480 | af ac.info(Au ditingEven t.SUBMITIN _END, getC lass()); | |
| 481 | re turn ret; | |
| 482 | } | |
| 483 | ||
| 484 | /* | |
| 485 | * Bui lds Regist ryResponse Type with Bson Doc I d as a slo t content | |
| 486 | * | |
| 487 | * @pa ram docId Bson Doc I d generate d by VLER DAS | |
| 488 | * | |
| 489 | * @re turn respo nse Regist ryResponse Type conta ining docI d | |
| 490 | */ | |
| 491 | privat e Registry ResponseTy pe createR egistryRes ponseType( String doc Id) | |
| 492 | { | |
| 493 | ||
| 494 | oa sis.names. tc.ebxml_r egrep.xsd. rs._3.Obje ctFactory of = new o asis.names .tc.ebxml_ regrep.xsd .rs._3.Obj ectFactory (); | |
| 495 | ||
| 496 | Re gistryResp onseType r et = of.cr eateRegist ryResponse Type(); | |
| 497 | ||
| 498 | Sl otListType slotList = new Slot ListType() ; | |
| 499 | Sl otType1 sl ot = new S lotType1() ; | |
| 500 | sl ot.setName ("Document Id"); | |
| 501 | ||
| 502 | Va lueListTyp e valueLis tType = ne w ValueLis tType(); | |
| 503 | va lueListTyp e.getValue ().add(doc Id); | |
| 504 | sl ot.setValu eList(valu eListType) ; | |
| 505 | sl otList.get Slot().add (slot); | |
| 506 | re t.setRespo nseSlotLis t(slotList ); | |
| 507 | ||
| 508 | re t.setStatu s(XDS_RETR IEVE_RESPO NSE_STATUS _SUCCESS); | |
| 509 | ||
| 510 | // CCR 17798 6- only if logger is enabled | |
| 511 | lo gger.debug ("Registry ResponseTy pe ret {}" , ret); | |
| 512 | ||
| 513 | re turn ret; | |
| 514 | } | |
| 515 | ||
| 516 | privat e Registry ResponseTy pe createE rrorRegist ryResponse Type(Strin g errorCod e, String codeContex t, Facilit y homeFaci lity) | |
| 517 | { | |
| 518 | oa sis.names. tc.ebxml_r egrep.xsd. rs._3.Obje ctFactory of = new o asis.names .tc.ebxml_ regrep.xsd .rs._3.Obj ectFactory (); | |
| 519 | ||
| 520 | Re gistryResp onseType r et = of.cr eateRegist ryResponse Type(); | |
| 521 | ||
| 522 | Re gistryErro rList regi stryErrorL ist = crea teRegistry ErrorList( ); | |
| 523 | ||
| 524 | Re gistryErro r registry Error = cr eateRegist ryError(er rorCode, c odeContext , homeFaci lity); | |
| 525 | ||
| 526 | re gistryErro rList.getR egistryErr or().add(r egistryErr or); | |
| 527 | ||
| 528 | re t.setRegis tryErrorLi st(registr yErrorList ); | |
| 529 | ||
| 530 | re t.setStatu s(XDS_RETR IEVE_RESPO NSE_STATUS _FAILURE); | |
| 531 | ||
| 532 | // CCR 17798 6- only if logger is enabled | |
| 533 | lo gger.debug ("Registry ResponseTy pe ret {}" , ret); | |
| 534 | ||
| 535 | re turn ret; | |
| 536 | } | |
| 537 | ||
| 538 | privat e Registry ErrorList createRegi stryErrorL ist() | |
| 539 | { | |
| 540 | oa sis.names. tc.ebxml_r egrep.xsd. rs._3.Obje ctFactory retObjFact ory = new oasis.name s.tc.ebxml _regrep.xs d.rs._3.Ob jectFactor y(); | |
| 541 | Re gistryErro rList ret = retObjFa ctory.crea teRegistry ErrorList( ); | |
| 542 | re t.setHighe stSeverity ("urn:oasi s:names:tc :ebxml-reg rep:ErrorS everityTyp e:Error"); | |
| 543 | re turn ret; | |
| 544 | } | |
| 545 | ||
| 546 | privat e Registry Error crea teRegistry Error(Stri ng errorCo de, String codeConte xt, Facili ty homeFac ility) | |
| 547 | { | |
| 548 | oa sis.names. tc.ebxml_r egrep.xsd. rs._3.Obje ctFactory retObjFact ory = new oasis.name s.tc.ebxml _regrep.xs d.rs._3.Ob jectFactor y(); | |
| 549 | Re gistryErro r ret = re tObjFactor y.createRe gistryErro r(); | |
| 550 | re t.setSever ity("urn:o asis:names :tc:ebxml- regrep:Err orSeverity Type:Error "); | |
| 551 | re t.setError Code(error Code); | |
| 552 | re t.setCodeC ontext(cod eContext); | |
| 553 | ||
| 554 | if (NullChec ker.isNull OrEmpty(ho meFacility )) { | |
| 555 | ret.setL ocation("" ); | |
| 556 | } | |
| 557 | el se { | |
| 558 | ret.setL ocation(ho meFacility .getFullHo meCommunit yId()); | |
| 559 | } | |
| 560 | ||
| 561 | re turn ret; | |
| 562 | } | |
| 563 | ||
| 564 | /* | |
| 565 | * Loo k up Facil ity data i n the FACI LITIES tab le | |
| 566 | */ | |
| 567 | privat e Facility getHomeFa cility(Str ing homeCo mmunityId) | |
| 568 | { | |
| 569 | Fa cility fac ility = nu ll; | |
| 570 | ||
| 571 | fa cility = f acilityMan ager.getFa cilityByFu llHomeComm unityId(ho meCommunit yId); | |
| 572 | ||
| 573 | if (NullChec ker.isNotN ullOrEmpty (facility) ) { | |
| 574 | return f acility; | |
| 575 | } | |
| 576 | ||
| 577 | fa cility = f acilityMan ager.getFa cilityByHo meCommunit yId(homeCo mmunityId) ; | |
| 578 | ||
| 579 | // CCR 17798 6- only if logger is enabled | |
| 580 | lo gger.debug ("facility name {}", facility. getFacilit yName()); | |
| 581 | lo gger.debug ("facility number {} ", facilit y.getFacil ityNumber( )); | |
| 582 | lo gger.debug ("Home Com munity Id {}", facil ity.getFul lHomeCommu nityId()); | |
| 583 | ||
| 584 | re turn facil ity; | |
| 585 | } | |
| 586 | ||
| 587 | /* | |
| 588 | * ret rieve C32 document < ProvideAnd RegisterDo cumentSetR equest> <D ocument | |
| 589 | * id= "Walgreens ">UjBsR09E bGhjZ0dTQU xNQUFBUUNB RU1tQ1p0dU 1GUXhEUzhi </ | |
| 590 | * Doc ument> </P rovideAndR egisterDoc umentSetRe quest> | |
| 591 | */ | |
| 592 | privat e byte[] g etC32Docum ent(Provid eAndRegist erDocument SetRequest Type body) | |
| 593 | { | |
| 594 | if (NullChec ker.isNull OrEmpty(bo dy.getDocu ment())) { | |
| 595 | //CCR 17 7986 | |
| 596 | logger.e rror("Seve re {}", "D ocument se ction is e mpty"); | |
| 597 | return n ull; | |
| 598 | } | |
| 599 | ||
| 600 | by te[] c32by tes = null ; | |
| 601 | tr y { | |
| 602 | ByteArra yOutputStr eam baos = new ByteA rrayOutput Stream(); | |
| 603 | body.get Document() .get(0).ge tValue().w riteTo(bao s); | |
| 604 | c32bytes = baos.to ByteArray( ); | |
| 605 | } | |
| 606 | ca tch (IOExc eption e) { | |
| 607 | //CCR 17 7986 | |
| 608 | logger.e rror("Seve re {}", "E rror getti ng Documen t from Pro videAndReg isterDocum entSet"); | |
| 609 | return n ull; | |
| 610 | } | |
| 611 | ||
| 612 | if (NullChec ker.isNull OrEmpty(c3 2bytes)) { | |
| 613 | //CCR 17 7986 | |
| 614 | logger.e rror("Seve re {}", "D ocument co ntent is e mpty"); | |
| 615 | return n ull; | |
| 616 | } | |
| 617 | ||
| 618 | re turn c32by tes; | |
| 619 | } | |
| 620 | ||
| 621 | /* | |
| 622 | * ret rieve ICN from Regis tryObjectL ist: | |
| 623 | */ | |
| 624 | privat e String g etICN(Prov ideAndRegi sterDocume ntSetReque stType bod y) | |
| 625 | { | |
| 626 | St ring uniqu ePatientId = getUniq uePatientI d(body); | |
| 627 | ||
| 628 | if (NullChec ker.isNotN ullOrEmpty (uniquePat ientId)) { | |
| 629 | logger.d ebug("uniq uePatientI d {} : ", uniquePati entId); | |
| 630 | return u niquePatie ntId.split ("\\^")[0] ; | |
| 631 | } | |
| 632 | ||
| 633 | re turn null; | |
| 634 | } | |
| 635 | ||
| 636 | privat e String g etUniquePa tientId(Pr ovideAndRe gisterDocu mentSetReq uestType b ody) | |
| 637 | { | |
| 638 | Re gistryPack ageType re gistryPack age; | |
| 639 | ||
| 640 | Li st<Externa lIdentifie rType> reg istryPacka geExternal Identifier List; | |
| 641 | ||
| 642 | Re gistryObje ctListType registryO bjectList = body.get SubmitObje ctsRequest ().getRegi stryObject List(); | |
| 643 | ||
| 644 | Li st<JAXBEle ment<? ext ends Ident ifiableTyp e>> identi fiableList = registr yObjectLis t.getIdent ifiable(); | |
| 645 | ||
| 646 | fo r (JAXBEle ment<? ext ends Ident ifiableTyp e> identif iable : id entifiable List) { | |
| 647 | ||
| 648 | // check RegistryP ackage of the DS req uest for | |
| 649 | // XDSSu bmissionSe t.patientI d | |
| 650 | if (iden tifiable.g etValue() instanceof RegistryP ackageType ) { | |
| 651 | regi stryPackag e = (Regis tryPackage Type)ident ifiable.ge tValue(); | |
| 652 | ||
| 653 | // g et Externa lIdentifie rs | |
| 654 | regi stryPackag eExternalI dentifierL ist = regi stryPackag e.getExter nalIdentif ier(); | |
| 655 | for (ExternalI dentifierT ype regist ryPackageE xternalIde ntifier : registryPa ckageExter nalIdentif ierList) { | |
| 656 | if (regist ryPackageE xternalIde ntifier.ge tName().ge tLocalized String().g et(0).getV alue().equ alsIgnoreC ase("XDSSu bmissionSe t.patientI d")) { | |
| 657 | return registryP ackageExte rnalIdenti fier.getVa lue(); | |
| 658 | } | |
| 659 | } | |
| 660 | ||
| 661 | } | |
| 662 | ||
| 663 | // check Extrinsic Object of the DS req uest | |
| 664 | /* | |
| 665 | * if (i dentifiabl e.getValue () instanc eof Extrin sicObjectT ype) { | |
| 666 | * extri nsicObject = (Extrin sicObjectT ype)identi fiable.get Value(); | |
| 667 | * | |
| 668 | * extri nsicObject ExternalId entifierLi st = | |
| 669 | * extri nsicObject .getExtern alIdentifi er(); for | |
| 670 | * (Exte rnalIdenti fierType e xtrinsicOb jectExtern alIdentifi er: | |
| 671 | * extri nsicObject ExternalId entifierLi st) { if | |
| 672 | * (extr insicObjec tExternalI dentifier. getName(). getLocaliz edString() | |
| 673 | * .get( 0).getValu e() | |
| 674 | * .equa lsIgnoreCa se("XDSDoc umentEntry .patientId ")) { retu rn | |
| 675 | * extri nsicObject ExternalId entifier.g etValue(); } } } | |
| 676 | */ | |
| 677 | } | |
| 678 | re turn null; | |
| 679 | } | |
| 680 | ||
| 681 | privat e String g etHomeComm unityId(As sertionTyp e assertio n) | |
| 682 | { | |
| 683 | if (NullChec ker.isNull OrEmpty(as sertion)) { | |
| 684 | logger.e rror("Seve re {}", "A ssertion s ection is empty"); | |
| 685 | ||
| 686 | return n ull; | |
| 687 | } | |
| 688 | ||
| 689 | if (NullChec ker.isNull OrEmpty(as sertion.ge tHomeCommu nity())) { | |
| 690 | logger.e rror("Seve re {}", "H omeCommuni ty section is empty" ); | |
| 691 | ||
| 692 | return n ull; | |
| 693 | } | |
| 694 | ||
| 695 | St ring homeC ommunityId = asserti on.getHome Community( ).getHomeC ommunityId ().trim(); | |
| 696 | ||
| 697 | // CCR 177986 | |
| 698 | lo gger.debug ("homeComm unityId {} :", homeC ommunityId ); | |
| 699 | ||
| 700 | if (homeComm unityId.st artsWith(" urn:oid:") ) { | |
| 701 | return h omeCommuni tyId; | |
| 702 | } | |
| 703 | el se { | |
| 704 | return " urn:oid:" + homeComm unityId; | |
| 705 | } | |
| 706 | } | |
| 707 | ||
| 708 | privat e String g etRequestI d(ProvideA ndRegister DocumentSe tRequestTy pe body) | |
| 709 | { | |
| 710 | if (NullChec ker.isNull OrEmpty(bo dy.getSubm itObjectsR equest())) { | |
| 711 | return " "; | |
| 712 | } | |
| 713 | ||
| 714 | if (NullChec ker.isNull OrEmpty(bo dy.getSubm itObjectsR equest().g etId())) { | |
| 715 | return " "; | |
| 716 | } | |
| 717 | ||
| 718 | // CCR 177986 | |
| 719 | lo gger.debug ("request id {} ", b ody.getSub mitObjects Request(). getId()); | |
| 720 | ||
| 721 | re turn body. getSubmitO bjectsRequ est().getI d(); | |
| 722 | } | |
| 723 | ||
| 724 | privat e void aud itDocument Submission (Assertion Type asser tion, Prov ideAndRegi sterDocume ntSetReque stType bod y, DasOper ationSendI mmunizatio nDataRespo nse respon se) | |
| 725 | { | |
| 726 | ||
| 727 | // create re cord in th e DOCUMENT table | |
| 728 | Do cument doc ument = ne w Document (); | |
| 729 | ||
| 730 | by te[] c32by tes = getC 32Document (body); | |
| 731 | do cument.set DocumentUn iqueId(res ponse.getD ocId()); | |
| 732 | do cument.set RawData(c3 2bytes); | |
| 733 | do cument.set Size(c32by tes.length ); | |
| 734 | do cument.set Availabili tyStatus(" urn:oasis: names:tc:e bxmlregrep :StatusTyp e:Approved "); | |
| 735 | do cument.set LastAccess edTime(new Date()); | |
| 736 | do cument.set CreationTi me(new Dat e()); | |
| 737 | do cument.set ClassCode( "11369-6") ; | |
| 738 | do cument.set ClassCodeD isplayName ("History of immuniz ations"); | |
| 739 | do cument.set ClassCodeS cheme("2.1 6.840.1.11 3883.6.1") ; | |
| 740 | do cument.set MimeType(" text/xml") ; | |
| 741 | do cument.set PatientId( getICN(bod y)); | |
| 742 | do cument.set FormatCode DisplayNam e("History of immuni zations"); | |
| 743 | do cument.set SourcePati entId(getU niquePatie ntId(body) ); | |
| 744 | do cument.set PatientSSN (assertion .getSSN()) ; | |
| 745 | ||
| 746 | if (NullChec ker.isNotN ullOrEmpty (assertion .getUserIn fo())) { | |
| 747 | ||
| 748 | if (Null Checker.is NotNullOrE mpty(asser tion.getUs erInfo().g etOrg())) { | |
| 749 | // d ocument.se tPatientPr eferredFac ilityNumbe r(assertio n.getUserI nfo().getO rg().getHo meCommunit yId()); | |
| 750 | docu ment.setPa tientPrefe rredFacili tyName(ass ertion.get UserInfo() .getOrg(). getName()) ; | |
| 751 | } | |
| 752 | ||
| 753 | document .setPatien tGivenName (getGivenN ame(body)) ; | |
| 754 | document .setPatien tLastName( getFamilyN ame(body)) ; | |
| 755 | ||
| 756 | } | |
| 757 | ||
| 758 | // CCR 177986 | |
| 759 | // logger.deb ug("Docume nt details {}", docu ment.toStr ing()); | |
| 760 | do cumentRepo sitory.sto reDocument (document) ; | |
| 761 | ||
| 762 | // create re cord in th e AUDIT ta ble | |
| 763 | Au dit audit = new Audi t(); | |
| 764 | ||
| 765 | au dit.setAct ion("Docum entSubmiss ionIn"); | |
| 766 | au dit.setAud itTime(new Date()); | |
| 767 | au dit.setDoc umentId(do cument.get DocumentUn iqueId()); | |
| 768 | au dit.setRem oteDocumen tId(docume nt.getDocu mentUnique Id()); | |
| 769 | // audit.set RemoteDocu mentReposi toryId(d.g etReposito ryUniqueId ()); | |
| 770 | au dit.setRem oteOrganiz ationId(ge tHomeCommu nityId(ass ertion)); | |
| 771 | ||
| 772 | if (NullChec ker.isNotN ullOrEmpty (assertion .getUserIn fo())) { | |
| 773 | audit.se tUserId(as sertion.ge tUserInfo( ).getUserN ame()); | |
| 774 | ||
| 775 | if (Null Checker.is NotNullOrE mpty(asser tion.getUs erInfo().g etRoleCode d())) { | |
| 776 | audi t.setUserR ole(assert ion.getUse rInfo().ge tRoleCoded ().getCode ()); | |
| 777 | } | |
| 778 | ||
| 779 | if (Null Checker.is NotNullOrE mpty(asser tion.getUs erInfo().g etOrg())) { | |
| 780 | audi t.setUserF acilityNum ber(assert ion.getUse rInfo().ge tOrg().get HomeCommun ityId()); | |
| 781 | audi t.setUserF acilityNam e(assertio n.getUserI nfo().getO rg().getNa me()); | |
| 782 | } | |
| 783 | ||
| 784 | if (Null Checker.is NotNullOrE mpty(asser tion.getUs erInfo().g etPersonNa me())) { | |
| 785 | Pers onNameType userName = assertio n.getUserI nfo().getP ersonName( ); | |
| 786 | if ( !NullCheck er.isNullO rEmpty(use rName.getF ullName()) ) { | |
| 787 | audit.setU serName(us erName.get FullName() ); | |
| 788 | } | |
| 789 | else { | |
| 790 | audit.setU serName(us erName.get GivenName( ) + " " + userName.g etFamilyNa me()); | |
| 791 | } | |
| 792 | } | |
| 793 | } | |
| 794 | ||
| 795 | if (NullChec ker.isNotN ullOrEmpty (assertion .getPurpos eOfDisclos ureCoded() )) { | |
| 796 | audit.se tPurposeFo rUse(asser tion.getPu rposeOfDis closureCod ed().getCo de()); | |
| 797 | } | |
| 798 | ||
| 799 | au dit.setSys temId(Audi tUtil.chec kSystemId( assertion) ); | |
| 800 | ||
| 801 | au dit.setOrg anizationI d(assertio n.getHomeC ommunity() .getHomeCo mmunityId( )); | |
| 802 | au dit.setPat ientId(get ICN(body)) ; | |
| 803 | au dit.setPat ientSSN(as sertion.ge tSSN()); | |
| 804 | ||
| 805 | au dit.setPat ientGivenN ame(getGiv enName(bod y)); | |
| 806 | au dit.setPat ientLastNa me(getFami lyName(bod y)); | |
| 807 | au dit.setPat ientFacili tyNumber(g etHomeFaci lity(getHo meCommunit yId(assert ion)).getF acilityNum ber()); | |
| 808 | au dit.setPat ientFacili tyName(get HomeFacili ty(getHome CommunityI d(assertio n)).getFac ilityName( )); | |
| 809 | ||
| 810 | au dit.setDet ails("ICN= " + audit. getPatient Id() + ", VLER DAS D ocument Id =" + respo nse.getDoc Id()); | |
| 811 | ||
| 812 | // CCR 177986 | |
| 813 | lo gger.debug ("Audit de tails {}", audit.toS tring()); | |
| 814 | ||
| 815 | au ditManager .storeAudi t(audit); | |
| 816 | } | |
| 817 | ||
| 818 | privat e String g etFamilyNa me(Provide AndRegiste rDocumentS etRequestT ype body) | |
| 819 | { | |
| 820 | ||
| 821 | re turn getPa rtName(bod y, 0); | |
| 822 | } | |
| 823 | ||
| 824 | privat e String g etGivenNam e(ProvideA ndRegister DocumentSe tRequestTy pe body) | |
| 825 | { | |
| 826 | ||
| 827 | re turn getPa rtName(bod y, 1); | |
| 828 | } | |
| 829 | ||
| 830 | privat e String g etPartName (ProvideAn dRegisterD ocumentSet RequestTyp e body, in t n) | |
| 831 | { | |
| 832 | ||
| 833 | Li st<String> sourcePat ientInfoLi st = getSo urcePatien tInfoList( body); | |
| 834 | ||
| 835 | if (NullChec ker.isNull OrEmpty(so urcePatien tInfoList) ) { | |
| 836 | return n ull; | |
| 837 | } | |
| 838 | ||
| 839 | St ring patie ntFullName = getPati entFullNam e(sourcePa tientInfoL ist); | |
| 840 | ||
| 841 | if (NullChec ker.isNull OrEmpty(pa tientFullN ame)) { | |
| 842 | return n ull; | |
| 843 | } | |
| 844 | ||
| 845 | St ring partN ame = null ; | |
| 846 | ||
| 847 | tr y { | |
| 848 | partName = patient FullName.s plit("\\^" )[n]; | |
| 849 | } | |
| 850 | ca tch (Excep tion e) { | |
| 851 | //CCR 17 9231 | |
| 852 | logger.e rror("Exce ption in g ettign par t name fro m the docu ment", e); | |
| 853 | } | |
| 854 | ||
| 855 | re turn partN ame; | |
| 856 | } | |
| 857 | ||
| 858 | privat e String g etPatientF ullName(Li st<String> sourcePat ientInfoLi st) | |
| 859 | { | |
| 860 | if (NullChec ker.isNull OrEmpty(so urcePatien tInfoList) ) { | |
| 861 | return n ull; | |
| 862 | } | |
| 863 | ||
| 864 | St ring patie ntFullName = null; | |
| 865 | ||
| 866 | fo r (String sourcePati entInfo : sourcePati entInfoLis t) { | |
| 867 | if (Null Checker.is NullOrEmpt y(sourcePa tientInfo) ) { | |
| 868 | cont inue; | |
| 869 | } | |
| 870 | ||
| 871 | if (sour cePatientI nfo.starts With("PID- 5|")) { | |
| 872 | pati entFullNam e = source PatientInf o.substrin g(6); | |
| 873 | brea k; | |
| 874 | } | |
| 875 | } | |
| 876 | ||
| 877 | re turn patie ntFullName ; | |
| 878 | } | |
| 879 | ||
| 880 | privat e List<Str ing> getSo urcePatien tInfoList( ProvideAnd RegisterDo cumentSetR equestType body) | |
| 881 | { | |
| 882 | Ex trinsicObj ectType ex trinsicObj ect; | |
| 883 | Li st<SlotTyp e1> extrin sicObjectS lotList; | |
| 884 | ||
| 885 | Re gistryObje ctListType registryO bjectList = body.get SubmitObje ctsRequest ().getRegi stryObject List(); | |
| 886 | ||
| 887 | Li st<JAXBEle ment<? ext ends Ident ifiableTyp e>> identi fiableList = registr yObjectLis t.getIdent ifiable(); | |
| 888 | ||
| 889 | fo r (JAXBEle ment<? ext ends Ident ifiableTyp e> identif iable : id entifiable List) { | |
| 890 | ||
| 891 | if (iden tifiable.g etValue() instanceof Extrinsic ObjectType ) { | |
| 892 | extr insicObjec t = (Extri nsicObject Type)ident ifiable.ge tValue(); | |
| 893 | ||
| 894 | // g et Slots | |
| 895 | extr insicObjec tSlotList = extrinsi cObject.ge tSlot(); | |
| 896 | for (SlotType1 extrinsic ObjectSlot : extrins icObjectSl otList) { | |
| 897 | // search for slot.n ame = 'sou rcePatient Info' | |
| 898 | if (extrin sicObjectS lot.getNam e().equals IgnoreCase ("sourcePa tientInfo" )) { | |
| 899 | return extrinsic ObjectSlot .getValueL ist().getV alue(); | |
| 900 | } | |
| 901 | } | |
| 902 | } | |
| 903 | } | |
| 904 | ||
| 905 | re turn null; | |
| 906 | } | |
| 907 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.