Last active
August 29, 2015 13:55
-
-
Save jmercedes/8758882 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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