-
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
(refactor) Remove the dependency of using patientUuid
from the URL
#2080
Conversation
Size Change: -373 kB (-2.3%) Total Size: 15.9 MB
ℹ️ View Unchanged
|
4f8d631
to
40bc433
Compare
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.
Thanks @vasharma05 , generally looks great.
I just have a few comments.
export function getPatientUuidFromUrl(): string { | ||
const match = /\/patient\/([a-zA-Z0-9\-]+)\/?/.exec(location.pathname); | ||
return match && match[1]; | ||
const patientUuidFromUrl = match && match[1]; | ||
return patientUuidFromUrl || getPatientChartStore().getState().patientUuid; |
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.
The function name getPatientUuidFromUrl
suggests it only retrieves the UUID from the URL, but it actually has a fallback behavior that gets the UUID from the store state. I suggest either:
- Rename the function to better reflect its complete behavior, e.g.,
getActivePatientUuid
orresolvePatientUuid
, since it resolves the patient UUID from either the URL or store - OR split this into two separate concerns if these use cases need to be handled differently
This would make the function's behavior more predictable from its name
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.
Yes @usamaidrsk!
I agree with you on this, and am seeking @denniskigen's advice too. But do note that this is an API in the Patient Common Lib, and changing the function will require updating all the places this function is being used, and hence will become a breaking change, since this will also affect other implementations to update their code when released.
One thing is, we can deprecate this function and in the message we can ask them to update the API in their respective code. This way, it'll not be a breaking change.
Thanks!
const patientChartStoreName = 'patient-chart-global-store'; | ||
|
||
const patientChartStore = createGlobalStore<PatientChartStore>(patientChartStoreName, { | ||
patientUuid: '', |
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.
Shouldn't this be patientUuid: null
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.
Right!
041ee42
to
8673aa8
Compare
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.
Thanks @vasharma05 LGTM.
Could you check why the E2E tests are failing
7071e79
to
d7eadaf
Compare
…penmrs#2080) * Introduce patient chart store for handling patient chart related state * Replace instances of getPatientUuidFromUrl * Update function name
Requirements
Summary
This PR aims to refactor the code locations that retrieve the patient UUID from the URL of the patient chart. The primary motivation for this refactor is that the extensions, widgets, and workspaces utilized in the patient chart are no longer guaranteed to be present in the patient chart. For instance, the Patient chart summary workspaces in the IPD. To reuse these widgets/workspaces in the IPD’s patient summary workspace and potentially in other future locations, I have implemented a global Patient Chart Store, which must be accessible by all components in the patient chart.
I also modified the
getPatientUuidFromUrl
function to get the patient UUID from the URL, but if not present it will look into the store.I also removed the instances where
patientUuid
was being fetched from theusePatient
, which should now be fetched from theusePatientChartStore
hook.Screenshots
None
Related Issue
None
Other