Produced by Araxis Merge on 2/21/2018 6:58:06 AM 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 | CUI-CPP-v2.4.0-source-archive.zip\app\helpers | exam_request_helper.rb | Thu Dec 21 03:33:17 2017 UTC |
| 2 | CUI-CPP-v2.4.0-source-archive.zip\app\helpers | exam_request_helper.rb | Tue Feb 6 20:06:57 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1040 |
| 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 | module Exa mRequestHe lper | |
| 2 | include Contention ObjectHelp er, Reques tObjectHel per | |
| 3 | ||
| 4 | def proc essExamSch edulingReq uestCreate dEvent(exa m_request_ xml, exam_ request_ha sh) | |
| 5 | Active Record::Ba se.transac tion do | |
| 6 | #set Document(e xam_reques t_xml) | |
| 7 | exam Scheduling RequestCre atedEvent = exam_req uest_hash[ 'feed']['e ntry']['co ntent']['E xamManagem entEventNo tification ']['ExamSc hedulingRe questCreat edEvent'] | |
| 8 | clai m_informat ion = exam Scheduling RequestCre atedEvent[ 'ClaimInfo rmation'] | |
| 9 | vete ran_servic e_member_i nfo = clai m_informat ion['Veter anServiceM emberInfo' ] | |
| 10 | ssn = "" # ssn _assignmen t({vet_inf o: veteran _service_m ember_info }) | |
| 11 | vbms ClaimId = claim_info rmation['c laimId'] | |
| 12 | vist a_ien = cl aim_inform ation['Vet eranServic eMemberInf o']['vista Ien'] | |
| 13 | ||
| 14 | @cla im = creat e_or_updat e_claim({c laim_info: claim_inf ormation, | |
| 15 | ve t_info: ve teran_serv ice_member _info, | |
| 16 | ss n: ssn, | |
| 17 | vb ms_claim_i d: vbmsCla imId, | |
| 18 | vi sta_ien: v ista_ien}) | |
| 19 | ||
| 20 | # cre ate_geo_lo cation({cl aim_id: @c laim.id, v et_info_xm l: veteran _service_m ember_info }) | |
| 21 | # cre ate_servic e_periods( {claim_id: @claim.id , vet_info _xml: vete ran_servic e_member_i nfo}) | |
| 22 | # cre ate_region al_office( {vet_info_ xml: veter an_service _member_in fo}) | |
| 23 | ||
| 24 | orig _notificat ion = Noko giri::XML( exam_reque st_xml) | |
| 25 | dest ination_do c = XmlHel per.getDoc (orig_noti fication, 'Destinati on') | |
| 26 | ||
| 27 | exam _request_i d = examSc hedulingRe questCreat edEvent['e xamSchedul ingRequest Id'] | |
| 28 | exam _request_d ate = exam Scheduling RequestCre atedEvent[ 'eventDtg' ] | |
| 29 | spec ial_consid erations = "" # find _special_c onsiderati ons({xml_d oc: exam_r equest_xml }) | |
| 30 | site = get_sit e(destinat ion_doc) | |
| 31 | syst em_name = destinatio n_doc['par ticipating SystemName '] | |
| 32 | exam _request_s tate = Exa mRequestSt ate.find_b y_code("IN _PROGRESS" ) | |
| 33 | ||
| 34 | @exa m_request = ExamRequ est.create ( claim_id : @claim.i d, | |
| 35 | particip ating_syst em_name: s ystem_name , | |
| 36 | request_ date: exam _request_d ate, | |
| 37 | request_ id: exam_r equest_id, | |
| 38 | special_ issues: sp ecial_cons iderations , | |
| 39 | site_id: site.id.t o_s, | |
| 40 | identifi er: Secure Random.uui d, | |
| 41 | exam_req uest_state _id: exam_ request_st ate.id) | |
| 42 | ||
| 43 | proc ess_conten tions({ori g_notifica tion: orig _notificat ion, claim _id: @clai m.id}) | |
| 44 | ||
| 45 | crea teRequestO bject exam _request_x ml, @claim .id | |
| 46 | send _emails_to _triage_us ers site | |
| 47 | end | |
| 48 | end | |
| 49 | ||
| 50 | def proc ess_rework ed_exam_sc heduling_r equest_cre ated_event (exam_requ est_xml, e xam_reques t_hash) | |
| 51 | puts " Processing " | |
| 52 | Active Record::Ba se.transac tion do | |
| 53 | rewo rkedExamSc hedulingRe questCreat edEvent = exam_reque st_hash['f eed']['ent ry']['cont ent']['Exa mManagemen tEventNoti fication'] ['Reworked ExamSchedu lingReques tCreatedEv ent'] | |
| 54 | clai mInformati on = rewor kedExamSch edulingReq uestCreate dEvent['Cl aimInforma tion'] | |
| 55 | ||
| 56 | vbms ClaimId = claimInfor mation['cl aimId'] | |
| 57 | clai mFromDb = Claim.find _by_vbms_c laim_id vb msClaimId | |
| 58 | ||
| 59 | if c laimFromDb .nil? | |
| 60 | ra ise "Claim with ID: #{vbmsClai mId}, does not exist ." | |
| 61 | end | |
| 62 | ||
| 63 | orig _notificat ion = Noko giri::XML( exam_reque st_xml) | |
| 64 | dest ination_do c = XmlHel per.getDoc (orig_noti fication, 'Destinati on') | |
| 65 | ||
| 66 | rewo rked_exam_ scheduling _request_c reated_eve nt = XmlHe lper.getDo c(orig_not ification, 'Reworked ExamSchedu lingReques tCreatedEv ent') | |
| 67 | exam _related_c ontentions = XmlHelp er.getDoc( reworked_e xam_schedu ling_reque st_created _event, 'E xamReworkR elatedCont entions') | |
| 68 | ||
| 69 | exam _related_c ontentions .elements. each do |c ontention| | |
| 70 | de sc = XmlHe lper.getDo c(contenti on, 'Conte ntionDescr iption').t ext | |
| 71 | ||
| 72 | ex am_related _contentio n_id = con tention['e xamRelated Contention Id'] | |
| 73 | ||
| 74 | pr eviously_w orked_cont ention_id = contenti on['previo uslyWorked Contention Id'] | |
| 75 | ||
| 76 | @c ontention = Contenti on.create( exam_relat ed_content ion_id: ex am_related _contentio n_id, clai m_id: clai mFromDb.id , identifi er: Secure Random.uui d, insuffi cient: tru e, previou sly_worked _contentio n_id: prev iously_wor ked_conten tion_id) | |
| 77 | Co ntentionDe tail.creat e(descript ion: desc, name: con tention['n ame'], con tention_id : @content ion.id, ac tive: true ) | |
| 78 | ||
| 79 | ex am_priorit ization_sp ecial_issu es = XmlHe lper.getDo c(contenti on, 'ExamP rioritizat ionSpecial Issues') | |
| 80 | ex am_priorit ization_sp ecial_issu es.element s.each do |special_i ssue| | |
| 81 | issue = Xm lHelper.ge tDoc(speci al_issue, 'SpecialIs sue').text | |
| 82 | @contentio n.exam_pri oritizatio n_special_ issues << ExamPriori tizationSp ecialIssue .create(sp ecial_issu e: issue.t o_s) | |
| 83 | en d | |
| 84 | ||
| 85 | re work_reaso ns = XmlHe lper.getAl l(contenti on, 'Rewor kReason') | |
| 86 | re work_reaso ns.each do |rework_r eason| | |
| 87 | @contentio n.rework_r easons << ReworkReas on.create( reason: re work_reaso n.text.str ip) | |
| 88 | en d | |
| 89 | ||
| 90 | re work_reaso n_free_tex t_list = X mlHelper.g etAll(cont ention, 'R eworkReaso nFreetext' ) | |
| 91 | re work_reaso n_free_tex t_list.eac h do |reas on| | |
| 92 | @contentio n.rework_r eason_free _texts << ReworkReas onFreeText .create(re ason: reas on.text.st rip) | |
| 93 | en d | |
| 94 | ||
| 95 | ad dOrUpdateC ontentionO bject(cont ention, re worked_exa m_scheduli ng_request _created_e vent) | |
| 96 | end | |
| 97 | ||
| 98 | site = get_sit e(destinat ion_doc) | |
| 99 | crea te_exam_re quest exam _request_x ml, orig_n otificatio n, claimFr omDb, site | |
| 100 | #Req uestObject processin g | |
| 101 | crea te_reworke d_request_ object(exa m_request_ xml, claim FromDb.id) | |
| 102 | send _emails_to _triage_us ers site | |
| 103 | end | |
| 104 | end | |
| 105 | ||
| 106 | def proc essExamSch edulingReq uestCancel lationEven t(notifica tionDoc) | |
| 107 | examSc hedulingRe questCance llationEve nt = XmlHe lper.getDo c(notifica tionDoc, " ExamSchedu lingReques tCancellat ionEvent") | |
| 108 | previo usEventId = examSche dulingRequ estCancell ationEvent ['previous Event'] | |
| 109 | examSc hedulingRe questId = examSchedu lingReques tCancellat ionEvent[' examSchedu lingReques tId'] | |
| 110 | if (pr eviousEven tId.nil? o r previous EventId.em pty? or ex amScheduli ngRequestI d.nil? or examSchedu lingReques tId.empty? ) | |
| 111 | rais e Exceptio n, "Invali d previous Event" | |
| 112 | end | |
| 113 | if (ex amScheduli ngRequestI d.nil? or examSchedu lingReques tId.empty? ) | |
| 114 | rais e Exceptio n, "Invali d examSche dulingRequ estId" | |
| 115 | end | |
| 116 | reques tObject = getRequest ObjectByEv entId(prev iousEventI d) | |
| 117 | if (re questObjec t.nil?) | |
| 118 | rais e Exceptio n, "Invali d previous Event. Una ble to loc ate the Ex amRequest record" | |
| 119 | end | |
| 120 | if (va lidExamReq uestCancel lationData (previousE ventId, ex amScheduli ngRequestI d, request Object)) | |
| 121 | exam Request = ExamReques t.find_by_ claim_id(r equestObje ct.claim_i d) | |
| 122 | if ( examReques t.nil?) | |
| 123 | ra ise Except ion, "Unab le to loca te the Exa mRequest r ecord" | |
| 124 | end | |
| 125 | canc elExamRequ estExamina tions(exam Request) | |
| 126 | canc elExamRequ est(notifi cationDoc, examReque st, reques tObject) | |
| 127 | upda teRequestO bjectWithE xamSchedul ingRequest Cancellati onEvent(ex amScheduli ngRequestC ancellatio nEvent, ex amRequest, requestOb ject) | |
| 128 | end | |
| 129 | end | |
| 130 | ||
| 131 | def upda teRequestO bjectWithE xamSchedul ingRequest Cancellati onEvent(ex amScheduli ngRequestC ancellatio nEvent, ex amRequest, requestOb ject) | |
| 132 | handle ExamSchedu lingReques tCancellat ionEvent(e xamSchedul ingRequest Cancellati onEvent, e xamRequest , requestO bject) | |
| 133 | end | |
| 134 | ||
| 135 | def canc elExamRequ estExamina tions(exam Request) | |
| 136 | @exami nations = examReques t.claim.ex aminations | |
| 137 | if (@e xamination s != nil & & @examina tions.coun t > 0) | |
| 138 | #can cel associ ated exami nations | |
| 139 | canc elledExami nationStat e = Examin ationState .find_by_c ode("CANCE LLED") | |
| 140 | @exa minations. each_with_ index do | examinatio n, index| | |
| 141 | ex amination. examinatio n_state_id = cancell edExaminat ionState.i d | |
| 142 | ex amination. cancellati on_reason = "This ex amination is cancell ed because the paren t exam req uest has b een cancel led" | |
| 143 | ex amination. save | |
| 144 | ||
| 145 | no tes = "Thi s examinat ion is can celled bec ause the p arent exam request h as been ca ncelled" | |
| 146 | @e xamination _history = Examinati onHistory. new(examin ation_id: examinatio n.id, note s: notes) | |
| 147 | @e xamination _history.s ave | |
| 148 | ||
| 149 | no tes = "Exa mination " | |
| 150 | no tes = note s + "(" + appendCont entionName s(examinat ion.conten tions) + " ) has been cancelled as a resu lt of Exam Request c ancellatio n" | |
| 151 | @@ exam_reque st_history = ExamReq uestHistor y.new(exam _request_i d: examReq uest.id, n otes: note s) | |
| 152 | @@ exam_reque st_history .save | |
| 153 | end | |
| 154 | end | |
| 155 | end | |
| 156 | ||
| 157 | def canc elExamRequ est(notifi cationDoc, examReque st, reques tObject) | |
| 158 | examRe questState = ExamReq uestState. find_by_co de("CANCEL LED") | |
| 159 | examRe quest.exam _request_s tate_id = examReques tState.id | |
| 160 | examCa ncellation Reason = X mlHelper.g etDoc(noti ficationDo c, "ExamCa ncellation Reason") | |
| 161 | examRe quest.canc ellation_r eason = ex amCancella tionReason .content | |
| 162 | examRe quest.save | |
| 163 | notes = "Exam Re quest has been cance lled" | |
| 164 | @exam_ request_hi story = Ex amRequestH istory.new (exam_requ est_id: ex amRequest. id, notes: notes) | |
| 165 | @exam_ request_hi story.save | |
| 166 | end | |
| 167 | ||
| 168 | def vali dExamReque stCancella tionData(p reviousEve ntId, exam Scheduling RequestIdF romCancell ationReque st, reques tObject) | |
| 169 | reques tObjectDoc = XmlHelp er.convert ToDocument (requestOb ject.xml) | |
| 170 | examSc hedulingRe quest = Xm lHelper.ge tDoc(reque stObjectDo c, "ExamSc hedulingRe quest") | |
| 171 | examSc hedulingRe questId = examSchedu lingReques t['examSch edulingReq uestId'] | |
| 172 | if (ex amScheduli ngRequestI d != examS chedulingR equestIdFr omCancella tionReques t) | |
| 173 | rais e Exceptio n, "Invali d examSche dulingRequ estId. Una ble to loc ate the Ex amRequest record" | |
| 174 | end | |
| 175 | return true | |
| 176 | end | |
| 177 | ||
| 178 | def crea te_or_upda te_claim(a rgs = {}) | |
| 179 | claim_ info = arg s[:claim_i nfo] | |
| 180 | vet_in fo = args[ :vet_info] | |
| 181 | ssn = args[:ssn] | |
| 182 | vbms_c laim_id = args[:vbms _claim_id] | |
| 183 | ||
| 184 | claim = Claim.fi nd_or_crea te_by(vbms _claim_id: vbms_clai m_id) | |
| 185 | claim. patient_ss n = ssn | |
| 186 | claim. claim_date = claim_i nfo['claim Date'] | |
| 187 | claim. label = cl aim_info[' claimLabel '] | |
| 188 | claim. end_produc t_code = c laim_info[ 'endProduc tCode'] | |
| 189 | claim. vbms_claim _id = vbms _claim_id | |
| 190 | claim. edipi = ve t_info['ED IPI'] | |
| 191 | claim. participan t_id = vet _info['par ticipantId '] | |
| 192 | claim. gender = v et_info['g ender'] | |
| 193 | claim. vista_ien = vet_info ['vistaIen '] | |
| 194 | claim. file_numbe r = vet_in fo['fileNu mber'] | |
| 195 | claim. first_name = vet_inf o['firstNa me'] | |
| 196 | claim. middle_nam e = vet_in fo['middle Name'] | |
| 197 | claim. last_name = vet_info ['lastName '] | |
| 198 | claim. date_of_bi rth = vet_ info['date OfBirth'] | |
| 199 | claim. email = ve t_info['em ailAddress '] | |
| 200 | #claim .phone_num ber = vet_ info.dig(' Phone','pr imaryPhone ') | |
| 201 | #claim .alternate _phone = v et_info.di g('Phone', 'alternate Phone') | |
| 202 | #claim .integrati on_control _number = vet_info.d ig('Integr ationContr olNumber', 'Value') | |
| 203 | claim. poa_vso_na me = vet_i nfo['PoaVs oName'] | |
| 204 | claim. poa_vso_nu mber = vet _info['Poa VsoNumber' ] | |
| 205 | #claim .regional_ office_id = vet_info .dig('Regi onalOffice ','station Number') | |
| 206 | claim. benefit_ty pe = claim _info['ben efitProgra mType'] | |
| 207 | ||
| 208 | claim. save | |
| 209 | claim | |
| 210 | end | |
| 211 | ||
| 212 | def ssn_ assignment (args = {} ) | |
| 213 | ssn = args[:vet_ info]['Soc ialSecurit yNumber'][ 'Value'] | |
| 214 | ssn.ni l? ? "-" : ssn | |
| 215 | end | |
| 216 | ||
| 217 | def get_ site(desti nation_doc ) | |
| 218 | the_de stination_ system_nam e = destin ation_doc[ 'participa tingSystem Name'] | |
| 219 | case t he_destina tion_syste m_name | |
| 220 | when "VBMS" | |
| 221 | ra ise "|#{th e_destinat ion_system _name}| is not a val id partici patingSyst emName for a Destina tion eleme nt" | |
| 222 | when 'VBA Cont ractor' | |
| 223 | co ntractorNa me = desti nation_doc ['contract orName'] | |
| 224 | si teFromDb = Site.find _by_name(c ontractorN ame) | |
| 225 | si teFromDb.n il? ? rais e(Exceptio n, "Invali d Contract or ::: #{c ontractorN ame}") : s iteFromDb | |
| 226 | when "VHA" | |
| 227 | th e_vha_site _name = "B oise VA Me dical Cent er" #cs 2 017-07-19 Stopgap un til ZIP Co de functio nality is added | |
| 228 | th e_vha_site = Site.fi nd_by_name (the_vha_s ite_name) | |
| 229 | th e_vha_site .nil? ? ra ise(Except ion, "|#{t he_vha_sit e_name}| i s not a va lid Site") : the_vha _site | |
| 230 | else | |
| 231 | ra ise "|#{th e_destinat ion_system _name}| is not a val id partici patingSyst emName for a Destina tion eleme nt" | |
| 232 | end | |
| 233 | end | |
| 234 | ||
| 235 | def crea te_geo_loc ation(args ={}) | |
| 236 | claim_ id = args[ :claim_id] | |
| 237 | vet_in fo = args[ :vet_info_ xml] | |
| 238 | xml = vet_info[' PreferredG eographicL ocation'] | |
| 239 | ||
| 240 | return if vet_in fo['Prefer redGeograp hicLocatio n'].nil? | |
| 241 | geo_lo cation = P referredGe oLocation. find_or_cr eate_by(cl aim_id: cl aim_id, zi p: xml['Zi pCode']) | |
| 242 | geo_lo cation.cla im_id = cl aim_id | |
| 243 | geo_lo cation.add ress_1 = x ml['Addres s1'] | |
| 244 | geo_lo cation.add ress_2 = x ml['Addres s2'] | |
| 245 | geo_lo cation.add ress_3 = x ml['Addres s3'] | |
| 246 | geo_lo cation.cit y = xml['C ity'] | |
| 247 | geo_lo cation.sta te = xml[' State'] | |
| 248 | geo_lo cation.zip = xml['Zi pCode'] | |
| 249 | geo_lo cation.sav e | |
| 250 | end | |
| 251 | ||
| 252 | def crea te_service _periods(a rgs = {}) | |
| 253 | claim_ id = args[ :claim_id] | |
| 254 | vet_in fo = args[ :vet_info_ xml] | |
| 255 | period s = vet_in fo['Period sOfService ']['Period '] | |
| 256 | ||
| 257 | return if vet_in fo['Period sOfService ']['Period '].nil? | |
| 258 | Array. wrap(perio ds).each d o |period| | |
| 259 | eras = "" | |
| 260 | entr y_date = p eriod['ent ryOnDuty'] .to_dateti me | |
| 261 | end_ date = per iod['servi ceEndDate' ].to_datet ime | |
| 262 | bran ch = perio d['branchO fService'] | |
| 263 | peri od['Eras'] .each { |e ra| eras < < "#{era} " } if per iod['Eras' ].present? | |
| 264 | ||
| 265 | serv ice_period = Service Period.fin d_or_creat e_by(claim _id: claim _id, entry _on_duty: entry_date ) | |
| 266 | serv ice_period .entry_on_ duty = ent ry_date | |
| 267 | serv ice_period .service_e nd_date = end_date | |
| 268 | serv ice_period .branch_of _service = branch | |
| 269 | serv ice_period .eras = er as.strip | |
| 270 | serv ice_period .claim_id = claim_id | |
| 271 | serv ice_period .save | |
| 272 | end | |
| 273 | end | |
| 274 | ||
| 275 | def crea te_regiona l_office(a rgs = {}) | |
| 276 | vet_in fo = args[ :vet_info_ xml] | |
| 277 | xml = vet_info[' RegionalOf fice'] | |
| 278 | statio n_number = xml['stat ionNumber' ] | |
| 279 | ||
| 280 | if Reg ionalOffic e.find_by_ station_nu mber(stati on_number) .nil? | |
| 281 | city = xml['Ph ysicalAddr ess']['Cit y'] | |
| 282 | stat e = xml['P hysicalAdd ress']['St ate'] | |
| 283 | zip = xml['Phy sicalAddre ss']['ZipC ode'] | |
| 284 | coun try = xml[ 'PhysicalA ddress'][' Country'] | |
| 285 | m_ci ty = xml[' MailingAdd ress']['Ci ty'] | |
| 286 | m_st ate = xml[ 'MailingAd dress']['S tate'] | |
| 287 | m_zi p = xml['M ailingAddr ess']['Zip Code'] | |
| 288 | m_co untry = xm l['Mailing Address'][ 'Country'] | |
| 289 | ||
| 290 | regi onal_offic e = Region alOffice.n ew | |
| 291 | regi onal_offic e.station_ number = s tation_num ber | |
| 292 | regi onal_offic e.physical _address = "#{city} #{state} # {zip} #{co untry}" | |
| 293 | regi onal_offic e.mailing_ address = "#{m_city} #{m_state } #{m_zip} #{m_count ry}" | |
| 294 | regi onal_offic e.save | |
| 295 | end | |
| 296 | end | |
| 297 | ||
| 298 | def find _special_c onsiderati ons (args= {}) | |
| 299 | orig_x ml = Nokog iri::XML(a rgs[:xml_d oc]) | |
| 300 | specia l_xml_elem ent = orig _xml.at('/ /em:'+'Spe cialIssue' , | |
| 301 | em: 'http: // DNS /vler/sche mas/vlerSu persetSche ma/examMan agement/1. 0') | |
| 302 | ||
| 303 | specia l_consider ations = " " | |
| 304 | return special_c onsiderati ons if spe cial_xml_e lement.nil ? | |
| 305 | ||
| 306 | specia l_xml_elem ent.childr en.each do |c| | |
| 307 | spec ial_consid erations + = c.text + ", " | |
| 308 | end | |
| 309 | ||
| 310 | specia l_consider ations.cho mp!(", ") | |
| 311 | specia l_consider ations | |
| 312 | end | |
| 313 | ||
| 314 | def proc ess_conten tions(args ={}) | |
| 315 | orig_n otificatio n = args[: orig_notif ication] | |
| 316 | claim_ id = args[ :claim_id] | |
| 317 | exam_r equest_id = Claim.fi nd(claim_i d).exam_re quest_ids. first | |
| 318 | ||
| 319 | the_er ror_string ="" | |
| 320 | ||
| 321 | exam_s cheduling_ request_cr eated_even t = XmlHel per.getDoc (orig_noti fication, 'ExamSched ulingReque stCreatedE vent') | |
| 322 | exam_r elated_con tentions = XmlHelper .getDoc(ex am_schedul ing_reques t_created_ event, 'Ex amRelatedC ontentions ') | |
| 323 | ||
| 324 | exam_r elated_con tentions.e lements.ea ch do |con tention| | |
| 325 | desc = XmlHelp er.getDoc( contention , 'Content ionDescrip tion').tex t | |
| 326 | exam RelatedCon tentionId = contenti on['examRe latedConte ntionId'] | |
| 327 | cont entionFrom Db = Conte ntion.find _by_exam_r elated_con tention_id _and_claim _id(examRe latedConte ntionId, c laim_id) | |
| 328 | the_ contention _to_use = contention FromDb | |
| 329 | if c ontentionF romDb.nil? | |
| 330 | @c ontention = Contenti on.create( exam_relat ed_content ion_id: ex amRelatedC ontentionI d, | |
| 331 | claim_id: claim_id, | |
| 332 | identifier : SecureRa ndom.uuid, | |
| 333 | exam_reque st_id: exa m_request_ id) | |
| 334 | Co ntentionDe tail.creat e(descript ion: desc, | |
| 335 | name: co ntention[' name'], | |
| 336 | contenti on_id: @co ntention.i d, | |
| 337 | active: true) | |
| 338 | th e_contenti on_to_use = @content ion | |
| 339 | end | |
| 340 | ||
| 341 | the_ contention _related_d bq_request s_envelope = XmlHelp er.getDoc( contention ,'DbqReque sts') | |
| 342 | the_ contention _related_d bq_request s_envelope .elements. each do |t he_current _dbq_reque st_envelop e| | |
| 343 | th e_dbq_requ est_identi fier = the _current_d bq_request _envelope[ 'name'] | |
| 344 | be gin | |
| 345 | the_dbq_in formation = DbqInfor mation.fin d_by!(iden tifier: th e_dbq_requ est_identi fier) | |
| 346 | the_conten tion_to_us e.creates_ a_unique_d bq_informa tion_assoc iation_wit h(the_dbq_ informatio n) | |
| 347 | re scue Excep tion => th e_exceptio n | |
| 348 | the_error_ string += "|#{the_db q_request_ identifier }| is not a valid Db qRequest I dentifier\ nPlease re fer to UC4 02 Master Copy v7.7 for DBQ Re quest nami ng convent ions\n" | |
| 349 | en d | |
| 350 | end | |
| 351 | if t he_error_s tring.leng th > 0 | |
| 352 | ra ise the_er ror_string | |
| 353 | end | |
| 354 | ||
| 355 | addO rUpdateCon tentionObj ect(conten tion, exam _schedulin g_request_ created_ev ent) | |
| 356 | end | |
| 357 | end | |
| 358 | ||
| 359 | def crea teRequestO bject(exam _request_x ml, claimI d) | |
| 360 | # Get nokogiri d oc version s of the r equest obj ect templa te and the incoming ExamSchedu lingReques t notifica tion0 | |
| 361 | templa te_path = File.join( Rails.root .to_s, 'ap p', 'xml', 'template s', 'reque st_object_ template.x ml') | |
| 362 | req_ob ject_doc = Nokogiri: :XML(File. open(templ ate_path)) | |
| 363 | orig_n otificatio n_doc = No kogiri::XM L(exam_req uest_xml) | |
| 364 | ||
| 365 | on_esr ce = XmlHe lper.getDo c(orig_not ification_ doc, 'Exam Scheduling RequestCre atedEvent' ).attribut es | |
| 366 | examSc hedulingRe quest = Xm lHelper.ge tDoc(req_o bject_doc, 'ExamSche dulingRequ est') | |
| 367 | examSc hedulingRe quest['exa mSchedulin gRequestId '] = on_es rce['examS chedulingR equestId'] | |
| 368 | ||
| 369 | # Copy ClaimInfo rmation No de into re questObjec t template doc | |
| 370 | ro_cla im_info = XmlHelper. getDoc(req _object_do c, 'ClaimI nformation ') | |
| 371 | on_cla im_info = XmlHelper. getDoc(ori g_notifica tion_doc, 'ClaimInfo rmation') | |
| 372 | ro_cla im_info.re place on_c laim_info. clone | |
| 373 | #claim Id = on_cl aim_info.a ttributes[ 'claimId'] .value | |
| 374 | ||
| 375 | # Copy Contentio ns Node in to request Object tem plate doc | |
| 376 | ro_con tentions = XmlHelper .getDoc(re q_object_d oc, 'Conte ntions') | |
| 377 | on_con tentions = XmlHelper .getDoc(or ig_notific ation_doc, 'ExamRela tedContent ions') | |
| 378 | ro_con tentions.r eplace on_ contention s.clone | |
| 379 | XmlHel per.getDoc (req_objec t_doc, 'Ex amRelatedC ontentions ').name = "Contentio ns" | |
| 380 | ||
| 381 | # Copy ExamSched ulingReque stCreatedE vent Node into reque stObject t emplate do c | |
| 382 | ro_esr _created_e vent = Xml Helper.get Doc(req_ob ject_doc, 'ExamSched ulingReque stCreatedE vent') | |
| 383 | on_esr _created_e vent = Xml Helper.get Doc(orig_n otificatio n_doc, 'Ex amScheduli ngRequestC reatedEven t') | |
| 384 | ro_esr _created_e vent.repla ce on_esr_ created_ev ent.clone | |
| 385 | ||
| 386 | # Copy EventSour ce Node in to request Object tem plate doc (there are multiple occurrance s in reque st_object_ doc, hence the searc h().each) | |
| 387 | req_ob ject_doc.s earch('//e m:EventSou rce').each do |es| | |
| 388 | on_e vent_sourc e = XmlHel per.getDoc (orig_noti fication_d oc, 'Event Source') | |
| 389 | es.r eplace on_ event_sour ce.clone | |
| 390 | end | |
| 391 | ||
| 392 | # Copy these val ues direct ly | |
| 393 | ro_era e = XmlHel per.getDoc (req_objec t_doc, 'Ex amRequestA cknowledge mentEvent' ).attribut es | |
| 394 | # on_es rce = XmlH elper.getD oc(orig_no tification _doc, 'Exa mSchedulin gRequestCr eatedEvent ').attribu tes | |
| 395 | ro_era e['examSch edulingReq uestId'].v alue = on_ esrce['exa mSchedulin gRequestId '] | |
| 396 | ro_era e['eventId '].value = on_esrce[ 'eventId'] | |
| 397 | ro_era e['eventDt g'].value = on_esrce ['eventDtg '] | |
| 398 | ro_era e['modelVe rsion'].va lue = on_e srce['mode lVersion'] | |
| 399 | eventI d = ro_era e['eventId '].value | |
| 400 | ||
| 401 | # Find the most recent req uestObject record wh ich matche s the clai m_id from the incomi ng request . | |
| 402 | # q | |
| 403 | # If p resent, se t active=f alse. Then add the n ew active requestObj ect record . | |
| 404 | reqObj ect = Requ estObject. all.order( 'created_a t desc').f ind_by_cla im_id clai mId | |
| 405 | if req Object.pre sent? | |
| 406 | reqO bject.upda te(active: false) | |
| 407 | reqO bject.save | |
| 408 | end | |
| 409 | reqObj ect = Requ estObject. create(req uest_type: "ExamSche dulingRequ estCreated Event_Noti fication", event_id: eventId, claim_id: claimId, a ctive: tru e, xml: re q_object_d oc.to_xml) | |
| 410 | ||
| 411 | examRe q = ExamRe quest.find _by_claim_ id(claimId ) | |
| 412 | examAc kNotificat ion = Exam RequestAck nowledgeme ntNotifica tion.new | |
| 413 | eventI d = examAc kNotificat ion.build_ notificati on(orig_no tification _doc, req_ object_doc , examReq. site) | |
| 414 | VlerDA SJob.sendN otificatio n(examAckN otificatio n, eventId , claimId, "Exam Req uest Ackno wledgement Event Not ification" ) | |
| 415 | end | |
| 416 | ||
| 417 | def crea te_reworke d_request_ object(exa m_request_ xml, claim Id) | |
| 418 | # Get nokogiri d oc version s of the r equest obj ect templa te and the incoming ExamSchedu lingReques t notifica tion0 | |
| 419 | templa te_path = File.join( Rails.root .to_s, 'ap p', 'xml', 'template s', 'rewor ked_exam_s cheduling_ request_ob ject_templ ate.xml') | |
| 420 | req_ob ject_doc = Nokogiri: :XML(File. open(templ ate_path)) | |
| 421 | orig_n otificatio n_doc = No kogiri::XM L(exam_req uest_xml) | |
| 422 | ||
| 423 | on_esr ce = XmlHe lper.getDo c(orig_not ification_ doc, 'Rewo rkedExamSc hedulingRe questCreat edEvent'). attributes | |
| 424 | examSc hedulingRe quest = Xm lHelper.ge tDoc(req_o bject_doc, 'Reworked ExamSchedu lingReques t') | |
| 425 | examSc hedulingRe quest['exa mSchedulin gRequestId '] = on_es rce['examS chedulingR equestId'] .value | |
| 426 | ||
| 427 | # Copy ClaimInfo rmation No de into re questObjec t template doc | |
| 428 | ro_cla im_info = XmlHelper. getDoc(req _object_do c, 'ClaimI nformation ') | |
| 429 | on_cla im_info = XmlHelper. getDoc(ori g_notifica tion_doc, 'ClaimInfo rmation') | |
| 430 | ro_cla im_info.re place on_c laim_info. clone | |
| 431 | #claim Id = on_cl aim_info.a ttributes[ 'claimId'] .value | |
| 432 | ||
| 433 | # Copy Contentio ns Node in to request Object tem plate doc | |
| 434 | ro_con tentions = XmlHelper .getDoc(re q_object_d oc, 'Conte ntions') | |
| 435 | on_con tentions = XmlHelper .getDoc(or ig_notific ation_doc, 'ExamRewo rkRelatedC ontentions ') | |
| 436 | ro_con tentions.r eplace on_ contention s.clone | |
| 437 | XmlHel per.getDoc (req_objec t_doc, 'Ex amReworkRe latedConte ntions').n ame = "Con tentions" | |
| 438 | ||
| 439 | # Copy ExamSched ulingReque stCreatedE vent Node into reque stObject t emplate do c | |
| 440 | ro_esr _created_e vent = Xml Helper.get Doc(req_ob ject_doc, 'ReworkedE xamSchedul ingRequest CreatedEve nt') | |
| 441 | on_esr _created_e vent = Xml Helper.get Doc(orig_n otificatio n_doc, 'Re workedExam Scheduling RequestCre atedEvent' ) | |
| 442 | ro_esr _created_e vent.repla ce on_esr_ created_ev ent.clone | |
| 443 | ||
| 444 | # Copy EventSour ce Node in to request Object tem plate doc (there are multiple occurrance s in reque st_object_ doc, hence the searc h().each) | |
| 445 | req_ob ject_doc.s earch('//e m:EventSou rce').each do |es| | |
| 446 | on_e vent_sourc e = XmlHel per.getDoc (orig_noti fication_d oc, 'Event Source') | |
| 447 | es.r eplace on_ event_sour ce.clone | |
| 448 | end | |
| 449 | ||
| 450 | # Copy these val ues direct ly | |
| 451 | ro_era e = XmlHel per.getDoc (req_objec t_doc, 'Ex amRequestA cknowledge mentEvent' ).attribut es | |
| 452 | # on_es rce = XmlH elper.getD oc(orig_no tification _doc, 'Exa mSchedulin gRequestCr eatedEvent ').attribu tes | |
| 453 | ro_era e['examSch edulingReq uestId'].v alue = on_ esrce['exa mSchedulin gRequestId '] | |
| 454 | ro_era e['eventId '].value = on_esrce[ 'eventId'] | |
| 455 | ro_era e['eventDt g'].value = on_esrce ['eventDtg '] | |
| 456 | ro_era e['modelVe rsion'].va lue = on_e srce['mode lVersion'] | |
| 457 | ro_era e['previou sEvent'].v alue = on_ esrce['eve ntId'] | |
| 458 | eventI d = ro_era e['eventId '].value | |
| 459 | ||
| 460 | # Find the most recent req uestObject record wh ich matche s the clai m_id from the incomi ng request . | |
| 461 | # If p resent, se t active=f alse. Then add the n ew active requestObj ect record . | |
| 462 | reqObj ect = Requ estObject. all.order( 'created_a t desc').f ind_by_cla im_id clai mId | |
| 463 | if req Object.pre sent? | |
| 464 | reqO bject.upda te(active: false) | |
| 465 | reqO bject.save | |
| 466 | end | |
| 467 | reqObj ect = Requ estObject. create(req uest_type: "Reworked ExamSchedu lingReques tCreatedEv ent_Notifi cation", e vent_id: e ventId, cl aim_id: cl aimId, act ive: true, xml: req_ object_doc .to_xml) | |
| 468 | ||
| 469 | examAc kNotificat ion = Exam RequestAck nowledgeme ntNotifica tion.new | |
| 470 | eventI d = examAc kNotificat ion.build_ notificati on(orig_no tification _doc, req_ object_doc ) | |
| 471 | VlerDA SJob.sendN otificatio n(examAckN otificatio n, eventId , claimId, "Reworked Exam Requ est Acknow ledgement Event Noti fication") | |
| 472 | end | |
| 473 | ||
| 474 | def prep are_examin ation_capt ion(select ed_content ions) | |
| 475 | examin ation_capt ion = "Exa mination f or:" | |
| 476 | select ed_content ions.each_ with_index do |conte ntion, ind ex| | |
| 477 | capt ion_separa tor = "" | |
| 478 | if i ndex > 0 & & index == selected_ contention s.length-1 | |
| 479 | ca ption_sepa rator = " and " | |
| 480 | elsi f index > 0 | |
| 481 | ca ption_sepa rator = "; " | |
| 482 | else | |
| 483 | ca ption_sepa rator = " " | |
| 484 | end | |
| 485 | exam ination_ca ption = "# {examinati on_caption }#{caption _separator }#{the_nam e_and_asso ciated_dbq _titles_st ring_for(c ontention) }" | |
| 486 | end | |
| 487 | ||
| 488 | examin ation_capt ion | |
| 489 | end | |
| 490 | ||
| 491 | def time _select | |
| 492 | option s_for_sele ct(['00:00 ', '00:30' , '01:00', '01:30', '02:00', | |
| 493 | '02:30 ', '03:00' , '03:30', '04:00', '04:30', | |
| 494 | '05:00 ', '05:30' , '06:00', '06:30', '07:00', | |
| 495 | '07:30 ', '08:00' , '08:30', '09:00', '09:30', | |
| 496 | '10:00 ', '10:30' , '11:00', '11:30', '12:00', | |
| 497 | '12:30 ', '13:00' , '13:30', '14:00', '14:30', | |
| 498 | '15:00 ', '15:30' , '16:00', '16:30', '17:00', | |
| 499 | '17:30 ', '18:00' , '18:30', '19:00', '19:30', | |
| 500 | '20:00 ', '20:30' , '21:00', '21:30', '22:00', | |
| 501 | '22:30 ', '23:00' , '23:30'] ) | |
| 502 | end | |
| 503 | ||
| 504 | private | |
| 505 | def crea te_exam_re quest exam _request_x ml, orig_n otificatio n, claim, site | |
| 506 | exam_r equest_sta te = ExamR equestStat e.find_by_ code("IN_P ROGRESS") | |
| 507 | ||
| 508 | if exa m_request_ state.nil? | |
| 509 | #FIX ME: Dont throw this exception to outsid e world | |
| 510 | rais e Exceptio n, "Invali d Exam Req uest State Id" | |
| 511 | end | |
| 512 | @exam_ request = ExamReques t.create(c laim_id: c laim.id, s ite_id: si te.id.to_s , identifi er: Secure Random.uui d, exam_re quest_stat e_id: exam _request_s tate.id) | |
| 513 | end | |
| 514 | ||
| 515 | def send _emails_to _triage_us ers site | |
| 516 | site_t riage_user s = User.a ll.include s(:sites). where(:sit es => {nam e: site.na me}).inclu des(:site_ role_sets) .where(:si te_role_se ts => {tri age: "true "}) | |
| 517 | site_t riage_user s.try(:eac h){|st| | |
| 518 | # Ex amManageme ntMailer.e xam_schedu ling_reque st_created (st).deliv er_now | |
| 519 | } | |
| 520 | end | |
| 521 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.