Skip to content

Commit

Permalink
fix home dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzy11 committed Aug 9, 2023
1 parent 88c58db commit 7161bc7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 41 deletions.
7 changes: 6 additions & 1 deletion frontend/src/components/home/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Icon, Link, Grid, Tile, ClickableTile, Column, ExpandableTile, TileAboveTheFoldContent, TileBelowTheFoldContent } from '@carbon/react';
import { Icon, Link, Grid, Tile, ClickableTile, Column, ExpandableTile, TileAboveTheFoldContent, TileBelowTheFoldContent ,Loading} from '@carbon/react';
import './Dashboard.css';
import { ArrowUpRight } from '@carbon/react/icons';
import { useContext, useState, useEffect, useRef } from "react";
Expand All @@ -16,6 +16,7 @@ interface Tile {
const HomeDashBoard: React.FC<DashBoardProps> = () => {

const [tileList, setTileList] = useState([Tile]);
const [loading, setLoading] = useState(true);
const componentMounted = useRef(true);

useEffect(() => {
Expand All @@ -30,10 +31,14 @@ const HomeDashBoard: React.FC<DashBoardProps> = () => {
const loadTiles = (tiles) => {
if (componentMounted.current) {
setTileList(tiles);
setLoading(false);
}
}
return (
<>
{loading && (
<Loading></Loading>
)}
<div className="dashboard-container">
{tileList.map((tile, index) => (
<ClickableTile key={index} className="dashboard-tile">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,6 @@ List<Analysis> getAnalysisForSiteBetweenResultDates(String referringSiteId, Loca

List<Analysis> getStudyAnalysisForSiteBetweenResultDates(String referringSiteId, LocalDate lowerDate,
LocalDate upperDate);

List<Analysis> getAnalysisCompletedOnByStatusId(Date completedDate, String statusId) throws LIMSRuntimeException;;
}
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,28 @@ public List<Analysis> getAnalysisStartedOnExcludedByStatusId(Date collectionDate
return null;
}

@Override
@Transactional(readOnly = true)
public List<Analysis> getAnalysisCompletedOnByStatusId(Date completedDate, String statusId)
throws LIMSRuntimeException {


String sql = "from Analysis a where a.releasedDate = :releasedDate and a.statusId = :statusId ";

try {
Query<Analysis> query = entityManager.unwrap(Session.class).createQuery(sql, Analysis.class);
query.setParameter("releasedDate", completedDate);
query.setParameter("statusId", Integer.parseInt(statusId));

List<Analysis> analysisList = query.list();
return analysisList;
} catch (HibernateException e) {
handleException(e, "getAnalysisStartedOnExcludedByStatusId");
}

return null;
}

@Override

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,6 @@ List<Analysis> getAnalysisForSiteBetweenResultDates(String referringSiteId, Loca

List<Analysis> getStudyAnalysisForSiteBetweenResultDates(String referringSiteId, LocalDate lowerDate,
LocalDate upperDate);

List<Analysis> getAnalysisCompletedOnByStatusId(Date completedDate, String statusId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -741,4 +741,9 @@ public List<Analysis> getStudyAnalysisForSiteBetweenResultDates(String referring
LocalDate upperDate) {
return baseObjectDAO.getStudyAnalysisForSiteBetweenResultDates(referringSiteId, lowerDate, upperDate);
}

@Override
public List<Analysis> getAnalysisCompletedOnByStatusId(Date completedDate, String statusId) {
return baseObjectDAO.getAnalysisCompletedOnByStatusId(completedDate ,statusId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ public List<DashBoardTile> getDasBoardTiles() {
case ORDERS_COMPLETED_TODAY:
//Completed Today
dashBoardTiles.add(new DashBoardTile("Orders Completed Today", "Total Orders Completed Today",
analysisService
.getAnalysisStartedOnRangeByStatusId(DateUtil.getNowAsSqlDate(),
DateUtil.getNowAsSqlDate(), iStatusService.getStatusID(AnalysisStatus.Finalized))
.size()));
analysisService.getAnalysisCompletedOnByStatusId(DateUtil.getNowAsSqlDate(),
iStatusService.getStatusID(AnalysisStatus.Finalized)).size()));
break;
case ORDERS_PATIALLY_COMPLETED_TODAY:
// Partially Completed Today
dashBoardTiles.add(new DashBoardTile("Patiallly Completed Today", "Total Orders Completed Today",
analysisService
.getAnalysisStartedOnRangeByStatusId(DateUtil.getNowAsSqlDate(),
DateUtil.getNowAsSqlDate(), iStatusService.getStatusID(AnalysisStatus.Finalized))
.size()));
Set<Integer> statusIds2 = new HashSet<>();
statusIds2.add(Integer.parseInt(iStatusService.getStatusID(AnalysisStatus.SampleRejected)));
statusIds2.add(Integer.parseInt(iStatusService.getStatusID(AnalysisStatus.Finalized)));
dashBoardTiles.add(
new DashBoardTile("Patiallly Completed Today", "Total Orders Completed Today", analysisService
.getAnalysisStartedOnExcludedByStatusId(DateUtil.getNowAsSqlDate(), statusIds2).size()));
break;

case ORDERS_ENTERED_BY_USER_TODAY:
//orders entered By user Today
Set<Integer> statusIds = new HashSet<>();
Expand Down Expand Up @@ -111,8 +111,8 @@ public List<DashBoardTile> getDasBoardTiles() {
}

private double calculateAverageTime() {
List<Analysis> analyses = analysisService.getAnalysisStartedOnRangeByStatusId(DateUtil.getNowAsSqlDate(),
DateUtil.getNowAsSqlDate(), iStatusService.getStatusID(AnalysisStatus.Finalized));
List<Analysis> analyses = analysisService.getAnalysisCompletedOnByStatusId(DateUtil.getNowAsSqlDate(),
iStatusService.getStatusID(AnalysisStatus.Finalized));

List<Long> hours = new ArrayList<>();
analyses.forEach(analysis -> {
Expand All @@ -135,8 +135,8 @@ private double calculateAverageTime() {
}

private int analysesWithDelayedTurnAroundTime() {
List<Analysis> analyses = analysisService.getAnalysisStartedOnRangeByStatusId(DateUtil.getNowAsSqlDate(),
DateUtil.getNowAsSqlDate(), iStatusService.getStatusID(AnalysisStatus.Finalized));
List<Analysis> analyses = analysisService.getAnalysisCompletedOnByStatusId(DateUtil.getNowAsSqlDate(),
iStatusService.getStatusID(AnalysisStatus.Finalized));

List<Analysis> delayedAnalyses = new ArrayList<>();
analyses.forEach(analysis -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,44 +444,49 @@ private List<Analysis> handleAutomaticReflexes(List<Analysis> parentAnalysisList

private List<TestReflex> applyDictionaryRelationRulesForReflex(Result result) {
List<TestReflex> reflexTests = new ArrayList<>();

reflexResolver.getTestReflexsByAnalyteAndTest(result).forEach(reflexTest -> {
switch (reflexTest.getRelation()) {
case EQUALS:
if (reflexTest.getTestResult().getValue().equals(result.getValue())) {
reflexTests.add(reflexTest);
}
break;
case NOT_EQUALS:
if (!(reflexTest.getTestResult().getValue().equals(result.getValue()))) {
reflexTests.add(reflexTest);
}
break;
case INSIDE_NORMAL_RANGE:
List<ResultLimit> resultLimits = SpringContext.getBean(ResultLimitService.class).getResultLimits(result.getTestResult().getTest());
if(!resultLimits.isEmpty() && StringUtils.isNotBlank(resultLimits.get(0).getDictionaryNormalId())){
if (result.getValue().equals(resultLimits.get(0).getDictionaryNormalId())) {
if (reflexTest.getRelation() != null) {
switch (reflexTest.getRelation()) {
case EQUALS:
if (reflexTest.getTestResult().getValue().equals(result.getValue())) {
reflexTests.add(reflexTest);
}
}
break;
case OUTSIDE_NORMAL_RANGE:
List<ResultLimit> limits = SpringContext.getBean(ResultLimitService.class).getResultLimits(result.getTestResult().getTest());
if(!limits.isEmpty() && StringUtils.isNotBlank(limits.get(0).getDictionaryNormalId())){
if (!(result.getValue().equals(limits.get(0).getDictionaryNormalId()))) {
break;
case NOT_EQUALS:
if (!(reflexTest.getTestResult().getValue().equals(result.getValue()))) {
reflexTests.add(reflexTest);
}
}
break;
default :
break;
break;
case INSIDE_NORMAL_RANGE:
List<ResultLimit> resultLimits = SpringContext.getBean(ResultLimitService.class)
.getResultLimits(result.getTestResult().getTest());
if (!resultLimits.isEmpty() && StringUtils.isNotBlank(resultLimits.get(0).getDictionaryNormalId())) {
if (result.getValue().equals(resultLimits.get(0).getDictionaryNormalId())) {
reflexTests.add(reflexTest);
}
}
break;
case OUTSIDE_NORMAL_RANGE:
List<ResultLimit> limits = SpringContext.getBean(ResultLimitService.class)
.getResultLimits(result.getTestResult().getTest());
if (!limits.isEmpty() && StringUtils.isNotBlank(limits.get(0).getDictionaryNormalId())) {
if (!(result.getValue().equals(limits.get(0).getDictionaryNormalId()))) {
reflexTests.add(reflexTest);
}
}
break;
default:
break;
}
}
});
return reflexTests;
}

private Boolean applyNumericRelationRulesForReflex(TestReflex reflexTest, TestReflexBean reflexBean) {

if(reflexTest.getRelation() == null){
return false;
}
switch (reflexTest.getRelation()) {
case EQUALS:
return Double.valueOf(reflexTest.getNonDictionaryValue())
Expand Down Expand Up @@ -518,6 +523,9 @@ private Boolean applyNumericRelationRulesForReflex(TestReflex reflexTest, TestRe
}

private Boolean applyTextRelationRulesForReflex(TestReflex reflexTest, TestReflexBean reflexBean) {
if(reflexTest.getRelation() == null){
return false;
}
switch (reflexTest.getRelation()) {
case EQUALS:
return reflexTest.getNonDictionaryValue().equals(reflexBean.getResult().getValue());
Expand Down

0 comments on commit 7161bc7

Please sign in to comment.