diff --git a/frontend/src/components/reports/common/ReportByDate.js b/frontend/src/components/reports/common/ReportByDate.js index 0cd3c81d2..43d3617bd 100644 --- a/frontend/src/components/reports/common/ReportByDate.js +++ b/frontend/src/components/reports/common/ReportByDate.js @@ -94,7 +94,7 @@ const ReportByDate = (props) => { ) { baseParams = `type=indicator&report=${props.report}&selectList.selection=${reportFormValues.value}`; } else if (props.report === "CISampleRoutineExport") { - baseParams = `report=${props.report}&type=routine`; + baseParams = `report=${props.report}&type=routine${reportFormValues.value ? `&selectList.selection=${reportFormValues.value}` : ""}`; } else { baseParams = `report=${props.report}&type=patient`; } @@ -112,6 +112,19 @@ const ReportByDate = (props) => { setLoading(false); }; + const getSelectLabel = () => { + switch (props.report) { + case "activityReportByTest": + return "input.placeholder.selectTest"; + case "activityReportByPanel": + return "input.placeholder.selectPanel"; + case "activityReportByTestSection": + return "input.placeholder.selectTestSection"; + case "CISampleRoutineExport": + return "input.placeholder.selectTestSection"; + } + }; + useEffect(() => { const fetchData = async () => { switch (props.report) { @@ -127,6 +140,9 @@ const ReportByDate = (props) => { setTempData, ); break; + case "CISampleRoutineExport": + getFromOpenElisServer("/rest/user-test-sections/ALL", setTempData); + break; default: break; } @@ -136,7 +152,8 @@ const ReportByDate = (props) => { if ( props.report === "activityReportByTest" || props.report === "activityReportByPanel" || - props.report === "activityReportByTestSection" + props.report === "activityReportByTestSection" || + props.report === "CISampleRoutineExport" ) { fetchData(); } @@ -226,7 +243,10 @@ const ReportByDate = (props) => { {list.map((statusOption) => ( reportItems; protected int iReportItem = -1; diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/ExportRoutineByDate.java b/src/main/java/org/openelisglobal/reports/action/implementation/ExportRoutineByDate.java index 4c20de0a8..2e08b9a88 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/ExportRoutineByDate.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/ExportRoutineByDate.java @@ -72,6 +72,10 @@ public void initializeReport(ReportForm form) { lowDateStr = form.getLowerDateRange(); highDateStr = form.getUpperDateRange(); + if (form.getSelectList() != null && form.getSelectList().getSelection() != null) { + selectedLabUnit = form.getSelectList().getSelection(); + } + // projectStr = form.getProjectCode(); dateRange = new DateRange(lowDateStr, highDateStr); @@ -112,6 +116,9 @@ private boolean validateSubmitParameters() { private void createReportItems() { try { csvRoutineColumnBuilder = getColumnBuilder(); + if (selectedLabUnit != null) { + csvRoutineColumnBuilder.setSelectedLabUnit(selectedLabUnit); + } csvRoutineColumnBuilder.buildDataSource(); } catch (SQLException e) { Log.error("Error in " + this.getClass().getSimpleName() + ".createReportItems: ", e); diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java index a4884985e..3383de107 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java @@ -59,6 +59,15 @@ * @since Mar 18, 2011 */ public abstract class CSVRoutineColumnBuilder { + protected String selectedLabUnit; + + public String getSelectedLabUnit() { + return selectedLabUnit; + } + + public void setSelectedLabUnit(String selectedLabUnit) { + this.selectedLabUnit = selectedLabUnit; + } // these are used so we are not passing around strings in the methods that are // appended to sql @@ -530,6 +539,10 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat SQLConstant listName = SQLConstant.RESULT; query.append(", \n\n ( SELECT si.samp_id, si.id AS sampleItem_id, si.sort_order AS sampleItemNo, " + listName + ".* " + " FROM sample_item AS si JOIN \n "); + String labUnitFilter = ""; + if (selectedLabUnit != null && !selectedLabUnit.isEmpty()) { + labUnitFilter = " AND ts.id = " + selectedLabUnit; + } // Begin cross tab / pivot table query.append(" crosstab( \n" + " 'SELECT si.id, t.description, replace(replace(replace(replace(r.value ,E''\\n" @@ -548,7 +561,7 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat // + (( excludeAnalytes == null)?"": // " AND r.analyte_id NOT IN ( " + excludeAnalytes) + ")" // + " AND a.test_id = t.id " - + "\n ORDER BY 1, 2 " + + labUnitFilter + "\n ORDER BY 1, 2 " + "\n ', 'SELECT t.description FROM test t where t.is_active = ''Y'' ORDER BY 1' ) "); // end of cross tab @@ -725,4 +738,4 @@ protected String getGendCD4CountAnalyteId() { } return gendCD4CountAnalyteId; } -} +} \ No newline at end of file