Class: ChangeHealthcare::Report

Inherits:
BaseApiObject show all
Defined in:
lib/change_healthcare/report.rb

Overview

Not a object on the API

Class Method Summary collapse

Methods inherited from BaseApiObject

attributes, chc_object_name, configuration, #initialize

Constructor Details

This class inherits a constructor from ChangeHealthcare::BaseApiObject

Class Method Details

.download_documentObject

Needs to be chained through session to previous call



114
115
116
117
118
119
120
# File 'lib/change_healthcare/report.rb', line 114

def self.download_document
  params = {
    "actionCommand" => "DownloadFile",
    "fdcuserid" => configuration.user_id
  }
  return "#{lab_portal_url}?#{params.to_query}"
end

.download_reports(params) ⇒ Object

params = {

          "reportTypes" => "LABRES",
          "EMR" => "y",
          "autoPrint" => "true",
          "batchDownload" => "true",
          "CreationDateFrom" => "03/01/2014",
          "CreationDateTo" => "03/08/2014",
}

yields a hash with all the file data



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/change_healthcare/report.rb', line 14

def self.download_reports(params)
  raise "Block needed to handle results" unless block_given?
  r1 = RestClient.get(search_downloadable_reports(params))
  cookies = r1.cookies

  loop do
    r2 = RestClient.get(number_of_files_to_download, cookies: cookies)
    #cookies = r2.cookies

    files_to_dowload_data = r2.body.match("<--BEGIN NUMBER OF DOCS>(?<data>.*)<--END NUMBER OF DOCS>")[:data]
    number, error_code, report_unique_id, _ = files_to_dowload_data.split(";")
    number = number.to_i

    break if number == -1

    i=0
    while i < number do
      r3 = RestClient.get(retrieve_document_information, cookies: cookies)
      doc_info = r3.body
      doc_data = r3.body.match("<--BEGIN FILE INFO>(?<data>.*)<--END FILE INFO>")[:data]

      sponsor_name, report_type, receiving_client_id,
      , document_unique_id, mime_type,
      special, request_or_service_date, sponsor_code,
      caregiver_id, , first_name, last_name, report_service_date,
      practice_id, report_subject, report_status = doc_data.split(";")

      r4 = RestClient.get(download_document, cookies: cookies)
      doc_content = r4.body

      yield({
              report_unique_id: report_unique_id,
              document_unique_id: document_unique_id,
              last_name: last_name,
              first_name: first_name,
              sponsor_name: sponsor_name,
              report_type: report_type,
              receiving_client_id: receiving_client_id,
              account_no_last_name_first_name: ,
              mime_type: mime_type,
              special: special,
              request_or_service_date: request_or_service_date,
              sponsor_code: sponsor_code,
              caregiver_id: caregiver_id,
              account: ,
              report_service_date: report_service_date,
              practice_id: practice_id,
              report_subject: report_subject,
              report_status: report_status,
              doc_content: doc_content,
              cookies: cookies
            })

    i+=1
    end
  end
end

.mark_as_downloadedObject

Needs to be chained through session to previous call



124
125
126
127
128
129
130
# File 'lib/change_healthcare/report.rb', line 124

def self.mark_as_downloaded
  params = {
    "actionCommand" => "MarkAsDownloaded",
    "fdcuserid" => configuration.user_id
  }
  return "#{lab_portal_url}?#{params.to_query}"
end

.number_of_files_to_downloadObject

Needs to be chained through session to previous call



95
96
97
98
99
100
101
102
# File 'lib/change_healthcare/report.rb', line 95

def self.number_of_files_to_download
  params = {
    "actionCommand" => "NextFile",
    "batchDownload" => "true",
    "fdcuserid" => configuration.user_id
  }
  return "#{lab_portal_url}?#{params.to_query}"
end

.retrieve_document_informationObject

Needs to be chained through session to previous call



105
106
107
108
109
110
111
# File 'lib/change_healthcare/report.rb', line 105

def self.retrieve_document_information
  params = {
    "actionCommand" => "GetFileInfo",
    "fdcuserid" => configuration.user_id
  }
  return "#{lab_portal_url}?#{params.to_query}"
end

.search_downloadable_reports(params) ⇒ Object

params = {

          "reportTypes" => "LABRES",
          "EMR" => "y",
          "autoPrint" => "true",
          "batchDownload" => "true",
          "CreationDateFrom" => "03/01/2014",
          "CreationDateTo" => "03/08/2014",
}


80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/change_healthcare/report.rb', line 80

def self.search_downloadable_reports(params)
  base = {
    "userid" => configuration.user_id,
    "PW" => configuration.password,
    "hdnBusiness" => configuration.facility,
    "apiLogin" => "true",
    "target" => "jsp/lab/results/FDC.jsp",
    "actionCommand" => "startDownload"
  }
  params.merge!(base)

  return "#{configuration.portal_url}?#{params.to_query}"
end