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 all 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
9 changes: 5 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
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"
}
}
139 changes: 89 additions & 50 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,36 +207,76 @@ const ReportByDate = (props) => {
{" "}
<br />
</Column>
<Column lg={8} md={8} sm={4}>
{list && list.length > 0 && (
<Select
id="type"
labelText={intl.formatMessage({
id: "label.form.searchby",
})}
value={reportFormValues.value}
onChange={(e) =>
setReportFormValues({
...reportFormValues,
value: e.target.value,
})
}
>
<SelectItem
key={"emptyselect"}
value={""}
text="Select Test Type"
/>
{list.map((statusOption) => (

{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.

i think this is duplication code for the of dropdown

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={statusOption.id}
value={statusOption.id}
text={statusOption.value}
key={"emptyselect"}
value={""}
text={intl.formatMessage({
id: "label.form.alllabunits",
defaultMessage: "All Lab Units",
})}
/>
))}
</Select>
{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({
id: "label.form.searchby",
})}
value={reportFormValues.value}
onChange={(e) =>
setReportFormValues({
...reportFormValues,
value: e.target.value,
})
}
>
<SelectItem
key={"emptyselect"}
value={""}
text="Select Test Type"
/>
{list.map((statusOption) => (
<SelectItem
key={statusOption.id}
value={statusOption.id}
text={statusOption.value}
/>
))}
</Select>
</Column>
)}
</Column>
</Grid>
<br />
<Section>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans",
"Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Expand Down
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 @@ -530,6 +540,11 @@ 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 +563,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
Loading