Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

labs filter on csv routine report #1388

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was the prettier version changed ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be because I installed a new version on my pc hence the version changes

Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.3.2",
"prettier": "^3.4.2",
"sass": "^1.57.1"
}
}
91 changes: 63 additions & 28 deletions frontend/src/components/reports/common/ReportByDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import CustomDatePicker from "../../common/CustomDatePicker";
import config from "../../../config.json";
import { encodeDate, Roles } from "../../utils/Utils";
import { getFromOpenElisServer } from "../../utils/Utils";

const ReportByDate = (props) => {
const intl = useIntl();
const [loading, setLoading] = useState(false);
Expand All @@ -27,6 +28,7 @@ const ReportByDate = (props) => {
startDate: null,
endDate: null,
value: "",
labUnit: "",
error: null,
});

Expand Down Expand Up @@ -94,7 +96,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.labUnit ? `&labUnit=${reportFormValues.labUnit}` : ''}`;
} else {
baseParams = `report=${props.report}&type=patient`;
}
Expand All @@ -107,36 +109,33 @@ const ReportByDate = (props) => {
setNotificationVisible(true);
};

const setTempData = (data) => {
setList(data);
setLoading(false);
};

useEffect(() => {
const fetchData = async () => {
switch (props.report) {
case "activityReportByTest":
getFromOpenElisServer("/rest/test-list", setTempData);
break;
case "activityReportByPanel":
getFromOpenElisServer("/rest/panels", setTempData);
break;
case "activityReportByTestSection":
getFromOpenElisServer(
"/rest/user-test-sections/" + Roles.REPORTS,
setTempData,
);
break;
default:
break;
if (props.report === "CISampleRoutineExport") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just put this under the existing swtich statement

getFromOpenElisServer("/rest/user-test-sections/ALL", setList);
} else {
switch (props.report) {
case "activityReportByTest":
getFromOpenElisServer("/rest/test-list", setList);
break;
case "activityReportByPanel":
getFromOpenElisServer("/rest/panels", setList);
break;
case "activityReportByTestSection":
getFromOpenElisServer(
"/rest/user-test-sections/" + Roles.REPORTS,
setList,
);
break;
}
}
};

console.log("props", props);
if (
props.report === "activityReportByTest" ||
props.report === "activityReportByPanel" ||
props.report === "activityReportByTestSection"
props.report === "activityReportByTestSection" ||
props.report === "CISampleRoutineExport"
) {
fetchData();
}
Expand Down Expand Up @@ -208,8 +207,44 @@ const ReportByDate = (props) => {
{" "}
<br />
</Column>
<Column lg={8} md={8} sm={4}>
{list && list.length > 0 && (

{props.report === "CISampleRoutineExport" && list && list.length > 0 && (
<Column lg={8} md={8} sm={4}>
<Select
id="labUnit"
labelText={intl.formatMessage({
id: "label.form.labunit",
defaultMessage: "Lab Unit"
})}
value={reportFormValues.labUnit}
onChange={(e) =>
setReportFormValues({
...reportFormValues,
labUnit: e.target.value,
})
}
>
<SelectItem
key={"emptyselect"}
value={""}
text={intl.formatMessage({
id: "label.form.alllabunits",
defaultMessage: "All Lab Units"
})}
/>
{list.map((unit) => (
<SelectItem
key={unit.id}
value={unit.id}
text={unit.value}
/>
))}
</Select>
</Column>
)}

{props.report !== "CISampleRoutineExport" && list && list.length > 0 && (
<Column lg={8} md={8} sm={4}>
<Select
id="type"
labelText={intl.formatMessage({
Expand All @@ -236,8 +271,8 @@ const ReportByDate = (props) => {
/>
))}
</Select>
)}
</Column>
</Column>
)}
</Grid>
<br />
<Section>
Expand Down Expand Up @@ -268,4 +303,4 @@ const ReportByDate = (props) => {
);
};

export default ReportByDate;
export default ReportByDate;
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@
* @since Mar 18, 2011
*/
public abstract class CSVRoutineColumnBuilder {
protected String selectedLabUnit;

// Add getter/setter
public void setLabUnit(String labUnit) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a wrong getter name

this.selectedLabUnit = labUnit;
}

public String getLabUnit() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worng setter naming

return selectedLabUnit;
}

// these are used so we are not passing around strings in the methods that are
// appended to sql
Expand Down Expand Up @@ -529,7 +539,11 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat
// String excludeAnalytes = getExcludedAnalytesSet();
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 ");
+ ".* " + " 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,6 +562,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 "
+ 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
Loading