Skip to content

Commit c9a6fb5

Browse files
various fixes for clinicaltrials
1 parent d6d205e commit c9a6fb5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

clinicaltrials/clinicaltrials.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,11 @@ function parse_dir(){
233233
**/
234234
function process_file($infile) {
235235
$indir = parent::getParameterValue('indir');
236-
$xml = new CXML($indir,basename($infile));
236+
$xml = new CXML($infile);
237237
$this->setCheckPoint('file');
238238
while($xml->Parse("clinical_study") == TRUE) {
239239
$this->setCheckPoint('record');
240240
$this->root = $root = $xml->GetXMLRoot();
241-
242241
$this->nct_id = $nct_id = $this->getString("//id_info/nct_id");
243242
$this->study_id = $study_id = parent::getNamespace()."$nct_id";
244243

@@ -759,7 +758,7 @@ function process_file($infile) {
759758
parent::triplifyString($location_uri,parent::getVoc()."status", $this->getString('//status',$location)).
760759
parent::triplify($study_id,parent::getVoc()."location",$location_uri).
761760
parent::triplify($location_uri, parent::getVoc()."address", $this->makeAddress($address)).
762-
parent::triplify($location_uri, parent::getVoc()."contact", $this->makeContact($contact))
761+
($contact != null?parent::triplify($location_uri, parent::getVoc()."contact", $this->makeContact($contact)):"")
763762
);
764763
if($backups) {
765764
foreach($backups AS $backup) {
@@ -831,11 +830,13 @@ function process_file($infile) {
831830
try{
832831
$links = $root->xpath('//link');
833832
foreach($links AS $i => $link) {
834-
$lid = parent::getRes().md5($this->getString('./url',$link));
833+
$url = $this->getString('./url',$link);
834+
$url = preg_replace("/>.*$/","",$url);
835+
$lid = parent::getRes().md5($url);
835836
parent::addRDF(
836837
parent::describeIndividual($lid, $this->getString('./description',$link), parent::getVoc()."Link").
837838
parent::describeClass(parent::getVoc()."Link","Link").
838-
parent::triplify($lid,parent::getVoc()."url",preg_replace("/>$/","",$this->getString('./url',$link))).
839+
parent::triplify($lid,parent::getVoc()."url",$url).
839840
parent::triplify($study_id,parent::getVoc()."link",$lid)
840841
);
841842
}
@@ -1166,7 +1167,7 @@ function process_file($infile) {
11661167
if(!$et) continue;
11671168
$ev_uri = parent::getVoc().str_replace(" ","-",$ev_label);
11681169

1169-
$categories = array_shift($et->xpath('./category_list'));
1170+
$categories = @array_shift($et->xpath('./category_list'));
11701171
foreach($categories AS $category) {
11711172
$major_title = $this->getString('./title', $category);
11721173
$major_title_uri = parent::getRes().md5($major_title);
@@ -1272,8 +1273,8 @@ public function getDatetimeFromDate($date)
12721273

12731274
public function makeContact($contact)
12741275
{
1275-
if($contact == null) return null;
1276-
$contact_uri = parent::getRes().md5($contact->asXML());
1276+
if($contact == null) return '';
1277+
$contact_uri = parent::getRes().md5($contact->asXML());
12771278
$contact_type_uri = parent::getVoc()."Contact";
12781279
$contact_label = trim($this->getString('//first_name',$contact)." ".$this->getString('//last_name', $contact));
12791280
parent::addRDF(

0 commit comments

Comments
 (0)