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\services | via_api.rb | Thu Dec 21 03:33:17 2017 UTC |
| 2 | CUI-CPP-v2.4.0-source-archive.zip\app\services | via_api.rb | Tue Feb 6 20:07:53 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 300 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | 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 | EMR_CLIE NT = Savon .client( | |
| 20 | # wsdl: VIA_EMR_W SDL, | |
| 21 | endpoin t: VIA_EMR _ENDPOINT_ URL, | |
| 22 | namespa ce: VIA_EM R_NAMESPAC E, | |
| 23 | env_nam espace: :s oapenv, | |
| 24 | namespa ce_identif ier: :ser, | |
| 25 | namespa ces: { | |
| 26 | # NOTE : xmlns:xs d and xmln s:xsi are being adde d by Savon by defaul t which | |
| 27 | # are not present in the actua l request/ response x ml obtaine d using So apUI | |
| 28 | 'xmlns :xsd' => '', | |
| 29 | 'xmlns :xsi' => '', | |
| 30 | 'xmlns :soapenv' => 'http:/ /schemas.x mlsoap.org /soap/enve lope/', | |
| 31 | 'xmlns:ser ' => 'http:/ / DNS . URL /' | |
| 32 | }, | |
| 33 | log: tr ue, | |
| 34 | logger: Rails.log ger, | |
| 35 | pretty_ print_xml: true | |
| 36 | ) | |
| 37 | ||
| 38 | SCHEDULI NG_CLIENT = Savon.cl ient( | |
| 39 | # wsdl: VIA_SCHED ULING_WSDL , | |
| 40 | endpoin t: VIA_SCH EDULING_EN DPOINT_URL , | |
| 41 | namespa ce: VIA_SC HEDULING_N AMESPACE, | |
| 42 | env_nam espace: :s oapenv, | |
| 43 | namespa ce_identif ier: :ser, | |
| 44 | namespa ces: { | |
| 45 | 'xmlns :xsd' => '', | |
| 46 | 'xmlns :xsi' => '', | |
| 47 | 'xmlns :soapenv' => 'http:/ /schemas.x mlsoap.org /soap/enve lope/', | |
| 48 | 'xmlns:ser ' => 'http:/ / DNS . URL /' | |
| 49 | }, | |
| 50 | log: tr ue, | |
| 51 | logger: Rails.log ger, | |
| 52 | pretty_ print_xml: true | |
| 53 | ) | |
| 54 | ||
| 55 | # Base e rror class for all V IA API err ors. If w e add mult iple VIA A PI excepti on | |
| 56 | # types we can res cue all AP I errors u nder one b ase type. | |
| 57 | class Vi aApiError < RuntimeE rror; end | |
| 58 | ||
| 59 | # Error returned f rom VISTA when messa ges contai n <fault> tags. | |
| 60 | class Vi aApiFaultE rror < Via ApiError; end | |
| 61 | ||
| 62 | # Error returned f rom VISTA when login VIA authen tication c ontains <f ault> tags . | |
| 63 | class Vi aApiAuthen ticationEr ror < ViaA piError; e nd | |
| 64 | ||
| 65 | ||
| 66 | class << self | |
| 67 | ||
| 68 | def lo gin_via_re quest(para ms) | |
| 69 | requ est = {} | |
| 70 | requ est[:siteC ode] = params[:si te_code] | |
| 71 | requ est[:acces sCode] = params[:ac cess_code] | |
| 72 | requ est[:verif yCode] = params[:ve rify_code] | |
| 73 | requ est[:query Bean]= { | |
| 74 | pat ient: { | |
| 75 | lo calSiteId: params[:s ite_code] | |
| 76 | }, | |
| 77 | req uestingApp : ENV['VIA _REQ_APP'] , | |
| 78 | con sumingAppT oken: ENV[ 'VIA_CONS_ APP_TOKEN' ], | |
| 79 | con sumingAppP assword: E NV['VIA_CO NS_APP_PAS S'] | |
| 80 | } | |
| 81 | ||
| 82 | retu rn request | |
| 83 | end | |
| 84 | ||
| 85 | # To c onvert a n oko elemen t to hash while pars ing a xml | |
| 86 | def x2 h(noko_ele ment) | |
| 87 | Hash .from_xml( noko_eleme nt.to_s) | |
| 88 | end | |
| 89 | ||
| 90 | def au thenticate (params) | |
| 91 | ||
| 92 | # NO TE: The du z returned by the lo ginVIA ope ration can be used i nterchange ably withi n | |
| 93 | # the VI A web-serv ices like FindPatien tService, Scheduling Service, E mrService etc. | |
| 94 | ||
| 95 | logi n_via_requ est = EMR_ CLIENT.bui ld_request (:login_v_ i_a, messa ge: login_ via_reques t(params)) .body | |
| 96 | ||
| 97 | # Ad ding 'ser: ' prefix a s necessar y to the x ml element s. | |
| 98 | ||
| 99 | logi n_via_requ est = add_ ser_prefix (login_via _request) | |
| 100 | ||
| 101 | logi n_via_resp onse = EMR _CLIENT.ca ll(:login_ v_i_a, xml : login_vi a_request, soap_acti on: false) .body | |
| 102 | ||
| 103 | # Fo r more com plex XML s tructures, | |
| 104 | # yo u can pass any other object th at is not a Hash and responds to #to_s | |
| 105 | # lo gin_via_re sponse = E MR_CLIENT. call(:logi n_via, mes sage: logi n_via_requ est(params )).body | |
| 106 | faul t_message = login_vi a_response .dig(:logi n_via_resp onse, :use r_to, :fau lt, :messa ge) | |
| 107 | ||
| 108 | if f ault_messa ge.present ? | |
| 109 | ra ise ViaApi Authentica tionError. new(fault_ message) | |
| 110 | end | |
| 111 | ||
| 112 | { | |
| 113 | du z: l ogin_via_r esponse[:l ogin_via_r esponse][: user_to][: duz], | |
| 114 | us er_name: l ogin_via_r esponse[:l ogin_via_r esponse][: user_to][: name], | |
| 115 | si te_id: l ogin_via_r esponse[:l ogin_via_r esponse][: user_to][: site_id] | |
| 116 | } | |
| 117 | ||
| 118 | end # def authen ticate | |
| 119 | ||
| 120 | def va lidate_vis ta_session (vista_ses sion) | |
| 121 | ||
| 122 | if vista_sess ion[:duz]. nil? || | |
| 123 | vista_sess ion[:user_ name].nil? || | |
| 124 | vista_sess ion[:site_ id].nil? | |
| 125 | ra ise ViaApi Authentica tionError. new("Authe ntication needed") | |
| 126 | end | |
| 127 | end | |
| 128 | ||
| 129 | # Conv ert date i n format " YYYYMMDD.H HMMSS" to Ruby Time object. | |
| 130 | # TODO : handle t ime zones in the fut ure. | |
| 131 | def pa rse_vista_ date(via_a pi_date) | |
| 132 | Time .strptime( via_api_da te, VISTA_ DATETIME_F ORMAT) | |
| 133 | end | |
| 134 | ||
| 135 | # Conv ert date f rom Ruby T ime object to "YYYYM MDD.HHMMSS " format. | |
| 136 | # TODO : handle t ime zones in the fut ure. | |
| 137 | def en code_vista _date(date time) | |
| 138 | date time.strft ime(VISTA_ DATETIME_F ORMAT) | |
| 139 | end | |
| 140 | ||
| 141 | def ad d_ser_pref ix(xml_req uest) | |
| 142 | node s = ["//ac cessCode", "//verify Code", "// siteCode", "//queryB ean", "//a ppointment "] | |
| 143 | doc = Nokogiri ::XML(xml_ request) | |
| 144 | node s.each do |node| | |
| 145 | un less doc.a t_xpath(no de).nil? | |
| 146 | doc.at_xpa th(node).n ame = "ser :" + doc.a t_xpath(no de).name | |
| 147 | en d | |
| 148 | end | |
| 149 | retu rn doc.to_ xml | |
| 150 | end | |
| 151 | end # cl ass << sel f | |
| 152 | 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.