Index: src/hg/hgc/hgc.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgc/hgc.c,v
retrieving revision 1.1635
retrieving revision 1.1636
diff -b -B -U 4 -r1.1635 -r1.1636
--- src/hg/hgc/hgc.c	28 May 2010 17:22:18 -0000	1.1635
+++ src/hg/hgc/hgc.c	28 May 2010 21:32:26 -0000	1.1636
@@ -8796,8 +8796,12 @@
 struct sqlConnection *conn = hAllocConn(database);
 char query[256];
 struct sqlResult *sr;
 char **row;
+struct sqlConnection *conn2 = hAllocConn(database);
+char query2[256];
+struct sqlResult *sr2;
+char **row2;
 char *strand={"+"};
 
 printf("<H3>Patient %s </H3>", itemName);
 
@@ -8819,14 +8823,15 @@
     }
 sqlFreeResult(&sr);
 
 /* link to Ensembl DECIPHER Patient View page */
+printf("<B>Patient View: </B>\n");
 printf("For more details of patient %s, click ", itemName);
 printf("<A HREF=\"%s%s\" target=_blank>",
        "https://decipher.sanger.ac.uk/application/patient/", itemName);
 printf("here</A>.<BR><BR>");
 
-/* print position inof */
+/* print position info */
 safef(query, sizeof(query),
       "select chrom, chromStart, chromEnd from decipher where name ='%s'", itemName);
 sr = sqlMustGetResult(conn, query);
 row = sqlNextRow(sr);
@@ -8837,26 +8842,35 @@
 sqlFreeResult(&sr);
 
 /* print UCSC Genes in the reported region */
 safef(query, sizeof(query),
-      "select distinct geneSymbol, kgId, description from decipher d, kgXref x, knownToDecipher t where value ='%s' and t.name=kgId", itemName);
+      "select distinct t.name from knownToDecipher t where value ='%s'", itemName);
 sr = sqlMustGetResult(conn, query);
 row = sqlNextRow(sr);
 if (row != NULL)
     {
     printf("<BR><B>UCSC Gene(s) in this genomic region: </B><UL>");
     while (row != NULL)
     	{
+	safef(query2, sizeof(query2),
+        "select geneSymbol, kgId, description from kgXref where kgId ='%s'", row[0]);
+	sr2 = sqlMustGetResult(conn2, query2);
+	row2 = sqlNextRow(sr2);
+	if (row2 != NULL)
+    	    {
 	printf("<LI>");
-        printf("<A HREF=\"%s%s\" target=_blank>","./hgGene\?hgg_chrom=none&hgg_gene=", row[1]);
-        printf("%s (%s)</A> ", row[0], row[1]);
-	printf(" %s", row[2]);
+            printf("<A HREF=\"%s%s\" target=_blank>","./hgGene\?hgg_chrom=none&hgg_gene=", row2[1]);
+            printf("%s (%s)</A> ", row2[0], row2[1]);
+	    printf(" %s", row2[2]);fflush(stdout);
+	    }
+        sqlFreeResult(&sr2);
 	row = sqlNextRow(sr);
         }
+    sqlFreeResult(&sr);
     printf("</UL>");
     }
-sqlFreeResult(&sr);
 hFreeConn(&conn);
+hFreeConn(&conn2);
 }
 
 void doDecipher(struct trackDb *tdb, char *item, char *itemForUrl)
 /* Put up DECIPHER track info. */

