Changeset 1748


Ignore:
Timestamp:
Nov 27, 2012, 3:37:46 PM (9 years ago)
Author:
olle
Message:

Fixes #434. Sample count report generator updated to allow the user to select if sample type should be specimen or blood.

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

Legend:

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

    r1744 r1748  
    6363    var frm = document.forms['reggie'];
    6464    frm.reporttype.disabled = true;
     65    // Hide sample type pop-up menu
     66    document.getElementById("sampleTypeSubSection01").style.display = 'none';
     67    document.getElementById("sampleTypeSubSection02").style.display = 'none';
     68    document.getElementById("sampleTypeSubSection04").style.display = 'none';
    6569    if (frm.reporttype[frm.reporttype.selectedIndex].value == 'samplecount')
    6670    {
     
    6872      document.getElementById("items01").innerHTML="tubes";
    6973      // Set item name for report time step text
    70       document.getElementById("items02").innerHTML="specimens";
    71       document.getElementById("items03").innerHTML="specimens";
    72       document.getElementById("items04").innerHTML="specimens";
    73       document.getElementById("items05").innerHTML="specimens";
     74      document.getElementById("items02").innerHTML="samples";
     75      document.getElementById("items03").innerHTML="samples";
     76      document.getElementById("items04").innerHTML="samples";
     77      document.getElementById("items05").innerHTML="samples";
    7478      // Show view type pop-up menu
    7579      document.getElementById("viewTypeSubSection01").style.display = 'block';
    7680      document.getElementById("viewTypeSubSection02").style.display = 'block';
    7781      document.getElementById("viewTypeSubSection04").style.display = 'block';
     82      // Show sample type pop-up menu
     83      document.getElementById("sampleTypeSubSection01").style.display = 'block';
     84      document.getElementById("sampleTypeSubSection02").style.display = 'block';
     85      document.getElementById("sampleTypeSubSection04").style.display = 'block';
    7886    }
    7987    else if (frm.reporttype[frm.reporttype.selectedIndex].value == 'consentcount')
     
    165173    frm.fromdate.disabled = true;
    166174    frm.todate.disabled = true;
     175    var sampleType = frm.sampletype[frm.sampletype.selectedIndex].value;   
    167176    if (reportType == 'samplecount')
    168177    {
    169178      frm.viewtype.disabled = true;
     179      frm.sampletype.disabled = true;
    170180    }
    171181    if (reportType == 'patientcount')
     
    182192    {     
    183193      if (frm.viewtype.value != null) url += '&vtype='+frm.viewtype.value;
     194      if (frm.sampletype.value != null) url += '&stype='+frm.sampletype.value;
    184195    }
    185196    if (reportType == 'patientcount')
     
    242253    if (unknownCreation == null) unknownCreation = 0;
    243254    if ('samplecount' == reportType)
    244     {     
    245       summaryList.appendChild(getListElement(unknownSite + ' specimens registered to unknown sites.'));
    246       summaryList.appendChild(getListElement(unknownCreation + ' specimens without creation date. These are included in the \'Total\' column.'));
     255    {
     256      var samples = 'specimens';
     257      if ('blood' == sampleType)
     258      {
     259        samples = 'blood samples';
     260      }
     261      summaryList.appendChild(getListElement(unknownSite + ' ' + samples + ' registered to unknown sites.'));
     262      summaryList.appendChild(getListElement(unknownCreation + ' ' + samples + ' without creation date. These are included in the \'Total\' column.'));
    247263    }
    248264    else if ('consentcount' == reportType)
     
    315331   
    316332    var viewType = report.viewType;   
     333    var sampleType = report.sampleType;
    317334 
    318335    var headerRow = document.createElement('tr');   
     
    320337    var columnHeaderRow = document.createElement('tr');
    321338   
    322     var headerText = '# Item by ';
     339    var headerText = '# Items by ';
    323340    if ('samplecount' == reportType)
    324341    {
    325       headerText = '# Specimen by ';
     342      headerText = '# Specimens by ';
     343      if ('blood' == sampleType)
     344      {
     345        headerText = '# Blood samples by ';
     346      }
    326347    }
    327348    else if ('patientcount' == reportType)
     
    14001421            </tr>
    14011422            <tr>
    1402               <!--       
    1403               <td valign="top" class="prompt">View type subsection</td>
    1404               -->
    14051423              <td valign="top" class="prompt">
    14061424                <div id="viewTypeSubSection01" style="display:none;">
    1407                   View type subsection
     1425                  View type
    14081426                </div>
    14091427              </td>
     
    14301448                    <li>Period is 3 year or greater - <text id="items05">items</text> per year</li>
    14311449                  </ul>                 
     1450                </div>
     1451              </td>
     1452            </tr>
     1453            <tr>
     1454              <td valign="top" class="prompt">
     1455                <div id="sampleTypeSubSection01" style="display:none;">
     1456                  Sample type
     1457                </div>
     1458              </td>
     1459              <td valign="top" class="input">
     1460                <div id="sampleTypeSubSection02" style="display:none;">
     1461                  <select name="sampletype">
     1462                    <option value="specimen" selected="yes">Specimen</option>
     1463                    <option value="blood">Blood</option>
     1464                  </select>
     1465                </div>
     1466              </td>
     1467              <td valign="top" class="status" id="displaySampleType.status"></td>
     1468              <td class="help">
     1469                <div id="sampleTypeSubSection04" style="display:none;">
     1470                  <span id="displaySampleType.message" class="message" style="display: none;"></span>
     1471                  Select sample type for report.
    14321472                </div>
    14331473              </td>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r1744 r1748  
    120120          viewType = getViewType(startDate, endDate);
    121121        }
    122 
    123         json = createSampleCountReport(dc, json, startDate, endDate, viewType);
     122        String sampleType = "specimen";
     123        String sampleTypeParameter = Values.getString(req.getParameter("stype"), null);
     124        if (sampleTypeParameter != null)
     125        {
     126          sampleType = sampleTypeParameter;
     127        }
     128
     129        json = createSampleCountReport(dc, json, startDate, endDate, viewType, sampleType);
    124130      }
    125131      else if ("consentcount".equals(cmd))
     
    206212  }
    207213 
    208   private JSONObject createSampleCountReport(DbControl dc, JSONObject json, Date startDate, Date endDate, String viewType)
     214  private JSONObject createSampleCountReport(DbControl dc, JSONObject json, Date startDate, Date endDate, String viewType, String sampleType)
    209215    throws ServletException, IOException
    210216  {
     
    215221    ItemQuery<Sample> sampleQuery = Sample.getQuery();
    216222    sampleQuery.joinPermanent(Hql.innerJoin(null, "creationEvent", "ce", true));
    217     Subtype.SPECIMEN.addFilter(dc, sampleQuery);
     223    if (sampleType.equals("blood"))
     224    {
     225      Subtype.BLOOD.addFilter(dc, sampleQuery);
     226    }
     227    else
     228    {
     229      Subtype.SPECIMEN.addFilter(dc, sampleQuery);
     230    }
    218231    sampleQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    219232    sampleQuery.order(Orders.asc(Hql.property("name")));
     
    238251    Date periodStartDate = calculatePeriodStartDate(startDate, viewType);
    239252    jsonReport.put("viewType", viewType);
     253    jsonReport.put("sampleType", sampleType);
    240254    jsonReport.put("beginDate", date2StringConverter.convert(startDate));
    241255    jsonReport.put("endDate", date2StringConverter.convert(endDate));
Note: See TracChangeset for help on using the changeset viewer.