Changeset 2223


Ignore:
Timestamp:
Feb 12, 2014, 10:35:26 AM (9 years ago)
Author:
olle
Message:

Refs #574. Refs #565. Refs #569. Consent and missing sample data report wizards updated to support missing data sample list export for users with PatientCurator role:

Java servlet SampleReportServlet in reggie/src/net/sf/basedb/reggie/servlet/ update:

  1. Private method JSONObject createConsentCountReport(DbControl dc, JSONObject json, Date startDate, Date endDate) updated to check if the user does not have permission to read patient names, and transfer the result in the returned JSON object in variable with key "permissionDeniedForPatientName". The same flag is already returned by private method JSONObject createMissingSampleDataReport(DbControl dc, JSONObject json, Date startDate, Date endDate, String sampleType, String bloodSampleFilter).

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

  1. Function goCreate() updated with argument exportOpt:
    a. If the value of argument exportOpt is "preview" or "export", the consent count and missing sample data report wizards directs the Ajax request to servlet ExportServlet.java to obtain data for corresponding the missing data sample list.
    b. If the value of argument exportOpt is "preview", a preview is shown created by the one of the new functions createMissingConsentDataSampleListPreview(allLines, previewTitle, previewList) or createMissingDataSampleListPreview(allLines, sampleTypes, previewTitle, previewList), that corresponds to the used report wizard.
    c. If the value of argument exportOpt is "export", the output from the Export servlet request is redirected to be downloaded or opened with a program of the user's choice.
  2. Function goCreate(exportOpt) updated for the consent and missing sample data reports to check if the user has permission to read patient names, and if so, add two new buttons to the right of the "Restart" button at the end, "Export preview" and "Export", coupled to calling function goCreate(exportOpt) with argument exportOpt having values "preview" and "export", respectively.
  3. New function createMissingConsentDataSampleListPreview(allLines, previewTitle, previewList) added. It creates a sample list preview like the one created by JSP script export_missing_consent_data_sample_list.jsp in reggie/resources/personal/, as described in Ticket #569 (Sample list export for missing consent data).
  4. New function createMissingDataSampleListPreview(allLines, sampleTypes, previewTitle, previewList) added. It creates a sample list preview like the one created by JSP script export_missing_data_sample_list.jsp in reggie/resources/personal/, as described in Ticket #565 (Missing sample data report should support sample list export).
  5. HTML part updated with new style section for the sample list preview, button definitions for the "Export preview" and "Export" buttons, and new div tags for the optional export preview.
Location:
extensions/net.sf.basedb.reggie/trunk
Files:
2 edited

Legend:

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

    r2210 r2223  
    286286  }
    287287
    288   function goCreate()
     288  function goCreate(exportOpt)
    289289  {
    290290    if (!intervalIsValid) return;
     
    317317    Main.hide('gocreate');
    318318    Main.show('reportSection');
    319     var url = '../SampleReport.servlet?ID=<%=ID%>&cmd='+reportType;   
     319    var url = '../SampleReport.servlet?ID=<%=ID%>&cmd='+reportType;
     320    if (exportOpt == 'preview' || exportOpt == 'export')
     321    {
     322      if (reportType == 'consentcount')
     323      {
     324        url = '../Export.servlet?ID=<%=ID%>&cmd='+'ExportMissingConsentDataSampleList';
     325      }
     326      if (reportType == 'missingsampledatareport')
     327      {
     328        url = '../Export.servlet?ID=<%=ID%>&cmd='+'ExportMissingSampleDataSampleList';
     329      }
     330    }
    320331   
    321332    if (frm.fromdate.value != null) url += '&fdate='+frm.fromdate.value;
     
    340351      if (frm.sampletype.value != null) url += '&stype='+frm.sampletype.value;
    341352      if (frm.bloodsamplefilter.value != null) url += '&bloodsamplefilter='+frm.bloodsamplefilter.value;
     353    }
     354    if (exportOpt == 'preview')
     355    {
     356      var previewTitle = document.getElementById('previewTitle');
     357      var previewList = document.getElementById('previewList');
     358
     359      Main.hide('previewWrapper');
     360      previewTitle.innerHTML = 'Working...';
     361      previewList.innerHTML = '';
     362
     363      url += '&preview=1';
     364      var request = Ajax.getXmlHttpRequest();
     365
     366      try
     367      {
     368        showLoadingAnimation('Working...');
     369        request.open("GET", url, false); 
     370        request.send(null);
     371      }
     372      finally
     373      {
     374        hideLoadingAnimation();
     375      }
     376
     377      if (request.status != 200)
     378      {
     379        Main.openPopup('', 'ErrorWindow', 800, 600);
     380        Main.getWindow('ErrorWindow').document.write(request.responseText);
     381      }
     382      else
     383      {
     384        var allLines = request.responseText.split('\n');
     385        if (reportType == 'consentcount')
     386        {
     387          createMissingConsentDataSampleListPreview(allLines, previewTitle, previewList);
     388        }
     389        else if (reportType == 'missingsampledatareport')
     390        {
     391          var sampleTypes = frm.sampletype[frm.sampletype.selectedIndex].text;
     392          createMissingDataSampleListPreview(allLines, sampleTypes, previewTitle, previewList);
     393        }
     394      }
     395    }
     396    else if (exportOpt == 'export')
     397    {
     398      window.location = url;   
    342399    }
    343400   
     
    603660    Main.show('printButton');
    604661    Main.show('gorestart');
     662    if ('consentcount' == reportType || 'missingsampledatareport' == reportType)
     663    {
     664      // Only show "Export preview" and "Export" buttons if user has permission to read patient data
     665      if (report != null)
     666      {
     667        var permissionDeniedForPatientName = report.permissionDeniedForPatientName;
     668        if (permissionDeniedForPatientName != null && !permissionDeniedForPatientName)
     669        {
     670          Main.show('gopreview');
     671          Main.show('goexport'); 
     672        }
     673      }
     674    }
     675  }
     676
     677  function createMissingConsentDataSampleListPreview(allLines, previewTitle, previewList)
     678  {
     679    var numCases = allLines.length - 2; // First line is a header line
     680     
     681    var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>';
     682    // Check last column for the 'Consent' value
     683    var numConsentWithoutDate = 0;
     684    var numMissingConsent = 0;
     685    var numYesConsent = 0;
     686    var numNoConsent = 0;
     687    var numNotAskedConsent = 0;
     688    for (var i = 1 ; i <= numCases; i++)
     689    {
     690      var line = allLines[i];
     691      var cols = line.split(/\t/);
     692      var consent = cols[cols.length-1];
     693      var rowClass = '';
     694      if (consent == null || consent == 'null')
     695      {
     696        rowClass = 'consent-warning';
     697        numMissingConsent++;
     698      }
     699      else if (consent == 'Yes')
     700      {
     701        numYesConsent++;
     702      }
     703      else if (consent == 'No')
     704      {
     705        numNoConsent++;
     706      }
     707      else if (consent == 'Not asked')
     708      {
     709        numNotAskedConsent++;
     710      }
     711      html += '<tr class="'+rowClass+'"><td>'+cols.join('</td><td>')+'</td></tr>';
     712    }
     713    numConsentWithoutDate = numCases - numMissingConsent;
     714
     715    previewTitle.innerHTML = numCases + ' Samples = ' + numConsentWithoutDate + ' unknown date (' + numYesConsent + ' Yes, ' + numNoConsent + ' No, ' + numNotAskedConsent + ' Not asked) + ' + numMissingConsent + ' missing consent';
     716    previewList.innerHTML = '<table>'+html+'</table>';
     717    Main.show('previewWrapper');
     718  }
     719 
     720  function createMissingDataSampleListPreview(allLines, sampleTypes, previewTitle, previewList)
     721  {
     722    var numCases = allLines.length - 2; // First line is a header line
     723    var numSpecimen = 0;
     724    var numNoSpecimen = 0;
     725     
     726    var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>';
     727    // Check second column for the 'Subtype' value
     728    var numNoConsent = 0;
     729    var numMissingConsent = 0;
     730    for (var i = 1 ; i <= numCases; i++)
     731    {
     732      var line = allLines[i];
     733      var cols = line.split(/\t/);
     734      var sampleSubtype = cols[1];
     735      if (sampleSubtype == 'Specimen')
     736      {
     737        numSpecimen++;
     738      }
     739      else if (sampleSubtype == 'NoSpecimen')
     740      {
     741        numNoSpecimen++;
     742      }
     743      var rowClass = '';
     744      html += '<tr class="'+rowClass+'"><td>'+cols.join('</td><td>')+'</td></tr>';
     745    }
     746
     747    previewTitle.innerHTML = 'Sample type(s) - ' + sampleTypes + ' (' + numCases + ')';
     748    if (sampleTypes == 'Specimen' || sampleTypes == 'No specimen')
     749    {
     750      // Report the number of each subtype for 'Specimen/No specimen'
     751      previewTitle.innerHTML = 'Sample type(s) - Specimen (' + numSpecimen + ')/No specimen (' + numNoSpecimen + ') Total (' + numCases + ')';
     752    }
     753    previewList.innerHTML = '<table>'+html+'</table>';
     754    Main.show('previewWrapper');
    605755  }
    606756 
     
    25832733
    25842734  </script>
    2585  
    2586  
     2735
     2736  <style>
     2737  #previewWrapper
     2738  {
     2739    position: relative;
     2740    top: 2em;
     2741    bottom: 1em;
     2742    left: 20px;
     2743    width: 950px;
     2744    overflow: visible;
     2745  }
     2746
     2747  #previewList
     2748  {
     2749    position: absolute;
     2750    top: 2em;
     2751    bottom: 1px;
     2752    width: 955px;
     2753    height: 500px;
     2754    overflow: auto;
     2755    white-space: pre;
     2756    font-family: monospace;
     2757    border: 1px dotted #A0A0A0;
     2758    border-radius: 4px;
     2759    background: #E8E8E8;
     2760    padding: 0.25em;
     2761  }
     2762
     2763  #previewTitle
     2764  {
     2765    font-weight: bold;
     2766    padding-bottom: 2em;
     2767  }
     2768
     2769  #previewList th
     2770  {
     2771    border-bottom: 1px dotted #A0A0A0;
     2772  }
     2773
     2774  #previewList td, #previewList th
     2775  {
     2776    text-align: left;
     2777    padding-right: 2em;
     2778    vertical-align: bottom;
     2779  }
     2780
     2781  .consent-warning
     2782  {
     2783    color: #A00000;
     2784    background-color: #F8F8E8;
     2785  }
     2786
     2787  .consent-warning td:last-child
     2788  {
     2789    background-image: url('../images/warning_small.png');
     2790    background-position: 95% 50%;
     2791    background-repeat: no-repeat;
     2792  }
     2793
     2794  </style>
     2795
    25872796  </base:head>
    25882797  <base:body onload="init()">
     
    28173026          <td><base:button id="gocancel" title="Cancel" onclick="goRestart(false)" style="display: none;"/></td>
    28183027          <td><base:button id="gonext" title="Next" image="<%=home+"/images/gonext.png"%>" onclick="goNext(true)" /></td>
    2819           <td><base:button id="gocreate" title="Generate" image="<%=home+"/images/gonext.png"%>" onclick="goCreate()" style="display: none;"/></td>         
     3028          <td><base:button id="gocreate" title="Generate" image="<%=home+"/images/gonext.png"%>" onclick="goCreate('')" style="display: none;"/></td>         
    28203029          <td><base:button id="gorestart" title="Restart" image="<%=home+"/images/goback.png"%>" onclick="goRestart(true)" style="display: none;"/></td>
     3030          <td><base:button id="gopreview" title="Export preview" image="<%=home+"/images/export.png"%>" onclick="goCreate('preview')" style="display: none;"/></td>
     3031          <td><base:button id="goexport" title="Export" image="<%=home+"/images/download.png"%>" onclick="goCreate('export')" style="display: none;"/></td>
    28213032          <td id="gonext.message" class="message"></td>
    28223033        </tr>
    28233034      </table>     
    28243035    </form>
     3036
     3037    <div class="loading" id="loading" style="display: none;"><table><tr><td><img src="../images/loading.gif"></td><td id="loading.msg">Please wait...</td></tr></table></div>
     3038 
     3039    <div id="previewWrapper" style="display: none;">
     3040      <div>
     3041        <span id="previewTitle">Preview</span>
     3042        <span id="previewWarning"></span>
     3043      </div>
     3044      <div id="previewList"></div>
     3045    </div>
     3046
    28253047    </div>
    28263048   
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r2203 r2223  
    618618    String totalKey = "totalKey";
    619619    String duplicateKey = "duplicateKey";
     620    String permissionDeniedForPatientNameKey = "permissionDeniedForPatientName";
    620621    jsonStatistics.put(sitesCombinedKey, jsonSitesCombined);
    621622    // Initialize site data to 0 for the different keys
     
    668669    jsonStatistics.put(duplicateKey, 0);
    669670    Date latestDate = null;
     671    boolean permissionDeniedForPatientName = false;
     672    try
     673    {
     674      Annotationtype.ALL_FIRST_NAMES.load(dc);
     675      Annotationtype.FAMILY_NAME.load(dc);
     676    }
     677    catch (RuntimeException ex)
     678    {
     679      permissionDeniedForPatientName = true;
     680    }
    670681    // Create HashMap to keep track of processed dates for each patient
    671682    HashMap<String, Set<Date>>patientDateSetHashMap = new HashMap<String, Set<Date>>();
     
    893904    String latestDateStr = (String) jsonStatistics.get("latestDateKey");
    894905    jsonReport.put("latestDate", latestDateStr);
     906    jsonReport.put(permissionDeniedForPatientNameKey, permissionDeniedForPatientName);
    895907    String siteOrder = ReportTableUtilServlet.alphabeticalOrder;
    896908    JSONObject jsonSiteOrderList = tableUtil.createJSONSiteOrderList(siteOrder);
Note: See TracChangeset for help on using the changeset viewer.