build block to scrape FDA Data
Hello All,
I was excited to start using popfly.
I wanted to create a block to get data fromwww.clinicaltrial.gov
The data is already in xml. The elements are:
ELEMENTclinical_study( required_header, id_info, brief_title,
The most important elements are:
official_title?,
sponsors,brief_summary,why_stopped?,start_date?,end_date?,phase,study_design,primary_outcome*,secondary_outcome*,enrollment?,condition+,lastchanged_date?,Secondary:
detailed_description?,I want to create a block that gets these 13 fields from the site.
Users will be prompted for condition.
I want to be able to return all variables for condition, but the site does not allow this, so I have to run through each option if all is selected.
Is there an easy way to do this?
I hope to be able to map the data via location as well, but that will come later.
Here is what I have so far but I am not sure if I linked the site xml to the fields I want to extract and sort.
// JScript File
Function ClinicalTrailsClass()
{
this.__getLatestPosts = [new ClinicalTrailPost()];}
// Get the posts from ClinicalTrails.gov (aka CT.GOV).
NinerClass.prototype.getLatestPosts =
function(keyword){
// Get the xml for the niner feed.var url = “http://www.clinicaltrial.gov/ct/search?term=" + keyword "&submit=Search”;var xml = environment.getXml(url);// Get the items and items count in the RSS.var items = xml.getElementsByTagName(“item”);var count = items.length;// Create the array holding the results.var result =new Array(count);// Loop over all items.for(var i = 0; i < count; i++){
// Get the values from the item.var title = items[i].getElementsByTagName(“title”)[0] ?items[i].getElementsByTagName(“title”)[0].firstChild.nodeValue : “”;
var pubDate = items[i].getElementsByTagName(“pubDate”)[0] ?items[i].getElementsByTagName(“pubDate”)[0].firstChild.nodeValue : “”;
var link = items[i].getElementsByTagName(“link”)[0] ?items[i].getElementsByTagName(“link”)[0].firstChild.nodeValue : “”;
var creator = items[i].getElementsByTagName(“dc:creator”)[0] ?items[i].getElementsByTagName(“dc:creator”)[0].firstChild.nodeValue : “”;
var description = items[i].selectSingleNode(“description”) ?items[i].selectSingleNode(“description”).firstChild.nodeValue : “”;
// Add the item to the result array.result[i] =
new ClinicalTrailPostt(title, pubDate, link, creator, description);}
return result;}
// This class represents a ClinicalTrail Data entry.
function
NinerPost(title, createdAt, url, creator, description){
this.brief_title = title;this.lastchanged_date = date;this.URL = url;this.Creator = creator;this.Description = description;// Converts the class to a html representation.this.toString =function(){
var html = “”;html += “
” + title + “
”;html += “
by “ + creator + ” at “ + createdAt + “
”;html += “
}
}
<?
xmlversion=“1.0″ encoding=“utf-8″?><
blockclass="ClinicalTrailsClass"><
providerName>ClinicalTrails.gov</providerName><
providerUrl>http://www.clinicaltrial.gov/ct/search?term=Mobic&submit=Search</providerUrl><
providerLogoUrl>http://www.clinicaltrial.gov/html/images/ctgov_logo_ttl.gif</providerLogoUrl><
blockIconUrl>http://www.clinicaltrial.gov/html/images/ctgov_logo_ttl.gif</blockIconUrl><
operations><
operationname="getLatestPosts"><
description>Gets the latest clinical trail posts
</
description><
inputs><
inputname="keyword"required="true"type="int"><
description>Enter a serach item.</description><
defaultValue>Mobic</defaultValue><
constraints /></
input></
inputs><
outputs><
outputisArray="true"type="custom"object="ClinicalTrailPost" /></
outputs></
operation></
operations><
objects><
objectname="ClinicalTrailPost"><
fieldname="brief_title"type="title"isArray="false" /><
fieldname="lastchanged_date"type="date"isArray="false" /><
fieldname="URL"type="url"isArray="false" /><
fieldname="Creator"type="creator"isArray="false" /><
fieldname="Description"type="description"isArray="false" /></
object></
objects></
block>
