diff --git a/src/lib/api/api-client.js b/src/lib/api/api-client.js index c929ee8..d4eb0be 100644 --- a/src/lib/api/api-client.js +++ b/src/lib/api/api-client.js @@ -40,7 +40,6 @@ export async function searchWithParams(endpoint, searchQuery) { const url = params ? `${API.BASE_URL}${endpoint}?${params}` : `${API.BASE_URL}${endpoint}`; - const res = await fetch(url); const data = await res.json(); return data.data || []; diff --git a/src/lib/components/app-sidebar.svelte b/src/lib/components/app-sidebar.svelte index 945ccf8..fa7fbe1 100644 --- a/src/lib/components/app-sidebar.svelte +++ b/src/lib/components/app-sidebar.svelte @@ -23,12 +23,21 @@ title: "Patient", url: "/patient", icon: LifeBuoyIcon, + submenus: [ + { + title: "Patient List", + url: "/list", + }, + { + title: "Patient Admission", + url: "/admission", + }, + ], }, { title: "Order", url: "/order", icon: LifeBuoyIcon, - isActive: false, submenus: [ { title: "Test Order", @@ -40,20 +49,20 @@ dictionary: [ { title: "Admission", - url: "#", + url: "/admission", icon: LifeBuoyIcon, submenus: [ { title: "Contact", - url: "#", + url: "/contact", }, { title: "Location", - url: "#", + url: "/location", }, { title: "Occupation", - url: "#", + url: "/occupation", }, ], }, diff --git a/src/lib/components/composable/use-search.svelte.js b/src/lib/components/composable/use-search.svelte.js index 2c37b00..8b1b38f 100644 --- a/src/lib/components/composable/use-search.svelte.js +++ b/src/lib/components/composable/use-search.svelte.js @@ -18,7 +18,7 @@ export function useSearch(searchFields, searchApiFunction) { async function handleSearch() { isLoading = true; try { - searchData = await searchApiFunction(searchQuery); + searchData = await searchApiFunction(searchQuery); } catch (error) { console.error('Search failed:', error); } finally { diff --git a/src/lib/components/nav-dictionary.svelte b/src/lib/components/nav-dictionary.svelte index d000d9a..f97eb11 100644 --- a/src/lib/components/nav-dictionary.svelte +++ b/src/lib/components/nav-dictionary.svelte @@ -1,61 +1,115 @@ Dictionary - {#each dictionary as item (item.title)} - - - - {#snippet child({ props })} - - - {item.title} - + {#each dictionary as item, index} + {#if sidebar.state === "expanded"} + + {#snippet child({ props })} + + + {#snippet child({ props })} + {#if item.submenus?.length} + + + {item.title} + + {:else} + + + {item.title} + + {/if} + {/snippet} + + {#if item.submenus?.length} + + {#snippet child({ props })} + + + Toggle + + {/snippet} + + + + {#each item.submenus as subItem (subItem.title)} + + + {subItem.title} + + + {/each} + + + {/if} + + {/snippet} + + {:else} + openPopovers[index] = open}> + + {#snippet trigger(props)} + + + {#if item.icon && !item.submenu} + + {/if} + {item.title} + + {/snippet} - - {#if item.items?.length} - - {#snippet child({ props })} - - - Toggle - - {/snippet} - - - - {#each item.items as subItem (subItem.title)} - - - {subItem.title} - - + {@render trigger()} + + + + + + + {/if} {/each} \ No newline at end of file diff --git a/src/lib/components/nav-main.svelte b/src/lib/components/nav-main.svelte index 649a6f0..582843b 100644 --- a/src/lib/components/nav-main.svelte +++ b/src/lib/components/nav-main.svelte @@ -89,7 +89,7 @@ {#each item.submenus || [] as submenu} - openPopovers[item.url] = false} class="flex items-center rounded-md px-2 py-1.5 text-sm hover:bg-accent" class:bg-accent={$page.url.pathname === submenu.url} diff --git a/src/lib/components/patient/admission/api/patient-admission-api.js b/src/lib/components/patient/admission/api/patient-admission-api.js new file mode 100644 index 0000000..c1499d1 --- /dev/null +++ b/src/lib/components/patient/admission/api/patient-admission-api.js @@ -0,0 +1,26 @@ +import { API } from '$lib/config/api.js'; +import { getById, searchWithParams, create, update } from '$lib/api/api-client'; + +export async function searchParam(searchQuery) { + return await searchWithParams(API.PATIENTS, searchQuery) +} + +export async function getVisit(searchQuery) { + const { data: visit, error } = await getById(API.VISITLIST, searchQuery) + return { visit }; +} + +export async function getPatient(searchQuery) { + const { data: patient, error } = await getById(API.PATIENTS, searchQuery) + return { patient }; +} + +export async function createPatient(newContactForm) { + // console.log(JSON.stringify(newContactForm)); + return await create(API.PATIENTS, newContactForm) +} + +export async function editPatient(editContactForm) { + // console.log(JSON.stringify(editContactForm)); + return await update(API.PATIENTS, editContactForm) +} \ No newline at end of file diff --git a/src/lib/components/patient/admission/config/admission-config.js b/src/lib/components/patient/admission/config/admission-config.js new file mode 100644 index 0000000..c4b8229 --- /dev/null +++ b/src/lib/components/patient/admission/config/admission-config.js @@ -0,0 +1,54 @@ +import PlusIcon from "@lucide/svelte/icons/plus"; +import Settings2Icon from "@lucide/svelte/icons/settings-2"; + +export const searchFields = [ + { + key: "PatientID", + label: "Patient ID", + placeholder: "", + type: "text", + defaultValue: "", + }, + { + key: "Name", + label: "Patient Name", + placeholder: "", + type: "text", + defaultValue: "", + }, + { + key: "Birthdate", + label: "Birthdate", + type: "date" + }, + { + key: "Identifier", + label: "Identifier", + type: "text" + }, + { + key: "VisitID", + label: "Visit ID", + type: "text" + }, + { + key: "EpisodeID", + label: "Episode ID", + type: "text" + }, +]; + +export function admissionActions(masterDetail) { + return [ + { + Icon: PlusIcon, + label: 'Add Visit', + onClick: masterDetail.enterCreate, + }, + { + Icon: Settings2Icon, + label: 'Search Parameters', + popoverWidth: "w-256", + }, + ]; +} \ No newline at end of file diff --git a/src/lib/components/patient/admission/config/admission-form-config.js b/src/lib/components/patient/admission/config/admission-form-config.js new file mode 100644 index 0000000..e69de29 diff --git a/src/lib/components/patient/admission/modal/search-param-modal.svelte b/src/lib/components/patient/admission/modal/search-param-modal.svelte new file mode 100644 index 0000000..c012425 --- /dev/null +++ b/src/lib/components/patient/admission/modal/search-param-modal.svelte @@ -0,0 +1,74 @@ + + +
+
+
+
+ {#each props.searchFields as field} + {#if field.type === "text"} +
+ + +
+ {:else if field.type === "date"} +
+ +
+ {:else if field.type === "select"} +
+ + + + + + + {#each field.options as opt} + + {opt.label} + + {/each} + + +
+ {/if} + {/each} +
+
+ + +
+
+
+ {#if props.search.searchData && props.search.searchData.length > 0} + + {:else} +
+ +
+ {/if} +
+
+
\ No newline at end of file diff --git a/src/lib/components/patient/admission/page/create-page.svelte b/src/lib/components/patient/admission/page/create-page.svelte new file mode 100644 index 0000000..4649907 --- /dev/null +++ b/src/lib/components/patient/admission/page/create-page.svelte @@ -0,0 +1 @@ +cr \ No newline at end of file diff --git a/src/lib/components/patient/admission/page/edit-page.svelte b/src/lib/components/patient/admission/page/edit-page.svelte new file mode 100644 index 0000000..9a58f89 --- /dev/null +++ b/src/lib/components/patient/admission/page/edit-page.svelte @@ -0,0 +1 @@ +ed \ No newline at end of file diff --git a/src/lib/components/patient/admission/page/master-page.svelte b/src/lib/components/patient/admission/page/master-page.svelte new file mode 100644 index 0000000..72ca18c --- /dev/null +++ b/src/lib/components/patient/admission/page/master-page.svelte @@ -0,0 +1,65 @@ + + +{#snippet searchParamSnippet()} + + +{/snippet} + +
props.masterDetail.isFormMode && props.masterDetail.exitForm()} + onkeydown={(e) => e.key === 'Enter' && props.masterDetail.isFormMode && props.masterDetail.exitForm()} + class={` + ${props.masterDetail.isMobile ? "w-full" : props.masterDetail.isFormMode ? "w-[3%] cursor-pointer" : "w-[35%]"} + transition-all duration-300 flex flex-col items-center p-2 h-full overflow-y-auto + `} +> +
+ {#if props.masterDetail.isFormMode} + + {#each "ADMISSION".split("") as c} + {c} + {/each} + + {/if} + + {#if !props.masterDetail.isFormMode} +
e.stopPropagation()} onkeydown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + e.stopPropagation(); + } + }}> + +
+ +
+ +
+ +
+
+ {/if} +
+
\ No newline at end of file diff --git a/src/lib/components/patient/admission/page/view-page.svelte b/src/lib/components/patient/admission/page/view-page.svelte new file mode 100644 index 0000000..3e0b9eb --- /dev/null +++ b/src/lib/components/patient/admission/page/view-page.svelte @@ -0,0 +1 @@ +vw \ No newline at end of file diff --git a/src/lib/components/patient/admission/table/patient-colums.js b/src/lib/components/patient/admission/table/patient-colums.js new file mode 100644 index 0000000..064caad --- /dev/null +++ b/src/lib/components/patient/admission/table/patient-colums.js @@ -0,0 +1,23 @@ +export const patientColumns = [ + { + accessorKey: "PatientID", + header: "PatientID", + }, + { + accessorKey: "FullName", + header: "Patient Name", + }, + { + accessorKey: "SexLabel", + header: "Sex", + }, + { + accessorKey: "Birthdate", + header: "Birthdate", + cell: ({ getValue }) => { + const value = getValue(); + if (!value) return ""; + return value.split(' ')[0]; + } + }, +]; \ No newline at end of file diff --git a/src/lib/components/patient/admission/table/visit-columns.js b/src/lib/components/patient/admission/table/visit-columns.js new file mode 100644 index 0000000..d1f736a --- /dev/null +++ b/src/lib/components/patient/admission/table/visit-columns.js @@ -0,0 +1,6 @@ +export const visitColumns = [ + { + accessorKey: "PVID", + header: "Visit ID", + }, +]; \ No newline at end of file diff --git a/src/lib/components/patient/api/patient-api.js b/src/lib/components/patient/list/api/patient-list-api.js similarity index 100% rename from src/lib/components/patient/api/patient-api.js rename to src/lib/components/patient/list/api/patient-list-api.js diff --git a/src/lib/components/patient/config/patient-config.js b/src/lib/components/patient/list/config/patient-config.js similarity index 100% rename from src/lib/components/patient/config/patient-config.js rename to src/lib/components/patient/list/config/patient-config.js diff --git a/src/lib/components/patient/config/patient-form-config.js b/src/lib/components/patient/list/config/patient-form-config.js similarity index 100% rename from src/lib/components/patient/config/patient-form-config.js rename to src/lib/components/patient/list/config/patient-form-config.js diff --git a/src/lib/components/patient/modal/custodian-modal.svelte b/src/lib/components/patient/list/modal/custodian-modal.svelte similarity index 97% rename from src/lib/components/patient/modal/custodian-modal.svelte rename to src/lib/components/patient/list/modal/custodian-modal.svelte index 247ba7f..a8f647b 100644 --- a/src/lib/components/patient/modal/custodian-modal.svelte +++ b/src/lib/components/patient/list/modal/custodian-modal.svelte @@ -1,18 +1,18 @@ + +
+ {#if masterDetail.showMaster} + + {/if} + + {#if masterDetail.showDetail} +
+ {#if masterDetail.mode === "view"} + + {:else if masterDetail.mode === "create"} + + {:else if masterDetail.mode === "edit"} + + {/if} +
+ {/if} +
\ No newline at end of file diff --git a/src/routes/patient/+page.svelte b/src/routes/patient/list/+page.svelte similarity index 70% rename from src/routes/patient/+page.svelte rename to src/routes/patient/list/+page.svelte index 6fcfe16..841a6e4 100644 --- a/src/routes/patient/+page.svelte +++ b/src/routes/patient/list/+page.svelte @@ -1,11 +1,11 @@