Changeset 1737


Ignore:
Timestamp:
Nov 16, 2012, 4:19:51 PM (9 years ago)
Author:
olle
Message:

Fixes #428. Refs #420. Refs #426. Sample count report and consent count report updated to show a table column with latest item dates for each site.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

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

    r1735 r1737  
    350350      headerText += latestDate.getDate();
    351351    }   
    352     headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+4)));
     352    headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+5)));
    353353   
    354354    // Sub headers
     
    356356    if (viewType != 'YEAR')
    357357    {
    358       subHeaderRowYear.appendChild(getTableCellElement('', 'reportsubheader', 2));
     358      subHeaderRowYear.appendChild(getTableCellElement('', 'reportsubheader', 3));
    359359      addYearSubHeaders(periodStartDate, endDate, subHeaderRowYear, viewType);     
    360360      subHeaderRowYear.appendChild(getTableCellElement('', 'reportsubheader', 2));
     
    364364    var siteHeader = getTableCellElement('Site', 'reportsubheader');     
    365365    var startDateHeader = getTableCellElement('Start date','reportsubheader');
     366    var latestDateHeader = getTableCellElement('Latest date','reportsubheader');
    366367    columnHeaderRow.appendChild(siteHeader);
    367368    columnHeaderRow.appendChild(startDateHeader);
     369    columnHeaderRow.appendChild(latestDateHeader); 
    368370   
    369371    if (viewType == 'MONTH') addMonthColumnHeaders(columnHeaderRow, periodStartDate);
     
    387389    var sitesCombinedRow = document.createElement('tr');
    388390    sitesCombinedRow.appendChild(getTableCellElement('Sites combined', 'colsummary'));
    389     sitesCombinedRow.appendChild(getTableCellElement('', 'colsummary'));
     391    sitesCombinedRow.appendChild(getTableCellElement('', 'colsummary', 2));
    390392    // Get combined numbers for all sites for each period
    391393    var statistics = report.statistics;
     
    452454    var numDecimals = 0;
    453455    var headerText = '# Consent forms of different types for cases and blood samples';
    454     headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+3)));
     456    headerRow.appendChild(getTableCellElement(headerText, 'reportheader', (numCols+4)));
    455457   
    456458    // Subheader   
    457459    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
    458     subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader'));
     460    subHeaderRow.appendChild(getTableCellElement('', 'reportsubheader', 2));
    459461   
    460462    //subHeaderRow.appendChild(getTableCellElement('Yes', 'reportsubheader'));
     
    474476    var siteHeader = getTableCellElement('Site', 'reportsubheader');     
    475477    var startDateHeader = getTableCellElement('Start date','reportsubheader');
     478    var latestDateHeader = getTableCellElement('Latest date','reportsubheader');
    476479    columnHeaderRow.appendChild(siteHeader);
    477480    columnHeaderRow.appendChild(startDateHeader);
     481    columnHeaderRow.appendChild(latestDateHeader); 
    478482   
    479483    //columnHeaderRow.appendChild(getTableCellElement('Yes', 'reportsubheader'));
     
    501505    var sitesCombinedRow = document.createElement('tr');
    502506    sitesCombinedRow.appendChild(getTableCellElement('Sites combined', 'colsummary'));
    503     sitesCombinedRow.appendChild(getTableCellElement('', 'colsummary'));
     507    sitesCombinedRow.appendChild(getTableCellElement('', 'colsummary', 2));
    504508    // Get combined numbers for all sites for each period
    505509    var sumKey = 'sumKey';
     
    630634     
    631635      var siteData = statistics[namePrefix];     
     636      var siteLatestDate = siteData['latestDateKey'];
     637      var siteLatestDateYear = siteLatestDate.substr(0,4);
     638      var siteLatestDateMonth = siteLatestDate.substr(4,2);
     639      var siteLatestDateDate = siteLatestDate.substr(6,2);
     640      var siteLatestDateStr = siteLatestDateYear + '-' + siteLatestDateMonth + '-' + siteLatestDateDate;
    632641      var tableRow = document.createElement('tr');
    633642      var tableCol = getTableCellElement(siteName, 'rowtitle');
    634643      tableRow.appendChild(tableCol);
    635644      tableRow.appendChild(getTableCellElement(year+'-'+(month)+'-'+date, 'reportdata'));
     645      tableRow.appendChild(getTableCellElement(siteLatestDateStr, 'reportdata'));
    636646      //var currentDate = new Date(periodStartDate.getFullYear(), periodStartDate.getMonth(), periodStartDate.getDate());     
    637647      var sumKey = 'sumKey';
     
    899909      var siteStartDate = new Date(year, month-1, date);
    900910     
    901       var siteData = statistics[namePrefix];     
     911      var siteData = statistics[namePrefix];
     912      var siteLatestDate = siteData['latestDateKey'];
     913      var siteLatestDateYear = siteLatestDate.substr(0,4);
     914      var siteLatestDateMonth = siteLatestDate.substr(4,2);
     915      var siteLatestDateDate = siteLatestDate.substr(6,2);
     916      var siteLatestDateStr = siteLatestDateYear + '-' + siteLatestDateMonth + '-' + siteLatestDateDate;
    902917      var tableRow = document.createElement('tr');
    903918      var tableCol = getTableCellElement(siteName, 'rowtitle');
    904919      tableRow.appendChild(tableCol);
    905920      tableRow.appendChild(getTableCellElement(year+'-'+(month)+'-'+date, 'reportdata'));
     921      tableRow.appendChild(getTableCellElement(siteLatestDateStr, 'reportdata'));
    906922      var currentDate = new Date(periodStartDate.getFullYear(), periodStartDate.getMonth(), periodStartDate.getDate());     
    907923      var columnCounter = 0;
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r1735 r1737  
    216216    String sumKey = "sumKey";
    217217    String totalKey = "totalKey";
     218    String latestDateKey = "latestDateKey";
    218219    String noDateKey = "noDate";
    219220    String duplicateKey = "duplicateKey";
     
    251252    HashMap<String, Set<Date>>patientDateSetHashMap = new HashMap<String, Set<Date>>();
    252253    JSONObject jsonPatientnamePatientid = new JSONObject();
     254    // Create HashMap to keep track of latest consent date for each site
     255    HashMap<String, Date> sitePrefixDateHashMap = new HashMap<String, Date>();
    253256    while (sampleIterator.hasNext())
    254257    {
     
    335338            key = otherKey;
    336339          }
     340
     341          // Keep track of latest consent date for site
     342          if (consentDate != null)
     343          {
     344            Date siteLatestDate = sitePrefixDateHashMap.get(site.getPrefix());
     345            if (siteLatestDate == null || siteLatestDate.before(consentDate))
     346            {
     347              sitePrefixDateHashMap.put(site.getPrefix(), consentDate);
     348            }
     349          }
    337350        }
    338351        // Note that items with duplicate == false include missing consent items
     
    354367        }
    355368      }
     369    }
     370    // Add latest consent date for site to site JSON object
     371    DateToStringConverter date2StringConverter = Reggie.CONVERTER_DATE_TO_STRING;
     372    for (Site s: Site.getAllSites())
     373    {
     374        JSONObject jsonSite = (JSONObject) jsonStatistics.get(s.getPrefix());
     375        if (jsonSite == null)
     376        {
     377          jsonSite = new JSONObject();
     378          jsonStatistics.put(s.getPrefix(), jsonSite);
     379        }
     380        Date siteLatestDate = sitePrefixDateHashMap.get(s.getPrefix());
     381        jsonSite.put(latestDateKey, date2StringConverter.convert(siteLatestDate));
    356382    }
    357383    // Create JSONObject (patient, dates) for patients with multiple dates
     
    534560    String latestDateKey = "latestDateKey";
    535561    jsonStatistics.put(sitesCombinedKey, jsonSitesCombined);
     562    // Create HashMap to keep track of latest sample date for each site
     563    HashMap<String, Date> sitePrefixDateHashMap = new HashMap<String, Date>();
    536564    while (sampleIterator.hasNext())
    537565    {
     
    578606            }
    579607          }
     608
     609          // Keep track of latest sample date for site
     610          Date siteLatestDate = sitePrefixDateHashMap.get(site.getPrefix());
     611          if (siteLatestDate == null || siteLatestDate.before(creationDate))
     612          {
     613            sitePrefixDateHashMap.put(site.getPrefix(), creationDate);
     614          }
    580615        }
    581616        else
     
    592627      }
    593628    }
     629    // Add latest sample date for site to site JSON object
     630    DateToStringConverter date2StringConverter = Reggie.CONVERTER_DATE_TO_STRING;
     631    for (Site s: Site.getAllSites())
     632    {
     633        JSONObject jsonSite = (JSONObject) jsonStatistics.get(s.getPrefix());
     634        if (jsonSite == null)
     635        {
     636          jsonSite = new JSONObject();
     637          jsonStatistics.put(s.getPrefix(), jsonSite);
     638        }
     639        Date siteLatestDate = sitePrefixDateHashMap.get(s.getPrefix());
     640        jsonSite.put(latestDateKey, date2StringConverter.convert(siteLatestDate));
     641    }
    594642    // Add latest date for further transfer to other JSON object
    595     DateToStringConverter date2StringConverter = Reggie.CONVERTER_DATE_TO_STRING;
    596643    jsonStatistics.put(latestDateKey, date2StringConverter.convert(latestDate));
    597644    return jsonStatistics;       
Note: See TracChangeset for help on using the changeset viewer.