-
Notifications
You must be signed in to change notification settings - Fork 259
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -27,6 +28,7 @@ const ReportByDate = (props) => { | |
startDate: null, | ||
endDate: null, | ||
value: "", | ||
labUnit: "", | ||
error: null, | ||
}); | ||
|
||
|
@@ -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`; | ||
} | ||
|
@@ -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") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
} | ||
|
@@ -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({ | ||
|
@@ -236,8 +271,8 @@ const ReportByDate = (props) => { | |
/> | ||
))} | ||
</Select> | ||
)} | ||
</Column> | ||
</Column> | ||
)} | ||
</Grid> | ||
<br /> | ||
<Section> | ||
|
@@ -268,4 +303,4 @@ const ReportByDate = (props) => { | |
); | ||
}; | ||
|
||
export default ReportByDate; | ||
export default ReportByDate; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,16 @@ | |
* @since Mar 18, 2011 | ||
*/ | ||
public abstract class CSVRoutineColumnBuilder { | ||
protected String selectedLabUnit; | ||
|
||
// Add getter/setter | ||
public void setLabUnit(String labUnit) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a wrong getter name |
||
this.selectedLabUnit = labUnit; | ||
} | ||
|
||
public String getLabUnit() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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" | ||
|
@@ -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 | ||
|
There was a problem hiding this comment.
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 ??
There was a problem hiding this comment.
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