@openmrs/esm-patient-common-lib 11.2.2-pre.8773 → 11.3.1-patch.9064

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-patient-common-lib",
3
- "version": "11.2.2-pre.8773",
3
+ "version": "11.3.1-patch.9064",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Library for common patient chart components",
6
6
  "browser": "dist/openmrs-esm-patient-common-lib.js",
@@ -38,5 +38,5 @@
38
38
  "react": "18.x",
39
39
  "single-spa": "6.x"
40
40
  },
41
- "stableVersion": "11.2.1"
41
+ "stableVersion": "11.3.0"
42
42
  }
@@ -3,12 +3,12 @@ import { BrowserRouter } from 'react-router-dom';
3
3
  import { DashboardExtension } from '@openmrs/esm-styleguide';
4
4
  import { type DashboardLinkConfig } from '../types';
5
5
 
6
- export const createDashboardLink = (db: DashboardLinkConfig) => {
7
- return ({ basePath }: { basePath: string }) => {
6
+ export function createDashboardLink(db: DashboardLinkConfig) {
7
+ return function ({ basePath }: { basePath: string }) {
8
8
  return (
9
9
  <BrowserRouter>
10
10
  <DashboardExtension basePath={basePath} title={db.title} path={db.path} icon={db.icon} />
11
11
  </BrowserRouter>
12
12
  );
13
13
  };
14
- };
14
+ }
@@ -1,4 +1,11 @@
1
- import { openmrsFetch, type OpenmrsResource, parseDate, restBaseUrl, type Visit } from '@openmrs/esm-framework';
1
+ import {
2
+ type Concept,
3
+ openmrsFetch,
4
+ type OpenmrsResource,
5
+ parseDate,
6
+ restBaseUrl,
7
+ type Visit,
8
+ } from '@openmrs/esm-framework';
2
9
  import { type OrderBasketStore, orderBasketStore } from './store';
3
10
  import type {
4
11
  DrugOrderPost,
@@ -15,18 +22,25 @@ export async function postOrdersOnNewEncounter(
15
22
  currentVisit: Visit | null,
16
23
  sessionLocationUuid: string,
17
24
  abortController?: AbortController,
25
+
26
+ /**
27
+ * If not specified, the encounterDate will either be set to
28
+ * `now` if currentVisit is active, or the start of the visit
29
+ */
30
+ encounterDate?: Date,
18
31
  ) {
19
32
  const now = new Date();
20
33
  const visitStartDate = parseDate(currentVisit?.startDatetime);
21
34
  const visitEndDate = parseDate(currentVisit?.stopDatetime);
22
- let encounterDate: Date;
23
- if (!currentVisit || (visitStartDate < now && (!visitEndDate || visitEndDate > now))) {
24
- encounterDate = now;
25
- } else {
26
- console.warn(
27
- 'postOrdersOnNewEncounter received an active visit that is not currently active. This is a programming error. Attempting to place the order using the visit start date.',
28
- );
29
- encounterDate = visitStartDate;
35
+ if (!encounterDate) {
36
+ if (!currentVisit || (visitStartDate < now && (!visitEndDate || visitEndDate > now))) {
37
+ encounterDate = now;
38
+ } else {
39
+ console.warn(
40
+ 'postOrdersOnNewEncounter received an active visit that is not currently active. This is a programming error. Attempting to place the order using the visit start date.',
41
+ );
42
+ encounterDate = visitStartDate;
43
+ }
30
44
  }
31
45
 
32
46
  const { items, postDataPrepFunctions }: OrderBasketStore = orderBasketStore.getState();
@@ -40,7 +54,7 @@ export async function postOrdersOnNewEncounter(
40
54
  });
41
55
  });
42
56
 
43
- const encounterPostData = {
57
+ const encounterPostData: EncounterPost = {
44
58
  patient: patientUuid,
45
59
  location: sessionLocationUuid,
46
60
  encounterType: orderEncounterType,
@@ -50,6 +64,24 @@ export async function postOrdersOnNewEncounter(
50
64
  orders,
51
65
  };
52
66
 
67
+ return postEncounter(encounterPostData, abortController);
68
+ }
69
+ interface ObsPayload {
70
+ concept: Concept | string;
71
+ value?: string | OpenmrsResource;
72
+ groupMembers?: Array<ObsPayload>;
73
+ }
74
+ export interface EncounterPost {
75
+ patient: string;
76
+ location: string;
77
+ encounterType: string;
78
+ encounterDatetime: Date;
79
+ visit?: string;
80
+ obs: ObsPayload[];
81
+ orders: OrderPost[];
82
+ }
83
+
84
+ export async function postEncounter(encounterPostData: EncounterPost, abortController?: AbortController) {
53
85
  return openmrsFetch<OpenmrsResource>(`${restBaseUrl}/encounter`, {
54
86
  headers: {
55
87
  'Content-Type': 'application/json',
@@ -186,7 +186,7 @@ export interface Order {
186
186
  changedBy: string;
187
187
  dateChanged: string;
188
188
  };
189
- fulfillerStatus: 'RECEIVED' | 'IN_PROGRESS' | 'EXCEPTION' | 'ON_HOLD' | 'DECLINED' | 'COMPLETED' | 'DISCONINTUED';
189
+ fulfillerStatus: FulfillerStatus;
190
190
  fulfillerComment: string;
191
191
  specimenSource: string;
192
192
  laterality: string;
@@ -207,7 +207,13 @@ export interface OrderType {
207
207
  description: string;
208
208
  }
209
209
 
210
- export type FulfillerStatus = 'EXCEPTION' | 'RECEIVED' | 'COMPLETED' | 'IN_PROGRESS' | 'ON_HOLD' | 'DECLINED';
210
+ export type FulfillerStatus =
211
+ | 'RECEIVED'
212
+ | 'IN_PROGRESS'
213
+ | 'EXCEPTION'
214
+ | 'ON_HOLD'
215
+ | 'DECLINED'
216
+ | 'COMPLETED';
211
217
 
212
218
  export type PostDataPrepFunction = (
213
219
  order: OrderBasketItem,
@@ -1,4 +1,4 @@
1
- import { useStoreWithActions } from '@openmrs/esm-framework';
1
+ import { type Actions, useStoreWithActions } from '@openmrs/esm-framework';
2
2
  import type { OrderBasketItem, PostDataPrepFunction } from './types';
3
3
  import { getPatientUuidFromStore } from '../store/patient-chart-store';
4
4
  import { useEffect } from 'react';
@@ -32,7 +32,7 @@ const orderBasketStoreActions = {
32
32
  },
33
33
  };
34
34
  },
35
- };
35
+ } satisfies Actions<OrderBasketStore>;
36
36
 
37
37
  function getOrderItems(items: OrderBasketStore['items'], grouping?: string | null): Array<OrderBasketItem> {
38
38
  const patientUuid = getPatientUuidFromStore();
@@ -1,11 +1,11 @@
1
- import { type OpenmrsResource } from '@openmrs/esm-framework';
1
+ import { type IconId, type OpenmrsResource } from '@openmrs/esm-framework';
2
2
 
3
3
  export * from './test-results';
4
4
 
5
5
  export interface DashboardLinkConfig {
6
6
  path: string;
7
7
  title: string;
8
- icon: string;
8
+ icon?: IconId;
9
9
  moduleName?: string;
10
10
  }
11
11