Changeset 2178


Ignore:
Timestamp:
Dec 12, 2013, 11:42:30 AM (7 years ago)
Author:
olle
Message:

Refs #550. Overview report updated to show number of patients having a sample type item:

Java servlet SampleReportServlet.java in reggie/src/net/sf/basedb/reggie/servlet/ updated in private method JSONObject createOverviewReport(DbControl dc, JSONObject json, Date startDate, Date endDate, String bloodSampleFilter):

  1. Four new JSON keys are defined for the required sample type information, and the JSON statistics objects are initialized for these keys.
  2. A new HashSet is defined for keeping track of ID's of patients having follow-up blood samples, and is filled with data.
  3. The HashSets keeping track of ID's of patients having different sample types are used to add data to the JSON statistic objects for the new JSON keys.

JSP script samplereportgenerator.jsp in reggie/resources/reports/ updates:

  1. Function goCreate() updated in the section for optional extra tables to add a table for the overview report, created by new function createOverviewPatientWithSampleTable(report).
  2. New function createOverviewPatientWithSampleTable(report) added. It creates the new table using data from JSON object report, calling new function addDataRowsToOverviewPatientWithSampleTable(report, reportTable) to set the main table entries.
  3. New function addDataRowsToOverviewPatientWithSampleTable(report, reportTable) added. It fills the main "patient with sample" table with data from the JSON object report.
Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/reports/samplereportgenerator.jsp

    r2159 r2178  
    477477    else if ('overviewreport' == reportType)
    478478    {
     479      var spacer0 = document.createElement('text');
     480      spacer0.innerHTML = "<BR>";
     481      cellElement.appendChild(spacer0);
    479482      var spacer = document.createElement('text');
    480483      spacer.innerHTML = "<BR>";
     484      cellElement.appendChild(spacer);
     485      // Table with patients having at least one item of different sample types
     486      cellElement.appendChild(spacer);
     487      var patientWithSampleTable = createOverviewPatientWithSampleTable(report);
     488      cellElement.appendChild(patientWithSampleTable);
     489      // Table with patients having different combinations of sample types
    481490      cellElement.appendChild(spacer);
    482491      var patientDetailedTable = createOverviewPatientDetailedTable(report);
     
    10921101      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    10931102      data = getJSONData(sitesCombined, 'consentMissing');
     1103      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     1104    }
     1105    reportTable.appendChild(sitesCombinedRow); 
     1106
     1107    return reportTable;
     1108  }
     1109 
     1110  function createOverviewPatientWithSampleTable(report)
     1111  {
     1112    var reportTable = getReportTable();
     1113    var bloodSampleFilter = report.bloodSampleFilter;
     1114    var sdString = report.beginDate;
     1115    var edString = report.endDate;
     1116    var ldString = report.latestDate;
     1117    var startDate = dateStrToDate(sdString);
     1118    var endDate = dateStrToDate(edString);
     1119    var latestDate = dateStrToDate(ldString);
     1120 
     1121    var headerRow = document.createElement('tr');   
     1122    var subHeaderRow = document.createElement('tr');
     1123    var subHeader2Row = document.createElement('tr');
     1124    var columnHeaderRow = document.createElement('tr');
     1125   
     1126    var numCols = 7;
     1127    var numDecimals = 0;
     1128    var headerText = 'Patients having a sample type item';
     1129    if (bloodSampleFilter != null && bloodSampleFilter != 'none')
     1130    {
     1131      bloodSampleFilterDisplayText = getBloodSampleFilterDisplayText(bloodSampleFilter);
     1132      headerText += ', blood sample type = \'' + bloodSampleFilterDisplayText + '\'';
     1133    }
     1134    var startDateStr = addHyphensToDateString(sdString);
     1135    var endDateStr = addHyphensToDateString(edString);
     1136    var latestDateStr = addHyphensToDateString(ldString);
     1137    headerText += ' (betweeen ' + startDateStr + ' and ' + endDateStr + ')';
     1138    headerText += '\nColumn entries are non-exclusive, i.e. a patient may be represented in several columns';
     1139    headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+3)));
     1140   
     1141    // Subheader
     1142    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader', 3));
     1143   
     1144    subHeaderRow.appendChild(getTableCellElement('Patients', 'reportsubheader'));
     1145    subHeaderRow.appendChild(getTableCellElement('with', 'reportsubheader'));
     1146    subHeaderRow.appendChild(getTableCellElement('with', 'reportsubheader'));
     1147    subHeaderRow.appendChild(getTableCellElement('with', 'reportsubheader'));
     1148    subHeaderRow.appendChild(getTableCellElement('with', 'reportsubheader'));
     1149    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1150    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1151
     1152    // Subheader 2
     1153    subHeader2Row.appendChild(getTableCellElement('', 'reportsubheader', 3));
     1154   
     1155    subHeader2Row.appendChild(getTableCellElement('total', 'reportsubheader'));
     1156    subHeader2Row.appendChild(getTableCellElement('blood', 'reportsubheader'));
     1157    subHeader2Row.appendChild(getTableCellElement('follow-up', 'reportsubheader'));
     1158    subHeader2Row.appendChild(getTableCellElement('specimen(s)', 'reportsubheader'));
     1159    subHeader2Row.appendChild(getTableCellElement('no specimen(s)', 'reportsubheader'));
     1160    subHeader2Row.appendChild(getTableCellElement('', 'reportsubheader'));
     1161    subHeader2Row.appendChild(getTableCellElement('', 'reportsubheader'));
     1162
     1163    // Columnsheader   
     1164    var siteHeader = getTableCellElement('Site', 'reportsubheader');     
     1165    var startDateHeader = getTableCellElement('Start date','reportsubheader');
     1166    var latestDateHeader = getTableCellElement('Latest date','reportsubheader');
     1167    columnHeaderRow.appendChild(siteHeader);
     1168    columnHeaderRow.appendChild(startDateHeader);
     1169    columnHeaderRow.appendChild(latestDateHeader); 
     1170   
     1171    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1172    columnHeaderRow.appendChild(getTableCellElement('sample(s)', 'reportsubheader'));
     1173    columnHeaderRow.appendChild(getTableCellElement('blood s.', 'reportsubheader'));
     1174    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1175    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1176    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1177    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     1178
     1179    // Build table     
     1180    reportTable.appendChild(headerRow);
     1181    reportTable.appendChild(subHeaderRow);
     1182    reportTable.appendChild(subHeader2Row);
     1183    reportTable.appendChild(columnHeaderRow);
     1184         
     1185    // Data rows     
     1186    addDataRowsToOverviewPatientWithSampleTable(report, reportTable);
     1187     
     1188    // Add a row with the combined numbers for all sites for each period
     1189    var sitesCombinedRow = document.createElement('tr');
     1190    sitesCombinedRow.appendChild(getTableCellElement('Sites combined', 'colsummary'));
     1191    sitesCombinedRow.appendChild(getTableCellElement('', 'colsummary', 2));
     1192    // Get combined numbers for all sites for each period
     1193    var noDateKey = 'noDate';
     1194    var sumKey = 'sumKey';
     1195    var statistics = report.statistics;
     1196    // Get values for use in summary section
     1197    numPatientsNoSamples = statistics.patientNoSamples;
     1198    var sitesCombined = statistics.sitesCombinedKey;
     1199    if (sitesCombined != null)
     1200    {
     1201      data = getJSONData(sitesCombined, 'patient');
     1202      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     1203      data = getJSONData(sitesCombined, 'patientWithBloodSample');
     1204      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     1205      data = getJSONData(sitesCombined, 'patientWithFollowUpBloodSample');
     1206      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     1207      data = getJSONData(sitesCombined, 'patientWithSpecimen');
     1208      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     1209      data = getJSONData(sitesCombined, 'patientWithNoSpecimen');
    10941210      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    10951211    }
     
    16681784        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    16691785        data = getJSONData(siteData, 'consentMissing');
     1786        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1787      }
     1788      reportTable.appendChild(tableRow);
     1789    }
     1790  }
     1791
     1792  function addDataRowsToOverviewPatientWithSampleTable(report, reportTable)
     1793  {
     1794    var sites = report.sites;   
     1795    var statistics = report.statistics;
     1796    unknownCreation = statistics.noDate;
     1797    unknownSite = statistics.unknownSite;
     1798    var siteOrderList = report.siteOrderListKey;
     1799    for (var siteOrderIndex in siteOrderList)
     1800    {
     1801      var namePrefix = siteOrderList[siteOrderIndex];   
     1802      if (!sites.hasOwnProperty(namePrefix)) continue;       
     1803      var site = sites[namePrefix];
     1804      var siteName = site.name;       
     1805      var siteStartDate = dateStrToDate(site.startDate);
     1806      var siteStartDateStr = addHyphensToDateString(site.startDate);
     1807     
     1808      var siteData = statistics[namePrefix];     
     1809      var siteLatestDate = siteData['latestDateKey'];
     1810      var siteLatestDateStr = addHyphensToDateString(siteLatestDate);
     1811      var tableRow = document.createElement('tr');
     1812      var tableCol = getTableCellElement(siteName, 'rowtitle');
     1813      tableRow.appendChild(tableCol);
     1814      tableRow.appendChild(getTableCellElement(siteStartDateStr, 'reportdata'));
     1815      tableRow.appendChild(getTableCellElement(siteLatestDateStr, 'reportdata'));
     1816      var noDateKey = 'noDate';
     1817      var sumKey = 'sumKey';
     1818      var totalKey = 'totalKey';
     1819      if (siteData != null)
     1820      {
     1821        data = getJSONData(siteData, 'patient');
     1822        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1823        data = getJSONData(siteData, 'patientWithBloodSample');
     1824        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1825        data = getJSONData(siteData, 'patientWithFollowUpBloodSample');
     1826        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1827        data = getJSONData(siteData, 'patientWithSpecimen');
     1828        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1829        data = getJSONData(siteData, 'patientWithNoSpecimen');
    16701830        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    16711831      }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r2160 r2178  
    976976    String specimenKey = "specimen";
    977977    String noSpecimenKey = "noSpecimen";
     978    String patientWithSpecimenKey = "patientWithSpecimen";
     979    String patientWithNoSpecimenKey = "patientWithNoSpecimen";
     980    String patientWithBloodSampleKey = "patientWithBloodSample";
     981    String patientWithFollowUpBloodSampleKey = "patientWithFollowUpBloodSample";
    978982    String patientBloodSampleOnlyKey = "patientBloodSampleOnly";
    979983    String patientSpecimenOnlyKey = "patientSpecimenOnly";
     
    9971001    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, specimenKey);
    9981002    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, noSpecimenKey);
     1003    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, patientWithSpecimenKey);
     1004    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, patientWithNoSpecimenKey);
     1005    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, patientWithBloodSampleKey);
     1006    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, patientWithFollowUpBloodSampleKey);
    9991007    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, patientBloodSampleOnlyKey);
    10001008    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, patientSpecimenOnlyKey);
     
    10141022    jsonSitesCombined.put(specimenKey, 0);
    10151023    jsonSitesCombined.put(noSpecimenKey, 0);
     1024    jsonSitesCombined.put(patientWithSpecimenKey, 0);
     1025    jsonSitesCombined.put(patientWithNoSpecimenKey, 0);
     1026    jsonSitesCombined.put(patientWithBloodSampleKey, 0);
     1027    jsonSitesCombined.put(patientWithFollowUpBloodSampleKey, 0);
    10161028    jsonSitesCombined.put(patientBloodSampleOnlyKey, 0);
    10171029    jsonSitesCombined.put(patientSpecimenOnlyKey, 0);
     
    10351047    // Set of patient id's for patients with blood samples
    10361048    Set<String> patientsWithBloodSamplesSet = new HashSet<String>();
     1049    // Set of patient id's for patients with follow-up blood samples
     1050    Set<String> patientsWithFollowUpBloodSamplesSet = new HashSet<String>();
    10371051    // Set of patient id's for patients with specimens
    10381052    Set<String> patientsWithSpecimensSet = new HashSet<String>();
     
    11911205              // Add patient to patients with blood samples set
    11921206              patientsWithBloodSamplesSet.add(patientId);
     1207              // Get blood sample annotation
     1208              String bloodSampleType = (String) Annotationtype.BLOOD_SAMPLE.getAnnotationValue(dc, manager, s);
     1209              if (bloodSampleType != null &&
     1210                  (bloodSampleType.equals(BLOOD_FILTER_FOLLOW_UP_06)
     1211                  || bloodSampleType.equals(BLOOD_FILTER_FOLLOW_UP_12)
     1212                  || bloodSampleType.equals(BLOOD_FILTER_FOLLOW_UP_36))
     1213                )
     1214              {
     1215                patientsWithFollowUpBloodSamplesSet.add(patientId);
     1216              }
    11931217            }
    11941218          }
     
    13231347        jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, patientKey);
    13241348        jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, patientKey);
     1349        // Update data for patients having different kinds of samples
     1350        if (patientsWithSpecimensSet.contains(patId))
     1351        {
     1352          // Patient with at least one specimen
     1353          jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, patientWithSpecimenKey);
     1354          jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, patientWithSpecimenKey);
     1355        }
     1356        if (patientsWithNoSpecimensSet.contains(patId))
     1357        {
     1358          // Patient with at least one no specimen
     1359          jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, patientWithNoSpecimenKey);
     1360          jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, patientWithNoSpecimenKey);
     1361        }
     1362        if (patientsWithBloodSamplesSet.contains(patId))
     1363        {
     1364          // Patient with at least one blood sample
     1365          jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, patientWithBloodSampleKey);
     1366          jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, patientWithBloodSampleKey);
     1367        }
     1368        if (patientsWithFollowUpBloodSamplesSet.contains(patId))
     1369        {
     1370          // Patient with at least one follow-up blood sample
     1371          jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, patientWithFollowUpBloodSampleKey);
     1372          jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, patientWithFollowUpBloodSampleKey);
     1373        }
     1374        // Update data for patient records of different kinds
    13251375        if (patientsWithSpecimensSet.contains(patId))
    13261376        {
Note: See TracChangeset for help on using the changeset viewer.