@openmrs/esm-api 6.2.1-pre.2920 → 6.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-api",
3
- "version": "6.2.1-pre.2920",
3
+ "version": "6.3.0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "The javascript module for interacting with the OpenMRS API",
6
6
  "browser": "dist/openmrs-esm-api.js",
@@ -48,12 +48,11 @@
48
48
  "@openmrs/esm-offline": "6.x"
49
49
  },
50
50
  "devDependencies": {
51
- "@openmrs/esm-config": "6.2.1-pre.2920",
52
- "@openmrs/esm-error-handling": "6.2.1-pre.2920",
53
- "@openmrs/esm-navigation": "6.2.1-pre.2920",
54
- "@openmrs/esm-state": "6.2.1-pre.2920",
51
+ "@openmrs/esm-config": "6.3.0",
52
+ "@openmrs/esm-error-handling": "6.3.0",
53
+ "@openmrs/esm-navigation": "6.3.0",
54
+ "@openmrs/esm-state": "6.3.0",
55
55
  "rxjs": "^6.5.3",
56
56
  "webpack": "^5.88.0"
57
- },
58
- "stableVersion": "6.2.0"
57
+ }
59
58
  }
@@ -25,6 +25,15 @@ export enum VisitStatus {
25
25
  export interface VisitStoreState {
26
26
  patientUuid: string | null;
27
27
  manuallySetVisitUuid: string | null;
28
+
29
+ /**
30
+ * Stores a record of SWR mutate callbacks that should be called when
31
+ * the Visit with the specified uuid is modified. The callbacks are keyed
32
+ * by unique component IDs.
33
+ */
34
+ mutateVisitCallbacks: {
35
+ [componentId: string]: () => void;
36
+ };
28
37
  }
29
38
 
30
39
  export const defaultVisitCustomRepresentation =
@@ -39,9 +48,10 @@ export const defaultVisitCustomRepresentation =
39
48
  'attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),' +
40
49
  'location:(uuid,name,display))';
41
50
 
42
- const initialState = getVisitLocalStorage() || {
51
+ const initialState: VisitStoreState = getVisitSessionStorage() || {
43
52
  patientUuid: null,
44
53
  manuallySetVisitUuid: null,
54
+ mutateVisitCallbacks: {},
45
55
  };
46
56
 
47
57
  export function getVisitStore() {
@@ -53,16 +63,16 @@ export function setCurrentVisit(patientUuid: string, visitUuid: string) {
53
63
  }
54
64
 
55
65
  getVisitStore().subscribe((state) => {
56
- setVisitLocalStorage(state);
66
+ setVisitSessionStorage(state);
57
67
  });
58
68
 
59
- function setVisitLocalStorage(value: VisitStoreState) {
60
- localStorage.setItem('openmrs:visitStoreState', JSON.stringify(value));
69
+ function setVisitSessionStorage(value: VisitStoreState) {
70
+ sessionStorage.setItem('openmrs:visitStoreState', JSON.stringify(value));
61
71
  }
62
72
 
63
- function getVisitLocalStorage(): VisitStoreState | null {
73
+ function getVisitSessionStorage(): VisitStoreState | null {
64
74
  try {
65
- return JSON.parse(localStorage.getItem('openmrs:visitStoreState') || 'null');
75
+ return JSON.parse(sessionStorage.getItem('openmrs:visitStoreState') || 'null');
66
76
  } catch (e) {
67
77
  return null;
68
78
  }
@@ -79,7 +89,11 @@ export function saveVisit(payload: NewVisitPayload, abortController: AbortContro
79
89
  });
80
90
  }
81
91
 
82
- export function updateVisit(uuid: string, payload: UpdateVisitPayload, abortController: AbortController) {
92
+ export function updateVisit(
93
+ uuid: string,
94
+ payload: UpdateVisitPayload,
95
+ abortController: AbortController,
96
+ ): Promise<FetchResponse<Visit>> {
83
97
  return openmrsFetch(`${restBaseUrl}/visit/${uuid}`, {
84
98
  signal: abortController.signal,
85
99
  method: 'POST',