Produced by Araxis Merge on 11/16/2017 4:02:22 PM Eastern 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.3.1-release.zip\app\services | via_api.rb | Fri Oct 20 20:13:45 2017 UTC |
| 2 | CUI-CPP-v2.3.1-release.zip\app\services | via_api.rb | Tue Nov 14 16:07:36 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 4 | 342 |
| Changed | 3 | 6 |
| 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 | require_re l 'via_api /**/*.rb' | |
| 2 | ||
| 3 | module VIA _API | |
| 4 | ||
| 5 | # dateti me format used by VI STA when s ending/rec eiving dat etime data | |
| 6 | # (appoi ntment tim es, etc.) | |
| 7 | VISTA_DA TETIME_FOR MAT = '%Y% m%d.%H%M%S ' | |
| 8 | ||
| 9 | # EMR SE RVICE | |
| 10 | VIA_EMR_ WSDL = File. join(ENV[' VIA_API_UR L'], 'EmrS ervice?wsd l') | |
| 11 | VIA_EMR_ ENDPOINT_U RL = File. join(ENV[' VIA_API_UR L'], 'EmrS ervice') | |
| 12 | VIA_EMR_ NAMESPACE = ENV[' VIA_API_RO OT_ENDPOIN T'] | |
| 13 | ||
| 14 | # SCHEDU LING SERVI CE | |
| 15 | VIA_SCHE DULING_WSD L = File.joi n(ENV['VIA _API_URL'] , 'Schedul ingService ?wsdl') | |
| 16 | VIA_SCHE DULING_END POINT_URL = File.joi n(ENV['VIA _API_URL'] , 'Schedul ingService ') | |
| 17 | VIA_SCHE DULING_NAM ESPACE = ENV['VIA _API_ROOT_ ENDPOINT'] | |
| 18 | ||
| 19 | # FINDPA TIENT SERV ICE | |
| 20 | VIA_FIND PATIENT_WS DL = File.jo in(ENV['VI A_API_URL' ], 'FindPa tientServi ce?wsdl') | |
| 21 | VIA_FIND PATIENT_EN DPOINT_URL = File.jo in(ENV['VI A_API_URL' ], 'FindPa tientServi ce') | |
| 22 | VIA_FIND PATIENT_NA MESPACE = ENV['VI A_API_ROOT _ENDPOINT' ] | |
| 23 | ||
| 24 | EMR_CLIE NT = Savon .client( | |
| 25 | # wsdl: VIA_EMR_W SDL, | |
| 26 | endpoin t: VIA_EMR _ENDPOINT_ URL, | |
| 27 | namespa ce: VIA_EM R_NAMESPAC E, | |
| 28 | env_nam espace: :s oapenv, | |
| 29 | namespa ce_identif ier: :ser, | |
| 30 | namespa ces: { | |
| 31 | # NOTE : xmlns:xs d and xmln s:xsi are being adde d by Savon by defaul t which | |
| 32 | # are not present in the actua l request/ response x ml obtaine d using So apUI | |
| 33 | 'xmlns :xsd' => '', | |
| 34 | 'xmlns :xsi' => '', | |
| 35 | 'xmlns :soapenv' => 'http:/ /schemas.x mlsoap.org /soap/enve lope/', | |
| 36 | 'xmlns:ser ' => 'http:/ / DNS . URL /' | |
| 37 | }, | |
| 38 | log: tr ue, | |
| 39 | logger: Rails.log ger, | |
| 40 | pretty_ print_xml: true | |
| 41 | ) | |
| 42 | ||
| 43 | SCHEDULI NG_CLIENT = Savon.cl ient( | |
| 44 | # wsdl: VIA_SCHED ULING_WSDL , | |
| 45 | endpoin t: VIA_SCH EDULING_EN DPOINT_URL , | |
| 46 | namespa ce: VIA_SC HEDULING_N AMESPACE, | |
| 47 | env_nam espace: :s oapenv, | |
| 48 | namespa ce_identif ier: :ser, | |
| 49 | namespa ces: { | |
| 50 | 'xmlns :xsd' => '', | |
| 51 | 'xmlns :xsi' => '', | |
| 52 | 'xmlns :soapenv' => 'http:/ /schemas.x mlsoap.org /soap/enve lope/', | |
| 53 | 'xmlns:ser ' => 'http:/ / DNS . URL /' | |
| 54 | }, | |
| 55 | log: tr ue, | |
| 56 | logger: Rails.log ger, | |
| 57 | pretty_ print_xml: true | |
| 58 | ) | |
| 59 | ||
| 60 | FINDPATI ENT_CLIENT = Savon.c lient( | |
| 61 | # wsdl: VIA_FINDP ATIENT_WSD L, | |
| 62 | endpoin t: VIA_FIN DPATIENT_E NDPOINT_UR L, | |
| 63 | namespa ce: VIA_FI NDPATIENT_ NAMESPACE, | |
| 64 | namespa ces: { | |
| 65 | 'xmlns :xsd' => '', | |
| 66 | 'xmlns :xsi' => '', | |
| 67 | 'xmlns :soapenv' => 'http:/ /schemas.x mlsoap.org /soap/enve lope/', | |
| 68 | 'xmlns:ser ' => 'http:/ / DNS . URL /' | |
| 69 | }, | |
| 70 | env_nam espace: :s oapenv, | |
| 71 | namespa ce_identif ier: :ser, | |
| 72 | log: tr ue, | |
| 73 | logger: Rails.log ger, | |
| 74 | pretty_ print_xml: true | |
| 75 | ) | |
| 76 | ||
| 77 | # Base e rror class for all V IA API err ors. If w e add mult iple VIA A PI excepti on | |
| 78 | # types we can res cue all AP I errors u nder one b ase type. | |
| 79 | class Vi aApiError < RuntimeE rror; end | |
| 80 | ||
| 81 | # Error returned f rom VISTA when messa ges contai n <fault> tags. | |
| 82 | class Vi aApiFaultE rror < Via ApiError; end | |
| 83 | ||
| 84 | # Error returned f rom VISTA when login VIA authen tication c ontains <f ault> tags . | |
| 85 | class Vi aApiAuthen ticationEr ror < ViaA piError; e nd | |
| 86 | ||
| 87 | ||
| 88 | class << self | |
| 89 | ||
| 90 | def lo gin_via_re quest(para ms) | |
| 91 | requ est = {} | |
| 92 | requ est[:siteC ode] = params[:si te_code] | |
| 93 | requ est[:acces sCode] = params[:ac cess_code] | |
| 94 | requ est[:verif yCode] = params[:ve rify_code] | |
| 95 | requ est[:query Bean]= { | |
| 96 | pat ient: { | |
| 97 | lo calSiteId: params[:s ite_code] | |
| 98 | }, | |
| 99 | req uestingApp : ENV['VIA _REQ_APP'] , | |
| 100 | con sumingAppT oken: ENV[ 'VIA_CONS_ APP_TOKEN' ], | |
| 101 | con sumingAppP assword: E NV['VIA_CO NS_APP_PAS S'] | |
| 102 | } | |
| 103 | ||
| 104 | retu rn request | |
| 105 | end | |
| 106 | ||
| 107 | # To c onvert a n oko elemen t to hash while pars ing a xml | |
| 108 | def x2 h(noko_ele ment) | |
| 109 | Hash .from_xml( noko_eleme nt.to_s) | |
| 110 | end | |
| 111 | ||
| 112 | def au thenticate (params) | |
| 113 | ||
| 114 | # NO TE: The du z returned by the lo ginVIA ope ration can be used i nterchange ably withi n | |
| 115 | # the VI A web-serv ices like FindPatien tService, Scheduling Service, E mrService etc. | |
| 116 | ||
| 117 | logi n_via_requ est = EMR_ CLIENT.bui ld_request (:login_v_ i_a, messa ge: login_ via_reques t(params)) .body | |
| 118 | ||
| 119 | # Ad ding 'ser: ' prefix a s necessar y to the x ml element s. | |
| 120 | ||
| 121 | logi n_via_requ est = add_ ser_prefix (login_via _request) | |
| 122 | ||
| 123 | logi n_via_resp onse = EMR _CLIENT.ca ll(:login_ v_i_a, xml : login_vi a_request, soap_acti on: false) .body | |
| 124 | ||
| 125 | # Fo r more com plex XML s tructures, | |
| 126 | # yo u can pass any other object th at is not a Hash and responds to #to_s | |
| 127 | # lo gin_via_re sponse = E MR_CLIENT. call(:logi n_via, mes sage: logi n_via_requ est(params )).body | |
| 128 | faul t_message = login_vi a_response .dig(:logi n_via_resp onse, :use r_to, :fau lt) | |
| 129 | ||
| 130 | if f ault_messa ge.present ? | |
| 131 | ra ise ViaApi Authentica tionError. new(fault_ message) | |
| 132 | end | |
| 133 | ||
| 134 | { | |
| 135 | du z: l ogin_via_r esponse[:l ogin_via_r esponse][: user_to][: duz], | |
| 136 | us er_name: l ogin_via_r esponse[:l ogin_via_r esponse][: user_to][: name], | |
| 137 | si te_id: l ogin_via_r esponse[:l ogin_via_r esponse][: user_to][: site_id] | |
| 138 | } | |
| 139 | ||
| 140 | end # def authen ticate | |
| 141 | ||
| 142 | def va lidate_vis ta_session (vista_ses sion) | |
| 143 | ||
| 144 | if vista_sess ion[:duz]. nil? || | |
| 145 | vista_sess ion[:user_ name].nil? || | |
| 146 | vista_sess ion[:site_ id].nil? | |
| 147 | ra ise ViaApi Authentica tionError. new("Authe ntication needed") | |
| 148 | end | |
| 149 | end | |
| 150 | ||
| 151 | # Conv ert date i n format " YYYYMMDD.H HMMSS" to Ruby Time object. | |
| 152 | # TODO : handle t ime zones in the fut ure. | |
| 153 | def pa rse_vista_ date(via_a pi_date) | |
| 154 | Time .strptime( via_api_da te, VISTA_ DATETIME_F ORMAT) | |
| 155 | end | |
| 156 | ||
| 157 | # Conv ert date f rom Ruby T ime object to "YYYYM MDD.HHMMSS " format. | |
| 158 | # TODO : handle t ime zones in the fut ure. | |
| 159 | def en code_vista _date(date time) | |
| 160 | date time.strft ime(VISTA_ DATETIME_F ORMAT) | |
| 161 | end | |
| 162 | ||
| 163 | def ad d_ser_pref ix(xml_req uest) | |
| 164 | node s = ["//ac cessCode", "//verify Code", "// siteCode", "//queryB ean", "//a ppointment "] | |
| 165 | doc = Nokogiri ::XML(xml_ request) | |
| 166 | node s.each do |node| | |
| 167 | un less doc.a t_xpath(no de).nil? | |
| 168 | doc.at_xpa th(node).n ame = "ser :" + doc.a t_xpath(no de).name | |
| 169 | en d | |
| 170 | end | |
| 171 | retu rn doc.to_ xml | |
| 172 | end | |
| 173 | end # cl ass << sel f | |
| 174 | end # modu le VIA_API |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.