Changeset 1926


Ignore:
Timestamp:
Apr 12, 2013, 9:14:18 AM (10 years ago)
Author:
olle
Message:

Fixes #484. Refs #426. Consent count report updated with an initial summary table with columns "Yes", "No", and "Not asked". Consents with unknown date are treated as if belonging to the selected time period for this table.

Servlet SampleReportServlet in reggie/src/net/sf/basedb/reggie/servlet/ updates:

  • Private method JSONObject createConsentCountReport(DbControl dc, JSONObject json, Date startDate, Date endDate) updated to assign a list of JSON keys to each consent item (in some cases, the list may still consist of a single key), and to use updated JSON key names.

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

  • Function goCreate() updated to create an initial summary table for the consent count report.
  • Functions createConsentCountReport(report) and addDataRowsToConsentTable(report, reportTable, numDecimals) renamed createConsentCountHasDateTable(report) and addDataRowsToConsentTableHasDate(report, reportTable, numDecimals), respectively.
  • Functions createConsentCountReport(report) and addDataRowsToConsentTable(report, reportTable, numDecimals) updated to create the initial summary table.
  • All functions related to the consent count report updated to use the new JSON key names.
Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

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

    r1923 r1926  
    292292    if ('consentcount' == reportType)
    293293    {
     294      var spacer0 = document.createElement('text');
     295      spacer0.innerHTML = "<BR>";
     296      cellElement.appendChild(spacer0);
    294297      var spacer = document.createElement('text');
    295298      spacer.innerHTML = "<BR>";
     299      cellElement.appendChild(spacer);
     300      // Table with consents in different categories with date, as well as consents with unknown date
     301      cellElement.appendChild(spacer);
     302      var hasDateTable = createConsentCountHasDateTable(report);
     303      cellElement.appendChild(hasDateTable);
     304      // Table with consents in different categories with unknown date, as well as missing consents
    296305      cellElement.appendChild(spacer);
    297306      var unknownDateTable = createConsentCountUnknownDateTable(report);
     
    561570        headerText += '\nLast registration ' + latestDateStr;
    562571    }
    563     headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+5)));
     572    headerText += '\nConsents without date treated as if belonging to selected time period';
     573    headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+3)));
    564574   
    565575    // Subheader   
    566576    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader', 3));
    567577   
    568     subHeaderRow.appendChild(getTableCellElement('Yes', 'reportsubheader'));
    569578    subHeaderRow.appendChild(getTableCellElement('Yes', 'reportsubheader'));
    570579    subHeaderRow.appendChild(getTableCellElement('No', 'reportsubheader'));
    571580    subHeaderRow.appendChild(getTableCellElement('Not asked', 'reportsubheader'));
    572     subHeaderRow.appendChild(getTableCellElement('Unknown date', 'reportsubheader'));
    573581    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader', 2));
    574582
     
    581589    columnHeaderRow.appendChild(latestDateHeader); 
    582590   
    583     columnHeaderRow.appendChild(getTableCellElement('(has PAT#)', 'reportsubheader'));
    584     columnHeaderRow.appendChild(getTableCellElement('(no PAT#)', 'reportsubheader'));
    585     columnHeaderRow.appendChild(getTableCellElement('(has date)', 'reportsubheader'));
    586     columnHeaderRow.appendChild(getTableCellElement('(has date)', 'reportsubheader'));
     591    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     592    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
    587593    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
    588594    columnHeaderRow.appendChild(getTableCellElement('Sum', 'reportsubheader'));
     
    603609    // Get combined numbers for all sites for each period
    604610    var noDateKey = 'noDate';
     611    var sumDateIgnoredKey = 'sumDateIgnoredKey';
     612    var statistics = report.statistics;
     613    var sitesCombined = statistics.sitesCombinedKey;
     614    if (sitesCombined != null)
     615    {
     616      data = getJSONDataWithPercent(sitesCombined, 'yes', sumDateIgnoredKey, numDecimals);
     617      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     618      data = getJSONDataWithPercent(sitesCombined, 'no', sumDateIgnoredKey, numDecimals);
     619      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     620      data = getJSONDataWithPercent(sitesCombined, 'notAsked', sumDateIgnoredKey, numDecimals);
     621      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     622    }
     623    // Add entry with total number of consents with chosen restrictions
     624    data = getJSONData(sitesCombined, sumDateIgnoredKey, 0);
     625    sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     626    // Add entry with total number of consents, regardless of restrictions
     627    var totalKey = 'totalKey';
     628    data = getJSONData(sitesCombined, totalKey, 0);
     629    sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     630    reportTable.appendChild(sitesCombinedRow); 
     631
     632    return reportTable;
     633  }
     634 
     635  function createConsentCountHasDateTable(report)
     636  {
     637    var reportTable = getReportTable();
     638    var sdString = report.beginDate;
     639    var edString = report.endDate;
     640    var ldString = report.latestDate;
     641    var startDate = dateStrToDate(sdString);
     642    var endDate = dateStrToDate(edString);
     643    var latestDate = dateStrToDate(ldString);
     644
     645    var headerRow = document.createElement('tr');   
     646    var subHeaderRow = document.createElement('tr');
     647    var columnHeaderRow = document.createElement('tr');
     648   
     649    var numCols = 5;
     650    var numDecimals = 0;
     651    var headerText = '# Consent forms of different types for cases and blood samples';
     652    var startDateStr = addHyphensToDateString(sdString);
     653    var endDateStr = addHyphensToDateString(edString);
     654    var latestDateStr = addHyphensToDateString(ldString);
     655    headerText += ' (betweeen ' + startDateStr + ' and ' + endDateStr + ')';
     656    if (latestDate != null)
     657    {
     658        headerText += '\nLast registration ' + latestDateStr;
     659    }
     660    headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+5)));
     661   
     662    // Subheader   
     663    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader', 3));
     664   
     665    subHeaderRow.appendChild(getTableCellElement('Yes', 'reportsubheader'));
     666    subHeaderRow.appendChild(getTableCellElement('Yes', 'reportsubheader'));
     667    subHeaderRow.appendChild(getTableCellElement('No', 'reportsubheader'));
     668    subHeaderRow.appendChild(getTableCellElement('Not asked', 'reportsubheader'));
     669    subHeaderRow.appendChild(getTableCellElement('Unknown date', 'reportsubheader'));
     670    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader', 2));
     671
     672    // Columnsheader   
     673    var siteHeader = getTableCellElement('Site', 'reportsubheader');     
     674    var startDateHeader = getTableCellElement('Start date','reportsubheader');
     675    var latestDateHeader = getTableCellElement('Latest date','reportsubheader');
     676    columnHeaderRow.appendChild(siteHeader);
     677    columnHeaderRow.appendChild(startDateHeader);
     678    columnHeaderRow.appendChild(latestDateHeader); 
     679   
     680    columnHeaderRow.appendChild(getTableCellElement('(has PAT#)', 'reportsubheader'));
     681    columnHeaderRow.appendChild(getTableCellElement('(no PAT#)', 'reportsubheader'));
     682    columnHeaderRow.appendChild(getTableCellElement('(has date)', 'reportsubheader'));
     683    columnHeaderRow.appendChild(getTableCellElement('(has date)', 'reportsubheader'));
     684    columnHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     685    columnHeaderRow.appendChild(getTableCellElement('Sum', 'reportsubheader'));
     686    columnHeaderRow.appendChild(getTableCellElement('Total', 'reportsubheader'));
     687
     688    // Build table     
     689    reportTable.appendChild(headerRow);
     690    reportTable.appendChild(subHeaderRow);
     691    reportTable.appendChild(columnHeaderRow);
     692         
     693    // Data rows     
     694    addDataRowsToConsentTableHasDate(report, reportTable);
     695     
     696    // Add a row with the combined numbers for all sites for each period
     697    var sitesCombinedRow = document.createElement('tr');
     698    sitesCombinedRow.appendChild(getTableCellElement('Sites combined', 'colsummary'));
     699    sitesCombinedRow.appendChild(getTableCellElement('', 'colsummary', 2));
     700    // Get combined numbers for all sites for each period
     701    var noDateKey = 'noDate';
    605702    var sumKey = 'sumKey';
    606703    var statistics = report.statistics;
     
    608705    if (sitesCombined != null)
    609706    {
    610       data = getJSONDataWithPercent(sitesCombined, 'yesPatient', sumKey, numDecimals);
    611       sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    612       data = getJSONDataWithPercent(sitesCombined, 'yesNoPatient', sumKey, numDecimals);
    613       sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    614       data = getJSONDataWithPercent(sitesCombined, 'no', sumKey, numDecimals);
    615       sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    616       data = getJSONDataWithPercent(sitesCombined, 'notAsked', sumKey, numDecimals);
     707      data = getJSONDataWithPercent(sitesCombined, 'yesPatientExistsDateExists', sumKey, numDecimals);
     708      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     709      data = getJSONDataWithPercent(sitesCombined, 'yesPatientUnknownDateExists', sumKey, numDecimals);
     710      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     711      data = getJSONDataWithPercent(sitesCombined, 'noDateExists', sumKey, numDecimals);
     712      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     713      data = getJSONDataWithPercent(sitesCombined, 'notAskedDateExists', sumKey, numDecimals);
    617714      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    618715      data = getJSONDataWithPercent(sitesCombined, noDateKey, sumKey, numDecimals);
     
    686783    if (sitesCombined != null)
    687784    {
    688       data = getJSONDataWithPercent(sitesCombined, 'yesNoDate', noDateOrMissingKey, numDecimals);
    689       sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    690       data = getJSONDataWithPercent(sitesCombined, 'noNoDate', noDateOrMissingKey, numDecimals);
    691       sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    692       data = getJSONDataWithPercent(sitesCombined, 'notAskedNoDate', noDateOrMissingKey, numDecimals);
     785      data = getJSONDataWithPercent(sitesCombined, 'yesDateUnknown', noDateOrMissingKey, numDecimals);
     786      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     787      data = getJSONDataWithPercent(sitesCombined, 'noDateUnknown', noDateOrMissingKey, numDecimals);
     788      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
     789      data = getJSONDataWithPercent(sitesCombined, 'notAskedDateUnknown', noDateOrMissingKey, numDecimals);
    693790      sitesCombinedRow.appendChild(getTableCellElement(data, 'colsummary'));
    694791      data = getJSONDataWithPercent(sitesCombined, 'missing', noDateOrMissingKey, numDecimals);
     
    11791276      tableRow.appendChild(getTableCellElement(siteLatestDateStr, 'reportdata'));
    11801277      var noDateKey = 'noDate';
     1278      var sumDateIgnoredKey = 'sumDateIgnoredKey';
     1279      var totalKey = 'totalKey';
     1280      if (siteData != null)
     1281      {
     1282        data = getJSONDataWithPercent(siteData, 'yes', sumDateIgnoredKey, numDecimals);
     1283        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1284        data = getJSONDataWithPercent(siteData, 'no', sumDateIgnoredKey, numDecimals);
     1285        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1286        data = getJSONDataWithPercent(siteData, 'notAsked', sumDateIgnoredKey, numDecimals);
     1287        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1288        // Add column with summed values for site
     1289        var siteSum = getJSONData(siteData, sumDateIgnoredKey, 0);
     1290        tableRow.appendChild(getTableCellElement(siteSum, 'rowsummary'));
     1291      }
     1292      // Add column with total number of samples for site, regardless of creation date
     1293      var siteTotal = getJSONData(siteData, totalKey, 0);
     1294      tableRow.appendChild(getTableCellElement(siteTotal, 'rowsummary'));
     1295      reportTable.appendChild(tableRow);
     1296    }
     1297  }
     1298
     1299  function addDataRowsToConsentTableHasDate(report, reportTable, numDecimals)
     1300  {
     1301    var sites = report.sites;   
     1302    var statistics = report.statistics;
     1303    unknownCreation = statistics.noDate;
     1304    unknownSite = statistics.unknownSite;
     1305    var siteOrderList = report.siteOrderListKey;
     1306    for (var siteOrderIndex in siteOrderList)
     1307    {
     1308      var namePrefix = siteOrderList[siteOrderIndex];   
     1309      if (!sites.hasOwnProperty(namePrefix)) continue;       
     1310      var site = sites[namePrefix];
     1311      var siteName = site.name;
     1312      var siteStartDate = dateStrToDate(site.startDate);
     1313      var siteStartDateStr = addHyphensToDateString(site.startDate);
     1314     
     1315      var siteData = statistics[namePrefix];     
     1316      var siteLatestDate = siteData['latestDateKey'];
     1317      var siteLatestDateStr = addHyphensToDateString(siteLatestDate);
     1318      var tableRow = document.createElement('tr');
     1319      var tableCol = getTableCellElement(siteName, 'rowtitle');
     1320      tableRow.appendChild(tableCol);
     1321      tableRow.appendChild(getTableCellElement(siteStartDateStr, 'reportdata'));
     1322      tableRow.appendChild(getTableCellElement(siteLatestDateStr, 'reportdata'));
     1323      var noDateKey = 'noDate';
    11811324      var sumKey = 'sumKey';
    11821325      var totalKey = 'totalKey';
    11831326      if (siteData != null)
    11841327      {
    1185         data = getJSONDataWithPercent(siteData, 'yesPatient', sumKey, numDecimals);
    1186         tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    1187         data = getJSONDataWithPercent(siteData, 'yesNoPatient', sumKey, numDecimals);
    1188         tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    1189         data = getJSONDataWithPercent(siteData, 'no', sumKey, numDecimals);
    1190         tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    1191         data = getJSONDataWithPercent(siteData, 'notAsked', sumKey, numDecimals);
     1328        data = getJSONDataWithPercent(siteData, 'yesPatientExistsDateExists', sumKey, numDecimals);
     1329        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1330        data = getJSONDataWithPercent(siteData, 'yesPatientUnknownDateExists', sumKey, numDecimals);
     1331        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1332        data = getJSONDataWithPercent(siteData, 'noDateExists', sumKey, numDecimals);
     1333        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1334        data = getJSONDataWithPercent(siteData, 'notAskedDateExists', sumKey, numDecimals);
    11921335        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    11931336        data = getJSONDataWithPercent(siteData, noDateKey, sumKey, numDecimals);
     
    12341377      if (siteData != null)
    12351378      {
    1236         data = getJSONDataWithPercent(siteData, 'yesNoDate', noDateOrMissingKey, numDecimals);
    1237         tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    1238         data = getJSONDataWithPercent(siteData, 'noNoDate', noDateOrMissingKey, numDecimals);
    1239         tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    1240         data = getJSONDataWithPercent(siteData, 'notAskedNoDate', noDateOrMissingKey, numDecimals);
     1379        data = getJSONDataWithPercent(siteData, 'yesDateUnknown', noDateOrMissingKey, numDecimals);
     1380        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1381        data = getJSONDataWithPercent(siteData, 'noDateUnknown', noDateOrMissingKey, numDecimals);
     1382        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
     1383        data = getJSONDataWithPercent(siteData, 'notAskedDateUnknown', noDateOrMissingKey, numDecimals);
    12411384        tableRow.appendChild(getTableCellElement(data, 'reportdata'));
    12421385        data = getJSONDataWithPercent(siteData, 'missing', noDateOrMissingKey, numDecimals);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r1923 r1926  
    462462    JSONObject jsonSitesCombined = new JSONObject();
    463463    String yesKey = "yes";
     464    String yesPatientExistsKey = "yesPatientExists";
     465    String yesPatientUnknownKey = "yesPatientUnkown";
     466    String yesPatientExistsDateExistsKey = "yesPatientExistsDateExists";
     467    String yesPatientExistsDateUnknownKey = "yesPatientExistsDateUnknown";
     468    String yesPatientUnknownDateExistsKey = "yesPatientUnknownDateExists";
     469    String yesPatientUnknownDateUnknownKey = "yesPatientUnknownDateUnknown";
     470    String yesDateUnknownKey = "yesDateUnknown";
    464471    String noKey = "no";
    465     String noNoDateKey = "noNoDate";
     472    String noDateExistsKey = "noDateExists";
     473    String noDateUnknownKey = "noDateUnknown";
    466474    String notAskedKey = "notAsked";
    467     String notAskedNoDateKey = "notAskedNoDate";
    468     String yesPatientKey = "yesPatient";
    469     String yesNoPatientKey = "yesNoPatient";
    470     String yesNoDateKey = "yesNoDate";
     475    String notAskedDateExistsKey = "notAskedDateExists";
     476    String notAskedDateUnknownKey = "notAskedDateUnknown";
    471477    String otherKey = "other";
    472478    String missingKey = "missing";
    473479    String sitesCombinedKey = "sitesCombinedKey";
    474     String sumKey = "sumKey";
    475     String totalKey = "totalKey";
    476480    String latestDateKey = "latestDateKey";
    477481    String noDateKey = "noDate";
    478482    String noDateOrMissingKey = "noDateOrMissing";
     483    String sumKey = "sumKey";
     484    String sumDateIgnoredKey = "sumDateIgnoredKey";
     485    String totalKey = "totalKey";
    479486    String duplicateKey = "duplicateKey";
    480487    jsonStatistics.put(sitesCombinedKey, jsonSitesCombined);
    481488    // Initialize site data to 0 for the different keys
    482489    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesKey);
     490    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientExistsKey);
     491    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientUnknownKey);
     492    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientExistsDateExistsKey);
     493    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientExistsDateUnknownKey);
     494    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientUnknownDateExistsKey);
     495    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientUnknownDateUnknownKey);
     496    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesDateUnknownKey);
    483497    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, noKey);
    484     jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, noNoDateKey);
     498    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, noDateExistsKey);
     499    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, noDateUnknownKey);
    485500    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, notAskedKey);
    486     jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, notAskedNoDateKey);
    487     jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesPatientKey);
    488     jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesNoPatientKey);
    489     jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, yesNoDateKey);
     501    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, notAskedDateExistsKey);
     502    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, notAskedDateUnknownKey);
    490503    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, otherKey);
    491504    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, missingKey);
     
    493506    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, noDateOrMissingKey);
    494507    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, sumKey);
     508    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, sumDateIgnoredKey);
    495509    jsonStatistics = tableUtil.initializeJSONSiteData(jsonStatistics, totalKey);
    496510    // Initialize combined data to 0 for the different keys
    497511    jsonSitesCombined.put(yesKey, 0);
     512    jsonSitesCombined.put(yesPatientExistsKey, 0);
     513    jsonSitesCombined.put(yesPatientUnknownKey, 0);
     514    jsonSitesCombined.put(yesPatientExistsDateExistsKey, 0);
     515    jsonSitesCombined.put(yesPatientExistsDateUnknownKey, 0);
     516    jsonSitesCombined.put(yesPatientUnknownDateExistsKey, 0);
     517    jsonSitesCombined.put(yesPatientUnknownDateUnknownKey, 0);
     518    jsonSitesCombined.put(yesDateUnknownKey, 0);
    498519    jsonSitesCombined.put(noKey, 0);
    499     jsonSitesCombined.put(noNoDateKey, 0);
     520    jsonSitesCombined.put(noDateExistsKey, 0);
     521    jsonSitesCombined.put(noDateUnknownKey, 0);
    500522    jsonSitesCombined.put(notAskedKey, 0);
    501     jsonSitesCombined.put(notAskedNoDateKey, 0);
    502     jsonSitesCombined.put(yesPatientKey, 0);
    503     jsonSitesCombined.put(yesNoPatientKey, 0);
    504     jsonSitesCombined.put(yesNoDateKey, 0);
     523    jsonSitesCombined.put(notAskedDateExistsKey, 0);
     524    jsonSitesCombined.put(notAskedDateUnknownKey, 0);
    505525    jsonSitesCombined.put(otherKey, 0);
    506526    jsonSitesCombined.put(missingKey, 0);
     
    508528    jsonSitesCombined.put(noDateOrMissingKey, 0);
    509529    jsonSitesCombined.put(sumKey, 0);
     530    jsonSitesCombined.put(sumDateIgnoredKey, 0);
    510531    jsonSitesCombined.put(totalKey, 0);
    511532    // Initialize other data to 0 for different keys
     
    546567        // Get consent date
    547568        Date consentDate = (Date) Annotationtype.CONSENT_DATE.getAnnotationValue(dc, manager, s);
    548         String key = null;
     569        // Several key may be of interest, so a list is used to collect them
     570        List<String> keyList = new ArrayList<String>();
    549571        Boolean duplicate = false;
    550572        if (consent != null)
     
    574596              if (consent.equals("Yes"))
    575597              {
    576                 key = yesKey;
     598                keyList.add(yesKey);
    577599                if (patient != null)
    578600                {
    579                   key = yesPatientKey;
     601                  keyList.add(yesPatientExistsKey);
     602                  keyList.add(yesPatientExistsDateExistsKey);
    580603                }
    581604                else
    582605                {
    583                   key = yesNoPatientKey;
     606                  keyList.add(yesPatientUnknownKey);
     607                  keyList.add(yesPatientUnknownDateExistsKey);
    584608                }
    585609              }
    586610              else if (consent.equals("No"))
    587611              {
    588                 key = noKey;
     612                keyList.add(noKey);
     613                keyList.add(noDateExistsKey);
    589614              }
    590615              else if (consent.equals("Not asked"))
    591616              {
    592                 key = notAskedKey;
     617                keyList.add(notAskedKey);
     618                keyList.add(notAskedDateExistsKey);
    593619              }
    594620              else
    595621              {
    596                 key = otherKey;
     622                keyList.add(otherKey);
    597623              }
    598624              // Find out if current consent date is the latest so far.
     
    605631          else
    606632          {
     633            // The parent is the 'Patient'
     634            BioMaterial patient = s.getParent();
    607635            if (consent.equals("Yes"))
    608636            {
    609               key = yesNoDateKey;
     637              keyList.add(yesKey);
     638              keyList.add(yesDateUnknownKey);
     639              if (patient != null)
     640              {
     641                keyList.add(yesPatientExistsKey);
     642                keyList.add(yesPatientExistsDateUnknownKey);
     643              }
     644              else
     645              {
     646                keyList.add(yesPatientUnknownKey);
     647                keyList.add(yesPatientUnknownDateUnknownKey);
     648              }
    610649            }
    611650            else if (consent.equals("No"))
    612651            {
    613               key = noNoDateKey;
     652              keyList.add(noKey);
     653              keyList.add(noDateUnknownKey);
    614654            }
    615655            else if (consent.equals("Not asked"))
    616656            {
    617               key = notAskedNoDateKey;
     657              keyList.add(notAskedKey);
     658              keyList.add(notAskedDateUnknownKey);
    618659            }
    619660            else
    620661            {
    621               key = otherKey;
     662              keyList.add(otherKey);
    622663            }
    623664          }
     
    634675        else
    635676        {
    636           key = missingKey;
     677          keyList.add(missingKey);
    637678        }
    638679        // Note that items with duplicate == false include missing consent items
    639680        if (!duplicate)
    640681        {
    641           if (key != null)
    642           {
    643             // Update consent counters
    644             jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, key);
    645             jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, key);
     682          if (keyList != null && keyList.size() > 0)
     683          {
     684            for (String key: keyList)
     685            {
     686              // Update consent counters
     687              jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, key);
     688              jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, key);
     689            }
    646690            // Include all consents except missing in summed count
    647691            if (consent != null)
     
    649693              jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, sumKey);
    650694              jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, sumKey);
     695              jsonSite = tableUtil.updateJSONObjectCounter(jsonSite, sumDateIgnoredKey);
     696              jsonSitesCombined = tableUtil.updateJSONObjectCounter(jsonSitesCombined, sumDateIgnoredKey);
    651697            }
    652698          }
Note: See TracChangeset for help on using the changeset viewer.