-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce patient chart store for handling patient chart related state
- Loading branch information
1 parent
f9a6f9f
commit 40bc433
Showing
9 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
packages/esm-patient-common-lib/src/get-patient-uuid-from-url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import { getPatientChartStore } from './store/patient-chart-store'; | ||
|
||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/esm-patient-common-lib/src/store/patient-chart-store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { createGlobalStore, useStore } from '@openmrs/esm-framework'; | ||
|
||
export interface PatientChartStore { | ||
patientUuid: string; | ||
} | ||
|
||
const patientChartStoreName = 'patient-chart-global-store'; | ||
|
||
const patientChartStore = createGlobalStore<PatientChartStore>(patientChartStoreName, { | ||
patientUuid: '', | ||
}); | ||
|
||
export function getPatientChartStore() { | ||
return patientChartStore; | ||
} | ||
|
||
export function usePatientChartStore() { | ||
return useStore(patientChartStore); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters