Class: AllscriptsApi::Documents::Document
- Inherits:
-
Object
- Object
- AllscriptsApi::Documents::Document
- Defined in:
- lib/allscripts_api/documents/document.rb
Overview
A value object wrapped around a Nokogiri::XML::Builder DSL that builds properly formatted XML for OrderingMethods.save_document_image
Constant Summary collapse
- REQUIRED_PARAMS =
rubocop:disable LineLength required parameters for building the XML, omitting any raises MissingRequiredParamsError
%i[bytes_read document_type first_name last_name organization_name owner_code].freeze
Class Method Summary collapse
-
.build_xml(file_name, command = "i", params) ⇒ String
Builder method for returning XML needed to save document images.
Class Method Details
.build_xml(file_name, command = "i", params) ⇒ String
Builder method for returning XML needed to save document images
params may look like the following, all of which are required: on required and optional params rubocop:enable LineLength
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/allscripts_api/documents/document.rb', line 36 def self.build_xml(file_name, command = "i", params) Utilities::Validator.validate_params(REQUIRED_PARAMS, params) encounter_date_time = DateTime.now.strftime("%Y-%m-%d %H:%m:%S") builder = Nokogiri::XML::Builder.new builder.document do # i for insert, e for delete (entered in error), u for update builder.item("name" => "documentCommand", "value" => command) # document_type_de.entrycode value GetDictionary builder.item("name" => "documentType", "value" => params[:document_type]) # file offset of the current chunk to upload # not yet supported by allscripts_api gem builder.item("name" => "offset", "value" => "0") # how many bytes in current chunk builder.item("name" => "bytesRead", "value" => params[:bytes_read]) # false until the last chunk, then call SaveDocumentImage # once more with true builder.item("name" => "bDoneUpload", "value" => params[:b_done_upload] || "false") # empty for first chunk, which will then return the GUID to use for # subsequent calls builder.item("name" => "documentVar", "value" => params[:document_var] || "") # documentid only applies to updates # not yet supported by allscripts_api gem builder.item("name" => "documentID", "value" => "0") # actual file name builder.item("name" => "vendorFileName", "value" => file_name) # Valid encounterID from GetEncounter Set to "0" to create encounter # based on ahsEncounterDDTM value builder.item("name" => "ahsEncounterDTTM", "value" => params[:encounter_time] || encounter_date_time) builder.item("name" => "ahsEncounterID", "value" => params[:encounter_id] || "0") # EntryCode value from GetProvider builder.item("name" => "ownerCode", "value" => params[:owner_code]) # required to ensure the proper patient is identified builder.item("name" => "organizationName", "value" => params[:organization_name]) # required for event table entries, audit builder.item("name" => "patientFirstName", "value" => params[:first_name]) builder.item("name" => "patientLastName", "value" => params[:last_name]) # Indicate how to display in TouchWorks EHR UI: # 1=No Rotation, 2=Rot 90 deg, 3=Rot 180 Deg, 4=Rot 270 Deg builder.item("name" => "Orientation", "value" => params[:orientation] || "1") builder.item("name" => "auditCCDASummary", "value" => "N") end # This is a hack to get around Nokogiri choking on # {Nokogiri::XML::Builder.doc} builder.to_xml.gsub("document>", "doc>") end |