-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
export default async function Page({ | ||
params, | ||
}: { | ||
params: { list: string, id: string }; | ||
}) { | ||
return <div>{params.list}</div>; | ||
} | ||
|
||
params, | ||
}: { | ||
params: { list: string; id: string }; | ||
}) { | ||
return <div>{params.list}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { fhirServer } from "@/lib/api/axios"; | ||
import { fhirR4 } from "@smile-cdr/fhirts"; | ||
|
||
interface CarePlanListItem { | ||
id: string; | ||
title: string; | ||
status: string; | ||
intent: string; | ||
period?: Date | string; | ||
visit: string; | ||
} | ||
|
||
export const fetchData = async (id: string): Promise<CarePlanListItem[] | null> => { | ||
try { | ||
const res = await fhirServer.get("/CarePlan", { | ||
params: { | ||
subject: id, | ||
_sort: "-date", | ||
}, | ||
}); | ||
|
||
const carePlans: CarePlanListItem[] = res.data.entry.map((entry: any) => { | ||
const resource = entry.resource as fhirR4.CarePlan; | ||
const data: CarePlanListItem = { | ||
id: resource.id ?? "", | ||
title: resource.title ?? "NA", | ||
status: resource.status ?? "NA", | ||
intent: resource.intent ?? "NA", | ||
period: resource.period?.start, | ||
visit: | ||
resource.category?.find( | ||
(e) => | ||
e?.coding?.[0].system == | ||
"https://d-tree.org/fhir/care-plan-visit-number" | ||
)?.coding?.[0].code ?? "NA", | ||
}; | ||
return data; | ||
}); | ||
|
||
return carePlans; | ||
} catch (error) { | ||
console.error(error); | ||
return null; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "react"; | ||
import { fetchData } from "./fetch"; | ||
|
||
type Props = { | ||
params: { id: string }; | ||
}; | ||
|
||
const Visits = async ({ params: { id } }: Props) => { | ||
const data = await fetchData(id); | ||
return ( | ||
<div className="container"> | ||
<div className="flex flex-col gap-4 w-full"> | ||
{data?.map((item) => ( | ||
<div | ||
key={item.id} | ||
className="card card-compact bg-base-100 shadow-xl w-full" | ||
> | ||
<div className="card-body"> | ||
<h2 className="card-title">{item.title}</h2> | ||
<div className="flex flex-row gap-2"> | ||
<span className="badge">Visit {item.visit}</span> | ||
<span className="badge badge-primary"> | ||
Status {item.status} | ||
</span> | ||
<span className="badge">Intent {item.intent}</span> | ||
</div> | ||
<p>{item.period?.toString()}</p> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Visits; |