-
Notifications
You must be signed in to change notification settings - Fork 248
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
(fix)O3-3046: Allow sorting vitals, biometrics and conditions rows based on different sort functions #1779
(fix)O3-3046: Allow sorting vitals, biometrics and conditions rows based on different sort functions #1779
Changes from all commits
da37c65
650e5f3
011bc8a
82a8e73
7b2118b
b1b000b
1ca5278
82c9bf3
da21434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import { type ConfigObject } from '../config-schema'; | |
import BiometricsChart from './biometrics-chart.component'; | ||
import PaginatedBiometrics from './paginated-biometrics.component'; | ||
import styles from './biometrics-base.scss'; | ||
import type { BiometricsTableHeader, BiometricsTableRow } from './types'; | ||
|
||
interface BiometricsBaseProps { | ||
pageSize: number; | ||
|
@@ -36,28 +37,50 @@ const BiometricsBase: React.FC<BiometricsBaseProps> = ({ patientUuid, pageSize, | |
[config, currentVisit], | ||
); | ||
|
||
const tableHeaders = [ | ||
{ key: 'date', header: t('dateAndTime', 'Date and time'), isSortable: true }, | ||
{ key: 'weight', header: withUnit(t('weight', 'Weight'), conceptUnits.get(config.concepts.weightUuid) ?? '') }, | ||
{ key: 'height', header: withUnit(t('height', 'Height'), conceptUnits.get(config.concepts.heightUuid) ?? '') }, | ||
{ key: 'bmi', header: `${t('bmi', 'BMI')} (${bmiUnit})` }, | ||
const tableHeaders: Array<BiometricsTableHeader> = [ | ||
{ | ||
key: 'muac', | ||
key: 'dateRender', | ||
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. What's the rationale behind the 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. There are 2 kinds of data for a column (say
Now, if we see, the user/ datatable sees the The |
||
header: t('dateAndTime', 'Date and time'), | ||
isSortable: true, | ||
sortFunc: (valueA, valueB) => new Date(valueA.date).getTime() - new Date(valueB.date).getTime(), | ||
}, | ||
{ | ||
key: 'weightRender', | ||
header: withUnit(t('weight', 'Weight'), conceptUnits.get(config.concepts.weightUuid) ?? ''), | ||
isSortable: true, | ||
sortFunc: (valueA, valueB) => (valueA.weight && valueB.weight ? valueA.weight - valueB.weight : 0), | ||
}, | ||
{ | ||
key: 'heightRender', | ||
header: withUnit(t('height', 'Height'), conceptUnits.get(config.concepts.heightUuid) ?? ''), | ||
isSortable: true, | ||
sortFunc: (valueA, valueB) => (valueA.height && valueB.height ? valueA.height - valueB.height : 0), | ||
}, | ||
{ | ||
key: 'bmiRender', | ||
header: `${t('bmi', 'BMI')} (${bmiUnit})`, | ||
isSortable: true, | ||
sortFunc: (valueA, valueB) => (valueA.bmi && valueB.bmi ? valueA.bmi - valueB.bmi : 0), | ||
}, | ||
{ | ||
key: 'muacRender', | ||
header: withUnit(t('muac', 'MUAC'), conceptUnits.get(config.concepts.midUpperArmCircumferenceUuid) ?? ''), | ||
isSortable: true, | ||
sortFunc: (valueA, valueB) => (valueA.muac && valueB.muac ? valueA.muac - valueB.muac : 0), | ||
}, | ||
]; | ||
|
||
const tableRows = useMemo( | ||
const tableRows: Array<BiometricsTableRow> = useMemo( | ||
() => | ||
biometrics?.map((biometricsData, index) => { | ||
return { | ||
...biometricsData, | ||
id: `${index}`, | ||
date: formatDatetime(parseDate(biometricsData.date.toString()), { mode: 'wide' }), | ||
weight: biometricsData.weight ?? '--', | ||
height: biometricsData.height ?? '--', | ||
bmi: biometricsData.bmi ?? '--', | ||
muac: biometricsData.muac ?? '--', | ||
dateRender: formatDatetime(parseDate(biometricsData.date.toString()), { mode: 'wide' }), | ||
weightRender: biometricsData.weight ?? '--', | ||
heightRender: biometricsData.height ?? '--', | ||
bmiRender: biometricsData.bmi ?? '--', | ||
muacRender: biometricsData.muac ?? '--', | ||
}; | ||
}), | ||
[biometrics], | ||
|
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.
Would something like
useSortedConditionTableRows
describe this hook better?