-
Notifications
You must be signed in to change notification settings - Fork 251
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
MF-795: Add swr to vitals widget #405
Conversation
view: string; | ||
vitals: PatientVitals; | ||
toggleView(): void; | ||
showDetails: boolean; | ||
showRecordVitals: boolean; | ||
} | ||
|
||
const VitalsHeaderStateTitle: React.FC<VitalsHeaderStateTitleProps> = ({ | ||
const VitalsHeaderTitle: React.FC<VitalsHeaderTitleProps> = ({ |
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.
This is still a funny name. Is it a header, or a title? Or a header tile? Or the title of the header, because for some reason the body has its own title, which is different??
const systolicBloodPressureData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.systolicBloodPressureUuid), | ||
); | ||
const diastolicBloodPressureData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.diastolicBloodPressureUuid), | ||
); | ||
const pulseData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.pulseUuid), | ||
); | ||
const temperatureData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.temperatureUuid), | ||
); | ||
const oxygenSaturationData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.oxygenSaturationUuid), | ||
); | ||
const heightData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.heightUuid), | ||
); | ||
const weightData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.weightUuid), | ||
); | ||
const respiratoryRateData = observations?.filter((obs) => | ||
obs.code.coding.some((sys) => sys.code === config.concepts.respiratoryRateUuid), | ||
); |
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.
I think this was better as it was before. That filterByConceptUuid
function could even be defined as an arrow function right on top of these lines, so it's all right there.
|
||
const tableHeaders = [ | ||
{ key: 'date', header: 'Date and time', isSortable: true }, | ||
{ | ||
key: 'bloodPressure', | ||
header: withUnit('BP', bloodPressureUnit), | ||
header: withUnit('BP', conceptUnits ? conceptUnits[0] : ''), |
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.
header: withUnit('BP', conceptUnits ? conceptUnits[0] : ''), | |
header: withUnit('BP', conceptUnits?.[0] ?? ''), |
Right? Also I wonder if withUnit
should (or does?) just treat undefined
like ''
. Then it could be
header: withUnit('BP', conceptUnits ? conceptUnits[0] : ''), | |
header: withUnit('BP', conceptUnits?.[0]), |
<div className={styles.row}> | ||
<VitalsHeaderItem | ||
unitName={t('temperatureAbbreviated', 'Temp')} | ||
unitSymbol={conceptUnits ? conceptUnits[2] : ''} |
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.
At some point (not in this PR) I think the vitals will need some refactoring to make it more robust, especially once we want to make it configurable. e.g. having these really arbitrary indexes tied to specific vitals is not awesome.
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.
A few small things, nothing major. I think the major thing is that all this vitals stuff will need some refactoring in the near future. And the situation with the units is bad.
Nice work, generally
Feel free to resolve conflicts, address feedback at your discretion, and merge. |
Improvements to the VitalsOverview involving the use of the `withUnit` function. Additionally, this commit adds improvements to the Vitals resource that include: - Better type annotations. - Inlining the `filterByConceptUuid` function implementation in the `useVitals` hook. - Invoking `formatVitals` directly on the results of calling `filterByConceptUuid`. This has the corollary of reducing the number of lines of repetitive code significantly.
Thanks, @brandones, for your review and suggestions. Unfortunately, the scope of this PR ended up far exceeding its original intention. I agree about refactoring being required very shortly - especially around the units stuff. The latest commit addresses the issues around the use of |
Requirements
Summary
Apologies for the huge diff.
This PR:
useVitalsConceptMetadata
(a hook for fetching vitals and biometrics concept units and metadata) toesm-patient-common-lib
so it can be reused by both the vitals and biometrics widgets. Also moves thewithUnit
helper function which renders a label for a vital sign along with its associated unit.Issue
https://issues.openmrs.org/browse/MF-795