@openmrs/esm-patient-common-lib 8.2.1-pre.6126 → 8.2.1-pre.6128

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": "8.2.1-pre.6126",
3
+ "version": "8.2.1-pre.6128",
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",
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from 'react';
2
2
  import useSWR, { useSWRConfig } from 'swr';
3
- import { type FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
3
+ import { type FetchResponse, openmrsFetch, restBaseUrl, toOmrsIsoString } from '@openmrs/esm-framework';
4
4
  import { type OrderTypeFetchResponse, type PatientOrderFetchResponse } from '@openmrs/esm-patient-common-lib';
5
5
 
6
6
  export type Status = 'ACTIVE' | 'any';
@@ -14,9 +14,18 @@ export const drugCustomRepresentation =
14
14
  'frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,' +
15
15
  'duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)';
16
16
 
17
- export function usePatientOrders(patientUuid: string, status?: Status, orderType?: string) {
17
+ export function usePatientOrders(
18
+ patientUuid: string,
19
+ status?: Status,
20
+ orderType?: string,
21
+ startDate?: string,
22
+ endDate?: string,
23
+ ) {
18
24
  const { mutate } = useSWRConfig();
19
- const baseOrdersUrl = `${restBaseUrl}/order?patient=${patientUuid}&careSetting=${careSettingUuid}&v=full&status=${status}`;
25
+ const baseOrdersUrl =
26
+ startDate && endDate
27
+ ? `${restBaseUrl}/order?patient=${patientUuid}&careSetting=${careSettingUuid}&v=full&activatedOnOrAfterDate=${startDate}&activatedOnOrBeforeDate=${endDate}`
28
+ : `${restBaseUrl}/order?patient=${patientUuid}&careSetting=${careSettingUuid}&v=full&status=${status}`;
20
29
  const ordersUrl = orderType ? `${baseOrdersUrl}&orderType=${orderType}` : baseOrdersUrl;
21
30
 
22
31
  const { data, error, isLoading, isValidating } = useSWR<FetchResponse<PatientOrderFetchResponse>, Error>(