Produced by Araxis Merge on 5/24/2018 2:23:10 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | CUI-v2.5.0-release-source.zip\app\models | claim.rb | Fri Mar 23 17:02:06 2018 UTC |
| 2 | CUI-v2.5.0-release-source.zip\app\models | claim.rb | Wed May 16 20:34:48 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 384 |
| 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 | # == Schem a Informat ion | |
| 2 | # | |
| 3 | # Table na me: claims | |
| 4 | # | |
| 5 | # id :integer no t null, pr imary key | |
| 6 | # complet ed_at :datetime | |
| 7 | # created _at :datetime | |
| 8 | # updated _at :datetime | |
| 9 | # patient _ssn :string | |
| 10 | # file_nu mber :string | |
| 11 | # first_n ame :string | |
| 12 | # middle_ name :string | |
| 13 | # last_na me :string | |
| 14 | # date_of _birth :date | |
| 15 | # facilit y_name :string | |
| 16 | # facilit y_number :string | |
| 17 | # exam_re quest_data :text | |
| 18 | # vbms_cl aim_id :string | |
| 19 | # claim_d ate :date | |
| 20 | # email :string | |
| 21 | # phone_n umber :string | |
| 22 | # benefit _type :string | |
| 23 | # label :string | |
| 24 | # end_pro duct_code :string | |
| 25 | # edipi :string | |
| 26 | # partici pant_id :string | |
| 27 | # gender :string | |
| 28 | # vista_i en :string | |
| 29 | # alterna te_phone :string | |
| 30 | # integra tion_contr ol_number :string | |
| 31 | # poa_vso _name :string | |
| 32 | # poa_vso _number :string | |
| 33 | # regiona l_office_i d :integer | |
| 34 | # | |
| 35 | ||
| 36 | class Clai m < Active Record::Ba se | |
| 37 | has_many :contenti ons, depen dent: :des troy | |
| 38 | has_many :evaluati ons, depen dent: :des troy | |
| 39 | ||
| 40 | has_many :examinat ions | |
| 41 | has_many :exam_req uests | |
| 42 | has_many :examinat ion_schedu les, throu gh: :exami nations | |
| 43 | ||
| 44 | validate s_presence _of :first _name | |
| 45 | validate s_presence _of :last_ name | |
| 46 | #validat es_presenc e_of :pati ent_ssn | |
| 47 | validate s_presence _of :file_ number | |
| 48 | validate s_presence _of :date_ of_birth | |
| 49 | ||
| 50 | auto_str ip_attribu tes :first _name, :mi ddle_name, :last_nam e, :patien t_ssn, :fi le_number, :date_of_ birth | |
| 51 | ||
| 52 | accepts_ nested_att ributes_fo r :content ions, allo w_destroy: true, rej ect_if: pr oc {|attri butes| att ributes.co llect{|k,v | v.blank? }.all? } | |
| 53 | ||
| 54 | serializ e :exam_re quest_data , Hash | |
| 55 | ||
| 56 | scope :w ith_exam_s chedules, -> () { jo ins(:exami nations => :examinat ion_schedu les).disti nct } | |
| 57 | ||
| 58 | scope :a ctive_exam _schedule, -> () { w here("exam ination_sc hedules.ac tive = tru e").refere nces(:clai ms) } | |
| 59 | ||
| 60 | scope :w ith_start_ and_end_da te, proc { |start_da te, end_da te| | |
| 61 | where( "examinati on_schedul es.exam_da te_time BE TWEEN ? AN D ?", star t_date, en d_date).ac tive_exam_ schedule i f start_da te.present ? && end_d ate.presen t? | |
| 62 | } | |
| 63 | ||
| 64 | scope :w ith_patien t_name, pr oc { |name | | |
| 65 | where( "CONCAT_WS (' ', firs t_name, mi ddle_name, last_name ) ILIKE :n ame OR CON CAT_WS(' ' , first_na me, last_n ame) ILIKE :name", n ame: "%#{n ame}%") if name.pres ent? | |
| 66 | } | |
| 67 | ||
| 68 | # vbms_cla im_id no l onger in u se by IEPD 2.0 | |
| 69 | # scope : with_patie nt_id, pro c { |patie nt_id| | |
| 70 | # where ("vbms_cla im_id ILIK E ?" , "%# {patient_i d}%") if p atient_id. present? | |
| 71 | # } | |
| 72 | ||
| 73 | TIMESTAM P_FORMAT = '%m/%d/%Y '.freeze | |
| 74 | ||
| 75 | def self .appointme nt_search( params) | |
| 76 | search _params = clean_para ms(params) | |
| 77 | with_e xam_schedu les | |
| 78 | .with_ start_and_ end_date(s earch_para ms[:start_ date], sea rch_params [:end_date ]) | |
| 79 | .with_ patient_na me(search_ params[:p_ name]) | |
| 80 | .with_ patient_id (search_pa rams[:pati ent_id_sea rch]) | |
| 81 | end | |
| 82 | ||
| 83 | def summ ary | |
| 84 | conten tions.coll ect{|conte ntion| con tention.na me }.join( ", ") | |
| 85 | end | |
| 86 | ||
| 87 | def mask ed_ssn | |
| 88 | patien t_ssn.pres ent? ? Vet eranSSN.ne w(patient_ ssn).maske d : "" | |
| 89 | end | |
| 90 | ||
| 91 | def othe r_contenti ons(conten tion) | |
| 92 | self.co ntentions. all - [con tention] | |
| 93 | end | |
| 94 | ||
| 95 | def pati ent_name | |
| 96 | [first _name, mid dle_name, last_name] .join(" ") .squish | |
| 97 | end | |
| 98 | ||
| 99 | # FIXME: this meth od doesn't seem like it belong s here | |
| 100 | # maybe there shou ld be a mo re generic object to hande thi s type of behavior.. . | |
| 101 | def buil d_date_of_ birth(para ms) | |
| 102 | if par ams[:date_ of_birth_d ay].presen t? && para ms[:date_o f_birth_mo nth].prese nt? && par ams[:date_ of_birth_d ay].presen t? | |
| 103 | Date Time.new(p arams[:dat e_of_birth _year].to_ i, | |
| 104 | p arams[:dat e_of_birth _month].to _i, | |
| 105 | p arams[:dat e_of_birth _day].to_i ) | |
| 106 | end | |
| 107 | end | |
| 108 | ||
| 109 | def self .create_fr om_exam_re quest_xml( exam_reque st_xml) | |
| 110 | new_cl aim = Clai m.new | |
| 111 | ||
| 112 | exam_r equest_has h = Hash.f rom_xml(ex am_request _xml) | |
| 113 | ||
| 114 | if exa m_request_ hash && ex am_request _hash['fee d'] && exa m_request_ hash['feed ']['entry' ] && exam_ request_ha sh['feed'] ['entry'][ 'content'] && | |
| 115 | exam _request = exam_requ est_hash[' feed']['en try']['con tent']['Ex amRequest' ] | |
| 116 | exam iner_email _address = exam_requ est['VhaUs erContactI nfo'].try( :[], 'Emai lAddress') | |
| 117 | exam iner_usern ame = exam _request[' VhaUserCon tactInfo'] .try(:[], 'UserName' ) | |
| 118 | exam iner = Use r.find_or_ create_by( email: exa miner_emai l_address. downcase) do |examin er| | |
| 119 | ex aminer.fir st_name, e xaminer.la st_name = examiner_u sername, e xaminer_us ername | |
| 120 | examiner.p assword = VsID | |
| 121 | ex aminer.rol es << "exa miner" | |
| 122 | end | |
| 123 | ||
| 124 | Acti veRecord:: Base.trans action do | |
| 125 | ne w_claim = create_new _claim_fro m_exam_dat a(exam_req uest) | |
| 126 | ||
| 127 | co ntentions_ data = exa m_request[ 'Contentio nsInformat ion']['Con tention'] | |
| 128 | co ntentions_ data = [co ntentions_ data] if c ontentions _data.is_a ? Hash | |
| 129 | co ntentions_ data.each do |conten tion| | |
| 130 | contention _name = co ntention[' Contention Classifica tionName'] | |
| 131 | new_conten tion = Con tention.cr eate(name: contentio n_name, hi story: con tention['C ontentionN ame'], cla im_id: new _claim.id) | |
| 132 | ||
| 133 | evaluation s_data = e xam_reques t['ExamsIn formation' ]['Exam'] | |
| 134 | evaluation s_data = [ evaluation s_data] if evaluatio ns_data.is _a? Hash | |
| 135 | evaluation s_data.eac h do |eval uation| | |
| 136 | dbq_eval uation_typ e = evalua tion['Exam TemplateDo cumentType '] | |
| 137 | if dbq_e valuation_ type.prese nt? | |
| 138 | dbq_ev aluation_k ey = get_d bq_evaluat ion_key(db q_evaluati on_type) | |
| 139 | if dbq _evaluatio n_key.pres ent? | |
| 140 | spec = Evaluat ionSpec.fi nd_by_titl e(EVALUATI ON_MAPPING S[dbq_eval uation_key ]) | |
| 141 | if s pec | |
| 142 | ne w_evaluati on = Evalu ation.crea te(claim: new_claim, evaluatio n_spec: sp ec, user: examiner) | |
| 143 | ||
| 144 | # This is a little wei rd, becaus e it will be logged after the "evaluatio n created" message | |
| 145 | # that gets created as a post-co mmit hook on the eva luation mo del but th ere's no w ay to | |
| 146 | # log before it gets c reated in the databa se | |
| 147 | Ev aluationLo g.create(e valuation_ id: new_ev aluation.i d, | |
| 148 | messa ge: "Evalu ation was submitted as an Exam Request") | |
| 149 | ||
| 150 | ne w_contenti on.evaluat ions << ne w_evaluati on | |
| 151 | end | |
| 152 | end | |
| 153 | end | |
| 154 | end | |
| 155 | en d | |
| 156 | end | |
| 157 | end | |
| 158 | new_cl aim | |
| 159 | end | |
| 160 | ||
| 161 | ||
| 162 | def self .clean_par ams(params ) | |
| 163 | ||
| 164 | return params if params.bl ank? | |
| 165 | ||
| 166 | clean_ params = p arams.perm it(:start_ date, :end _date, :na me, :patie nt_id_sear ch, :p_nam e) | |
| 167 | ||
| 168 | clean_ params[:st art_date] = Date.str ptime(para ms[:start_ date], TIM ESTAMP_FOR MAT).begin ning_of_da y if clean _params[:s tart_date] .present? | |
| 169 | clean_ params[:en d_date] = Date.str ptime(para ms[:end_da te], TIME STAMP_FORM AT).end_of _day if cl ean_params [:end_date ].present? | |
| 170 | ||
| 171 | clean_ params | |
| 172 | end | |
| 173 | ||
| 174 | private | |
| 175 | ||
| 176 | def self .create_ne w_claim_fr om_exam_da ta(exam_re quest) | |
| 177 | claim_ data = exa m_request[ 'PostDisch argeClaimI nformation '] | |
| 178 | patien t_data = c laim_data[ 'VeteranSe rviceMembe rInformati on'] | |
| 179 | Claim. create(fir st_name: p atient_dat a['FirstNa me'], | |
| 180 | mid dle_name: patient_da ta['Middle Name'], | |
| 181 | las t_name: pa tient_data ['LastName '], | |
| 182 | fil e_number: patient_da ta['FileNu mber'], | |
| 183 | dat e_of_birth : patient_ data['Date OfBirth']. try(:to_da te), | |
| 184 | fac ility_name : exam_req uest['Faci lityInform ation'].tr y(:[], 'Na me'), | |
| 185 | fac ility_numb er: exam_r equest['Fa cilityInfo rmation']. try(:[], ' Id'), | |
| 186 | exa m_request_ data: exam _request.d elete_if{ |key,value | key.star t_with?('x mlns:')} | |
| 187 | ) | |
| 188 | end | |
| 189 | ||
| 190 | def self .get_dbq_e valuation_ key(dbq_ev aluation_t ype) | |
| 191 | EVALUA TION_MAPPI NGS.keys.s elect { |k ey| dbq_ev aluation_t ype.downca se.include ?(key.down case) }.fi rst | |
| 192 | end | |
| 193 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.