Skip to content

Commit 030b120

Browse files
SteveGT96SteveGT96
andauthored
OH2-264 | Sort table component date fields by date time (#546)
* update(OH2-264): Sort table component date fields by date time * fix(OH2-264): Fix blanc screeen occuring when a table row date value is undefined * update: Show date fields with time in table row detaitls * update(i18n): Rename 'Date (d/m/y)' to 'Date' * fix: Fix table collapse, remove duplicate date in clinic table * update: Update data fields display order and fix some lint warnings * update: Update table to display row details in the labels keys order * update: Add code in clinic data and also display empty fields * update: Restore showEmptyCells to false in clinic --------- Co-authored-by: SteveGT96 <steve.tsala@intesys.it>
1 parent ae27ea3 commit 030b120

File tree

20 files changed

+121
-79
lines changed

20 files changed

+121
-79
lines changed

src/components/accessories/admission/admissionTable/AdmissionTable.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useDispatch, useSelector } from "react-redux";
77
import { IState } from "../../../../types";
88
import { AdmissionDTO } from "../../../../generated";
99
import { getPatientAdmissions } from "../../../../state/admissions/actions";
10-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
10+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1111
import { usePermission } from "../../../../libraries/permissionUtils/usePermission";
1212

1313
interface IOwnProps {
@@ -26,6 +26,7 @@ const PatientAdmissionTable: FunctionComponent<IOwnProps> = ({
2626
const dateFields = ["admDate", "disDate"];
2727

2828
const label = {
29+
id: t("admission.code"),
2930
admDate: t("admission.admDate"),
3031
disDate: t("admission.disDate"),
3132
admType: t("admission.admType"),
@@ -69,8 +70,8 @@ const PatientAdmissionTable: FunctionComponent<IOwnProps> = ({
6970
return data.map((item) => {
7071
return {
7172
id: item.id ?? "",
72-
admDate: item.admDate ? renderDate(item.admDate) : "",
73-
disDate: item.disDate ? renderDate(item.disDate) : "",
73+
admDate: item.admDate ? renderDateTime(item.admDate) : "",
74+
disDate: item.disDate ? renderDateTime(item.disDate) : "",
7475
admType: item.admType?.description ?? "",
7576
diseaseIn: item.diseaseIn?.description ?? "",
7677
transUnit: item.transUnit,

src/components/accessories/currentAdmission/CurrentAdmission.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { FunctionComponent, useEffect, useState } from "react";
2-
import { useTranslation } from "react-i18next";
32
import { useDispatch, useSelector } from "react-redux";
4-
import { AdmissionDTO, OpdDTO, PatientDTO } from "../../../generated";
3+
import { AdmissionDTO, OpdDTO } from "../../../generated";
54
import { updateAdmission } from "../../../state/admissions/actions";
65
import { IState } from "../../../types";
76
import { useFields } from "../admission/useFields";
@@ -52,7 +51,7 @@ export const CurrentAdmission: FunctionComponent<IOwnProps> = ({
5251
if (onEditChange) {
5352
onEditChange(editionMode);
5453
}
55-
}, [editionMode]);
54+
}, [editionMode, onEditChange]);
5655

5756
return (
5857
<div className="currentAdmission">

src/components/accessories/currentAdmission/currentAdmissionData/CurrentAdmissionData.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export const CurrentAdmissionData: FunctionComponent<IOwnProps> = ({
2828
)}
2929
</div>
3030
<div className="currentAdmissionData__content">
31+
{!isEmpty(admission?.admDate) && (
32+
<div className="currentAdmissionData__item">
33+
<span className="item_label">{t("admission.admDate")}</span>
34+
<p className="item_content">{renderDate(admission?.admDate)}</p>
35+
</div>
36+
)}
3137
{!isEmpty(admission?.ward?.description) && (
3238
<div className="currentAdmissionData__item">
3339
<span className="item_label">{t("admission.ward")}</span>
@@ -40,12 +46,6 @@ export const CurrentAdmissionData: FunctionComponent<IOwnProps> = ({
4046
<p className="item_content">{admission?.fhu}</p>
4147
</div>
4248
)}
43-
{!isEmpty(admission?.admDate) && (
44-
<div className="currentAdmissionData__item">
45-
<span className="item_label">{t("admission.admDate")}</span>
46-
<p className="item_content">{renderDate(admission?.admDate)}</p>
47-
</div>
48-
)}
4949
{!isEmpty(admission?.admType?.description) && (
5050
<div className="currentAdmissionData__item">
5151
<span className="item_label">{t("admission.admType")}</span>

src/components/accessories/laboratory/table/ExamTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CustomModal } from "../../customModal/CustomModal";
44
import Table from "../../table/Table";
55
import { IExamTableProps, multipleResultsLabel } from "./types";
66
import "./styles.scss";
7-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
7+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
88
import { LaboratoryDetails } from "../LaboratoryDetails";
99
import { useDispatch, useSelector } from "react-redux";
1010
import { getLabWithRowsByCode } from "../../../../state/laboratories/actions";
@@ -69,7 +69,7 @@ export const ExamTable: FC<IExamTableProps> = ({
6969
results = data.map((e) => {
7070
return {
7171
id: e.laboratoryDTO?.code ?? "",
72-
date: renderDate(e.laboratoryDTO?.labDate ?? ""),
72+
date: renderDateTime(e.laboratoryDTO?.labDate ?? ""),
7373
patName: e.laboratoryDTO?.patName ?? "",
7474
exam:
7575
e.laboratoryDTO?.exam?.description ?? e.laboratoryDTO?.exam ?? "", //The second case should be removed when the api is ready

src/components/accessories/opds/table/OpdTable.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SkeletonLoader from "../../skeletonLoader/SkeletonLoader";
66
import Table from "../../table/Table";
77
import { IOpdTableProps } from "./types";
88
import "./styles.scss";
9-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
9+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1010

1111
export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
1212
const { t } = useTranslation();
@@ -25,6 +25,7 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
2525
const label = {
2626
id: t("opd.code"),
2727
date: t("opd.date"),
28+
nextVisitDate: t("opd.nextvisitdate"),
2829
patientCode: t("opd.patientcode"),
2930
patientName: t("opd.patient"),
3031
sex: t("opd.sex"),
@@ -36,7 +37,6 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
3637
note: t("opd.note"),
3738
referralFrom: t("opd.referralfrom"),
3839
referralTo: t("opd.referralto"),
39-
nextVisitDate: t("opd.nextvisitdate"),
4040
age: t("opd.age"),
4141
ward: t("opd.ward"),
4242
};
@@ -49,16 +49,15 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
4949
"age",
5050
"disease",
5151
];
52-
const [opd, setOpd] = useState({} as OpdDTO);
5352

5453
const formatDataToDisplay = (data: OpdDTO[]) => {
5554
let results: any = [];
5655
if (data)
5756
results = data.map((e) => {
5857
return {
5958
id: e.code ?? "",
60-
date: renderDate(e.date ?? ""),
61-
nextVisitDate: renderDate(e.nextVisitDate ?? ""),
59+
date: renderDateTime(e.date ?? ""),
60+
nextVisitDate: renderDateTime(e.nextVisitDate ?? ""),
6261
patientCode: e.patientCode ?? "",
6362
patientName: e.patientName ?? "",
6463
sex: e.sex ?? "",
@@ -82,9 +81,6 @@ export const OpdTable: FC<IOpdTableProps> = ({ data }) => {
8281
const formattedData: any[] = formatDataToDisplay(data);
8382

8483
const [open, setOpen] = useState(false);
85-
const handleOpen = () => {
86-
setOpen(true);
87-
};
8884

8985
const handleClose = () => {
9086
setOpen(false);

src/components/accessories/patientExams/patientExamRequestsTable/PatientExamRequestsTable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React, { FunctionComponent, useEffect, useRef } from "react";
22
import { useDispatch, useSelector } from "react-redux";
3-
import { LaboratoryDTO, LaboratoryDTOStatusEnum } from "../../../../generated";
3+
import { LaboratoryDTO } from "../../../../generated";
44
import { IState } from "../../../../types";
55
import Table from "../../table/Table";
66
import { useTranslation } from "react-i18next";
77
import { CircularProgress } from "@material-ui/core";
88
import InfoBox from "../../infoBox/InfoBox";
99
import { getLabsRequestByPatientId } from "../../../../state/laboratories/actions";
10-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
10+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1111
import { usePermission } from "../../../../libraries/permissionUtils/usePermission";
1212
import { statusLabel } from "../../laboratory/table/ExamTable";
1313

@@ -60,7 +60,7 @@ const PatientExamRequestsTable: FunctionComponent<IOwnProps> = ({
6060
return data.map((item) => {
6161
return {
6262
code: item.code,
63-
date: item.labDate ? renderDate(item.labDate) : "",
63+
date: item.labDate ? renderDateTime(item.labDate) : "",
6464
status: item.status ? statusLabel(item.status) : "",
6565
exam: item.exam?.description ?? "",
6666
//material: item.material ? t(item.material) : "",

src/components/accessories/patientExams/patientExamsTable/PatientExamsTable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useTranslation } from "react-i18next";
77
import { CircularProgress } from "@material-ui/core";
88
import InfoBox from "../../infoBox/InfoBox";
99
import { getLabsByPatientId } from "../../../../state/laboratories/actions";
10-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
10+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1111
import { usePermission } from "../../../../libraries/permissionUtils/usePermission";
1212
import { statusLabel } from "../../laboratory/table/ExamTable";
1313

@@ -32,7 +32,7 @@ const PatientExamsTable: FunctionComponent<IOwnProps> = ({
3232

3333
const label = {
3434
code: t("common.code"),
35-
labDate: t("lab.date"),
35+
date: t("lab.date"),
3636
exam: t("lab.exam"),
3737
result: t("lab.result"),
3838
note: t("lab.note"),
@@ -63,7 +63,7 @@ const PatientExamsTable: FunctionComponent<IOwnProps> = ({
6363
return {
6464
code: item.laboratoryDTO?.code,
6565
date: item.laboratoryDTO?.labDate
66-
? renderDate(item.laboratoryDTO?.labDate)
66+
? renderDateTime(item.laboratoryDTO?.labDate)
6767
: "",
6868
exam: item.laboratoryDTO?.exam?.description ?? "",
6969
result:

src/components/accessories/patientOPD/patientOPDTable/PatientOPDTable.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import React, { FunctionComponent, useEffect, useRef } from "react";
22
import { useDispatch, useSelector } from "react-redux";
33
import { OpdDTO, OpdWithOperationRowDTO } from "../../../../generated";
4-
import {
5-
getOpds,
6-
getOpdsWithOperationRows,
7-
} from "../../../../state/opds/actions";
4+
import { getOpdsWithOperationRows } from "../../../../state/opds/actions";
85
import { IState } from "../../../../types";
96
import Table from "../../table/Table";
107
import { CircularProgress } from "@material-ui/core";
118
import { useTranslation } from "react-i18next";
129
import InfoBox from "../../infoBox/InfoBox";
13-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
10+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1411
import { usePermission } from "../../../../libraries/permissionUtils/usePermission";
1512
interface IOwnProps {
1613
shouldUpdateTable: boolean;
@@ -61,7 +58,7 @@ const PatientOPDTable: FunctionComponent<IOwnProps> = ({
6158
results = data.map((item) => {
6259
return {
6360
code: item.opdDTO?.code,
64-
date: item.opdDTO?.date ? renderDate(item.opdDTO.date) : "",
61+
date: item.opdDTO?.date ? renderDateTime(item.opdDTO.date) : "",
6562
disease: item.opdDTO?.disease?.description || "",
6663
ward: item.opdDTO?.ward.description,
6764
disease2: item.opdDTO?.disease2?.description || "",

src/components/accessories/patientOperation/operationTable/OperationRowTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CircularProgress } from "@material-ui/core";
66
import { useDispatch, useSelector } from "react-redux";
77
import { IState } from "../../../../types";
88
import { OperationRowDTO } from "../../../../generated";
9-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
9+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1010
import { getOperationsByAdmissionId } from "../../../../state/operations/actions";
1111
import { usePermission } from "../../../../libraries/permissionUtils/usePermission";
1212

@@ -59,7 +59,7 @@ const PatientOperationRowTable: FunctionComponent<IOwnProps> = ({
5959
return data.map((item) => {
6060
return {
6161
id: item.id,
62-
opDate: item.opDate ? renderDate(item.opDate) : "",
62+
opDate: item.opDate ? renderDateTime(item.opDate) : "",
6363
opResult: t("operation.result." + item.opResult ?? "unknown"),
6464
remarks: item.remarks ?? "",
6565
operation: item.operation?.description ?? "",

src/components/accessories/patientSummary/patientSummaryByDate/PatientSummaryByDate.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const PatientSummaryByDate: FunctionComponent<TProps> = ({
4343
rowsPerPage={ORDER_BY_DATE_PAGE_SIZE}
4444
isCollapsabile={true}
4545
showEmptyCell={false}
46+
detailsExcludedFields={["date"]}
4647
/>
4748
) : (
4849
<CircularProgress

src/components/accessories/patientSummary/patientSummaryByType/PatientSummaryByType.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
6060
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
6161
isCollapsabile={true}
6262
showEmptyCell={false}
63+
detailsExcludedFields={["date"]}
6364
/>
6465
</div>
6566
)}
@@ -84,6 +85,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
8485
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
8586
isCollapsabile={true}
8687
showEmptyCell={false}
88+
detailsExcludedFields={["date"]}
8789
/>
8890
</div>
8991
)}
@@ -107,6 +109,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
107109
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
108110
isCollapsabile={true}
109111
showEmptyCell={false}
112+
detailsExcludedFields={["date"]}
110113
/>
111114
</div>
112115
)}
@@ -131,6 +134,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
131134
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
132135
isCollapsabile={true}
133136
showEmptyCell={false}
137+
detailsExcludedFields={["date"]}
134138
/>
135139
</div>
136140
)}
@@ -153,6 +157,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
153157
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
154158
isCollapsabile={true}
155159
showEmptyCell={false}
160+
detailsExcludedFields={["date"]}
156161
/>
157162
</div>
158163
)}
@@ -175,6 +180,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
175180
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
176181
isCollapsabile={true}
177182
showEmptyCell={false}
183+
detailsExcludedFields={["date"]}
178184
/>
179185
</div>
180186
)}
@@ -198,6 +204,7 @@ const PatientSummaryByType: FunctionComponent<TProps> = ({
198204
rowsPerPage={ORDER_BY_TYPE_PAGE_SIZE}
199205
isCollapsabile={true}
200206
showEmptyCell={false}
207+
detailsExcludedFields={["date"]}
201208
/>
202209
</div>
203210
)}

src/components/accessories/patientSummary/useSummaryMetaData.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@ import { useTranslation } from "react-i18next";
33
const useSummaryMetaData = () => {
44
const { t } = useTranslation();
55
const labels = {
6+
id: t("common.code"),
7+
code: t("common.code"),
8+
pex_ID: t("common.code"),
9+
therapyID: t("common.code"),
610
date: t("common.date"),
711
visitDate: t("opd.date"),
8-
type: t("common.type"),
12+
labDate: t("lab.date"),
13+
opdDate: t("opd.date"),
14+
startDate: t("therapy.startDate"),
15+
endDate: t("therapy.endDate"),
916
opDate: t("operation.opDate"),
10-
ward: t("admission.ward"),
1117
admDate: t("admission.admDate"),
18+
disDate: t("admission.disDate"),
19+
type: t("common.type"),
1220
admType: t("admission.admType"),
1321
disType: t("admission.disType"),
14-
disDate: t("admission.disDate"),
22+
ward: t("admission.ward"),
1523
diseaseIn: t("admission.diseaseIn"),
1624
diseaseOut1: t("admission.diseaseOut1"),
1725
diseaseOut2: t("admission.diseaseOut2"),
@@ -40,9 +48,6 @@ const useSummaryMetaData = () => {
4048
pex_note: t("examination.note"),
4149
exam: t("lab.exam"),
4250
//material: t("lab.material"),
43-
labDate: t("lab.date"),
44-
startDate: t("therapy.startDate"),
45-
endDate: t("therapy.endDate"),
4651
qty: t("therapy.quantity"),
4752
freqInDay: t("therapy.frequencyInDay"),
4853
freqInPeriod: t("therapy.frequencyInPeriod"),

src/components/accessories/patientTherapy/patientTherapyTable/PatientTherapyTable.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getTherapiesByPatientId } from "../../../../state/therapies/actions";
77
import { useTranslation } from "react-i18next";
88
import { CircularProgress } from "@material-ui/core";
99
import InfoBox from "../../infoBox/InfoBox";
10-
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
10+
import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting";
1111
import { getMedicals } from "../../../../state/medicals/actions";
1212
import { formatDateDiff } from "../../../../libraries/formatUtils/formatDateDiff";
1313
import moment from "moment";
@@ -86,8 +86,8 @@ const PatientTherapyTable: FunctionComponent<IOwnProps> = ({
8686
return {
8787
therapyID: item.therapyID,
8888
medicalId: medical ? medical.description : item.medicalId,
89-
startDate: item.startDate ? renderDate(item.startDate) : "",
90-
endDate: item.endDate ? renderDate(item.endDate) : "",
89+
startDate: item.startDate ? renderDateTime(item.startDate) : "",
90+
endDate: item.endDate ? renderDateTime(item.endDate) : "",
9191
qty: item.qty,
9292
freqInDay: item.freqInDay,
9393
freqInPeriod: item.freqInPeriod,

0 commit comments

Comments
 (0)