Skip to content

Commit c9cb1b7

Browse files
committed
update filters
1 parent 3152bf1 commit c9cb1b7

File tree

2 files changed

+22
-32
lines changed

2 files changed

+22
-32
lines changed

src/app/(dashboard)/stats/actions.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ export async function fetchData(formData: FormData) {
4141
filter.params[0].value ?? ""
4242
}`;
4343
temp["_tag"] = template;
44-
} else {
45-
temp[filter.template] = filter.params[0].value ?? "";
46-
}
47-
if (filter.params.find((e) => e.name == "date")) {
44+
} else if (filter.template == "date") {
4845
rawDate =
4946
filter.params.find((e) => e.name == "date")?.value?.split("T")[0] ??
5047
null;
@@ -71,7 +68,10 @@ export async function fetchData(formData: FormData) {
7168
rawDate = [from.split("T")[0]];
7269
}
7370
}
71+
} else {
72+
temp[filter.template] = filter.params[0].value ?? "";
7473
}
74+
7575
return temp;
7676
});
7777

src/app/(dashboard)/stats/filters.ts

+18-28
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,16 @@ export const createQuestionnaireResponseFilters = (
2727
if (date) {
2828
if (typeof date === "string") {
2929
date = [date];
30-
} else {
31-
query.add(
32-
"_tag",
33-
date
34-
.map(
35-
(d) =>
36-
`https://d-tree.org/fhir/created-on-tag|${format(
37-
d,
38-
"dd/MM/yyyy"
39-
)}`
40-
)
41-
.join(",")
42-
);
43-
date.forEach((d) => {});
4430
}
31+
query.add(
32+
"_tag",
33+
date
34+
.map(
35+
(d) =>
36+
`https://d-tree.org/fhir/created-on-tag|${format(d, "dd/MM/yyyy")}`
37+
)
38+
.join(",")
39+
);
4540
}
4641
return query.toUrl("/QuestionnaireResponse");
4742
};
@@ -61,21 +56,16 @@ export const createPatientFilters = (
6156
if (date) {
6257
if (typeof date === "string") {
6358
date = [date];
64-
} else {
65-
query.add(
66-
"_tag",
67-
date
68-
.map(
69-
(d) =>
70-
`https://d-tree.org/fhir/created-on-tag|${format(
71-
d,
72-
"dd/MM/yyyy"
73-
)}`
74-
)
75-
.join(",")
76-
);
77-
date.forEach((d) => {});
7859
}
60+
query.add(
61+
"_tag",
62+
date
63+
.map(
64+
(d) =>
65+
`https://d-tree.org/fhir/created-on-tag|${format(d, "dd/MM/yyyy")}`
66+
)
67+
.join(",")
68+
);
7969
}
8070
if (types) {
8171
query.add(

0 commit comments

Comments
 (0)