Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Jul 16, 2024
1 parent 8e77543 commit c9a8f22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/app/(dashboard)/stats/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { fetchBundle } from "@/lib/fhir/bundle";
import { LocationData, SummaryItem } from "@/lib/models/types";
import { FilterFormData } from "@/model/filters";
import { fhirR4 } from "@smile-cdr/fhirts";
import { format } from "date-fns";
import { QueryParam, fixDate } from "./model";
import { fixDate } from "./model";
import {
createPatientFilters,
createQuestionnaireResponseFilters,
Expand Down Expand Up @@ -34,7 +33,9 @@ export async function fetchData(formData: FormData) {
let rawDate: string | null = null;
const baseFilter = data.filters.map((filter) => {
const temp: Record<string, string> = {};

if (filter.template == "_tag_location") {
console.log(filter);
const template = `http://smartregister.org/fhir/location-tag|${
filter.params[0].value ?? ""
}`;
Expand All @@ -53,6 +54,7 @@ export async function fetchData(formData: FormData) {
if (rawDate) {
rawDate = fixDate(rawDate);
}


const bundle = await fetchBundle([
createQuestionnaireResponseFilters(
Expand Down
4 changes: 2 additions & 2 deletions src/app/(dashboard)/stats/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createQuestionnaireResponseFilters = (

query.remove("date");
if (date) {
query.set(
query.add(
"_tag",
`https://d-tree.org/fhir/created-on-tag|${format(date, "dd/MM/yyyy")}`
);
Expand All @@ -44,7 +44,7 @@ export const createPatientFilters = (

query.remove("date");
if (date) {
query.set(
query.add(
"_tag",
`https://d-tree.org/fhir/created-on-tag|${format(date, "dd/MM/yyyy")}`
);
Expand Down
8 changes: 7 additions & 1 deletion src/app/(dashboard)/stats/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export class QueryParam {
}

add(key: string, value: any) {
console.log(key,this.queries.has(key) );

if (this.queries.has(key)) {
this.queries.set(`${key}[${randomInt(100)}]`, value);
this.queries.set(`${key}[${Math.random()}]`, value);
} else {
this.queries.set(key, value);
}
Expand Down Expand Up @@ -46,9 +48,13 @@ export class QueryParam {
for (const key in values) {
this.from(values[key]);
}
console.log(values);
console.log(this.queries);

}

toUrl( resources: string,) {
console.log(this.queries);
const query = Array.from(this.queries)
.map(([key, value]) => {
if (key.includes("[")) {
Expand Down

0 comments on commit c9a8f22

Please sign in to comment.