@openmrs/esm-cohort-builder-app 3.0.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.
Files changed (103) hide show
  1. package/LICENSE +401 -0
  2. package/README.md +16 -0
  3. package/dist/130.js +2 -0
  4. package/dist/130.js.LICENSE.txt +9 -0
  5. package/dist/139.js +1 -0
  6. package/dist/247.js +1 -0
  7. package/dist/294.js +2 -0
  8. package/dist/294.js.LICENSE.txt +9 -0
  9. package/dist/434.js +2 -0
  10. package/dist/434.js.LICENSE.txt +12 -0
  11. package/dist/480.js +2 -0
  12. package/dist/480.js.LICENSE.txt +12 -0
  13. package/dist/484.js +1 -0
  14. package/dist/574.js +1 -0
  15. package/dist/595.js +2 -0
  16. package/dist/595.js.LICENSE.txt +3 -0
  17. package/dist/690.js +1 -0
  18. package/dist/873.js +1 -0
  19. package/dist/935.js +2 -0
  20. package/dist/935.js.LICENSE.txt +19 -0
  21. package/dist/964.js +2 -0
  22. package/dist/964.js.LICENSE.txt +14 -0
  23. package/dist/main.js +1 -0
  24. package/dist/openmrs-esm-cohort-builder-app.js +1 -0
  25. package/dist/openmrs-esm-cohort-builder-app.js.buildmanifest.json +426 -0
  26. package/dist/openmrs-esm-cohort-builder-app.old +1 -0
  27. package/package.json +99 -0
  28. package/src/cohort-builder-app-menu-link.tsx +14 -0
  29. package/src/cohort-builder.resources.ts +84 -0
  30. package/src/cohort-builder.scss +126 -0
  31. package/src/cohort-builder.test.tsx +12 -0
  32. package/src/cohort-builder.tsx +213 -0
  33. package/src/cohort-builder.utils.ts +197 -0
  34. package/src/components/composition/composition.component.tsx +109 -0
  35. package/src/components/composition/composition.style.css +3 -0
  36. package/src/components/composition/composition.test.tsx +112 -0
  37. package/src/components/composition/composition.utils.ts +53 -0
  38. package/src/components/empty-data/empty-data.component.tsx +25 -0
  39. package/src/components/empty-data/empty-data.style.scss +19 -0
  40. package/src/components/saved-cohorts/saved-cohorts-options/saved-cohort-options.test.tsx +49 -0
  41. package/src/components/saved-cohorts/saved-cohorts-options/saved-cohorts-options.component.tsx +112 -0
  42. package/src/components/saved-cohorts/saved-cohorts.component.tsx +139 -0
  43. package/src/components/saved-cohorts/saved-cohorts.resources.ts +39 -0
  44. package/src/components/saved-cohorts/saved-cohorts.scss +15 -0
  45. package/src/components/saved-cohorts/saved-cohorts.test.tsx +51 -0
  46. package/src/components/saved-queries/saved-queries-options/saved-queries-options.component.tsx +112 -0
  47. package/src/components/saved-queries/saved-queries-options/saved-queries-options.test.tsx +47 -0
  48. package/src/components/saved-queries/saved-queries.component.tsx +139 -0
  49. package/src/components/saved-queries/saved-queries.resources.ts +39 -0
  50. package/src/components/saved-queries/saved-queries.scss +23 -0
  51. package/src/components/saved-queries/saved-queries.test.tsx +50 -0
  52. package/src/components/search-button-set/search-button-set.css +9 -0
  53. package/src/components/search-button-set/search-button-set.test.tsx +26 -0
  54. package/src/components/search-button-set/search-button-set.tsx +47 -0
  55. package/src/components/search-by-concepts/search-by-concepts.component.tsx +344 -0
  56. package/src/components/search-by-concepts/search-by-concepts.style.scss +48 -0
  57. package/src/components/search-by-concepts/search-by-concepts.test.tsx +129 -0
  58. package/src/components/search-by-concepts/search-concept/search-concept.component.tsx +130 -0
  59. package/src/components/search-by-concepts/search-concept/search-concept.resource.ts +53 -0
  60. package/src/components/search-by-concepts/search-concept/search-concept.style.css +25 -0
  61. package/src/components/search-by-concepts/search-concept/search-concept.test.tsx +89 -0
  62. package/src/components/search-by-demographics/search-by-demographics.component.tsx +209 -0
  63. package/src/components/search-by-demographics/search-by-demographics.style.scss +41 -0
  64. package/src/components/search-by-demographics/search-by-demographics.test.tsx +92 -0
  65. package/src/components/search-by-demographics/search-by-demographics.utils.ts +129 -0
  66. package/src/components/search-by-drug-orders/search-by-drug-orders.component.tsx +185 -0
  67. package/src/components/search-by-drug-orders/search-by-drug-orders.resources.ts +60 -0
  68. package/src/components/search-by-drug-orders/search-by-drug-orders.style.scss +4 -0
  69. package/src/components/search-by-drug-orders/search-by-drug-orders.test.tsx +159 -0
  70. package/src/components/search-by-drug-orders/search-by-drug-orders.utils.ts +118 -0
  71. package/src/components/search-by-encounters/search-by-encounters.component.tsx +188 -0
  72. package/src/components/search-by-encounters/search-by-encounters.resources.ts +51 -0
  73. package/src/components/search-by-encounters/search-by-encounters.style.scss +12 -0
  74. package/src/components/search-by-encounters/search-by-encounters.test.tsx +202 -0
  75. package/src/components/search-by-encounters/search-by-encounters.utils.ts +113 -0
  76. package/src/components/search-by-enrollments/search-by-enrollments.component.tsx +183 -0
  77. package/src/components/search-by-enrollments/search-by-enrollments.resources.ts +31 -0
  78. package/src/components/search-by-enrollments/search-by-enrollments.style.scss +4 -0
  79. package/src/components/search-by-enrollments/search-by-enrollments.test.tsx +158 -0
  80. package/src/components/search-by-enrollments/search-by-enrollments.utils.ts +69 -0
  81. package/src/components/search-by-location/search-by-location.component.tsx +97 -0
  82. package/src/components/search-by-location/search-by-location.style.scss +4 -0
  83. package/src/components/search-by-location/search-by-location.test.tsx +110 -0
  84. package/src/components/search-by-location/search-by-location.utils.ts +40 -0
  85. package/src/components/search-by-person-attributes/search-by-person-attributes.component.tsx +90 -0
  86. package/src/components/search-by-person-attributes/search-by-person-attributes.resource.ts +27 -0
  87. package/src/components/search-by-person-attributes/search-by-person-attributes.style.scss +4 -0
  88. package/src/components/search-by-person-attributes/search-by-person-attributes.test.tsx +133 -0
  89. package/src/components/search-by-person-attributes/search-by-person-attributes.utils.ts +42 -0
  90. package/src/components/search-history/search-history-options/search-history-options.component.tsx +290 -0
  91. package/src/components/search-history/search-history-options/search-history-options.resources.ts +29 -0
  92. package/src/components/search-history/search-history-options/search-history-options.test.tsx +144 -0
  93. package/src/components/search-history/search-history.component.tsx +174 -0
  94. package/src/components/search-history/search-history.style.scss +12 -0
  95. package/src/components/search-history/search-history.test.tsx +106 -0
  96. package/src/components/search-history/search-history.utils.ts +14 -0
  97. package/src/components/search-results-table/search-results-table.component.tsx +105 -0
  98. package/src/components/search-results-table/search-results-table.scss +4 -0
  99. package/src/components/search-results-table/search-results-table.test.tsx +47 -0
  100. package/src/declarations.d.tsx +2 -0
  101. package/src/index.ts +47 -0
  102. package/src/setup-tests.ts +1 -0
  103. package/src/types/index.ts +120 -0
@@ -0,0 +1,185 @@
1
+ import React, { useState } from "react";
2
+
3
+ import {
4
+ Column,
5
+ DatePicker,
6
+ DatePickerInput,
7
+ Dropdown,
8
+ MultiSelect,
9
+ } from "@carbon/react";
10
+ import { showToast } from "@openmrs/esm-framework";
11
+ import dayjs from "dayjs";
12
+ import { useTranslation } from "react-i18next";
13
+
14
+ import { DropdownValue, DrugOrderDetails, SearchByProps } from "../../types";
15
+ import SearchButtonSet from "../search-button-set/search-button-set";
16
+ import { useCareSettings, useDrugs } from "./search-by-drug-orders.resources";
17
+ import styles from "./search-by-drug-orders.style.scss";
18
+ import { getDescription, getQueryDetails } from "./search-by-drug-orders.utils";
19
+
20
+ const SearchByDrugOrder: React.FC<SearchByProps> = ({ onSubmit }) => {
21
+ const { t } = useTranslation();
22
+ const { drugs, drugsError } = useDrugs();
23
+ const { careSettings, careSettingsError } = useCareSettings();
24
+ const [activeOnOrAfter, setActiveOnOrAfter] = useState("");
25
+ const [activeOnOrBefore, setActiveOnOrBefore] = useState("");
26
+ const [activatedOnOrAfter, setActivatedOnOrAfter] = useState("");
27
+ const [activatedOnOrBefore, setActivatedOnOrBefore] = useState("");
28
+ const [selectedDrugs, setSelectedDrugs] = useState<DropdownValue[]>(null);
29
+ const [selectedCareSetting, setSelectedCareSetting] =
30
+ useState<DropdownValue>(null);
31
+ const [isLoading, setIsLoading] = useState(false);
32
+
33
+ if (drugsError) {
34
+ showToast({
35
+ title: t("error", "Error"),
36
+ kind: "error",
37
+ critical: true,
38
+ description: drugsError?.message,
39
+ });
40
+ }
41
+
42
+ if (careSettingsError) {
43
+ showToast({
44
+ title: t("error", "Error"),
45
+ kind: "error",
46
+ critical: true,
47
+ description: careSettingsError?.message,
48
+ });
49
+ }
50
+
51
+ const handleResetInputs = () => {
52
+ setSelectedDrugs(null);
53
+ setSelectedCareSetting(null);
54
+ setActiveOnOrAfter("");
55
+ setActiveOnOrBefore("");
56
+ setActivatedOnOrAfter("");
57
+ setActivatedOnOrBefore("");
58
+ };
59
+
60
+ const submit = async () => {
61
+ setIsLoading(true);
62
+ const drugOrderParams: DrugOrderDetails = {
63
+ selectedDrugs,
64
+ selectedCareSetting,
65
+ activeOnOrAfter,
66
+ activeOnOrBefore,
67
+ activatedOnOrAfter,
68
+ activatedOnOrBefore,
69
+ };
70
+ await onSubmit(
71
+ getQueryDetails(drugOrderParams),
72
+ getDescription(drugOrderParams)
73
+ );
74
+ setIsLoading(false);
75
+ };
76
+
77
+ return (
78
+ <>
79
+ <Column>
80
+ <div>
81
+ <MultiSelect
82
+ id="drugs"
83
+ data-testid="drugs"
84
+ onChange={(data) => setSelectedDrugs(data.selectedItems)}
85
+ items={drugs}
86
+ label={t("selectDrugs", "Select drugs")}
87
+ />
88
+ </div>
89
+ </Column>
90
+ <div className={styles.column}>
91
+ <Column>
92
+ <Dropdown
93
+ id="careSettings"
94
+ data-testid="careSettings"
95
+ onChange={(data) => setSelectedCareSetting(data.selectedItem)}
96
+ initialSelectedItem={careSettings[0]}
97
+ items={careSettings}
98
+ label={t("selectCareSettings", "Select a care setting")}
99
+ />
100
+ </Column>
101
+ </div>
102
+ <div className={styles.column}>
103
+ <Column>
104
+ <DatePicker
105
+ datePickerType="single"
106
+ allowInput={false}
107
+ onChange={(date) => setActiveOnOrAfter(dayjs(date[0]).format())}
108
+ >
109
+ <DatePickerInput
110
+ id="activeOnOrAfter"
111
+ labelText={t("using", "Using between")}
112
+ value={
113
+ activeOnOrAfter && dayjs(activeOnOrAfter).format("DD-MM-YYYY")
114
+ }
115
+ placeholder="DD-MM-YYYY"
116
+ size="md"
117
+ />
118
+ </DatePicker>
119
+ </Column>
120
+ <Column>
121
+ <DatePicker
122
+ datePickerType="single"
123
+ allowInput={false}
124
+ onChange={(date) => setActiveOnOrBefore(dayjs(date[0]).format())}
125
+ >
126
+ <DatePickerInput
127
+ id="activeOnOrBefore"
128
+ value={
129
+ activeOnOrBefore && dayjs(activeOnOrBefore).format("DD-MM-YYYY")
130
+ }
131
+ labelText={t("to", "to")}
132
+ placeholder="DD-MM-YYYY"
133
+ size="md"
134
+ />
135
+ </DatePicker>
136
+ </Column>
137
+ </div>
138
+ <div className={styles.column}>
139
+ <Column>
140
+ <DatePicker
141
+ datePickerType="single"
142
+ allowInput={false}
143
+ onChange={(date) => setActivatedOnOrAfter(dayjs(date[0]).format())}
144
+ >
145
+ <DatePickerInput
146
+ id="activatedOnOrAfter"
147
+ labelText={t("used", "Used between")}
148
+ value={
149
+ activatedOnOrAfter &&
150
+ dayjs(activatedOnOrAfter).format("DD-MM-YYYY")
151
+ }
152
+ placeholder="DD-MM-YYYY"
153
+ size="md"
154
+ />
155
+ </DatePicker>
156
+ </Column>
157
+ <Column>
158
+ <DatePicker
159
+ datePickerType="single"
160
+ allowInput={false}
161
+ onChange={(date) => setActivatedOnOrBefore(dayjs(date[0]).format())}
162
+ >
163
+ <DatePickerInput
164
+ id="activatedOnOrBefore"
165
+ value={
166
+ activatedOnOrBefore &&
167
+ dayjs(activatedOnOrBefore).format("DD-MM-YYYY")
168
+ }
169
+ labelText={t("and", "and")}
170
+ placeholder="DD-MM-YYYY"
171
+ size="md"
172
+ />
173
+ </DatePicker>
174
+ </Column>
175
+ </div>
176
+ <SearchButtonSet
177
+ onHandleReset={handleResetInputs}
178
+ onHandleSubmit={submit}
179
+ isLoading={isLoading}
180
+ />
181
+ </>
182
+ );
183
+ };
184
+
185
+ export default SearchByDrugOrder;
@@ -0,0 +1,60 @@
1
+ import { useMemo } from "react";
2
+
3
+ import { openmrsFetch } from "@openmrs/esm-framework";
4
+ import useSWRImmutable from "swr/immutable";
5
+
6
+ import { DropdownValue, Response } from "../../types";
7
+
8
+ /**
9
+ * @returns Drugs
10
+ */
11
+ export function useDrugs() {
12
+ const { data, error } = useSWRImmutable<{
13
+ data: { results: Response[] };
14
+ }>("/ws/rest/v1/drug", openmrsFetch);
15
+
16
+ const results = useMemo(() => {
17
+ const drugs: DropdownValue[] = [];
18
+ data?.data.results.map((drug: Response, index: number) => {
19
+ drugs.push({
20
+ id: index,
21
+ label: drug.display,
22
+ value: drug.uuid,
23
+ });
24
+ });
25
+ return {
26
+ isLoading: !data && !error,
27
+ drugs,
28
+ drugsError: error,
29
+ };
30
+ }, [data, error]);
31
+
32
+ return results;
33
+ }
34
+
35
+ /**
36
+ * @returns CareSettings
37
+ */
38
+ export function useCareSettings() {
39
+ const { data, error } = useSWRImmutable<{
40
+ data: { results: Response[] };
41
+ }>("/ws/rest/v1/caresetting", openmrsFetch);
42
+
43
+ const results = useMemo(() => {
44
+ const careSettings: DropdownValue[] = [];
45
+ data?.data.results.map((careSetting: Response, index: number) => {
46
+ careSettings.push({
47
+ id: index,
48
+ label: careSetting.display,
49
+ value: careSetting.uuid,
50
+ });
51
+ });
52
+ return {
53
+ isLoading: !data && !error,
54
+ careSettings,
55
+ careSettingsError: error,
56
+ };
57
+ }, [data, error]);
58
+
59
+ return results;
60
+ }
@@ -0,0 +1,4 @@
1
+ .column {
2
+ padding-top: 1.5rem;
3
+ display: flex;
4
+ }
@@ -0,0 +1,159 @@
1
+ import React from "react";
2
+
3
+ import { openmrsFetch } from "@openmrs/esm-framework";
4
+ import { render, fireEvent, waitFor } from "@testing-library/react";
5
+
6
+ import translations from "../../../translations/en.json";
7
+ import SearchByDrugOrder from "./search-by-drug-orders.component";
8
+ import { useCareSettings, useDrugs } from "./search-by-drug-orders.resources";
9
+
10
+ const mockCareSettings = [
11
+ {
12
+ id: 0,
13
+ label: "Isolation Ward",
14
+ value: "ac7d7773-fe9f-11ec-8b9b-0242ac1b1102",
15
+ },
16
+ {
17
+ id: 1,
18
+ label: "Armani Hospital",
19
+ value: "8d8718c2-c2cc-11de-8d13-0010c6effd0f",
20
+ },
21
+ {
22
+ id: 2,
23
+ label: "Pharmacy",
24
+ value: "8d871afc-c2cc-11de-8d13-0010c6dffd0f",
25
+ },
26
+ ];
27
+
28
+ const mockDrugs = [
29
+ {
30
+ id: 0,
31
+ label: "Triomune-40",
32
+ value: "ac7d7773-fe9f-11ec-8b9b-0242ac1b0402",
33
+ },
34
+ {
35
+ id: 1,
36
+ label: "Valium",
37
+ value: "8d8718c2-c2cc-11de-8d13-0010c6dffd0f",
38
+ },
39
+ {
40
+ id: 2,
41
+ label: "Aspirin",
42
+ value: "9d971afc-c2cc-11de-8d13-0010c6dffd0f",
43
+ },
44
+ ];
45
+
46
+ const expectedQuery = {
47
+ query: {
48
+ type: "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition",
49
+ columns: [
50
+ {
51
+ name: "firstname",
52
+ key: "reporting.library.patientDataDefinition.builtIn.preferredName.givenName",
53
+ type: "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition",
54
+ },
55
+ {
56
+ name: "lastname",
57
+ key: "reporting.library.patientDataDefinition.builtIn.preferredName.familyName",
58
+ type: "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition",
59
+ },
60
+ {
61
+ name: "gender",
62
+ key: "reporting.library.patientDataDefinition.builtIn.gender",
63
+ type: "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition",
64
+ },
65
+ {
66
+ name: "age",
67
+ key: "reporting.library.patientDataDefinition.builtIn.ageOnDate.fullYears",
68
+ type: "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition",
69
+ },
70
+ {
71
+ name: "patientId",
72
+ key: "reporting.library.patientDataDefinition.builtIn.patientId",
73
+ type: "org.openmrs.module.reporting.data.patient.definition.PatientDataDefinition",
74
+ },
75
+ ],
76
+ rowFilters: [
77
+ {
78
+ key: "reporting.library.cohortDefinition.builtIn.drugOrderSearch",
79
+ parameterValues: {
80
+ careSetting: mockCareSettings[2].value,
81
+ drugs: [mockDrugs[0].value, mockDrugs[1].value],
82
+ },
83
+ type: "org.openmrs.module.reporting.dataset.definition.PatientDataSetDefinition",
84
+ },
85
+ ],
86
+ customRowFilterCombination: "1",
87
+ },
88
+ };
89
+
90
+ jest.mock("./search-by-drug-orders.resources", () => {
91
+ const original = jest.requireActual("./search-by-drug-orders.resources");
92
+ return {
93
+ ...original,
94
+ useCareSettings: jest.fn(),
95
+ useDrugs: jest.fn(),
96
+ };
97
+ });
98
+
99
+ const mockOpenmrsFetch = openmrsFetch as jest.Mock;
100
+
101
+ describe("Test the search by drug orders component", () => {
102
+ it("should be able to select input values", async () => {
103
+ // @ts-ignore
104
+ useCareSettings.mockImplementation(() => ({
105
+ careSettings: mockCareSettings,
106
+ isLoading: false,
107
+ careSettingsError: undefined,
108
+ }));
109
+ mockOpenmrsFetch.mockReturnValueOnce({
110
+ data: { results: mockCareSettings },
111
+ });
112
+
113
+ // @ts-ignore
114
+ useDrugs.mockImplementation(() => ({
115
+ drugs: mockDrugs,
116
+ isLoading: false,
117
+ drugsError: undefined,
118
+ }));
119
+ mockOpenmrsFetch.mockReturnValueOnce({
120
+ data: { results: mockCareSettings },
121
+ });
122
+
123
+ const submit = jest.fn();
124
+ const { getByTestId, getByTitle, getByText } = render(
125
+ <SearchByDrugOrder onSubmit={submit} />
126
+ );
127
+
128
+ waitFor(() => {
129
+ fireEvent.click(getByText(translations.selectDrugs));
130
+ });
131
+
132
+ waitFor(() => {
133
+ fireEvent.click(getByText(mockDrugs[1].label));
134
+ });
135
+
136
+ waitFor(() => {
137
+ fireEvent.click(getByText(mockDrugs[2].label));
138
+ });
139
+
140
+ waitFor(() => {
141
+ fireEvent.click(getByTitle(mockCareSettings[0].label));
142
+ });
143
+
144
+ waitFor(() => {
145
+ fireEvent.click(getByText(mockCareSettings[2].label));
146
+ });
147
+
148
+ waitFor(() => {
149
+ fireEvent.click(getByTestId("search-btn"));
150
+ });
151
+
152
+ await waitFor(() => {
153
+ expect(submit).toBeCalledWith(
154
+ expectedQuery,
155
+ `Patients who taking ${mockDrugs[1].label} and ${mockDrugs[2].label} from Pharmacy`
156
+ );
157
+ });
158
+ });
159
+ });
@@ -0,0 +1,118 @@
1
+ import { formatDate } from "@openmrs/esm-framework";
2
+
3
+ import { composeJson } from "../../cohort-builder.utils";
4
+ import { DrugOrderDetails } from "./../../types/index";
5
+
6
+ export const getDescription = ({
7
+ selectedDrugs,
8
+ selectedCareSetting,
9
+ activeOnOrBefore,
10
+ activeOnOrAfter,
11
+ activatedOnOrBefore,
12
+ activatedOnOrAfter,
13
+ }: DrugOrderDetails) => {
14
+ let description =
15
+ "Patients who taking " +
16
+ selectedDrugs
17
+ .map((drug) => drug.label)
18
+ .join(", ")
19
+ .replace(/,(?=[^,]*$)/, " and");
20
+
21
+ if (selectedCareSetting) {
22
+ description += ` from ${selectedCareSetting.label}`;
23
+ }
24
+
25
+ if (activeOnOrAfter) {
26
+ const date = formatDate(new Date(activeOnOrAfter), { mode: "standard" });
27
+ if (activeOnOrBefore) {
28
+ description += ` from ${date}`;
29
+ } else {
30
+ description += ` on or after ${date}`;
31
+ }
32
+ }
33
+
34
+ if (activeOnOrBefore) {
35
+ const date = formatDate(new Date(activeOnOrBefore), { mode: "standard" });
36
+ if (activeOnOrAfter) {
37
+ description += ` to ${date}`;
38
+ } else {
39
+ description += ` on or before ${date}`;
40
+ }
41
+ }
42
+
43
+ if (activatedOnOrAfter) {
44
+ const date = formatDate(new Date(activatedOnOrAfter), { mode: "standard" });
45
+ if (activatedOnOrBefore) {
46
+ description += ` from ${date}`;
47
+ } else {
48
+ description += ` on or after ${date}`;
49
+ }
50
+ }
51
+
52
+ if (activatedOnOrBefore) {
53
+ const date = formatDate(new Date(activatedOnOrBefore), {
54
+ mode: "standard",
55
+ });
56
+ if (activatedOnOrAfter) {
57
+ description += ` to ${date}`;
58
+ } else {
59
+ description += ` on or before ${date}`;
60
+ }
61
+ }
62
+
63
+ return description;
64
+ };
65
+
66
+ export const getQueryDetails = ({
67
+ selectedDrugs,
68
+ selectedCareSetting,
69
+ activeOnOrBefore,
70
+ activeOnOrAfter,
71
+ activatedOnOrBefore,
72
+ activatedOnOrAfter,
73
+ }: DrugOrderDetails) => {
74
+ const searchParams = { drugOrderSearch: [] };
75
+ if (activeOnOrAfter) {
76
+ searchParams.drugOrderSearch.push({
77
+ name: "activeOnOrAfter",
78
+ value: activeOnOrAfter,
79
+ });
80
+ }
81
+
82
+ if (activatedOnOrAfter) {
83
+ searchParams.drugOrderSearch.push({
84
+ name: "activatedOnOrAfter",
85
+ value: activatedOnOrAfter,
86
+ });
87
+ }
88
+
89
+ if (activatedOnOrBefore) {
90
+ searchParams.drugOrderSearch.push({
91
+ name: "activatedOnOrBefore",
92
+ value: activatedOnOrBefore,
93
+ });
94
+ }
95
+
96
+ if (selectedCareSetting) {
97
+ searchParams.drugOrderSearch.push({
98
+ name: "careSetting",
99
+ value: selectedCareSetting.value,
100
+ });
101
+ }
102
+
103
+ if (selectedDrugs.length) {
104
+ searchParams.drugOrderSearch.push({
105
+ name: "drugs",
106
+ value: selectedDrugs.map((form) => form.value),
107
+ });
108
+ }
109
+
110
+ if (activeOnOrBefore) {
111
+ searchParams.drugOrderSearch.push({
112
+ name: "activeOnOrBefore",
113
+ value: activeOnOrBefore,
114
+ });
115
+ }
116
+
117
+ return composeJson(searchParams);
118
+ };