@openmrs/esm-react-utils 6.3.1-pre.3136 → 6.3.1-pre.3140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/useVisit.js +2 -2
- package/dist/useVisitContextStore.js +7 -3
- package/package.json +12 -12
- package/src/useVisit.ts +2 -2
- package/src/useVisitContextStore.ts +7 -5
package/.turbo/turbo-build.log
CHANGED
package/dist/useVisit.js
CHANGED
|
@@ -42,8 +42,8 @@ dayjs.extend(isToday);
|
|
|
42
42
|
]);
|
|
43
43
|
const previousCurrentVisit = useRef(null);
|
|
44
44
|
useEffect(()=>{
|
|
45
|
-
// if an active visit is created
|
|
46
|
-
if (!activeIsValidating && activeVisit &&
|
|
45
|
+
// if an active visit is created for the visit store patient and they have no visit in context, set the context to the active visit
|
|
46
|
+
if (!activeIsValidating && activeVisit && visitStorePatientUuid === patientUuid && manuallySetVisitUuid === null) {
|
|
47
47
|
setVisitContext(activeVisit);
|
|
48
48
|
}
|
|
49
49
|
if (!retroIsValidating) {
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { useEffect, useId } from "react";
|
|
2
2
|
import { getVisitStore } from "@openmrs/esm-emr-api";
|
|
3
3
|
import { useStoreWithActions } from "./useStore.js";
|
|
4
|
-
// TODO: add better typing with `satisfies` keyword when we upgrade typescript
|
|
5
4
|
const visitContextStoreActions = {
|
|
6
5
|
setVisitContext (_, newSelectedVisit) {
|
|
6
|
+
if (newSelectedVisit == null) {
|
|
7
|
+
return {
|
|
8
|
+
manuallySetVisitUuid: null
|
|
9
|
+
};
|
|
10
|
+
}
|
|
7
11
|
return {
|
|
8
|
-
manuallySetVisitUuid: newSelectedVisit
|
|
9
|
-
patientUuid: newSelectedVisit
|
|
12
|
+
manuallySetVisitUuid: newSelectedVisit.uuid,
|
|
13
|
+
patientUuid: newSelectedVisit.patient?.uuid
|
|
10
14
|
};
|
|
11
15
|
},
|
|
12
16
|
mutateVisit (currState) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-react-utils",
|
|
3
|
-
"version": "6.3.1-pre.
|
|
3
|
+
"version": "6.3.1-pre.3140",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "React utilities for OpenMRS.",
|
|
6
6
|
"type": "module",
|
|
@@ -78,17 +78,17 @@
|
|
|
78
78
|
"swr": "2.x"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@openmrs/esm-api": "6.3.1-pre.
|
|
82
|
-
"@openmrs/esm-config": "6.3.1-pre.
|
|
83
|
-
"@openmrs/esm-context": "6.3.1-pre.
|
|
84
|
-
"@openmrs/esm-emr-api": "6.3.1-pre.
|
|
85
|
-
"@openmrs/esm-error-handling": "6.3.1-pre.
|
|
86
|
-
"@openmrs/esm-extensions": "6.3.1-pre.
|
|
87
|
-
"@openmrs/esm-feature-flags": "6.3.1-pre.
|
|
88
|
-
"@openmrs/esm-globals": "6.3.1-pre.
|
|
89
|
-
"@openmrs/esm-navigation": "6.3.1-pre.
|
|
90
|
-
"@openmrs/esm-state": "6.3.1-pre.
|
|
91
|
-
"@openmrs/esm-utils": "6.3.1-pre.
|
|
81
|
+
"@openmrs/esm-api": "6.3.1-pre.3140",
|
|
82
|
+
"@openmrs/esm-config": "6.3.1-pre.3140",
|
|
83
|
+
"@openmrs/esm-context": "6.3.1-pre.3140",
|
|
84
|
+
"@openmrs/esm-emr-api": "6.3.1-pre.3140",
|
|
85
|
+
"@openmrs/esm-error-handling": "6.3.1-pre.3140",
|
|
86
|
+
"@openmrs/esm-extensions": "6.3.1-pre.3140",
|
|
87
|
+
"@openmrs/esm-feature-flags": "6.3.1-pre.3140",
|
|
88
|
+
"@openmrs/esm-globals": "6.3.1-pre.3140",
|
|
89
|
+
"@openmrs/esm-navigation": "6.3.1-pre.3140",
|
|
90
|
+
"@openmrs/esm-state": "6.3.1-pre.3140",
|
|
91
|
+
"@openmrs/esm-utils": "6.3.1-pre.3140",
|
|
92
92
|
"@swc/cli": "^0.7.7",
|
|
93
93
|
"@swc/core": "^1.11.29",
|
|
94
94
|
"concurrently": "^9.1.2",
|
package/src/useVisit.ts
CHANGED
|
@@ -76,8 +76,8 @@ export function useVisit(patientUuid: string, representation = defaultVisitCusto
|
|
|
76
76
|
const previousCurrentVisit = useRef<Visit | null>(null);
|
|
77
77
|
|
|
78
78
|
useEffect(() => {
|
|
79
|
-
// if an active visit is created
|
|
80
|
-
if (!activeIsValidating && activeVisit &&
|
|
79
|
+
// if an active visit is created for the visit store patient and they have no visit in context, set the context to the active visit
|
|
80
|
+
if (!activeIsValidating && activeVisit && visitStorePatientUuid === patientUuid && manuallySetVisitUuid === null) {
|
|
81
81
|
setVisitContext(activeVisit);
|
|
82
82
|
}
|
|
83
83
|
if (!retroIsValidating) {
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { useEffect, useId } from 'react';
|
|
2
2
|
import { getVisitStore, type Visit, type VisitStoreState } from '@openmrs/esm-emr-api';
|
|
3
|
-
import { useStoreWithActions } from './useStore';
|
|
3
|
+
import { type Actions, useStoreWithActions } from './useStore';
|
|
4
4
|
|
|
5
|
-
// TODO: add better typing with `satisfies` keyword when we upgrade typescript
|
|
6
5
|
const visitContextStoreActions = {
|
|
7
6
|
setVisitContext(_: VisitStoreState, newSelectedVisit: Visit | null) {
|
|
7
|
+
if (newSelectedVisit == null) {
|
|
8
|
+
return { manuallySetVisitUuid: null };
|
|
9
|
+
}
|
|
8
10
|
return {
|
|
9
|
-
manuallySetVisitUuid: newSelectedVisit
|
|
10
|
-
patientUuid: newSelectedVisit
|
|
11
|
+
manuallySetVisitUuid: newSelectedVisit.uuid,
|
|
12
|
+
patientUuid: newSelectedVisit.patient?.uuid,
|
|
11
13
|
};
|
|
12
14
|
},
|
|
13
15
|
mutateVisit(currState: VisitStoreState) {
|
|
@@ -16,7 +18,7 @@ const visitContextStoreActions = {
|
|
|
16
18
|
}
|
|
17
19
|
return {};
|
|
18
20
|
},
|
|
19
|
-
}
|
|
21
|
+
} satisfies Actions<VisitStoreState>;
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* A hook to return the visit context store and corresponding actions.
|