continue order test: bugfix

This commit is contained in:
faiztyanirh 2026-04-28 17:39:27 +07:00
parent 24f1eaf985
commit 30fcc22ffd
4 changed files with 42 additions and 25 deletions

View File

@ -4,6 +4,7 @@ export function useSearch(searchFields, searchApiFunction) {
let searchData = $state([]); let searchData = $state([]);
let selectOptions = $state({}); let selectOptions = $state({});
let loadingOptions = $state({}); let loadingOptions = $state({});
let isRefreshData = $state(false);
function initializeSearchQuery(fields) { function initializeSearchQuery(fields) {
const query = {}; const query = {};
@ -63,6 +64,8 @@ export function useSearch(searchFields, searchApiFunction) {
get isLoading() { return isLoading; }, get isLoading() { return isLoading; },
get loadingOptions() { return loadingOptions; }, get loadingOptions() { return loadingOptions; },
get selectOptions() { return selectOptions; }, get selectOptions() { return selectOptions; },
get isRefreshData() { return isRefreshData; },
set isRefreshData(val) { isRefreshData = val; },
handleSearch, handleSearch,
handleReset, handleReset,
fetchOptions, fetchOptions,

View File

@ -10,7 +10,21 @@ export const orderTestSchema = z.object({
}) })
) )
.min(1, " "), .min(1, " "),
TrnDate: z.string(),
EffDate: z.string(),
}) })
.superRefine((data, ctx) => {
const trn = new Date(data.TrnDate);
const eff = new Date(data.EffDate);
if (trn > eff) {
console.log('ff')
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: 'Cant set before Trn Date',
path: ['EffDate']
});
}
});
export const orderTestInitialForm = { export const orderTestInitialForm = {
InternalOID: '', InternalOID: '',
@ -19,7 +33,6 @@ export const orderTestInitialForm = {
InternalPID: '', InternalPID: '',
SiteID: '', SiteID: '',
PVADTID: '', PVADTID: '',
ReqApp: '',
Priority: '', Priority: '',
TrnDate: '', TrnDate: '',
EffDate: '', EffDate: '',
@ -30,6 +43,7 @@ export const orderTestInitialForm = {
export const orderTestDefaultErrors = { export const orderTestDefaultErrors = {
Tests: '', Tests: '',
EffDate: '',
}; };
export const orderTestFormFields = [ export const orderTestFormFields = [
@ -66,12 +80,6 @@ export const orderTestFormFields = [
required: false, required: false,
type: "text", type: "text",
}, },
{
key: "ReqApp",
label: "Requested Application",
required: false,
type: "text",
},
] ]
}, },
{ {
@ -89,7 +97,8 @@ export const orderTestFormFields = [
label: "Effective Date", label: "Effective Date",
required: false, required: false,
type: "datetime", type: "datetime",
allowFuture: true allowFuture: true,
validateOn: ['input']
}, },
] ]
}, },

View File

@ -27,16 +27,15 @@
let visitData = $state(null); let visitData = $state(null);
let isLoadingVisit = $state(false); let isLoadingVisit = $state(false);
let hasFetched = $state(false); let hasFetched = $state(false);
let isRefreshData = $state(false);
const search = useSearch(searchFields, searchParam); const search = useSearch(searchFields, searchParam);
const handlers = { const handlers = {
refresh: async () => { refresh: async () => {
isRefreshData = true; search.isRefreshData = true;
try { try {
await handlePatientConfirm(tempSelectedPatient, tempSelectedVisit); await handlePatientConfirm(tempSelectedPatient, tempSelectedVisit);
} finally { } finally {
isRefreshData = false; search.isRefreshData = false;
} }
} }
}; };
@ -152,7 +151,7 @@
</div> </div>
{/if} {/if}
<div class="flex-1 w-full h-full relative overflow-hidden"> <div class="flex-1 w-full h-full relative overflow-hidden">
{#if isRefreshData} {#if search.isRefreshData}
<div class="absolute inset-0 flex items-center justify-center bg-background/50 z-10"> <div class="absolute inset-0 flex items-center justify-center bg-background/50 z-10">
<Spinner class="size-6" /> <Spinner class="size-6" />
</div> </div>

View File

@ -163,6 +163,7 @@
selectedTests = [...pendingTests]; selectedTests = [...pendingTests];
}); });
$inspect(formState.errors)
</script> </script>
{#snippet Fieldset({ {#snippet Fieldset({
@ -179,7 +180,8 @@
labelKey, labelKey,
withLabel = true, withLabel = true,
})} })}
<div class="flex w-full flex-col min-h-0 flex-1 h-full gap-1.5 overflow-hidden"> <!-- <div class="flex w-full flex-col min-h-0 flex-1 h-full gap-1.5"> -->
<div class="flex w-full flex-col min-h-0 gap-1.5 {type === 'tests' ? 'flex-1 h-full overflow-hidden' : ''}">
{#if withLabel} {#if withLabel}
<div class="flex justify-between items-center w-full"> <div class="flex justify-between items-center w-full">
<div class="ps-1"> <div class="ps-1">
@ -190,7 +192,8 @@
{/if} {/if}
</div> </div>
{/if} {/if}
<div class="relative flex flex-col h-full items-start w-full flex-1 p-1 overflow-hidden"> <!-- <div class="relative flex flex-col h-full items-start w-full flex-1 p-1"> -->
<div class="relative flex flex-col items-start w-full {type === 'tests' ? 'h-full flex-1' : ''} p-1">
{#if type === 'text'} {#if type === 'text'}
<Input <Input
type="text" type="text"
@ -283,7 +286,7 @@
</div> </div>
{:else if type === "tests"} {:else if type === "tests"}
<div class="flex flex-1 h-full min-h-0 w-full gap-2"> <div class="flex flex-1 h-full min-h-0 w-full gap-2">
<div class="flex flex-1 flex-col gap-2 overflow-hidden min-h-0 h-full w-full"> <div class="flex flex-1 flex-col gap-2 overflow-hidden min-h-0 h-full w-full p-1">
<div class="shrink-0 h-18 flex gap-2 flex flex-col"> <div class="shrink-0 h-18 flex gap-2 flex flex-col">
<div class="h-7 border-b-2 flex justify-between items-center"> <div class="h-7 border-b-2 flex justify-between items-center">
<p class="text-xs font-medium text-muted-foreground uppercase tracking-wide">Test list</p> <p class="text-xs font-medium text-muted-foreground uppercase tracking-wide">Test list</p>
@ -367,7 +370,7 @@
</Button> </Button>
</div> </div>
</div> </div>
<div class="flex flex-1 flex-col overflow-hidden min-h-0 h-full w-1/2 gap-2"> <div class="flex flex-1 flex-col overflow-hidden min-h-0 h-full gap-2 p-1">
<div class="shrink-0 h-7 border-b-2 flex justify-between items-center"> <div class="shrink-0 h-7 border-b-2 flex justify-between items-center">
<p class="text-xs font-medium text-muted-foreground uppercase tracking-wide">Test ordered</p> <p class="text-xs font-medium text-muted-foreground uppercase tracking-wide">Test ordered</p>
<Badge variant="outline">{pendingTests.length} test(s)</Badge> <Badge variant="outline">{pendingTests.length} test(s)</Badge>
@ -416,19 +419,22 @@
placeholder="Custom field type: {type}" placeholder="Custom field type: {type}"
/> />
{/if} {/if}
<div class="absolute top-8 min-h-[1rem] w-full">
{#if type !== 'tests'}
<div class="h-5 w-full">
{#if formState.errors[key]} {#if formState.errors[key]}
<span class="text-destructive text-sm leading-none"> <span class="text-destructive text-sm leading-none">
{formState.errors[key]} {formState.errors[key]}
</span> </span>
{/if} {/if}
</div> </div>
{/if}
</div> </div>
</div> </div>
{/snippet} {/snippet}
{#snippet GroupBlock(groups)} {#snippet GroupBlock(groups)}
<div class="p-2 min-h-0 flex-1 flex flex-col h-full"> <div class="p-2 min-h-0 flex-1 flex flex-col h-full space-y-6">
{#each groups as group} {#each groups as group}
<div class="flex flex-col flex-1 space-y-4 h-full"> <div class="flex flex-col flex-1 space-y-4 h-full">
{#if group.title} {#if group.title}
@ -439,7 +445,7 @@
{#each group.rows as row} {#each group.rows as row}
<div <div
class="grid grid-cols-1 grid-rows-1 space-y-2 h-full gap-3 min-h-0 md:gap-2" class="grid grid-cols-1 gap-3 min-h-0 md:gap-2"
class:h-full={row.columns.some(col => col.key === "Tests")} class:h-full={row.columns.some(col => col.key === "Tests")}
class:md:grid-cols-1={row.columns.length === 1} class:md:grid-cols-1={row.columns.length === 1}
class:md:grid-cols-2={row.columns.length === 2} class:md:grid-cols-2={row.columns.length === 2}