Skip to content

Instantly share code, notes, and snippets.

@jmercedes
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save jmercedes/8758882 to your computer and use it in GitHub Desktop.

Select an option

Save jmercedes/8758882 to your computer and use it in GitHub Desktop.
def create_result
xml ||= open("https://s3.amazonaws.com/bionuclear/154948_Tabla1.xml")
document = Nokogiri::XML(xml)
articles = document.css('ARTICULOS')
# return nil if the user does not exist
user_e = User.find_by(:email => result.email)
#if user is not nil then create a result record where the user email to the node email
if user_e != nil
articles.each do |result|
email = result.css(email).first.content
patient = result.css('nombre_paciente').first.content
age = result.css('edad').first.content
insurance_plan = result.css('Aseguradora').first.content
gender = result.css('Sexo').first.content
Result.create!(where result.email == User.email)
{
patient: patient,
gender: gender,
insurance_plan: insurance_plan,
age: age
}
end
end
else
...
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment