@openmrs/esm-react-utils 6.3.1-pre.3127 → 6.3.1-pre.3136

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 52 files with swc (143.82ms)
1
+ [0] Successfully compiled: 52 files with swc (125.02ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
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 and there is no visit in context, set the context to the active visit
46
- if (manuallySetVisitUuid == null && !activeIsValidating && activeVisit) {
45
+ // if an active visit is created and either there is no visit in context or we've switched to a different patient, 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) {
@@ -59,14 +59,13 @@ dayjs.extend(isToday);
59
59
  manuallySetVisitUuid,
60
60
  activeVisit,
61
61
  activeIsValidating,
62
- retroIsValidating
62
+ retroIsValidating,
63
+ visitStorePatientUuid
63
64
  ]);
64
65
  const mutateVisit = useCallback(()=>{
65
66
  activeMutate();
66
67
  retroMutate();
67
68
  }, [
68
- activeVisit,
69
- currentVisit,
70
69
  activeMutate,
71
70
  retroMutate
72
71
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-react-utils",
3
- "version": "6.3.1-pre.3127",
3
+ "version": "6.3.1-pre.3136",
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.3127",
82
- "@openmrs/esm-config": "6.3.1-pre.3127",
83
- "@openmrs/esm-context": "6.3.1-pre.3127",
84
- "@openmrs/esm-emr-api": "6.3.1-pre.3127",
85
- "@openmrs/esm-error-handling": "6.3.1-pre.3127",
86
- "@openmrs/esm-extensions": "6.3.1-pre.3127",
87
- "@openmrs/esm-feature-flags": "6.3.1-pre.3127",
88
- "@openmrs/esm-globals": "6.3.1-pre.3127",
89
- "@openmrs/esm-navigation": "6.3.1-pre.3127",
90
- "@openmrs/esm-state": "6.3.1-pre.3127",
91
- "@openmrs/esm-utils": "6.3.1-pre.3127",
81
+ "@openmrs/esm-api": "6.3.1-pre.3136",
82
+ "@openmrs/esm-config": "6.3.1-pre.3136",
83
+ "@openmrs/esm-context": "6.3.1-pre.3136",
84
+ "@openmrs/esm-emr-api": "6.3.1-pre.3136",
85
+ "@openmrs/esm-error-handling": "6.3.1-pre.3136",
86
+ "@openmrs/esm-extensions": "6.3.1-pre.3136",
87
+ "@openmrs/esm-feature-flags": "6.3.1-pre.3136",
88
+ "@openmrs/esm-globals": "6.3.1-pre.3136",
89
+ "@openmrs/esm-navigation": "6.3.1-pre.3136",
90
+ "@openmrs/esm-state": "6.3.1-pre.3136",
91
+ "@openmrs/esm-utils": "6.3.1-pre.3136",
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 and there is no visit in context, set the context to the active visit
80
- if (manuallySetVisitUuid == null && !activeIsValidating && activeVisit) {
79
+ // if an active visit is created and either there is no visit in context or we've switched to a different patient, 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) {
@@ -94,12 +94,12 @@ export function useVisit(patientUuid: string, representation = defaultVisitCusto
94
94
  }
95
95
  previousCurrentVisit.current = currentVisit;
96
96
  }
97
- }, [currentVisit, manuallySetVisitUuid, activeVisit, activeIsValidating, retroIsValidating]);
97
+ }, [currentVisit, manuallySetVisitUuid, activeVisit, activeIsValidating, retroIsValidating, visitStorePatientUuid]);
98
98
 
99
99
  const mutateVisit = useCallback(() => {
100
100
  activeMutate();
101
101
  retroMutate();
102
- }, [activeVisit, currentVisit, activeMutate, retroMutate]);
102
+ }, [activeMutate, retroMutate]);
103
103
 
104
104
  useVisitContextStore(mutateVisit);
105
105