/* clinical - do Clinical section. */
#include "common.h"
#include "hash.h"
#include "linefile.h"
#include "dystring.h"
#include "cheapcgi.h"
#include "spDb.h"
#include "gsidSubj.h"
#include "hdb.h"
#include "net.h"
static boolean clinicalExists(struct section *section,
struct sqlConnection *conn, char *subjId)
/* Return TRUE if clinicalAll table exists and it has an entry with the gene symbol */
{
if (sqlTableExists(conn, "gsidClinicRec") == TRUE)
{
return(TRUE);
}
return(FALSE);
}
static void clinicalPrint(struct section *section,
struct sqlConnection *conn, char *subjId)
/* Print out Clinical section. */
{
char bigQuery[2000];
struct sqlResult *sr;
char **row;
char *specimenId, *labCode, *daysCollection, *hivQuan, *cd4Count;
char *naString = strdup("N/A");
printf("
\n");
printf("
\n");
printf("Days After Estimated Infection (DAEI)* | \n");
printf("HIV-1 RNA copies/mL | \n");
printf("CD4 cells/microliter | \n");
printf("
\n");
/* complex query to ensure date is correctly sorted */
safef(bigQuery, sizeof(bigQuery),
"select specimenId, labCode, daysCollection, hivQuan, cd4Count from gsidClinicRec where subjId='%s' order by daysCollection",
subjId);
sr = sqlMustGetResult(conn, bigQuery);
row = sqlNextRow(sr);
/* special processing if this subject does not have any clinical data */
if (row == NULL)
{
/*specimenId = row[0];
labCode = row[1];
daysCollection = row[2];
hivQuan = row[3];
cd4Count = row[4];
*/
daysCollection = naString;
hivQuan = naString;
cd4Count = naString;
printf("");
printf("%s | \n", daysCollection);
printf("%s | \n", hivQuan);
printf("%s | \n", cd4Count);
printf("
");
}
while (row != NULL)
{
specimenId = row[0];
labCode = row[1];
daysCollection = row[2];
hivQuan = row[3];
cd4Count = row[4];
if (daysCollection == NULL) daysCollection = naString;
if (hivQuan == NULL) hivQuan = naString;
if (cd4Count == NULL) cd4Count = naString;
printf("");
printf("%s | \n", daysCollection);
//printf("%s | \n", cd4Count);
if (sameWord(hivQuan, "1000000"))
{
printf("> 1000000 | \n");
}
else
{
if (sameWord(hivQuan, "200"))
{
printf("< 400 | \n");
}
else
{
printf("%s | \n", hivQuan);
}
}
if (sameWord(cd4Count, "0"))
{
printf("N/A | \n");
}
else
{
printf("%s | \n", cd4Count);
}
printf("
");
row = sqlNextRow(sr);
}
sqlFreeResult(&sr);
printf("
");
printf("
* Estimated Study Day of Infection (ESDI), ");
printf("click here ");
printf(" for further explanation.\n");
printf("
* Days After Estimated Infection (DAEI), ");
printf("click here ");
printf(" for further explanation.\n");
return;
}
struct section *clinicalSection(struct sqlConnection *conn,
struct hash *sectionRa)
/* Create clinical section. */
{
struct section *section = sectionNew(sectionRa, "clinical");
section->exists = clinicalExists;
section->print = clinicalPrint;
return section;
}