Module: AllscriptsApi::NamedMagicMethods

Included in:
Client
Defined in:
lib/allscripts_api/named_magic_methods.rb

Overview

A collection of named convenience methods that map to Allscripts magic actions. These methods are included in ‘AllscriptsApi::Client` and can be accessed from instances of that class.

Instance Method Summary collapse

Instance Method Details

#get_ccda(patient_id, encounter_id, org_id = nil, app_group = nil, referral_text = nil, site_id = nil, document_type = "CCDACCD") ⇒ String, AllscriptsApi::MagicError

gets the CCDA documents for the specified patient and encounter

uses the organization for the specified user CCDACCD (Default) - Returns the Continuity of Care Document. This is the default behavior if nothing is passed in. CCDASOC - Returns the Summary of Care Document CCDACS - Returns the Clinical Summary Document (Visit Summary).

Parameters:

  • patient_id (String)

    patient id

  • encounter_id (String)

    encounter id from which to generate the CCDA

  • org_id (String) (defaults to: nil)

    specifies the organization, by default Unity

  • app_group (String) (defaults to: nil)

    defaults to “TouchWorks”

  • referral_text (String) (defaults to: nil)

    contents of ReferralText are appended

  • site_id (String) (defaults to: nil)

    site id

  • document_type (String) (defaults to: "CCDACCD")

    document type defaults to CCDACCD,

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/allscripts_api/named_magic_methods.rb', line 40

def get_ccda(patient_id,
             encounter_id,
             org_id = nil,
             app_group = nil,
             referral_text = nil,
             site_id = nil,
             document_type = "CCDACCD")
  params =
    MagicParams.format(
      user_id: @allscripts_username,
      patient_id: patient_id,
      parameter1: encounter_id,
      parameter2: org_id,
      parameter3: app_group,
      parameter4: referral_text,
      parameter5: site_id,
      parameter6: document_type
    )
  results = magic("GetCCDA", magic_params: params)
  results["getccdainfo"][0]["ccdaxml"]
end

#get_clinical_summary(patient_id, section = nil, encounter_id = nil, verbose = nil) ⇒ String, AllscriptsApi::MagicError

gets data elements of a patient’s history

if no section is specified than all sections wt data are returned list multiple sections by using a pipe-delimited list ex. “Vitals|Alerts” the EncounterID can be acquired with GetEncounterList verbose column will be Y or blank, when Y is provided there will be a piece of XML data that is specific to that element of the patient’s chart

Parameters:

  • patient_id (String)

    patient id

  • section (String) (defaults to: nil)

    section

  • encounter_id (String) (defaults to: nil)

    internal identifier for the encounter

  • verbose (String) (defaults to: nil)

    XMLDetail

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/allscripts_api/named_magic_methods.rb', line 74

def get_clinical_summary(patient_id,
                         section = nil,
                         encounter_id = nil,
                         verbose = nil)
  params =
    MagicParams.format(
      user_id: @allscripts_username,
      patient_id: patient_id,
      parameter1: section,
      parameter2: encounter_id,
      parameter3: verbose
    )
  results = magic("GetClinicalSummary", magic_params: params)
  results["getclinicalsummaryinfo"]
end

#get_dictionary(dictionary_name) ⇒ Array<Hash>, ...

a wrapper around GetDictionary, which returnsentries from a specific dictionary.

a “TableName” value from ‘get_list_of_dictionaries` an empty array, or an error

Parameters:

  • dictionary_name (String)

    the name of the desired dictionary,

Returns:

  • (Array<Hash>, Array, MagicError)

    a list dictionary entries,



171
172
173
174
175
176
177
178
# File 'lib/allscripts_api/named_magic_methods.rb', line 171

def get_dictionary(dictionary_name)
  params = MagicParams.format(
    user_id: @allscripts_username,
    parameter1: dictionary_name
  )
  results = magic("GetDictionary", magic_params: params)
  results["getdictionaryinfo"]
end

#get_list_of_dictionariesArray<Hash>, ...

a wrapper around GetListOfDictionaries, which returns list of all dictionaries

an empty array, or an error

Returns:

  • (Array<Hash>, Array, MagicError)

    a list of found dictionaries,



158
159
160
161
162
# File 'lib/allscripts_api/named_magic_methods.rb', line 158

def get_list_of_dictionaries
  params = MagicParams.format(user_id: @allscripts_username)
  results = magic("GetListOfDictionaries", magic_params: params)
  results["getlistofdictionariesinfo"]
end

#get_patient(patient_id, patient_number = nil) ⇒ String, AllscriptsApi::MagicError

gets patient’s demographic info, insurance, guarantor, and PCP info

Parameters:

  • patient_id (String)

    patient id

  • patient_number (String) (defaults to: nil)

    PM patient number

Returns:



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/allscripts_api/named_magic_methods.rb', line 95

def get_patient(patient_id,
                patient_number = nil)
  params =
    MagicParams.format(
      user_id: @allscripts_username,
      patient_id: patient_id,
      parameter1: patient_number
    )
  results = magic("GetPatient", magic_params: params)
  results["getpatientinfo"]
end

#get_patient_problems(patient_id, show_by_encounter = "N", assessed = nil, encounter_id = nil, filter_on_id = nil, display_in_progress = nil) ⇒ Array<Hash>, ...

a wrapper around GetPatientProblems

an empty array, or an error

Parameters:

  • patient_id (String)

    patient id

  • show_by_encounter (String) (defaults to: "N")

    Y or N (defaults to ‘N`)

  • assessed (String) (defaults to: nil)
  • encounter_id (String) (defaults to: nil)

    id for a specific patient encounter

  • filter_on_id (String) (defaults to: nil)
  • display_in_progress (String) (defaults to: nil)

Returns:

  • (Array<Hash>, Array, MagicError)

    a list of found problems,



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/allscripts_api/named_magic_methods.rb', line 117

def get_patient_problems(patient_id,
                         show_by_encounter = "N",
                         assessed = nil,
                         encounter_id = nil,
                         filter_on_id = nil,
                         display_in_progress = nil)
  params = MagicParams.format(
    user_id: @allscripts_username,
    patient_id: patient_id,
    parameter1: show_by_encounter,
    parameter2: assessed,
    parameter3: encounter_id,
    parameter4: filter_on_id,
    parameter5: display_in_progress
  )
  results = magic("GetPatientProblems", magic_params: params)
  results["getpatientproblemsinfo"]
end

#get_schedule(start_date, end_date) ⇒ Array<Hash>, ...

a wrapper around GetSchedule, returns appointments scheduled under the the user for a given date range

an empty array, or an error

Parameters:

  • start_date (Date)

    start date inclusive

  • end_date (Date)

    end date inclusive

Returns:

  • (Array<Hash>, Array, MagicError)

    a list of scheduled appointments,



143
144
145
146
147
148
149
150
151
# File 'lib/allscripts_api/named_magic_methods.rb', line 143

def get_schedule(start_date, end_date)
  params =
    MagicParams.format(
      user_id: @allscripts_username,
      parameter1: format_date_range(start_date, end_date)
    )
  results = magic("GetSchedule", magic_params: params)
  results["getscheduleinfo"]
end

#search_patients(search_string) ⇒ Array<Hash>, ...

a wrapper around SearchPatients

partial address, or other PHI an empty array, or an error

Parameters:

  • search_string (String)

    may be a name, birthdate

Returns:

  • (Array<Hash>, Array, MagicError)

    a list of found patients,



15
16
17
18
19
20
21
22
23
# File 'lib/allscripts_api/named_magic_methods.rb', line 15

def search_patients(search_string)
  params =
    MagicParams.format(
      user_id: @allscripts_username,
      parameter1: search_string
    )
  results = magic("SearchPatients", magic_params: params)
  results["searchpatientsinfo"]
end