Clinical trials viewer downloads and parses information from clinicaltrials.gov at the time of search to populate the graph of clinical trials. FDA information is updated weekly from the Drugs@FDA dataset and the FDA postmarketing commitment data set.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

613 lines
22 KiB

  1. <?php
  2. $ctviewer = ctv_get_ctviewer_for_address ( $_GET['address'] );
  3. $firststart = ctv_get_first_start_for_address ( $_GET['address'], $ctviewer );
  4. $lastend = ctv_get_last_end_for_address ( $_GET['address'], $ctviewer );
  5. $viewerwidth = ctv_get_width_of_display ($firststart, $lastend);
  6. $ctgtrials = ctv_get_trials_for_address ( $_GET['address'] );
  7. $fdaapps = ctv_get_applications_for_query ( $ctviewer['query'] );
  8. if ( count ($fdaapps) > 0 ) {
  9. $fdaproducts = ctv_get_apps_and_products_for_query ($ctviewer['query']);
  10. $pmcs = ctv_get_apps_and_pmcs_for_query ($ctviewer['query']);
  11. $fdasubs = ctv_get_apps_and_subs_for_query ( $ctviewer['query'] );
  12. $fdadocs = ctv_get_apps_and_docs_for_query ( $ctviewer['query'] );
  13. }
  14. $devices = ctv_get_devices_for_query ($ctviewer['query']);
  15. // echo "devices: [" . count($devices) . "]";
  16. ?><div style="position: fixed; margin-top: 30px; z-index: 700;">
  17. <div class="ctvSticky">
  18. <h1><a href="<?php echo SITE_URL; echo $ctviewer['address']; ?>/">Search term: <?php echo urldecode ($ctviewer['query']); ?></a></h1>
  19. <?php
  20. if (! is_null ($ctviewer['indication'])) {
  21. echo "<p>Indication: " . urldecode ($ctviewer['indication']) . "</p>";
  22. }
  23. ?>
  24. <p><?php echo count ( $ctgtrials ); ?> record(s) found on clinicaltrials.gov</p>
  25. <?php if ( count ($fdaapps) > 0 ) { ?>
  26. <p>Expand or flatten:</p>
  27. <div class="btn-group" role="group" aria-label="FDA info">
  28. <button type="button" class="btn btn-primary" onclick="$('.fdaSubmission').toggleClass('fdaSubmissionFlat').toggleClass('fdaSubmissionStaggered');">FDA submissions</button>
  29. <button type="button" class="btn btn-primary" onclick="$('.fdaDocument').toggleClass('fdaDocumentFlat').toggleClass('fdaDocumentStaggered');">FDA docs</button>
  30. <button type="button" class="btn btn-primary" onclick="$('.fdaPMC').toggleClass('fdaPMCFlat').toggleClass('fdaPMCStaggered');">PMCs</button>
  31. </div>
  32. <p>Yellow: FDA submissions; red: FDA documents; cyan: postmarketing commitments (PMCs)</p>
  33. <?php } ?>
  34. <?php if ( count ($devices) > 0 ) { ?>
  35. <div class="btn-group" role="group" aria-label="Medical device PMAs">
  36. <button type="button" class="btn btn-primary" onclick="$('.devicePMA').toggleClass('devicePMAFlat').toggleClass('devicePMAStaggered');">Expand/flatten PMAs</button>
  37. </div>
  38. <p>Yellow: medical device premarketing approvals (PMAs)</p>
  39. <?php } ?>
  40. <label for="sortby">Sort trials by</label>
  41. <div class="btn-group btn-group-sm btn-block" id="sortby" role="group" aria-label="Sort by">
  42. <button type="button" id="ctvSortStartDateButton" class="btn btn-primary" onclick="ctv_sort_trials(event, $(this), 'ctvSortStartDate');"<?php
  43. if ($ctviewer['sort_by'] == "ctvSortStartDate") {
  44. echo " disabled";
  45. }
  46. ?>>
  47. Start
  48. </button>
  49. <button type="button" id="ctvSortEndDateButton" class="btn btn-primary" onclick="ctv_sort_trials(event, $(this), 'ctvSortEndDate');"<?php
  50. if ($ctviewer['sort_by'] == "ctvSortEndDate") {
  51. echo " disabled";
  52. }
  53. ?>>
  54. End
  55. </button>
  56. <button type="button" id="ctvSortPhaseButton" class="btn btn-primary" onclick="ctv_sort_trials(event, $(this), 'ctvSortPhase');"<?php
  57. if ($ctviewer['sort_by'] == "ctvSortPhase") {
  58. echo " disabled";
  59. }
  60. ?>>
  61. Phase
  62. </button>
  63. <button type="button" id="ctvSortFundingButton" class="btn btn-primary" onclick="ctv_sort_trials(event, $(this), 'ctvSortFunding');"<?php
  64. if ($ctviewer['sort_by'] == "ctvSortFunding") {
  65. echo " disabled";
  66. }
  67. ?>>
  68. Funding
  69. </button>
  70. </div>
  71. <!-- <label for="colourby">Colour by</label>
  72. <div class="btn-group btn-group-sm btn-block" id="colourby" role="group" aria-label="Colour by">
  73. <button type="button" class="btn btn-primary" disabled>None</button>
  74. <button type="button" class="btn btn-primary">Phase</button>
  75. <button type="button" class="btn btn-primary">Industry</button>
  76. <button type="button" class="btn btn-primary">Type</button>
  77. <button type="button" class="btn btn-primary">Gender</button>
  78. </div> -->
  79. </div>
  80. <?php if ( count ($fdaapps) > 0 ) { ?>
  81. <div class="ctvSticky" style="position: fixed; overflow-y: scroll; height: 500px;">
  82. <p><?php echo count ($fdaapps); ?> FDA application(s) found for this search term</p>
  83. <table class="table table-dark table-hover table-sm">
  84. <thead>
  85. <th scope="col">#</th>
  86. <th scope="col">Product</th>
  87. <th scope="col">Sponsor</th>
  88. <th scope="col">Events</th>
  89. </thead>
  90. <tbody>
  91. <?php
  92. foreach ($fdaapps as $fdaapp) {
  93. echo "<tr class=\"table-info\">";
  94. echo "<td>" . $fdaapp['ApplType'] . " " . $fdaapp['ApplNo'] . "</td>";
  95. echo "<td>" . $fdaapp['DrugName'] . " (" . $fdaapp['ActiveIngredient'] . ")</td>";
  96. echo "<td>" . $fdaapp['SponsorName'] . "</td>";
  97. echo "<td>" . count (ctv_get_submissions_for_product ($fdaapp['ApplNo'])) . " submissions(s)<br>";
  98. echo count (ctv_get_documents_for_product ($fdaapp['ApplNo'])) . " document(s)</td>";
  99. echo "</tr>";
  100. // $fdaproducts = ctv_get_products_for_application ( $fdaapp['ApplNo'] );
  101. $refstandardfound = 0;
  102. foreach ($fdaproducts as $fdaproduct) {
  103. if ( $fdaproduct['ApplNo'] == $fdaapp['ApplNo'] ) {
  104. echo "<tr><td colspan=\"4\">";
  105. echo $fdaproduct['ApplNo'] . "-" . $fdaproduct['ProductNo'];
  106. if ($fdaproduct['ReferenceStandard'] == 1) {
  107. echo "*";
  108. $refstandardfound++;
  109. }
  110. echo " " . $fdaproduct['Form'] . ", ";
  111. echo $fdaproduct['Strength'] . "<br>";
  112. echo "Marketing status: " . $fdaproduct['MarketingStatusDescription'];
  113. echo "</td></tr>";
  114. }
  115. }
  116. if ($refstandardfound > 0) {
  117. echo "<tr><td colspan=\"4\">Asterisk (*) indicates reference standard</td></tr>";
  118. }
  119. }
  120. ?>
  121. </tbody>
  122. </table>
  123. </div>
  124. <?php } ?>
  125. <?php if ( count ($devices) > 0 ) { ?>
  126. <div class="ctvSticky" style="position: fixed; overflow-y: scroll; height: 500px;">
  127. <p><?php echo count ($devices); ?> medical device PMAs found for this search term</p>
  128. <table class="table table-dark table-hover table-sm">
  129. <thead>
  130. <th scope="col">#</th>
  131. <th scope="col">Device name (trade name)</th>
  132. <th scope="col">Applicant</th>
  133. <th scope="col">Decision code</th>
  134. </thead>
  135. <tbody>
  136. <?php
  137. foreach ($devices as $device) {
  138. echo "<tr>";
  139. echo "<td>" . $device['PMANUMBER'];
  140. if ($device['SUPPLEMENTNUMBER'] != '') {
  141. echo "-" . $device['SUPPLEMENTNUMBER'];
  142. }
  143. echo "</td>";
  144. echo "<td>" . $device['GENERICNAME'] . " (" . $device['TRADENAME'] . ")</td>";
  145. echo "<td>" . $device['APPLICANT'] . "</td>";
  146. echo "<td>" . $device['DECISIONCODE'] . " (" . $device['DECISIONDATE'] . ")</td>";
  147. echo "</tr>";
  148. }
  149. ?>
  150. </tbody>
  151. </table>
  152. </div>
  153. <?php } ?>
  154. </div>
  155. <div style="position: fixed; margin-top: 30px; z-index: 700; right: 10px;">
  156. <?php
  157. // for each trial, put a hidden div with its details
  158. foreach ( $ctgtrials as $trial ) {
  159. ?><div class="ctvSticky ctvTrialDetails ctvHidden" id="ctvDetails-<?php echo $trial['NCT_Number']; ?>">
  160. <ul class="nav nav-pill nav-fill" style="margin-bottom: 10px;">
  161. <li class="nav-item">
  162. <a class="nav-link" href="#" onclick="event.preventDefault();$('#ctvTrial-<?php echo $trial['NCT_Number']; ?>').prev().click();">Previous (k)</a>
  163. </li>
  164. <li class="nav-item">
  165. <a class="nav-link" href="#" onclick="event.preventDefault();hide_trial_details();">Close (c)</a>
  166. </li>
  167. <li class="nav-item">
  168. <a class="nav-link" href="#" onclick="event.preventDefault();$('#ctvTrial-<?php echo $trial['NCT_Number']; ?>').next().click();">Next (j)</a>
  169. </li>
  170. </ul>
  171. <h2><a href="<?php echo $trial['URL']; ?>" target="_blank"><?php echo $trial['NCT_Number']; ?></a>: <?php echo $trial['Title']; ?></h2>
  172. <p>Other ID(s): <?php echo $trial['Other_IDs']; ?></p>
  173. <p>Status: <?php echo $trial['Status']; ?></p>
  174. <p>Phase: <?php echo $trial['Phases']; ?></p>
  175. <p>Indications: <?php echo $trial['Conditions']; ?></p>
  176. <p>Age: <?php echo $trial['Age']; ?></p>
  177. <hr>
  178. <p>Start: <?php
  179. if ( ! is_null ($trial['Start_Date']) ) {
  180. if ( substr($trial['Start_Date'],8 ,2) == "00" ) {
  181. echo substr($trial['Start_Date'], 0, 7) . "-01";
  182. } else {
  183. echo $trial['Start_Date'];
  184. }
  185. } else {
  186. echo "NS";
  187. }
  188. ?></p>
  189. <p>Primary completion: <?php
  190. if ( ! is_null($trial['Primary_Completion_Date']) ) {
  191. if ( substr($trial['Primary_Completion_Date'],8 ,2) == "00" ) {
  192. echo substr($trial['Primary_Completion_Date'], 0, 7) . "-01";
  193. } else {
  194. echo $trial['Primary_Completion_Date'];
  195. }
  196. } else {
  197. echo "NS";
  198. }
  199. ?></p>
  200. <p>Completion: <?php
  201. if ( ! is_null($trial['Completion_Date']) ) {
  202. if ( substr($trial['Completion_Date'],8 ,2) == "00" ) {
  203. echo substr($trial['Completion_Date'], 0, 7) . "-01";
  204. } else {
  205. echo $trial['Completion_Date'];
  206. }
  207. } else {
  208. echo "NS";
  209. }
  210. ?></p>
  211. <hr>
  212. <p>Enrolment: <?php echo $trial['Enrollment']; ?></p>
  213. <hr>
  214. <p>Funding: <?php echo $trial['Funded_Bys']; ?></p>
  215. <p>Sponsor: <?php echo $trial['Sponsor_Collaborators']; ?></p>
  216. </div>
  217. <?php
  218. }
  219. // For each FDA application, put a hidden div for each postmarketing commitment
  220. if ( count ($fdaapps) > 0 ) {
  221. foreach ($pmcs as $pmc) {
  222. echo "<div class=\"ctvSticky ctvTrialDetails ctvHidden\" id=\"ctvDetails-PMC" . $pmc['CMT_ID'] . "\">";
  223. echo "<a href=\"#\" onclick=\"event.preventDefault();hide_trial_details();\" style=\"margin: 0 1px 4px 10px; float: right;\">[Close]</a>";
  224. echo "<h2>";
  225. if ( $pmc['SUBPART_FLAG'] == "" ) {
  226. echo "Postmarketing commitment ";
  227. } else {
  228. echo "Postmarketing requirement ";
  229. }
  230. echo $pmc['CMT_ID'] . "-" . $pmc['CMT_NUMBER'] . " [" . $fdaapp['ApplNo'] . "]</h2>";
  231. echo "<p>Supplement number: " . $pmc['CMT_DOC_TYPE'] . "-" . $pmc['CMT_DOC_TYPE_NO'] . "</p>";
  232. if ( $pmc['SUBPART_FLAG'] != "" ) {
  233. switch ($pmc['SUBPART_FLAG']) {
  234. case "H":
  235. echo "<p>Required under: <a href=\"http://www.fda.gov/Drugs/GuidanceComplianceRegulatoryInformation/Post-marketingPhaseIVCommitments/ucm070766.htm#q13\" target=\"_blank\">Accelerated approval</a></p>";
  236. break;
  237. case "F":
  238. echo "<p>Required under: <a href=\"http://www.fda.gov/Drugs/GuidanceComplianceRegulatoryInformation/Post-marketingPhaseIVCommitments/ucm070766.htm#q16\" target=\"_blank\">FDAAA section 505(o)(3)</a></p>";
  239. break;
  240. case "P":
  241. echo "<p>Required under: <a href=\"http://www.fda.gov/Drugs/GuidanceComplianceRegulatoryInformation/Post-marketingPhaseIVCommitments/ucm070766.htm#q15\" target=\"_blank\">Pediatric research equity act</a></p>";
  242. break;
  243. case "E":
  244. echo "<p>Required under: <a href=\"http://www.fda.gov/Drugs/GuidanceComplianceRegulatoryInformation/Post-marketingPhaseIVCommitments/ucm070766.htm#q14\" target=\"_blank\">Animal efficacy rule</a></p>";
  245. break;
  246. }
  247. }
  248. echo "<p>Original projected completion date: " . substr($pmc['ORIG_PROJ_COMPL_DATE'], 0, 10 ) . "</p>";
  249. echo "<p>Status: " . $pmc['Status_Desc'] . "</p>";
  250. if ( $pmc['CMT_STATUS_DESC'] != "" ) {
  251. echo "<p>Status description: ";
  252. echo $pmc['CMT_STATUS_DESC'];
  253. echo "</p>";
  254. }
  255. echo "<p>Description: " . $pmc['CMT_DESC'] . "</p>";
  256. echo "<p>Applicant: " . $pmc['APPLICANT'] . "</p>";
  257. echo "<p>Product: " . $pmc['PRODUCT'] . " [" . $pmc['NDA_NUMBER'] . "]</p>";
  258. echo "</div>";
  259. }
  260. }
  261. // For each medical device PMA, put a hidden div
  262. if ( count ($devices) > 0 ) {
  263. foreach ( $devices as $device ) {
  264. echo "<div class=\"ctvSticky ctvTrialDetails ctvHidden\" id=\"ctvDetails-PMA-" . $device['PMANUMBER'] . "-" . $device['DECISIONDATE'] . "\">";
  265. echo "<a href=\"#\" onclick=\"event.preventDefault();hide_trial_details();\" style=\"margin: 0 1px 4px 10px; float: right;\">[Close]</a>";
  266. echo "<h2>PMA number: " . $device['PMANUMBER'] . "</h2>";
  267. if ( $device['SUPPLEMENTNUMBER'] != '') {
  268. echo "<p>Supplement number: " . $device['SUPPLEMENTNUMBER'] . "</p>";
  269. }
  270. echo "<hr>";
  271. echo "<p>Applicant: " . $device['APPLICANT'] . "</p>";
  272. echo "<p>Generic name: " . $device['GENERICNAME'] . "</p>";
  273. echo "<p>Trade name: " . $device['TRADENAME'] . "</p>";
  274. echo "<p>Product code: " . $device['PRODUCTCODE'] . "</p>";
  275. echo "<p>Review granted: " . $device['REVIEWGRANTEDYN'] . "</p>";
  276. echo "<hr>";
  277. echo "<p>Date received: " . $device['DATERECEIVED'] . "</p>";
  278. echo "<p>Decision date: " . $device['DECISIONDATE'] . "</p>";
  279. echo "<p>Decision code: " . $device['DECISIONCODE'] . "</p>";
  280. echo "<hr>";
  281. echo "<p>" . $device['AOSTATEMENT'] . "</p>";
  282. echo "</div>";
  283. }
  284. }
  285. ?>
  286. </div>
  287. <div style="border: 1px solid #666; min-height: 200px; height: 100%; margin-top: 50px; margin-left: 350px; width: <?php echo $viewerwidth + 350; ?>px; padding-right: 350px;">
  288. <div id="ctvDrugViewGrid" style="padding: 40px 0px 10px 0px; background: url('https://trials.bgcarlisle.com/images/timeline.png'); overflow: visible; width: <?php echo $viewerwidth + 350; ?>px; min-height: 200px;">
  289. <div id="ctvYearMarkerContainer" style="width: <?php echo $viewerwidth; ?>px;">
  290. <?php
  291. // Label the years on the graph
  292. $counter = substr($firststart, 0, 4);
  293. while ($counter <= substr($lastend, 0, 4)) {
  294. echo "<div class=\"ctvYearMarker\">";
  295. echo $counter;
  296. echo "</div>";
  297. $counter++;
  298. }
  299. ?>
  300. </div>
  301. <?php
  302. if ( count ($fdaapps) > 0 ) {
  303. echo "<div class=\"ctvGraphSectionLabel\" style=\"margin-bottom: 70px;\">FDA information</div>";
  304. }
  305. // Put FDA submissions, documents, pmc's and pma's on the graph
  306. if ( count ( $fdaapps ) > 0 ) {
  307. echo "<div id=\"fdaInfoContainer\">";
  308. foreach ($fdaapps as $fdaapp) { // Need to optimize ***
  309. // submissions
  310. // $fdasubs = ctv_get_submissions_for_product ($fdaapp['ApplNo']);
  311. foreach ( $fdasubs as $fdasub ) {
  312. if ( $fdaapp['ApplNo'] == $fdasub['ApplNo'] ) {
  313. $subleftyears = ( substr($fdasub['SubmissionStatusDate'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  314. $subleftmonths = substr($fdasub['SubmissionStatusDate'], 5, 2) * 10 - 10;
  315. $subleft = $subleftyears + $subleftmonths;
  316. echo "<div class=\"fdaSubmission fdaSubmissionFlat\" style=\"left: ";
  317. echo $subleft;
  318. echo "px;\" fdaSortDate=\"";
  319. echo $fdasub['ApplNo'] . "-" . $fdasub['SubmissionStatusDate'] . "-1\">";
  320. echo $fdasub['SubmissionType'] . "-" . $fdasub['SubmissionNo'];
  321. echo " (";
  322. echo $fdasub['ReviewPriority'] . " " . $fdasub['SubmissionClassCode'] . " " . $fdasub['SubmissionClassCodeDescription'];
  323. echo ")<br>";
  324. echo "<span class=\"fdaDocApplNo\">" . $fdasub['ApplNo'] . "</span>";
  325. // echo "-";
  326. // echo "<span class=\"fdaProdNo\">" . $fdasub['ProductNo'] . "</span>";
  327. echo "</div>";
  328. }
  329. }
  330. // documents
  331. // $fdadocs = ctv_get_documents_for_product ($fdaapp['ApplNo']);
  332. foreach ($fdadocs as $fdadoc) {
  333. if ( $fdaapp['ApplNo'] == $fdadoc['ApplNo'] ) {
  334. $docleftyears = ( substr($fdadoc['ApplicationDocsDate'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  335. $docleftmonths = substr($fdadoc['ApplicationDocsDate'], 5, 2) * 10 - 10;
  336. $docleft = $docleftyears + $docleftmonths;
  337. echo "<div class=\"fdaDocument fdaDocumentFlat\" style=\"left: " . $docleft . "px;\" fdaSortDate=\"" . $fdasub['ApplNo'] . "-" . $fdadoc['ApplicationDocsDate'] . "-2\">";
  338. echo "<a href=\"" . $fdadoc['ApplicationDocsURL'] . "\" target=\"_blank\">";
  339. echo $fdadoc['ApplicationDocsType_Lookup_Description'] . " (" . $fdadoc['SubmissionType'] . "-" . $fdadoc['SubmissionNo'] . ")";
  340. echo "</a>";
  341. echo "<br>";
  342. echo "<span class=\"fdaDocApplNo\">" . $fdadoc['ApplNo'] . "</span>";
  343. echo "</div>";
  344. }
  345. }
  346. // postmarketing commitments
  347. // $pmcs = ctv_get_pmc_for_nda ($fdaapp['ApplNo']);
  348. foreach ($pmcs as $pmc) {
  349. if ( $fdaapp['ApplNo'] == $pmc['NDA_NUMBER']) {
  350. $pmcleftyears = ( substr($pmc['ORIG_PROJ_COMPL_DATE'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  351. $pmcleftmonths = substr($pmc['ORIG_PROJ_COMPL_DATE'], 5, 2) * 10 - 10;
  352. $pmcleft = $pmcleftyears + $pmcleftmonths;
  353. echo "<div class=\"fdaPMC fdaPMCFlat\" style=\"left: " . $pmcleft . "px;\" fdaSortDate=\"" . $fdaapp['ApplNo'] . "-" . $pmc['ORIG_PROJ_COMPL_DATE'] ."-3\" onclick=\"show_trial_details('PMC" . $pmc['CMT_ID'] . "');\">";
  354. if ( $pmc['SUBPART_FLAG'] == "" ) {
  355. echo "Postmarketing commitment ";
  356. } else {
  357. echo "Postmarketing requirement ";
  358. }
  359. echo $pmc['CMT_ID'] . "-" . $pmc['CMT_NUMBER'] . " / " . $pmc['CMT_DOC_TYPE'] . "-" . $pmc['CMT_DOC_TYPE_NO'] . " (" . $pmc['Status_Desc'] . ")";
  360. echo "<br>";
  361. echo "<span class=\"fdaDocApplNo\">" . $fdaapp['ApplNo'] . "</span>";
  362. echo "</div>";
  363. }
  364. }
  365. }
  366. echo "</div><hr>";
  367. }
  368. if ( count ($devices) > 0 ) {
  369. echo "<div class=\"ctvGraphSectionLabel\" style=\"margin-bottom: 100px;\">Medical device PMAs</div>";
  370. }
  371. if ( count ($devices) > 0 ) {
  372. echo "<div id=\"fdaInfoContainer\">";
  373. foreach ($devices as $device) {
  374. $pmaleftyears = ( substr($device['DECISIONDATE'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  375. $pmaleftmonths = substr($device['DECISIONDATE'], 5, 2) * 10 - 10;
  376. $pmaleft = $pmaleftyears + $pmaleftmonths;
  377. echo "<div class=\"devicePMA devicePMAFlat\" style=\"left: ";
  378. echo $pmaleft;
  379. echo "px;\" fdaSortDate=\"";
  380. echo $device['PMANUMBER'] . "-" . $device['DECISIONDATE'] . "-1\" onclick=\"show_trial_details('PMA-" . $device['PMANUMBER'] . "-" . $device['DECISIONDATE'] . "');\">";
  381. echo $device['PMANUMBER'] . ": ";
  382. echo $device['GENERICNAME'] . " (" . $device['TRADENAME'] . ")<br>";
  383. echo $device['DECISIONCODE'] . " (" . $device['DECISIONDATE'] . ")";
  384. echo "</div>";
  385. }
  386. echo "</div><hr>";
  387. }
  388. ?>
  389. <div class="ctvGraphSectionLabel" style="margin-bottom: 20px;">Trial records from clinicaltrials.gov</div>
  390. <?php
  391. // Now put the trials on the graph
  392. foreach ( $ctgtrials as $trial ) {
  393. // Get the right and left bounds
  394. // There are 6 possible cases, numbered below
  395. if ( ! is_null ($trial['Start_Date']) ) { // There is a start date
  396. if ( ! is_null ($trial['Primary_Completion_Date']) ) { // There is a start date and a primary completion date
  397. // 1. Make left and right bounded by start and primary completion dates
  398. $lmyears = ( substr($trial['Start_Date'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  399. $lmmonths = substr($trial['Start_Date'], 5, 2) * 10 - 10;
  400. $leftmargin = $lmyears + $lmmonths;
  401. $trialwidth = floor ( ( strtotime(substr($trial['Primary_Completion_Date'], 0, 7) . "-01") - strtotime(substr($trial['Start_Date'], 0, 7) . "-01") ) / 60 / 60 / 24 / 365 * 120 );
  402. $noDateInfo = "";
  403. } else { // There is a start date but no primary completion date
  404. if ( ! is_null ($trial['Completion_Date']) ) { // There is a start date and a completion date
  405. // 2. Make left and right bounded by start and completion date
  406. $lmyears = ( substr($trial['Start_Date'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  407. $lmmonths = substr($trial['Start_Date'], 5, 2) * 10 - 10;
  408. $leftmargin = $lmyears + $lmmonths;
  409. $trialwidth = floor ( ( strtotime(substr($trial['Completion_Date'], 0, 7) . "-01") - strtotime(substr($trial['Start_Date'], 0, 7) . "-01") ) / 60 / 60 / 24 / 365 * 120 );
  410. $noDateInfo = "";
  411. } else { // There is a start date, but no completion date of any kind
  412. // 3. Make it fade away to the right
  413. $lmyears = ( substr($trial['Start_Date'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  414. $lmmonths = substr($trial['Start_Date'], 5, 2) * 10 - 10;
  415. $leftmargin = $lmyears + $lmmonths;
  416. $trialwidth = 250;
  417. $noDateInfo = " NoEndDate";
  418. }
  419. }
  420. } else { // No start date
  421. if ( ! is_null ($trial['Primary_Completion_Date']) ) { // No start date, but there is a primary completion date
  422. // 4. Make it fade away to the left
  423. $lmyears = ( substr($trial['Primary_Completion_Date'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  424. $lmmonths = substr($trial['Primary_Completion_Date'], 5, 2) * 10 - 10;
  425. $leftmargin = $lmyears + $lmmonths - 250;
  426. $noDateInfo = " NoStartDate";
  427. } else { // No start date, no primary completion date
  428. if ( ! is_null ($trial['Completion_Date']) ) { // No start date, but there is a completion date
  429. // 5. Make it fade away to the left
  430. $lmyears = ( substr($trial['Completion_Date'], 0, 4) - substr($firststart, 0, 4) ) * 120;
  431. $lmmonths = substr($trial['Completion_Date'], 5, 2) * 10 - 10;
  432. $leftmargin = $lmyears + $lmmonths - 250;
  433. $noDateInfo = " NoStartDate";
  434. } else { // No dates of any kind
  435. // 6. Make it fade away both ways
  436. $leftmargin = 0;
  437. $trialwidth = 250;
  438. $noDateInfo = " NoDates";
  439. }
  440. }
  441. }
  442. // Now you have the left and right bounds
  443. // Get stuff for colouring (to-do!)
  444. echo "<div class=\"ctvTrial" . $noDateInfo . "\" id=\"ctvTrial-" . $trial['NCT_Number'] . "\" style=\"margin-left: " . $leftmargin . "px; width: " . $trialwidth . "px;\" onclick=\"show_trial_details('" . $trial['NCT_Number'] . "');\" ctvSortStartDate=\"" . $trial['Start_Date'] . "\" ctvSortEndDate=\"" . $trial['End_Date'] . "\" ctvSortPhase=\"" . $trial['Phases'] . "-" . $trial['Start_Date'] . "\" ctvSortFunding=\"" . $trial['Funded_Bys'] . "-" . $trial['Start_Date'] . "\">";
  445. echo $trial['NCT_Number'] . " | " . $trial['Phases'] . " | " . $trial['Conditions'];
  446. echo "</div>";
  447. }
  448. ?>
  449. </div>
  450. </div>