Skip to content

Commit

Permalink
Merge pull request #1405 from mozzy11/develop
Browse files Browse the repository at this point in the history
add Lab unit filter on csv Routine report
  • Loading branch information
mozzy11 authored Jan 14, 2025
2 parents 4cc03a7 + f00b157 commit e44814c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
26 changes: 23 additions & 3 deletions frontend/src/components/reports/common/ReportByDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand All @@ -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) {
Expand All @@ -127,6 +140,9 @@ const ReportByDate = (props) => {
setTempData,
);
break;
case "CISampleRoutineExport":
getFromOpenElisServer("/rest/user-test-sections/ALL", setTempData);
break;
default:
break;
}
Expand All @@ -136,7 +152,8 @@ const ReportByDate = (props) => {
if (
props.report === "activityReportByTest" ||
props.report === "activityReportByPanel" ||
props.report === "activityReportByTestSection"
props.report === "activityReportByTestSection" ||
props.report === "CISampleRoutineExport"
) {
fetchData();
}
Expand Down Expand Up @@ -226,7 +243,10 @@ const ReportByDate = (props) => {
<SelectItem
key={"emptyselect"}
value={""}
text="Select Test Type"
text={intl.formatMessage({
id: getSelectLabel(),
defaultMessage: "Seelect Test",
})}
/>
{list.map((statusOption) => (
<SelectItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public abstract class CSVRoutineSampleExportReport extends CSVRoutineExportRepor

protected String lowDateStr;
protected String highDateStr;
protected String selectedLabUnit;
protected List<Object> reportItems;
protected int iReportItem = -1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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

Expand Down Expand Up @@ -725,4 +738,4 @@ protected String getGendCD4CountAnalyteId() {
}
return gendCD4CountAnalyteId;
}
}
}

0 comments on commit e44814c

Please sign in to comment.