diff --git a/src/app/(dashboard)/stats/actions.ts b/src/app/(dashboard)/stats/actions.ts index edc322f..3e40b26 100644 --- a/src/app/(dashboard)/stats/actions.ts +++ b/src/app/(dashboard)/stats/actions.ts @@ -41,10 +41,7 @@ export async function fetchData(formData: FormData) { filter.params[0].value ?? "" }`; temp["_tag"] = template; - } else { - temp[filter.template] = filter.params[0].value ?? ""; - } - if (filter.params.find((e) => e.name == "date")) { + } else if (filter.template == "date") { rawDate = filter.params.find((e) => e.name == "date")?.value?.split("T")[0] ?? null; @@ -71,7 +68,10 @@ export async function fetchData(formData: FormData) { rawDate = [from.split("T")[0]]; } } + } else { + temp[filter.template] = filter.params[0].value ?? ""; } + return temp; }); diff --git a/src/app/(dashboard)/stats/filters.ts b/src/app/(dashboard)/stats/filters.ts index 5c6e652..ed4b180 100644 --- a/src/app/(dashboard)/stats/filters.ts +++ b/src/app/(dashboard)/stats/filters.ts @@ -27,21 +27,16 @@ export const createQuestionnaireResponseFilters = ( if (date) { if (typeof date === "string") { date = [date]; - } else { - query.add( - "_tag", - date - .map( - (d) => - `https://d-tree.org/fhir/created-on-tag|${format( - d, - "dd/MM/yyyy" - )}` - ) - .join(",") - ); - date.forEach((d) => {}); } + query.add( + "_tag", + date + .map( + (d) => + `https://d-tree.org/fhir/created-on-tag|${format(d, "dd/MM/yyyy")}` + ) + .join(",") + ); } return query.toUrl("/QuestionnaireResponse"); }; @@ -61,21 +56,16 @@ export const createPatientFilters = ( if (date) { if (typeof date === "string") { date = [date]; - } else { - query.add( - "_tag", - date - .map( - (d) => - `https://d-tree.org/fhir/created-on-tag|${format( - d, - "dd/MM/yyyy" - )}` - ) - .join(",") - ); - date.forEach((d) => {}); } + query.add( + "_tag", + date + .map( + (d) => + `https://d-tree.org/fhir/created-on-tag|${format(d, "dd/MM/yyyy")}` + ) + .join(",") + ); } if (types) { query.add(