You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code works on a mac but I'm getting a lot of failures when running in RedHat 8. Are there any dependencies I need to consider when running on linux?
app/models/concerns/attachable.rb
moduleAttachableextendActiveSupport::Concernincludeddomount_uploader:attachment,AttachmentUploaderendclass_methodsdodefcreate_from_attachment(attachment)patient_data=read_data_from_file(attachment)mrn,_encounter_number=patient_data[:mrn].split('-')patient=Patient.find_by_mrn(mrn)patient ||= create_patient(patient_data)new_attacheble=find_by(encounter_number: patient_data[:mrn])new_attacheble ||= newnew_attacheble.patient=patientnew_attacheble.clinical_history=patient_data[:history]new_attacheble.report_date=patient_data[:report_date]new_attacheble.admission_date=patient_data[:report_date]new_attacheble.meg_impression=patient_data[:meg_impression]new_attacheble.eeg_results=patient_data[:eeg_results]new_attacheble.encounter_number=patient_data[:mrn]new_attacheble.attachment=attachmentifpatient_data[:referring_physician].present?first_name=patient_data[:referring_physician].split[0]last_name=patient_data[:referring_physician].split[1].split(',').firstreferring_physician=ReferringPhysician.find_by(first_name: first_name,last_name: last_name)new_attacheble.referring_physician_id=referring_physician.idifreferring_physicianendnew_attacheble.savepatient_data[:reported_by].eachdo |reported_by|
name=reported_by.split(',').firstfirst_name=name.split.firstlast_name=name.split.lastuser=User.find_by(user_firstname: first_name,user_lastname: last_name)nextunlessusernew_attacheble.clinical_attendings << userifuser.clinical_attending?new_attacheble.clinical_fellows << userifuser.clinical_fellow?unlessnew_attacheble.saveraise"Error saving new attacheble"elsenew_attacheble.sign(user)endendRails.logger.debug'-----------------New Attacheble-----------------'Rails.logger.debugJSON.pretty_generate(new_attacheble.as_json)new_attachebleendprivatedefcreate_patient(patient_data)patient=Patient.newpatient.first_name=patient_data[:first_name]patient.middle_name=patient_data[:middle_name]patient.last_name=patient_data[:last_name]patient.medical_record_number=patient_data[:mrn].split('-').firstpatient.date_of_birth=patient_data[:patient_dob]patient.gender='Female'ifpatient_data[:history].include?(' female ')patient.gender ||= 'Male'ifpatient_data[:history].include?(' male ')patient.saveRails.logger.debug'-----------------Patient-----------------'Rails.logger.debugJSON.pretty_generate(patient.as_json)patientenddefread_data_from_file(attachment)data=Hash.new('')data[:reported_by]=[]doc=Docx::Document.open(attachment.path)ifdoc.inspect.include?("relationships/image")raise'Attachment contains image'endunlessdoc.paragraphs.any?{ |p| p.text.include?('Patient Name')}raise'Attachment does not contain patient name'endlooking_at_history=falselooking_at_reported_by=falselooking_at_meg_impression=falselooking_at_eeg_results=falselooking_at_meg_results=falsedoc.paragraphs.eachdo |p|
data[:patient_name]=extract_value(p.text)ifp.text.include?('Patient Name')data[:mrn]=extract_value(p.text)ifp.text.include?('MRN')data[:patient_dob]=extract_value(p.text)ifp.text.include?('DOB')data[:report_date]=extract_value(p.text)ifp.text.include?('Date of Exam')data[:referring_physician]=extract_value(p.text)ifp.text.include?('Referring Physician')iflooking_at_historydata[:history]=p.textlooking_at_history=falseendifp.text.include?('INTRODUCTION')looking_at_history=truelooking_at_reported_by=falseendifp.text.include?('MEG RESULTS')looking_at_meg_results=truelooking_at_reported_by=falselooking_at_history=falsenextendifp.text.include?('EEG RESULTS')looking_at_eeg_results=truelooking_at_meg_impression=falselooking_at_reported_by=falselooking_at_history=falsenextendifp.text.include?('MEG AND EEG IMPRESSION')looking_at_meg_impression=truelooking_at_reported_by=falselooking_at_history=falselooking_at_eeg_results=falsenextendifp.text.include?('There is a picture set that is part of this MEG report.')looking_at_meg_impression=falselooking_at_reported_by=falselooking_at_history=falsenextendiflooking_at_reported_bydata[:reported_by] << p.textifp.text.present?endiflooking_at_meg_impressiondata[:meg_impression] << ("\n#{p.text}")ifp.text.present?endiflooking_at_eeg_resultsdata[:eeg_results] << ("\n#{p.text}")ifp.text.present?endiflooking_at_meg_resultsdata[:meg_results] << ("\n#{p.text}")ifp.text.present?endlooking_at_reported_by=trueifp.text.include?('Reported By')endname_parts=data[:patient_name].split(',')first_name_parts=name_parts.first.splitdata[:last_name]=name_parts.first.stripdata[:middle_name]=first_name_parts[1..-1].join(' ')data[:first_name]=first_name_parts.firstdataenddefextract_value(string)string.split(':').last.stripendendend
The error occurs here when the patient has no middle name
Describe the bug
My code works on a mac but I'm getting a lot of failures when running in RedHat 8. Are there any dependencies I need to consider when running on linux?
app/models/concerns/attachable.rb
The error occurs here when the patient has no middle name
I.E Smith, Chris vs Smith, Chris Michael
Expected behavior
A clear and concise description of what you expected to happen.
Environment
docx
gem version: [0.8.0]The text was updated successfully, but these errors were encountered: