@openmrs/esm-stock-management-app 1.0.1-pre.390 → 1.0.1-pre.395

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,9 +32,9 @@
32
32
  "initial": false,
33
33
  "entry": false,
34
34
  "recorded": false,
35
- "size": 1033166,
35
+ "size": 1032484,
36
36
  "sizes": {
37
- "javascript": 1032956,
37
+ "javascript": 1032274,
38
38
  "consume-shared": 210
39
39
  },
40
40
  "names": [],
@@ -48,7 +48,7 @@
48
48
  "auxiliaryFiles": [
49
49
  "39.js.map"
50
50
  ],
51
- "hash": "2cbfcdfa0269bf60",
51
+ "hash": "1f3724fd167824bb",
52
52
  "childrenByOrder": {}
53
53
  },
54
54
  {
@@ -110,10 +110,10 @@
110
110
  "initial": true,
111
111
  "entry": true,
112
112
  "recorded": false,
113
- "size": 4782215,
113
+ "size": 4781533,
114
114
  "sizes": {
115
115
  "consume-shared": 252,
116
- "javascript": 4760267,
116
+ "javascript": 4759585,
117
117
  "share-init": 252,
118
118
  "runtime": 21444
119
119
  },
@@ -130,7 +130,7 @@
130
130
  "auxiliaryFiles": [
131
131
  "main.js.map"
132
132
  ],
133
- "hash": "c181c28d434fae3b",
133
+ "hash": "defc8b2869583d61",
134
134
  "childrenByOrder": {}
135
135
  },
136
136
  {
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.390"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.395"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.390",
3
+ "version": "1.0.1-pre.395",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Stock management microfrontend for OpenMRS 3.x",
6
6
  "browser": "dist/openmrs-esm-stock-management-app.js",
@@ -15,7 +15,7 @@ interface MetricsCardProps {
15
15
  headerLabel: string;
16
16
  children?: React.ReactNode;
17
17
  view: string;
18
- count?: { expiry7days: Array<any>; expiry30days: Array<any> };
18
+ count?: { expiry6months: Array<any> };
19
19
  outofstockCount?: { itemsbelowmin: Array<any>; itemsabovemax: Array<any> };
20
20
  disposedCount?: { expired: Array<any>; poorquality: Array<any> };
21
21
  }
@@ -58,13 +58,9 @@ const MetricsCard: React.FC<MetricsCardProps> = ({
58
58
  {!isEmpty(count) && (
59
59
  <div className={styles.countGrid}>
60
60
  <span style={{ color: "#DA1E28" }}>
61
- {t("in7days", "In 7 days")}
61
+ {t("in6months", "In 6 months")}
62
62
  </span>
63
- <span style={{ color: " #FABA5F" }}>
64
- {t("in30days", "In 30 days")}
65
- </span>
66
- <p style={{ color: "#DA1E28" }}>{count.expiry7days?.length}</p>
67
- <p style={{ color: "#FABA5F" }}>{count.expiry30days?.length}</p>
63
+ <p style={{ color: "#DA1E28" }}>{count.expiry6months?.length}</p>
68
64
  </div>
69
65
  )}
70
66
  {!isEmpty(outofstockCount) && (
@@ -11,12 +11,11 @@ const StockHomeInventoryCard = () => {
11
11
  const { t } = useTranslation();
12
12
  const isTablet = useLayoutType() === "tablet";
13
13
 
14
- // TODO: Pull low on stock
15
14
  const { items: expiryItems, isLoading: inventoryLoading } =
16
15
  useStockInventory();
17
16
  const { items: stockItems, isLoading } = useStockInventoryItems();
18
17
 
19
- if (isLoading) return <></>;
18
+ if (isLoading || inventoryLoading) return <></>;
20
19
 
21
20
  if (stockItems?.length === 0) {
22
21
  return (
@@ -28,23 +27,23 @@ const StockHomeInventoryCard = () => {
28
27
  );
29
28
  }
30
29
 
31
- const currentDate: any = new Date();
32
- let mergedArray: any[] = expiryItems.map((batch) => {
30
+ const currentDate = new Date();
31
+
32
+ let mergedArray = expiryItems.map((batch) => {
33
33
  const matchingItem = stockItems?.find(
34
- (item2) => batch?.stockItemUuid === item2.uuid
34
+ (item) => batch?.stockItemUuid === item.uuid
35
35
  );
36
36
  return { ...batch, ...matchingItem };
37
37
  });
38
+
38
39
  mergedArray = mergedArray.filter((item) => item.hasExpiration);
40
+
39
41
  const filteredData = mergedArray.filter((item) => {
40
- const expiryNotice = item.expiryNotice || 0; // Default to 0 if expiryNotice is undefined or null
41
- const expirationDate: any = new Date(item.expiration);
42
+ const expirationDate = new Date(item.expiration);
42
43
  const differenceInDays = Math.ceil(
43
- (expirationDate - currentDate) / (1000 * 60 * 60 * 24)
44
+ (expirationDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24)
44
45
  );
45
-
46
- // Include items that have not expired yet or are within the expiry notice period
47
- return differenceInDays <= expiryNotice || differenceInDays < 0;
46
+ return differenceInDays <= 180 && differenceInDays >= 0;
48
47
  });
49
48
 
50
49
  return (
@@ -16,29 +16,34 @@ const StockManagementMetrics: React.FC = (filter: StockOperationFilter) => {
16
16
  const { t } = useTranslation();
17
17
 
18
18
  const { stockList: allStocks, isLoading, error } = useStockList();
19
-
20
19
  const { items: expiryItems, isLoading: inventoryLoading } =
21
20
  useStockInventory();
22
21
  const { items: stockItems } = useStockInventoryItems();
23
22
 
24
- const currentDate: any = new Date();
25
- let mergedArray: any[] = expiryItems.map((batch) => {
23
+ const currentDate = new Date();
24
+
25
+ let mergedArray = expiryItems.map((batch) => {
26
26
  const matchingItem = stockItems?.find(
27
- (item2) => batch?.stockItemUuid === item2.uuid
27
+ (item) => batch?.stockItemUuid === item.uuid
28
28
  );
29
29
  return { ...batch, ...matchingItem };
30
30
  });
31
+
31
32
  mergedArray = mergedArray.filter((item) => item.hasExpiration);
33
+
32
34
  const filteredData = mergedArray.filter((item) => {
33
35
  const expiryNotice = item.expiryNotice || 0;
34
- const expirationDate: any = new Date(item.expiration);
36
+ const expirationDate = new Date(item.expiration);
35
37
  const differenceInDays = Math.ceil(
36
- (expirationDate - currentDate) / (1000 * 60 * 60 * 24)
38
+ (expirationDate.getTime() - currentDate.getTime()) / (1000 * 60 * 60 * 24)
37
39
  );
38
-
39
40
  return differenceInDays <= expiryNotice || differenceInDays < 0;
40
41
  });
41
42
 
43
+ const sixMonthsExpiryStocks = filteredData.filter(
44
+ (stock) => stock.hasExpiration && stock.expiryNotice <= 180
45
+ );
46
+
42
47
  const { items } = useDisposalList({
43
48
  v: ResourceRepresentation.Full,
44
49
  totalCount: true,
@@ -56,13 +61,6 @@ const StockManagementMetrics: React.FC = (filter: StockOperationFilter) => {
56
61
  return <ErrorState headerTitle={t("errorStockMetric")} error={error} />;
57
62
  }
58
63
 
59
- const sevenDaysExpiryStocks = allStocks.filter(
60
- (stock) => stock.hasExpiration && stock.ExpiryNotice <= 7
61
- );
62
- const thirtyDaysExpiryStocks = allStocks.filter(
63
- (stock) => stock.hasExpiration && stock.ExpiryNotice <= 30
64
- );
65
-
66
64
  const filteredItems =
67
65
  items &&
68
66
  items.filter(
@@ -81,8 +79,7 @@ const StockManagementMetrics: React.FC = (filter: StockOperationFilter) => {
81
79
  headerLabel={t("expiringStock", "Expiring Stock")}
82
80
  view="items"
83
81
  count={{
84
- expiry7days: sevenDaysExpiryStocks,
85
- expiry30days: thirtyDaysExpiryStocks,
82
+ expiry6months: sixMonthsExpiryStocks,
86
83
  }}
87
84
  />
88
85
  <MetricsCard
@@ -91,8 +88,8 @@ const StockManagementMetrics: React.FC = (filter: StockOperationFilter) => {
91
88
  headerLabel={t("highestServiceVolume", "Out of Stock ")}
92
89
  view="items"
93
90
  outofstockCount={{
94
- itemsbelowmin: sevenDaysExpiryStocks,
95
- itemsabovemax: thirtyDaysExpiryStocks,
91
+ itemsbelowmin: ["0"],
92
+ itemsabovemax: ["0"],
96
93
  }}
97
94
  />
98
95
  <MetricsCard
@@ -4,16 +4,16 @@ import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
4
4
  interface StockList {
5
5
  uuid: string;
6
6
  hasExpiration: boolean;
7
- ExpiryNotice: number;
7
+ expiryNotice: number;
8
8
  results: {
9
9
  uuid: string;
10
10
  hasExpiration: boolean;
11
- ExpiryNotice: number;
11
+ expiryNotice: number;
12
12
  };
13
13
  }
14
14
 
15
15
  const useStockList = () => {
16
- const url = `${restBaseUrl}/stockmanagement/stockitem`;
16
+ const url = `${restBaseUrl}/stockmanagement/stockitem?v=default&totalCount=true`;
17
17
 
18
18
  const { data, error } = useSWR<{ data: { results: Array<StockList> } }>(
19
19
  url,
@@ -23,7 +23,7 @@ const useStockList = () => {
23
23
  const stocks = data?.data.results.map((stock) => ({
24
24
  uuid: stock.uuid,
25
25
  hasExpiration: stock.hasExpiration,
26
- ExpiryNotice: stock.ExpiryNotice,
26
+ expiryNotice: stock.expiryNotice,
27
27
  }));
28
28
 
29
29
  return {