Wednesday, January 29, 2014

Department database design (10) - import publication database





 http://localhost/ubc_surgery_pub/scripts/manage/pubmedimport/index.php
line 354 change
<p>    <label style="padding: 1px 40px 1px 1px;"><input name="autoapprove" type="radio" value="1" checked="checked" />Approve immediately</label>
    <label style="padding: 1px 1px 1px 40px;"><input name="autoapprove" type="radio" value="0" />Don't approve immediately</label></p>

to
<p>    <label style="padding: 1px 40px 1px 1px;display:none;"><input name="autoapprove" type="radio" value="1" checked="checked" />Approve immediately</label>
    <label style="padding: 1px 1px 1px 40px;display:none;"><input name="autoapprove" type="radio" value="0" />Don't approve immediately</label></p>

line 359 change
  $mydepts = getMyDepartments($_SERVER['REMOTE_USER']);
  echo "<p>Choose division to assign data to:
  <select name='chosendept'>";
  foreach($mydepts as $dcode=>$ddept)
    echo "<option value='$dcode'>$ddept[NAME]</option>";
    echo "<option value=0>Unknown</option>";
  echo "</select></p>";

to
  $allpeople = getallpeople();
  echo "<p>Choose a person to assign data to:
  <select name='chosenperson'>";
  echo '<option value=""> --- Choose a person --- </option>';
  foreach($allpeople as $k=>$v)
      echo "\n<option value=\"$k\">$v[LASTNAME],$v[FIRSTNAME]</option>";
  echo "</select></p>";

line 28 change
$chosendept = $_REQUEST['chosendept'];
to
$chosenperson = $_REQUEST['chosenperson'];
if($chosenperson !='')
$chosendept = getdivision($chosenperson);

line 392 add
  global $chosenperson;
line 426 add
 $ret['userlist'][] = ",$chosenperson,";
line 180 change
 $q = "SELECT pubid, url, deptlist FROM PUBLICATIONS WHERE url='" . mysql_real_escape_string($current['url'][0]) . "' LIMIT 1";
        $res = mysql_query($q,connectpubsdb());
        if($res && (mysql_num_rows($res)!=0)){
          $existing = mysql_fetch_assoc($res);
          if(strpos($existing, $current['deptlist'][0])===false)
            mysql_query("UPDATE PUBLICATIONS SET deptlist='"
               . mysql_real_escape_string($existing['deptlist'] . substr($current['deptlist'][0], 1))
               . "' WHERE pubid=$existing[pubid] LIMIT 1", connectpubsdb());
          echo "\n<p>The record with PubMed ID <a href=\"$config[pageshomeurl]manage/?action=edit&amp;pubid=$existing[pubid]\">{$current[url][0]}</a> (<strong><em>"
            . htmlspecialchars($current['title'][0]) . "</em></strong>) is already in the database, so rather than inserting a duplicate, "
            . " the system has associated your department with the existing record.</p>";

to
        $q = "SELECT pubid, url, deptlist, userlist FROM PUBLICATIONS WHERE url='" . mysql_real_escape_string($current['url'][0]) . "' LIMIT 1";
        $res = mysql_query($q,connectpubsdb());
        if($res && (mysql_num_rows($res)!=0)){
          $existing = mysql_fetch_assoc($res);
         
          if(strpos($existing['userlist'], $chosenperson)===false)
            mysql_query("UPDATE PUBLICATIONS SET userlist='"
               . mysql_real_escape_string($existing['userlist'] . "$chosenperson,")
               . "' WHERE pubid=$existing[pubid] LIMIT 1", connectpubsdb());
          echo "\n<p>The record with PubMed ID <a href=\"$config[pageshomeurl]manage/?action=edit&amp;pubid=$existing[pubid]\">{$current[url][0]}</a> (<strong><em>"
            . htmlspecialchars($current['title'][0]) . "</em></strong>) is already in the database, so rather than inserting a duplicate, "
            . " the system has associated your userid with the existing record.</p>";

 line 128 change
  $pmregex1 = '/^(\d+): (.+?)\.'
 
         . ' (.+?)\.'
       
         . '(.+?)\. (\d\d\d\d)(.*?);(.+?):(\w+)-?(\w*?)\;(.*)'
       
         . 'PMID: (\d+)'
       
         . '/s';

to

  $pmregex = '/^(\d+): (.+?)\.'
 
         . ' (.+?)\.'
       
         . '(.+?)[\. \n?](\d\d\d\d)(.*?);(.+?):(\w+)-?(\w*?)[\.\;](.*)'
       
         . '[PMID: \n?](\d+)'
       
         . '/s';

C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\common.php, line 446 add
function getdivision($userid)
{
    $results = mysql_query("SELECT deptid FROM USERS  WHERE userid='$userid'", connectpubsdb());
     return mysql_result($results,0);
}

No comments:

Post a Comment