Produced by Araxis Merge on 5/28/2019 3:28:34 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 | CV_src.zip\CVjMeadows-CCP\src\main\java\gov\va\med\jmeadows\dataservicehandler | PDWSServiceHandler.java | Wed May 1 18:46:27 2019 UTC |
2 | CV_src.zip\CVjMeadows-CCP\src\main\java\gov\va\med\jmeadows\dataservicehandler | PDWSServiceHandler.java | Tue May 28 17:41:24 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 2886 |
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 | * Janus 4 .0 (c) | |
3 | * Copyrig ht (c) 201 1 Hawaii R esource Gr oup LLC. A ll Rights Reserved. | |
4 | * Develop ed for the Pacific T elehealth & Technolo gy Hui and the Pacif ic Joint I nformation Technolog y Center | |
5 | * Contrib utors: | |
6 | * Hon orable Sen ator Danie l K. Inouy e | |
7 | * VA Pacific Is lands Heal th Care Sy stem | |
8 | * Tri pler Army Medical Ce nter | |
9 | */ | |
10 | ||
11 | package go v.va.med.j meadows.da taserviceh andler; | |
12 | ||
13 | import gov .va.med.jm eadows.com mon.AppCon fig; | |
14 | import gov .va.med.jm eadows.com mon.JMeado wsExceptio n; | |
15 | import gov .va.med.jm eadows.com mon.Langua geCache; | |
16 | import gov .va.med.jm eadows.dao .beans.PDW SQueryBean ; | |
17 | import gov .va.med.jm eadows.dao .beans.Res ponsePatie ntQuery; | |
18 | import gov .va.med.jm eadows.dao .hdd.Codin gSystem; | |
19 | import gov .va.med.pd ws.*; | |
20 | import gov .va.med.pd ws.ObjectF actory; | |
21 | import gov .va.med.vd s.webservi ce.*; | |
22 | import gov .va.med.vh ahon.commo n.Utils; | |
23 | import org .apache.co mmons.coll ections4.C ollectionU tils; | |
24 | import org .apache.co mmons.lang 3.StringUt ils; | |
25 | import org .apache.co mmons.lang 3.time.Fas tDateForma t; | |
26 | import org .slf4j.Log ger; | |
27 | import org .slf4j.Log gerFactory ; | |
28 | ||
29 | import jav ax.xml.bin d.JAXBElem ent; | |
30 | import jav ax.xml.dat atype.Data typeConfig urationExc eption; | |
31 | import jav ax.xml.dat atype.Data typeFactor y; | |
32 | import jav ax.xml.dat atype.XMLG regorianCa lendar; | |
33 | import jav ax.xml.nam espace.QNa me; | |
34 | import jav ax.xml.ws. BindingPro vider; | |
35 | import jav ax.xml.ws. handler.Ha ndler; | |
36 | import jav a.io.Seria lizable; | |
37 | import jav a.math.Big Integer; | |
38 | import jav a.text.Par seExceptio n; | |
39 | import jav a.text.Sim pleDateFor mat; | |
40 | import jav a.util.*; | |
41 | ||
42 | public cla ss PDWSSer viceHandle r extends DataServic eHandler { | |
43 | privat e static f inal Logge r LOGGER = LoggerFac tory.getLo gger(PDWSS erviceHand ler.class) ; | |
44 | privat e final St ring AGENC Y_DOD = AP P_CONFIG.g etAgencyDO D(); | |
45 | privat e final St ring AGENC Y_VA = APP _CONFIG.ge tAgencyVA( ); | |
46 | privat e final St ring PERSO N_SEARCH_U RL = APP_C ONFIG.getP dwsPsUrl() ; | |
47 | privat e final St ring PERSO N_RETRIEVE _URL = APP _CONFIG.ge tPdwsPrUrl (); | |
48 | privat e final St ring FAMIL Y_SEARCH_U RL = APP_C ONFIG.getP dwsFsUrl() ; | |
49 | privat e final St ring FAMIL Y_RETRIEVE _URL = APP _CONFIG.ge tPdwsFrUrl (); | |
50 | privat e final Bo olean DEBU G_SOAP_OUT PUT; | |
51 | privat e final En tityPatien tInquiry e ntityPatie ntInquiry = new Enti tyPatientI nquiry(); | |
52 | privat e static f inal FastD ateFormat simpleDate Format = F astDateFor mat.getIns tance("yyy yMMdd"); | |
53 | ||
54 | public PDWSServi ceHandler( ) { | |
55 | su per(); | |
56 | se rviceName = "PDWSSer vice"; | |
57 | serviceNam espace = " http:// DNS . URL /"; | |
58 | qS erviceName = new QNa me(service Namespace, serviceNa me); | |
59 | St ring debug = AppConf ig.getInst ance().get Properties ().getProp erty("DEBU G_SOAP_OUT PUT", "fal se"); | |
60 | if ("true".e qualsIgnor eCase(debu g)) { | |
61 | DEBUG_SO AP_OUTPUT = true; | |
62 | } else { | |
63 | DEBUG_SO AP_OUTPUT = false; | |
64 | } | |
65 | } | |
66 | ||
67 | privat e EntityPa tientSearc hPortType getEntityP atientSear chPort() { | |
68 | En tityPatien tSearchPor tType port = entityP atientInqu iry.getEnt ityPatient SearchPort Soap11(); | |
69 | ||
70 | Bi ndingProvi der prov = (BindingP rovider) p ort; | |
71 | pr ov.getRequ estContext ().put(Bin dingProvid er.ENDPOIN T_ADDRESS_ PROPERTY, PERSON_SEA RCH_URL); | |
72 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.connect. timeout", serviceCon nectionTim eoutMS); | |
73 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.request. timeout", serviceReq uestTimeou tMS); | |
74 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.connect .timeout", serviceCo nnectionTi meoutMS); | |
75 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.request .timeout", serviceRe questTimeo utMS); | |
76 | ||
77 | if (DEBUG_SO AP_OUTPUT) { | |
78 | prov.get Binding(). getHandler Chain().ad d(new SOAP LoggingHan dler()); | |
79 | List<Han dler> hand lerList = prov.getBi nding().ge tHandlerCh ain(); | |
80 | handlerL ist.add(ne w SOAPLogg ingHandler ()); | |
81 | prov.get Binding(). setHandler Chain(hand lerList); | |
82 | } | |
83 | ||
84 | re turn port; | |
85 | } | |
86 | ||
87 | privat e EntityPa tientRetri evePortTyp e getEntit yPatientRe trievePort () { | |
88 | En tityPatien tRetrieveP ortType po rt = entit yPatientIn quiry.getE ntityPatie ntRetrieve PortSoap11 (); | |
89 | ||
90 | Bi ndingProvi der prov = (BindingP rovider) p ort; | |
91 | pr ov.getRequ estContext ().put(Bin dingProvid er.ENDPOIN T_ADDRESS_ PROPERTY, PERSON_RET RIEVE_URL) ; | |
92 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.connect. timeout", serviceCon nectionTim eoutMS); | |
93 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.request. timeout", serviceReq uestTimeou tMS); | |
94 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.connect .timeout", serviceCo nnectionTi meoutMS); | |
95 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.request .timeout", serviceRe questTimeo utMS); | |
96 | ||
97 | if (DEBUG_SO AP_OUTPUT) { | |
98 | prov.get Binding(). getHandler Chain().ad d(new SOAP LoggingHan dler()); | |
99 | List<Han dler> hand lerList = prov.getBi nding().ge tHandlerCh ain(); | |
100 | handlerL ist.add(ne w SOAPLogg ingHandler ()); | |
101 | prov.get Binding(). setHandler Chain(hand lerList); | |
102 | } | |
103 | ||
104 | re turn port; | |
105 | } | |
106 | ||
107 | privat e EntityPa tientFamil ySearchPor tType getE ntityFamil ySearchPor t() { | |
108 | En tityPatien tFamilySea rchPortTyp e port = e ntityPatie ntInquiry. getEntityP atientFami lySearchPo rtSoap11() ; | |
109 | ||
110 | Bi ndingProvi der prov = (BindingP rovider) p ort; | |
111 | pr ov.getRequ estContext ().put(Bin dingProvid er.ENDPOIN T_ADDRESS_ PROPERTY, FAMILY_SEA RCH_URL); | |
112 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.connect. timeout", serviceCon nectionTim eoutMS); | |
113 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.request. timeout", serviceReq uestTimeou tMS); | |
114 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.connect .timeout", serviceCo nnectionTi meoutMS); | |
115 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.request .timeout", serviceRe questTimeo utMS); | |
116 | ||
117 | if (DEBUG_SO AP_OUTPUT) { | |
118 | prov.get Binding(). getHandler Chain().ad d(new SOAP LoggingHan dler()); | |
119 | List<Han dler> hand lerList = prov.getBi nding().ge tHandlerCh ain(); | |
120 | handlerL ist.add(ne w SOAPLogg ingHandler ()); | |
121 | prov.get Binding(). setHandler Chain(hand lerList); | |
122 | } | |
123 | ||
124 | re turn port; | |
125 | } | |
126 | ||
127 | privat e EntityPa tientFamil yRetrieveP ortType ge tEntityFam ilyRetriev ePort() { | |
128 | En tityPatien tFamilyRet rievePortT ype port = entityPat ientInquir y.getEntit yPatientFa milyRetrie vePortSoap 11(); | |
129 | ||
130 | Bi ndingProvi der prov = (BindingP rovider) p ort; | |
131 | pr ov.getRequ estContext ().put(Bin dingProvid er.ENDPOIN T_ADDRESS_ PROPERTY, FAMILY_RET RIEVE_URL) ; | |
132 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.connect. timeout", serviceCon nectionTim eoutMS); | |
133 | pr ov.getRequ estContext ().put("co m.sun.xml. internal.w s.request. timeout", serviceReq uestTimeou tMS); | |
134 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.connect .timeout", serviceCo nnectionTi meoutMS); | |
135 | pr ov.getRequ estContext ().put("co m.sun.xml. ws.request .timeout", serviceRe questTimeo utMS); | |
136 | ||
137 | if (DEBUG_SO AP_OUTPUT) { | |
138 | prov.get Binding(). getHandler Chain().ad d(new SOAP LoggingHan dler()); | |
139 | List<Han dler> hand lerList = prov.getBi nding().ge tHandlerCh ain(); | |
140 | handlerL ist.add(ne w SOAPLogg ingHandler ()); | |
141 | prov.get Binding(). setHandler Chain(hand lerList); | |
142 | } | |
143 | ||
144 | re turn port; | |
145 | } | |
146 | ||
147 | privat e PRPAIN20 1305UV02 g enerateReq uest(PDWSQ ueryBean q ueryBean) { | |
148 | MC CIMT000100 UV01Device device; | |
149 | En Given enGi ven; | |
150 | II ii; | |
151 | CS cs; | |
152 | EN en; | |
153 | ST st; | |
154 | AD ad; | |
155 | ||
156 | Us er user = queryBean. getUser(); | |
157 | Si te host = user.getHo stSite(); | |
158 | St ring agenc y = user.g etAgency() ; | |
159 | St ring dmisI d = ""; | |
160 | St ring siteI d = ""; | |
161 | ||
162 | if (host != null) { | |
163 | dmisId = host.getD misId(); | |
164 | siteId = host.getS iteCode(); | |
165 | } | |
166 | ||
167 | Ob jectFactor y factory = new Obje ctFactory( ); | |
168 | PR PAIN201305 UV02 reque st = facto ry.createP RPAIN20130 5UV02(); | |
169 | ||
170 | // id | |
171 | ii = factory .createII( ); | |
172 | ii .setRoot(" 2.16.840.1 .113883.3. 2017"); | |
173 | ii .setExtens ion("DMDC" ); | |
174 | re quest.setI d(ii); | |
175 | ||
176 | // creationTi me | |
177 | TS ts = fact ory.create TS(); | |
178 | Si mpleDateFo rmat simpl eDateForma t = new Si mpleDateFo rmat("yyyy MMddhhmmss ", Locale. getDefault ()); | |
179 | ts .setValue( simpleDate Format.for mat(new Da te())); | |
180 | re quest.setC reationTim e(ts); | |
181 | ||
182 | // interactio nId | |
183 | ii = factory .createII( ); | |
184 | ii .setRoot(" 2.16.840.1 .113883.1. 6"); | |
185 | ii .setExtens ion("PRPA_ IN201305UV 02"); | |
186 | re quest.setI nteraction Id(ii); | |
187 | ||
188 | // processing Code | |
189 | cs = factory .createCS( ); | |
190 | cs .setCode(A PP_CONFIG. getPDWSPro cCode()); | |
191 | re quest.setP rocessingC ode(cs); | |
192 | ||
193 | // processing ModeCode | |
194 | cs = factory .createCS( ); | |
195 | cs .setCode(" I"); | |
196 | re quest.setP rocessingM odeCode(cs ); | |
197 | ||
198 | // acceptAckC ode | |
199 | cs = factory .createCS( ); | |
200 | cs .setCode(" AL"); | |
201 | re quest.setA cceptAckCo de(cs); | |
202 | ||
203 | // receiver | |
204 | MC CIMT000100 UV01Receiv er receive r = factor y.createMC CIMT000100 UV01Receiv er(); | |
205 | re quest.getR eceiver(). add(receiv er); | |
206 | ||
207 | // receiver/t ypeCode | |
208 | re ceiver.set TypeCode(C ommunicati onFunction Type.RCV); | |
209 | ||
210 | // receiver/d evice | |
211 | de vice = fac tory.creat eMCCIMT000 100UV01Dev ice(); | |
212 | re ceiver.set Device(dev ice); | |
213 | ||
214 | // receiver/d evice/clas sCode | |
215 | de vice.setCl assCode(En tityClassD evice.DEV) ; | |
216 | ||
217 | // receiver/d evice/dete rminerCode | |
218 | de vice.setDe terminerCo de("INSTAN CE"); | |
219 | ||
220 | // receiver/d evice/id | |
221 | ii = factory .createII( ); | |
222 | ii .setRoot(" 1.3.6.1.4. 1.21367.20 09.1.3.1.1 45"); | |
223 | de vice.getId ().add(ii) ; | |
224 | ||
225 | // sender | |
226 | MC CIMT000100 UV01Sender sender = factory.cr eateMCCIMT 000100UV01 Sender(); | |
227 | re quest.setS ender(send er); | |
228 | ||
229 | // sender/typ eCode | |
230 | se nder.setTy peCode(Com munication FunctionTy pe.SND); | |
231 | ||
232 | // sender/dev ice | |
233 | de vice = fac tory.creat eMCCIMT000 100UV01Dev ice(); | |
234 | se nder.setDe vice(devic e); | |
235 | ||
236 | // sender/dev ice/classC ode | |
237 | de vice.setCl assCode(En tityClassD evice.DEV) ; | |
238 | ||
239 | // sender/dev ice/determ inerCode | |
240 | de vice.setDe terminerCo de("INSTAN CE"); | |
241 | ||
242 | // sender/dev ice/id | |
243 | ii = factory .createII( ); | |
244 | ii .setRoot(" 2.16.840.1 .113883.3. 2017.11.7" ); | |
245 | ii .setExtens ion(APP_CO NFIG.getPD WSSndDevId ()); | |
246 | de vice.getId ().add(ii) ; | |
247 | ||
248 | // sender/dev ice/asAgen t | |
249 | MC CIMT000100 UV01Agent agent = fa ctory.crea teMCCIMT00 0100UV01Ag ent(); | |
250 | de vice.setAs Agent(fact ory.create MCCIMT0001 00UV01Devi ceAsAgent( agent)); | |
251 | ||
252 | // sender/dev ice/asAgen t/classCod e | |
253 | ag ent.getCla ssCode().a dd("AGNT") ; | |
254 | ||
255 | // sender/dev ice/asAgen t/represen tedOrganiz ation | |
256 | MC CIMT000100 UV01Organi zation org anization = factory. createMCCI MT000100UV 01Organiza tion(); | |
257 | ag ent.setRep resentedOr ganization (factory.c reateMCCIM T000100UV0 1AgentRepr esentedOrg anization( organizati on)); | |
258 | ||
259 | // sender/dev ice/asAgen t/represen tedOrganiz ation/clas sCode | |
260 | or ganization .setClassC ode("ORG") ; | |
261 | ||
262 | // sender/dev ice/asAgen t/represen tedOrganiz ation/dete rminerCode | |
263 | or ganization .setDeterm inerCode(" INSTANCE") ; | |
264 | ||
265 | // sender/dev ice/asAgen t/represen tedOrganiz ation/id | |
266 | ii = factory .createII( ); | |
267 | if (AGENCY_D OD.equalsI gnoreCase( agency)) { | |
268 | ii.setRo ot("2.16.8 40.1.11388 3.3.42.100 02.100001. 8"); | |
269 | ii.setEx tension(dm isId); | |
270 | } else if (A GENCY_VA.e qualsIgnor eCase(agen cy)) { | |
271 | ii.setRo ot("2.16.8 40.1.11388 3.4.349"); | |
272 | ii.setEx tension(si teId); | |
273 | } | |
274 | or ganization .getId().a dd(ii); | |
275 | ||
276 | // controlAct Process | |
277 | PR PAIN201305 UV02QUQIMT 021001UV01 ControlAct Process co ntrolActPr ocess = fa ctory.crea tePRPAIN20 1305UV02QU QIMT021001 UV01Contro lActProces s(); | |
278 | re quest.setC ontrolActP rocess(con trolActPro cess); | |
279 | ||
280 | // controlAct Process/cl assCode | |
281 | co ntrolActPr ocess.setC lassCode(A ctClassCon trolAct.CA CT); | |
282 | ||
283 | // controlAct Process/mo odCode | |
284 | co ntrolActPr ocess.setM oodCode(XA ctMoodInte ntEvent.EV N); | |
285 | ||
286 | // controlAct Process/co de | |
287 | CD cd = fact ory.create CD(); | |
288 | cd .setCode(" PRPA_TE201 305UV02"); | |
289 | co ntrolActPr ocess.setC ode(cd); | |
290 | ||
291 | // controlAct Process/co deSystem | |
292 | cd .setCodeSy stem("2.16 .840.1.113 883.1.6"); | |
293 | ||
294 | // controlAct Process/da taEnterer | |
295 | QU QIMT021001 UV01DataEn terer data Enterer = factory.cr eateQUQIMT 021001UV01 DataEntere r(); | |
296 | co ntrolActPr ocess.getD ataEnterer ().add(dat aEnterer); | |
297 | ||
298 | // controlAct Process/da taEnterer/ typeCode | |
299 | da taEnterer. getTypeCod e().add("E NT"); | |
300 | ||
301 | // controlAct Process/da taEnterer/ contextCon trolCode | |
302 | da taEnterer. setContext ControlCod e("AP"); | |
303 | ||
304 | // controlAct Process/da taEnterer/ assignedPe rson | |
305 | CO CTMT090100 UV01Assign edPerson a ssignedPer son = fact ory.create COCTMT0901 00UV01Assi gnedPerson (); | |
306 | da taEnterer. setAssigne dPerson(as signedPers on); | |
307 | ||
308 | // controlAct Process/da taEnterer/ assignedPe rson/class Code | |
309 | as signedPers on.setClas sCode("ASS IGNED"); | |
310 | ||
311 | // controlAct Process/da taEnterer/ assignedPe rson/id | |
312 | ii = factory .createII( ); | |
313 | if (AGENCY_D OD.equalsI gnoreCase( agency)) { | |
314 | ii.setRo ot("2.16.8 40.1.11388 3.3.42.127 .100001.79 "); | |
315 | ii.setEx tension(us er.getUser Ien() + "^ " + dmisId ); | |
316 | } else if (A GENCY_VA.e qualsIgnor eCase(agen cy)) { | |
317 | ii.setRo ot("2.16.8 40.1.11388 3.4.349"); | |
318 | ii.setEx tension(us er.getUser Ien() + "^ " + siteId ); | |
319 | } | |
320 | as signedPers on.getId() .add(ii); | |
321 | ||
322 | // controlAct Process/da taEnterer/ assignedPe rson/Perso n | |
323 | CO CTMT090100 UV01Person person1 = factory.c reateCOCTM T090100UV0 1Person(); | |
324 | as signedPers on.setAssi gnedPerson (factory.c reateCOCTM T090100UV0 1AssignedP ersonAssig nedPerson( person1)); | |
325 | ||
326 | // controlAct Process/da taEnterer/ assignedPe rson/Perso n/name | |
327 | en = factory .createEN( ); | |
328 | en .getConten t().add(qu eryBean.ge tUser().ge tName()); | |
329 | pe rson1.getN ame().add( en); | |
330 | ||
331 | // controlAct Process/qu eryByParam eter | |
332 | PR PAMT201306 UV02QueryB yParameter queryByPa rameter = factory.cr eatePRPAMT 201306UV02 QueryByPar ameter(); | |
333 | co ntrolActPr ocess.setQ ueryByPara meter(fact ory.create PRPAIN2013 05UV02QUQI MT021001UV 01ControlA ctProcessQ ueryByPara meter(quer yByParamet er)); | |
334 | ||
335 | // controlAct Process/qu eryByParam eter/query Id | |
336 | ii = factory .createII( ); | |
337 | ii .setRoot(" 2.16.840.1 .113883.3. 2017"); | |
338 | ii .setExtens ion("33333 4433"); | |
339 | qu eryByParam eter.setQu eryId(ii); | |
340 | ||
341 | // controlAct Process/qu eryByParam eter/statu sCode | |
342 | cs = factory .createCS( ); | |
343 | cs .setCode(" new"); | |
344 | qu eryByParam eter.setSt atusCode(c s); | |
345 | ||
346 | // controlAct Process/qu eryByParam eter/initi alQuantity | |
347 | IN T i = fact ory.create INT(); | |
348 | i. setValue(B igInteger. valueOf(10 )); | |
349 | qu eryByParam eter.setIn itialQuant ity(i); | |
350 | ||
351 | // controlAct Process/qu eryByParam eter/param eterList | |
352 | PR PAMT201306 UV02Parame terList pa rameterLis t = factor y.createPR PAMT201306 UV02Parame terList(); | |
353 | qu eryByParam eter.setPa rameterLis t(paramete rList); | |
354 | ||
355 | // controlAct Process/qu eryByParam eter/param eterList/l ivingSubje ctId | |
356 | if (!"".equa ls(queryBe an.getPati entId()) & & !"".equa ls(queryBe an.getPati entIdType( ))) { | |
357 | ii = fac tory.creat eII(); | |
358 | ii.setEx tension(qu eryBean.ge tPatientId ()); | |
359 | ||
360 | String t ype = quer yBean.getP atientIdTy pe(); | |
361 | if ("SSN ".equalsIg noreCase(t ype)) { | |
362 | ii.s etRoot("2. 16.840.1.1 13883.4.1" ); | |
363 | } else i f ("TIN".e qualsIgnor eCase(type )) { | |
364 | ii.s etRoot("2. 16.840.1.1 13883.3.42 .10001.100 001.225"); | |
365 | } else i f ("FIN".e qualsIgnor eCase(type )) { | |
366 | ii.s etRoot("2. 16.840.1.1 13883.3.42 .10001.100 001.224"); | |
367 | } else i f ("ITIN". equalsIgno reCase(typ e)) { | |
368 | ii.s etRoot("2. 16.840.1.1 13883.4.2" ); | |
369 | } else i f ("PIN".e qualsIgnor eCase(type )) { | |
370 | ii.s etRoot("2. 16.840.1.1 13883.3.42 .10001.100 001.226"); | |
371 | } else i f ("EDIPI" .equalsIgn oreCase(ty pe)) { | |
372 | ii.s etRoot("2. 16.840.1.1 13883.3.42 .10001.100 001.12"); | |
373 | } | |
374 | ||
375 | PRPAMT20 1306UV02Li vingSubjec tId living SubjectId = factory. createPRPA MT201306UV 02LivingSu bjectId(); | |
376 | livingSu bjectId.ge tValue().a dd(ii); | |
377 | paramete rList.getL ivingSubje ctId().add (livingSub jectId); | |
378 | ||
379 | //contro lActProces s/queryByP arameter/p arameterLi st/livingS ubjectId/s emanticsTe xt | |
380 | st = fac tory.creat eST(); | |
381 | st.getCo ntent().ad d("LivingS ubject.id" ); | |
382 | livingSu bjectId.se tSemantics Text(st); | |
383 | } | |
384 | ||
385 | // controlAct Process/qu eryByParam eter/param eterList/l ivingSubje ctAdminist rativeGend er | |
386 | if (queryBea n.getGende r() != nul l) { | |
387 | PRPAMT20 1306UV02Li vingSubjec tAdministr ativeGende r adminGen der = fact ory.create PRPAMT2013 06UV02Livi ngSubjectA dministrat iveGender( ); | |
388 | CE ce = factory.cr eateCE(); | |
389 | ce.setCo de(queryBe an.getGend er()); | |
390 | adminGen der.getVal ue().add(c e); | |
391 | paramete rList.getL ivingSubje ctAdminist rativeGend er().add(a dminGender ); | |
392 | ||
393 | //contro lActProces s/queryByP arameter/p arameterLi st/livingS ubjectAdmi nistrative Gender/sem anticsText | |
394 | st = fac tory.creat eST(); | |
395 | st.getCo ntent().ad d("LivingS ubject.adm inistrativ eGender"); | |
396 | adminGen der.setSem anticsText (st); | |
397 | } | |
398 | ||
399 | // controlAct Process/qu eryByParam eter/param eterList/l ivingSubje ctBirthTim e | |
400 | PR PAMT201306 UV02Living SubjectBir thTime bir thTime = f actory.cre atePRPAMT2 01306UV02L ivingSubje ctBirthTim e(); | |
401 | IV LTS ivlts = factory. createIVLT S(); | |
402 | iv lts.setVal ue(queryBe an.getDob( )); | |
403 | bi rthTime.ge tValue().a dd(ivlts); | |
404 | pa rameterLis t.getLivin gSubjectBi rthTime(). add(birthT ime); | |
405 | ||
406 | // controlAct Process/qu eryByParam eter/param eterList/l ivingSubje ctBirthTim e/semantic sText | |
407 | st = factory .createST( ); | |
408 | st .getConten t().add("L ivingSubje ct.birthTi me"); | |
409 | bi rthTime.se tSemantics Text(st); | |
410 | ||
411 | // controlAct Process/qu eryByParam eter/param eterList/l ivingSubje ctName | |
412 | PR PAMT201306 UV02Living SubjectNam e name = f actory.cre atePRPAMT2 01306UV02L ivingSubje ctName(); | |
413 | en = factory .createEN( ); | |
414 | en .getUse(). add("L"); | |
415 | ||
416 | if (StringUt ils.isNotB lank(query Bean.getFi rstName()) ) { | |
417 | enGiven = factory. createEnGi ven(); | |
418 | enGiven. getContent ().add(que ryBean.get FirstName( )); | |
419 | en.getCo ntent().ad d(factory. createENGi ven(enGive n)); | |
420 | } | |
421 | ||
422 | if (StringUt ils.isNotB lank(query Bean.getMi ddleName() )) { | |
423 | enGiven = factory. createEnGi ven(); | |
424 | enGiven. getContent ().add(que ryBean.get MiddleName ()); | |
425 | en.getCo ntent().ad d(factory. createENGi ven(enGive n)); | |
426 | } | |
427 | ||
428 | if (StringUt ils.isNotB lank(query Bean.getLa stName())) { | |
429 | EnFamily enFamily = factory. createEnFa mily(); | |
430 | enFamily .getConten t().add(qu eryBean.ge tLastName( )); | |
431 | en.getCo ntent().ad d(factory. createENFa mily(enFam ily)); | |
432 | } | |
433 | ||
434 | na me.getValu e().add(en ); | |
435 | pa rameterLis t.getLivin gSubjectNa me().add(n ame); | |
436 | ||
437 | // controlAct Process/qu eryByParam eter/param eterList/l ivingSubje ctName/sem anticsText | |
438 | st = factory .createST( ); | |
439 | st .getConten t().add("L ivingSubje ct.name"); | |
440 | na me.setSema nticsText( st); | |
441 | ||
442 | // controlAct Process/qu eryByParam eter/param eterList/p atientAddr ess/value | |
443 | PR PAMT201306 UV02Patien tAddress a ddress = f actory.cre atePRPAMT2 01306UV02P atientAddr ess(); | |
444 | ad = factory .createAD( ); | |
445 | ad .getUse(). add("HP"); | |
446 | ||
447 | // controlAct Process/qu eryByParam eter/param eterList/p atientAddr ess/value/ [@use="HP" ]/streetAd dressLine | |
448 | if (StringUt ils.isNotB lank(query Bean.getAd dress())) { | |
449 | AdxpStre etAddressL ine addres sLine = fa ctory.crea teAdxpStre etAddressL ine(); | |
450 | addressL ine.getCon tent().add (queryBean .getAddres s()); | |
451 | ad.getCo ntent().ad d(factory. createADSt reetAddres sLine(addr essLine)); | |
452 | } | |
453 | ||
454 | // controlAct Process/qu eryByParam eter/param eterList/p atientAddr ess/value/ [@use="HP" ]/city | |
455 | if (StringUt ils.isNotB lank(query Bean.getCi ty())) { | |
456 | AdxpCity city = fa ctory.crea teAdxpCity (); | |
457 | city.get Content(). add(queryB ean.getCit y()); | |
458 | ad.getCo ntent().ad d(factory. createADCi ty(city)); | |
459 | } | |
460 | ||
461 | // controlAct Process/qu eryByParam eter/param eterList/p atientAddr ess/value/ [@use="HP" ]/state | |
462 | if (StringUt ils.isNotB lank(query Bean.getSt ate())) { | |
463 | AdxpStat e state = factory.cr eateAdxpSt ate(); | |
464 | state.ge tContent() .add(query Bean.getSt ate()); | |
465 | ad.getCo ntent().ad d(factory. createADSt ate(state) ); | |
466 | } | |
467 | ||
468 | // controlAct Process/qu eryByParam eter/param eterList/p atientAddr ess/value/ [@use="HP" ]/zip | |
469 | if (StringUt ils.isNotB lank(query Bean.getZi p())) { | |
470 | AdxpPost alCode zip = factory .createAdx pPostalCod e(); | |
471 | zip.getC ontent().a dd(queryBe an.getZip( )); | |
472 | ad.getCo ntent().ad d(factory. createADPo stalCode(z ip)); | |
473 | } | |
474 | ||
475 | ad dress.getV alue().add (ad); | |
476 | pa rameterLis t.getPatie ntAddress( ).add(addr ess); | |
477 | ||
478 | // controlAct Process/qu eryByParam eter/param eterList/o therIDsSco pingOrgani zation | |
479 | PR PAMT201306 UV02OtherI DsScopingO rganizatio n otherIDs ScopingOrg anization = factory. createPRPA MT201306UV 02OtherIDs ScopingOrg anization( ); | |
480 | pa rameterLis t.getOther IDsScoping Organizati on().add(o therIDsSco pingOrgani zation); | |
481 | ||
482 | // controlAct Process/qu eryByParam eter/param eterList/o therIDsSco pingOrgani zation/val ue/id | |
483 | ii = factory .createII( ); | |
484 | ii .setRoot(" 2.16.840.1 .113883.4. 1"); | |
485 | ot herIDsScop ingOrganiz ation.getV alue().add (ii); | |
486 | ||
487 | // controlAct Process/qu eryByParam eter/param eterList/o therIDsSco pingOrgani zation/sem anticsText | |
488 | st = factory .createST( ); | |
489 | st .getConten t().add("O therIDs.sc opingOrgan ization.id "); | |
490 | ot herIDsScop ingOrganiz ation.setS emanticsTe xt(st); | |
491 | ||
492 | // controlAct Process/qu eryByParam eter/param eterList/p atientTelc om | |
493 | if (StringUt ils.isNotB lank(query Bean.getTe l())) { | |
494 | PRPAMT20 1306UV02Pa tientTelec om telecom = factory .createPRP AMT201306U V02Patient Telecom(); | |
495 | TEL tel = factory. createTEL( ); | |
496 | tel.setV alue(query Bean.getTe l()); | |
497 | tel.getU se().add(" H"); | |
498 | telecom. getValue() .add(tel); | |
499 | paramete rList.getP atientTele com().add( telecom); | |
500 | } | |
501 | ||
502 | re turn reque st; | |
503 | } | |
504 | ||
505 | privat e Response PatientQue ry parseRe sponse(PRP AIN201306U V02 respon se, String inquiryTy pe) { | |
506 | Re sponsePati entQuery r espPatQuer y = new Re sponsePati entQuery() ; | |
507 | bo olean done = false; | |
508 | ||
509 | // Initially set to fa ilure with generic e rror messa ge. Will o nly be | |
510 | // set to su ccess if t here are n o acknowle dgement er rors and n o | |
511 | // errors re trieving p atient lis t, even if the list is empty | |
512 | re spPatQuery .setSucces s(false); | |
513 | re spPatQuery .setErrorM sg("Error retrieving patients. " | |
514 | + "< br><br>Ple ase try ag ain." | |
515 | + "< br><br>If the proble m persists , notify y our system administr ator or he lp desk.") ; | |
516 | ||
517 | // Create li st of resu lt patient s | |
518 | Li st<Patient > resultPa tientList = new Arra yList<Pati ent>(); | |
519 | ||
520 | if (response != null) { | |
521 | if (resp onse.getAc knowledgem ent() != n ull) { | |
522 | Ackn owledgemen tDetailTyp e ackDetai lTypeCode; | |
523 | Stri ng ackCode ; | |
524 | Stri ng ackDeta ilCode; | |
525 | Stri ng display Message; | |
526 | CS c s; | |
527 | CE c e; | |
528 | ||
529 | for (MCCIMT000 300UV01Ack nowledgeme nt acknowl edgement : response. getAcknowl edgement() ) { | |
530 | cs = ackno wledgement .getTypeCo de(); | |
531 | if (cs == null) { co ntinue; } | |
532 | ||
533 | ackCode = cs.getCode (); | |
534 | ||
535 | if (acknow ledgement. getAcknowl edgementDe tail() == null) { co ntinue; } | |
536 | for (MCCIM T000300UV0 1Acknowled gementDeta il ackDeta il : ackno wledgement .getAcknow ledgementD etail()) { | |
537 | ackDet ailTypeCod e = ackDet ail.getTyp eCode(); | |
538 | ||
539 | ce = a ckDetail.g etCode(); | |
540 | if (ce == null) { continue ; } | |
541 | ||
542 | ackDet ailCode = ce.getCode (); | |
543 | displa yMessage = ce.getDis playName() ; | |
544 | ||
545 | if ("A A".equalsI gnoreCase( ackCode)) { | |
546 | if (ackDetai lTypeCode == Acknowl edgementDe tailType.W | |
547 | && a ckDetailCo de.contain s("PN") || ackDetail Code.conta ins("FM")) { | |
548 | respPatQ uery.setEr rorMsg(dis playMessag e); | |
549 | } | |
550 | } else if ("AE". equalsIgno reCase(ack Code) | |
551 | && ackDe tailTypeCo de == Ackn owledgemen tDetailTyp e.E | |
552 | && !ackD etailCode. contains(" PN") && !a ckDetailCo de.contain s("FM")) { | |
553 | re spPatQuery .setErrorM sg(display Message); | |
554 | re spPatQuery .setSucces s(false); | |
555 | do ne = true; | |
556 | br eak; | |
557 | } | |
558 | } | |
559 | } | |
560 | } | |
561 | if (!don e) { | |
562 | PRPA IN201306UV 02MFMIMT70 0711UV01Co ntrolActPr ocess cont rolActProc ess = resp onse.getCo ntrolActPr ocess(); | |
563 | if ( (controlAc tProcess ! = null) && (controlA ctProcess. getSubject () != null )) { | |
564 | PRPAIN2013 06UV02MFMI MT700711UV 01Registra tionEvent registrati onEvent; | |
565 | PRPAIN2013 06UV02MFMI MT700711UV 01Subject2 subject1; | |
566 | PRPAMT2013 10UV02Pati ent patien t; | |
567 | PRPAMT2013 10UV02Pers on patient Person; | |
568 | CE ce; | |
569 | TS ts; | |
570 | CS cs; | |
571 | SC sc; | |
572 | Code code; | |
573 | List<Patie nt> person alRelation shipList; | |
574 | List<Perso n> sponsor List; | |
575 | List<PRPAM T201310UV0 2ContactPa rty> conta ctPartyLis t; | |
576 | Patient re sultPatien t; | |
577 | PatientDem ographics resultDemo graphics; | |
578 | PatientDem ographics tempDemogr aphics; | |
579 | ||
580 | for (PRPAI N201306UV0 2MFMIMT700 711UV01Sub ject1 subj ect : cont rolActProc ess.getSub ject()) { | |
581 | regist rationEven t = subjec t.getRegis trationEve nt(); | |
582 | if (re gistration Event == n ull) { con tinue; } | |
583 | ||
584 | subjec t1 = regis trationEve nt.getSubj ect1(); | |
585 | if (su bject1 == null) { co ntinue; } | |
586 | ||
587 | patien t = subjec t1.getPati ent(); | |
588 | if (pa tient == n ull) { con tinue; } | |
589 | ||
590 | result Patient = new Patien t(); | |
591 | result Demographi cs = new P atientDemo graphics() ; | |
592 | tempDe mographics = new Pat ientDemogr aphics(); | |
593 | ||
594 | // Pat ient EDIPI | |
595 | if (pa tient.getI d() != nul l) { | |
596 | fo r (II ii : patient.g etId()) { | |
597 | resultPa tient.setE DIPI(ii.ge tExtension ()); | |
598 | } | |
599 | } | |
600 | ||
601 | if (pa tient.getP atientPers on() != nu ll) { | |
602 | pa tientPerso n = patien t.getPatie ntPerson() .getValue( ); | |
603 | if (patientP erson != n ull) { | |
604 | // Patie nt gender | |
605 | ce = pat ientPerson .getAdmini strativeGe nderCode() ; | |
606 | if (ce ! = null) { | |
607 | resu ltPatient. setGender( ce.getCode ()); | |
608 | } | |
609 | ||
610 | // Patie nt date of birth | |
611 | ts = pat ientPerson .getBirthT ime(); | |
612 | if (ts ! = null) { | |
613 | resu ltPatient. setDob(ts. getValue() ); | |
614 | } | |
615 | ||
616 | // Patie nt name | |
617 | if (pati entPerson. getName() != null) { | |
618 | for (PN pn : p atientPers on.getName ()) { | |
619 | if (pn.get Use() == n ull) { con tinue; } | |
620 | for (Strin g use : pn .getUse()) { | |
621 | if ("L ".equalsIg noreCase(u se)) { | |
622 | re sultPatien t.setName( parseName( pn)); | |
623 | } | |
624 | } | |
625 | } | |
626 | } | |
627 | // Patie nt SSN | |
628 | if (pati entPerson. getAsOther IDs() != n ull) { | |
629 | for (PRPAMT201 310UV02Oth erIDs othe rIDs : pat ientPerson .getAsOthe rIDs()) { | |
630 | if (otherI Ds.getId() == null) { continue ; } | |
631 | for (II ii : otherID s.getId()) { | |
632 | cs = o therIDs.ge tStatusCod e(); | |
633 | if (cs == null) { continue ; } | |
634 | if ("2 .16.840.1. 113883.4.1 ".equalsIg noreCase(i i.getRoot( )) | |
635 | && "acti ve".equals IgnoreCase (cs.getCod e())) { | |
636 | re sultPatien t.setSSN(i i.getExten sion()); | |
637 | } | |
638 | } | |
639 | } | |
640 | } | |
641 | if ("PR" .equalsIgn oreCase(in quiryType) ) { | |
642 | // P atient ran k | |
643 | if ( patientPer son.getAsE mployee() != null) { | |
644 | for (PRPAM T201310UV0 2Employee employee : patientPe rson.getAs Employee() ) { | |
645 | sc = e mployee.ge tJobTitleN ame(); | |
646 | if (sc == null) { continue ; } | |
647 | result Demographi cs.setRank (sc.getDis playName() ); | |
648 | } | |
649 | } | |
650 | ||
651 | // P atient rac e code | |
652 | if ( patientPer son.getRac eCode() != null) { | |
653 | code = new Code(); | |
654 | for (CE ce 1 : patien tPerson.ge tRaceCode( )) { | |
655 | code.s etCode(ce1 .getCode() ); | |
656 | code.s etSystem(C odingSyste m.CDC_RACE .getDispla yName()); | |
657 | result Demographi cs.getRace ().add(cod e); | |
658 | } | |
659 | } | |
660 | ||
661 | // P atient Lan guage (cur rently is a string b ut can be a code) | |
662 | if ( patientPer son.getLan guageCommu nication() != null) { | |
663 | for (PRPAM T201310UV0 2LanguageC ommunicati on lc1 : p atientPers on.getLang uageCommun ication()) { | |
664 | String langDispl ay = lc1.g etLanguage Code().get Code(); | |
665 | result Demographi cs.getLang uages().ad d(Language Cache.getL abel(langD isplay)); | |
666 | } | |
667 | } | |
668 | ||
669 | if(p atientPers on.getEthn icGroupCod e() != nul l) { | |
670 | code = new Code(); | |
671 | for(CE eth : patient Person.get EthnicGrou pCode()){ | |
672 | code.s etCode(eth .getCode() ); | |
673 | code.s etDisplay( eth.getDis playName() ); | |
674 | result Demographi cs.getEthn icGroup(). add(code); | |
675 | } | |
676 | } | |
677 | ||
678 | // P atient hom e & work t elephone n umbers | |
679 | if ( patientPer son.getTel ecom() != null) { | |
680 | for (TEL t el : patie ntPerson.g etTelecom( )) { | |
681 | if ((t el.getUse( ) == null) | |
682 | || (tel. getUse().s ize() > 1) | |
683 | || (tel. getValue() .contains( "mailto")) | |
684 | || (tel. getValue() .contains( "@"))) { | |
685 | co ntinue; | |
686 | } | |
687 | for (S tring use : tel.getU se()) { | |
688 | if ("HP".equ alsIgnoreC ase(use)) { | |
689 | resultDe mographics .setPhone1 (parsePhon eNumber(te l.getValue ())); | |
690 | } else if (" WP".equals IgnoreCase (use)) { | |
691 | resultDe mographics .setPhone2 (parsePhon eNumber(te l.getValue ())); | |
692 | } | |
693 | } | |
694 | } | |
695 | } | |
696 | ||
697 | // P atient's a ddress | |
698 | pars eAddress(p atientPers on, tempDe mographics ); | |
699 | ||
700 | // S ponsors | |
701 | spon sorList = parseSpons ors(patien tPerson); | |
702 | if(s ponsorList != null & & sponsorL ist.size() > 0) { | |
703 | resultDemo graphics.g etSponsors ().addAll( sponsorLis t); | |
704 | } | |
705 | ||
706 | BL o rganDonorI nd = patie ntPerson.g etOrganDon orInd(); | |
707 | if ( organDonor Ind != nul l && organ DonorInd.i sValue() ! = null) { | |
708 | resultDemo graphics.s etOrganDon orInd(Stri ng.valueOf (organDono rInd.isVal ue())); | |
709 | } | |
710 | ||
711 | List <PRPAMT201 310UV02Sub ject4> sub jectOf2 = patient.ge tSubjectOf 2(); | |
712 | if ( subjectOf2 != null) { | |
713 | for (int i = 0; i < subjectOf2 .size(); i ++) { | |
714 | PRPAMT 201310UV02 Subject4 p rpamt20131 0UV02Subje ct4 = subj ectOf2.get (i); | |
715 | PRPAMT 201310UV02 Administra tiveObserv ation admi nistrative Observatio n = prpamt 201310UV02 Subject4.g etAdminist rativeObse rvation(); | |
716 | if (ad ministrati veObservat ion != nul l) { | |
717 | CD code1 = a dministrat iveObserva tion.getCo de(); | |
718 | if (code1 != null && c ode1.getCo de() != nu ll) { | |
719 | String c odeString = code1.ge tCode().tr im(); | |
720 | //blood donor indi cation dat e | |
721 | if ("2.1 6.840.1.11 3883.3.201 7.11.6.2.2 ".equals(c odeString) | |
722 | && adminis trativeObs ervation.g etEffectiv eTime() != null | |
723 | && adminis trativeObs ervation.g etEffectiv eTime().si ze() > 0 | |
724 | //note thi s assumes the date i s the firs t entry | |
725 | && adminis trativeObs ervation.g etEffectiv eTime().ge t(0) != nu ll) { | |
726 | IVLT S sxcmts = (IVLTS) a dministrat iveObserva tion.getEf fectiveTim e().get(0) ; | |
727 | if ( sxcmts != null) { | |
728 | List<JAXBE lement<? e xtends QTY >> rest = sxcmts.get Rest(); | |
729 | if (rest ! = null && rest.size( ) > 0) { | |
730 | JAXBEl ement jaxb Element = rest.get(0 ); | |
731 | IVXBTS ixIvxbts = (IVXBTS) jaxbEleme nt.getValu e(); | |
732 | if (ix Ivxbts != null) { | |
733 | St ring value = ixIvxbt s.getValue (); | |
734 | if (value != null) { | |
735 | Date d = null; | |
736 | ||
737 | Gregoria nCalendar orgIndDate GregorianC alendar = new Gregor ianCalenda r(); | |
738 | ||
739 | try { | |
740 | d = simpleDate Format.par se(value); | |
741 | orgI ndDateGreg orianCalen dar.setTim e(d); | |
742 | } catch (ParseExce ption e) { | |
743 | LOGG ER.error(" Error pars ing organ donor ind date: ", e ); | |
744 | } | |
745 | ||
746 | Datatype Factory da tatypeFact ory = null ; | |
747 | try { | |
748 | data typeFactor y = Dataty peFactory. newInstanc e(); | |
749 | } catch (DatatypeC onfigurati onExceptio n e) { | |
750 | LOGG ER.error(" Error crea ting Datat ypeFactory : ", e); | |
751 | } | |
752 | ||
753 | if(datat ypeFactory != null) { | |
754 | XMLG regorianCa lendar xd = datatype Factory.ne wXMLGregor ianCalenda r(orgIndDa teGregoria nCalendar) ; | |
755 | resu ltDemograp hics.setOr ganDonorIn dDate(xd); | |
756 | } | |
757 | ||
758 | } | |
759 | } | |
760 | } | |
761 | } | |
762 | } | |
763 | //blood type | |
764 | else if ("2.16.840 .1.113883. 3.2017.11. 6.2.3".equ als(codeSt ring) | |
765 | && adminis trativeObs ervation.g etValue() != null) { | |
766 | CD v alue1 = (C D) adminis trativeObs ervation.g etValue(); | |
767 | if ( value1 != null) { | |
768 | resultDemo graphics.s etBloodTyp e(value1.g etDisplayN ame()); | |
769 | } | |
770 | } | |
771 | } | |
772 | } | |
773 | } | |
774 | } | |
775 | ||
776 | ||
777 | // E mergency C ontact/Nex t of Kin | |
778 | cont actPartyLi st = patie ntPerson.g etContactP arty(); | |
779 | if ( (contactPa rtyList != null) && (!contactP artyList.i sEmpty())) { | |
780 | for (PRPAM T201310UV0 2ContactPa rty contac tParty : c ontactPart yList) | |
781 | { | |
782 | if ("E CON".equal sIgnoreCas e(contactP arty.getCl assCode(). name())) | |
783 | { | |
784 | Pe rson perso n = parseP erson(cont actParty); | |
785 | re sultDemogr aphics.get EmergencyC ontact().a dd(person) ; | |
786 | } | |
787 | else i f ("NOK".e qualsIgnor eCase(cont actParty.g etClassCod e().name() )) | |
788 | { | |
789 | Pe rson perso n = parseP erson(cont actParty); | |
790 | re sultDemogr aphics.get NextOfKin( ).add(pers on); | |
791 | } | |
792 | } | |
793 | } | |
794 | ||
795 | } else i f ("FR".eq ualsIgnore Case(inqui ryType)) { | |
796 | // F amily memb ers (depen dents) | |
797 | pers onalRelati onshipList = parsePe rsonalRela tionship(p atientPers on); | |
798 | if ( personalRe lationship List != nu ll) { | |
799 | for (Patie nt patient 1 : person alRelation shipList) { | |
800 | // Set sponsor S SN for eac h family m ember | |
801 | patien t1.setSpon sorSSN(res ultPatient .getSSN()) ; | |
802 | } | |
803 | resultPati entList.ad dAll(perso nalRelatio nshipList) ; | |
804 | } | |
805 | } | |
806 | } | |
807 | } | |
808 | if (!" FR".equals IgnoreCase (inquiryTy pe)) { | |
809 | // Set patie nt data | |
810 | re sultPatien tList.add( resultPati ent); | |
811 | } | |
812 | if ("P R".equalsI gnoreCase( inquiryTyp e)) { | |
813 | // Patient's primary c are manage r (PCM) | |
814 | pa rsePrimary CareManage r(patient, tempDemog raphics); | |
815 | ||
816 | // Set demog raphics da ta | |
817 | // Address ad dress = ne w Address( ); | |
818 | re sultDemogr aphics.set EDIPI(resu ltPatient. getEDIPI() ); | |
819 | re sultDemogr aphics.set SSN(result Patient.ge tSSN()); | |
820 | re sultDemogr aphics.set Name(resul tPatient.g etName()); | |
821 | re sultDemogr aphics.set Gender(res ultPatient .getGender ()); | |
822 | re sultDemogr aphics.set Dob(result Patient.ge tDob()); | |
823 | if (tempDemog raphics.ge tAddress() != null & & tempDemo graphics.g etAddress( ).size() > 0) { | |
824 | // addres s.setStree t1(tempDem ographics. getAddress ().get(0). getStreet1 ()); | |
825 | // addres s.setStree t2(tempDem ographics. getAddress ().get(0). getStreet2 ()); | |
826 | // addres s.setCity( tempDemogr aphics.get Address(). get(0).get City()); | |
827 | // addres s.setState Province(t empDemogra phics.getA ddress().g et(0).getS tateProvin ce()); | |
828 | // addres s.setPosta lCode(temp Demographi cs.getAddr ess().get( 0).getPost alCode()); | |
829 | resultDe mographics .getAddres s().addAll (tempDemog raphics.ge tAddress() ); | |
830 | } | |
831 | re sultDemogr aphics.set PrimaryPro vider(temp Demographi cs.getPrim aryProvide r()); | |
832 | re sultDemogr aphics.set PcmDates(t empDemogra phics.getP cmDates()) ; | |
833 | re sultDemogr aphics.set PcmClinic( tempDemogr aphics.get PcmClinic( )); | |
834 | re spPatQuery .setDemogr aphics(res ultDemogra phics); | |
835 | } | |
836 | } | |
837 | respPatQue ry.setSucc ess(true); | |
838 | respPatQue ry.setErro rMsg(""); | |
839 | respPatQue ry.setPati ents(resul tPatientLi st); | |
840 | } | |
841 | } | |
842 | } | |
843 | re turn respP atQuery; | |
844 | } | |
845 | ||
846 | privat e void par seAddress( PRPAMT2013 10UV02Pers on person, PatientDe mographics patientDe mographics ) { | |
847 | Li st<String> streetAdd ressList = new Array List<Strin g>(); | |
848 | Li st<Seriali zable> ser ializableL ist; | |
849 | Ob ject objec t; | |
850 | Bo olean isBa dAddress; | |
851 | Bo olean isCo nfidential ; | |
852 | ||
853 | Li st<Address > homeList = new Arr ayList<Add ress>(); | |
854 | Li st<Address > tempList = new Arr ayList<Add ress>(); | |
855 | Li st<Address > workList = new Arr ayList<Add ress>(); | |
856 | Li st<Address > postalLi st = new A rrayList<A ddress>(); | |
857 | Li st<Address > pharmLis t = new Ar rayList<Ad dress>(); | |
858 | ||
859 | // Check for home prim ary addres s and bad address | |
860 | fo r (AD ad : person.ge tAddr()) { | |
861 | ||
862 | Address address = new Addres s(); | |
863 | ||
864 | isBadAdd ress = fal se; | |
865 | isConfid ential = f alse; | |
866 | ||
867 | if (ad.g etUse() == null) { | |
868 | cont inue; | |
869 | } | |
870 | ||
871 | for (Str ing use : ad.getUse( )) { | |
872 | if ( use.contai ns("BAD")) { | |
873 | isBadAddre ss = true; | |
874 | address.se tType("BAD "); | |
875 | } el se if (use .contains( "DIR")) { | |
876 | isConfiden tial = tru e; | |
877 | address.se tType("CON FIDENTIAL" ); | |
878 | } el se if (use .contains( "HP")) { | |
879 | address.se tType("Hom e"); | |
880 | } el se if (use .contains( "TMP")) { | |
881 | address.se tType("Tem porary"); | |
882 | } el se if (use .contains( "PST")) { | |
883 | address.se tType("Pos tal"); | |
884 | } el se if (use .contains( "WP")) { | |
885 | address.se tType("Wor k"); | |
886 | } el se if (use .contains( "PHYS")) { | |
887 | address.se tType("Pha rmacy"); | |
888 | } | |
889 | } | |
890 | ||
891 | // If no t home pri mary addre ss or addr ess is bad or addres s content is null, t hen skip t o next | |
892 | if (isCo nfidential || isBadA ddress || (ad.getCon tent() == null)) { | |
893 | cont inue; | |
894 | } | |
895 | ||
896 | streetAd dressList. clear(); | |
897 | ||
898 | for (Ser ializable serializab le : ad.ge tContent() ) { | |
899 | if ( serializab le instanc eof JAXBEl ement) { | |
900 | object = ( (JAXBEleme nt) serial izable).ge tValue(); | |
901 | if (object == null) { | |
902 | contin ue; | |
903 | } | |
904 | ||
905 | // Street address | |
906 | if (object instanceo f AdxpStre etAddressL ine) { | |
907 | serial izableList = ((AdxpS treetAddre ssLine) ob ject).getC ontent(); | |
908 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
909 | st reetAddres sList.add( serializab leList.get (0).toStri ng()); | |
910 | } | |
911 | } else if (object in stanceof A dxpCity) { // City | |
912 | serial izableList = ((AdxpC ity) objec t).getCont ent(); | |
913 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
914 | ad dress.setC ity(serial izableList .get(0).to String()); | |
915 | } | |
916 | } else if (object in stanceof A dxpState) { // State | |
917 | serial izableList = ((AdxpS tate) obje ct).getCon tent(); | |
918 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
919 | ad dress.setS tateProvin ce(seriali zableList. get(0).toS tring()); | |
920 | } | |
921 | } | |
922 | // Zip cod e | |
923 | if (object instanceo f AdxpPost alCode) { | |
924 | serial izableList = ((AdxpP ostalCode) object).g etContent( ); | |
925 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
926 | ad dress.setP ostalCode( serializab leList.get (0).toStri ng()); | |
927 | } | |
928 | } | |
929 | } | |
930 | } | |
931 | ||
932 | // Set s treet addr ess from l ist | |
933 | if (!str eetAddress List.isEmp ty()) { | |
934 | addr ess.setStr eet1(stree tAddressLi st.get(0)) ; | |
935 | if ( streetAddr essList.si ze() > 1) { | |
936 | address.se tStreet2(s treetAddre ssList.get (1)); | |
937 | } | |
938 | } | |
939 | ||
940 | //patien tDemograph ics.getAdd ress().add (address); | |
941 | if (addr ess.getTyp e().equals IgnoreCase ("Home")) { | |
942 | home List.add(a ddress); | |
943 | } else i f (address .getType() .equalsIgn oreCase("T emporary") ) { | |
944 | temp List.add(a ddress); | |
945 | } else i f (address .getType() .equalsIgn oreCase("P ostal")) { | |
946 | post alList.add (address); | |
947 | } else i f (address .getType() .equalsIgn oreCase("W ork")) { | |
948 | work List.add(a ddress); | |
949 | } else i f (address .getType() .equalsIgn oreCase("P harmacy")) { | |
950 | phar mList.add( address); | |
951 | } | |
952 | } | |
953 | ||
954 | if (homeList. size()>0) patientDem ographics. getAddress ().addAll( homeList); | |
955 | if (tempList. size()>0) patientDem ographics. getAddress ().addAll( tempList); | |
956 | if (postalLis t.size()>0 ) patientD emographic s.getAddre ss().addAl l(postalLi st); | |
957 | if (workList. size()>0) patientDem ographics. getAddress ().addAll( workList); | |
958 | if (pharmList .size()>0) patientDe mographics .getAddres s().addAll (pharmList ); | |
959 | } | |
960 | ||
961 | privat e Person p arsePerson (PRPAMT201 310UV02Con tactParty contactPar ty) { | |
962 | Pe rson perso n = new Pe rson(); | |
963 | if (contactP arty.getTe lecom() != null) { | |
964 | for (TEL tel : con tactParty. getTelecom ()) { | |
965 | if ( (tel.getUs e() == nul l) | |
966 | // || ( tel.getUse ().size() > 1) //? | |
967 | || (te l.getValue ().contain s("mailto" )) | |
968 | || (te l.getValue ().contain s("@"))) { | |
969 | continue; | |
970 | } | |
971 | Stri ng telStr= ""; | |
972 | for (int i = 0 ; i < tel. getUse().s ize(); i++ ) { | |
973 | // String u se = tel.g etUse().ge t(i); | |
974 | if (i>0) | |
975 | telStr = telStr. concat(", "); | |
976 | telStr = t elStr.conc at(parsePh oneNumber( tel.getVal ue())); | |
977 | } | |
978 | ||
979 | Tele com teleco m = new Te lecom(); | |
980 | tele com.setVal ue(telStr) ; | |
981 | pers on.getTelc oms().add( telecom); | |
982 | } | |
983 | } | |
984 | ||
985 | // Name | |
986 | if (contactP arty.getCo ntactPerso n().getVal ue().getNa me() != nu ll) { | |
987 | for (EN en : conta ctParty.ge tContactPe rson().get Value().ge tName() ) { | |
988 | if ( en.getUse( ) == null) { continu e; } | |
989 | for (String us e : en.get Use()) { | |
990 | if ("L".eq ualsIgnore Case(use)) { //? PD WS_Ext_Ser v_Desc_R17 .docx p86 | |
991 | person .setName(p arseName(e n)); | |
992 | } | |
993 | } | |
994 | } | |
995 | } | |
996 | ||
997 | Pa tientDemog raphics te mpDemograp hics = new PatientDe mographics (); | |
998 | pa rseAddress ContactPar ty(contact Party, tem pDemograph ics); | |
999 | ||
1000 | if (tempDemog raphics.ge tAddress() != null & & tempDemo graphics.g etAddress( ).size() > 0) { | |
1001 | Address address = new Addres s(); | |
1002 | address. setStreet1 (tempDemog raphics.ge tAddress() .get(0).ge tStreet1() ); | |
1003 | address. setStreet2 (tempDemog raphics.ge tAddress() .get(0).ge tStreet2() ); | |
1004 | address. setCity(te mpDemograp hics.getAd dress().ge t(0).getCi ty()); | |
1005 | address. setStatePr ovince(tem pDemograph ics.getAdd ress().get (0).getSta teProvince ()); | |
1006 | address. setPostalC ode(tempDe mographics .getAddres s().get(0) .getPostal Code()); | |
1007 | ||
1008 | person.g etAddress( ).add(addr ess); | |
1009 | } | |
1010 | ||
1011 | if (contactP arty.getCo de()!=null && contac tParty.get Code().get DisplayNam e()!=null) | |
1012 | person.s etRelation ship(conta ctParty.ge tCode().ge tDisplayNa me()); | |
1013 | ||
1014 | re turn perso n; | |
1015 | } | |
1016 | ||
1017 | ||
1018 | privat e void par seAddressC ontactPart y(PRPAMT20 1310UV02Co ntactParty person, P atientDemo graphics p atientDemo graphics) { | |
1019 | Li st<String> streetAdd ressList = new Array List<Strin g>(); | |
1020 | Li st<Seriali zable> ser ializableL ist; | |
1021 | Ob ject objec t; | |
1022 | Bo olean isBa dAddress; | |
1023 | Bo olean isHo mePrimary; | |
1024 | Bo olean isTe mpAddress; | |
1025 | ||
1026 | // Check for home prim ary addres s and bad address | |
1027 | fo r (AD ad : person.ge tAddr()) { | |
1028 | isBadAdd ress = fal se; | |
1029 | isHomePr imary = fa lse; | |
1030 | isTempAd dress = fa lse; | |
1031 | ||
1032 | if (ad.g etUse() == null) { c ontinue; } | |
1033 | ||
1034 | for (Str ing use : ad.getUse( )) { | |
1035 | if ( use.contai ns("H")) { //? PDWS _Ext_Serv_ Desc_R17.d ocx p84 | |
1036 | isHomePrim ary = true ; | |
1037 | } el se if (use .contains( "BAD")) { | |
1038 | isBadAddre ss = true; | |
1039 | } el se if (use .contains( "TMP")) { | |
1040 | isTempAddr ess = true ; | |
1041 | } | |
1042 | } | |
1043 | ||
1044 | // If no t home pri mary addre ss or addr ess is bad or addres s content is null, t hen skip t o next | |
1045 | if ((!is HomePrimar y && !isTe mpAddress) || isBadA ddress || (ad.getCon tent() == null)) { c ontinue; } | |
1046 | ||
1047 | streetAd dressList. clear(); | |
1048 | ||
1049 | Address address = new Addres s(); | |
1050 | ||
1051 | for (Ser ializable serializab le : ad.ge tContent() ) { | |
1052 | if ( serializab le instanc eof JAXBEl ement) { | |
1053 | object = ( (JAXBEleme nt) serial izable).ge tValue(); | |
1054 | if (object == null) { continue ; } | |
1055 | ||
1056 | // Street address | |
1057 | if (object instanceo f AdxpStre etAddressL ine) { | |
1058 | serial izableList = ((AdxpS treetAddre ssLine) ob ject).getC ontent(); | |
1059 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
1060 | st reetAddres sList.add( serializab leList.get (0).toStri ng()); | |
1061 | } | |
1062 | } else if (object in stanceof A dxpCity) { // City | |
1063 | serial izableList = ((AdxpC ity) objec t).getCont ent(); | |
1064 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
1065 | ad dress.setC ity(serial izableList .get(0).to String()); | |
1066 | } | |
1067 | } else if (object in stanceof A dxpState) { // State | |
1068 | serial izableList = ((AdxpS tate) obje ct).getCon tent(); | |
1069 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
1070 | ad dress.setS tateProvin ce(seriali zableList. get(0).toS tring()); | |
1071 | } | |
1072 | } | |
1073 | // Zip cod e | |
1074 | if (object instanceo f AdxpPost alCode) { | |
1075 | serial izableList = ((AdxpP ostalCode) object).g etContent( ); | |
1076 | if ((s erializabl eList != n ull) && !s erializabl eList.isEm pty()) { | |
1077 | ad dress.setP ostalCode( serializab leList.get (0).toStri ng()); | |
1078 | } | |
1079 | } | |
1080 | } | |
1081 | } | |
1082 | ||
1083 | // Set s treet addr ess from l ist | |
1084 | if (!str eetAddress List.isEmp ty()) { | |
1085 | addr ess.setStr eet1(stree tAddressLi st.get(0)) ; | |
1086 | ||
1087 | if ( streetAddr essList.si ze() > 1) { | |
1088 | address.se tStreet2(s treetAddre ssList.get (1)); | |
1089 | } | |
1090 | } | |
1091 | patientD emographic s.getAddre ss().add(a ddress); | |
1092 | } | |
1093 | } | |
1094 | ||
1095 | privat e void par sePrimaryC areManager (PRPAMT201 310UV02Pat ient patie nt, Patien tDemograph ics patien tDemograph ics) { | |
1096 | if (patient. getCovered PartyOf() == null) { return; } | |
1097 | ||
1098 | CO CTMT510000 UV06Covera geRecord c overageRec ord; | |
1099 | CO CTMT510000 UV06Policy OrProgram policyOrPr ogram; | |
1100 | CO CTMT510000 UV06Benefi t benefit; | |
1101 | CO CTMT530000 UVObservat ion observ ation; | |
1102 | CO CTMT090000 UV01Assign edEntity a ssignedEnt ity; | |
1103 | CO CTMT090000 UV01Person person; | |
1104 | IV LTS ivlts; | |
1105 | IV XBTS ivxbt s; | |
1106 | ||
1107 | fo r (PRPAMT2 01310UV02C overedPart y coveredP arty : pat ient.getCo veredParty Of()) { | |
1108 | coverage Record = c overedPart y.getCover ageRecord( ); | |
1109 | if (cove rageRecord == null) { continue ; } | |
1110 | ||
1111 | if (cove rageRecord .getCompon ent() == n ull) { con tinue; } | |
1112 | ||
1113 | for (COC TMT510000U V06Compone nt compone nt : cover ageRecord. getCompone nt()) { | |
1114 | if ( component. getPolicyO rProgram() == null) { continue ; } | |
1115 | ||
1116 | poli cyOrProgra m = compon ent.getPol icyOrProgr am(); | |
1117 | for (COCTMT510 000UV06Cov erage2 cov erage2 : p olicyOrPro gram.getCo verageOf() ) { | |
1118 | if (covera ge2.getBen efit() == null) { co ntinue; } | |
1119 | ||
1120 | benefit = coverage2. getBenefit (); | |
1121 | for (COCTM T510000UV0 6Definitio n definiti on : benef it.getDefi nition()) { | |
1122 | if (de finition.g etObservat ion() == n ull) { con tinue; } | |
1123 | ||
1124 | observ ation = de finition.g etObservat ion().getV alue(); | |
1125 | if (ob servation == null) { continue; } | |
1126 | ||
1127 | if (ob servation. getPerform er() == nu ll) { cont inue; } | |
1128 | for (C OCTMT53000 0UVPerform er perform er : obser vation.get Performer( )) { | |
1129 | if (performe r.getAssig nedEntity( ) == null) { continu e; } | |
1130 | ||
1131 | as signedEnti ty = perfo rmer.getAs signedEnti ty().getVa lue(); | |
1132 | if (assigned Entity == null) { co ntinue; } | |
1133 | ||
1134 | if (patientDe mographics .getPrimar yProvider( ) == null) { | |
1135 | patientD emographic s.setPrima ryProvider (""); | |
1136 | } | |
1137 | // patientDem ographics. setPcmDate s(null); | |
1138 | if (patientDe mographics .getPcmCli nic() == n ull){ | |
1139 | patientD emographic s.setPcmCl inic(""); | |
1140 | } | |
1141 | ||
1142 | // PCM name | |
1143 | if (assigned Entity.get AssignedPe rson() != null) { | |
1144 | person = assignedE ntity.getA ssignedPer son().getV alue(); | |
1145 | if ((per son != nul l) && (per son.getNam e() != nul l)) { | |
1146 | for (EN en : p erson.getN ame()) { | |
1147 | if (en.get Content() == null) { continue; } | |
1148 | for (Seria lizable co ntent : en .getConten t()) { | |
1149 | patien tDemograph ics.setPri maryProvid er(content .toString( )); | |
1150 | } | |
1151 | } | |
1152 | } | |
1153 | } | |
1154 | ||
1155 | // PCM date | |
1156 | if (assigned Entity.get EffectiveT ime() != n ull) { | |
1157 | ivlts = assignedEn tity.getEf fectiveTim e(); | |
1158 | if (ivlt s.getRest( ) != null) { | |
1159 | for (JAXBEleme nt element : ivlts.g etRest()) { | |
1160 | if (!"low" .equalsIgn oreCase(el ement.getN ame().getL ocalPart() )) { conti nue; } | |
1161 | ||
1162 | ivxbts = ( IVXBTS) el ement.getV alue(); | |
1163 | if (ivxbts == null) { continue ; } | |
1164 | ||
1165 | // YYYYMMD D format ( 8 characte rs) | |
1166 | if (ivxbts .getValue( ) != null && ivxbts. getValue() .length() != 8) { co ntinue; } | |
1167 | patientDem ographics. setPcmDate s(Utils.to XMLGregori anCalendar (ivxbts.ge tValue())) ; | |
1168 | } | |
1169 | } | |
1170 | } | |
1171 | ||
1172 | // PCM Clinic | |
1173 | if (assignedE ntity.getA ssignedOrg anization( ) != null && assigne dEntity.ge tAssignedO rganizatio n().getVal ue() != nu ll) { | |
1174 | COCTMT09 0000UV01Or ganization organizat ion = assi gnedEntity .getAssign edOrganiza tion().get Value(); | |
1175 | if (Coll ectionUtil s.isNotEmp ty(organiz ation.getA sMember()) && organi zation.get AsMember() .get(0).ge tCode() != null) { | |
1176 | pati entDemogra phics.setP cmClinic(o rganizatio n.getAsMem ber().get( 0).getCode ().getDisp layName()) ; | |
1177 | pati entDemogra phics.setP cTeam(orga nization.g etAsMember ().get(0). getCode(). getDisplay Name()); | |
1178 | } | |
1179 | } | |
1180 | } | |
1181 | } | |
1182 | } | |
1183 | } | |
1184 | } | |
1185 | } | |
1186 | ||
1187 | privat e String p arseName(E N en) { | |
1188 | St ringBuilde r familyNa me = new S tringBuild er(); | |
1189 | St ringBuilde r givenNam e = new St ringBuilde r(); | |
1190 | St ringBuilde r prefixNa me = new S tringBuild er(); | |
1191 | St ringBuilde r suffixNa me = new S tringBuild er(); | |
1192 | Li st<Seriali zable> ser ializableL ist1; | |
1193 | Li st<Seriali zable> ser ializableL ist2; | |
1194 | St ring rtc; | |
1195 | Ob ject objec t; | |
1196 | ||
1197 | se rializable List1 = en .getConten t(); | |
1198 | if (serializ ableList1 == null) { | |
1199 | rtc = nu ll; | |
1200 | } else { | |
1201 | ||
1202 | for (Ser ializable serializab le1 : seri alizableLi st1) { | |
1203 | if ( !(serializ able1 inst anceof JAX BElement)) { continu e; } | |
1204 | ||
1205 | obje ct = ((JAX BElement) serializab le1).getVa lue(); | |
1206 | if ( object == null) { co ntinue; } | |
1207 | ||
1208 | if ( object ins tanceof En Family) { | |
1209 | serializab leList2 = ((EnFamily ) object). getContent (); | |
1210 | if (serial izableList 2 == null) { continu e; } | |
1211 | ||
1212 | for (Seria lizable se rializable 2 : serial izableList 2) { | |
1213 | family Name.appen d(serializ able2.toSt ring()); | |
1214 | family Name.appen d(" "); | |
1215 | } | |
1216 | } el se if (obj ect instan ceof EnGiv en) { | |
1217 | serializab leList2 = ((EnGiven) object).g etContent( ); | |
1218 | if (serial izableList 2 == null) { continu e; } | |
1219 | ||
1220 | for (Seria lizable se rializable 2 : serial izableList 2) { | |
1221 | givenN ame.append (serializa ble2.toStr ing()); | |
1222 | givenN ame.append (" "); | |
1223 | } | |
1224 | } el se if (obj ect instan ceof EnPre fix) { | |
1225 | serializab leList2 = ((EnPrefix ) object). getContent (); | |
1226 | if (serial izableList 2 == null) { continu e; } | |
1227 | ||
1228 | for (Seria lizable se rializable 2 : serial izableList 2) { | |
1229 | prefix Name.appen d(serializ able2.toSt ring()); | |
1230 | prefix Name.appen d(" "); | |
1231 | } | |
1232 | } el se if (obj ect instan ceof EnSuf fix) { | |
1233 | serializab leList2 = ((EnSuffix ) object). getContent (); | |
1234 | if (serial izableList 2 == null) { continu e; } | |
1235 | ||
1236 | for (Seria lizable se rializable 2 : serial izableList 2) { | |
1237 | suffix Name.appen d(serializ able2.toSt ring()); | |
1238 | suffix Name.appen d(" "); | |
1239 | } | |
1240 | } | |
1241 | } | |
1242 | ||
1243 | // add p refix befo re given n ame | |
1244 | if (pref ixName.len gth() > 0) { | |
1245 | give nName = pr efixName.a ppend(give nName); | |
1246 | } | |
1247 | ||
1248 | // // add suffix af ter family name | |
1249 | // if (su ffixName.l ength() > 0) { | |
1250 | // fa milyName.a ppend(suff ixName); | |
1251 | // } | |
1252 | ||
1253 | // add s uffix afte r given na me | |
1254 | if (suff ixName.len gth() > 0) { | |
1255 | give nName = gi venName.ap pend(suffi xName); | |
1256 | } | |
1257 | ||
1258 | rtc = fa milyName.t oString(). trim() + " ," + given Name.toStr ing().trim (); | |
1259 | } | |
1260 | re turn rtc; | |
1261 | } | |
1262 | ||
1263 | privat e String p arsePhoneN umber(Stri ng telecom ) { | |
1264 | St ringBuilde r phoneNum ber = new StringBuil der(); | |
1265 | St ringTokeni zer tokeni zer = new StringToke nizer(tele com, " "); | |
1266 | St ring token ; | |
1267 | ch ar code; | |
1268 | ||
1269 | wh ile (token izer.hasMo reTokens() ) { | |
1270 | token = tokenizer. nextToken( ); | |
1271 | code = t oken.toLow erCase(Loc ale.getDef ault()).ch arAt(0); | |
1272 | // Do no t accept t okens that begin wit h (p)riori ty, (y)es text, (n)o text | |
1273 | if ((cod e != 'p') && (code ! = 'y') && (code != ' n')) { | |
1274 | phon eNumber.ap pend(token ); | |
1275 | phon eNumber.ap pend(" "); | |
1276 | } | |
1277 | } | |
1278 | ||
1279 | re turn phone Number.toS tring().tr im(); | |
1280 | } | |
1281 | ||
1282 | privat e List<Per son> parse Sponsors(P RPAMT20131 0UV02Perso n person) { | |
1283 | Li st<Person> sponsorLi st = new A rrayList<P erson>(); | |
1284 | ||
1285 | if (person.g etPersonal Relationsh ip() != nu ll) { | |
1286 | COCTMT03 0007UVPers on person1 ; | |
1287 | ||
1288 | for (PRP AMT201310U V02Persona lRelations hip person alRelation ship : per son.getPer sonalRelat ionship()) { | |
1289 | Pers on sponsor = new Per son(); | |
1290 | if ( personalRe lationship .getRelati onshipHold er1() == n ull) { con tinue; } | |
1291 | ||
1292 | pers on1 = pers onalRelati onship.get Relationsh ipHolder1( ).getValue (); | |
1293 | if ( person1 == null) { c ontinue; } | |
1294 | ||
1295 | // N ame | |
1296 | if ( person1.ge tName() != null) { | |
1297 | for (EN en : person1 .getName() ) { | |
1298 | if (en .getUse() == null) { continue; } | |
1299 | for (S tring use : en.getUs e()) { | |
1300 | if ("L".equa lsIgnoreCa se(use)) { | |
1301 | sponsor. setName(pa rseName(en )); | |
1302 | } | |
1303 | } | |
1304 | } | |
1305 | } | |
1306 | ||
1307 | // R elation | |
1308 | if ( personalRe lationship .getCode() != null) { | |
1309 | sponsor.se tRelations hip(person alRelation ship.getCo de().getDi splayName( )); | |
1310 | } | |
1311 | ||
1312 | // S SN | |
1313 | if ( person1.ge tAsOtherID s() != nul l) { | |
1314 | for (COCTM T030007UVO therIDs ot herIDs : p erson1.get AsOtherIDs ()) { | |
1315 | if (ot herIDs.get Id() == nu ll) { cont inue; } | |
1316 | for (I I ii : oth erIDs.getI d()) { | |
1317 | if ("2.16.84 0.1.113883 .4.1".equa lsIgnoreCa se(ii.getR oot())) { | |
1318 | sponsor. setIdentif ier(ii.get Extension( )); | |
1319 | } | |
1320 | } | |
1321 | } | |
1322 | } | |
1323 | ||
1324 | spon sorList.ad d(sponsor) ; | |
1325 | } | |
1326 | } | |
1327 | ||
1328 | re turn spons orList; | |
1329 | } | |
1330 | ||
1331 | privat e List<Pat ient> pars ePersonalR elationshi p(PRPAMT20 1310UV02Pe rson perso n) { | |
1332 | Li st<Patient > patientL ist = new ArrayList< Patient>() ; | |
1333 | ||
1334 | if (person.g etPersonal Relationsh ip() != nu ll) { | |
1335 | COCTMT03 0007UVPers on person1 ; | |
1336 | Patient patient; | |
1337 | ||
1338 | for (PRP AMT201310U V02Persona lRelations hip person alRelation ship : per son.getPer sonalRelat ionship()) { | |
1339 | if ( personalRe lationship .getRelati onshipHold er1() == n ull) { con tinue; } | |
1340 | ||
1341 | pers on1 = pers onalRelati onship.get Relationsh ipHolder1( ).getValue (); | |
1342 | if ( person1 == null) { c ontinue; } | |
1343 | ||
1344 | pati ent = new Patient(); | |
1345 | ||
1346 | // E DIPI | |
1347 | if ( person1.ge tId() != n ull) { | |
1348 | for (II ii : person1 .getId()) { | |
1349 | if ("2 .16.840.1. 113883.3.4 2.10001.10 0001.12".e qualsIgnor eCase(ii.g etRoot())) { | |
1350 | pa tient.setE DIPI(ii.ge tExtension ()); | |
1351 | } | |
1352 | } | |
1353 | } | |
1354 | ||
1355 | // N ame | |
1356 | if ( person1.ge tName() != null) { | |
1357 | for (EN en : person1 .getName() ) { | |
1358 | if (en .getUse() == null) { continue; } | |
1359 | for (S tring use : en.getUs e()) { | |
1360 | if ("L".equa lsIgnoreCa se(use)) { | |
1361 | patient. setName(pa rseName(en )); | |
1362 | } | |
1363 | } | |
1364 | } | |
1365 | } | |
1366 | ||
1367 | // G ender | |
1368 | if ( person1.ge tAdministr ativeGende rCode() != null) { | |
1369 | patient.se tGender(pe rson1.getA dministrat iveGenderC ode().getC ode()); | |
1370 | } | |
1371 | ||
1372 | // D ate of bir th | |
1373 | if ( person1.ge tBirthTime () != null ) { | |
1374 | patient.se tDob(perso n1.getBirt hTime().ge tValue()); | |
1375 | } | |
1376 | ||
1377 | // S SN | |
1378 | if ( person1.ge tAsOtherID s() != nul l) { | |
1379 | for (COCTM T030007UVO therIDs ot herIDs : p erson1.get AsOtherIDs ()) { | |
1380 | if (ot herIDs.get Id() == nu ll) { cont inue; } | |
1381 | for (I I ii : oth erIDs.getI d()) { | |
1382 | if ("2.16.84 0.1.113883 .4.1".equa lsIgnoreCa se(ii.getR oot())) { | |
1383 | patient. setSSN(ii. getExtensi on()); | |
1384 | } | |
1385 | } | |
1386 | } | |
1387 | } | |
1388 | ||
1389 | pati entList.ad d(patient) ; | |
1390 | } | |
1391 | } | |
1392 | ||
1393 | re turn patie ntList; | |
1394 | } | |
1395 | ||
1396 | public ResponseP atientQuer y lookupPa tient(PDWS QueryBean queryBean) throws JM eadowsExce ption { | |
1397 | PR PAIN201305 UV02 reque st = gener ateRequest (queryBean ); | |
1398 | PR PAIN201306 UV02 respo nse; | |
1399 | Re sponsePati entQuery r tc = null; | |
1400 | ||
1401 | St ring inqui ryType = q ueryBean.g etInquiryT ype(); | |
1402 | if ("PS".equ alsIgnoreC ase(inquir yType)) { | |
1403 | // Perso n Search | |
1404 | response = getEnti tyPatientS earchPort( ).entityPa tientSearc h(request) ; | |
1405 | } else if (" PR".equals IgnoreCase (inquiryTy pe)) { | |
1406 | // Patie nt Retriev e | |
1407 | response = getEnti tyPatientR etrievePor t().entity PatientRet rieve(requ est); | |
1408 | } else if (" FS".equals IgnoreCase (inquiryTy pe)) { | |
1409 | // Famil y Search | |
1410 | response = getEnti tyFamilySe archPort() .entityPat ientFamily Search(req uest); | |
1411 | } else if (" FR".equals IgnoreCase (inquiryTy pe)) { | |
1412 | // Famil y Retrieve | |
1413 | response = getEnti tyFamilyRe trievePort ().entityP atientFami lyRetrieve (request); | |
1414 | } else { | |
1415 | // Inval id Inquiry Type | |
1416 | throw ne w JMeadows Exception( "Invalid I nquiryType :" + inqui ryType); | |
1417 | } | |
1418 | ||
1419 | if (response != null) { | |
1420 | rtc = pa rseRespons e(response , inquiryT ype); | |
1421 | if (rtc != null && !rtc.getP atients(). isEmpty()) { | |
1422 | bool ean found = true; | |
1423 | whil e (found) { | |
1424 | found = fa lse; | |
1425 | List<Patie nt> patien ts = rtc.g etPatients (); | |
1426 | Patient bl acklisted = null; | |
1427 | for (Patie nt patient : patient s) { | |
1428 | if (PD WSBlackLis t.getInsta nce().isBl ackListed( patient.ge tEDIPI())) { | |
1429 | fo und = true ; | |
1430 | bl acklisted = patient; | |
1431 | br eak; | |
1432 | } | |
1433 | } | |
1434 | if (blackl isted != n ull) { | |
1435 | LOGGER .error("re moving bla cklisted p atient"); | |
1436 | patien ts.remove( blackliste d); | |
1437 | rtc.se tPatients( patients); | |
1438 | } | |
1439 | } | |
1440 | } | |
1441 | } | |
1442 | re turn rtc; | |
1443 | } | |
1444 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.